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

Last change on this file since 3301 was 3294, checked in by raasch, 6 years ago

modularization of the ocean code

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