source: palm/trunk/SOURCE/plant_canopy_model_mod.f90 @ 1960

Last change on this file since 1960 was 1960, checked in by suehring, 8 years ago

Separate balance equations for humidity and passive_scalar

  • Property svn:keywords set to Id
File size: 54.0 KB
Line 
1!> @file plant_canopy_model_mod.f90
2!--------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2016 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! -----------------
21! Separate humidity and passive scalar
22!
23! Former revisions:
24! -----------------
25! $Id: plant_canopy_model_mod.f90 1960 2016-07-12 16:34:24Z suehring $
26!
27! 1953 2016-06-21 09:28:42Z suehring
28! Bugfix, lad_s and lad must be public
29!
30! 1826 2016-04-07 12:01:39Z maronga
31! Further modularization
32!
33! 1721 2015-11-16 12:56:48Z raasch
34! bugfixes: shf is reduced in areas covered with canopy only,
35!           canopy is set on top of topography
36!
37! 1682 2015-10-07 23:56:08Z knoop
38! Code annotations made doxygen readable
39!
40! 1484 2014-10-21 10:53:05Z kanani
41! Changes due to new module structure of the plant canopy model:
42!   module plant_canopy_model_mod now contains a subroutine for the
43!   initialization of the canopy model (pcm_init),
44!   limitation of the canopy drag (previously accounted for by calculation of
45!   a limiting canopy timestep for the determination of the maximum LES timestep
46!   in subroutine timestep) is now realized by the calculation of pre-tendencies
47!   and preliminary velocities in subroutine pcm_tendency,
48!   some redundant MPI communication removed in subroutine pcm_init
49!   (was previously in init_3d_model),
50!   unnecessary 3d-arrays lad_u, lad_v, lad_w removed - lad information on the
51!   respective grid is now provided only by lad_s (e.g. in the calculation of
52!   the tendency terms or of cum_lai_hf),
53!   drag_coefficient, lai, leaf_surface_concentration,
54!   scalar_exchange_coefficient, sec and sls renamed to canopy_drag_coeff,
55!   cum_lai_hf, leaf_surface_conc, leaf_scalar_exch_coeff, lsec and lsc,
56!   respectively,
57!   unnecessary 3d-arrays cdc, lsc and lsec now defined as single-value constants,
58!   USE-statements and ONLY-lists modified accordingly
59!
60! 1340 2014-03-25 19:45:13Z kanani
61! REAL constants defined as wp-kind
62!
63! 1320 2014-03-20 08:40:49Z raasch
64! ONLY-attribute added to USE-statements,
65! kind-parameters added to all INTEGER and REAL declaration statements,
66! kinds are defined in new module kinds,
67! old module precision_kind is removed,
68! revision history before 2012 removed,
69! comment fields (!:) to be used for variable explanations added to
70! all variable declaration statements
71!
72! 1036 2012-10-22 13:43:42Z raasch
73! code put under GPL (PALM 3.9)
74!
75! 138 2007-11-28 10:03:58Z letzel
76! Initial revision
77!
78! Description:
79! ------------
80!> 1) Initialization of the canopy model, e.g. construction of leaf area density
81!> profile (subroutine pcm_init).
82!> 2) Calculation of sinks and sources of momentum, heat and scalar concentration
83!> due to canopy elements (subroutine pcm_tendency).
84!------------------------------------------------------------------------------!
85 MODULE plant_canopy_model_mod
86 
87    USE arrays_3d,                                                             &
88        ONLY:  dzu, dzw, e, q, s, shf, tend, u, v, w, zu, zw 
89
90    USE indices,                                                               &
91        ONLY:  nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
92               nz, nzb, nzb_s_inner, nzb_u_inner, nzb_v_inner, nzb_w_inner, nzt
93
94    USE kinds
95
96
97    IMPLICIT NONE
98
99
100    CHARACTER (LEN=20)   ::  canopy_mode = 'block' !< canopy coverage
101
102    INTEGER(iwp) ::  pch_index = 0                 !< plant canopy height/top index
103    INTEGER(iwp) ::                                                            &
104       lad_vertical_gradient_level_ind(10) = -9999 !< lad-profile levels (index)
105
106    LOGICAL ::  calc_beta_lad_profile = .FALSE. !< switch for calc. of lad from beta func.
107    LOGICAL ::  plant_canopy = .FALSE.          !< switch for use of canopy model
108
109    REAL(wp) ::  alpha_lad = 9999999.9_wp   !< coefficient for lad calculation
110    REAL(wp) ::  beta_lad = 9999999.9_wp    !< coefficient for lad calculation
111    REAL(wp) ::  canopy_drag_coeff = 0.0_wp !< canopy drag coefficient (parameter)
112    REAL(wp) ::  cdc = 0.0_wp               !< canopy drag coeff. (abbreviation used in equations)
113    REAL(wp) ::  cthf = 0.0_wp              !< canopy top heat flux
114    REAL(wp) ::  dt_plant_canopy = 0.0_wp   !< timestep account. for canopy drag
115    REAL(wp) ::  lad_surface = 0.0_wp       !< lad surface value
116    REAL(wp) ::  lai_beta = 0.0_wp          !< leaf area index (lai) for lad calc.
117    REAL(wp) ::                                                                &
118       leaf_scalar_exch_coeff = 0.0_wp      !< canopy scalar exchange coeff.
119    REAL(wp) ::                                                                &
120       leaf_surface_conc = 0.0_wp           !< leaf surface concentration
121    REAL(wp) ::  lsec = 0.0_wp              !< leaf scalar exchange coeff.
122    REAL(wp) ::  lsc = 0.0_wp               !< leaf surface concentration
123
124    REAL(wp) ::                                                                &
125       lad_vertical_gradient(10) = 0.0_wp              !< lad gradient
126    REAL(wp) ::                                                                &
127       lad_vertical_gradient_level(10) = -9999999.9_wp !< lad-prof. levels (in m)
128
129    REAL(wp), DIMENSION(:), ALLOCATABLE ::  lad            !< leaf area density
130    REAL(wp), DIMENSION(:), ALLOCATABLE ::  pre_lad        !< preliminary lad
131   
132    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::                                 &
133       canopy_heat_flux                                    !< canopy heat flux
134    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  cum_lai_hf !< cumulative lai for heatflux calc.
135    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  lad_s      !< lad on scalar-grid
136
137
138    SAVE
139
140
141    PRIVATE
142 
143!
144!-- Public functions
145    PUBLIC pcm_check_parameters, pcm_header, pcm_init, pcm_parin, pcm_tendency
146
147!
148!-- Public variables and constants
149    PUBLIC canopy_mode, cthf, dt_plant_canopy, lad, lad_s, plant_canopy
150
151
152    INTERFACE pcm_check_parameters
153       MODULE PROCEDURE pcm_check_parameters
154    END INTERFACE pcm_check_parameters     
155   
156     INTERFACE pcm_header
157       MODULE PROCEDURE pcm_header
158    END INTERFACE pcm_header       
159   
160    INTERFACE pcm_init
161       MODULE PROCEDURE pcm_init
162    END INTERFACE pcm_init
163
164    INTERFACE pcm_parin
165       MODULE PROCEDURE pcm_parin
166    END INTERFACE pcm_parin 
167   
168    INTERFACE pcm_tendency
169       MODULE PROCEDURE pcm_tendency
170       MODULE PROCEDURE pcm_tendency_ij
171    END INTERFACE pcm_tendency
172
173
174 CONTAINS
175
176 
177!------------------------------------------------------------------------------!
178! Description:
179! ------------
180!> Check parameters routine for plant canopy model
181!------------------------------------------------------------------------------!
182    SUBROUTINE pcm_check_parameters
183
184       USE control_parameters,                                                 &
185           ONLY: cloud_physics, message_string, microphysics_seifert
186                 
187   
188       IMPLICIT NONE
189
190   
191       IF ( canopy_drag_coeff == 0.0_wp )  THEN
192          message_string = 'plant_canopy = .TRUE. requires a non-zero drag '// &
193                           'coefficient & given value is canopy_drag_coeff = 0.0'
194          CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
195       ENDIF
196   
197       IF ( ( alpha_lad /= 9999999.9_wp  .AND.  beta_lad == 9999999.9_wp )  .OR.&
198              beta_lad /= 9999999.9_wp   .AND.  alpha_lad == 9999999.9_wp )  THEN
199          message_string = 'using the beta function for the construction ' //  &
200                           'of the leaf area density profile requires '    //  &
201                           'both alpha_lad and beta_lad to be /= 9999999.9'
202          CALL message( 'check_parameters', 'PA0118', 1, 2, 0, 6, 0 )
203       ENDIF
204   
205       IF ( calc_beta_lad_profile  .AND.  lai_beta == 0.0_wp )  THEN
206          message_string = 'using the beta function for the construction ' //  &
207                           'of the leaf area density profile requires '    //  &
208                           'a non-zero lai_beta, but given value is '      //  &
209                           'lai_beta = 0.0'
210          CALL message( 'check_parameters', 'PA0119', 1, 2, 0, 6, 0 )
211       ENDIF
212
213       IF ( calc_beta_lad_profile  .AND.  lad_surface /= 0.0_wp )  THEN
214          message_string = 'simultaneous setting of alpha_lad /= 9999999.9' // &
215                           'and lad_surface /= 0.0 is not possible, '       // &
216                           'use either vertical gradients or the beta '     // &
217                           'function for the construction of the leaf area '// &
218                           'density profile'
219          CALL message( 'check_parameters', 'PA0120', 1, 2, 0, 6, 0 )
220       ENDIF
221
222       IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
223          message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' // &
224                          ' seifert_beheng'
225          CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 )
226       ENDIF
227
228 
229    END SUBROUTINE pcm_check_parameters 
230 
231
232!------------------------------------------------------------------------------!
233! Description:
234! ------------
235!> Header output for plant canopy model
236!------------------------------------------------------------------------------!
237    SUBROUTINE pcm_header ( io )
238
239       USE control_parameters,                                                 &
240           ONLY: dz, passive_scalar
241
242
243       IMPLICIT NONE
244 
245       CHARACTER (LEN=10) ::  coor_chr            !<
246
247       CHARACTER (LEN=86) ::  coordinates         !<
248       CHARACTER (LEN=86) ::  gradients           !<
249       CHARACTER (LEN=86) ::  leaf_area_density   !<
250       CHARACTER (LEN=86) ::  slices              !<
251 
252       INTEGER(iwp) :: i                !<
253       INTEGER(iwp),  INTENT(IN) ::  io !< Unit of the output file
254       INTEGER(iwp) :: k                !<       
255   
256       REAL(wp) ::  canopy_height       !< canopy height (in m)
257       
258       canopy_height = pch_index * dz
259
260       WRITE ( io, 1 )  canopy_mode, canopy_height, pch_index,                 &
261                          canopy_drag_coeff
262       IF ( passive_scalar )  THEN
263          WRITE ( io, 2 )  leaf_scalar_exch_coeff,                             &
264                             leaf_surface_conc
265       ENDIF
266
267!
268!--    Heat flux at the top of vegetation
269       WRITE ( io, 3 )  cthf
270
271!
272!--    Leaf area density profile, calculated either from given vertical
273!--    gradients or from beta probability density function.
274       IF (  .NOT.  calc_beta_lad_profile )  THEN
275
276!--       Building output strings, starting with surface value
277          WRITE ( leaf_area_density, '(F7.4)' )  lad_surface
278          gradients = '------'
279          slices = '     0'
280          coordinates = '   0.0'
281          i = 1
282          DO  WHILE ( i < 11  .AND.  lad_vertical_gradient_level_ind(i)        &
283                      /= -9999 )
284
285             WRITE (coor_chr,'(F7.2)')  lad(lad_vertical_gradient_level_ind(i))
286             leaf_area_density = TRIM( leaf_area_density ) // ' ' //           &
287                                 TRIM( coor_chr )
288 
289             WRITE (coor_chr,'(F7.2)')  lad_vertical_gradient(i)
290             gradients = TRIM( gradients ) // ' ' // TRIM( coor_chr )
291
292             WRITE (coor_chr,'(I7)')  lad_vertical_gradient_level_ind(i)
293             slices = TRIM( slices ) // ' ' // TRIM( coor_chr )
294
295             WRITE (coor_chr,'(F7.1)')  lad_vertical_gradient_level(i)
296             coordinates = TRIM( coordinates ) // ' '  // TRIM( coor_chr )
297
298             i = i + 1
299          ENDDO
300
301          WRITE ( io, 4 )  TRIM( coordinates ), TRIM( leaf_area_density ),     &
302                             TRIM( gradients ), TRIM( slices )
303
304       ELSE
305       
306          WRITE ( leaf_area_density, '(F7.4)' )  lad_surface
307          coordinates = '   0.0'
308         
309          DO  k = 1, pch_index
310
311             WRITE (coor_chr,'(F7.2)')  lad(k)
312             leaf_area_density = TRIM( leaf_area_density ) // ' ' //           &
313                                 TRIM( coor_chr )
314 
315             WRITE (coor_chr,'(F7.1)')  zu(k)
316             coordinates = TRIM( coordinates ) // ' '  // TRIM( coor_chr )
317
318          ENDDO       
319
320          WRITE ( io, 5 ) TRIM( coordinates ), TRIM( leaf_area_density ),      &
321                          alpha_lad, beta_lad, lai_beta
322
323       ENDIF 
324
3251 FORMAT (//' Vegetation canopy (drag) model:'/                                &
326              ' ------------------------------'//                              &
327              ' Canopy mode: ', A /                                            &
328              ' Canopy height: ',F6.2,'m (',I4,' grid points)' /               &
329              ' Leaf drag coefficient: ',F6.2 /)
3302 FORMAT (/ ' Scalar exchange coefficient: ',F6.2 /                            &
331              ' Scalar concentration at leaf surfaces in kg/m**3: ',F6.2 /)
3323 FORMAT (' Predefined constant heatflux at the top of the vegetation: ',F6.2, &
333          ' K m/s')
3344 FORMAT (/ ' Characteristic levels of the leaf area density:'//               &
335              ' Height:              ',A,'  m'/                                &
336              ' Leaf area density:   ',A,'  m**2/m**3'/                        &
337              ' Gradient:            ',A,'  m**2/m**4'/                        &
338              ' Gridpoint:           ',A)
3395 FORMAT (//' Characteristic levels of the leaf area density and coefficients:'&
340          //  ' Height:              ',A,'  m'/                                &
341              ' Leaf area density:   ',A,'  m**2/m**3'/                        &
342              ' Coefficient alpha: ',F6.2 /                                    &
343              ' Coefficient beta: ',F6.2 /                                     &
344              ' Leaf area index: ',F6.2,'  m**2/m**2' /)   
345       
346    END SUBROUTINE pcm_header
347 
348 
349!------------------------------------------------------------------------------!
350! Description:
351! ------------
352!> Initialization of the plant canopy model
353!------------------------------------------------------------------------------!
354    SUBROUTINE pcm_init
355   
356
357       USE control_parameters,                                                 &
358           ONLY: dz, ocean, passive_scalar
359
360
361       IMPLICIT NONE
362
363       INTEGER(iwp) ::  i !< running index
364       INTEGER(iwp) ::  j !< running index
365       INTEGER(iwp) ::  k !< running index
366
367       REAL(wp) ::  int_bpdf      !< vertical integral for lad-profile construction
368       REAL(wp) ::  dzh           !< vertical grid spacing in units of canopy height
369       REAL(wp) ::  gradient      !< gradient for lad-profile construction
370       REAL(wp) ::  canopy_height !< canopy height for lad-profile construction
371
372!
373!--    Allocate one-dimensional arrays for the computation of the
374!--    leaf area density (lad) profile
375       ALLOCATE( lad(0:nz+1), pre_lad(0:nz+1) )
376       lad = 0.0_wp
377       pre_lad = 0.0_wp
378
379!
380!--    Set flag that indicates that the lad-profile shall be calculated by using
381!--    a beta probability density function
382       IF ( alpha_lad /= 9999999.9_wp  .AND.  beta_lad /= 9999999.9_wp )  THEN
383          calc_beta_lad_profile = .TRUE.
384       ENDIF
385       
386       
387!
388!--    Compute the profile of leaf area density used in the plant
389!--    canopy model. The profile can either be constructed from
390!--    prescribed vertical gradients of the leaf area density or by
391!--    using a beta probability density function (see e.g. Markkanen et al.,
392!--    2003: Boundary-Layer Meteorology, 106, 437-459)
393       IF (  .NOT.  calc_beta_lad_profile )  THEN   
394
395!
396!--       Use vertical gradients for lad-profile construction   
397          i = 1
398          gradient = 0.0_wp
399
400          IF (  .NOT.  ocean )  THEN
401
402             lad(0) = lad_surface
403             lad_vertical_gradient_level_ind(1) = 0
404 
405             DO k = 1, pch_index
406                IF ( i < 11 )  THEN
407                   IF ( lad_vertical_gradient_level(i) < zu(k)  .AND.          &
408                        lad_vertical_gradient_level(i) >= 0.0_wp )  THEN
409                      gradient = lad_vertical_gradient(i)
410                      lad_vertical_gradient_level_ind(i) = k - 1
411                      i = i + 1
412                   ENDIF
413                ENDIF
414                IF ( gradient /= 0.0_wp )  THEN
415                   IF ( k /= 1 )  THEN
416                      lad(k) = lad(k-1) + dzu(k) * gradient
417                   ELSE
418                      lad(k) = lad_surface + dzu(k) * gradient
419                   ENDIF
420                ELSE
421                   lad(k) = lad(k-1)
422                ENDIF
423             ENDDO
424
425          ENDIF
426
427!
428!--       In case of no given leaf area density gradients, choose a vanishing
429!--       gradient. This information is used for the HEADER and the RUN_CONTROL
430!--       file.
431          IF ( lad_vertical_gradient_level(1) == -9999999.9_wp )  THEN
432             lad_vertical_gradient_level(1) = 0.0_wp
433          ENDIF
434
435       ELSE
436
437!
438!--       Use beta function for lad-profile construction
439          int_bpdf = 0.0_wp
440          canopy_height = pch_index * dz
441
442          DO k = nzb, pch_index
443             int_bpdf = int_bpdf +                                             &
444                      ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) *  &
445                      ( ( 1.0_wp - ( zw(k) / canopy_height ) )**(              &
446                          beta_lad-1.0_wp ) )                                  &
447                      * ( ( zw(k+1)-zw(k) ) / canopy_height ) )
448          ENDDO
449
450!
451!--       Preliminary lad profile (defined on w-grid)
452          DO k = nzb, pch_index
453             pre_lad(k) =  lai_beta *                                          &
454                        ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) )  &
455                        * ( ( 1.0_wp - ( zw(k) / canopy_height ) )**(          &
456                              beta_lad-1.0_wp ) ) / int_bpdf                   &
457                        ) / canopy_height
458          ENDDO
459
460!
461!--       Final lad profile (defined on scalar-grid level, since most prognostic
462!--       quantities are defined there, hence, less interpolation is required
463!--       when calculating the canopy tendencies)
464          lad(0) = pre_lad(0)
465          DO k = nzb+1, pch_index
466             lad(k) = 0.5 * ( pre_lad(k-1) + pre_lad(k) )
467          ENDDO         
468
469       ENDIF
470
471!
472!--    Allocate 3D-array for the leaf area density (lad_s). In case of a
473!--    prescribed canopy-top heat flux (cthf), allocate 3D-arrays for
474!--    the cumulative leaf area index (cum_lai_hf) and the canopy heat flux.
475       ALLOCATE( lad_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
476
477       IF ( cthf /= 0.0_wp )  THEN
478          ALLOCATE( cum_lai_hf(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                 &
479                    canopy_heat_flux(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
480       ENDIF
481
482!
483!--    Initialize canopy parameters cdc (canopy drag coefficient),
484!--    lsec (leaf scalar exchange coefficient), lsc (leaf surface concentration)
485!--    with the prescribed values
486       cdc = canopy_drag_coeff
487       lsec = leaf_scalar_exch_coeff
488       lsc = leaf_surface_conc
489
490!
491!--    Initialization of the canopy coverage in the model domain:
492!--    Setting the parameter canopy_mode = 'block' initializes a canopy, which
493!--    fully covers the domain surface
494       SELECT CASE ( TRIM( canopy_mode ) )
495
496          CASE( 'block' )
497
498             DO  i = nxlg, nxrg
499                DO  j = nysg, nyng
500                   lad_s(:,j,i) = lad(:)
501                ENDDO
502             ENDDO
503
504          CASE DEFAULT
505
506!
507!--       The DEFAULT case is reached either if the parameter
508!--       canopy mode contains a wrong character string or if the
509!--       user has coded a special case in the user interface.
510!--       There, the subroutine user_init_plant_canopy checks
511!--       which of these two conditions applies.
512          CALL user_init_plant_canopy
513 
514       END SELECT
515
516!
517!--    Initialization of the canopy heat source distribution
518       IF ( cthf /= 0.0_wp )  THEN
519!
520!--       Piecewise calculation of the leaf area index by vertical
521!--       integration of the leaf area density
522          cum_lai_hf(:,:,:) = 0.0_wp
523          DO  i = nxlg, nxrg
524             DO  j = nysg, nyng
525                DO  k = pch_index-1, 0, -1
526                   IF ( k == pch_index-1 )  THEN
527                      cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) +                &
528                         ( 0.5_wp * lad_s(k+1,j,i) *                           &
529                           ( zw(k+1) - zu(k+1) ) )  +                          &
530                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) +              &
531                                                 lad_s(k,j,i) ) +              &
532                                      lad_s(k+1,j,i) ) *                       &
533                           ( zu(k+1) - zw(k) ) ) 
534                   ELSE
535                      cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) +                &
536                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+2,j,i) +              &
537                                                 lad_s(k+1,j,i) ) +            &
538                                      lad_s(k+1,j,i) ) *                       &
539                           ( zw(k+1) - zu(k+1) ) )  +                          &
540                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) +              &
541                                                 lad_s(k,j,i) ) +              &
542                                      lad_s(k+1,j,i) ) *                       &
543                           ( zu(k+1) - zw(k) ) )
544                   ENDIF
545                ENDDO
546             ENDDO
547          ENDDO
548
549!
550!--       Calculation of the upward kinematic vertical heat flux within the
551!--       canopy
552          DO  i = nxlg, nxrg
553             DO  j = nysg, nyng
554                DO  k = 0, pch_index
555                   canopy_heat_flux(k,j,i) = cthf *                            &
556                                             exp( -0.6_wp * cum_lai_hf(k,j,i) )
557                ENDDO
558             ENDDO
559          ENDDO
560
561!
562!--       In areas covered with canopy, the surface heat flux is set to
563!--       the surface value of the above calculated in-canopy heat flux
564!--       distribution
565          DO  i = nxlg,nxrg
566             DO  j = nysg, nyng
567                IF ( canopy_heat_flux(0,j,i) /= cthf )  THEN
568                   shf(j,i) = canopy_heat_flux(0,j,i)
569                ENDIF
570             ENDDO
571          ENDDO
572
573       ENDIF
574
575
576
577    END SUBROUTINE pcm_init
578
579
580
581!------------------------------------------------------------------------------!
582! Description:
583! ------------
584!> Calculation of the tendency terms, accounting for the effect of the plant
585!> canopy on momentum and scalar quantities.
586!>
587!> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0
588!> (defined on scalar grid), as initialized in subroutine pcm_init.
589!> The lad on the w-grid is vertically interpolated from the surrounding
590!> lad_s. The upper boundary of the canopy is defined on the w-grid at
591!> k = pch_index. Here, the lad is zero.
592!>
593!> The canopy drag must be limited (previously accounted for by calculation of
594!> a limiting canopy timestep for the determination of the maximum LES timestep
595!> in subroutine timestep), since it is physically impossible that the canopy
596!> drag alone can locally change the sign of a velocity component. This
597!> limitation is realized by calculating preliminary tendencies and velocities.
598!> It is subsequently checked if the preliminary new velocity has a different
599!> sign than the current velocity. If so, the tendency is limited in a way that
600!> the velocity can at maximum be reduced to zero by the canopy drag.
601!>
602!>
603!> Call for all grid points
604!------------------------------------------------------------------------------!
605    SUBROUTINE pcm_tendency( component )
606
607
608       USE control_parameters,                                                 &
609           ONLY:  dt_3d, message_string
610
611       USE kinds
612
613       IMPLICIT NONE
614
615       INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
616       INTEGER(iwp) ::  i         !< running index
617       INTEGER(iwp) ::  j         !< running index
618       INTEGER(iwp) ::  k         !< running index
619       INTEGER(iwp) ::  kk        !< running index for flat lad arrays
620
621       REAL(wp) ::  ddt_3d    !< inverse of the LES timestep (dt_3d)
622       REAL(wp) ::  lad_local !< local lad value
623       REAL(wp) ::  pre_tend  !< preliminary tendency
624       REAL(wp) ::  pre_u     !< preliminary u-value
625       REAL(wp) ::  pre_v     !< preliminary v-value
626       REAL(wp) ::  pre_w     !< preliminary w-value
627
628
629       ddt_3d = 1.0_wp / dt_3d
630 
631!
632!--    Compute drag for the three velocity components and the SGS-TKE:
633       SELECT CASE ( component )
634
635!
636!--       u-component
637          CASE ( 1 )
638             DO  i = nxlu, nxr
639                DO  j = nys, nyn
640                   DO  k = nzb_u_inner(j,i)+1, nzb_u_inner(j,i)+pch_index
641
642                      kk = k - nzb_u_inner(j,i)  !- lad arrays are defined flat
643!
644!--                   In order to create sharp boundaries of the plant canopy,
645!--                   the lad on the u-grid at index (k,j,i) is equal to
646!--                   lad_s(k,j,i), rather than being interpolated from the
647!--                   surrounding lad_s, because this would yield smaller lad
648!--                   at the canopy boundaries than inside of the canopy.
649!--                   For the same reason, the lad at the rightmost(i+1)canopy
650!--                   boundary on the u-grid equals lad_s(k,j,i).
651                      lad_local = lad_s(kk,j,i)
652                      IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp )&
653                      THEN
654                         lad_local = lad_s(kk,j,i-1)
655                      ENDIF
656
657                      pre_tend = 0.0_wp
658                      pre_u = 0.0_wp
659!
660!--                   Calculate preliminary value (pre_tend) of the tendency
661                      pre_tend = - cdc *                                       &
662                                   lad_local *                                 &
663                                   SQRT( u(k,j,i)**2 +                         &
664                                         ( 0.25_wp * ( v(k,j,i-1) +            &
665                                                       v(k,j,i)   +            &
666                                                       v(k,j+1,i) +            &
667                                                       v(k,j+1,i-1) )          &
668                                         )**2 +                                &
669                                         ( 0.25_wp * ( w(k-1,j,i-1) +          &
670                                                       w(k-1,j,i)   +          &
671                                                       w(k,j,i-1)   +          &
672                                                       w(k,j,i) )              &
673                                         )**2                                  &
674                                       ) *                                     &
675                                   u(k,j,i)
676
677!
678!--                   Calculate preliminary new velocity, based on pre_tend
679                      pre_u = u(k,j,i) + dt_3d * pre_tend
680!
681!--                   Compare sign of old velocity and new preliminary velocity,
682!--                   and in case the signs are different, limit the tendency
683                      IF ( SIGN(pre_u,u(k,j,i)) /= pre_u )  THEN
684                         pre_tend = - u(k,j,i) * ddt_3d
685                      ELSE
686                         pre_tend = pre_tend
687                      ENDIF
688!
689!--                   Calculate final tendency
690                      tend(k,j,i) = tend(k,j,i) + pre_tend
691
692                   ENDDO
693                ENDDO
694             ENDDO
695
696!
697!--       v-component
698          CASE ( 2 )
699             DO  i = nxl, nxr
700                DO  j = nysv, nyn
701                   DO  k = nzb_v_inner(j,i)+1, nzb_v_inner(j,i)+pch_index
702
703                      kk = k - nzb_v_inner(j,i)  !- lad arrays are defined flat
704!
705!--                   In order to create sharp boundaries of the plant canopy,
706!--                   the lad on the v-grid at index (k,j,i) is equal to
707!--                   lad_s(k,j,i), rather than being interpolated from the
708!--                   surrounding lad_s, because this would yield smaller lad
709!--                   at the canopy boundaries than inside of the canopy.
710!--                   For the same reason, the lad at the northmost(j+1) canopy
711!--                   boundary on the v-grid equals lad_s(k,j,i).
712                      lad_local = lad_s(kk,j,i)
713                      IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp )&
714                      THEN
715                         lad_local = lad_s(kk,j-1,i)
716                      ENDIF
717
718                      pre_tend = 0.0_wp
719                      pre_v = 0.0_wp
720!
721!--                   Calculate preliminary value (pre_tend) of the tendency
722                      pre_tend = - cdc *                                       &
723                                   lad_local *                                 &
724                                   SQRT( ( 0.25_wp * ( u(k,j-1,i)   +          &
725                                                       u(k,j-1,i+1) +          &
726                                                       u(k,j,i)     +          &
727                                                       u(k,j,i+1) )            &
728                                         )**2 +                                &
729                                         v(k,j,i)**2 +                         &
730                                         ( 0.25_wp * ( w(k-1,j-1,i) +          &
731                                                       w(k-1,j,i)   +          &
732                                                       w(k,j-1,i)   +          &
733                                                       w(k,j,i) )              &
734                                         )**2                                  &
735                                       ) *                                     &
736                                   v(k,j,i)
737
738!
739!--                   Calculate preliminary new velocity, based on pre_tend
740                      pre_v = v(k,j,i) + dt_3d * pre_tend
741!
742!--                   Compare sign of old velocity and new preliminary velocity,
743!--                   and in case the signs are different, limit the tendency
744                      IF ( SIGN(pre_v,v(k,j,i)) /= pre_v )  THEN
745                         pre_tend = - v(k,j,i) * ddt_3d
746                      ELSE
747                         pre_tend = pre_tend
748                      ENDIF
749!
750!--                   Calculate final tendency
751                      tend(k,j,i) = tend(k,j,i) + pre_tend
752
753                   ENDDO
754                ENDDO
755             ENDDO
756
757!
758!--       w-component
759          CASE ( 3 )
760             DO  i = nxl, nxr
761                DO  j = nys, nyn
762                   DO  k = nzb_w_inner(j,i)+1, nzb_w_inner(j,i)+pch_index-1
763
764                      kk = k - nzb_w_inner(j,i)  !- lad arrays are defined flat
765
766                      pre_tend = 0.0_wp
767                      pre_w = 0.0_wp
768!
769!--                   Calculate preliminary value (pre_tend) of the tendency
770                      pre_tend = - cdc *                                       &
771                                   (0.5_wp *                                   &
772                                      ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *   &
773                                   SQRT( ( 0.25_wp * ( u(k,j,i)   +            &
774                                                       u(k,j,i+1) +            &
775                                                       u(k+1,j,i) +            &
776                                                       u(k+1,j,i+1) )          &
777                                         )**2 +                                &
778                                         ( 0.25_wp * ( v(k,j,i)   +            &
779                                                       v(k,j+1,i) +            &
780                                                       v(k+1,j,i) +            &
781                                                       v(k+1,j+1,i) )          &
782                                         )**2 +                                &
783                                         w(k,j,i)**2                           &
784                                       ) *                                     &
785                                   w(k,j,i)
786!
787!--                   Calculate preliminary new velocity, based on pre_tend
788                      pre_w = w(k,j,i) + dt_3d * pre_tend
789!
790!--                   Compare sign of old velocity and new preliminary velocity,
791!--                   and in case the signs are different, limit the tendency
792                      IF ( SIGN(pre_w,w(k,j,i)) /= pre_w )  THEN
793                         pre_tend = - w(k,j,i) * ddt_3d
794                      ELSE
795                         pre_tend = pre_tend
796                      ENDIF
797!
798!--                   Calculate final tendency
799                      tend(k,j,i) = tend(k,j,i) + pre_tend
800
801                   ENDDO
802                ENDDO
803             ENDDO
804
805!
806!--       potential temperature
807          CASE ( 4 )
808             DO  i = nxl, nxr
809                DO  j = nys, nyn
810                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
811                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
812                      tend(k,j,i) = tend(k,j,i) +                              &
813                                       ( canopy_heat_flux(kk,j,i) -            &
814                                         canopy_heat_flux(kk-1,j,i) ) / dzw(k)
815                   ENDDO
816                ENDDO
817             ENDDO
818
819!
820!--       humidity
821          CASE ( 5 )
822             DO  i = nxl, nxr
823                DO  j = nys, nyn
824                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
825                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
826                      tend(k,j,i) = tend(k,j,i) -                              &
827                                       lsec *                                  &
828                                       lad_s(kk,j,i) *                         &
829                                       SQRT( ( 0.5_wp * ( u(k,j,i) +           &
830                                                          u(k,j,i+1) )         &
831                                             )**2 +                            &
832                                             ( 0.5_wp * ( v(k,j,i) +           &
833                                                          v(k,j+1,i) )         &
834                                             )**2 +                            &
835                                             ( 0.5_wp * ( w(k-1,j,i) +         & 
836                                                          w(k,j,i) )           &
837                                             )**2                              &
838                                           ) *                                 &
839                                       ( q(k,j,i) - lsc )
840                   ENDDO
841                ENDDO
842             ENDDO
843
844!
845!--       sgs-tke
846          CASE ( 6 )
847             DO  i = nxl, nxr
848                DO  j = nys, nyn
849                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
850                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
851                      tend(k,j,i) = tend(k,j,i) -                              &
852                                       2.0_wp * cdc *                          &
853                                       lad_s(kk,j,i) *                         &
854                                       SQRT( ( 0.5_wp * ( u(k,j,i) +           &
855                                                          u(k,j,i+1) )         &
856                                             )**2 +                            &
857                                             ( 0.5_wp * ( v(k,j,i) +           &
858                                                          v(k,j+1,i) )         &
859                                             )**2 +                            &
860                                             ( 0.5_wp * ( w(k,j,i) +           &
861                                                          w(k+1,j,i) )         &
862                                             )**2                              &
863                                           ) *                                 &
864                                       e(k,j,i)
865                   ENDDO
866                ENDDO
867             ENDDO 
868!
869!--       scalar concentration
870          CASE ( 7 )
871             DO  i = nxl, nxr
872                DO  j = nys, nyn
873                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
874                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
875                      tend(k,j,i) = tend(k,j,i) -                              &
876                                       lsec *                                  &
877                                       lad_s(kk,j,i) *                         &
878                                       SQRT( ( 0.5_wp * ( u(k,j,i) +           &
879                                                          u(k,j,i+1) )         &
880                                             )**2 +                            &
881                                             ( 0.5_wp * ( v(k,j,i) +           &
882                                                          v(k,j+1,i) )         &
883                                             )**2 +                            &
884                                             ( 0.5_wp * ( w(k-1,j,i) +         & 
885                                                          w(k,j,i) )           &
886                                             )**2                              &
887                                           ) *                                 &
888                                       ( s(k,j,i) - lsc )
889                   ENDDO
890                ENDDO
891             ENDDO   
892
893
894
895          CASE DEFAULT
896
897             WRITE( message_string, * ) 'wrong component: ', component
898             CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) 
899
900       END SELECT
901
902    END SUBROUTINE pcm_tendency
903
904
905!------------------------------------------------------------------------------!
906! Description:
907! ------------
908!> Parin for &canopy_par for plant canopy model
909!------------------------------------------------------------------------------!
910    SUBROUTINE pcm_parin
911
912
913       IMPLICIT NONE
914
915       CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
916       
917        NAMELIST /canopy_par/     alpha_lad, beta_lad, canopy_drag_coeff,      &
918                                  canopy_mode, cthf,                           &
919                                  lad_surface,                                 & 
920                                  lad_vertical_gradient,                       &
921                                  lad_vertical_gradient_level,                 &
922                                  lai_beta,                                    &
923                                  leaf_scalar_exch_coeff,                      &
924                                  leaf_surface_conc, pch_index
925       
926       line = ' '
927       
928!
929!--    Try to find radiation model package
930       REWIND ( 11 )
931       line = ' '
932       DO   WHILE ( INDEX( line, '&canopy_par' ) == 0 )
933          READ ( 11, '(A)', END=10 )  line
934       ENDDO
935       BACKSPACE ( 11 )
936
937!
938!--    Read user-defined namelist
939       READ ( 11, canopy_par )
940
941!
942!--    Set flag that indicates that the radiation model is switched on
943       plant_canopy = .TRUE.
944
945 10    CONTINUE
946       
947
948    END SUBROUTINE pcm_parin   
949   
950
951
952!------------------------------------------------------------------------------!
953! Description:
954! ------------
955!> Calculation of the tendency terms, accounting for the effect of the plant
956!> canopy on momentum and scalar quantities.
957!>
958!> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0
959!> (defined on scalar grid), as initialized in subroutine pcm_init.
960!> The lad on the w-grid is vertically interpolated from the surrounding
961!> lad_s. The upper boundary of the canopy is defined on the w-grid at
962!> k = pch_index. Here, the lad is zero.
963!>
964!> The canopy drag must be limited (previously accounted for by calculation of
965!> a limiting canopy timestep for the determination of the maximum LES timestep
966!> in subroutine timestep), since it is physically impossible that the canopy
967!> drag alone can locally change the sign of a velocity component. This
968!> limitation is realized by calculating preliminary tendencies and velocities.
969!> It is subsequently checked if the preliminary new velocity has a different
970!> sign than the current velocity. If so, the tendency is limited in a way that
971!> the velocity can at maximum be reduced to zero by the canopy drag.
972!>
973!>
974!> Call for grid point i,j
975!------------------------------------------------------------------------------!
976    SUBROUTINE pcm_tendency_ij( i, j, component )
977
978
979       USE control_parameters,                                                 &
980           ONLY:  dt_3d, message_string
981
982       USE kinds
983
984       IMPLICIT NONE
985
986       INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
987       INTEGER(iwp) ::  i         !< running index
988       INTEGER(iwp) ::  j         !< running index
989       INTEGER(iwp) ::  k         !< running index
990       INTEGER(iwp) ::  kk        !< running index for flat lad arrays
991
992       REAL(wp) ::  ddt_3d    !< inverse of the LES timestep (dt_3d)
993       REAL(wp) ::  lad_local !< local lad value
994       REAL(wp) ::  pre_tend  !< preliminary tendency
995       REAL(wp) ::  pre_u     !< preliminary u-value
996       REAL(wp) ::  pre_v     !< preliminary v-value
997       REAL(wp) ::  pre_w     !< preliminary w-value
998
999
1000       ddt_3d = 1.0_wp / dt_3d
1001
1002!
1003!--    Compute drag for the three velocity components and the SGS-TKE
1004       SELECT CASE ( component )
1005
1006!
1007!--       u-component
1008          CASE ( 1 )
1009             DO  k = nzb_u_inner(j,i)+1, nzb_u_inner(j,i)+pch_index
1010
1011                kk = k - nzb_u_inner(j,i)  !- lad arrays are defined flat
1012!
1013!--             In order to create sharp boundaries of the plant canopy,
1014!--             the lad on the u-grid at index (k,j,i) is equal to lad_s(k,j,i),
1015!--             rather than being interpolated from the surrounding lad_s,
1016!--             because this would yield smaller lad at the canopy boundaries
1017!--             than inside of the canopy.
1018!--             For the same reason, the lad at the rightmost(i+1)canopy
1019!--             boundary on the u-grid equals lad_s(k,j,i).
1020                lad_local = lad_s(kk,j,i)
1021                IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp )  THEN
1022                   lad_local = lad_s(kk,j,i-1)
1023                ENDIF
1024
1025                pre_tend = 0.0_wp
1026                pre_u = 0.0_wp
1027!
1028!--             Calculate preliminary value (pre_tend) of the tendency
1029                pre_tend = - cdc *                                             &
1030                             lad_local *                                       &   
1031                             SQRT( u(k,j,i)**2 +                               &
1032                                   ( 0.25_wp * ( v(k,j,i-1)  +                 &
1033                                                 v(k,j,i)    +                 &
1034                                                 v(k,j+1,i)  +                 &
1035                                                 v(k,j+1,i-1) )                &
1036                                   )**2 +                                      &
1037                                   ( 0.25_wp * ( w(k-1,j,i-1) +                &
1038                                                 w(k-1,j,i)   +                &
1039                                                 w(k,j,i-1)   +                &
1040                                                 w(k,j,i) )                    &
1041                                   )**2                                        &
1042                                 ) *                                           &
1043                             u(k,j,i)
1044
1045!
1046!--             Calculate preliminary new velocity, based on pre_tend
1047                pre_u = u(k,j,i) + dt_3d * pre_tend
1048!
1049!--             Compare sign of old velocity and new preliminary velocity,
1050!--             and in case the signs are different, limit the tendency
1051                IF ( SIGN(pre_u,u(k,j,i)) /= pre_u )  THEN
1052                   pre_tend = - u(k,j,i) * ddt_3d
1053                ELSE
1054                   pre_tend = pre_tend
1055                ENDIF
1056!
1057!--             Calculate final tendency
1058                tend(k,j,i) = tend(k,j,i) + pre_tend
1059             ENDDO
1060
1061
1062!
1063!--       v-component
1064          CASE ( 2 )
1065             DO  k = nzb_v_inner(j,i)+1, nzb_v_inner(j,i)+pch_index
1066
1067                kk = k - nzb_v_inner(j,i)  !- lad arrays are defined flat
1068!
1069!--             In order to create sharp boundaries of the plant canopy,
1070!--             the lad on the v-grid at index (k,j,i) is equal to lad_s(k,j,i),
1071!--             rather than being interpolated from the surrounding lad_s,
1072!--             because this would yield smaller lad at the canopy boundaries
1073!--             than inside of the canopy.
1074!--             For the same reason, the lad at the northmost(j+1)canopy
1075!--             boundary on the v-grid equals lad_s(k,j,i).
1076                lad_local = lad_s(kk,j,i)
1077                IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp )  THEN
1078                   lad_local = lad_s(kk,j-1,i)
1079                ENDIF
1080
1081                pre_tend = 0.0_wp
1082                pre_v = 0.0_wp
1083!
1084!--             Calculate preliminary value (pre_tend) of the tendency
1085                pre_tend = - cdc *                                             &
1086                             lad_local *                                       &
1087                             SQRT( ( 0.25_wp * ( u(k,j-1,i)   +                &
1088                                                 u(k,j-1,i+1) +                &
1089                                                 u(k,j,i)     +                &
1090                                                 u(k,j,i+1) )                  &
1091                                   )**2 +                                      &
1092                                   v(k,j,i)**2 +                               &
1093                                   ( 0.25_wp * ( w(k-1,j-1,i) +                &
1094                                                 w(k-1,j,i)   +                &
1095                                                 w(k,j-1,i)   +                &
1096                                                 w(k,j,i) )                    &
1097                                   )**2                                        &
1098                                 ) *                                           &
1099                             v(k,j,i)
1100
1101!
1102!--             Calculate preliminary new velocity, based on pre_tend
1103                pre_v = v(k,j,i) + dt_3d * pre_tend
1104!
1105!--             Compare sign of old velocity and new preliminary velocity,
1106!--             and in case the signs are different, limit the tendency
1107                IF ( SIGN(pre_v,v(k,j,i)) /= pre_v )  THEN
1108                   pre_tend = - v(k,j,i) * ddt_3d
1109                ELSE
1110                   pre_tend = pre_tend
1111                ENDIF
1112!
1113!--             Calculate final tendency
1114                tend(k,j,i) = tend(k,j,i) + pre_tend
1115             ENDDO
1116
1117
1118!
1119!--       w-component
1120          CASE ( 3 )
1121             DO  k = nzb_w_inner(j,i)+1, nzb_w_inner(j,i)+pch_index-1
1122
1123                kk = k - nzb_w_inner(j,i)  !- lad arrays are defined flat
1124
1125                pre_tend = 0.0_wp
1126                pre_w = 0.0_wp
1127!
1128!--             Calculate preliminary value (pre_tend) of the tendency
1129                pre_tend = - cdc *                                             &
1130                             (0.5_wp *                                         &
1131                                ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *         &
1132                             SQRT( ( 0.25_wp * ( u(k,j,i)    +                 & 
1133                                                 u(k,j,i+1)  +                 &
1134                                                 u(k+1,j,i)  +                 &
1135                                                 u(k+1,j,i+1) )                &
1136                                   )**2 +                                      &
1137                                   ( 0.25_wp * ( v(k,j,i)    +                 &
1138                                                 v(k,j+1,i)  +                 &
1139                                                 v(k+1,j,i)  +                 &
1140                                                 v(k+1,j+1,i) )                &
1141                                   )**2 +                                      &
1142                                   w(k,j,i)**2                                 &
1143                                 ) *                                           &
1144                             w(k,j,i)
1145!
1146!--             Calculate preliminary new velocity, based on pre_tend
1147                pre_w = w(k,j,i) + dt_3d * pre_tend
1148!
1149!--             Compare sign of old velocity and new preliminary velocity,
1150!--             and in case the signs are different, limit the tendency
1151                IF ( SIGN(pre_w,w(k,j,i)) /= pre_w )  THEN
1152                   pre_tend = - w(k,j,i) * ddt_3d
1153                ELSE
1154                   pre_tend = pre_tend
1155                ENDIF
1156!
1157!--             Calculate final tendency
1158                tend(k,j,i) = tend(k,j,i) + pre_tend
1159             ENDDO
1160
1161!
1162!--       potential temperature
1163          CASE ( 4 )
1164             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
1165                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
1166                tend(k,j,i) = tend(k,j,i) +                                    &
1167                                 ( canopy_heat_flux(kk,j,i) -                  &
1168                                   canopy_heat_flux(kk-1,j,i) ) / dzw(k)
1169             ENDDO
1170
1171
1172!
1173!--       humidity
1174          CASE ( 5 )
1175             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
1176                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
1177                tend(k,j,i) = tend(k,j,i) -                                    &
1178                                 lsec *                                        &
1179                                 lad_s(kk,j,i) *                               &
1180                                 SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
1181                                                    u(k,j,i+1) )               &
1182                                       )**2  +                                 &
1183                                       ( 0.5_wp * ( v(k,j,i) +                 &
1184                                                    v(k,j+1,i) )               &
1185                                       )**2 +                                  &
1186                                       ( 0.5_wp * ( w(k-1,j,i) +               &
1187                                                    w(k,j,i) )                 &
1188                                       )**2                                    &
1189                                     ) *                                       &
1190                                 ( q(k,j,i) - lsc )
1191             ENDDO   
1192
1193!
1194!--       sgs-tke
1195          CASE ( 6 )
1196             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
1197                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
1198                tend(k,j,i) = tend(k,j,i) -                                    &
1199                                 2.0_wp * cdc *                                &
1200                                 lad_s(kk,j,i) *                               &
1201                                 SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
1202                                                    u(k,j,i+1) )               &
1203                                       )**2 +                                  & 
1204                                       ( 0.5_wp * ( v(k,j,i) +                 &
1205                                                    v(k,j+1,i) )               &
1206                                       )**2 +                                  &
1207                                       ( 0.5_wp * ( w(k,j,i) +                 &
1208                                                    w(k+1,j,i) )               &
1209                                       )**2                                    &
1210                                     ) *                                       &
1211                                 e(k,j,i)
1212             ENDDO
1213             
1214!
1215!--       scalar concentration
1216          CASE ( 7 )
1217             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
1218                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
1219                tend(k,j,i) = tend(k,j,i) -                                    &
1220                                 lsec *                                        &
1221                                 lad_s(kk,j,i) *                               &
1222                                 SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
1223                                                    u(k,j,i+1) )               &
1224                                       )**2  +                                 &
1225                                       ( 0.5_wp * ( v(k,j,i) +                 &
1226                                                    v(k,j+1,i) )               &
1227                                       )**2 +                                  &
1228                                       ( 0.5_wp * ( w(k-1,j,i) +               &
1229                                                    w(k,j,i) )                 &
1230                                       )**2                                    &
1231                                     ) *                                       &
1232                                 ( s(k,j,i) - lsc )
1233             ENDDO               
1234
1235       CASE DEFAULT
1236
1237          WRITE( message_string, * ) 'wrong component: ', component
1238          CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) 
1239
1240       END SELECT
1241
1242    END SUBROUTINE pcm_tendency_ij
1243
1244 END MODULE plant_canopy_model_mod
Note: See TracBrowser for help on using the repository browser.