1C
2C                Demonstrates the use of sprng in subroutines
3
4       program sprngf
5       implicit none
6
7#include "sprng_f.h"
8
9       integer streamnum, nstreams, seed,junk
10       SPRNG_POINTER stream
11C--- reading in a generator type
12       integer gtype
13#include "genf_types_menu.h"
14       print *,'Type in a generator type (integers: 0,1,2,3,4,5):  '
15       read *, gtype
16C---
17       streamnum = 0
18       nstreams = 1
19       seed = 985456376
20
21C   initialize stream
22       stream = init_sprng(gtype,streamnum,nstreams,seed,SPRNG_DEFAULT)
23       print *, 'Printing information about new stream'
24       junk = print_sprng(stream)
25
26       call sub1(stream)
27
28       junk = free_sprng(stream)
29
30       end
31
32C --- print random numbers in  subroutine ---
33      subroutine sub1(stream)
34
35#include "sprng_f.h"
36      SPRNG_POINTER stream
37      real *8 rn
38
39       print *, 'Printing 3 double precision numbers in [0,1): '
40       do 100 i = 1, 3
41          rn = sprng(stream)
42          write(*, "(i6, 2H   , f19.16)") i, rn
43 100   continue
44
45       return
46       end
47
48