Changeset 4438 for palm/trunk/SOURCE/random_generator_parallel_mod.f90
 Timestamp:
 Mar 3, 2020 8:49:28 PM (3 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

palm/trunk/SOURCE/random_generator_parallel_mod.f90
r4360 r4438 25 25 !  26 26 ! $Id$ 27 !  Rename variables to avoid confusion with subdomain grid indices 28 !  Some formatting adjustments 29 !  New routine to initialize spatial 1Darrays independent on the 2D random 30 ! number array 31 ! 32 ! 4360 20200107 11:25:50Z suehring 27 33 ! Corrected "Former revisions" section 28 34 ! … … 50 56 !! 51 57 MODULE random_generator_parallel 52 53 58 54 59 USE kinds 55 60 56 61 IMPLICIT NONE 57 58 PRIVATE 59 PUBLIC random_number_parallel, random_seed_parallel, random_dummy, & 60 id_random_array, seq_random_array, init_parallel_random_generator 61 62 62 63 INTEGER(isp), SAVE :: lenran=0 !< 63 64 INTEGER(isp), SAVE :: seq=0 !< … … 68 69 INTEGER(isp), SAVE :: nran0 !< 69 70 INTEGER(isp), SAVE :: rans !< 70 71 71 72 INTEGER(isp), DIMENSION(:, :), POINTER, SAVE :: ranseeds !< 72 73 73 74 INTEGER(isp), DIMENSION(:), POINTER, SAVE :: iran !< 74 75 INTEGER(isp), DIMENSION(:), POINTER, SAVE :: jran !< … … 77 78 INTEGER(isp), DIMENSION(:), POINTER, SAVE :: nran !< 78 79 INTEGER(isp), DIMENSION(:), POINTER, SAVE :: ranv !< 79 80 81 80 82 81 INTEGER(isp), DIMENSION(:,:), ALLOCATABLE :: id_random_array !< 83 82 INTEGER(isp), DIMENSION(:,:,:), ALLOCATABLE :: seq_random_array !< 84 83 85 84 REAL(wp), SAVE :: amm !< 86 85 87 86 REAL(wp) :: random_dummy=0.0 !< 88 87 89 88 INTERFACE init_parallel_random_generator 90 MODULE PROCEDURE init_parallel_random_generator 89 MODULE PROCEDURE init_parallel_random_generator_1d 90 MODULE PROCEDURE init_parallel_random_generator_2d 91 91 END INTERFACE 92 92 93 93 INTERFACE random_number_parallel 94 94 MODULE PROCEDURE ran0_s 95 95 END INTERFACE 96 96 97 97 INTERFACE random_seed_parallel 98 98 MODULE PROCEDURE random_seed_parallel 99 99 END INTERFACE 100 100 101 101 INTERFACE ran_hash 102 102 MODULE PROCEDURE ran_hash_v 103 103 END INTERFACE 104 104 105 105 INTERFACE reallocate 106 106 MODULE PROCEDURE reallocate_iv,reallocate_im 107 107 END INTERFACE 108 108 109 109 INTERFACE arth 110 110 MODULE PROCEDURE arth_i 111 111 END INTERFACE 112 112 113 PRIVATE 114 115 PUBLIC random_number_parallel, random_seed_parallel, random_dummy, & 116 id_random_array, seq_random_array, init_parallel_random_generator 117 113 118 CONTAINS 114 115 !! 116 ! Description: 117 !  118 !> Initialize the parallel random number generator for a specific subdomain 119 !! 120 SUBROUTINE init_parallel_random_generator( nx, nys, nyn, nxl, nxr ) 121 122 USE kinds 119 120 !! 121 ! Description: 122 !  123 !> Initialize the parallel random number generator for a 1dimensional array. 124 !! 125 SUBROUTINE init_parallel_random_generator_1d( nxy, ns, ne, id_rand, seq_rand ) 123 126 124 127 USE control_parameters, & 125 128 ONLY: ensemble_member_nr 126 129 130 INTEGER(isp), INTENT(IN) :: nxy !< constant scaling with grid dimensions 131 INTEGER(isp), INTENT(IN) :: ns !< start index on subdomain 132 INTEGER(isp), INTENT(IN) :: ne !< end index on subdomain 133 134 INTEGER(iwp) :: j !< loop index 135 136 INTEGER(isp), DIMENSION(ns:ne) :: id_rand !< initial IDs 137 INTEGER(isp), DIMENSION(5,ns:ne) :: seq_rand !< initial random seeds 138 139 ! 140 ! Asigning an ID to every vertical gridpoint column 141 ! dependig on the ensemble run number. 142 DO j = ns, ne 143 id_rand(j) = j * ( nxy + 1.0_wp ) + 1.0_wp + 1E6 * & 144 ( ensemble_member_nr  1000 ) 145 ENDDO 146 ! 147 ! Initializing with random_seed_parallel for every vertical 148 ! gridpoint column. 149 random_dummy=0 150 DO j = ns, ne 151 CALL random_seed_parallel( random_sequence=id_rand(j) ) 152 CALL random_number_parallel( random_dummy ) 153 CALL random_seed_parallel( get=seq_rand(:,j) ) 154 ENDDO 155 156 END SUBROUTINE init_parallel_random_generator_1d 157 158 !! 159 ! Description: 160 !  161 !> Initialize the parallel random number generator for a specific subdomain 162 !! 163 SUBROUTINE init_parallel_random_generator_2d( nx_l, nys_l, nyn_l, nxl_l, nxr_l ) 164 165 USE kinds 166 167 USE control_parameters, & 168 ONLY: ensemble_member_nr 169 127 170 IMPLICIT NONE 128 171 129 INTEGER(isp), INTENT(IN) :: nx !<130 INTEGER(isp), INTENT(IN) :: nys !<131 INTEGER(isp), INTENT(IN) :: nyn !<132 INTEGER(isp), INTENT(IN) :: nxl !<133 INTEGER(isp), INTENT(IN) :: nxr !<134 135 INTEGER(iwp) :: i !< 136 INTEGER(iwp) :: j !< 172 INTEGER(isp), INTENT(IN) :: nx_l !< constant 173 INTEGER(isp), INTENT(IN) :: nys_l !< local lower subdomain bound index in ydirection 174 INTEGER(isp), INTENT(IN) :: nyn_l !< local upper subdomain bound index in ydirection 175 INTEGER(isp), INTENT(IN) :: nxl_l !< local lower subdomain bound index in xdirection 176 INTEGER(isp), INTENT(IN) :: nxr_l !< local upper subdomain bound index in xdirection 177 178 INTEGER(iwp) :: i !< grid index xdirection 179 INTEGER(iwp) :: j !< grid index ydirection 137 180 138 181 ! Allocate IDarray and statespacearray 139 ALLOCATE ( seq_random_array(5,nys :nyn,nxl:nxr) )140 ALLOCATE ( id_random_array(nys :nyn,nxl:nxr) )182 ALLOCATE ( seq_random_array(5,nys_l:nyn_l,nxl_l:nxr_l) ) 183 ALLOCATE ( id_random_array(nys_l:nyn_l,nxl_l:nxr_l) ) 141 184 seq_random_array = 0 142 185 id_random_array = 0 … … 144 187 ! Asigning an ID to every vertical gridpoint column 145 188 ! dependig on the ensemble run number. 146 DO i=nxl, nxr147 DO j=nys, nyn148 id_random_array(j,i) = j *(nx+1.0_wp) + i + 1.0_wp + 1E6 *&189 DO i = nxl_l, nxr_l 190 DO j = nys_l, nyn_l 191 id_random_array(j,i) = j * ( nx_l + 1.0_wp ) + i + 1.0_wp + 1E6 * & 149 192 ( ensemble_member_nr  1000 ) 150 193 ENDDO … … 153 196 ! gridpoint column. 154 197 random_dummy=0 155 DO i = nxl, nxr156 DO j = nys, nyn198 DO i = nxl_l, nxr_l 199 DO j = nys_l, nyn_l 157 200 CALL random_seed_parallel (random_sequence=id_random_array(j, i)) 158 201 CALL random_number_parallel (random_dummy) … … 161 204 ENDDO 162 205 163 END SUBROUTINE init_parallel_random_generator 206 END SUBROUTINE init_parallel_random_generator_2d 164 207 165 208 !!
Note: See TracChangeset
for help on using the changeset viewer.