Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_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: none
34 !
35 ! Uses negative seeds. The procedure to produce them is somewhat awkward
36 ! because we make no assumptions about the values regions(:)%iRegionGlobal
37 !
38 ! The seed 0 is forbidden; positive seeds are used for structured regions.
39 
40 !******************************************************************************
41 !
42 ! $Id: RFLU_RandomInit.F90,v 1.5 2008/12/06 08:44:12 mtcampbe Exp $
43 !
44 ! Copyright: (c) 2003 by the University of Illinois
45 !
46 !******************************************************************************
47 
48 SUBROUTINE rflu_randominit( regions )
49 
50  USE moddatatypes
51  USE moddatastruct, ONLY : t_region
52  USE modglobal, ONLY : t_global
53  USE modrandom, ONLY : randomseed
54  USE moderror
55  USE modparameters
56 
57  IMPLICIT NONE
58 
59 ! ******************************************************************************
60 ! Definitions and declarations
61 ! ******************************************************************************
62 
63 ! ==============================================================================
64 ! Arguments
65 ! ==============================================================================
66 
67  TYPE(t_region), POINTER :: regions(:)
68 
69 ! ==============================================================================
70 ! Locals
71 ! ==============================================================================
72 
73  CHARACTER(CHRLEN) :: rcsidentstring
74  INTEGER :: iclock1,ilo,ihi,ireg,seed,seedclock
75 
76  TYPE(t_global), POINTER :: global
77 
78 ! ******************************************************************************
79 ! Start
80 ! ******************************************************************************
81 
82  rcsidentstring = '$RCSfile: RFLU_RandomInit.F90,v $ $Revision: 1.5 $'
83 
84  global => regions(1)%global
85 
86  CALL registerfunction( global,'RFLU_RandomInit',&
87  'RFLU_RandomInit.F90' )
88 
89 ! ******************************************************************************
90 ! Set seed type
91 ! ******************************************************************************
92 
93  SELECT CASE(global%randSeedType)
94  CASE(rand_seed_type_fixed)
95  seedclock = 0
96  CASE(rand_seed_type_clock)
97  CALL system_clock(iclock1)
98  seedclock = -iclock1
99  END SELECT ! global%randSeedType
100 
101 ! ******************************************************************************
102 ! Loop over regions
103 ! Note: seed with negative numbers is used for RFLU
104 ! ******************************************************************************
105 
106  ilo = lbound(regions,1)
107  ihi = ubound(regions,1)
108 
109  DO ireg = ilo,ihi
110  seed = ireg-ihi-1 - (ihi-ilo+1) * global%randSeedOffset + seedclock
111  IF (seed >= 0) THEN ! RFLU seeds must be negative
112  CALL errorstop( global,err_illegal_value,__line__ )
113  ENDIF ! seed
114 
115  CALL randomseed(seed,regions(ireg)%randData)
116  END DO ! iReg
117 
118 ! ******************************************************************************
119 ! End
120 ! ******************************************************************************
121 
122  CALL deregisterfunction( global )
123 
124 END SUBROUTINE rflu_randominit
125 
126 !******************************************************************************
127 !
128 ! RCS Revision history:
129 !
130 ! $Log: RFLU_RandomInit.F90,v $
131 ! Revision 1.5 2008/12/06 08:44:12 mtcampbe
132 ! Updated license.
133 !
134 ! Revision 1.4 2008/11/19 22:17:25 mtcampbe
135 ! Added Illinois Open Source License/Copyright
136 !
137 ! Revision 1.3 2005/12/01 17:09:05 fnajjar
138 ! Added capability for clock-based random seed
139 !
140 ! Revision 1.2 2003/11/21 22:35:51 fnajjar
141 ! Update Random Number Generator
142 !
143 ! Revision 1.1 2003/02/17 19:31:11 jferry
144 ! Implemented portable random number generator ModRandom
145 !
146 !
147 !******************************************************************************
148 
149 
150 
151 
152 
153 
154 
subroutine randomseed(seed, rdata)
Definition: ModRandom.F90:92
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
subroutine rflu_randominit(regions)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469