File: fsprngf_mpi.F

package info (click to toggle)
sprng 2.0a-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,308 kB
  • sloc: ansic: 30,353; fortran: 1,618; makefile: 576; cpp: 58; sh: 5
file content (61 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download | duplicates (10)
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
56
57
58
59
60
61
C
C          Demonstrates use of the single precision generator      
C One stream is maintained per processor. Each processor prints a few 
C single precision random numbers.
C
C Uncomment the following line to get the interface with pointer checking
C #define CHECK_POINTERS

       program fsprngf_mpi
       implicit none

#define FLOAT_GEN 1	! make 'sprng()' return single precision numbers
#include <mpif.h>
#include "sprng_f.h"

       integer streamnum, nstreams, seed
       SPRNG_POINTER stream
       real*4 rn
       integer i, myid, nprocs, ierror, junk
C---
       integer gtype
C---

      call MPI_INIT(ierror)

      call MPI_COMM_SIZE(MPI_COMM_WORLD, nprocs, ierror)

      call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierror)

       
       streamnum = myid
       nstreams = nprocs
       seed = 985456376

C--- node 0 is reading in a generator type
       if (myid .eq. 0) then
#include "genf_types_menu.h"
         print *,'Type in a generator type (integers: 0,1,2,3,4,5):  '
         read *, gtype
       endif
       call MPI_BCAST(gtype,1, MPI_INTEGER,0,MPI_COMM_WORLD,ierror)
C---


C 
       stream = init_sprng(gtype,streamnum,nstreams,seed,SPRNG_DEFAULT)
       write(*, "('Process',i2,': Print information about stream:')"
     &      ) myid
       junk = print_sprng(stream)

       do 100 i = 1, 3
          rn = sprng(stream)
          write(*, "('Process',i2,', random number',i2,': ',f8.6)")
     &          myid,i,rn
 100   continue

       junk = free_sprng(stream)
       call MPI_FINALIZE(ierror)


       end