Changeset 3068 for palm/trunk/SOURCE
- Timestamp:
- Jun 12, 2018 2:49:41 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/init_grid.f90
r3066 r3068 25 25 ! ----------------- 26 26 ! $Id$ 27 ! New warning message concerning grid stretching has been introduced 28 ! 29 ! 3066 2018-06-12 08:55:55Z Giersch 27 30 ! Bugfix in IF statement before error message 28 31 ! … … 633 636 634 637 ! 635 !-- Stretching must not be applied within the prandtl_layer 636 !-- (first two grid points). For the default case dz_stretch_level_start 637 !-- is negative. Therefore the absolut value is checked here. 638 IF ( ANY( dz_stretch_level_start > dz(1) * 1.5_wp ) ) THEN 638 !-- Stretching must not be applied close to the surface (last two grid 639 !-- points). For the default case dz_stretch_level_start is negative. 640 IF ( ANY( dz_stretch_level_start > - dz(1) * 1.5_wp ) ) THEN 639 641 WRITE( message_string, * ) 'Eeach dz_stretch_level_start has to be ',& 640 642 'less than ', dz(1) * 1.5 … … 1148 1150 REAL(wp) :: stretch_factor_2 !< stretching factor that fulfil Eq. (6) togehter with l_rounded exactly 1149 1151 1152 REAL(wp) :: dz_stretch_factor_array_2(9) = 1.08_wp !< Array that contains all stretch_factor_2 that belongs to stretch_factor_1 1153 1150 1154 REAL(wp), PARAMETER :: stretch_factor_interval = 1.0E-06 !< interval for sampling possible stretching factors 1151 1155 REAL(wp), PARAMETER :: stretch_factor_lower_limit = 0.88 !< lowest possible stretching factor … … 1153 1157 1154 1158 1155 l = 0 1156 DO n = 1, number_end 1159 l = 0 1160 DO n = 1, number_end 1161 1162 iterations = 1 1163 stretch_factor_1 = 1.0 1164 stretch_factor_2 = 1.0 1165 delta_total_old = 1.0 1157 1166 1158 iterations = 1 1159 stretch_factor_1 = 1.0 1160 stretch_factor_2 = 1.0 1161 delta_total_old = 1.0 1162 1163 IF ( dz(n) > dz(n+1) ) THEN 1164 DO WHILE ( stretch_factor_1 >= stretch_factor_lower_limit ) 1165 1166 stretch_factor_1 = 1.0 - iterations * stretch_factor_interval 1167 distance = ABS( dz_stretch_level_end(n) - & 1168 dz_stretch_level_start(n) ) 1169 numerator = distance*stretch_factor_1/dz(n) + & 1170 stretch_factor_1 - distance/dz(n) 1171 1172 IF ( numerator > 0.0 ) THEN 1173 l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0 1174 l_rounded = NINT( l ) 1175 delta_l = ABS( l_rounded - l ) / l 1176 ENDIF 1177 1178 stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) ) 1179 1180 delta_stretch_factor = ABS( stretch_factor_1 - & 1181 stretch_factor_2 ) / & 1182 stretch_factor_2 1183 1184 delta_total_new = delta_l + delta_stretch_factor 1167 IF ( dz(n) > dz(n+1) ) THEN 1168 DO WHILE ( stretch_factor_1 >= stretch_factor_lower_limit ) 1169 1170 stretch_factor_1 = 1.0 - iterations * stretch_factor_interval 1171 distance = ABS( dz_stretch_level_end(n) - & 1172 dz_stretch_level_start(n) ) 1173 numerator = distance*stretch_factor_1/dz(n) + & 1174 stretch_factor_1 - distance/dz(n) 1175 1176 IF ( numerator > 0.0 ) THEN 1177 l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0 1178 l_rounded = NINT( l ) 1179 delta_l = ABS( l_rounded - l ) / l 1180 ENDIF 1181 1182 stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) ) 1183 1184 delta_stretch_factor = ABS( stretch_factor_1 - & 1185 stretch_factor_2 ) / & 1186 stretch_factor_2 1187 1188 delta_total_new = delta_l + delta_stretch_factor 1185 1189 1186 1190 ! … … 1189 1193 !-- stretch_factor_2 would guarantee that the stretched dz(n) is 1190 1194 !-- equal to dz(n+1) after l_rounded grid levels. 1191 IF (delta_total_new < delta_total_old) THEN 1192 dz_stretch_factor_array(n) = stretch_factor_1 1193 delta_total_old = delta_total_new 1194 ENDIF 1195 1196 iterations = iterations + 1 1197 1198 ENDDO 1199 1200 ELSEIF ( dz(n) < dz(n+1) ) THEN 1201 DO WHILE ( stretch_factor_1 <= stretch_factor_upper_limit ) 1202 1203 stretch_factor_1 = 1.0 + iterations * stretch_factor_interval 1204 distance = ABS( dz_stretch_level_end(n) - & 1205 dz_stretch_level_start(n) ) 1206 numerator = distance*stretch_factor_1/dz(n) + & 1207 stretch_factor_1 - distance/dz(n) 1208 1209 l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0 1210 l_rounded = NINT( l ) 1211 delta_l = ABS( l_rounded - l ) / l 1212 1213 stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) ) 1214 1215 delta_stretch_factor = ABS( stretch_factor_1 - & 1216 stretch_factor_2 ) / & 1217 stretch_factor_2 1218 1219 delta_total_new = delta_l + delta_stretch_factor 1220 1195 IF (delta_total_new < delta_total_old) THEN 1196 dz_stretch_factor_array(n) = stretch_factor_1 1197 dz_stretch_factor_array_2(n) = stretch_factor_2 1198 delta_total_old = delta_total_new 1199 ENDIF 1200 1201 iterations = iterations + 1 1202 1203 ENDDO 1204 1205 ELSEIF ( dz(n) < dz(n+1) ) THEN 1206 DO WHILE ( stretch_factor_1 <= stretch_factor_upper_limit ) 1207 1208 stretch_factor_1 = 1.0 + iterations * stretch_factor_interval 1209 distance = ABS( dz_stretch_level_end(n) - & 1210 dz_stretch_level_start(n) ) 1211 numerator = distance*stretch_factor_1/dz(n) + & 1212 stretch_factor_1 - distance/dz(n) 1213 1214 l = LOG( numerator ) / LOG( stretch_factor_1 ) - 1.0 1215 l_rounded = NINT( l ) 1216 delta_l = ABS( l_rounded - l ) / l 1217 1218 stretch_factor_2 = EXP( LOG( dz(n+1)/dz(n) ) / (l_rounded) ) 1219 1220 delta_stretch_factor = ABS( stretch_factor_1 - & 1221 stretch_factor_2 ) / & 1222 stretch_factor_2 1223 1224 delta_total_new = delta_l + delta_stretch_factor 1225 1221 1226 ! 1222 1227 !-- stretch_factor_1 is taken to guarantee that the stretching … … 1224 1229 !-- stretch_factor_2 would guarantee that the stretched dz(n) is 1225 1230 !-- equal to dz(n+1) after l_rounded grid levels. 1226 IF (delta_total_new < delta_total_old) THEN 1227 dz_stretch_factor_array(n) = stretch_factor_1 1228 delta_total_old = delta_total_new 1229 ENDIF 1230 1231 iterations = iterations + 1 1232 ENDDO 1231 IF (delta_total_new < delta_total_old) THEN 1232 dz_stretch_factor_array(n) = stretch_factor_1 1233 dz_stretch_factor_array_2(n) = stretch_factor_2 1234 delta_total_old = delta_total_new 1235 ENDIF 1233 1236 1234 ELSE 1235 message_string= 'Two adjacent values of dz must be different' 1236 CALL message( 'init_grid', 'PA0228', 1, 2, 0, 6, 0 ) 1237 1238 ENDIF 1239 ENDDO 1237 iterations = iterations + 1 1238 ENDDO 1239 1240 ELSE 1241 message_string= 'Two adjacent values of dz must be different' 1242 CALL message( 'init_grid', 'PA0228', 1, 2, 0, 6, 0 ) 1243 1244 ENDIF 1245 1246 ! 1247 !-- Check if also the second stretching factor fits into the allowed 1248 !-- interval. If not, print a warning for the user. 1249 IF ( dz_stretch_factor_array_2(n) < stretch_factor_lower_limit .OR. & 1250 dz_stretch_factor_array_2(n) > stretch_factor_upper_limit ) THEN 1251 WRITE( message_string, * ) 'stretch_factor_2 = ', & 1252 dz_stretch_factor_array_2(n), ' which is',& 1253 ' responsible for exactly reaching& dz =',& 1254 dz(n+1), 'after a specific amount of', & 1255 ' grid levels& exceeds the upper', & 1256 ' limit =', stretch_factor_upper_limit, & 1257 ' &or lower limit = ', & 1258 stretch_factor_lower_limit 1259 CALL message( 'init_grid', 'PA0499', 0, 1, 0, 6, 0 ) 1260 1261 ENDIF 1262 ENDDO 1240 1263 1241 1264 END SUBROUTINE calculate_stretching_factor
Note: See TracChangeset
for help on using the changeset viewer.