source: palm/trunk/SOURCE/subsidence.f90 @ 1381

Last change on this file since 1381 was 1381, checked in by heinze, 10 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 11.6 KB
RevLine 
[411]1 MODULE subsidence_mod
2
[1036]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
[1036]18!--------------------------------------------------------------------------------!
19!
[411]20! Current revisions:
21! -----------------
[1321]22!
[1381]23!
[1321]24! Former revisions:
25! -----------------
26! $Id: subsidence.f90 1381 2014-04-28 12:41:59Z heinze $
27!
[1381]28! 1380 2014-04-28 12:40:45Z heinze
29! Shifting only necessary in case of scalar Rayleigh damping
30!
[1366]31! 1365 2014-04-22 15:03:56Z boeske
32! Summation of subsidence tendencies for data output added
33! +ls_index, sums_ls_l, tmp_tend
34!
[1354]35! 1353 2014-04-08 15:21:23Z heinze
36! REAL constants provided with KIND-attribute
37!
[1321]38! 1320 2014-03-20 08:40:49Z raasch
[1320]39! ONLY-attribute added to USE-statements,
40! kind-parameters added to all INTEGER and REAL declaration statements,
41! kinds are defined in new module kinds,
42! old module precision_kind is removed,
43! revision history before 2012 removed,
44! comment fields (!:) to be used for variable explanations added to
45! all variable declaration statements
[411]46!
[1037]47! 1036 2012-10-22 13:43:42Z raasch
48! code put under GPL (PALM 3.9)
49!
[464]50! Revision 3.7 2009-12-11 14:15:58Z heinze
51! Initial revision
[411]52!
53! Description:
54! ------------
55! Impact of large-scale subsidence or ascent as tendency term for use
56! in the prognostic equation of potential temperature. This enables the
57! construction of a constant boundary layer height z_i with time.
58!-----------------------------------------------------------------------------!
59
60
61    IMPLICIT NONE
62
63    PRIVATE
64    PUBLIC  init_w_subsidence, subsidence
65
66    INTERFACE init_w_subsidence
67       MODULE PROCEDURE init_w_subsidence
68    END INTERFACE init_w_subsidence
69
70    INTERFACE subsidence
71       MODULE PROCEDURE subsidence
72       MODULE PROCEDURE subsidence_ij
73    END INTERFACE subsidence
74
75 CONTAINS
76
77    SUBROUTINE init_w_subsidence 
78
[1320]79       USE arrays_3d,                                                          &
80           ONLY:  dzu, w_subs, zu
[411]81
[1320]82       USE control_parameters,                                                 &
83           ONLY:  message_string, ocean, subs_vertical_gradient,               &
84                  subs_vertical_gradient_level, subs_vertical_gradient_level_i
85
86       USE indices,                                                            &
87           ONLY:  nzb, nzt
88
89       USE kinds
90
[411]91       IMPLICIT NONE
92
[1320]93       INTEGER(iwp) ::  i !:
94       INTEGER(iwp) ::  k !:
[411]95
[1320]96       REAL(wp)     ::  gradient   !:
97       REAL(wp)     ::  ws_surface !:
98
[1365]99       IF ( .NOT. ALLOCATED( w_subs ))  THEN
[411]100          ALLOCATE( w_subs(nzb:nzt+1) )
[1353]101          w_subs = 0.0_wp
[411]102       ENDIF
103
[1365]104       IF ( ocean )  THEN
[411]105          message_string = 'Applying large scale vertical motion is not ' // &
106                           'allowed for ocean runs'
107          CALL message( 'init_w_subsidence', 'PA0324', 2, 2, 0, 6, 0 )
108       ENDIF
109
110!
111!--   Compute the profile of the subsidence/ascent velocity
112!--   using the given gradients
113      i = 1
[1353]114      gradient = 0.0_wp
115      ws_surface = 0.0_wp
[411]116     
117
[580]118      subs_vertical_gradient_level_i(1) = 0
[411]119      DO  k = 1, nzt+1
[1365]120         IF ( i < 11 )  THEN
[580]121            IF ( subs_vertical_gradient_level(i) < zu(k)  .AND. &
[1353]122                 subs_vertical_gradient_level(i) >= 0.0_wp )  THEN
123               gradient = subs_vertical_gradient(i) / 100.0_wp
[580]124               subs_vertical_gradient_level_i(i) = k - 1
[411]125               i = i + 1
126            ENDIF
127         ENDIF
[1353]128         IF ( gradient /= 0.0_wp )  THEN
[411]129            IF ( k /= 1 )  THEN
130               w_subs(k) = w_subs(k-1) + dzu(k) * gradient
131            ELSE
[1353]132               w_subs(k) = ws_surface   + 0.5_wp * dzu(k) * gradient
[411]133            ENDIF
134         ELSE
135            w_subs(k) = w_subs(k-1)
136         ENDIF
137      ENDDO
138
139!
140!--   In case of no given gradients for the subsidence/ascent velocity,
141!--   choose zero gradient
[1353]142      IF ( subs_vertical_gradient_level(1) == -9999999.9_wp )  THEN
143         subs_vertical_gradient_level(1) = 0.0_wp
[411]144      ENDIF
145
146    END SUBROUTINE init_w_subsidence
147
148
[1365]149    SUBROUTINE subsidence( tendency, var, var_init, ls_index ) 
[411]150
[1320]151       USE arrays_3d,                                                          &
152           ONLY:  ddzu, w_subs
[411]153
[1320]154       USE control_parameters,                                                 &
[1380]155           ONLY:  dt_3d, intermediate_timestep_count, large_scale_forcing,     &
156                  scalar_rayleigh_damping
[1320]157
158       USE indices,                                                            &
159           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzb_s_inner,&
160                  nzt
161
162       USE kinds
163
[1365]164       USE statistics,                                                         &
165           ONLY:  sums_ls_l, weight_pres
166
[411]167       IMPLICIT NONE
168 
[1320]169       INTEGER(iwp) ::  i !:
170       INTEGER(iwp) ::  j !:
171       INTEGER(iwp) ::  k !:
[1365]172       INTEGER(iwp) ::  ls_index !:
[411]173
[1365]174       REAL(wp)     ::  tmp_tend !:
[1320]175       REAL(wp)     ::  tmp_grad !:
[411]176   
[1320]177       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var      !:
178       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  tendency !:
179       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_init                     !:
180       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_mod                      !:
[411]181
[464]182       var_mod = var_init
[411]183
184!
185!--    Influence of w_subsidence on the current tendency term
186       DO  i = nxl, nxr
187          DO  j = nys, nyn
188             DO  k = nzb_s_inner(j,i)+1, nzt 
[1365]189                IF ( w_subs(k) < 0.0_wp )  THEN    ! large-scale subsidence
190                   tmp_tend = - w_subs(k) *                                    &
191                              ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1)
192                ELSE                               ! large-scale ascent
193                   tmp_tend = - w_subs(k) *                                    &
194                              ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k)
[411]195                ENDIF
[1365]196
197                tendency(k,j,i) = tendency(k,j,i) + tmp_tend
198
199                IF ( large_scale_forcing )  THEN
200                   sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend    &
201                                      * weight_pres(intermediate_timestep_count)
202                ENDIF
[411]203             ENDDO
204          ENDDO
205       ENDDO
206
207!
208!--    Shifting of the initial profile is especially necessary with Rayleigh
209!--    damping switched on
[1380]210       IF ( scalar_rayleigh_damping ) THEN
211          DO  k = nzb, nzt
212             IF ( w_subs(k) < 0.0_wp )  THEN      ! large-scale subsidence
213                var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
214                                  ( var_init(k+1) - var_init(k) ) * ddzu(k+1)
215             ENDIF
216          ENDDO
[411]217!
[1380]218!--      At the upper boundary, the initial profile is shifted with aid of
219!--      the gradient tmp_grad. (This is ok if the gradients are linear.)
220         IF ( w_subs(nzt) < 0.0_wp )  THEN
221            tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1)
222            var_mod(nzt+1) = var_init(nzt+1) -  &
223                                 dt_3d * w_subs(nzt+1) * tmp_grad
224         ENDIF
[411]225       
226
[1380]227         DO  k = nzt+1, nzb+1, -1
228            IF ( w_subs(k) >= 0.0_wp )  THEN  ! large-scale ascent
229               var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
230                                  ( var_init(k) - var_init(k-1) ) * ddzu(k) 
231            ENDIF
232         ENDDO
233!
234!--      At the lower boundary shifting is not necessary because the
235!--      subsidence velocity w_subs(nzb) vanishes.
236         IF ( w_subs(nzb+1) >= 0.0_wp )  THEN
237            var_mod(nzb) = var_init(nzb)
[411]238         ENDIF
[1380]239
240         var_init = var_mod
[411]241      ENDIF
242
243
244 END SUBROUTINE subsidence
245
[1365]246 SUBROUTINE subsidence_ij( i, j, tendency, var, var_init, ls_index ) 
[411]247
[1320]248       USE arrays_3d,                                                          &
249           ONLY:  ddzu, w_subs
[411]250
[1320]251       USE control_parameters,                                                 &
[1380]252           ONLY:  dt_3d, intermediate_timestep_count, large_scale_forcing,     &
253                  scalar_rayleigh_damping
[1320]254
255       USE indices,                                                            &
256           ONLY:  nxl, nxlg, nxrg, nyng, nys, nysg, nzb_s_inner, nzb, nzt
257
258       USE kinds
259
[1365]260       USE statistics,                                                         &
261           ONLY:  sums_ls_l, weight_pres
262
[411]263       IMPLICIT NONE
264 
[1320]265       INTEGER(iwp) ::  i !:
266       INTEGER(iwp) ::  j !:
267       INTEGER(iwp) ::  k !:
[1365]268       INTEGER(iwp) ::  ls_index !:
[411]269
[1365]270       REAL(wp)     ::  tmp_tend !:
[1320]271       REAL(wp)     ::  tmp_grad !:
[411]272   
[1320]273       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var      !:
274       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  tendency !:
275       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_init                     !:
276       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_mod                      !:
[411]277
[464]278       var_mod = var_init
[411]279
280!
281!--    Influence of w_subsidence on the current tendency term
282       DO  k = nzb_s_inner(j,i)+1, nzt 
[1365]283          IF ( w_subs(k) < 0.0_wp )  THEN      ! large-scale subsidence
284             tmp_tend = - w_subs(k) * ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1)
285          ELSE                                 ! large-scale ascent
286             tmp_tend = - w_subs(k) * ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k)
[411]287          ENDIF
[1365]288
289          tendency(k,j,i) = tendency(k,j,i) + tmp_tend
290
291          IF ( large_scale_forcing )  THEN
292             sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend          &
293                                     * weight_pres(intermediate_timestep_count)
294          ENDIF
[411]295       ENDDO
296
297
298!
299!--    Shifting of the initial profile is especially necessary with Rayleigh
300!--    damping switched on
[1380]301       IF ( scalar_rayleigh_damping ) THEN
302          IF ( i == nxl .AND. j == nys )  THEN ! shifting only once per PE
[411]303
[1380]304             DO  k = nzb, nzt
305                IF ( w_subs(k) < 0.0_wp )  THEN      ! large-scale subsidence
306                   var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
307                                     ( var_init(k+1) - var_init(k) ) * ddzu(k+1)
308                ENDIF
309             ENDDO
310!
311!--          At the upper boundary, the initial profile is shifted with aid of
312!--          the gradient tmp_grad. (This is ok if the gradients are linear.)
313             IF ( w_subs(nzt) < 0.0_wp )  THEN
314                tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1)
315                var_mod(nzt+1) = var_init(nzt+1) -  &
316                                     dt_3d * w_subs(nzt+1) * tmp_grad
[411]317             ENDIF
318       
319
[1380]320             DO  k = nzt+1, nzb+1, -1
321                IF ( w_subs(k) >= 0.0_wp )  THEN  ! large-scale ascent
322                   var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
323                                      ( var_init(k) - var_init(k-1) ) * ddzu(k)
324                ENDIF
325             ENDDO
326!
327!--          At the lower boundary shifting is not necessary because the
328!--          subsidence velocity w_subs(nzb) vanishes.
329             IF ( w_subs(nzb+1) >= 0.0_wp )  THEN
330                var_mod(nzb) = var_init(nzb)
[411]331             ENDIF
332
[1380]333             var_init = var_mod 
[411]334
[1380]335          ENDIF
[411]336       ENDIF
337
338 END SUBROUTINE subsidence_ij
339
340
341 END MODULE subsidence_mod
Note: See TracBrowser for help on using the repository browser.