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