-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRANUM.F
34 lines (28 loc) · 940 Bytes
/
RANUM.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FUNCTION RANUM()
COMMON /RAN/RRN(54), KRANUM, RLIMIT, NRNOPT, ITAPE
C RANDOM NUMBER RETURNED AS VALUE OF RANUM =.0-1. FROM SOURCE-
C -RANF(0), SYSTEM FUNCTION, IF NRNOPT=1
C -TAPE OF RANDOM NUMBERS IF NRNOPT=2, REQUIRES REQUEST I.E.
C -REQUEST(TAPE50,987,MT,HI,READ) IN CONTROL CARDS.
IF(NRNOPT-1) 2, 2, 20
C MTP: REPLACED RANF FROM CDC FORTRAN WITH GFORTRAN'S RAND
2 RANUM = RAND(0)
RETURN
20 KRANUM = KRANUM + 1
IF(KRANUM-55) 28, 26, 28
26 KRANUM = 1
28 IF(KRANUM-1) 50, 40, 50
C MTP: BROUGHT THIS IN BECAUSE GFORTRAN DIDN'T LIKE THE EOF IF STATEMENT
40 READ(ITAPE, IOSTAT=IOSTATUS) RRN
IF (IOSTATUS .NE. 0) THEN
REWIND ITAPE
GO TO 40
END IF
50 RANUM = RRN(KRANUM)
RANUM = RANUM / RLIMIT
RETURN
END
C 40 READ(ITAPE) RRN
C IF(EOF, ITAPE) 41, 50
C 41 REWIND ITAPE
C GO TO 40