File: convertf.F

package info (click to toggle)
sprng 2.0a-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,308 kB
  • sloc: ansic: 30,353; fortran: 1,618; makefile: 575; cpp: 58; sh: 5
file content (55 lines) | stat: -rw-r--r-- 1,264 bytes parent folder | download | duplicates (9)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
C            ____Demonstrates converting code to SPRNG____ 
C    
C The original random number call is to 'myrandom'. We change it to 
C call SPRNG by defining a macro.     
C                     
C The lines between the '#ifdef CONVERT' and the '#else' are the
C newly added lines. Those lines between the '#else' and the '#endif'
C are theoriginal lines that need to be deleted.



       program sprngf_simple
       implicit none

#define CONVERT

#ifdef CONVERT
#define SIMPLE_SPRNG	
#include "sprng_f.h"
#define myrandom sprng	

       SPRNG_POINTER junkPtr
#else
       external myrandom
       real*8   myrandom
#endif
       real*8 rn
       integer seed, irn, i, junk

C--- reading in a generator type
       integer gtype
#include "genf_types_menu.h"
       print *,'Type in a generator type (integers: 0,1,2,3,4,5):  '
       read *, gtype
C---

       seed = 985456376

#ifdef CONVERT
C   initialization
       junkPtr = init_sprng(gtype,seed,SPRNG_DEFAULT)
       print *, 'Printing information about new stream'
       junk = print_sprng()
#else
C Old initialization lines
#endif

       print *, 'Printing 3 double precision numbers in [0,1): '
       do 100 i = 1, 3
          rn = myrandom()
          print *,i, rn
 100   continue

 
       end