-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_range.f
More file actions
55 lines (41 loc) · 1.4 KB
/
set_range.f
File metadata and controls
55 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
subroutine set_range( N1, N2 )
c © 2002 – 2014 NorthWest Research Associates, Inc. All Rights Reserved
c Author: Thomas S. Lund, lund@cora.nwra.com
c *** Get ranges for x and z variables.
include 'sam.h'
logical write_ranges
character(3) num
write_ranges = .false.
c write_ranges = .true.
do i=0, numprocs-1
call range( 1, N1, numprocs, i, iz_s(i), iz_e(i) )
call range( 1, N2, numprocs, i, ix_s(i), ix_e(i) )
nx_p( i) = ix_e(i) - ix_s(i) + 1
nz_p( i) = iz_e(i) - iz_s(i) + 1
end do
ixs = ix_s(myid)
ixe = ix_e(myid)
nxp = nx_p(myid)
izs = iz_s(myid)
ize = iz_e(myid)
nzp = nz_p(myid)
if( write_ranges ) then
write(num,'(i3.3)') myid
open(unit=80,file='ranges.'//num)
write(80,5) ixs, ixe, izs, ize, nxp, nzp
5 format(6i6)
close(80)
end if
return
end
subroutine range( n1, n2, nprocs, irank, ista, iend )
c © 2002 – 2014 NorthWest Research Associates, Inc. All Rights Reserved
c Author: Thomas S. Lund, lund@cora.nwra.com
c *** The j. tuccillo range getter to balance load.
iwork1 = (n2 - n1 + 1)/nprocs
iwork2 = mod(n2 - n1 +1, nprocs)
ista = irank*iwork1 + n1 + min(irank,iwork2)
iend = ista + iwork1 - 1
if(iwork2 .gt. irank) iend = iend + 1
return
end