1
integer function nxtasksub(nproc,ichunk,p_handle)
10
data f1stcall /.true./
11
external util_tcesublock
12
integer util_tcesublock
15
integer nproc, ichunk ! [input]
18
integer icount, nleft, nxtval, junk
21
data nleft, icount /0, 0/
24
junk=util_tcesublock(0,p_handle)
29
c wrapper round nxtval() to increase granularity
30
c and thus reduce no. of requests to shared counter
32
c !! ichunk MUST not be changed during a parallel loop
33
c !! AND all processors MUST agree on the value
40
if(nproc.eq.ga_pgroup_nnodes(p_handle)) then
42
icount = util_tcesublock(nproc,p_handle) * ichunk
48
* else if (nproc.lt.0) then
49
else if (nproc.eq.-ga_pgroup_nnodes(p_handle)) then
52
junk = util_tcesublock(nproc,p_handle)
55
call errquit('nxtask: invalid nproc ', nproc, UNKNOWN_ERR)
58
c following does dumb static load balancing
62
call errquit('nxtask: STATIC DIST !!! ', nproc, UNKNOWN_ERR)
65
if (nleft .eq. 0) then
70
icount = icount + ga_nnodes()
78
c if(nxtasksub.eq.-1) call ga_pgroup_sync(p_handle)
80
c if(p_handle.eq.1) then
81
c write(6,*) ga_nodeid(), ' got task ', nxtasksub