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