Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 2745)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2743 2018-01-12 16:03:39Z suehring
 ! In case of natural- and urban-type surfaces output surfaces fluxes in W/m2.
 ! 
@@ -608,5 +611,5 @@
     USE pegrid
     USE plant_canopy_model_mod,                                                &
-        ONLY:  pcm_check_data_output, pcm_check_parameters, plant_canopy
+        ONLY:  pcm_check_data_output, pcm_check_parameters
 
     USE pmc_interface,                                                         &
Index: palm/trunk/SOURCE/data_output_3d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_3d.f90	(revision 2745)
+++ palm/trunk/SOURCE/data_output_3d.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -190,5 +193,5 @@
         ONLY:  air_chemistry, cloud_physics, do3d, do3d_no, do3d_time_count,   &
                io_blocks, io_group, land_surface, message_string,              &
-               ntdim_3d, nz_do3d,                                              &
+               ntdim_3d, nz_do3d,  plant_canopy,                               &
                psolver, simulated_time, time_since_reference_point,            &
                urban_surface, varnamelength
@@ -220,5 +223,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  pcm_data_output_3d, plant_canopy
+        ONLY:  pcm_data_output_3d
         
     USE radiation_model_mod,                                                   &
Index: palm/trunk/SOURCE/header.f90
===================================================================
--- palm/trunk/SOURCE/header.f90	(revision 2745)
+++ palm/trunk/SOURCE/header.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -405,5 +408,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  pcm_header, plant_canopy
+        ONLY:  pcm_header
 
     USE pmc_handle_communicator,                                               &
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 2745)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -455,5 +458,5 @@
     
     USE plant_canopy_model_mod,                                                &
-        ONLY:  pcm_init, plant_canopy
+        ONLY:  pcm_init
 
     USE radiation_model_mod,                                                   &
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 2745)
+++ palm/trunk/SOURCE/modules.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! +plant_canopy
+! 
+! 2742 2018-01-12 14:59:47Z suehring
 ! +tsurf_av
 ! 
@@ -1268,4 +1271,5 @@
     LOGICAL ::  outflow_s = .FALSE.                          !< south domain boundary has non-cyclic outflow?
     LOGICAL ::  passive_scalar = .FALSE.                     !< namelist parameter
+    LOGICAL ::  plant_canopy = .FALSE.                       !< switch for use of plant canopy model
     LOGICAL ::  precipitation = .FALSE.                      !< namelist parameter
     LOGICAL ::  random_heatflux = .FALSE.                    !< namelist parameter
Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2745)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Read plant-canopy variables independently on land-surface model usage
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -497,8 +500,9 @@
        USE control_parameters,                                                 &
            ONLY:  bc_lr_cyc, bc_ns_cyc, land_surface, message_string,          &
-                  urban_surface
+                  plant_canopy, urban_surface
 
        USE indices,                                                            &
            ONLY:  nbgp, nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg
+
 
        IMPLICIT NONE
@@ -525,8 +529,128 @@
 !
 !--    If not static input file is available, skip this routine
-       IF ( .NOT. input_pids_static )  RETURN  
-!
-!--    Moreover, skip routine if no land-surface or urban-surface module are 
-!--    applied as no variable is used anyway.  
+       IF ( .NOT. input_pids_static )  RETURN
+!
+!--    Read plant canopy variables.
+       IF ( plant_canopy )  THEN
+          DO  ii = 0, io_blocks-1
+             IF ( ii == io_group )  THEN
+#if defined ( __netcdf )
+!
+!--             Open file in read-only mode
+                CALL open_read_file( TRIM( input_file_static ) //              &
+                                     TRIM( coupling_char ) , id_surf )
+!
+!--             At first, inquire all variable names. 
+!--             This will be used to check whether an optional input variable
+!--             exist or not. 
+                CALL inquire_num_variables( id_surf, num_vars )
+
+                ALLOCATE( var_names(1:num_vars) )
+                CALL inquire_variable_names( id_surf, var_names )
+
+
+!
+!--             Read leaf area density - resolved vegetation
+                IF ( check_existence( var_names, 'leaf_area_density' ) )  THEN
+                   leaf_area_density_f%from_file = .TRUE. 
+                   CALL get_attribute( id_surf, char_fill,                     &
+                                       leaf_area_density_f%fill,               &
+                                       .FALSE., 'leaf_area_density' )  
+!
+!--                Inquire number of vertical vegetation layer
+                   CALL get_dimension_length( id_surf, leaf_area_density_f%nz, &
+                                              'zlad' )
+!            
+!--                Allocate variable for leaf-area density
+                   ALLOCATE( leaf_area_density_f%var(                          &
+                                                   0:leaf_area_density_f%nz-1, &
+                                                   nys:nyn,nxl:nxr) )
+
+                      DO  i = nxl, nxr
+                         DO  j = nys, nyn
+                            CALL get_variable( id_surf, 'leaf_area_density',   &
+                                               i, j,                           &
+                                               leaf_area_density_f%var(:,j,i) ) 
+                         ENDDO
+                      ENDDO
+                ELSE
+                   leaf_area_density_f%from_file = .FALSE. 
+                ENDIF
+
+!
+!--             Read basal area density - resolved vegetation
+                IF ( check_existence( var_names, 'basal_area_density' ) )  THEN
+                   basal_area_density_f%from_file = .TRUE. 
+                   CALL get_attribute( id_surf, char_fill,                     &
+                                       basal_area_density_f%fill,              &
+                                       .FALSE., 'basal_area_density' )  
+!
+!--                Inquire number of vertical vegetation layer
+                   CALL get_dimension_length( id_surf,                         &
+                                              basal_area_density_f%nz,         &
+                                              'zlad' )
+!            
+!--                Allocate variable
+                   ALLOCATE( basal_area_density_f%var(                         &
+                                                  0:basal_area_density_f%nz-1, &
+                                                  nys:nyn,nxl:nxr) )
+
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
+                         CALL get_variable( id_surf, 'basal_area_density',     &
+                                            i, j,                              &
+                                            basal_area_density_f%var(:,j,i) ) 
+                      ENDDO
+                   ENDDO
+                ELSE
+                   basal_area_density_f%from_file = .FALSE. 
+                ENDIF
+
+!
+!--             Read root area density - resolved vegetation
+                IF ( check_existence( var_names, 'root_area_density_lad' ) )  THEN
+                   root_area_density_lad_f%from_file = .TRUE. 
+                   CALL get_attribute( id_surf, char_fill,                     &
+                                       root_area_density_lad_f%fill,           &
+                                       .FALSE., 'root_area_density_lad' )  
+!
+!--                Inquire number of vertical soil layers
+                   CALL get_dimension_length( id_surf,                         &
+                                              root_area_density_lad_f%nz,      &
+                                              'zsoil' )
+!            
+!--                Allocate variable
+                   ALLOCATE( root_area_density_lad_f%var                       &
+                                               (0:root_area_density_lad_f%nz-1,&
+                                                nys:nyn,nxl:nxr) )
+
+                   DO  i = nxl, nxr
+                      DO  j = nys, nyn
+                         CALL get_variable( id_surf, 'root_area_density_lad',  &
+                                            i, j,                              &
+                                            root_area_density_lad_f%var(:,j,i) ) 
+                      ENDDO
+                   ENDDO
+                ELSE
+                   root_area_density_lad_f%from_file = .FALSE. 
+                ENDIF
+!
+!--             Finally, close input file
+                CALL close_input_file( id_surf )
+#endif
+             ENDIF
+#if defined( __parallel )
+             CALL MPI_BARRIER( comm2d, ierr )
+#endif
+          ENDDO
+!
+!--       Deallocate variable list. Will be re-allocated in case further 
+!--       variables are read from file.          
+          IF ( ALLOCATED( var_names ) )  DEALLOCATE( var_names )
+
+       ENDIF
+!
+!--    Skip the following if no land-surface or urban-surface module are 
+!--    applied. This case, no one of the following variables is used anyway.  
        IF (  .NOT. land_surface  .OR.  .NOT. urban_surface )  RETURN
 !
@@ -544,5 +668,5 @@
 
 !
-!--          At first, inquire all variable names. 
+!--          Inquire all variable names. 
 !--          This will be used to check whether an optional input variable exist 
 !--          or not. 
@@ -953,84 +1077,4 @@
                 water_pars_f%from_file = .FALSE. 
              ENDIF
-
-!
-!--          Read leaf area density - resolved vegetation
-             IF ( check_existence( var_names, 'leaf_area_density' ) )  THEN
-                leaf_area_density_f%from_file = .TRUE. 
-                CALL get_attribute( id_surf, char_fill,                        &
-                                    leaf_area_density_f%fill,                  &
-                                    .FALSE., 'leaf_area_density' )  
-!
-!--             Inquire number of vertical vegetation layer
-                CALL get_dimension_length( id_surf, leaf_area_density_f%nz,    &
-                                           'zlad' )
-!            
-!--             Allocate variable for leaf-area density
-                ALLOCATE( leaf_area_density_f%var(0:leaf_area_density_f%nz-1,  &
-                                                  nys:nyn,nxl:nxr) )
-
-                DO  i = nxl, nxr
-                   DO  j = nys, nyn
-                      CALL get_variable( id_surf, 'leaf_area_density', i, j,   &
-                                         leaf_area_density_f%var(:,j,i) ) 
-                   ENDDO
-                ENDDO
-             ELSE
-                leaf_area_density_f%from_file = .FALSE. 
-             ENDIF
-
-!
-!--          Read basal area density - resolved vegetation
-             IF ( check_existence( var_names, 'basal_area_density' ) )  THEN
-                basal_area_density_f%from_file = .TRUE. 
-                CALL get_attribute( id_surf, char_fill,                        &
-                                    basal_area_density_f%fill,                 &
-                                    .FALSE., 'basal_area_density' )  
-!
-!--             Inquire number of vertical vegetation layer
-                CALL get_dimension_length( id_surf, basal_area_density_f%nz,   &
-                                           'zlad' )
-!            
-!--             Allocate variable
-                ALLOCATE( basal_area_density_f%var(0:basal_area_density_f%nz-1,&
-                                                   nys:nyn,nxl:nxr) )
-
-                DO  i = nxl, nxr
-                   DO  j = nys, nyn
-                      CALL get_variable( id_surf, 'basal_area_density', i, j,  &
-                                         basal_area_density_f%var(:,j,i) ) 
-                   ENDDO
-                ENDDO
-             ELSE
-                basal_area_density_f%from_file = .FALSE. 
-             ENDIF
-
-!
-!--          Read root area density - resolved vegetation
-             IF ( check_existence( var_names, 'root_area_density_lad' ) )  THEN
-                root_area_density_lad_f%from_file = .TRUE. 
-                CALL get_attribute( id_surf, char_fill,                        &
-                                    root_area_density_lad_f%fill,              &
-                                    .FALSE., 'root_area_density_lad' )  
-!
-!--             Inquire number of vertical soil layers
-                CALL get_dimension_length( id_surf, root_area_density_lad_f%nz,&
-                                           'zsoil' )
-!            
-!--             Allocate variable
-                ALLOCATE( root_area_density_lad_f%var                          &
-                                            (0:root_area_density_lad_f%nz-1,   &
-                                             nys:nyn,nxl:nxr) )
-
-                DO  i = nxl, nxr
-                   DO  j = nys, nyn
-                      CALL get_variable( id_surf, 'root_area_density_lad', i, j,&
-                                         root_area_density_lad_f%var(:,j,i) ) 
-                   ENDDO
-                ENDDO
-             ELSE
-                root_area_density_lad_f%from_file = .FALSE. 
-             ENDIF
-
 !
 !--          Read root area density - parametrized vegetation
Index: palm/trunk/SOURCE/netcdf_interface_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_interface_mod.f90	(revision 2745)
+++ palm/trunk/SOURCE/netcdf_interface_mod.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -496,6 +499,6 @@
                mask_size_l, mask_i, mask_i_global, mask_j, mask_j_global,      &
                mask_k_global, message_string, mid, ntdim_2d_xy,                &
-               ntdim_2d_xz, ntdim_2d_yz, ntdim_3d, nz_do3d, prt_time_count,    &
-               run_description_header, section, simulated_time,                &
+               ntdim_2d_xz, ntdim_2d_yz, ntdim_3d, nz_do3d, plant_canopy,      &
+               prt_time_count, run_description_header, section, simulated_time,&
                simulated_time_at_begin, skip_time_data_output_av,              &
                skip_time_do2d_xy, skip_time_do2d_xz, skip_time_do2d_yz,        &
@@ -520,5 +523,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  pcm_define_netcdf_grid, plant_canopy
+        ONLY:  pcm_define_netcdf_grid
 
     USE profil_parameter,                                                      &
Index: palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 2745)
+++ palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -175,5 +178,4 @@
 
     LOGICAL ::  calc_beta_lad_profile = .FALSE. !< switch for calc. of lad from beta func.
-    LOGICAL ::  plant_canopy = .FALSE.          !< switch for use of canopy model
     LOGICAL ::  usm_lad_rma = .TRUE.            !< use MPI RMA to access LAD for raytracing (instead of global array)
 
@@ -218,5 +220,5 @@
 !-- Public variables and constants
     PUBLIC pc_heating_rate, canopy_mode, cthf, dt_plant_canopy, lad, lad_s,   &
-           pch_index, plant_canopy, prototype_lad, usm_lad_rma
+           pch_index, prototype_lad, usm_lad_rma
            
 
@@ -931,4 +933,6 @@
     SUBROUTINE pcm_parin
 
+       USE control_parameters,                                                 &
+           ONLY:  plant_canopy
 
        IMPLICIT NONE
Index: palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- palm/trunk/SOURCE/prognostic_equations.f90	(revision 2745)
+++ palm/trunk/SOURCE/prognostic_equations.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2719 2018-01-02 09:02:06Z maronga
 ! Bugfix for last change.
 ! 
@@ -282,7 +285,8 @@
                inflow_l, intermediate_timestep_count,                          &
                intermediate_timestep_count_max, large_scale_forcing,           &
-               large_scale_subsidence, microphysics_morrison, microphysics_seifert, &
-               microphysics_sat_adjust, neutral, nudging, ocean, outflow_l,    &
-               outflow_s, passive_scalar, prho_reference, prho_reference,      &
+               large_scale_subsidence, microphysics_morrison,                  &
+               microphysics_seifert, microphysics_sat_adjust, neutral, nudging,&
+               ocean, outflow_l, outflow_s, passive_scalar, plant_canopy,      &
+               prho_reference, prho_reference,                                 &
                prho_reference, pt_reference, pt_reference, pt_reference,       &
                scalar_advec, scalar_advec, simulated_time, sloping_surface,    &
@@ -362,5 +366,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  cthf, plant_canopy, pcm_tendency
+        ONLY:  cthf, pcm_tendency
 
     USE radiation_model_mod,                                                   &
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 2745)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2724 2018-01-05 12:12:38Z maronga
 ! Set default of average_radiation to .FALSE.
 ! 
@@ -235,5 +238,5 @@
                initializing_actions, io_blocks, io_group,                      &
                latitude, longitude, large_scale_forcing, lsf_surf,             &
-               message_string, microphysics_morrison, pt_surface,              &
+               message_string, microphysics_morrison, plant_canopy, pt_surface,&
                rho_surface, surface_pressure, time_since_reference_point
 
@@ -268,5 +271,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  plant_canopy, pc_heating_rate, lad_s, usm_lad_rma
+        ONLY:  pc_heating_rate, lad_s, usm_lad_rma
 
     USE pegrid
@@ -4423,6 +4426,5 @@
 
        USE plant_canopy_model_mod,                                             &      
-           ONLY:  plant_canopy, pch_index,                                     &
-                  pc_heating_rate, lad_s, prototype_lad, usm_lad_rma       
+           ONLY:  pch_index, pc_heating_rate, lad_s, prototype_lad, usm_lad_rma       
        
        IMPLICIT NONE
Index: palm/trunk/SOURCE/turbulence_closure_mod.f90
===================================================================
--- palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 2745)
+++ palm/trunk/SOURCE/turbulence_closure_mod.f90	(revision 2746)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
 ! 
@@ -73,8 +76,8 @@
                initializing_actions, intermediate_timestep_count,              &
                intermediate_timestep_count_max, kappa, km_constant, les_mw,    &
-               ocean, prandtl_number, prho_reference, pt_reference, rans_mode, &
-               rans_tke_e, rans_tke_l, simulated_time, timestep_scheme,        &
-               turbulence_closure, turbulent_inflow, use_upstream_for_tke,     &
-               vpt_reference, ws_scheme_sca
+               ocean, plant_canopy, prandtl_number, prho_reference,            &
+               pt_reference, rans_mode, rans_tke_e, rans_tke_l, simulated_time,&
+               timestep_scheme, turbulence_closure, turbulent_inflow,          &
+               use_upstream_for_tke, vpt_reference, ws_scheme_sca
 
     USE advec_ws,                                                              &
@@ -103,5 +106,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  pcm_tendency, plant_canopy
+        ONLY:  pcm_tendency
 
     USE statistics,                                                            &
Index: palm/trunk/SOURCE/urban_surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2745)
+++ palm/trunk/SOURCE/urban_surface_mod.f90	(revision 2746)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Move flag plant canopy to modules
+! 
+! 2737 2018-01-11 14:58:11Z kanani
 ! Removed unused variables t_surf_whole...
 ! 
@@ -231,5 +234,6 @@
                g, pt_surface, large_scale_forcing, lsf_surf, spinup,           &
                spinup_pt_mean, spinup_time, time_do3d, dt_do3d,                &
-               average_count_3d, varnamelength, urban_surface, kappa
+               average_count_3d, varnamelength, urban_surface, kappa,          &
+               plant_canopy
 
     USE cpulog,                                                                &
@@ -253,5 +257,5 @@
     
     USE plant_canopy_model_mod,                                                &
-        ONLY:  pc_heating_rate, plant_canopy, usm_lad_rma
+        ONLY:  pc_heating_rate, usm_lad_rma
     
     USE radiation_model_mod,                                                   &
