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