Index: palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4341)
+++ palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 4342)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! Use statements moved to module level, ocean dependency removed, redundant
+! variables removed
+! 
+! 4341 2019-12-16 10:43:49Z motisi
 ! - Unification of variable names: pc_-variables now pcm_-variables 
 !   (pc_latent_rate, pc_heating_rate, pc_transpiration_rate)
@@ -134,7 +138,15 @@
     USE basic_constants_and_equations_mod,                                     &
         ONLY:  c_p, degc_to_k, l_v, lv_d_cp, r_d, rd_d_rv
+        
+    USE bulk_cloud_model_mod,                                                  &
+        ONLY: bulk_cloud_model, microphysics_seifert
 
     USE control_parameters,                                                    &
-        ONLY: debug_output, humidity
+        ONLY: average_count_3d, coupling_char, debug_output, dt_3d, dz,        &
+              humidity, message_string, ocean_mode, passive_scalar,            &
+              plant_canopy, urban_surface
+              
+    USE grid_variables,                                                        &
+        ONLY:  dx, dy
 
     USE indices,                                                               &
@@ -143,10 +155,15 @@
 
     USE kinds
+    
+    USE netcdf_data_input_mod,                                                 &
+        ONLY:  input_pids_static, leaf_area_density_f
 
     USE pegrid
+        
+    USE surface_mod,                                                           &
+        ONLY: surf_def_h, surf_lsm_h, surf_usm_h
 
 
     IMPLICIT NONE
-
 
     CHARACTER (LEN=30)   ::  canopy_mode = 'homogeneous'           !< canopy coverage
@@ -165,5 +182,4 @@
     REAL(wp) ::  beta_lad = 9999999.9_wp          !< coefficient for lad calculation
     REAL(wp) ::  canopy_drag_coeff = 0.0_wp       !< canopy drag coefficient (parameter)
-    REAL(wp) ::  cdc = 0.0_wp                     !< canopy drag coeff. (abbreviation used in equations)
     REAL(wp) ::  cthf = 0.0_wp                    !< canopy top heat flux
     REAL(wp) ::  dt_plant_canopy = 0.0_wp         !< timestep account. for canopy drag
@@ -173,6 +189,4 @@
     REAL(wp) ::  leaf_scalar_exch_coeff = 0.0_wp  !< canopy scalar exchange coeff.
     REAL(wp) ::  leaf_surface_conc = 0.0_wp       !< leaf surface concentration
-    REAL(wp) ::  lsc = 0.0_wp                     !< leaf surface concentration
-    REAL(wp) ::  lsec = 0.0_wp                    !< leaf scalar exchange coeff.
 
     REAL(wp) ::  lad_vertical_gradient(10) = 0.0_wp              !< lad gradient
@@ -197,7 +211,6 @@
     SAVE
 
-
     PRIVATE
-  
+    
 !
 !-- Public functions
@@ -209,7 +222,7 @@
 !
 !-- Public variables and constants
-    PUBLIC cdc, pcm_heating_rate, pcm_transpiration_rate, pcm_latent_rate,    &
-           canopy_mode, cthf, dt_plant_canopy, lad, lad_s, pch_index,         &
-           plant_canopy_transpiration
+    PUBLIC canopy_drag_coeff, pcm_heating_rate, pcm_transpiration_rate,       &
+           pcm_latent_rate, canopy_mode, cthf, dt_plant_canopy, lad, lad_s,   &
+           pch_index, plant_canopy_transpiration
 
     INTERFACE pcm_calc_transpiration_rate
@@ -260,7 +273,6 @@
 
  CONTAINS
-
-
-
+ 
+ 
 !------------------------------------------------------------------------------!
 ! Description:
@@ -281,11 +293,5 @@
  SUBROUTINE pcm_calc_transpiration_rate(i, j, k, kk, pcbsw, pcblw, pcbtr, pcblh)
 
-     USE control_parameters,                                                   &
-        ONLY: dz
-
-     USE grid_variables,                                                       &
-        ONLY:  dx, dy
-
-     IMPLICIT NONE
+!
 !--  input parameters
      INTEGER(iwp), INTENT(IN) ::  i, j, k, kk        !< indices of the pc gridbox
@@ -383,9 +389,4 @@
  SUBROUTINE pcm_check_data_output( var, unit )
 
-    USE control_parameters,                                                 &
-        ONLY:  message_string, urban_surface
-
-    IMPLICIT NONE
-
     CHARACTER (LEN=*) ::  unit  !< 
     CHARACTER (LEN=*) ::  var   !<
@@ -427,17 +428,11 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE pcm_check_parameters
-
-       USE control_parameters,                                                 &
-           ONLY: message_string
-
-       USE bulk_cloud_model_mod,                                               &
-           ONLY: bulk_cloud_model, microphysics_seifert
-
-       USE netcdf_data_input_mod,                                              &
-           ONLY:  input_pids_static
-
-
-       IMPLICIT NONE
-
+           
+       IF ( ocean_mode )  THEN
+          message_string = 'plant_canopy = .TRUE. is not allowed in the '//    &
+                           'ocean'
+          CALL message( 'pcm_check_parameters', 'PA0696', 1, 2, 0, 6, 0 )
+       ENDIF
+           
        IF ( canopy_drag_coeff == 0.0_wp )  THEN
           message_string = 'plant_canopy = .TRUE. requires a non-zero drag '// &
@@ -486,5 +481,4 @@
        ENDIF
 
- 
     END SUBROUTINE pcm_check_parameters 
  
@@ -497,13 +491,4 @@
 !------------------------------------------------------------------------------!
  SUBROUTINE pcm_3d_data_averaging( mode, variable )
-
-
-    USE control_parameters
-
-    USE indices
-
-    USE kinds
-
-    IMPLICIT NONE
 
     CHARACTER (LEN=*) ::  mode    !<
@@ -659,11 +644,4 @@
  SUBROUTINE pcm_data_output_3d( av, variable, found, local_pf, fill_value,     &
                                 nzb_do, nzt_do )
-  
-    USE indices
-
-    USE kinds
-
-
-    IMPLICIT NONE
 
     CHARACTER (LEN=*) ::  variable !< treated variable
@@ -768,5 +746,4 @@
     END SELECT
 
-
  END SUBROUTINE pcm_data_output_3d 
          
@@ -779,6 +756,4 @@
 !------------------------------------------------------------------------------!
  SUBROUTINE pcm_define_netcdf_grid( var, found, grid_x, grid_y, grid_z )
-    
-     IMPLICIT NONE
 
      CHARACTER (LEN=*), INTENT(IN)  ::  var         !< 
@@ -791,5 +766,5 @@
 
 !
-!--  Check for the grid
+!--  Check for the grid. zpc is zu(nzb:nzb+pch_index)
      SELECT CASE ( TRIM( var ) )
 
@@ -815,10 +790,4 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE pcm_header ( io )
-
-       USE control_parameters,                                                 &
-           ONLY: passive_scalar
-
-
-       IMPLICIT NONE
  
        CHARACTER (LEN=10) ::  coor_chr            !<
@@ -931,18 +900,4 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE pcm_init
-    
-
-       USE control_parameters,                                                 &
-           ONLY: message_string, ocean_mode
-
-       USE netcdf_data_input_mod,                                              &
-           ONLY:  leaf_area_density_f
-
-       USE pegrid
-
-       USE surface_mod,                                                        &
-           ONLY: surf_def_h, surf_lsm_h, surf_usm_h
-
-       IMPLICIT NONE
 
        INTEGER(iwp) ::  i   !< running index
@@ -985,30 +940,26 @@
           gradient = 0.0_wp
 
-          IF (  .NOT.  ocean_mode )  THEN
-
-             lad(0) = lad_surface
-             lad_vertical_gradient_level_ind(1) = 0
- 
-             DO k = 1, pch_index
-                IF ( i < 11 )  THEN
-                   IF ( lad_vertical_gradient_level(i) < zu(k)  .AND.          &
-                        lad_vertical_gradient_level(i) >= 0.0_wp )  THEN
-                      gradient = lad_vertical_gradient(i)
-                      lad_vertical_gradient_level_ind(i) = k - 1
-                      i = i + 1
-                   ENDIF
+          lad(0) = lad_surface
+          lad_vertical_gradient_level_ind(1) = 0
+
+          DO k = 1, pch_index
+             IF ( i < 11 )  THEN
+                IF ( lad_vertical_gradient_level(i) < zu(k)  .AND.          &
+                     lad_vertical_gradient_level(i) >= 0.0_wp )  THEN
+                   gradient = lad_vertical_gradient(i)
+                   lad_vertical_gradient_level_ind(i) = k - 1
+                   i = i + 1
                 ENDIF
-                IF ( gradient /= 0.0_wp )  THEN
-                   IF ( k /= 1 )  THEN
-                      lad(k) = lad(k-1) + dzu(k) * gradient
-                   ELSE
-                      lad(k) = lad_surface + dzu(k) * gradient
-                   ENDIF
+             ENDIF
+             IF ( gradient /= 0.0_wp )  THEN
+                IF ( k /= 1 )  THEN
+                   lad(k) = lad(k-1) + dzu(k) * gradient
                 ELSE
-                   lad(k) = lad(k-1)
+                   lad(k) = lad_surface + dzu(k) * gradient
                 ENDIF
-             ENDDO
-
-          ENDIF
+             ELSE
+                lad(k) = lad(k-1)
+             ENDIF
+          ENDDO
 
 !
@@ -1059,11 +1010,4 @@
 !--    Allocate 3D-array for the leaf area density (lad_s).
        ALLOCATE( lad_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-!
-!--    Initialize canopy parameters cdc (canopy drag coefficient), 
-!--    lsec (leaf scalar exchange coefficient), lsc (leaf surface concentration)
-!--    with the prescribed values
-       cdc = canopy_drag_coeff
-       lsec = leaf_scalar_exch_coeff
-       lsc = leaf_surface_conc
 
 !
@@ -1133,6 +1077,6 @@
 !
 !            ASCII file
-!--          Initialize canopy parameters cdc (canopy drag coefficient),
-!--          lsec (leaf scalar exchange coefficient), lsc (leaf surface concentration)
+!--          Initialize canopy parameters canopy_drag_coeff,
+!--          leaf_scalar_exch_coeff, leaf_surface_conc
 !--          from file which contains complete 3D data (separate vertical profiles for
 !--          each location).
@@ -1266,5 +1210,4 @@
              i = surf_def_h(0)%i(m)
              j = surf_def_h(0)%j(m)
-             k = surf_def_h(0)%k(m)
              IF ( cum_lai_hf(0,j,i) /= 0.0_wp )                                &
                 surf_def_h(0)%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) )
@@ -1275,5 +1218,4 @@
              i = surf_lsm_h%i(m)
              j = surf_lsm_h%j(m)
-             k = surf_lsm_h%k(m)
              IF ( cum_lai_hf(0,j,i) /= 0.0_wp )                                &
                 surf_lsm_h%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) )
@@ -1284,5 +1226,4 @@
              i = surf_usm_h%i(m)
              j = surf_usm_h%j(m)
-             k = surf_usm_h%k(m)
              IF ( cum_lai_hf(0,j,i) /= 0.0_wp )                                &
                 surf_usm_h%shf(m) = cthf * exp( -ext_coef * cum_lai_hf(0,j,i) )
@@ -1313,5 +1254,4 @@
        IF ( debug_output )  CALL debug_message( 'pcm_init', 'end' )
 
-
     END SUBROUTINE pcm_init
 
@@ -1323,9 +1263,4 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE pcm_parin
-
-       USE control_parameters,                                                 &
-           ONLY:  message_string, plant_canopy
-
-       IMPLICIT NONE
 
        CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file 
@@ -1406,7 +1341,5 @@
  14    CONTINUE
 
-
     END SUBROUTINE pcm_parin
-
 
 
@@ -1434,12 +1367,4 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE pcm_read_plant_canopy_3d
-    
-       USE control_parameters,                                                 &
-           ONLY:  coupling_char, message_string
-
-       USE indices,                                                            &
-           ONLY:  nbgp
-           
-       IMPLICIT NONE
 
        INTEGER(iwp)                        ::  dtype     !< type of input data (1=lad)
@@ -1507,5 +1432,4 @@
     
     
-
 !------------------------------------------------------------------------------!
 ! Description:
@@ -1534,12 +1458,4 @@
     SUBROUTINE pcm_tendency( component )
 
-
-       USE control_parameters,                                                 &
-           ONLY:  dt_3d, message_string
-
-       USE kinds
-
-       IMPLICIT NONE
-
        INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
        INTEGER(iwp) ::  i         !< running index
@@ -1614,5 +1530,5 @@
 !
 !--                   Calculate preliminary value (pre_tend) of the tendency
-                      pre_tend = - cdc *                                       &
+                      pre_tend = - canopy_drag_coeff *                         &
                                    lad_local *                                 &
                                    SQRT( u(k,j,i)**2 +                         &
@@ -1694,5 +1610,5 @@
 !
 !--                   Calculate preliminary value (pre_tend) of the tendency
-                      pre_tend = - cdc *                                       &
+                      pre_tend = - canopy_drag_coeff *                         &
                                    lad_local *                                 &
                                    SQRT( ( 0.25_wp * ( u(k,j-1,i)   +          &
@@ -1744,5 +1660,5 @@
 !
 !--                   Calculate preliminary value (pre_tend) of the tendency
-                      pre_tend = - cdc *                                       &
+                      pre_tend = - canopy_drag_coeff *                         &
                                    (0.5_wp *                                   &
                                       ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *   &
@@ -1820,17 +1736,17 @@
                          ! to include also the dependecy to the radiation
                          ! in the plant canopy box
-                         pcm_transpiration_rate(kk,j,i) =  - lsec               &
-                                          * lad_s(kk,j,i) *                    &
-                                          SQRT( ( 0.5_wp * ( u(k,j,i) +        &
-                                                             u(k,j,i+1) )      &
-                                                )**2 +                         &
-                                                ( 0.5_wp * ( v(k,j,i) +        &
-                                                             v(k,j+1,i) )      &
-                                                )**2 +                         &
-                                                ( 0.5_wp * ( w(k-1,j,i) +      &
-                                                             w(k,j,i) )        &
-                                                )**2                           &
-                                              ) *                              &
-                                          ( q(k,j,i) - lsc )
+                         pcm_transpiration_rate(kk,j,i) =  - leaf_scalar_exch_coeff &
+                                          * lad_s(kk,j,i) *                         &
+                                          SQRT( ( 0.5_wp * ( u(k,j,i) +             &
+                                                             u(k,j,i+1) )           &
+                                                )**2 +                              &
+                                                ( 0.5_wp * ( v(k,j,i) +             &
+                                                             v(k,j+1,i) )           &
+                                                )**2 +                              &
+                                                ( 0.5_wp * ( w(k-1,j,i) +           &
+                                                             w(k,j,i) )             &
+                                                )**2                                &
+                                              ) *                                   &
+                                          ( q(k,j,i) - leaf_surface_conc )
                       ENDIF
 
@@ -1851,5 +1767,5 @@
                       kk = k - topo_top_ind(j,i,0)   !- lad arrays are defined flat
                       tend(k,j,i) = tend(k,j,i) -                              &
-                                       2.0_wp * cdc *                          &
+                                       2.0_wp * canopy_drag_coeff *            &
                                        lad_s(kk,j,i) *                         &
                                        SQRT( ( 0.5_wp * ( u(k,j,i) +           &
@@ -1878,5 +1794,5 @@
                       kk = k - topo_top_ind(j,i,0)   !- lad arrays are defined flat
                       tend(k,j,i) = tend(k,j,i) -                              &
-                                       lsec *                                  &
+                                       leaf_scalar_exch_coeff *                &
                                        lad_s(kk,j,i) *                         &
                                        SQRT( ( 0.5_wp * ( u(k,j,i) +           &
@@ -1890,5 +1806,5 @@
                                              )**2                              &
                                            ) *                                 &
-                                       ( s(k,j,i) - lsc )
+                                       ( s(k,j,i) - leaf_surface_conc )
                    ENDDO
                 ENDDO
@@ -1933,12 +1849,4 @@
     SUBROUTINE pcm_tendency_ij( i, j, component )
 
-
-       USE control_parameters,                                                 &
-           ONLY:  dt_3d, message_string
-
-       USE kinds
-
-       IMPLICIT NONE
-
        INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
        INTEGER(iwp) ::  i         !< running index
@@ -2011,5 +1919,5 @@
 !
 !--             Calculate preliminary value (pre_tend) of the tendency
-                pre_tend = - cdc *                                             &
+                pre_tend = - canopy_drag_coeff *                               &
                              lad_local *                                       &   
                              SQRT( u(k,j,i)**2 +                               &
@@ -2089,5 +1997,5 @@
 !
 !--             Calculate preliminary value (pre_tend) of the tendency
-                pre_tend = - cdc *                                             &
+                pre_tend = - canopy_drag_coeff *                               &
                              lad_local *                                       &
                              SQRT( ( 0.25_wp * ( u(k,j-1,i)   +                &
@@ -2135,5 +2043,5 @@
 !
 !--             Calculate preliminary value (pre_tend) of the tendency
-                pre_tend = - cdc *                                             &
+                pre_tend = - canopy_drag_coeff *                               &
                              (0.5_wp *                                         &
                                 ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *         &
@@ -2197,5 +2105,5 @@
                    ! to include also the dependecy to the radiation
                    ! in the plant canopy box
-                   pcm_transpiration_rate(kk,j,i) = - lsec                      &
+                   pcm_transpiration_rate(kk,j,i) = - leaf_scalar_exch_coeff   &
                                     * lad_s(kk,j,i) *                          &
                                     SQRT( ( 0.5_wp * ( u(k,j,i) +              &
@@ -2209,5 +2117,5 @@
                                           )**2                                 &
                                         ) *                                    &
-                                    ( q(k,j,i) - lsc )
+                                    ( q(k,j,i) - leaf_surface_conc )
                 ENDIF
 
@@ -2225,5 +2133,5 @@
                 kk = k - topo_top_ind(j,i,0)
                 tend(k,j,i) = tend(k,j,i) -                                    &
-                                 2.0_wp * cdc *                                &
+                                 2.0_wp * canopy_drag_coeff *                  &
                                  lad_s(kk,j,i) *                               &
                                  SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
@@ -2249,5 +2157,5 @@
                 kk = k - topo_top_ind(j,i,0)
                 tend(k,j,i) = tend(k,j,i) -                                    &
-                                 lsec *                                        &
+                                 leaf_scalar_exch_coeff *                      &
                                  lad_s(kk,j,i) *                               &
                                  SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
@@ -2261,5 +2169,5 @@
                                        )**2                                    &
                                      ) *                                       &
-                                 ( s(k,j,i) - lsc )
+                                 ( s(k,j,i) - leaf_surface_conc )
              ENDDO                
 
@@ -2274,4 +2182,3 @@
 
 
-
  END MODULE plant_canopy_model_mod
Index: palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- palm/trunk/SOURCE/salsa_mod.f90	(revision 4341)
+++ palm/trunk/SOURCE/salsa_mod.f90	(revision 4342)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! cdc replaced by canopy_drag_coeff
+! 
+! 4329 2019-12-10 15:46:36Z motisi
 ! Renamed wall_flags_0 to wall_flags_static_0
 ! 
@@ -3831,6 +3834,6 @@
  SUBROUTINE deposition( paero, tk, adn, mag_u, lad, kvis, schmidt_num, vc )
 
-    USE plant_canopy_model_mod,                                                                    &
-        ONLY:  cdc
+    USE plant_canopy_model_mod,                                                &
+        ONLY:  canopy_drag_coeff
 
     IMPLICIT NONE
@@ -3930,5 +3933,5 @@
 !
 !--       Friction velocity for deposition on vegetation. Calculated following Prandtl (1925):
-          ustar = SQRT( cdc ) * mag_u
+          ustar = SQRT( canopy_drag_coeff ) * mag_u
           SELECT CASE ( depo_pcm_par_num )
 
