Index: /palm/trunk/UTIL/inifor/src/inifor.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor.f90	(revision 4674)
+++ /palm/trunk/UTIL/inifor/src/inifor.f90	(revision 4675)
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! Support for soil profile initialization
+! Improved code formatting
+!
+!
+! 4659 2020-08-31 11:21:17Z eckhard
 ! List all warnings after successful run
 ! Only define netCDF variables in enabled IO groups
@@ -202,5 +207,5 @@
 !-- Set up the tables containing the input and output variables and set
 !-- the corresponding netCDF dimensions for each output variable
-    CALL setup_variable_tables( cfg%ic_mode )
+    CALL setup_variable_tables
     CALL setup_io_groups
     CALL log_runtime( 'time', 'init' )
@@ -273,11 +278,11 @@
                          CASE( 'init soil' )
    
-                            ALLOCATE( output_arr(0:output_var%grid%nx,            &
-                                                 0:output_var%grid%ny,            &
+                            ALLOCATE( output_arr(0:output_var%grid%nx,         &
+                                                 0:output_var%grid%ny,         &
                                                  SIZE( output_var%grid%depths )) )
    
                          CASE ( 'surface forcing' )
    
-                            ALLOCATE( output_arr(0:output_var%grid%nx,            &
+                            ALLOCATE( output_arr(0:output_var%grid%nx,         &
                                                  0:output_var%grid%ny, 1) )
    
@@ -299,13 +304,13 @@
                       CASE ( 'interpolate_3d' )
    
-                         ALLOCATE( output_arr(0:output_var%grid % nx,           &
-                                              0:output_var%grid % ny,           &
+                         ALLOCATE( output_arr(0:output_var%grid % nx,          &
+                                              0:output_var%grid % ny,          &
                                               1:output_var%grid % nz) )
    
                          CALL log_runtime( 'time', 'alloc' )
-                         CALL interpolate_3d(                                     &
-                            input_buffer(output_var%input_id)%array(:,:,:),       &
-                            output_arr(:,:,:),                                    &
-                            output_var%intermediate_grid,                         &
+                         CALL interpolate_3d(                                  &
+                            input_buffer(output_var%input_id)%array(:,:,:),    &
+                            output_arr(:,:,:),                                 &
+                            output_var%intermediate_grid,                      &
                             output_var%grid)
                          CALL log_runtime( 'time', 'comp' )
@@ -315,15 +320,12 @@
                       CASE ( 'average profile' )
    
-                         ALLOCATE( output_arr(0:output_var%grid%nx,               &
-                                              0:output_var%grid%ny,               &
-                                              1:output_var%grid%nz) )
+                         ALLOCATE( output_arr(0:0, 0:0, 1:output_var%averaging_grid%nz) )
                          CALL log_runtime( 'time', 'alloc' )
-                         
-                         CALL interp_average_profile(                             &
-                            input_buffer(output_var%input_id)%array(:,:,:),     &
-                            output_arr(0,0,:),                                    &
+                         CALL interp_average_profile(                          &
+                            input_buffer(output_var%input_id)%array(:,:,:),    &
+                            output_arr(0,0,:),                                 &
                             output_var%averaging_grid )
    
-                         IF ( TRIM( output_var%name ) ==                          &
+                         IF ( TRIM( output_var%name ) ==                       &
                               'surface_forcing_surface_pressure' )  THEN
    
@@ -331,10 +333,21 @@
                                output_arr(0,0,1) = p0
                             ELSE
-                               CALL get_surface_pressure(                         &
-                                  output_arr(0,0,:), rho_centre,                  &
+                               CALL get_surface_pressure(                      &
+                                  output_arr(0,0,:), rho_centre,               &
                                   output_var%averaging_grid )
                             ENDIF
    
                          ENDIF
+                         CALL log_runtime( 'time', 'comp' )
+
+                      CASE ( 'average levels' )
+
+                         ALLOCATE( output_arr(0:0, 0:0, 1:output_var%averaging_grid%nz) )
+                         CALL log_runtime( 'time', 'alloc' )
+                         CALL average_profile(                                 &
+                            input_buffer(output_var%input_id)%array(:,:,:),    &
+                            output_arr(0,0,:),                                 &
+                            output_var%averaging_grid                          &
+                         )
                          CALL log_runtime( 'time', 'comp' )
    
@@ -393,35 +406,25 @@
                          SELECT CASE( TRIM( output_var%name ) )
    
-                         CASE( 'internal_pressure_north',                         &
-                               'internal_pressure_south',                         &
-                               'internal_pressure_east',                          &
+                         CASE( 'internal_pressure_north',                      &
+                               'internal_pressure_south',                      &
+                               'internal_pressure_east',                       &
                                'internal_pressure_west' )
    
-                            CALL average_pressure_perturbation(                   &
-                               input_buffer(output_var%input_id) % array(:,:,:),&
-                               internal_arr(:),                                   &
-                               cosmo_grid, output_var%averaging_grid            &
+                            CALL average_pressure_perturbation(                &
+                               input_buffer(output_var%input_id)%array(:,:,:), &
+                               internal_arr(:),                                &
+                               cosmo_grid, output_var%averaging_grid           &
                             )
    
                          CASE DEFAULT
    
-                            CALL average_profile(                                 &
-                               input_buffer(output_var%input_id) % array(:,:,:),&
-                               internal_arr(:),                                   &
-                               output_var%averaging_grid                        &
+                            CALL average_profile(                              &
+                               input_buffer(output_var%input_id)%array(:,:,:), &
+                               internal_arr(:),                                &
+                               output_var%averaging_grid                       &
                             )
 
                       END SELECT
 
-
-!
-!--                   Output of geostrophic pressure profiles (with --debug
-!--                   option) is currently deactivated, since they are now
-!--                   defined on averaged COSMO levels instead of PALM levels
-!--                   (requires definiton of COSMO levels in netCDF output.)
-                      !IF (.TRUE.)  THEN
-                      !   ALLOCATE( output_arr(1,1,1:output_var%grid % nz) )
-                      !   output_arr(1,1,:) = internal_arr(:)
-                      !ENDIF
                       CALL log_runtime( 'time', 'comp' )
 
@@ -450,8 +453,8 @@
                                                     ug_cosmo, vg_cosmo )
 
-                            CALL interpolate_1d( ug_cosmo, ug_palm,             &
+                            CALL interpolate_1d( ug_cosmo, ug_palm,            &
                                                  output_var%grid )
 
-                            CALL interpolate_1d( vg_cosmo, vg_palm,             &
+                            CALL interpolate_1d( vg_cosmo, vg_palm,            &
                                                  output_var%grid )
                          ENDIF
Index: /palm/trunk/UTIL/inifor/src/inifor_control.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_control.f90	(revision 4674)
+++ /palm/trunk/UTIL/inifor/src/inifor_control.f90	(revision 4675)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Improve visibility of errors by printing them below warnings listing
+!
+!
+! 4659 2020-08-31 11:21:17Z eckhard
 ! List warnings after successful run or abort
 ! Produce failure exit code (1) on program abort for test automation
@@ -207,9 +211,10 @@
  SUBROUTINE report_warnings()
 
-    INTEGER(iwp) ::  warning_idx
+    INTEGER(iwp)        ::  warning_idx
+    CHARACTER (LEN=500) ::  warning = ''
 
     IF (n_wrngs > 0)  THEN
-       message = 'Encountered the following '// TRIM( str( n_wrngs ) ) // " warning(s) during this run:"
-       CALL report( 'report_warnings', message )
+       warning = 'Encountered the following '// TRIM( str( n_wrngs ) ) // " warning(s) during this run:"
+       CALL report( 'report_warnings', warning)
 
        DO warning_idx = 1, n_wrngs
@@ -233,5 +238,5 @@
     message = TRIM( message ) // "' successfully."
     IF (n_wrngs > 0)  THEN
-       message = TRIM( message ) // " Some warnings were encountered."
+       message = TRIM( message ) // " Some warnings were encountered, see above."
     ENDIF
     CALL report( 'main loop', message )
@@ -268,6 +273,6 @@
     CHARACTER(LEN=*), INTENT(IN) ::  message !< log message
 
+    CALL report_warnings
     CALL report( routine, "ERROR: " // TRIM( message ) // " Stopping." )
-    CALL report_warnings
     CALL close_log
     CALL EXIT(1)
Index: /palm/trunk/UTIL/inifor/src/inifor_defs.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 4674)
+++ /palm/trunk/UTIL/inifor/src/inifor_defs.f90	(revision 4675)
@@ -21,9 +21,15 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! New command-line options for soil profile initialization and homogeneous
+!    boundary conditions
+! Improved code formatting
+! 
+! 
+! 4659 2020-08-31 11:21:17Z eckhard
 ! Bumped version number
 ! 
@@ -177,21 +183,28 @@
 !
 !-- PALM static driver attribute names (PIDS 1.9)
-CHARACTER(SNAME), PARAMETER ::  PIDS_ORIGIN_LON = 'origin_lon'
-CHARACTER(SNAME), PARAMETER ::  PIDS_ORIGIN_LAT = 'origin_lat'
-CHARACTER(SNAME), PARAMETER ::  PIDS_ORIGIN_Z   = 'origin_z'
+ CHARACTER(SNAME), PARAMETER ::  PIDS_ORIGIN_LON = 'origin_lon'
+ CHARACTER(SNAME), PARAMETER ::  PIDS_ORIGIN_LAT = 'origin_lat'
+ CHARACTER(SNAME), PARAMETER ::  PIDS_ORIGIN_Z   = 'origin_z'
 
 ! 
 !-- COSMO netCDF parameters
-INTEGER, PARAMETER          ::  NC_DEPTH_DIM_IDX = 3
-CHARACTER(SNAME), PARAMETER ::  NC_DEPTH_NAME = 'depth_2'
-CHARACTER(SNAME), PARAMETER ::  NC_HHL_NAME = 'HHL'
-CHARACTER(SNAME), PARAMETER ::  NC_RLAT_NAME = 'rlat'
-CHARACTER(SNAME), PARAMETER ::  NC_RLON_NAME = 'rlon'
-CHARACTER(SNAME), PARAMETER ::  NC_ROTATED_POLE_NAME = 'rotated_pole'
-CHARACTER(SNAME), PARAMETER ::  NC_POLE_LATITUDE_NAME = 'grid_north_pole_latitude'
-CHARACTER(SNAME), PARAMETER ::  NC_POLE_LONGITUDE_NAME = 'grid_north_pole_longitude'
+ INTEGER, PARAMETER          ::  NC_DEPTH_DIM_IDX = 3
+ CHARACTER(SNAME), PARAMETER ::  NC_DEPTH_NAME = 'depth_2'
+ CHARACTER(SNAME), PARAMETER ::  NC_HHL_NAME = 'HHL'
+ CHARACTER(SNAME), PARAMETER ::  NC_RLAT_NAME = 'rlat'
+ CHARACTER(SNAME), PARAMETER ::  NC_RLON_NAME = 'rlon'
+ CHARACTER(SNAME), PARAMETER ::  NC_ROTATED_POLE_NAME = 'rotated_pole'
+ CHARACTER(SNAME), PARAMETER ::  NC_POLE_LATITUDE_NAME = 'grid_north_pole_latitude'
+ CHARACTER(SNAME), PARAMETER ::  NC_POLE_LONGITUDE_NAME = 'grid_north_pole_longitude'
 
 !
 !-- INIFOR parameters
+ CHARACTER(LEN=*), PARAMETER ::  CFG_INIT_PROFILE = 'profile'
+ CHARACTER(LEN=*), PARAMETER ::  CFG_INIT_VOLUME = 'volume'
+ CHARACTER(LEN=*), PARAMETER ::  CFG_INIT_SOIL_PROFILE = 'profile'
+ CHARACTER(LEN=*), PARAMETER ::  CFG_INIT_SOIL_VOLUME = 'volume'
+ CHARACTER(LEN=*), PARAMETER ::  CFG_FORCING_HETERO = 'hetero'
+ CHARACTER(LEN=*), PARAMETER ::  CFG_FORCING_HOMO = 'homo'
+ CHARACTER(LEN=*), PARAMETER ::  CFG_FORCING_NUDGING = 'nudging'
  INTEGER(iwp), PARAMETER     ::  FILL_ITERATIONS = 5          !< Number of iterations for extrapolating soil data into COSMO-DE
                                                               !< water cells [-]
@@ -201,5 +214,5 @@
     ACHAR( 10 ) // ' Copyright 2017-2020 Deutscher Wetterdienst Offenbach' !< Copyright notice
  CHARACTER(LEN=*), PARAMETER ::  LOG_FILE_NAME = 'inifor.log' !< Name of INIFOR's log file
- CHARACTER(LEN=*), PARAMETER ::  VERSION = '2.0.0'            !< INIFOR version number
+ CHARACTER(LEN=*), PARAMETER ::  VERSION = '2.1.0'            !< INIFOR version number
  
  END MODULE inifor_defs
Index: /palm/trunk/UTIL/inifor/src/inifor_grid.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_grid.f90	(revision 4674)
+++ /palm/trunk/UTIL/inifor/src/inifor_grid.f90	(revision 4675)
@@ -26,4 +26,10 @@
 ! -----------------
 ! $Id$
+! Support for profile initialization of soil and for homogeneous (profile)
+!    boundary conditions, including respective command-line options
+! Improved code formatting
+!
+!
+! 4659 2020-08-31 11:21:17Z eckhard
 ! Only define netCDF variables in enabled IO groups
 ! Added cloud and precipitation quantiteis (cloud water, cloud ice, rain, snow
@@ -181,5 +187,7 @@
     USE inifor_control
     USE inifor_defs,                                                           &
-        ONLY:  DATE, EARTH_RADIUS, TO_RADIANS, TO_DEGREES, PI,                 &
+        ONLY:  CFG_INIT_PROFILE, CFG_INIT_SOIL_VOLUME, CFG_INIT_SOIL_PROFILE,  &
+               CFG_FORCING_HETERO, CFG_FORCING_HOMO, CFG_FORCING_NUDGING,      &
+               DATE, EARTH_RADIUS, TO_RADIANS, TO_DEGREES, PI,                 &
                SNAME, LNAME, PATH, FORCING_STEP, FILL_ITERATIONS,              &
                BETA, P_SL, T_SL, BETA, RD, RV, G, P_REF, RD_PALM, CP_PALM,     &
@@ -297,5 +305,4 @@
     INTEGER(iwp) ::  ndepths !< number of COSMO-DE soil layers
     INTEGER(iwp) ::  start_hour_flow          !< start of flow forcing in number of hours relative to start_date
-    INTEGER(iwp) ::  start_hour_soil          !< start of soil forcing in number of hours relative to start_date, typically equals start_hour_flow
     INTEGER(iwp) ::  start_hour_radiation     !< start of radiation forcing in number of hours relative to start_date, 0 to 2 hours before start_hour_flow to reconstruct hourly averages from one- to three hourly averages of the input data
     INTEGER(iwp) ::  start_hour_precipitation !< start of forcing for precipitaiton forcing in number of hours relative to start_date
@@ -362,12 +369,15 @@
     TYPE(grid_definition), TARGET ::  w_south_intermediate            !< intermediate grid for southern w boundary condition
     TYPE(grid_definition), TARGET ::  w_top_intermediate              !< intermediate grid for top w boundary condition
-    TYPE(grid_definition), TARGET ::  north_averaged_scalar_profile   !< grid of the northern geostrophic scalar averaging region
-    TYPE(grid_definition), TARGET ::  south_averaged_scalar_profile   !< grid of the southern geostrophic scalar averaging region
-    TYPE(grid_definition), TARGET ::  west_averaged_scalar_profile    !< grid of the western geostrophic scalar averaging region
-    TYPE(grid_definition), TARGET ::  east_averaged_scalar_profile    !< grid of the eastern geostrophic scalar averaging region
-    TYPE(grid_definition), TARGET ::  averaged_scalar_profile         !< grid of the central geostrophic scalar averaging region
-    TYPE(grid_definition), TARGET ::  averaged_w_profile              !< grid of the central geostrophic w-velocity averaging region
-    TYPE(grid_definition), TARGET ::  averaged_initial_scalar_profile !< averaging grid for initial scalar profiles
-    TYPE(grid_definition), TARGET ::  averaged_initial_w_profile      !< averaging grid for the initial w profile
+    TYPE(grid_definition), TARGET ::  north_geostrophic_scalar_profile!< grid of the northern geostrophic scalar averaging region
+    TYPE(grid_definition), TARGET ::  south_geostrophic_scalar_profile!< grid of the southern geostrophic scalar averaging region
+    TYPE(grid_definition), TARGET ::  west_geostrophic_scalar_profile !< grid of the western geostrophic scalar averaging region
+    TYPE(grid_definition), TARGET ::  east_geostrophic_scalar_profile !< grid of the eastern geostrophic scalar averaging region
+    TYPE(grid_definition), TARGET ::  geostrophic_scalar_profile      !< grid of the central geostrophic scalar averaging region
+    TYPE(grid_definition), TARGET ::  geostrophic_w_profile           !< grid of the central geostrophic w-velocity averaging region
+    TYPE(grid_definition), TARGET ::  averaged_soil_profile           !< averaging grid for initial soil profiles
+    TYPE(grid_definition), TARGET ::  averaged_scalar_profile         !< averaging grid for initial and boundary condition scalar profiles
+    TYPE(grid_definition), TARGET ::  averaged_w_profile              !< averaging grid for initial and boundary condition scalar profiles
+    TYPE(grid_definition), TARGET ::  averaged_scalar_top_point       !< averaging grid for top scalar boundary conditions for homogeneous forcing mode
+    TYPE(grid_definition), TARGET ::  averaged_w_top_point            !< averaging grid for top w boundary condition for homogeneous forcing mode
 
     TYPE(io_group), ALLOCATABLE, TARGET ::  io_group_list(:)  !< List of I/O groups, which group together output variables that share the same input variable
@@ -432,5 +442,4 @@
 !-- Parameters for file names
     start_hour_flow = 0
-    start_hour_soil = 0
     start_hour_radiation = 0
     start_hour_precipitation = start_hour_flow 
@@ -464,6 +473,7 @@
     cfg%static_driver_file = ''
     cfg%output_file = './palm-4u-input.nc'
-    cfg%ic_mode = 'profile'
-    cfg%bc_mode = 'real'
+    cfg%ic_mode = CFG_INIT_PROFILE
+    cfg%isc_mode = CFG_INIT_SOIL_VOLUME
+    cfg%bc_mode = CFG_FORCING_HETERO
     cfg%averaging_mode = 'level'
 
@@ -485,6 +495,9 @@
 
     init_variables_required = .TRUE.
-    boundary_variables_required = TRIM( cfg%bc_mode ) == 'real'
-    ls_forcing_variables_required = TRIM( cfg%bc_mode ) == 'ideal'
+    boundary_variables_required = (                                            &
+       ( TRIM( cfg%bc_mode ) == CFG_FORCING_HETERO )  .OR.                     &
+       ( TRIM( cfg%bc_mode ) == CFG_FORCING_HOMO )                             &
+    )
+    ls_forcing_variables_required = TRIM( cfg%bc_mode ) == CFG_FORCING_NUDGING
     surface_forcing_required = .TRUE.
 
@@ -503,14 +516,15 @@
     CALL validate_config( cfg ) 
 
-    CALL report('setup_parameters', "initialization mode: " // TRIM(cfg%ic_mode))
-    CALL report('setup_parameters', "       forcing mode: " // TRIM(cfg%bc_mode))
-    CALL report('setup_parameters', "     averaging mode: " // TRIM(cfg%averaging_mode))
-    CALL report('setup_parameters', "    averaging angle: " // real_to_str(cfg%averaging_angle))
-    CALL report('setup_parameters', "    averaging angle: " // real_to_str(cfg%averaging_angle))
-    CALL report('setup_parameters', "          data path: " // TRIM(cfg%input_path))
-    CALL report('setup_parameters', "           hhl file: " // TRIM(cfg%hhl_file))
-    CALL report('setup_parameters', "       soiltyp file: " // TRIM(cfg%soiltyp_file))
-    CALL report('setup_parameters', "      namelist file: " // TRIM(cfg%namelist_file))
-    CALL report('setup_parameters', "   output data file: " // TRIM(output_file%name))
+    CALL report('setup_parameters', "atmosphere initialization mode: " // TRIM(cfg%ic_mode))
+    CALL report('setup_parameters', "      soil initialization mode: " // TRIM(cfg%isc_mode))
+    CALL report('setup_parameters', "                  forcing mode: " // TRIM(cfg%bc_mode))
+    CALL report('setup_parameters', "                averaging mode: " // TRIM(cfg%averaging_mode))
+    CALL report('setup_parameters', "               averaging angle: " // real_to_str(cfg%averaging_angle))
+    CALL report('setup_parameters', "               averaging angle: " // real_to_str(cfg%averaging_angle))
+    CALL report('setup_parameters', "                     data path: " // TRIM(cfg%input_path))
+    CALL report('setup_parameters', "                      hhl file: " // TRIM(cfg%hhl_file))
+    CALL report('setup_parameters', "                  soiltyp file: " // TRIM(cfg%soiltyp_file))
+    CALL report('setup_parameters', "                 namelist file: " // TRIM(cfg%namelist_file))
+    CALL report('setup_parameters', "              output data file: " // TRIM(output_file%name))
     IF (cfg%process_precipitation )  THEN
         CALL report('setup_parameters', "      precipitation: enabled")
@@ -557,5 +571,5 @@
        cfg%input_path, flow_prefix, flow_suffix, flow_files)
     CALL get_input_file_list(                                                  &
-       cfg%start_date, start_hour_soil, end_hour, step_hour,                   &
+       cfg%start_date, start_hour_flow, start_hour_flow, step_hour,            &
        cfg%input_path, soil_prefix, soil_suffix, soil_files)
     CALL get_input_file_list(                                                  &
@@ -1097,56 +1111,73 @@
     ENDIF
 
-
-    CALL init_averaging_grid(averaged_initial_scalar_profile, cosmo_grid,   &
+    CALL init_averaging_grid(averaged_soil_profile, cosmo_grid,             &
+            x = 0.5_wp * lx, y = 0.5_wp * ly, z = depths, z0 = z0,          &
+            lonmin = lonmin_palm, lonmax = lonmax_palm,                     &
+            latmin = latmin_palm, latmax = latmax_palm,                     &
+            kind='scalar', name='averaged soil profile')
+
+    CALL init_averaging_grid(averaged_scalar_profile, cosmo_grid,           &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0,               &
             lonmin = lonmin_palm, lonmax = lonmax_palm,                     &
             latmin = latmin_palm, latmax = latmax_palm,                     &
-            kind='scalar', name='averaged initial scalar')
-
-    CALL init_averaging_grid(averaged_initial_w_profile, cosmo_grid,        &
+            kind='scalar', name='averaged scalar profile')
+
+    CALL init_averaging_grid(averaged_w_profile, cosmo_grid,                &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = zw, z0 = z0,              &
             lonmin = lonmin_palm, lonmax = lonmax_palm,                     &
             latmin = latmin_palm, latmax = latmax_palm,                     &
-            kind='w', name='averaged initial w')
-
-    CALL init_averaging_grid(averaged_scalar_profile, cosmo_grid,           &
+            kind='w', name='averaged w profile')
+
+    CALL init_averaging_grid(averaged_scalar_top_point, cosmo_grid,         &
+            x = 0.5_wp * lx, y = 0.5_wp * ly, z = z_top, z0 = z0,           &
+            lonmin = lonmin_palm, lonmax = lonmax_palm,                     &
+            latmin = latmin_palm, latmax = latmax_palm,                     &
+            kind='scalar', name='averaged scalar top point')
+
+    CALL init_averaging_grid(averaged_w_top_point, cosmo_grid,              &
+            x = 0.5_wp * lx, y = 0.5_wp * ly, z = zw_top, z0 = z0,          &
+            lonmin = lonmin_palm, lonmax = lonmax_palm,                     &
+            latmin = latmin_palm, latmax = latmax_palm,                     &
+            kind='w', name='averaged w top point')
+
+    CALL init_averaging_grid(geostrophic_scalar_profile, cosmo_grid,           &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0,               &
             lonmin = lam_west, lonmax = lam_east,                           &
             latmin = phi_south, latmax = phi_north,                         &
-            kind='scalar', name='centre geostrophic scalar')
-
-    CALL init_averaging_grid(averaged_w_profile, cosmo_grid,                &
+            kind='scalar', name='centre geostrophic scalar profile')
+
+    CALL init_averaging_grid(geostrophic_w_profile, cosmo_grid,                &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = zw, z0 = z0,              &
             lonmin = lam_west, lonmax = lam_east,                           &
             latmin = phi_south, latmax = phi_north,                         &
-            kind='w', name='centre geostrophic w')
-
-    CALL init_averaging_grid(south_averaged_scalar_profile, cosmo_grid,     &
+            kind='w', name='centre geostrophic w profile')
+
+    CALL init_averaging_grid(south_geostrophic_scalar_profile, cosmo_grid,     &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0,               &
             lonmin = lam_west, lonmax = lam_east,                           &
             latmin = phi_centre - averaging_angle,                          &
             latmax = phi_centre,                                            &
-            kind='scalar', name='south geostrophic scalar')
-
-    CALL init_averaging_grid(north_averaged_scalar_profile, cosmo_grid,     &
+            kind='scalar', name='south geostrophic scalar profile')
+
+    CALL init_averaging_grid(north_geostrophic_scalar_profile, cosmo_grid,     &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0,               &
             lonmin = lam_west, lonmax = lam_east,                           &
             latmin = phi_centre,                                            &
             latmax = phi_centre + averaging_angle,                          &
-            kind='scalar', name='north geostrophic scalar')
-
-    CALL init_averaging_grid(west_averaged_scalar_profile, cosmo_grid,      &
+            kind='scalar', name='north geostrophic scalar profile')
+
+    CALL init_averaging_grid(west_geostrophic_scalar_profile, cosmo_grid,      &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0,               &
             lonmin = lam_centre - averaging_angle,                          &
             lonmax = lam_centre,                                            &
             latmin = phi_south, latmax = phi_north,                         &
-            kind='scalar', name='west geostrophic scalar')
-
-    CALL init_averaging_grid(east_averaged_scalar_profile, cosmo_grid,      &
+            kind='scalar', name='west geostrophic scalar profile')
+
+    CALL init_averaging_grid(east_geostrophic_scalar_profile, cosmo_grid,      &
             x = 0.5_wp * lx, y = 0.5_wp * ly, z = z, z0 = z0,               &
             lonmin = lam_centre,                                            &
             lonmax = lam_centre + averaging_angle,                          &
             latmin = phi_south, latmax = phi_north,                         &
-            kind='scalar', name='east geostrophic scalar')
+            kind='scalar', name='east geostrophic scalar profile')
 
 
@@ -1195,5 +1226,5 @@
     ENDIF
 
-    IF (TRIM(cfg%ic_mode) == 'profile')  THEN
+    IF (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)  THEN
         !TODO: remove this conditional if not needed. 
     ENDIF
@@ -1285,5 +1316,5 @@
     setup_volumetric = .TRUE.
     IF (PRESENT(ic_mode))  THEN
-       IF (TRIM(ic_mode) == 'profile')  setup_volumetric = .FALSE.
+       IF (TRIM(ic_mode) == CFG_INIT_PROFILE)  setup_volumetric = .FALSE.
     ENDIF
 
@@ -1374,5 +1405,5 @@
 !      
 !--       Allocate neighbour indices and weights
-          IF (TRIM(ic_mode) .NE. 'profile')  THEN
+          IF (TRIM(ic_mode) .NE. CFG_INIT_PROFILE)  THEN
              ALLOCATE( grid%kk(0:nx, 0:ny, 1:nz, 2) )
              grid%kk(:,:,:,:) = -1
@@ -1446,5 +1477,5 @@
 !      
 !--       Allocate neighbour indices and weights
-          IF (TRIM(ic_mode) .NE. 'profile')  THEN
+          IF (TRIM(ic_mode) .NE. CFG_INIT_PROFILE)  THEN
              ALLOCATE( grid%kk(0:nx, 0:ny, 1:nz, 2) )
              grid%kk(:,:,:,:) = -1
@@ -1858,6 +1889,4 @@
     IF ( ANY( min_dz_stretch_level_end(1:number_stretch_level_start) >      &
               dz_stretch_level_end(1:number_stretch_level_start) ) )  THEN
-    !IF ( ANY( min_dz_stretch_level_end >      &
-    !          dz_stretch_level_end ) ) THEN
           message = 'Each dz_stretch_level_end has to be larger '  // &
                     'than its corresponding value for ' //            &
@@ -2369,23 +2398,10 @@
                       invar%to_be_processed = .FALSE.
                       outvar%to_be_processed = .FALSE.
-                      message = "Optional output variable '" // TRIM( outvar%name ) // "' was deactivated" // &
-                         " because the corresponding input variable was not found in file '" // TRIM( filename ) // "'."
+                      message = "Skipping optional output variable '" // TRIM( outvar%name ) // &
+                         ", corresponding input variable not available in file '" // TRIM( filename ) // "'."
                       CALL warn( 'validate_io_groups', message )
                 ENDIF
              ENDIF
 
-             !IF ( .NOT.netcdf_variable_present_in_file( invar%name, filename ) )  THEN
-!--          !      abort due to missing input variable
-             !      message = "The mandatory input variable '" // TRIM( invar%name ) // &
-             !         " was not found in the input file '" // TRIM( filename ) // "'."
-             !      CALL inifor_abort( 'validate_io_groups', message  )
-             !   ENDIF
-             !IF ( .NOT.netcdf_variable_present_in_file( invar%name, filename ) )  THEN
-!--          !      abort due to missing input variable
-             !      message = "The mandatory input variable '" // TRIM( invar%name ) // &
-             !         " was not found in the input file '" // TRIM( filename ) // "'."
-             !      CALL inifor_abort( 'validate_io_groups', message  )
-             !   ENDIF
-             !ENDIF
 !--       outvar loop
           ENDDO
@@ -2493,9 +2509,8 @@
 !> Initializes the variable list.
 !------------------------------------------------------------------------------!
- SUBROUTINE setup_variable_tables(ic_mode)
-    CHARACTER(LEN=*), INTENT(IN) ::  ic_mode
-    INTEGER(iwp)                 ::  n_invar = 0  !< number of variables in the input variable table
-    INTEGER(iwp)                 ::  n_outvar = 0 !< number of variables in the output variable table
-    TYPE(nc_var), POINTER        ::  var
+ SUBROUTINE setup_variable_tables
+    INTEGER(iwp)                    ::  n_invar = 0  !< number of variables in the input variable table
+    INTEGER(iwp)                    ::  n_outvar = 0 !< number of variables in the output variable table
+    TYPE(nc_var), POINTER           ::  var
 
     IF (TRIM(cfg%start_date) == '')  THEN
@@ -2626,5 +2641,6 @@
        output_file       = output_file,                                     &
        grid              = palm_grid,                                       &
-       intermediate_grid = palm_intermediate                                &
+       intermediate_grid = palm_intermediate,                               &
+       is_profile = (TRIM(cfg%isc_mode) == CFG_INIT_SOIL_PROFILE)           &
     )
 
@@ -2638,5 +2654,6 @@
        output_file       = output_file,                                     &
        grid              = palm_grid,                                       &
-       intermediate_grid = palm_intermediate                                &
+       intermediate_grid = palm_intermediate,                               &
+       is_profile = (TRIM(cfg%isc_mode) == CFG_INIT_SOIL_PROFILE)           &
     )
 
@@ -2651,9 +2668,6 @@
        grid              = palm_grid,                                       &
        intermediate_grid = palm_intermediate,                               &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(3)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
 
     output_var_table(4) = init_nc_var(                                      &
@@ -2666,4 +2680,5 @@
        grid              = scalars_west_grid,                               &
        intermediate_grid = scalars_west_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO),                &
        output_file = output_file                                            &
     )
@@ -2678,4 +2693,5 @@
        grid              = scalars_east_grid,                               &
        intermediate_grid = scalars_east_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO),                &
        output_file = output_file                                            &
     )
@@ -2690,4 +2706,5 @@
        grid              = scalars_north_grid,                              &
        intermediate_grid = scalars_north_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO),                &
        output_file = output_file                                            &
     )
@@ -2702,4 +2719,5 @@
        grid              = scalars_south_grid,                              &
        intermediate_grid = scalars_south_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO),                &
        output_file = output_file                                            &
     )
@@ -2714,4 +2732,5 @@
        grid              = scalars_top_grid,                                &
        intermediate_grid = scalars_top_intermediate,                        &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO),                &
        output_file = output_file                                            &
     )
@@ -2727,9 +2746,6 @@
        grid              = palm_grid,                                       &
        intermediate_grid = palm_intermediate,                               &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(9)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
 
     output_var_table(10) = init_nc_var(                                     &
@@ -2742,5 +2758,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_west_grid,                               &
-       intermediate_grid = scalars_west_intermediate                        &
+       intermediate_grid = scalars_west_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2754,5 +2771,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_east_grid,                               &
-       intermediate_grid = scalars_east_intermediate                        &
+       intermediate_grid = scalars_east_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2766,5 +2784,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_north_grid,                              &
-       intermediate_grid = scalars_north_intermediate                       &
+       intermediate_grid = scalars_north_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2778,5 +2797,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_south_grid,                              &
-       intermediate_grid = scalars_south_intermediate                       &
+       intermediate_grid = scalars_south_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2790,5 +2810,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_top_grid,                                &
-       intermediate_grid = scalars_top_intermediate                         &
+       intermediate_grid = scalars_top_intermediate,                        &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2803,9 +2824,6 @@
        grid              = u_initial_grid,                                  &
        intermediate_grid = u_initial_intermediate,                          &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(15)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF 
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
 
     output_var_table(16) = init_nc_var(                                     &
@@ -2818,5 +2836,6 @@
        output_file       = output_file,                                     &
        grid              = u_west_grid,                                     &
-       intermediate_grid = u_west_intermediate                              &
+       intermediate_grid = u_west_intermediate,                             &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2830,5 +2849,6 @@
        output_file       = output_file,                                     &
        grid              = u_east_grid,                                     &
-       intermediate_grid = u_east_intermediate                              &
+       intermediate_grid = u_east_intermediate,                             &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2842,5 +2862,6 @@
        output_file       = output_file,                                     &
        grid              = u_north_grid,                                    &
-       intermediate_grid = u_north_intermediate                             &
+       intermediate_grid = u_north_intermediate,                            &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2854,5 +2875,6 @@
        output_file       = output_file,                                     &
        grid              = u_south_grid,                                    &
-       intermediate_grid = u_south_intermediate                             &
+       intermediate_grid = u_south_intermediate,                            &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2866,5 +2888,6 @@
        output_file       = output_file,                                     &
        grid              = u_top_grid,                                      &
-       intermediate_grid = u_top_intermediate                               &
+       intermediate_grid = u_top_intermediate,                              &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2879,9 +2902,6 @@
        grid              = v_initial_grid,                                  &
        intermediate_grid = v_initial_intermediate,                          &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(21)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
 
     output_var_table(22) = init_nc_var(                                     &
@@ -2894,5 +2914,6 @@
        output_file       = output_file,                                     &
        grid              = v_west_grid,                                     &
-       intermediate_grid = v_west_intermediate                              &
+       intermediate_grid = v_west_intermediate,                             &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2906,5 +2927,6 @@
        output_file       = output_file,                                     &
        grid              = v_east_grid,                                     &
-       intermediate_grid = v_east_intermediate                              &
+       intermediate_grid = v_east_intermediate,                             &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2918,5 +2940,6 @@
        output_file       = output_file,                                     &
        grid              = v_north_grid,                                    &
-       intermediate_grid = v_north_intermediate                             &
+       intermediate_grid = v_north_intermediate,                            &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2930,5 +2953,6 @@
        output_file       = output_file,                                     &
        grid              = v_south_grid,                                    &
-       intermediate_grid = v_south_intermediate                             &
+       intermediate_grid = v_south_intermediate,                            &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2942,5 +2966,6 @@
        output_file       = output_file,                                     &
        grid              = v_top_grid,                                      &
-       intermediate_grid = v_top_intermediate                               &
+       intermediate_grid = v_top_intermediate,                              &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2955,9 +2980,6 @@
        grid              = w_initial_grid,                                  &
        intermediate_grid = w_initial_intermediate,                          &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(27)%averaging_grid => averaged_initial_w_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
 
     output_var_table(28) = init_nc_var(                                     &
@@ -2970,5 +2992,6 @@
        output_file       = output_file,                                     &
        grid              = w_west_grid,                                     &
-       intermediate_grid = w_west_intermediate                              &
+       intermediate_grid = w_west_intermediate,                             &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2982,5 +3005,6 @@
        output_file       = output_file,                                     &
        grid              = w_east_grid,                                     &
-       intermediate_grid = w_east_intermediate                              &
+       intermediate_grid = w_east_intermediate,                             &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -2994,5 +3018,6 @@
        output_file       = output_file,                                     &
        grid              = w_north_grid,                                    &
-       intermediate_grid = w_north_intermediate                             &
+       intermediate_grid = w_north_intermediate,                            &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -3006,5 +3031,6 @@
        output_file       = output_file,                                     &
        grid              = w_south_grid,                                    &
-       intermediate_grid = w_south_intermediate                             &
+       intermediate_grid = w_south_intermediate,                            &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -3018,5 +3044,6 @@
        output_file       = output_file,                                     &
        grid              = w_top_grid,                                      &
-       intermediate_grid = w_top_intermediate                               &
+       intermediate_grid = w_top_intermediate,                              &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
 
@@ -3143,5 +3170,5 @@
        intermediate_grid = palm_intermediate                                &
     )
-    output_var_table(42)%averaging_grid => averaged_scalar_profile
+    output_var_table(42)%averaging_grid => geostrophic_scalar_profile
 
     output_var_table(43) = init_nc_var(                                     &
@@ -3153,6 +3180,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
 
@@ -3165,6 +3192,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
 
@@ -3177,6 +3204,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(45)%to_be_processed = ls_forcing_variables_required
@@ -3190,6 +3217,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(46)%to_be_processed = ls_forcing_variables_required
@@ -3203,6 +3230,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(47)%to_be_processed = ls_forcing_variables_required
@@ -3216,6 +3243,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_w_profile,                              &
-       intermediate_grid = averaged_w_profile                               &
+       grid              = geostrophic_w_profile,                              &
+       intermediate_grid = geostrophic_w_profile                               &
     )
     output_var_table(48)%to_be_processed = ls_forcing_variables_required
@@ -3230,6 +3257,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(49)%to_be_processed = ls_forcing_variables_required
@@ -3243,6 +3270,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(50)%to_be_processed = ls_forcing_variables_required
@@ -3256,6 +3283,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(51)%to_be_processed = ls_forcing_variables_required
@@ -3269,6 +3296,6 @@
        input_id          = 3_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(52)%to_be_processed = ls_forcing_variables_required
@@ -3283,6 +3310,6 @@
        input_id          = 3_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(53)%to_be_processed = ls_forcing_variables_required
@@ -3296,6 +3323,6 @@
        input_id          = 3_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(54)%to_be_processed = ls_forcing_variables_required
@@ -3309,6 +3336,6 @@
        input_id          = 1_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
     )
     output_var_table(55)%to_be_processed = ls_forcing_variables_required
@@ -3316,5 +3343,5 @@
 
     output_var_table(56) = init_nc_var(                                     &
-       name              = 'internal_density_centre',                              &
+       name              = 'internal_density_centre',                       &
        std_name          = "",                                              &
        long_name         = "",                                              &
@@ -3323,12 +3350,12 @@
        input_id          = 4_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = averaged_scalar_profile,                         &
-       intermediate_grid = averaged_scalar_profile                          &
-    )
-    output_var_table(56)%averaging_grid => averaged_scalar_profile
+       grid              = geostrophic_scalar_profile,                         &
+       intermediate_grid = geostrophic_scalar_profile                          &
+    )
+    output_var_table(56)%averaging_grid => geostrophic_scalar_profile
 
 
     output_var_table(57) = init_nc_var(                                     &
-       name              = 'internal_density_north',                       &
+       name              = 'internal_density_north',                        &
        std_name          = "",                                              &
        long_name         = "",                                              &
@@ -3337,13 +3364,13 @@
        input_id          = 4_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = north_averaged_scalar_profile,                   &
-       intermediate_grid = north_averaged_scalar_profile                    &
-    )
-    output_var_table(57)%averaging_grid => north_averaged_scalar_profile
+       grid              = north_geostrophic_scalar_profile,                   &
+       intermediate_grid = north_geostrophic_scalar_profile                    &
+    )
+    output_var_table(57)%averaging_grid => north_geostrophic_scalar_profile
     output_var_table(57)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
 
     output_var_table(58) = init_nc_var(                                     &
-       name              = 'internal_density_south',                       &
+       name              = 'internal_density_south',                        &
        std_name          = "",                                              &
        long_name         = "",                                              &
@@ -3352,13 +3379,13 @@
        input_id          = 4_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = south_averaged_scalar_profile,                   &
-       intermediate_grid = south_averaged_scalar_profile                    &
-    )
-    output_var_table(58)%averaging_grid => south_averaged_scalar_profile
+       grid              = south_geostrophic_scalar_profile,                   &
+       intermediate_grid = south_geostrophic_scalar_profile                    &
+    )
+    output_var_table(58)%averaging_grid => south_geostrophic_scalar_profile
     output_var_table(58)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
 
     output_var_table(59) = init_nc_var(                                     &
-       name              = 'internal_density_east',                        &
+       name              = 'internal_density_east',                         &
        std_name          = "",                                              &
        long_name         = "",                                              &
@@ -3367,13 +3394,13 @@
        input_id          = 4_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = east_averaged_scalar_profile,                    &
-       intermediate_grid = east_averaged_scalar_profile                     &
-    )
-    output_var_table(59)%averaging_grid => east_averaged_scalar_profile
+       grid              = east_geostrophic_scalar_profile,                    &
+       intermediate_grid = east_geostrophic_scalar_profile                     &
+    )
+    output_var_table(59)%averaging_grid => east_geostrophic_scalar_profile
     output_var_table(59)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
 
     output_var_table(60) = init_nc_var(                                     &
-       name              = 'internal_density_west',                        &
+       name              = 'internal_density_west',                         &
        std_name          = "",                                              &
        long_name         = "",                                              &
@@ -3382,8 +3409,8 @@
        input_id          = 4_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = west_averaged_scalar_profile,                    &
-       intermediate_grid = west_averaged_scalar_profile                     &
-    )
-    output_var_table(60)%averaging_grid => west_averaged_scalar_profile
+       grid              = west_geostrophic_scalar_profile,                    &
+       intermediate_grid = west_geostrophic_scalar_profile                     &
+    )
+    output_var_table(60)%averaging_grid => west_geostrophic_scalar_profile
     output_var_table(60)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
@@ -3396,8 +3423,8 @@
        input_id          = 2_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = north_averaged_scalar_profile,                   &
-       intermediate_grid = north_averaged_scalar_profile                    &
-    )
-    output_var_table(61)%averaging_grid => north_averaged_scalar_profile
+       grid              = north_geostrophic_scalar_profile,                   &
+       intermediate_grid = north_geostrophic_scalar_profile                    &
+    )
+    output_var_table(61)%averaging_grid => north_geostrophic_scalar_profile
     output_var_table(61)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
@@ -3411,8 +3438,8 @@
        input_id          = 2_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = south_averaged_scalar_profile,                   &
-       intermediate_grid = south_averaged_scalar_profile                    &
-    )
-    output_var_table(62)%averaging_grid => south_averaged_scalar_profile
+       grid              = south_geostrophic_scalar_profile,                   &
+       intermediate_grid = south_geostrophic_scalar_profile                    &
+    )
+    output_var_table(62)%averaging_grid => south_geostrophic_scalar_profile
     output_var_table(62)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
@@ -3426,8 +3453,8 @@
        input_id          = 2_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = east_averaged_scalar_profile,                    &
-       intermediate_grid = east_averaged_scalar_profile                     &
-    )
-    output_var_table(63)%averaging_grid => east_averaged_scalar_profile
+       grid              = east_geostrophic_scalar_profile,                    &
+       intermediate_grid = east_geostrophic_scalar_profile                     &
+    )
+    output_var_table(63)%averaging_grid => east_geostrophic_scalar_profile
     output_var_table(63)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
@@ -3441,11 +3468,11 @@
        input_id          = 2_iwp,                                           &
        output_file       = output_file,                                     &
-       grid              = west_averaged_scalar_profile,                    &
-       intermediate_grid = west_averaged_scalar_profile                     &
-    )
-    output_var_table(64)%averaging_grid => west_averaged_scalar_profile
+       grid              = west_geostrophic_scalar_profile,                    &
+       intermediate_grid = west_geostrophic_scalar_profile                     &
+    )
+    output_var_table(64)%averaging_grid => west_geostrophic_scalar_profile
     output_var_table(64)%to_be_processed = .NOT. cfg%ug_defined_by_user
 
-    output_var_table(65) = init_nc_var(                                      &
+    output_var_table(65) = init_nc_var(                                     &
        name              = 'init_atmosphere_qc',                            &
        std_name          = "",                                              &
@@ -3457,9 +3484,6 @@
        grid              = palm_grid,                                       &
        intermediate_grid = palm_intermediate,                               &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(65)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
     output_var_table(65)%is_optional = .TRUE.
 
@@ -3473,5 +3497,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_west_grid,                               &
-       intermediate_grid = scalars_west_intermediate                        &
+       intermediate_grid = scalars_west_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(66)%is_optional = .TRUE.
@@ -3486,5 +3511,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_east_grid,                               &
-       intermediate_grid = scalars_east_intermediate                        &
+       intermediate_grid = scalars_east_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(67)%is_optional = .TRUE.
@@ -3499,5 +3525,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_north_grid,                              &
-       intermediate_grid = scalars_north_intermediate                       &
+       intermediate_grid = scalars_north_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(68)%is_optional = .TRUE.
@@ -3512,5 +3539,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_south_grid,                              &
-       intermediate_grid = scalars_south_intermediate                       &
+       intermediate_grid = scalars_south_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(69)%is_optional = .TRUE.
@@ -3525,5 +3553,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_top_grid,                                &
-       intermediate_grid = scalars_top_intermediate                         &
+       intermediate_grid = scalars_top_intermediate,                        &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(70)%is_optional = .TRUE.
@@ -3539,9 +3568,6 @@
        grid              = palm_grid,                                       &
        intermediate_grid = palm_intermediate,                               &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(71)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
     output_var_table(71)%is_optional = .TRUE.
 
@@ -3555,5 +3581,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_west_grid,                               &
-       intermediate_grid = scalars_west_intermediate                        &
+       intermediate_grid = scalars_west_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(72)%is_optional = .TRUE.
@@ -3568,5 +3595,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_east_grid,                               &
-       intermediate_grid = scalars_east_intermediate                        &
+       intermediate_grid = scalars_east_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(73)%is_optional = .TRUE.
@@ -3581,5 +3609,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_north_grid,                              &
-       intermediate_grid = scalars_north_intermediate                       &
+       intermediate_grid = scalars_north_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(74)%is_optional = .TRUE.
@@ -3594,5 +3623,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_south_grid,                              &
-       intermediate_grid = scalars_south_intermediate                       &
+       intermediate_grid = scalars_south_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(75)%is_optional = .TRUE.
@@ -3607,5 +3637,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_top_grid,                                &
-       intermediate_grid = scalars_top_intermediate                         &
+       intermediate_grid = scalars_top_intermediate,                        &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(76)%is_optional = .TRUE.
@@ -3614,5 +3645,5 @@
        name              = 'init_atmosphere_qr',                            &
        std_name          = "",                                              &
-       long_name         = "initial rain water mixture fraction",            &
+       long_name         = "initial rain water mixture fraction",           &
        units             = "kg/kg",                                         &
        kind              = "init scalar",                                   &
@@ -3621,9 +3652,6 @@
        grid              = palm_grid,                                       &
        intermediate_grid = palm_intermediate,                               &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(77)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
     output_var_table(77)%is_optional = .TRUE.
 
@@ -3637,5 +3665,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_west_grid,                               &
-       intermediate_grid = scalars_west_intermediate                        &
+       intermediate_grid = scalars_west_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(78)%is_optional = .TRUE.
@@ -3650,5 +3679,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_east_grid,                               &
-       intermediate_grid = scalars_east_intermediate                        &
+       intermediate_grid = scalars_east_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(79)%is_optional = .TRUE.
@@ -3663,5 +3693,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_north_grid,                              &
-       intermediate_grid = scalars_north_intermediate                       &
+       intermediate_grid = scalars_north_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(80)%is_optional = .TRUE.
@@ -3676,5 +3707,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_south_grid,                              &
-       intermediate_grid = scalars_south_intermediate                       &
+       intermediate_grid = scalars_south_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(81)%is_optional = .TRUE.
@@ -3689,5 +3721,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_top_grid,                                &
-       intermediate_grid = scalars_top_intermediate                         &
+       intermediate_grid = scalars_top_intermediate,                        &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(82)%is_optional = .TRUE.
@@ -3696,5 +3729,5 @@
        name              = 'init_atmosphere_qs',                            &
        std_name          = "",                                              &
-       long_name         = "initial snow mixture fraction",            &
+       long_name         = "initial snow mixture fraction",                 &
        units             = "kg/kg",                                         &
        kind              = "init scalar",                                   &
@@ -3703,9 +3736,6 @@
        grid              = palm_grid,                                       &
        intermediate_grid = palm_intermediate,                               &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(83)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
     output_var_table(83)%is_optional = .TRUE.
 
@@ -3719,5 +3749,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_west_grid,                               &
-       intermediate_grid = scalars_west_intermediate                        &
+       intermediate_grid = scalars_west_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(84)%is_optional = .TRUE.
@@ -3732,5 +3763,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_east_grid,                               &
-       intermediate_grid = scalars_east_intermediate                        &
+       intermediate_grid = scalars_east_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(85)%is_optional = .TRUE.
@@ -3745,5 +3777,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_north_grid,                              &
-       intermediate_grid = scalars_north_intermediate                       &
+       intermediate_grid = scalars_north_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(86)%is_optional = .TRUE.
@@ -3758,5 +3791,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_south_grid,                              &
-       intermediate_grid = scalars_south_intermediate                       &
+       intermediate_grid = scalars_south_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(87)%is_optional = .TRUE.
@@ -3771,5 +3805,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_top_grid,                                &
-       intermediate_grid = scalars_top_intermediate                         &
+       intermediate_grid = scalars_top_intermediate,                        &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(88)%is_optional = .TRUE.
@@ -3778,5 +3813,5 @@
        name              = 'init_atmosphere_qg',                            &
        std_name          = "",                                              &
-       long_name         = "initial graupel mixture fraction",            &
+       long_name         = "initial graupel mixture fraction",              &
        units             = "kg/kg",                                         &
        kind              = "init scalar",                                   &
@@ -3785,9 +3820,6 @@
        grid              = palm_grid,                                       &
        intermediate_grid = palm_intermediate,                               &
-       is_profile = (TRIM(ic_mode) == 'profile')                            &
-    )
-    IF (TRIM(ic_mode) == 'profile')  THEN
-       output_var_table(89)%averaging_grid => averaged_initial_scalar_profile
-    ENDIF
+       is_profile = (TRIM(cfg%ic_mode) == CFG_INIT_PROFILE)                 &
+    )
     output_var_table(89)%is_optional = .TRUE.
 
@@ -3801,5 +3833,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_west_grid,                               &
-       intermediate_grid = scalars_west_intermediate                        &
+       intermediate_grid = scalars_west_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(90)%is_optional = .TRUE.
@@ -3814,5 +3847,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_east_grid,                               &
-       intermediate_grid = scalars_east_intermediate                        &
+       intermediate_grid = scalars_east_intermediate,                       &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(91)%is_optional = .TRUE.
@@ -3827,5 +3861,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_north_grid,                              &
-       intermediate_grid = scalars_north_intermediate                       &
+       intermediate_grid = scalars_north_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(92)%is_optional = .TRUE.
@@ -3840,5 +3875,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_south_grid,                              &
-       intermediate_grid = scalars_south_intermediate                       &
+       intermediate_grid = scalars_south_intermediate,                      &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(93)%is_optional = .TRUE.
@@ -3853,5 +3889,6 @@
        output_file       = output_file,                                     &
        grid              = scalars_top_grid,                                &
-       intermediate_grid = scalars_top_intermediate                         &
+       intermediate_grid = scalars_top_intermediate,                        &
+       is_profile = (TRIM(cfg%bc_mode) == CFG_FORCING_HOMO)                 &
     )
     output_var_table(94)%is_optional = .TRUE.
@@ -3969,5 +4006,16 @@
           var%task            = "interpolate_3d"
 
-       CASE( 'init scalar profile', 'init u profile', 'init v profile')
+       CASE( 'init soil profile' )
+          var%nt              = 1
+          var%lod             = 1
+          var%ndim            = 1
+          var%dimids(1)       = output_file%dimids_soil(3)
+          var%dimvarids(1)    = output_file%dimvarids_soil(3)
+          var%to_be_processed = init_variables_required
+          var%is_internal     = .FALSE.
+          var%task            = "average levels"
+          var%averaging_grid  => averaged_soil_profile
+
+       CASE( 'init scalar profile', 'init u profile', 'init v profile' )
           var%nt              = 1
           var%lod             = 1
@@ -3978,4 +4026,5 @@
           var%is_internal     = .FALSE.
           var%task            = "average profile"
+          var%averaging_grid  => averaged_scalar_profile
 
        CASE( 'init w profile')
@@ -3988,7 +4037,8 @@
           var%is_internal     = .FALSE.
           var%task            = "average profile"
+          var%averaging_grid  => averaged_w_profile
 
        CASE( 'surface forcing' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time
@@ -4001,5 +4051,5 @@
 
        CASE( 'left scalar', 'right scalar')
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time
@@ -4014,5 +4064,5 @@
 
        CASE( 'north scalar', 'south scalar')
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time
@@ -4027,5 +4077,5 @@
 
        CASE( 'top scalar', 'top w' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time
@@ -4040,5 +4090,5 @@
 
        CASE( 'left u', 'right u' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time
@@ -4053,5 +4103,5 @@
 
        CASE( 'north u', 'south u' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time    !t
@@ -4066,5 +4116,5 @@
 
        CASE( 'top u' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time    !t
@@ -4079,5 +4129,5 @@
 
        CASE( 'left v', 'right v' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time
@@ -4092,5 +4142,5 @@
 
        CASE( 'north v', 'south v' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time    !t
@@ -4105,5 +4155,5 @@
 
        CASE( 'top v' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time    !t
@@ -4118,5 +4168,5 @@
 
        CASE( 'left w', 'right w')
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time
@@ -4131,5 +4181,5 @@
 
        CASE( 'north w', 'south w' )
-          var%lod             = -1
+          var%lod             = 2
           var%ndim            = 3
           var%dimids(3)       = output_file%dimid_time    !t
@@ -4143,4 +4193,54 @@
           var%task            = "interpolate_3d"
 
+       CASE( 'left scalar profile', 'right scalar profile',                    &
+             'north scalar profile', 'south scalar profile',                   &
+             'left u profile', 'right u profile',                              &
+             'north u profile', 'south u profile',                             &
+             'left v profile', 'right v profile',                              &
+             'north v profile', 'south v profile' )
+          var%lod             = 1
+          var%ndim            = 2
+          var%dimids(2)       = output_file%dimid_time    !t
+          var%dimids(1)       = output_file%dimids_scl(3) !z
+          var%dimvarids(2)    = output_file%dimvarid_time
+          var%dimvarids(1)    = output_file%dimvarids_scl(3)
+          var%to_be_processed = boundary_variables_required
+          var%is_internal     = .FALSE.
+          var%task            = "average profile"
+          var%averaging_grid  => averaged_scalar_profile
+
+       CASE( 'top scalar profile', 'top u profile', 'top v profile' )
+          var%lod             = 0
+          var%ndim            = 1
+          var%dimids(1)       = output_file%dimid_time    !t
+          var%dimvarids(1)    = output_file%dimvarid_time
+          var%to_be_processed = boundary_variables_required
+          var%is_internal     = .FALSE.
+          var%task            = "average profile"
+          var%averaging_grid  => averaged_scalar_top_point
+
+       CASE( 'left w profile', 'right w profile',                              &
+             'north w profile', 'south w profile' )
+          var%lod             = 1
+          var%ndim            = 2
+          var%dimids(2)       = output_file%dimid_time    !t
+          var%dimids(1)       = output_file%dimids_vel(3) !z
+          var%dimvarids(2)    = output_file%dimvarid_time
+          var%dimvarids(1)    = output_file%dimvarids_vel(3)
+          var%to_be_processed = boundary_variables_required
+          var%is_internal     = .FALSE.
+          var%task            = "average profile"
+          var%averaging_grid  => averaged_w_profile
+
+       CASE( 'top w profile' )
+          var%lod             = 0
+          var%ndim            = 1
+          var%dimids(1)       = output_file%dimid_time    !t
+          var%dimvarids(1)    = output_file%dimvarid_time
+          var%to_be_processed = boundary_variables_required
+          var%is_internal     = .FALSE.
+          var%task            = "average profile"
+          var%averaging_grid  => averaged_w_top_point
+
        CASE( 'time series' )
           var%lod             = 0
@@ -4153,5 +4253,5 @@
 
        CASE( 'constant scalar profile' )
-          var%lod             = -1
+          var%lod             = 1
           var%ndim            = 2
           var%dimids(2)       = output_file%dimid_time    !t
@@ -4164,5 +4264,5 @@
 
        CASE( 'large-scale scalar forcing' )
-          var%lod             = -1
+          var%lod             = 1
           var%ndim            = 2
           var%dimids(2)       = output_file%dimid_time    !t
@@ -4175,5 +4275,5 @@
 
        CASE( 'geostrophic' )
-          var%lod             = -1
+          var%lod             = 1
           var%ndim            = 2
           var%dimids(2)       = output_file%dimid_time    !t
@@ -4186,5 +4286,5 @@
 
        CASE( 'large-scale w forcing' )
-          var%lod             = -1
+          var%lod             = 1
           var%ndim            = 2
           var%dimids(2)       = output_file%dimid_time    !t
@@ -4208,5 +4308,5 @@
 
        CASE DEFAULT
-           message = "Variable kind '" // TRIM(kind) // "' not recognized."
+           message = "Variable kind '" // TRIM(out_var_kind) // "' not recognized."
            CALL inifor_abort ('init_nc_var', message)
 
@@ -4350,6 +4450,6 @@
              DO  i = 1, nx
 
-                CALL get_basic_state(cosmo_grid%hfl(i,j,:), BETA, P_SL, T_SL,&
-                                     RD, G, basic_state_pressure)
+                CALL get_basic_state( cosmo_grid%hfl(i,j,:), BETA, P_SL, T_SL, &
+                                      RD, G, basic_state_pressure )
 
 !
Index: /palm/trunk/UTIL/inifor/src/inifor_io.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 4674)
+++ /palm/trunk/UTIL/inifor/src/inifor_io.f90	(revision 4675)
@@ -26,4 +26,9 @@
 ! -----------------
 ! $Id$
+! New command-line options for soil profile initialization and homogeneous
+!    boundary conditions
+!
+!
+! 4659 2020-08-31 11:21:17Z eckhard
 ! New command-line option '--precipitation' enables output of precipitation
 !    surface forcing
@@ -160,5 +165,8 @@
     USE inifor_control
     USE inifor_defs,                                                           &
-        ONLY:  DATE, SNAME, PATH, PI, TO_RADIANS, TO_DEGREES, VERSION,         &
+        ONLY:  CFG_INIT_PROFILE, CFG_INIT_VOLUME,                              &
+               CFG_INIT_SOIL_PROFILE, CFG_INIT_SOIL_VOLUME,                    &
+               CFG_FORCING_HETERO, CFG_FORCING_HOMO, CFG_FORCING_NUDGING,      &
+               DATE, SNAME, PATH, PI, TO_RADIANS, TO_DEGREES, VERSION,         &
                NC_DEPTH_DIM_IDX, NC_DEPTH_NAME, NC_HHL_NAME, NC_RLAT_NAME,     &
                NC_RLON_NAME, NC_ROTATED_POLE_NAME, NC_POLE_LATITUDE_NAME,      &
@@ -562,7 +570,11 @@
                 cfg%namelist_file = TRIM(arg)
 
-             CASE( '-mode', '-i', '--init-mode' )
+             CASE( '-i', '--init-mode' )
                 CALL get_option_argument( i, arg )
                 cfg%ic_mode = TRIM(arg)
+
+             CASE( '--soil-init-mode' )
+                CALL get_option_argument( i, arg )
+                cfg%isc_mode = TRIM(arg)
 
              CASE( '-f', '--forcing-mode' )
@@ -733,20 +745,35 @@
 
     SELECT CASE( TRIM( cfg%ic_mode ) )
-       CASE( 'profile', 'volume' )
+       CASE( CFG_INIT_PROFILE, CFG_INIT_VOLUME )
        CASE DEFAULT
           message = "Initialization mode '" // TRIM( cfg%ic_mode ) //&
                     "' is not supported. " //&
-                    "Please select either 'profile' or 'volume', " //&
-                    "or omit the -i/--init-mode/-mode option entirely, which corresponds "//&
+                    "Please select either '" // CFG_INIT_PROFILE //"' or '" // &
+                    CFG_INIT_VOLUME //"', " //&
+                    "or omit the -i/--init-mode option entirely, which corresponds "//&
                     "to the latter."
           CALL inifor_abort( 'validate_config', message )
     END SELECT
 
+    SELECT CASE( TRIM( cfg%isc_mode ) )
+       CASE( CFG_INIT_SOIL_PROFILE, CFG_INIT_SOIL_VOLUME )
+       CASE DEFAULT
+          message = "Soil initialization mode '" // TRIM( cfg%isc_mode ) //&
+                    "' is not supported. " //&
+                    "Please select either '" // CFG_INIT_SOIL_PROFILE //"' or '" // &
+                    CFG_INIT_SOIL_VOLUME //"', " //&
+                    "or omit the --soil-init-mode option entirely, which corresponds "//&
+                    "to the latter."
+          CALL inifor_abort( 'validate_config', message )
+    END SELECT
+
     SELECT CASE( TRIM(cfg%bc_mode) )
-       CASE( 'real', 'ideal')
+       CASE( CFG_FORCING_HOMO, CFG_FORCING_HETERO, CFG_FORCING_NUDGING )
        CASE DEFAULT
           message = "Forcing mode '" // TRIM( cfg%bc_mode ) //& 
                     "' is not supported. " //&
-                    "Please select either 'real' or 'ideal', " //&
+                    "Please select either '" // CFG_FORCING_NUDGING //          &
+                    "', '" // CFG_FORCING_HOMO // "', or '" //                 &
+                    CFG_FORCING_HETERO // "' " //&
                     "or omit the -f/--forcing-mode option entirely, which corresponds "//&
                     "to the latter."
@@ -1420,6 +1447,6 @@
     LOGICAL      ::  var_is_time_dependent
 
-    var_is_time_dependent = (                                               &
-       var%dimids( var%ndim ) == output_file%dimid_time               &
+    var_is_time_dependent = (                                                  &
+       var%dimids( var%ndim ) == output_file%dimid_time                        &
     )
 
@@ -1439,10 +1466,10 @@
     SELECT CASE (TRIM(var%kind))
        
-       CASE ( 'init scalar profile', 'init u profile', 'init v profile',       &
-              'init w profile' )
+       CASE( 'init scalar profile', 'init u profile', 'init v profile',        &
+             'init w profile', 'init soil profile' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(1,1,:) ) )
 
-       CASE ( 'init soil', 'init scalar', 'init u', 'init v', 'init w' )
+       CASE( 'init soil', 'init scalar', 'init u', 'init v', 'init w' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(:,:,:) ) )
@@ -1457,5 +1484,5 @@
           IF (.NOT. SIZE(array, 2) .EQ. var%dimlen(1))  THEN
              PRINT *, "inifor: update_output: Dimension ", 1, " of variable ", &
-                 TRIM(var%name), " (", var%dimlen(1),                      &
+                 TRIM(var%name), " (", var%dimlen(1),                          &
                  ") does not match the dimension of the output array (",       &
                  SIZE(array, 2), ")."
@@ -1477,5 +1504,5 @@
                                    count=count(1:ndim) ) )
           
-       CASE ( 'left u', 'right u', 'left v', 'right v' )
+       CASE( 'left u', 'right u', 'left v', 'right v' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(1,:,:),              &
@@ -1483,5 +1510,5 @@
                                    count=count(1:ndim) ) )
 
-       CASE ( 'north u', 'south u', 'north v', 'south v' )
+       CASE( 'north u', 'south u', 'north v', 'south v' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(:,1,:),              &
@@ -1489,5 +1516,5 @@
                                    count=count(1:ndim) ) )
 
-       CASE ( 'top u', 'top v' )
+       CASE( 'top u', 'top v' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(:,:,1),              &
@@ -1495,10 +1522,20 @@
                                    count=count(1:ndim) ) )
 
-       CASE ( 'time series' )
+       CASE( 'time series' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(1,1,1),              &
                                    start=start(1:ndim+1) ) )
 
-       CASE ( 'constant scalar profile', 'geostrophic' )
+       CASE( 'constant scalar profile', 'geostrophic',                         &
+             'left scalar profile', 'right scalar profile',                    &
+             'north scalar profile', 'south scalar profile',                   &
+             'left u profile', 'right u profile',                              &
+             'north u profile', 'south u profile',                             &
+             'left v profile', 'right v profile',                              &
+             'north v profile', 'south v profile',                             &
+             'top scalar profile', 'top u profile', 'top v profile',           &
+             'top w profile',                                                  &
+             'left w profile', 'right w profile',                              &
+             'north w profile', 'south w profile' )
 
           CALL check(nf90_put_var( ncid, var%varid, array(1,1,:),              &
Index: /palm/trunk/UTIL/inifor/src/inifor_transform.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_transform.f90	(revision 4674)
+++ /palm/trunk/UTIL/inifor/src/inifor_transform.f90	(revision 4675)
@@ -21,9 +21,13 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Improved code formatting
+! 
+! 
+! 4553 2020-06-03 16:34:15Z eckhard
 ! Improved code readability and documentation
 ! 
@@ -431,5 +435,5 @@
 
     TYPE(grid_definition), INTENT(IN)          ::  avg_grid
-    REAL(wp), DIMENSION(:,:,:), INTENT(IN)     ::  source_array 
+    REAL(wp), DIMENSION(:,:,:), INTENT(IN)     ::  source_array
     REAL(wp), DIMENSION(:), INTENT(OUT)        ::  profile_array
 
@@ -445,5 +449,5 @@
                  "cosmo_pressure(" // TRIM( str( nlev ) ) //                &
                  "), profile_array(" // TRIM( str( nz ) )  // ")."
-       CALL inifor_abort('average_pressure_perturbation', message)
+       CALL inifor_abort( 'average_profile', message )
     ENDIF
     
Index: /palm/trunk/UTIL/inifor/src/inifor_types.f90
===================================================================
--- /palm/trunk/UTIL/inifor/src/inifor_types.f90	(revision 4674)
+++ /palm/trunk/UTIL/inifor/src/inifor_types.f90	(revision 4675)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Added INIFOR configuration flag for soil profile initialization
+!
+!
+! 4659 2020-08-31 11:21:17Z eckhard
 ! Added flag in support of new command-line option '--precipitation'
 ! Improved code formatting
@@ -133,4 +137,5 @@
     CHARACTER(LEN=SNAME) ::  bc_mode              !< destinguishes realistic and idealistic forcing
     CHARACTER(LEN=SNAME) ::  ic_mode              !< destinguishes volume and profile initialization
+    CHARACTER(LEN=SNAME) ::  isc_mode             !< destinguishes volume and profile soil initialization
     CHARACTER(LEN=SNAME) ::  rotation_method      !< selects method for velocity rotation
 
