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