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