[1682] | 1 | !> @file disturb_heatflux.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[1036] | 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
[2000] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | ! terms of the GNU General Public License as published by the Free Software |
---|
| 7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | ! version. |
---|
[1036] | 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[2101] | 17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
[1320] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1322] | 21 | ! ------------------ |
---|
[2232] | 22 | ! Adjustment according new surface data type. |
---|
| 23 | ! Implemented parallel random number generator to obtain always the same |
---|
| 24 | ! random number distribution regardless of the processor distribution. |
---|
[1354] | 25 | ! |
---|
[1321] | 26 | ! Former revisions: |
---|
| 27 | ! ----------------- |
---|
| 28 | ! $Id: disturb_heatflux.f90 2232 2017-05-30 17:47:52Z suehring $ |
---|
| 29 | ! |
---|
[2038] | 30 | ! 2037 2016-10-26 11:15:40Z knoop |
---|
| 31 | ! Anelastic approximation implemented |
---|
| 32 | ! |
---|
[2001] | 33 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 34 | ! Forced header and separation lines into 80 columns |
---|
| 35 | ! |
---|
[1683] | 36 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 37 | ! Code annotations made doxygen readable |
---|
| 38 | ! |
---|
[1354] | 39 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 40 | ! REAL constants provided with KIND-attribute |
---|
| 41 | ! |
---|
[1323] | 42 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 43 | ! REAL constants defined as wp-kind |
---|
| 44 | ! |
---|
[1321] | 45 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 46 | ! ONLY-attribute added to USE-statements, |
---|
| 47 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 48 | ! kinds are defined in new module kinds, |
---|
| 49 | ! revision history before 2012 removed, |
---|
| 50 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 51 | ! all variable declaration statements |
---|
[1] | 52 | ! |
---|
[1037] | 53 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 54 | ! code put under GPL (PALM 3.9) |
---|
| 55 | ! |
---|
[1] | 56 | ! Revision 1.1 1998/03/25 20:03:47 raasch |
---|
| 57 | ! Initial revision |
---|
| 58 | ! |
---|
| 59 | ! |
---|
| 60 | ! Description: |
---|
| 61 | ! ------------ |
---|
[1682] | 62 | !> Generate random, normally distributed heatflux values and store them as the |
---|
| 63 | !> near-surface heatflux. |
---|
[1] | 64 | !------------------------------------------------------------------------------! |
---|
[2232] | 65 | SUBROUTINE disturb_heatflux( surf ) |
---|
[1682] | 66 | |
---|
[1] | 67 | |
---|
[1320] | 68 | USE arrays_3d, & |
---|
[2232] | 69 | ONLY: heatflux_input_conversion |
---|
[1320] | 70 | |
---|
| 71 | USE control_parameters, & |
---|
[2232] | 72 | ONLY: iran, surface_heatflux, random_generator, wall_heatflux |
---|
[1320] | 73 | |
---|
| 74 | USE cpulog, & |
---|
| 75 | ONLY: cpu_log, log_point |
---|
| 76 | |
---|
| 77 | USE kinds |
---|
| 78 | |
---|
| 79 | USE indices, & |
---|
[2232] | 80 | ONLY: nzb |
---|
[1] | 81 | |
---|
[2232] | 82 | USE random_generator_parallel, & |
---|
| 83 | ONLY: random_number_parallel, random_seed_parallel, random_dummy, & |
---|
| 84 | id_random_array, seq_random_array |
---|
| 85 | |
---|
| 86 | USE surface_mod, & |
---|
| 87 | ONLY: surf_type |
---|
| 88 | |
---|
[1] | 89 | IMPLICIT NONE |
---|
| 90 | |
---|
[2232] | 91 | INTEGER(iwp) :: i !< grid index, x direction |
---|
| 92 | INTEGER(iwp) :: j !< grid index, y direction |
---|
| 93 | INTEGER(iwp) :: k !< grid index, z direction |
---|
| 94 | INTEGER(iwp) :: m !< loop variables over surface elements |
---|
[1320] | 95 | |
---|
[1682] | 96 | REAL(wp) :: random_gauss !< |
---|
| 97 | REAL(wp) :: randomnumber !< |
---|
[1] | 98 | |
---|
[2232] | 99 | TYPE(surf_type) :: surf !< surface-type variable |
---|
[1] | 100 | |
---|
[2232] | 101 | |
---|
[1] | 102 | CALL cpu_log( log_point(23), 'disturb_heatflux', 'start' ) |
---|
| 103 | |
---|
| 104 | ! |
---|
[2232] | 105 | !-- Generate random disturbances and store them. Note, if |
---|
| 106 | !-- random_generator /= 'random-parallel' it is not guaranteed to obtain |
---|
| 107 | !-- the same random distribution if the number of processors is changed. |
---|
| 108 | IF ( random_generator /= 'random-parallel' ) THEN |
---|
| 109 | |
---|
| 110 | DO m = 1, surf%ns |
---|
| 111 | |
---|
| 112 | k = surf%k(m) |
---|
| 113 | |
---|
| 114 | randomnumber = random_gauss( iran, 5.0_wp ) |
---|
[1] | 115 | ! |
---|
[2232] | 116 | !-- k-1 is topography top index. If this is 0, set surface heatflux. Over |
---|
| 117 | !-- topography surface_heatflux is replaced by wall_heatflux(0). |
---|
| 118 | IF ( k-1 == 0 ) THEN |
---|
| 119 | surf%shf(m) = randomnumber * surface_heatflux & |
---|
| 120 | * heatflux_input_conversion(nzb) |
---|
| 121 | ELSE |
---|
| 122 | surf%shf(m) = randomnumber * wall_heatflux(0) & |
---|
| 123 | * heatflux_input_conversion(k-1) |
---|
[1] | 124 | ENDIF |
---|
| 125 | ENDDO |
---|
[2232] | 126 | ELSE |
---|
[1] | 127 | |
---|
[2232] | 128 | DO m = 1, surf%ns |
---|
| 129 | |
---|
| 130 | i = surf%i(m) |
---|
| 131 | j = surf%j(m) |
---|
| 132 | k = surf%k(m) |
---|
| 133 | |
---|
| 134 | CALL random_seed_parallel( put=seq_random_array(:, j, i) ) |
---|
| 135 | CALL random_number_parallel( random_dummy ) |
---|
[1] | 136 | ! |
---|
[2232] | 137 | !-- k-1 is topography top index. If this is 0, set surface heatflux. Over |
---|
| 138 | !-- topography surface_heatflux is replaced by wall_heatflux(0). |
---|
| 139 | IF ( k-1 == 0 ) THEN |
---|
| 140 | surf%shf(m) = ( random_dummy - 0.5_wp ) * surface_heatflux & |
---|
| 141 | * heatflux_input_conversion(nzb) |
---|
| 142 | ELSE |
---|
| 143 | surf%shf(m) = ( random_dummy - 0.5_wp ) * wall_heatflux(0) & |
---|
| 144 | * heatflux_input_conversion(k-1) |
---|
| 145 | ENDIF |
---|
[1] | 146 | |
---|
[2232] | 147 | CALL random_seed_parallel( get=seq_random_array(:, j, i) ) |
---|
| 148 | |
---|
| 149 | ENDDO |
---|
| 150 | |
---|
| 151 | ENDIF |
---|
| 152 | |
---|
[1] | 153 | CALL cpu_log( log_point(23), 'disturb_heatflux', 'stop' ) |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | END SUBROUTINE disturb_heatflux |
---|