source: palm/trunk/SOURCE/ls_forcing.f90 @ 1318

Last change on this file since 1318 was 1318, checked in by raasch, 10 years ago

former files/routines cpu_log and cpu_statistics combined to one module,
which also includes the former data module cpulog from the modules-file,
module interfaces removed

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