Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_RandomInit.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: Initializes random number generator in each region
26 !
27 ! Description: none.
28 !
29 ! Input: does not use any data already present
30 !
31 ! Output: regions(:)%randData is initialized
32 !
33 ! Notes:
34 !
35 ! Uses positive seeds.
36 !
37 ! The seed 0 is forbidden; negative seeds are used for unstructured regions.
38 !
39 !******************************************************************************
40 !
41 ! $Id: RFLO_RandomInit.F90,v 1.4 2008/12/06 08:44:07 mtcampbe Exp $
42 !
43 ! Copyright: (c) 2003 by the University of Illinois
44 !
45 !******************************************************************************
46 
47 SUBROUTINE rflo_randominit( regions )
48 
49  USE moddatatypes
50  USE moddatastruct, ONLY : t_region
51  USE modglobal, ONLY : t_global
52  USE modrandom, ONLY : randomseed
53  USE moderror
54  USE modparameters
55  IMPLICIT NONE
56 
57 ! ... parameters
58  TYPE(t_region), POINTER :: regions(:)
59 
60 ! ... loop variables
61  INTEGER :: ireg
62 
63 ! ... local variables
64  INTEGER :: iclock1,seed,seedclock
65  TYPE(t_global), POINTER :: global
66 
67 !******************************************************************************
68 
69  global => regions(1)%global
70 
71  CALL registerfunction( global,'RFLO_RandomInit',&
72  'RFLO_RandomInit.F90' )
73 
74 ! ******************************************************************************
75 ! Set seed type
76 ! ******************************************************************************
77 
78  SELECT CASE(global%randSeedType)
79  CASE(rand_seed_type_fixed)
80  seedclock = 0
81  CASE(rand_seed_type_clock)
82  CALL system_clock(iclock1)
83  seedclock = iclock1
84  END SELECT ! global%randSeedType
85 
86 ! ******************************************************************************
87 ! Loop over regions
88 ! ******************************************************************************
89 
90  DO ireg=1,global%nRegions
91  IF (regions(ireg)%procid==global%myProcid .AND. & ! region active and
92  regions(ireg)%active==active) THEN ! on my processor
93  seed = ireg + global%nRegions * global%randSeedOffset +seedclock
94  IF (seed <= 0) THEN ! RFLO seeds must be positive
95  CALL errorstop( global,err_illegal_value,__line__ )
96  ENDIF
97  CALL randomseed(seed,regions(ireg)%randData)
98  ENDIF ! procid
99  ENDDO
100 
101 ! finalize
102 
103  CALL deregisterfunction( global )
104 
105 END SUBROUTINE rflo_randominit
106 
107 !******************************************************************************
108 !
109 ! RCS Revision history:
110 !
111 ! $Log: RFLO_RandomInit.F90,v $
112 ! Revision 1.4 2008/12/06 08:44:07 mtcampbe
113 ! Updated license.
114 !
115 ! Revision 1.3 2008/11/19 22:17:20 mtcampbe
116 ! Added Illinois Open Source License/Copyright
117 !
118 ! Revision 1.2 2005/12/01 17:25:04 fnajjar
119 ! Added capability for clock-based random seed
120 !
121 ! Revision 1.1 2004/11/29 21:25:16 wasistho
122 ! lower to upper case
123 !
124 ! Revision 1.3 2003/11/21 22:30:04 fnajjar
125 ! Added global seed offset for Random Number Generator
126 !
127 ! Revision 1.2 2003/05/15 02:57:01 jblazek
128 ! Inlined index function.
129 !
130 ! Revision 1.1 2003/02/17 19:31:11 jferry
131 ! Implemented portable random number generator ModRandom
132 !
133 !******************************************************************************
134 
135 
136 
137 
138 
139 
140 
subroutine randomseed(seed, rdata)
Definition: ModRandom.F90:92
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine rflo_randominit(regions)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469