source: palm/trunk/SOURCE/subsidence_mod.f90 @ 2716

Last change on this file since 2716 was 2716, checked in by kanani, 6 years ago

Correction of "Former revisions" section

  • Property svn:keywords set to Id
File size: 14.9 KB
RevLine 
[1850]1!> @file subsidence_mod.f90
[2000]2!------------------------------------------------------------------------------!
[2696]3! This file is part of the PALM model system.
[1036]4!
[2000]5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
[1036]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!
[2101]17! Copyright 1997-2017 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[411]20! Current revisions:
21! -----------------
[1683]22!
[2233]23!
[1383]24! Former revisions:
25! -----------------
26! $Id: subsidence_mod.f90 2716 2017-12-29 16:35:59Z kanani $
[2716]27! Corrected "Former revisions" section
28!
29! 2696 2017-12-14 17:12:51Z kanani
30! Change in file header (GPL part)
[1383]31!
[2716]32! 2233 2017-05-30 18:08:54Z suehring
33!
[2233]34! 2232 2017-05-30 17:47:52Z suehring
35! Adjustments to new topography and surface concept
36!
[2001]37! 2000 2016-08-20 18:09:15Z knoop
38! Forced header and separation lines into 80 columns
39!
[1863]40! 1862 2016-04-14 09:07:42Z hoffmann
41! Bugfix: In case of vector machine optimized model runs, sums_ls_l should not
42! be addressed if large_scale_forcing is false because sums_ls_l is not
43! allocated.
44!
[1851]45! 1850 2016-04-08 13:29:27Z maronga
46! Module renamed
47!
[1730]48! 1729 2015-11-20 11:01:48Z gronemeier
49! Bugfix: shifting of initial profiles only once each time step
50!
[1683]51! 1682 2015-10-07 23:56:08Z knoop
52! Code annotations made doxygen readable
53!
[1490]54! 1489 2014-10-30 08:09:12Z raasch
55! bugfix: sums_ls_l can only be used if large_scale_forcing is switched on
56!
[1383]57! 1382 2014-04-30 12:15:41Z boeske
[1382]58! Changed the weighting factor that is used in the summation of subsidence
59! tendencies for profile data output from weight_pres to weight_substep
60! added Neumann boundary conditions for profile data output of subsidence terms
61! at nzt+1
[1321]62!
[1381]63! 1380 2014-04-28 12:40:45Z heinze
64! Shifting only necessary in case of scalar Rayleigh damping
65!
[1366]66! 1365 2014-04-22 15:03:56Z boeske
67! Summation of subsidence tendencies for data output added
68! +ls_index, sums_ls_l, tmp_tend
69!
[1354]70! 1353 2014-04-08 15:21:23Z heinze
71! REAL constants provided with KIND-attribute
72!
[1321]73! 1320 2014-03-20 08:40:49Z raasch
[1320]74! ONLY-attribute added to USE-statements,
75! kind-parameters added to all INTEGER and REAL declaration statements,
76! kinds are defined in new module kinds,
77! old module precision_kind is removed,
78! revision history before 2012 removed,
79! comment fields (!:) to be used for variable explanations added to
80! all variable declaration statements
[411]81!
[1037]82! 1036 2012-10-22 13:43:42Z raasch
83! code put under GPL (PALM 3.9)
84!
[464]85! Revision 3.7 2009-12-11 14:15:58Z heinze
86! Initial revision
[411]87!
88! Description:
89! ------------
[1682]90!> Impact of large-scale subsidence or ascent as tendency term for use
91!> in the prognostic equation of potential temperature. This enables the
92!> construction of a constant boundary layer height z_i with time.
[411]93!-----------------------------------------------------------------------------!
[1682]94 MODULE subsidence_mod
95 
[411]96
97
98    IMPLICIT NONE
99
100    PRIVATE
101    PUBLIC  init_w_subsidence, subsidence
102
103    INTERFACE init_w_subsidence
104       MODULE PROCEDURE init_w_subsidence
105    END INTERFACE init_w_subsidence
106
107    INTERFACE subsidence
108       MODULE PROCEDURE subsidence
109       MODULE PROCEDURE subsidence_ij
110    END INTERFACE subsidence
111
112 CONTAINS
113
[1682]114!------------------------------------------------------------------------------!
115! Description:
116! ------------
117!> @todo Missing subroutine description.
118!------------------------------------------------------------------------------!
[411]119    SUBROUTINE init_w_subsidence 
120
[1320]121       USE arrays_3d,                                                          &
122           ONLY:  dzu, w_subs, zu
[411]123
[1320]124       USE control_parameters,                                                 &
125           ONLY:  message_string, ocean, subs_vertical_gradient,               &
126                  subs_vertical_gradient_level, subs_vertical_gradient_level_i
127
128       USE indices,                                                            &
129           ONLY:  nzb, nzt
130
131       USE kinds
132
[411]133       IMPLICIT NONE
134
[1682]135       INTEGER(iwp) ::  i !<
136       INTEGER(iwp) ::  k !<
[411]137
[1682]138       REAL(wp)     ::  gradient   !<
139       REAL(wp)     ::  ws_surface !<
[1320]140
[1862]141       IF ( .NOT. ALLOCATED( w_subs ) )  THEN
[411]142          ALLOCATE( w_subs(nzb:nzt+1) )
[1353]143          w_subs = 0.0_wp
[411]144       ENDIF
145
[1365]146       IF ( ocean )  THEN
[411]147          message_string = 'Applying large scale vertical motion is not ' // &
148                           'allowed for ocean runs'
149          CALL message( 'init_w_subsidence', 'PA0324', 2, 2, 0, 6, 0 )
150       ENDIF
151
152!
153!--   Compute the profile of the subsidence/ascent velocity
154!--   using the given gradients
155      i = 1
[1353]156      gradient = 0.0_wp
157      ws_surface = 0.0_wp
[411]158     
159
[580]160      subs_vertical_gradient_level_i(1) = 0
[411]161      DO  k = 1, nzt+1
[1365]162         IF ( i < 11 )  THEN
[580]163            IF ( subs_vertical_gradient_level(i) < zu(k)  .AND. &
[1353]164                 subs_vertical_gradient_level(i) >= 0.0_wp )  THEN
165               gradient = subs_vertical_gradient(i) / 100.0_wp
[580]166               subs_vertical_gradient_level_i(i) = k - 1
[411]167               i = i + 1
168            ENDIF
169         ENDIF
[1353]170         IF ( gradient /= 0.0_wp )  THEN
[411]171            IF ( k /= 1 )  THEN
172               w_subs(k) = w_subs(k-1) + dzu(k) * gradient
173            ELSE
[1353]174               w_subs(k) = ws_surface   + 0.5_wp * dzu(k) * gradient
[411]175            ENDIF
176         ELSE
177            w_subs(k) = w_subs(k-1)
178         ENDIF
179      ENDDO
180
181!
182!--   In case of no given gradients for the subsidence/ascent velocity,
183!--   choose zero gradient
[1353]184      IF ( subs_vertical_gradient_level(1) == -9999999.9_wp )  THEN
185         subs_vertical_gradient_level(1) = 0.0_wp
[411]186      ENDIF
187
188    END SUBROUTINE init_w_subsidence
189
190
[1682]191!------------------------------------------------------------------------------!
192! Description:
193! ------------
194!> @todo Missing subroutine description.
195!------------------------------------------------------------------------------!
[1365]196    SUBROUTINE subsidence( tendency, var, var_init, ls_index ) 
[411]197
[1320]198       USE arrays_3d,                                                          &
199           ONLY:  ddzu, w_subs
[411]200
[1320]201       USE control_parameters,                                                 &
[1380]202           ONLY:  dt_3d, intermediate_timestep_count, large_scale_forcing,     &
203                  scalar_rayleigh_damping
[1320]204
205       USE indices,                                                            &
[2232]206           ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt,        &
207                  wall_flags_0
[1320]208
209       USE kinds
210
[1365]211       USE statistics,                                                         &
[1382]212           ONLY:  sums_ls_l, weight_substep
[1365]213
[411]214       IMPLICIT NONE
215 
[1682]216       INTEGER(iwp) ::  i !<
217       INTEGER(iwp) ::  j !<
218       INTEGER(iwp) ::  k !<
219       INTEGER(iwp) ::  ls_index !<
[411]220
[1682]221       REAL(wp)     ::  tmp_tend !<
222       REAL(wp)     ::  tmp_grad !<
[411]223   
[1682]224       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var      !<
225       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  tendency !<
226       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_init                     !<
227       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_mod                      !<
[411]228
[464]229       var_mod = var_init
[411]230
231!
232!--    Influence of w_subsidence on the current tendency term
233       DO  i = nxl, nxr
234          DO  j = nys, nyn
[1382]235
[2232]236             DO  k = nzb+1, nzt 
[1365]237                IF ( w_subs(k) < 0.0_wp )  THEN    ! large-scale subsidence
238                   tmp_tend = - w_subs(k) *                                    &
[2232]239                              ( var(k+1,j,i) - var(k,j,i) ) * ddzu(k+1) *      &
240                                        MERGE( 1.0_wp, 0.0_wp,                 &
241                                               BTEST( wall_flags_0(k,j,i), 0 ) )
[1365]242                ELSE                               ! large-scale ascent
243                   tmp_tend = - w_subs(k) *                                    &
[2232]244                              ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k) *        &
245                                        MERGE( 1.0_wp, 0.0_wp,                 &
246                                               BTEST( wall_flags_0(k,j,i), 0 ) )
[411]247                ENDIF
[1365]248
249                tendency(k,j,i) = tendency(k,j,i) + tmp_tend
250
251                IF ( large_scale_forcing )  THEN
252                   sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend    &
[2232]253                                 * weight_substep(intermediate_timestep_count) &
254                                 * MERGE( 1.0_wp, 0.0_wp,                      &
255                                          BTEST( wall_flags_0(k,j,i), 0 ) )
[1365]256                ENDIF
[411]257             ENDDO
[1382]258
[1862]259             IF ( large_scale_forcing )  THEN
260                sums_ls_l(nzt+1,ls_index) = sums_ls_l(nzt,ls_index)
261             ENDIF
[1382]262
[411]263          ENDDO
264       ENDDO
265
266!
267!--    Shifting of the initial profile is especially necessary with Rayleigh
268!--    damping switched on
[1729]269       IF ( scalar_rayleigh_damping .AND.                                      &
270            intermediate_timestep_count == 1 )  THEN
[1380]271          DO  k = nzb, nzt
272             IF ( w_subs(k) < 0.0_wp )  THEN      ! large-scale subsidence
273                var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
274                                  ( var_init(k+1) - var_init(k) ) * ddzu(k+1)
275             ENDIF
276          ENDDO
[411]277!
[1380]278!--      At the upper boundary, the initial profile is shifted with aid of
279!--      the gradient tmp_grad. (This is ok if the gradients are linear.)
280         IF ( w_subs(nzt) < 0.0_wp )  THEN
281            tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1)
282            var_mod(nzt+1) = var_init(nzt+1) -  &
283                                 dt_3d * w_subs(nzt+1) * tmp_grad
284         ENDIF
[411]285       
286
[1380]287         DO  k = nzt+1, nzb+1, -1
288            IF ( w_subs(k) >= 0.0_wp )  THEN  ! large-scale ascent
289               var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
290                                  ( var_init(k) - var_init(k-1) ) * ddzu(k) 
291            ENDIF
292         ENDDO
293!
294!--      At the lower boundary shifting is not necessary because the
295!--      subsidence velocity w_subs(nzb) vanishes.
296         IF ( w_subs(nzb+1) >= 0.0_wp )  THEN
297            var_mod(nzb) = var_init(nzb)
[411]298         ENDIF
[1380]299
300         var_init = var_mod
[411]301      ENDIF
302
303
304 END SUBROUTINE subsidence
305
[1682]306!------------------------------------------------------------------------------!
307! Description:
308! ------------
309!> @todo Missing subroutine description.
310!------------------------------------------------------------------------------!
[1365]311 SUBROUTINE subsidence_ij( i, j, tendency, var, var_init, ls_index ) 
[411]312
[1320]313       USE arrays_3d,                                                          &
314           ONLY:  ddzu, w_subs
[411]315
[1320]316       USE control_parameters,                                                 &
[1380]317           ONLY:  dt_3d, intermediate_timestep_count, large_scale_forcing,     &
318                  scalar_rayleigh_damping
[1320]319
320       USE indices,                                                            &
[2232]321           ONLY:  nxl, nxlg, nxrg, nyng, nys, nysg, nzb, nzt, wall_flags_0
[1320]322
323       USE kinds
324
[1365]325       USE statistics,                                                         &
[1382]326           ONLY:  sums_ls_l, weight_substep
[1365]327
[411]328       IMPLICIT NONE
329 
[1682]330       INTEGER(iwp) ::  i !<
331       INTEGER(iwp) ::  j !<
332       INTEGER(iwp) ::  k !<
333       INTEGER(iwp) ::  ls_index !<
[411]334
[1682]335       REAL(wp)     ::  tmp_tend !<
336       REAL(wp)     ::  tmp_grad !<
[411]337   
[1682]338       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  var      !<
339       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ::  tendency !<
340       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_init                     !<
341       REAL(wp), DIMENSION(nzb:nzt+1) ::  var_mod                      !<
[411]342
[464]343       var_mod = var_init
[411]344
345!
346!--    Influence of w_subsidence on the current tendency term
[2232]347       DO  k = nzb+1, nzt 
[1365]348          IF ( w_subs(k) < 0.0_wp )  THEN      ! large-scale subsidence
[2232]349             tmp_tend = - w_subs(k) * ( var(k+1,j,i) - var(k,j,i) )            &
350                                    * ddzu(k+1)                                &
351                                    * MERGE( 1.0_wp, 0.0_wp,                   &
352                                             BTEST( wall_flags_0(k,j,i), 0 ) )
[1365]353          ELSE                                 ! large-scale ascent
[2232]354             tmp_tend = - w_subs(k) * ( var(k,j,i) - var(k-1,j,i) ) * ddzu(k)  &
355                                    * MERGE( 1.0_wp, 0.0_wp,                   &
356                                             BTEST( wall_flags_0(k,j,i), 0 ) )
[411]357          ENDIF
[1365]358
359          tendency(k,j,i) = tendency(k,j,i) + tmp_tend
360
361          IF ( large_scale_forcing )  THEN
362             sums_ls_l(k,ls_index) = sums_ls_l(k,ls_index) + tmp_tend          &
[2232]363                                  * weight_substep(intermediate_timestep_count)&
364                                  * MERGE( 1.0_wp, 0.0_wp,                     &
365                                           BTEST( wall_flags_0(k,j,i), 0 ) )
[1365]366          ENDIF
[411]367       ENDDO
368
[1489]369       IF ( large_scale_forcing )  THEN
370          sums_ls_l(nzt+1,ls_index) = sums_ls_l(nzt,ls_index)
371       ENDIF
[411]372
373!
374!--    Shifting of the initial profile is especially necessary with Rayleigh
375!--    damping switched on
[1729]376       IF ( scalar_rayleigh_damping .AND.                                      &
377            intermediate_timestep_count == 1 )  THEN
[1380]378          IF ( i == nxl .AND. j == nys )  THEN ! shifting only once per PE
[411]379
[1380]380             DO  k = nzb, nzt
381                IF ( w_subs(k) < 0.0_wp )  THEN      ! large-scale subsidence
382                   var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
383                                     ( var_init(k+1) - var_init(k) ) * ddzu(k+1)
384                ENDIF
385             ENDDO
386!
387!--          At the upper boundary, the initial profile is shifted with aid of
388!--          the gradient tmp_grad. (This is ok if the gradients are linear.)
389             IF ( w_subs(nzt) < 0.0_wp )  THEN
390                tmp_grad = ( var_init(nzt+1) - var_init(nzt) ) * ddzu(nzt+1)
391                var_mod(nzt+1) = var_init(nzt+1) -  &
392                                     dt_3d * w_subs(nzt+1) * tmp_grad
[411]393             ENDIF
394       
395
[1380]396             DO  k = nzt+1, nzb+1, -1
397                IF ( w_subs(k) >= 0.0_wp )  THEN  ! large-scale ascent
398                   var_mod(k) = var_init(k) - dt_3d * w_subs(k) *  &
399                                      ( var_init(k) - var_init(k-1) ) * ddzu(k)
400                ENDIF
401             ENDDO
402!
403!--          At the lower boundary shifting is not necessary because the
404!--          subsidence velocity w_subs(nzb) vanishes.
405             IF ( w_subs(nzb+1) >= 0.0_wp )  THEN
406                var_mod(nzb) = var_init(nzb)
[411]407             ENDIF
408
[1380]409             var_init = var_mod 
[411]410
[1380]411          ENDIF
[411]412       ENDIF
413
414 END SUBROUTINE subsidence_ij
415
416
417 END MODULE subsidence_mod
Note: See TracBrowser for help on using the repository browser.