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_x86_64 | |
download | calfuse-d54fe7c1f704a63824c5bfa0ece65245572e9b27.tar.gz |
Initial commit
Diffstat (limited to 'src/slalib/random.f_x86_64')
-rw-r--r-- | src/slalib/random.f_x86_64 | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/slalib/random.f_x86_64 b/src/slalib/random.f_x86_64 new file mode 100644 index 0000000..acd1047 --- /dev/null +++ b/src/slalib/random.f_x86_64 @@ -0,0 +1,54 @@ + REAL FUNCTION sla_RANDOM (SEED) +*+ +* - - - - - - - +* R A N D O M +* - - - - - - - +* +* Generate pseudo-random real number in the range 0 <= X < 1. +* (single precision) +* +* !!! Version for Linux !!! +* +* 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: RANDOM (a REAL function compiled by the makefile from rtl_random.c) +* +* B.K.McIlwrath Starlink 12 January 1996 +*- + + IMPLICIT NONE + + REAL SEED + + REAL RANDOM + + REAL AS + INTEGER ISEED + LOGICAL FIRST + SAVE FIRST + DATA FIRST /.TRUE./ + + + +* If first time, turn SEED into a large, odd integer + 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. + ELSE + ISEED = 0 + END IF + +* Next pseudo-random number + sla_RANDOM=RANDOM(ISEED) + + END |