Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 2718)
+++ 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
