Commit a38b2c25 by LEFEBVREJP email

Updating mergesort fortran indices to be int instead of float.

parent 2f0e652e
 ... ... @@ -12,7 +12,7 @@ implicit none integer :: i, imax, i0, j, jmax, k, L, L1, m, n real :: a(n) real :: indices(n) integer :: indices(n) real, allocatable :: b(:) allocate (b(n)) L1 = 1 ... ...
 Program run_merge implicit none external merge_sort integer :: n, i character (len=10) :: d1, d2, d3 integer :: time(8) real :: dtime1, dtime2 real, allocatable :: a(:) real, allocatable :: indices(:) integer, allocatable :: indices(:) call DATE_AND_TIME(d1, d2, d3, time) dtime1 = time(6)*60.+time(7)+time(8)/1000. n = 1000 n = 10000 allocate (a(n)) allocate (indices(n)) ! avoid unitialised value warning ... ... @@ -27,13 +28,13 @@ dtime1 = dtime2 - dtime1 print *, "setup time (s) =", dtime1 print *, "First/Last 10 elements before sorting" print "(10f12.3/10f12.0)", (a(i), i=1, 10), (indices(i), i=1, 10) print "(10f12.3/10f12.0)", (a(i), i=n-9, n), (indices(i), i=n-9, n) print "(10f12.3/10i10)", (a(i), i=1, 10), (indices(i), i=1, 10) print "(10f12.3/10i10)", (a(i), i=n-9, n), (indices(i), i=n-9, n) call merge_sort(n, a, indices) call DATE_AND_TIME(d1, d2, d3, time) print *, "First/Last 10 elements after sorting" print "(10f12.3/10f12.0)", (a(i), i=1, 10), (indices(i), i=1, 10) print "(10f12.3/10f12.0)", (a(i), i=n-9, n), (indices(i), i=n-9, n) print "(10f12.3/10i10)", (a(i), i=1, 10), (indices(i), i=1, 10) print "(10f12.3/10i10)", (a(i), i=n-9, n), (indices(i), i=n-9, n) dtime2 = time(6)*60.+time(7)+time(8)/1000.-dtime2 print *, "sort time (s) =", dtime2 do i=1, (n-1) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!