c move process back and forth between c waiting que and active status subroutine rshdw( numrep) integer numrep include "/usr4/vgr/include/rshcom.i" include "/usr4/vgr/include/rshio.i" include "/usr4/vgr/include/rshcmd.i" integer i, j, time, k, kin, kout, kk logical ll c move all waiting process into execution, if possible c move all completed process back to que c for now forget about priority of timing c loop through search C rhhstw status of remote request c 0 => not used c 1 => waiting th be submitted c 2 => being processed c 3 => finished & waiting to be returned C if ( rshmax .le. 0) call rshstrt do 1000 kk=1,numrep kin = 0 kout = 0 c loop through the waiting que do 900 i=1,rshfnx c if no process skip if (rshstw( i) .eq. 0 ) go to 900 c we are waiting for a get if (rshstw( i) .eq. 3 ) go to 900 c waiting for a remote process, is there one? if (rshstw( i) .eq. 1) then c look for a free process of right type do 200 k=1,rshmax c this process in use if ( rshtima( k) .ne. 0) then c has this process completed initilization if ( rshsida( k) .gt. rshmax) go to 200 rshin = rshina( k) inquire( file=rshin, exist=ll) if (ll) go to 200 c mark that initilization is finished rshtima( k) = 0 rshuida( k) = 0 rshsida( k) = 0 end if c not right type if ( rshnama( k) .ne. rshnamw(i)) go to 200 c send off correct one rshcomd = 'mv ' // rshfilw( i) // ' ' // | rshina(k) // '!' call syscmd( rshcomd,jj) rshcomd = 'rm ' // rshouta( k) // '!' call syscmd( rshcomd,jj) rshstw ( i) = 2 rshtypw( i) = k rshtima( k) = time() rshsida( k) = rshsidw( i) rshuida( k) = rshuidw( i) go to 900 200 continue c we did not find a free process kin = kin + 1 else c we have one that is processing, is it done j = rshtypw( i) rshin = rshina ( j) rshout = rshouta( j) inquire( file=rshin, exist=ll) c if input file exists, the job is still running if (ll) go to 900 c change name so that the outside world can see that joj is done ii = index( rshfilw( i), ' ') - 1 rshfilw( i) = rshfilw( i)(1:ii) // '.C' rshcomd = 'cp ' // rshout // ' ' // rshfilw( i ) // '! ' c copy output file over, other one will be removed by rshdo or rshdw call syscmd( rshcomd,jj) c mark that it is waiting to be gotten rshtypw( i) = 0 rshstw ( i) = 3 rshtima( j) = 0 rshuida( j) = 0 rshsida( j) = 0 kout = kout + 1 c we have freed up one process end if 900 continue c if we freed up process, and did not get enough , try again if (kin*kout .eq. 0) go to 1200 1000 continue 1200 continue return end