1377 |
implicit none |
implicit none |
1378 |
integer n,iras,nrnd,myid |
integer n,iras,nrnd,myid |
1379 |
_RL random_numbx |
_RL random_numbx |
1380 |
_RL rnd(nrnd) |
c _RL rnd(nrnd) |
1381 |
|
_RL rnd(*) |
1382 |
integer irm |
integer irm |
1383 |
parameter (irm = 1000) |
parameter (irm = 1000) |
1384 |
_RL random(irm) |
_RL random(irm) |
1385 |
integer i,mcheck,numrand,iseed,indx |
integer i,mcheck,iseed,indx |
1386 |
logical first |
logical first |
1387 |
data first /.true./ |
data first /.true./ |
1388 |
integer iras0 |
integer iras0 |
1389 |
data iras0 /0/ |
data iras0 /0/ |
1390 |
save random, iras0 |
save random, iras0 |
1391 |
|
|
1392 |
if(nrnd.eq.0.)then |
if(nrnd.eq.0)then |
1393 |
do i = 1,nrnd |
do i = 1,nrnd |
1394 |
rnd(i) = 0 |
rnd(i) = 0 |
1395 |
enddo |
enddo |
1399 |
|
|
1400 |
mcheck = mod(iras-1,irm/nrnd) |
mcheck = mod(iras-1,irm/nrnd) |
1401 |
|
|
|
c First Time In From a Continuing RESTART (IRAS.GT.1) or Reading a New RESTART |
|
|
c ---------------------------------------------------------------------------- |
|
1402 |
c print *,' RNDCLOUD: first ',first,' iras ',iras,' iras0 ',iras0 |
c print *,' RNDCLOUD: first ',first,' iras ',iras,' iras0 ',iras0 |
1403 |
c print *,' RNDCLOUD: irm,nrnd,mcheck=',irm,nrnd,mcheck |
c print *,' RNDCLOUD: irm,nrnd,mcheck=',irm,nrnd,mcheck |
1404 |
if( first.and.(iras.gt.1) .or. iras.ne.iras0+1 )then |
|
1405 |
print *,' first ',first,' iras ',iras,' iras0 ',iras0 |
if ( iras.eq.iras0 ) then |
1406 |
if( myid.eq.1 ) print *, 'Recreating Rand Numb Array in RNDCLOUD' |
C- Not the 1rst tile: we are all set (already done for the 1rst tile): |
1407 |
if( myid.eq.1 ) print *, 'IRAS: ',iras,' IRAS0: ',iras0 |
c ----------------------------------------------------------------------- |
1408 |
numrand = mod(iras,irm/nrnd) * nrnd |
indx = (iras-1)*nrnd |
1409 |
iseed = iras * nrnd - numrand |
|
1410 |
|
c First Time In From a Continuing RESTART (IRAS.GT.1) or Reading a New RESTART |
1411 |
|
c -- or -- |
1412 |
|
c Multiple Time In But have Used Up all 1000 numbers (MCHECK.EQ.0) |
1413 |
|
c ---------------------------------------------------------------------------- |
1414 |
|
elseif ( first.and.(iras.gt.1) .or. mcheck.eq.0 ) then |
1415 |
|
iseed = (iras-1-mcheck)*nrnd |
1416 |
call random_seedx(iseed) |
call random_seedx(iseed) |
1417 |
do i = 1,irm |
do i = 1,irm |
1418 |
random(i) = random_numbx(iseed) |
random(i) = random_numbx(iseed) |
1419 |
enddo |
enddo |
1420 |
indx = (iras-1)*nrnd |
indx = (iras-1)*nrnd |
1421 |
|
|
1422 |
c Multiple Time In But have Used Up all 1000 numbers (MCHECK.EQ.0) |
if( myid.eq.1 ) print *, 'Creating Rand Numb Array in RNDCLOUD' |
1423 |
c ---------------------------------------------------------------- |
& ,', iseed=', iseed |
1424 |
else if (mcheck.eq.0) then |
if( myid.eq.1 ) print *, 'IRAS: ',iras,' IRAS0: ',iras0, |
1425 |
iseed = (iras-1)*nrnd |
& ' indx: ', mod(indx,irm) |
|
call random_seedx(iseed) |
|
|
do i = 1,irm |
|
|
random(i) = random_numbx(iseed) |
|
|
enddo |
|
|
indx = iseed |
|
1426 |
|
|
1427 |
c Multiple Time In But have NOT Used Up all 1000 numbers (MCHECK.NE.0) |
c Multiple Time In But have NOT Used Up all 1000 numbers (MCHECK.NE.0) |
1428 |
c -------------------------------------------------------------------- |
c -------------------------------------------------------------------- |
1431 |
endif |
endif |
1432 |
|
|
1433 |
indx = mod(indx,irm) |
indx = mod(indx,irm) |
1434 |
if( indx+nrnd.gt.1000 ) indx=1000-nrnd |
if( indx+nrnd.gt.irm ) then |
1435 |
|
c if( myid.eq.1 .AND. iras.ne.iras0 ) print *, |
1436 |
|
c & 'reach end of Rand Numb Array in RNDCLOUD',indx,irm-nrnd |
1437 |
|
indx=irm-nrnd |
1438 |
|
endif |
1439 |
|
|
1440 |
do n = 1,nrnd |
do n = 1,nrnd |
1441 |
rnd(n) = random(indx+n) |
rnd(n) = random(indx+n) |
1442 |
enddo |
enddo |
1444 |
100 continue |
100 continue |
1445 |
first = .false. |
first = .false. |
1446 |
iras0 = iras |
iras0 = iras |
1447 |
|
|
1448 |
return |
return |
1449 |
end |
end |
1450 |
function random_numbx(iseed) |
function random_numbx(iseed) |