diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-04 21:21:30 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-03-04 21:21:30 -0500 |
commit | d54fe7c1f704a63824c5bfa0ece65245572e9b27 (patch) | |
tree | afc52015ffc2c74e0266653eecef1c8ef8ba5d91 /src/slalib/random.f_convex | |
download | calfuse-d54fe7c1f704a63824c5bfa0ece65245572e9b27.tar.gz |
Initial commit
Diffstat (limited to 'src/slalib/random.f_convex')
-rw-r--r-- | src/slalib/random.f_convex | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/slalib/random.f_convex b/src/slalib/random.f_convex new file mode 100644 index 0000000..336983f --- /dev/null +++ b/src/slalib/random.f_convex @@ -0,0 +1,56 @@ + REAL FUNCTION sla_RANDOM (SEED) +*+ +* - - - - - - - +* R A N D O M +* - - - - - - - +* +* Generate pseudo-random real number in the range 0 <= X < 1. +* (single precision) +* +* !!! Convex dependent !!! +* +* Given: +* SEED real an arbitrary real number +* +* Notes: +* +* 1) The result is a pseudo-random REAL number in the range +* 0 <= sla_RANDOM < 1. +* +* 2) SEED is used first time through only. +* +* Called: RAND (a REAL function from the Convex Fortran Library) +* +* P.T.Wallace Starlink 28 June 1994 +* +* Copyright (C) 1995 Rutherford Appleton Laboratory +*- + + IMPLICIT NONE + + REAL SEED + + REAL RAND + + REAL AS + INTEGER ISEED + LOGICAL FIRST + SAVE FIRST + DATA FIRST /.TRUE./ + + + +* If first time, turn SEED into a large, odd integer, and start the +* generator + IF (FIRST) THEN + AS=ABS(SEED)+1.0 + ISEED=NINT(AS/10.0**(NINT(ALOG10(AS))-6)) + IF (MOD(ISEED,2).EQ.0) ISEED=ISEED+1 + FIRST=.FALSE. + AS=RAND(ISEED) + END IF + +* Next pseudo-random number + sla_RANDOM=RAND(0) + + END |