Debian Codegraph @

packages/seacas/libraries/suplib/ran1.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 REAL FUNCTION RAN1(idum)
8
9 C This function returns a pseudo-random number for each invocation.
10 C It is a FORTRAN 77 adaptation of the "Integer Version 2" minimal
11 C standard number generator whose Pascal code appears in the article:
12
13 C Park, Steven K. and Miller, Keith W., "Random Number Generators:
14 C Good Ones are Hard to Find", Communications of the ACM,
15 C October, 1988.
16
17 PARAMETER (MPLIER=16807,MODLUS=2147483647,MOBYMP=127773,
18 + MOMDMP=2836)
19
20 data jseed /123456789/
21 data ifrst /0/
22
23 INTEGER HVLUE, LVLUE, TESTV, NEXTN
24 SAVE NEXTN
25
26 IF (IFRST .EQ. 0) THEN
27 if (idum .ne. 0) then
28 nextn = idum
29 else
30 NEXTN = JSEED
31 end if
32
33 IFRST = 1
34 ENDIF
35
36 HVLUE = NEXTN / MOBYMP
37 LVLUE = MOD(NEXTN, MOBYMP)
38 TESTV = MPLIER*LVLUE - MOMDMP*HVLUE
39 IF (TESTV .GT. 0) THEN
40 NEXTN = TESTV
41 ELSE
42 NEXTN = TESTV + MODLUS
43 ENDIF
44 RAN1 = REAL(NEXTN)/REAL(MODLUS)
45
46 RETURN
47 END