Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 4149)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 4150)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Input of additional surface variables independent on land- or urban-surface
+! model
+! 
+! 4131 2019-08-02 11:06:18Z monakurppa
 ! Allocate sums and sums_l to allow profile output for salsa variables.
 ! 
@@ -661,7 +665,18 @@
 
     USE netcdf_data_input_mod,                                                 &
-        ONLY:  init_3d,                              &
-               netcdf_data_input_init_3d, netcdf_data_input_interpolate
-
+        ONLY:  char_fill,                                                      &
+               check_existence,                                                &
+               close_input_file,                                               &
+               get_attribute,                                                  &
+               get_variable,                                                   &
+               init_3d,                                                        &
+               input_pids_static,                                              &
+               inquire_num_variables,                                          &
+               inquire_variable_names,                                         &
+               input_file_static,                                              &
+               netcdf_data_input_init_3d,                                      &
+               open_read_file,                                                 &
+               real_2d
+               
     USE nesting_offl_mod,                                                      &
         ONLY:  nesting_offl_init
@@ -695,6 +710,12 @@
 
     USE surface_mod,                                                           &
-        ONLY :  init_surface_arrays, init_surfaces, surf_def_h, surf_lsm_h,    &
-                surf_usm_h, get_topography_top_index_ji
+        ONLY :  init_single_surface_properties,                                &
+                init_surface_arrays,                                           &
+                init_surfaces,                                                 &
+                surf_def_h,                                                    &
+                surf_def_v,                                                    &
+                surf_lsm_h,                                                    &
+                surf_usm_h,                                                    &
+                get_topography_top_index_ji
 
 #if defined( _OPENACC )
@@ -710,11 +731,25 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i             !< grid index in x direction
-    INTEGER(iwp) ::  ind_array(1)  !< dummy used to determine start index for external pressure forcing
-    INTEGER(iwp) ::  j             !< grid index in y direction
-    INTEGER(iwp) ::  k             !< grid index in z direction
-    INTEGER(iwp) ::  k_surf        !< surface level index
-    INTEGER(iwp) ::  m             !< index of surface element in surface data type
-    INTEGER(iwp) ::  sr            !< index of statistic region
+    CHARACTER(LEN=50), DIMENSION(:), ALLOCATABLE ::  vars_pids_static  !< variable names in static input file
+    
+    INTEGER(iwp) ::  i                    !< grid index in x direction
+    INTEGER(iwp) ::  ind_array(1)         !< dummy used to determine start index for external pressure forcing
+    INTEGER(iwp) ::  j                    !< grid index in y direction
+    INTEGER(iwp) ::  k                    !< grid index in z direction
+    INTEGER(iwp) ::  k_surf               !< surface level index
+    INTEGER(iwp) ::  l                    !< running index over surface orientation   
+    INTEGER(iwp) ::  m                    !< index of surface element in surface data type    
+    INTEGER(iwp) ::  num_vars_pids_static !< number of variables in static input file
+    INTEGER(iwp) ::  nz_u_shift           !< topography-top index on u-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nz_v_shift           !< topography-top index on v-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nz_w_shift           !< topography-top index on w-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nz_s_shift           !< topography-top index on scalar-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nz_u_shift_l         !< topography-top index on u-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nz_v_shift_l         !< topography-top index on v-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nz_w_shift_l         !< topography-top index on w-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nz_s_shift_l         !< topography-top index on scalar-grid, used to vertically shift initial profiles
+    INTEGER(iwp) ::  nzt_l                !< index of top PE boundary for multigrid level
+    INTEGER(iwp) ::  pids_static_id       !< file id for static input file
+    INTEGER(iwp) ::  sr                   !< index of statistic region
 
     INTEGER(iwp), DIMENSION(:), ALLOCATABLE   ::  ngp_2dh_l  !< toal number of horizontal grid points in statistical region on subdomain
@@ -723,9 +758,9 @@
     INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_s_inner_l  !< number of horizontal non-topography grid points on subdomain
 
+
+    
     REAL(wp), DIMENSION(:), ALLOCATABLE ::  init_l        !< dummy array used for averaging 3D data to obtain inital profiles 
     REAL(wp), DIMENSION(:), ALLOCATABLE ::  p_hydrostatic !< hydrostatic pressure
 
-    INTEGER(iwp) ::  l       !< loop variable
-    INTEGER(iwp) ::  nzt_l   !< index of top PE boundary for multigrid level
     REAL(wp) ::  dx_l !< grid spacing along x on different multigrid level
     REAL(wp) ::  dy_l !< grid spacing along y on different multigrid level
@@ -738,14 +773,6 @@
     REAL(wp), DIMENSION(:), ALLOCATABLE ::  ngp_3d_inner_tmp  !< total number of non-topography grid points
 
-    INTEGER(iwp) ::  nz_u_shift   !< topography-top index on u-grid, used to vertically shift initial profiles
-    INTEGER(iwp) ::  nz_v_shift   !< topography-top index on v-grid, used to vertically shift initial profiles
-    INTEGER(iwp) ::  nz_w_shift   !< topography-top index on w-grid, used to vertically shift initial profiles
-    INTEGER(iwp) ::  nz_s_shift   !< topography-top index on scalar-grid, used to vertically shift initial profiles
-    INTEGER(iwp) ::  nz_u_shift_l !< topography-top index on u-grid, used to vertically shift initial profiles
-    INTEGER(iwp) ::  nz_v_shift_l !< topography-top index on v-grid, used to vertically shift initial profiles
-    INTEGER(iwp) ::  nz_w_shift_l !< topography-top index on w-grid, used to vertically shift initial profiles
-    INTEGER(iwp) ::  nz_s_shift_l !< topography-top index on scalar-grid, used to vertically shift initial profiles
-
-
+    TYPE(real_2d) ::  tmp_2d !< temporary variable to input additional surface-data from static file
+    
     CALL location_message( 'model initialization', 'start' )
 
@@ -1619,5 +1646,4 @@
           ENDDO
        ENDIF
-
 !
 !--    Initialization of the turbulence recycling method
@@ -2005,4 +2031,73 @@
        ENDIF
 
+    ENDIF
+!
+!-- In the following, surface properties can be further initialized with
+!-- input from static driver file.
+!-- At the moment this affects only default surfaces. For example, 
+!-- roughness length or sensible / latent heat fluxes can be initialized
+!-- heterogeneously for default surfaces. Therefore, a generic routine
+!-- from netcdf_data_input_mod is called to read a 2D array.
+    IF ( input_pids_static )  THEN
+!
+!--    Open the static input file
+       CALL open_read_file( TRIM( input_file_static ) //                    &
+                            TRIM( coupling_char ),                          &
+                            pids_static_id )
+                            
+       CALL inquire_num_variables( pids_static_id, num_vars_pids_static )
+!
+!--    Allocate memory to store variable names and read them
+       ALLOCATE( vars_pids_static(1:num_vars_pids_static) )
+       CALL inquire_variable_names( pids_static_id, vars_pids_static )
+                            
+       ALLOCATE( tmp_2d%var(nys:nyn,nxl:nxr) )
+       tmp_2d%var = 0.0_wp
+!
+!--    Input roughness length. 
+       IF ( check_existence( vars_pids_static, 'z0' ) )  THEN
+!
+!--       Read _FillValue attribute
+          CALL get_attribute( pids_static_id, char_fill, tmp_2d%fill,          &
+                              .FALSE., 'z0' )                                  
+!                                                                              
+!--       Read variable                                                        
+          CALL get_variable( pids_static_id, 'z0', tmp_2d%var,                 &
+                             nxl, nxr, nys, nyn )                              
+!                                                                              
+!--       Initialize roughness length. Note, z0 will be only initialized at    
+!--       default-type surfaces. At natural or urban z0 is implicitly          
+!--       initialized bythe respective parameter lists.                        
+!--       Initialize horizontal surface elements.                              
+          CALL init_single_surface_properties( surf_def_h(0)%z0,               &
+                                               tmp_2d%var,                     &
+                                               surf_def_h(0)%ns,               &
+                                               tmp_2d%fill,                    &
+                                               surf_def_h(0)%i,                &
+                                               surf_def_h(0)%j )               
+!                                                                              
+!--       Initialize roughness also at vertical surface elements.              
+!--       Note, the actual 2D input arrays are only defined on the             
+!--       subdomain. Therefore, pass the index arrays with their respective    
+!--       offset values.                                                       
+          DO  l = 0, 3                                                         
+             CALL init_single_surface_properties(                              &
+                                         surf_def_v(l)%z0,                     &
+                                         tmp_2d%var,                           &
+                                         surf_def_v(l)%ns,                     &
+                                         tmp_2d%fill,                          &
+                                         surf_def_v(l)%i + surf_def_v(l)%ioff, &
+                                         surf_def_v(l)%j + surf_def_v(l)%joff )
+          ENDDO
+          
+       ENDIF
+!
+!--    Additional variables, e.g. shf, qsws, etc, can be initialized the 
+!--    same way.
+                           
+       DEALLOCATE( tmp_2d%var )
+!
+!--    Finally, close the input file.
+       CALL close_input_file( pids_static_id )
     ENDIF
 !
Index: /palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4149)
+++ /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4150)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Some variables are given the public attribute, in order to call netcdf input
+! from single routines
+! 
+! 4125 2019-07-29 13:31:44Z suehring
 ! To enable netcdf-parallel access for lateral boundary data (dynamic input), 
 ! zero number of elements are passed to the respective get_variable routine 
@@ -944,7 +948,10 @@
 
 !
+!-- Public data structures
+    PUBLIC real_2d
+!
 !-- Public variables
     PUBLIC albedo_pars_f, albedo_type_f, basal_area_density_f, buildings_f,    &
-           building_id_f, building_pars_f, building_type_f,                    &
+           building_id_f, building_pars_f, building_type_f, char_fill,         &
            chem_emis, chem_emis_att, chem_emis_att_type, chem_emis_val_type,   &
            coord_ref_sys,                                                      &
Index: /palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_mod.f90	(revision 4149)
+++ /palm/trunk/SOURCE/surface_mod.f90	(revision 4150)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Generic routine to initialize single surface properties added
+! 
+! 4104 2019-07-17 17:08:20Z suehring
 ! Bugfix, initialization of index space for boundary data structure accidantly
 ! run over ghost points, causing a segmentation fault.
@@ -642,4 +645,8 @@
     END INTERFACE init_bc
 
+    INTERFACE init_single_surface_properties
+       MODULE PROCEDURE init_single_surface_properties
+    END INTERFACE init_single_surface_properties
+    
     INTERFACE init_surfaces
        MODULE PROCEDURE init_surfaces
@@ -685,7 +692,14 @@
 !
 !-- Public subroutines and functions
-    PUBLIC get_topography_top_index, get_topography_top_index_ji, init_bc, init_surfaces,          &
-           init_surface_arrays, surface_rrd_local, surface_restore_elements, surface_wrd_local,    &
-           surface_last_actions
+    PUBLIC get_topography_top_index,                                                               &
+           get_topography_top_index_ji,                                                            &
+           init_bc,                                                                                &
+           init_single_surface_properties,                                                         &
+           init_surfaces,                                                                          &
+           init_surface_arrays,                                                                    &
+           surface_last_actions,                                                                   &
+           surface_rrd_local,                                                                      &
+           surface_restore_elements,                                                               &
+           surface_wrd_local
 
 #if defined( _OPENACC )
@@ -3035,4 +3049,32 @@
     END SUBROUTINE init_surfaces
 
+! Description:
+! ------------
+!> Initialize single surface properties from 2D input arrays
+!------------------------------------------------------------------------------!
+    SUBROUTINE init_single_surface_properties( var_surf, var_2d,               &
+                                               ns, fill_value,                 &
+                                               index_space_i,                  &
+                                               index_space_j                   &
+                                             )
+    
+       INTEGER(iwp) ::  m  !< running index over surface elements
+       INTEGER(iwp) ::  ns !< number of surface elements in var_surf
+
+       INTEGER(iwp), DIMENSION(1:ns) ::  index_space_i !< grid indices along x direction where surface properties should be defined
+       INTEGER(iwp), DIMENSION(1:ns) ::  index_space_j !< grid indices along y direction where surface properties should be defined 
+       
+       REAL(wp) ::  fill_value !< fill value in var_2d
+       
+       REAL(wp), DIMENSION(1:ns) ::  var_surf !< 1D surface variable that should be initialized
+       REAL(wp), DIMENSION(nys:nyn,nxl:nxr) ::  var_2d !< input variable
+
+       DO  m = 1, ns
+          IF ( var_2d(index_space_j(m),index_space_i(m)) /= fill_value )  THEN
+             var_surf(m) = var_2d(index_space_j(m),index_space_i(m))
+          ENDIF
+       ENDDO
+       
+    END SUBROUTINE init_single_surface_properties
 
 !------------------------------------------------------------------------------!
