[1239] | 1 | MODULE ls_forcing_mod |
---|
| 2 | |
---|
| 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 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 | ! |
---|
[1310] | 17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1239] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
[1354] | 22 | ! |
---|
| 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: ls_forcing.f90 1354 2014-04-08 15:22:57Z witha $ |
---|
| 27 | ! |
---|
[1354] | 28 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 29 | ! REAL constants provided with KIND-attribute |
---|
| 30 | ! |
---|
[1321] | 31 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 32 | ! ONLY-attribute added to USE-statements, |
---|
| 33 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 34 | ! kinds are defined in new module kinds, |
---|
| 35 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 36 | ! all variable declaration statements |
---|
[1239] | 37 | ! |
---|
[1319] | 38 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
| 39 | ! module interfaces removed |
---|
| 40 | ! |
---|
[1300] | 41 | ! 1299 2014-03-06 13:15:21Z heinze |
---|
| 42 | ! Ensure a zero large scale vertical velocity at the surface |
---|
| 43 | ! Bugfix: typo in case of boundary condition in if-clause |
---|
| 44 | ! |
---|
[1277] | 45 | ! 1276 2014-01-15 13:40:41Z heinze |
---|
| 46 | ! Use LSF_DATA also in case of Dirichlet bottom boundary condition for scalars |
---|
| 47 | ! |
---|
[1250] | 48 | ! 1249 2013-11-06 10:45:47Z heinze |
---|
| 49 | ! remove call of user module |
---|
| 50 | ! reformatting |
---|
| 51 | ! |
---|
[1242] | 52 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
| 53 | ! Initial revision |
---|
[1239] | 54 | ! |
---|
| 55 | ! Description: |
---|
| 56 | ! ------------ |
---|
| 57 | ! Calculates large scale forcings (geostrophic wind and subsidence velocity) as |
---|
[1299] | 58 | ! well as surfaces fluxes dependent on time given in an external file (LSF_DATA). |
---|
[1239] | 59 | ! Code is based in parts on DALES and UCLA-LES. |
---|
| 60 | !--------------------------------------------------------------------------------! |
---|
| 61 | |
---|
| 62 | PRIVATE |
---|
| 63 | PUBLIC init_ls_forcing, ls_forcing_surf, ls_forcing_vert |
---|
| 64 | SAVE |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | CONTAINS |
---|
| 68 | |
---|
| 69 | SUBROUTINE init_ls_forcing |
---|
| 70 | |
---|
[1320] | 71 | USE arrays_3d, & |
---|
| 72 | ONLY: p_surf, pt_surf, q_surf, qsws_surf, shf_surf, time_surf, & |
---|
| 73 | time_vert, ug_vert, vg_vert, wsubs_vert, zu |
---|
[1239] | 74 | |
---|
[1320] | 75 | USE control_parameters, & |
---|
| 76 | ONLY: end_time, lsf_surf, lsf_vert, message_string, nlsf |
---|
| 77 | |
---|
| 78 | USE indices, & |
---|
| 79 | ONLY: nzb, nzt |
---|
| 80 | |
---|
| 81 | USE kinds |
---|
| 82 | |
---|
| 83 | |
---|
[1239] | 84 | IMPLICIT NONE |
---|
| 85 | |
---|
[1320] | 86 | CHARACTER(100) :: chmess !: |
---|
| 87 | CHARACTER(1) :: hash !: |
---|
[1239] | 88 | |
---|
[1320] | 89 | INTEGER(iwp) :: ierrn !: |
---|
| 90 | INTEGER(iwp) :: finput = 90 !: |
---|
| 91 | INTEGER(iwp) :: k !: |
---|
| 92 | INTEGER(iwp) :: t !: |
---|
| 93 | |
---|
| 94 | REAL(wp) :: fac !: |
---|
| 95 | REAL(wp) :: highheight !: |
---|
| 96 | REAL(wp) :: highug_vert !: |
---|
| 97 | REAL(wp) :: highvg_vert !: |
---|
| 98 | REAL(wp) :: highwsubs_vert !: |
---|
| 99 | REAL(wp) :: lowheight !: |
---|
| 100 | REAL(wp) :: lowug_vert !: |
---|
| 101 | REAL(wp) :: lowvg_vert !: |
---|
| 102 | REAL(wp) :: lowwsubs_vert !: |
---|
| 103 | REAL(wp) :: r_dummy !: |
---|
| 104 | |
---|
[1239] | 105 | ALLOCATE( p_surf(0:nlsf), pt_surf(0:nlsf), q_surf(0:nlsf), & |
---|
| 106 | qsws_surf(0:nlsf), shf_surf(0:nlsf), time_vert(0:nlsf), & |
---|
| 107 | time_surf(0:nlsf), ug_vert(nzb:nzt+1,0:nlsf), & |
---|
| 108 | vg_vert(nzb:nzt+1,0:nlsf), wsubs_vert(nzb:nzt+1,0:nlsf) ) |
---|
| 109 | |
---|
[1353] | 110 | p_surf = 0.0_wp; pt_surf = 0.0_wp; q_surf = 0.0_wp |
---|
| 111 | qsws_surf = 0.0_wp; shf_surf = 0.0_wp; time_vert = 0.0_wp |
---|
| 112 | time_surf = 0.0_wp; ug_vert = 0.0_wp; vg_vert = 0.0_wp |
---|
| 113 | wsubs_vert = 0.0_wp |
---|
[1239] | 114 | |
---|
| 115 | |
---|
[1249] | 116 | OPEN ( finput, FILE='LSF_DATA', STATUS='OLD', & |
---|
| 117 | FORM='FORMATTED', IOSTAT=ierrn ) |
---|
[1239] | 118 | |
---|
[1249] | 119 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 120 | message_string = 'file LSF_DATA does not exist' |
---|
| 121 | CALL message( 'ls_forcing', 'PA0368', 1, 2, 0, 6, 0 ) |
---|
| 122 | ENDIF |
---|
| 123 | |
---|
| 124 | ierrn = 0 |
---|
| 125 | ! |
---|
| 126 | !-- First three lines of LSF_DATA contain header |
---|
[1249] | 127 | READ ( finput, FMT='(a100)', IOSTAT=ierrn ) chmess |
---|
| 128 | READ ( finput, FMT='(a100)', IOSTAT=ierrn ) chmess |
---|
| 129 | READ ( finput, FMT='(a100)', IOSTAT=ierrn ) chmess |
---|
[1239] | 130 | |
---|
[1249] | 131 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 132 | message_string = 'errors in file LSF_DATA' |
---|
| 133 | CALL message( 'ls_forcing', 'PA0369', 1, 2, 0, 6, 0 ) |
---|
| 134 | ENDIF |
---|
| 135 | |
---|
| 136 | ! |
---|
| 137 | !-- Surface values are read in |
---|
| 138 | t = 0 |
---|
| 139 | ierrn = 0 |
---|
| 140 | |
---|
| 141 | DO WHILE ( time_surf(t) < end_time ) |
---|
| 142 | t = t + 1 |
---|
[1249] | 143 | READ ( finput, *, IOSTAT = ierrn ) time_surf(t), shf_surf(t), & |
---|
[1239] | 144 | qsws_surf(t), pt_surf(t), & |
---|
| 145 | q_surf(t), p_surf(t) |
---|
| 146 | |
---|
[1249] | 147 | IF ( ierrn < 0 ) THEN |
---|
[1299] | 148 | WRITE ( message_string, * ) 'No time dependent surface variables ',& |
---|
[1239] | 149 | 'in&LSF_DATA for end of run found' |
---|
| 150 | |
---|
| 151 | CALL message( 'ls_forcing', 'PA0370', 1, 2, 0, 6, 0 ) |
---|
| 152 | ENDIF |
---|
| 153 | ENDDO |
---|
| 154 | |
---|
| 155 | |
---|
[1249] | 156 | IF ( time_surf(1) > end_time ) THEN |
---|
[1299] | 157 | WRITE ( message_string, * ) 'No time dependent surface variables in ',& |
---|
[1239] | 158 | '&LSF_DATA for end of run found - ', & |
---|
| 159 | 'lsf_surf is set to FALSE' |
---|
| 160 | CALL message( 'ls_forcing', 'PA0371', 0, 0, 0, 6, 0 ) |
---|
| 161 | lsf_surf = .FALSE. |
---|
| 162 | ENDIF |
---|
| 163 | |
---|
| 164 | ! |
---|
| 165 | !-- Go to the end of the list with surface variables |
---|
| 166 | DO WHILE ( ierrn == 0 ) |
---|
[1249] | 167 | READ ( finput, *, IOSTAT = ierrn ) r_dummy |
---|
[1239] | 168 | ENDDO |
---|
| 169 | |
---|
| 170 | ! |
---|
| 171 | !-- Profiles of ug, vg and w_subs are read in (large scale forcing) |
---|
| 172 | |
---|
| 173 | t = 0 |
---|
[1249] | 174 | DO WHILE ( time_vert(t) < end_time ) |
---|
[1239] | 175 | t = t + 1 |
---|
| 176 | hash = "#" |
---|
| 177 | ierrn = 1 ! not zero |
---|
| 178 | ! |
---|
| 179 | !-- Search for the next line consisting of "# time", |
---|
| 180 | !-- from there onwards the profiles will be read |
---|
| 181 | DO WHILE ( .NOT. ( hash == "#" .AND. ierrn == 0 ) ) |
---|
[1249] | 182 | READ ( finput, *, IOSTAT=ierrn ) hash, time_vert(t) |
---|
| 183 | IF ( ierrn < 0 ) THEN |
---|
[1299] | 184 | WRITE( message_string, * ) 'No time dependent vertical profiles',& |
---|
[1239] | 185 | ' in&LSF_DATA for end of run found' |
---|
| 186 | CALL message( 'ls_forcing', 'PA0372', 1, 2, 0, 6, 0 ) |
---|
| 187 | ENDIF |
---|
| 188 | ENDDO |
---|
| 189 | |
---|
| 190 | IF ( t == 1 .AND. time_vert(t) > end_time ) EXIT |
---|
| 191 | |
---|
[1249] | 192 | READ ( finput, *, IOSTAT=ierrn ) lowheight, lowug_vert, lowvg_vert, & |
---|
| 193 | lowwsubs_vert |
---|
| 194 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 195 | message_string = 'errors in file LSF_DATA' |
---|
[1299] | 196 | CALL message( 'ls_forcing', 'PA0369', 1, 2, 0, 6, 0 ) |
---|
[1239] | 197 | ENDIF |
---|
| 198 | |
---|
[1249] | 199 | READ ( finput, *, IOSTAT=ierrn ) highheight, highug_vert, highvg_vert, & |
---|
| 200 | highwsubs_vert |
---|
[1239] | 201 | |
---|
[1249] | 202 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 203 | message_string = 'errors in file LSF_DATA' |
---|
[1299] | 204 | CALL message( 'ls_forcing', 'PA0369', 1, 2, 0, 6, 0 ) |
---|
[1239] | 205 | ENDIF |
---|
| 206 | |
---|
[1241] | 207 | |
---|
[1239] | 208 | DO k = nzb, nzt+1 |
---|
[1249] | 209 | IF ( highheight < zu(k) ) THEN |
---|
[1239] | 210 | lowheight = highheight |
---|
| 211 | lowug_vert = highug_vert |
---|
| 212 | lowvg_vert = highvg_vert |
---|
| 213 | lowwsubs_vert = highwsubs_vert |
---|
| 214 | |
---|
| 215 | ierrn = 0 |
---|
[1249] | 216 | READ ( finput, *, IOSTAT=ierrn ) highheight, highug_vert, & |
---|
| 217 | highvg_vert, highwsubs_vert |
---|
[1239] | 218 | |
---|
[1249] | 219 | IF ( ierrn /= 0 ) THEN |
---|
[1239] | 220 | message_string = 'errors in file LSF_DATA' |
---|
[1299] | 221 | CALL message( 'ls_forcing', 'PA0369', 1, 2, 0, 6, 0 ) |
---|
[1239] | 222 | ENDIF |
---|
| 223 | |
---|
| 224 | ENDIF |
---|
| 225 | |
---|
| 226 | ! |
---|
| 227 | !-- Interpolation of prescribed profiles in space |
---|
| 228 | fac = (highheight-zu(k))/(highheight - lowheight) |
---|
| 229 | |
---|
| 230 | ug_vert(k,t) = fac*lowug_vert + (1-fac)*highug_vert |
---|
| 231 | vg_vert(k,t) = fac*lowvg_vert + (1-fac)*highvg_vert |
---|
| 232 | wsubs_vert(k,t) = fac*lowwsubs_vert + (1-fac)*highwsubs_vert |
---|
| 233 | |
---|
| 234 | ENDDO |
---|
| 235 | |
---|
| 236 | ENDDO |
---|
| 237 | |
---|
[1299] | 238 | ! |
---|
| 239 | !-- Large scale vertical velocity has to be zero at the surface |
---|
[1353] | 240 | wsubs_vert(nzb,:) = 0.0_wp |
---|
[1299] | 241 | |
---|
[1249] | 242 | IF ( time_vert(1) > end_time ) THEN |
---|
| 243 | WRITE ( message_string, * ) 'Time dependent large scale profile ',& |
---|
| 244 | 'forcing from&LSF_DATA sets in after end of ' ,& |
---|
| 245 | 'simulation - lsf_vert is set to FALSE' |
---|
[1239] | 246 | CALL message( 'ls_forcing', 'PA0373', 0, 0, 0, 6, 0 ) |
---|
| 247 | lsf_vert = .FALSE. |
---|
| 248 | ENDIF |
---|
| 249 | |
---|
| 250 | CLOSE( finput ) |
---|
| 251 | |
---|
| 252 | |
---|
| 253 | END SUBROUTINE init_ls_forcing |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | SUBROUTINE ls_forcing_surf ( time ) |
---|
| 257 | |
---|
[1320] | 258 | USE arrays_3d, & |
---|
| 259 | ONLY: p_surf, pt_surf, q_surf, qsws, qsws_surf, shf, shf_surf, & |
---|
| 260 | time_surf, time_vert, ug, ug_vert, vg, vg_vert |
---|
[1239] | 261 | |
---|
[1320] | 262 | USE control_parameters, & |
---|
| 263 | ONLY: bc_q_b, ibc_pt_b, ibc_q_b, pt_surface, q_surface, & |
---|
| 264 | surface_pressure |
---|
| 265 | |
---|
| 266 | USE kinds |
---|
| 267 | |
---|
| 268 | |
---|
[1239] | 269 | IMPLICIT NONE |
---|
| 270 | |
---|
[1320] | 271 | INTEGER(iwp) :: t !: |
---|
[1239] | 272 | |
---|
[1320] | 273 | REAL(wp) :: fac !: |
---|
| 274 | REAL(wp), INTENT(in) :: time !: |
---|
| 275 | |
---|
[1239] | 276 | ! |
---|
| 277 | !-- Interpolation in time of LSF_DATA at the surface |
---|
| 278 | t = 1 |
---|
| 279 | DO WHILE ( time > time_surf(t) ) |
---|
| 280 | t = t + 1 |
---|
| 281 | ENDDO |
---|
[1249] | 282 | IF ( time /= time_surf(t) ) THEN |
---|
[1239] | 283 | t = t - 1 |
---|
| 284 | ENDIF |
---|
| 285 | |
---|
| 286 | fac = ( time -time_surf(t) ) / ( time_surf(t+1) - time_surf(t) ) |
---|
| 287 | |
---|
[1276] | 288 | IF ( ibc_pt_b == 0 ) THEN |
---|
| 289 | ! |
---|
| 290 | !-- In case of Dirichlet boundary condition shf must not |
---|
| 291 | !-- be set - it is calculated via MOST in prandtl_fluxes |
---|
| 292 | pt_surface = pt_surf(t) + fac * ( pt_surf(t+1) - pt_surf(t) ) |
---|
| 293 | |
---|
| 294 | ELSEIF ( ibc_pt_b == 1 ) THEN |
---|
| 295 | ! |
---|
| 296 | !-- In case of Neumann boundary condition pt_surface is needed for |
---|
| 297 | !-- calculation of reference density |
---|
| 298 | shf = shf_surf(t) + fac * ( shf_surf(t+1) - shf_surf(t) ) |
---|
| 299 | pt_surface = pt_surf(t) + fac * ( pt_surf(t+1) - pt_surf(t) ) |
---|
| 300 | |
---|
| 301 | ENDIF |
---|
| 302 | |
---|
| 303 | IF ( ibc_q_b == 0 ) THEN |
---|
| 304 | ! |
---|
| 305 | !-- In case of Dirichlet boundary condition qsws must not |
---|
| 306 | !-- be set - it is calculated via MOST in prandtl_fluxes |
---|
| 307 | q_surface = q_surf(t) + fac * ( q_surf(t+1) - q_surf(t) ) |
---|
| 308 | |
---|
[1299] | 309 | ELSEIF ( ibc_q_b == 1 ) THEN |
---|
[1276] | 310 | |
---|
| 311 | qsws = qsws_surf(t) + fac * ( qsws_surf(t+1) - qsws_surf(t) ) |
---|
| 312 | |
---|
| 313 | ENDIF |
---|
| 314 | |
---|
[1239] | 315 | surface_pressure = p_surf(t) + fac * ( p_surf(t+1) - p_surf(t) ) |
---|
| 316 | |
---|
| 317 | END SUBROUTINE ls_forcing_surf |
---|
| 318 | |
---|
| 319 | |
---|
| 320 | SUBROUTINE ls_forcing_vert ( time ) |
---|
| 321 | |
---|
[1320] | 322 | USE arrays_3d, & |
---|
| 323 | ONLY: time_vert, ug, ug_vert, vg, vg_vert, w_subs, wsubs_vert |
---|
[1239] | 324 | |
---|
[1320] | 325 | USE control_parameters, & |
---|
| 326 | ONLY: large_scale_subsidence |
---|
| 327 | |
---|
| 328 | USE kinds |
---|
| 329 | |
---|
| 330 | |
---|
[1239] | 331 | IMPLICIT NONE |
---|
| 332 | |
---|
[1320] | 333 | INTEGER(iwp) :: t !: |
---|
[1239] | 334 | |
---|
[1320] | 335 | REAL(wp) :: fac !: |
---|
| 336 | REAL(wp), INTENT(in) :: time !: |
---|
| 337 | |
---|
[1239] | 338 | ! |
---|
| 339 | !-- Interpolation in time of LSF_DATA for ug, vg and w_subs |
---|
| 340 | t = 1 |
---|
| 341 | DO WHILE ( time > time_vert(t) ) |
---|
| 342 | t = t + 1 |
---|
| 343 | ENDDO |
---|
[1249] | 344 | IF ( time /= time_vert(t) ) THEN |
---|
[1239] | 345 | t = t - 1 |
---|
| 346 | ENDIF |
---|
| 347 | |
---|
[1249] | 348 | fac = ( time-time_vert(t) ) / ( time_vert(t+1)-time_vert(t) ) |
---|
[1239] | 349 | |
---|
| 350 | ug = ug_vert(:,t) + fac * ( ug_vert(:,t+1) - ug_vert(:,t) ) |
---|
| 351 | vg = vg_vert(:,t) + fac * ( vg_vert(:,t+1) - vg_vert(:,t) ) |
---|
| 352 | |
---|
[1249] | 353 | IF ( large_scale_subsidence ) THEN |
---|
[1239] | 354 | w_subs = wsubs_vert(:,t) + fac * ( wsubs_vert(:,t+1) - wsubs_vert(:,t) ) |
---|
| 355 | ENDIF |
---|
| 356 | |
---|
| 357 | END SUBROUTINE ls_forcing_vert |
---|
| 358 | |
---|
| 359 | |
---|
| 360 | END MODULE ls_forcing_mod |
---|