Index: palm/trunk/SCRIPTS/mbuild
===================================================================
--- palm/trunk/SCRIPTS/mbuild	(revision 1825)
+++ palm/trunk/SCRIPTS/mbuild	(revision 1826)
@@ -22,5 +22,5 @@
 # Current revisions:
 # ------------------
-# 
+# Added note that the script does not work on MAC OS
 # 
 # Former revisions:
@@ -119,4 +119,6 @@
 # Procedure to compile code on local and remote hosts using the
 # make-mechanism. The source code must be provided on the local host.
+#
+# @note This script does not work on MAC OS
 #--------------------------------------------------------------------------------#
 
Index: palm/trunk/SOURCE/Makefile
===================================================================
--- palm/trunk/SOURCE/Makefile	(revision 1825)
+++ palm/trunk/SOURCE/Makefile	(revision 1826)
@@ -20,5 +20,6 @@
 # Current revisions:
 # ------------------
-#
+# Renamed radiation_model to radiation_model_mod.
+# Renamed plant_canopy_model to plant_canopy_model_mod.
 # 
 # Former revisions:
@@ -278,10 +279,10 @@
 	ls_forcing.f90 message.f90 microphysics.f90 modules.f90 mod_kinds.f90 \
 	mod_particle_attributes.f90 netcdf_interface.f90 nudging.f90 \
-	package_parin.f90 palm.f90 parin.f90 plant_canopy_model.f90 pmc_interface.f90 \
+	package_parin.f90 palm.f90 parin.f90 plant_canopy_model_mod.f90 pmc_interface.f90 \
 	pmc_client.f90 pmc_general.f90 pmc_handle_communicator.f90 pmc_mpi_wrapper.f90 \
 	pmc_server.f90 \
 	poisfft.f90 poismg.f90 \
 	poismg_fast.f90 pres.f90 print_1d.f90 production_e.f90 \
-	prognostic_equations.f90 progress_bar.f90 radiation_model.f90 \
+	prognostic_equations.f90 progress_bar.f90 radiation_model_mod.f90 \
 	random_function.f90 random_gauss.f90 random_generator_parallel.f90 \
 	read_3d_binary.f90 read_var_list.f90 run_control.f90 \
@@ -347,5 +348,5 @@
 advec_w_up.o: modules.o mod_kinds.o
 average_3d_data.o: modules.o cpulog.o mod_kinds.o land_surface_model_mod.o\
-                   radiation_model.o
+                   radiation_model_mod.o
 boundary_conds.o: modules.o mod_kinds.o
 buoyancy.o: modules.o mod_kinds.o
@@ -356,5 +357,5 @@
 check_open.o: modules.o mod_kinds.o mod_particle_attributes.o netcdf_interface.o
 check_parameters.o: modules.o mod_kinds.o land_surface_model_mod.o \
-	netcdf_interface.o plant_canopy_model.o pmc_interface.o radiation_model.o \
+	netcdf_interface.o plant_canopy_model_mod.o pmc_interface.o radiation_model_mod.o \
 	subsidence.o
 close_file.o: modules.o mod_kinds.o netcdf_interface.o
@@ -375,5 +376,5 @@
 data_output_tseries.o: modules.o cpulog.o mod_kinds.o netcdf_interface.o
 data_output_2d.o: modules.o cpulog.o mod_kinds.o mod_particle_attributes.o\
-   netcdf_interface.o land_surface_model_mod.o radiation_model.o
+   netcdf_interface.o land_surface_model_mod.o radiation_model_mod.o
 data_output_3d.o: modules.o cpulog.o mod_kinds.o mod_particle_attributes.o\
    netcdf_interface.o land_surface_model_mod.o
@@ -392,14 +393,14 @@
 fft_xy.o: cuda_fft_interfaces.o modules.o mod_kinds.o singleton.o temperton_fft.o
 flow_statistics.o: modules.o cpulog.o mod_kinds.o land_surface_model_mod.o\
-   netcdf_interface.o radiation_model.o
+   netcdf_interface.o radiation_model_mod.o
 global_min_max.o: modules.o mod_kinds.o
 header.o: modules.o cpulog.o mod_kinds.o netcdf_interface.o land_surface_model_mod.o\
-   plant_canopy_model.o pmc_handle_communicator.o pmc_interface.o \
-   radiation_model.o spectrum.o subsidence.o 
+plant_canopy_model_mod.o pmc_handle_communicator.o pmc_interface.o \
+   radiation_model_mod.o spectrum.o subsidence.o
 inflow_turbulence.o: modules.o cpulog.o mod_kinds.o
 init_1d_model.o: modules.o mod_kinds.o
 init_3d_model.o: modules.o mod_kinds.o advec_ws.o cpulog.o land_surface_model_mod.o \
-   lpm_init.o ls_forcing.o netcdf_interface.o plant_canopy_model.o \
-   radiation_model.o random_function.o random_generator_parallel.o \
+   lpm_init.o ls_forcing.o netcdf_interface.o plant_canopy_model_mod.o \
+   radiation_model_mod.o random_function.o random_generator_parallel.o \
 	surface_layer_fluxes.o
 init_advec.o: modules.o mod_kinds.o
@@ -415,5 +416,5 @@
 init_slope.o: modules.o mod_kinds.o
 interaction_droplets_ptq.o: modules.o mod_kinds.o
-land_surface_model_mod.o: modules.o mod_kinds.o radiation_model.o
+land_surface_model_mod.o: modules.o mod_kinds.o radiation_model_mod.o
 local_stop.o: modules.o mod_kinds.o pmc_interface.o
 local_tremain.o: modules.o cpulog.o mod_kinds.o
@@ -454,11 +455,10 @@
    land_surface_model_mod.o spectrum.o
 nudging.o: modules.o cpulog.o mod_kinds.o
-package_parin.o: modules.o mod_kinds.o \
-   plant_canopy_model.o radiation_model.o spectrum.o
+package_parin.o: modules.o mod_kinds.o spectrum.o
 palm.o: modules.o cpulog.o ls_forcing.o mod_kinds.o nudging.o\
 	pmc_interface.o surface_layer_fluxes.o
 parin.o: modules.o cpulog.o land_surface_model_mod.o mod_kinds.o netcdf_interface.o \
-   pmc_interface.o progress_bar.o
-plant_canopy_model.o: modules.o mod_kinds.o
+   plant_canopy_model_mod.o pmc_interface.o progress_bar.o radiation_model_mod.o 
+plant_canopy_model_mod.o: modules.o mod_kinds.o
 pmc_interface.o: modules.o mod_kinds.o pmc_client.o pmc_general.o\
 	pmc_handle_communicator.o pmc_mpi_wrapper.o pmc_server.o
@@ -480,15 +480,15 @@
 	cpulog.o diffusion_e.o diffusion_s.o diffusion_u.o diffusion_v.o diffusion_w.o \
 	eqn_state_seawater.o mod_kinds.o microphysics.o \
-	nudging.o plant_canopy_model.o production_e.o radiation_model.o \
+	nudging.o plant_canopy_model_mod.o production_e.o radiation_model_mod.o \
 	subsidence.o user_actions.o
 progress_bar.o: modules.o mod_kinds.o
-radiation_model.o : modules.o mod_particle_attributes.o
+radiation_model_mod.o : modules.o mod_particle_attributes.o
 random_function.o: mod_kinds.o
 random_gauss.o: mod_kinds.o random_function.o random_generator_parallel.o
 random_generator_parallel.o: mod_kinds.o
 read_3d_binary.o: modules.o cpulog.o mod_kinds.o land_surface_model_mod.o\
-                  radiation_model.o random_function.o\
+                  radiation_model_mod.o random_function.o\
                   random_generator_parallel.o
-read_var_list.o: modules.o mod_kinds.o netcdf_interface.o plant_canopy_model.o
+read_var_list.o: modules.o mod_kinds.o netcdf_interface.o plant_canopy_model_mod.o
 run_control.o: modules.o cpulog.o mod_kinds.o
 set_slicer_attributes_dvrp.o: modules.o mod_kinds.o
@@ -498,5 +498,5 @@
 subsidence.o: modules.o mod_kinds.o
 sum_up_3d_data.o: modules.o cpulog.o mod_kinds.o land_surface_model_mod.o\
-                  radiation_model.o 
+                  radiation_model_mod.o 
 surface_coupler.o: modules.o cpulog.o mod_kinds.o
 surface_layer_fluxes.o: modules.o mod_kinds.o land_surface_model_mod.o
@@ -507,5 +507,5 @@
 	cpulog.o interaction_droplets_ptq.o land_surface_model_mod.o \
 	ls_forcing.o mod_kinds.o nudging.o pmc_interface.o production_e.o \
-	prognostic_equations.o progress_bar.o radiation_model.o \
+	prognostic_equations.o progress_bar.o radiation_model_mod.o \
 	spectrum.o user_actions.o surface_layer_fluxes.o
 time_to_string.o: mod_kinds.o
@@ -532,6 +532,6 @@
 user_init_grid.o: modules.o mod_kinds.o user_module.o
 user_init_land_surface.o: modules.o mod_kinds.o user_module.o land_surface_model_mod.o
-user_init_plant_canopy.o: modules.o mod_kinds.o user_module.o plant_canopy_model.o
-user_init_radiation.o: modules.o mod_kinds.o user_module.o radiation_model.o
+user_init_plant_canopy.o: modules.o mod_kinds.o user_module.o plant_canopy_model_mod.o
+user_init_radiation.o: modules.o mod_kinds.o user_module.o radiation_model_mod.o
 user_last_actions.o: modules.o mod_kinds.o user_module.o
 user_lpm_advec.o: modules.o mod_kinds.o user_module.o
@@ -545,5 +545,5 @@
 wall_fluxes.o: modules.o mod_kinds.o
 write_3d_binary.o: modules.o cpulog.o mod_kinds.o land_surface_model_mod.o\
-                   radiation_model.o random_function.o\
+                   radiation_model_mod.o random_function.o\
                    random_generator_parallel.o
-write_var_list.o: modules.o mod_kinds.o netcdf_interface.o plant_canopy_model.o 
+write_var_list.o: modules.o mod_kinds.o netcdf_interface.o plant_canopy_model_mod.o 
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 1825)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 1826)
@@ -19,6 +19,8 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+! Moved checks for radiation model to the respective module.
+! Moved checks for plant canopy model to the respective module.
+! Bugfix for check of too large roughness_length
+!
 ! Former revisions:
 ! -----------------
@@ -349,5 +351,6 @@
     USE land_surface_model_mod,                                                &
         ONLY: land_surface, lsm_check_data_output, lsm_check_data_output_pr,   &
-              lsm_check_parameters, nzs, zs
+              lsm_check_parameters
+
     USE kinds
     USE model_1d
@@ -355,11 +358,17 @@
         ONLY:  dopr_unit, do2d_unit, do3d_unit, netcdf_data_format,            &
                netcdf_data_format_string
+
     USE particle_attributes
     USE pegrid
-    USE plant_canopy_model_mod
+    USE plant_canopy_model_mod,                                                &
+        ONLY:  pcm_check_parameters, plant_canopy
+        
     USE pmc_interface,                                                         &
         ONLY:  cpl_id, nested_run
+
     USE profil_parameter
-    USE radiation_model_mod
+    USE radiation_model_mod,                                                   &
+        ONLY: radiation, radiation_check_data_output,                          &
+              radiation_check_data_output_pr, radiation_check_parameters
     USE statistics
     USE subsidence_mod
@@ -1022,97 +1031,15 @@
     ENDIF
 
-    IF ( plant_canopy )  THEN
+!
+!-- When plant canopy model is used, peform addtional checks
+    IF ( plant_canopy )  CALL pcm_check_parameters
     
-       IF ( canopy_drag_coeff == 0.0_wp )  THEN
-          message_string = 'plant_canopy = .TRUE. requires a non-zero drag '// &
-                           'coefficient & given value is canopy_drag_coeff = 0.0'
-          CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
-       ENDIF
-    
-       IF ( ( alpha_lad /= 9999999.9_wp  .AND.  beta_lad == 9999999.9_wp )  .OR.&
-              beta_lad /= 9999999.9_wp   .AND.  alpha_lad == 9999999.9_wp )  THEN
-          message_string = 'using the beta function for the construction ' //  &
-                           'of the leaf area density profile requires '    //  &
-                           'both alpha_lad and beta_lad to be /= 9999999.9'
-          CALL message( 'check_parameters', 'PA0118', 1, 2, 0, 6, 0 )
-       ENDIF
-    
-       IF ( calc_beta_lad_profile  .AND.  lai_beta == 0.0_wp )  THEN
-          message_string = 'using the beta function for the construction ' //  &
-                           'of the leaf area density profile requires '    //  &
-                           'a non-zero lai_beta, but given value is '      //  &
-                           'lai_beta = 0.0'
-          CALL message( 'check_parameters', 'PA0119', 1, 2, 0, 6, 0 )
-       ENDIF
-
-       IF ( calc_beta_lad_profile  .AND.  lad_surface /= 0.0_wp )  THEN
-          message_string = 'simultaneous setting of alpha_lad /= 9999999.9' // &
-                           'and lad_surface /= 0.0 is not possible, '       // &
-                           'use either vertical gradients or the beta '     // &
-                           'function for the construction of the leaf area '// &
-                           'density profile'
-          CALL message( 'check_parameters', 'PA0120', 1, 2, 0, 6, 0 )
-       ENDIF 
-
-       IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
-          message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' // &
-                           ' seifert_beheng'
-          CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 )
-       ENDIF 
-
-    ENDIF
-
 !
 !-- When land surface model is used, peform addtional checks
     IF ( land_surface )  CALL lsm_check_parameters
 
-
-    IF ( radiation )  THEN
-       IF ( radiation_scheme /= 'constant'   .AND.                             &
-            radiation_scheme /= 'clear-sky'  .AND.                             &
-            radiation_scheme /= 'rrtmg' )  THEN
-          message_string = 'unknown radiation_scheme = '//                     &
-                           TRIM( radiation_scheme )
-          CALL message( 'check_parameters', 'PA0405', 1, 2, 0, 6, 0 )
-       ELSEIF ( radiation_scheme == 'rrtmg' )  THEN
-#if ! defined ( __rrtmg )
-          message_string = 'radiation_scheme = "rrtmg" requires ' //           & 
-                           'compilation of PALM with pre-processor ' //        &
-                           'directive -D__rrtmg'
-          CALL message( 'check_parameters', 'PA0407', 1, 2, 0, 6, 0 )
-#endif
-#if defined ( __rrtmg ) && ! defined( __netcdf )
-          message_string = 'radiation_scheme = "rrtmg" requires ' //           & 
-                           'the use of NetCDF (preprocessor directive ' //     &
-                           '-D__netcdf'
-          CALL message( 'check_parameters', 'PA0412', 1, 2, 0, 6, 0 )
-#endif
-
-       ENDIF
-       IF ( albedo_type == 0  .AND.  albedo == 9999999.9_wp  .AND.             &
-            radiation_scheme == 'clear-sky')  THEN
-          message_string = 'radiation_scheme = "clear-sky" in combination' //  & 
-                           'with albedo_type = 0 requires setting of albedo'// &
-                           ' /= 9999999.9'
-          CALL message( 'check_parameters', 'PA0410', 1, 2, 0, 6, 0 )
-       ENDIF
-       IF ( albedo_type == 0  .AND.  radiation_scheme == 'rrtmg'  .AND.        &
-          (    albedo_lw_dif == 9999999.9_wp .OR. albedo_lw_dir == 9999999.9_wp&
-          .OR. albedo_sw_dif == 9999999.9_wp .OR. albedo_sw_dir == 9999999.9_wp& 
-          ) ) THEN
-          message_string = 'radiation_scheme = "rrtmg" in combination' //      & 
-                           'with albedo_type = 0 requires setting of ' //      &
-                           'albedo_lw_dif /= 9999999.9' //                     &
-                           'albedo_lw_dir /= 9999999.9' //                     &
-                           'albedo_sw_dif /= 9999999.9 and' //                 &
-                           'albedo_sw_dir /= 9999999.9'
-          CALL message( 'check_parameters', 'PA0411', 1, 2, 0, 6, 0 )
-       ENDIF
-       IF ( topography /= 'flat' )  THEN
-          message_string = 'radiation scheme cannot be used ' //               & 
-                           'in combination with  topography /= "flat"'
-          CALL message( 'check_parameters', 'PA0414', 1, 2, 0, 6, 0 )
-       ENDIF
-    ENDIF
+!
+!-- When radiation model is used, peform addtional checks
+    IF ( radiation )  CALL radiation_check_parameters
 
     IF ( .NOT. ( loop_optimization == 'cache'  .OR.                            &
@@ -2980,134 +2907,16 @@
              ENDIF
 
-          CASE ( 'rad_net' )
-             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme == 'constant' )&
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme = "constant"'
-                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 101
-                dopr_unit(i)  = 'W/m2'
-                hom(:,2,101,:)  = SPREAD( zw, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_lw_in' )
-             IF ( (  .NOT.  radiation)  .OR.  radiation_scheme == 'constant' ) &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme = "constant"'
-                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 102
-                dopr_unit(i)  = 'W/m2'
-                hom(:,2,102,:)  = SPREAD( zw, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_lw_out' )
-             IF ( (  .NOT. radiation )  .OR.  radiation_scheme == 'constant' ) &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme = "constant"'
-                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 103
-                dopr_unit(i)  = 'W/m2'
-                hom(:,2,103,:)  = SPREAD( zw, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_sw_in' )
-             IF ( (  .NOT. radiation )  .OR.  radiation_scheme == 'constant' ) &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme = "constant"'
-                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 104
-                dopr_unit(i)  = 'W/m2'
-                hom(:,2,104,:)  = SPREAD( zw, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_sw_out')
-             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme == 'constant' ) &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme = "constant"'
-                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 105
-                dopr_unit(i)  = 'W/m2'
-                hom(:,2,105,:)  = SPREAD( zw, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_lw_cs_hr' )
-             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme /= "rrtmg"'
-                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 106
-                dopr_unit(i)  = 'K/h'
-                hom(:,2,106,:)  = SPREAD( zu, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_lw_hr' )
-             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme /= "rrtmg"'
-                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 107
-                dopr_unit(i)  = 'K/h'
-                hom(:,2,107,:)  = SPREAD( zu, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_sw_cs_hr' )
-             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme /= "rrtmg"'
-                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 108
-                dopr_unit(i)  = 'K/h'
-                hom(:,2,108,:)  = SPREAD( zu, 2, statistic_regions+1 )
-             ENDIF
-
-          CASE ( 'rad_sw_hr' )
-             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
-             THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not ava' // &
-                                 'lable for radiation = .FALSE. or ' //        &
-                                 'radiation_scheme /= "rrtmg"'
-                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 109
-                dopr_unit(i)  = 'K/h'
-                hom(:,2,109,:)  = SPREAD( zu, 2, statistic_regions+1 )
-             ENDIF
+ 
 
           CASE DEFAULT
 
-             CALL lsm_check_data_output_pr( data_output_pr(i), i, unit, dopr_unit(i) )
-
+             CALL lsm_check_data_output_pr( data_output_pr(i), i, unit,        &
+                                            dopr_unit(i) )
+
+             IF ( unit == 'illegal' )  THEN
+                CALL radiation_check_data_output_pr( data_output_pr(i), i,     &
+                                                     unit, dopr_unit(i) )
+             ENDIF
+             
              IF ( unit == 'illegal' )  THEN
                 CALL user_check_data_output_pr( data_output_pr(i), i, unit )
@@ -3288,14 +3097,4 @@
              unit = 'kg/kg'
 
-          CASE ( 'rad_lw_in', 'rad_lw_out', 'rad_lw_cs_hr', 'rad_lw_hr',       &
-                 'rad_sw_in', 'rad_sw_out', 'rad_sw_cs_hr', 'rad_sw_hr' )
-             IF (  .NOT.  radiation  .OR.  radiation_scheme /= 'rrtmg' )  THEN
-                message_string = '"output of "' // TRIM( var ) // '" requi' // &
-                                 'res radiation = .TRUE. and ' //              &
-                                 'radiation_scheme = "rrtmg"'
-                CALL message( 'check_parameters', 'PA0406', 1, 2, 0, 6, 0 )
-             ENDIF
-             unit = 'W/m2'
-
           CASE ( 'rho' )
              IF (  .NOT.  ocean )  THEN
@@ -3330,7 +3129,6 @@
              CONTINUE
 
-          CASE ( 'lai*', 'lwp*', 'ol*', 'pra*', 'prr*', 'qsws*', 'rad_net*',   &
-                 'rrtm_aldif*', 'rrtm_aldir*', 'rrtm_asdif*', 'rrtm_asdir*',   &
-                 'shf*', 't*', 'u*', 'z0*', 'z0h*', 'z0q*' )
+          CASE ( 'lai*', 'lwp*', 'ol*', 'pra*', 'prr*', 'qsws*', 'shf*', 't*', &
+                 'u*', 'z0*', 'z0h*', 'z0q*' )
              IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
                 message_string = 'illegal value for data_output: "' //         &
@@ -3339,21 +3137,5 @@
                 CALL message( 'check_parameters', 'PA0111', 1, 2, 0, 6, 0 )
              ENDIF
-             IF (  .NOT.  radiation  .OR.  radiation_scheme /= "rrtmg" )  THEN
-                IF ( TRIM( var ) == 'rrtm_aldif*'  .OR.                        &
-                     TRIM( var ) == 'rrtm_aldir*'  .OR.                        &
-                     TRIM( var ) == 'rrtm_asdif*'  .OR.                        &
-                     TRIM( var ) == 'rrtm_asdir*'      )                       &
-                THEN
-                   message_string = 'output of "' // TRIM( var ) // '" require'&
-                                    // 's radiation = .TRUE. and radiation_sch'&
-                                    // 'eme = "rrtmg"'
-                   CALL message( 'check_parameters', 'PA0409', 1, 2, 0, 6, 0 )
-                ENDIF
-             ENDIF
-             IF ( TRIM( var ) == 'lai*'  .AND.  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
+
              IF ( TRIM( var ) == 'lwp*'  .AND.  .NOT. cloud_physics )  THEN
                 message_string = 'output of "' // TRIM( var ) // '" requi' //  &
@@ -3384,5 +3166,4 @@
              ENDIF
 
-             IF ( TRIM( var ) == 'lai*'   )  unit = 'none'
              IF ( TRIM( var ) == 'lwp*'   )  unit = 'kg/m2'
              IF ( TRIM( var ) == 'ol*'   )   unit = 'm'
@@ -3390,9 +3171,4 @@
              IF ( TRIM( var ) == 'prr*'   )  unit = 'mm/s'
              IF ( TRIM( var ) == 'qsws*'  )  unit = 'kgm/kgs'
-             IF ( TRIM( var ) == 'rad_net*'      ) unit = 'W/m2'   
-             IF ( TRIM( var ) == 'rrtm_aldif*'   ) unit = ''   
-             IF ( TRIM( var ) == 'rrtm_aldir*'   ) unit = '' 
-             IF ( TRIM( var ) == 'rrtm_asdif*'   ) unit = '' 
-             IF ( TRIM( var ) == 'rrtm_asdir*'   ) unit = '' 
              IF ( TRIM( var ) == 'shf*'   )  unit = 'K*m/s'
              IF ( TRIM( var ) == 't*'     )  unit = 'K'
@@ -3404,5 +3180,9 @@
 
              CALL lsm_check_data_output ( var, unit, i, ilen, k )
-             
+ 
+             IF ( unit == 'illegal' )  THEN
+                CALL radiation_check_data_output( var, unit, i, ilen, k )
+             ENDIF
+
              IF ( unit == 'illegal' )  THEN
                 CALL user_check_data_output( var, unit )
@@ -4073,4 +3853,6 @@
     ENDIF
 
+    CALL location_message( 'finished', .TRUE. )
+
 !
 !-- Prevent empty time records in volume, cross-section and masked data in case of 
@@ -4100,5 +3882,5 @@
     IF ( ( constant_flux_layer .OR.  &
            INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) &
-         .AND. roughness_length <= 0.5 * dz )  THEN
+         .AND. roughness_length > 0.5 * dz )  THEN
        message_string = 'roughness_length must be smaller than dz/2'
        CALL message( 'check_parameters', 'PA0424', 1, 2, 0, 6, 0 )
Index: palm/trunk/SOURCE/header.f90
===================================================================
--- palm/trunk/SOURCE/header.f90	(revision 1825)
+++ palm/trunk/SOURCE/header.f90	(revision 1826)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! -----------------
-!
+! Moved radiation model header output to the respective module.
+! Moved canopy model header output to the respective module.
 !
 ! Former revisions:
@@ -289,9 +290,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  alpha_lad, beta_lad, calc_beta_lad_profile, canopy_drag_coeff,  &
-               canopy_mode, cthf, lad, lad_surface, lad_vertical_gradient,     &
-               lad_vertical_gradient_level, lad_vertical_gradient_level_ind,   &
-               lai_beta, leaf_scalar_exch_coeff, leaf_surface_conc, pch_index, &
-               plant_canopy
+        ONLY:  pcm_header, plant_canopy
 
     USE pmc_handle_communicator,                                               &
@@ -302,7 +299,5 @@
 
     USE radiation_model_mod,                                                   &
-        ONLY:  albedo, albedo_type, albedo_type_name, constant_albedo,         &
-               day_init, dt_radiation, lambda, lw_radiation, net_radiation,    &
-               radiation, radiation_scheme, sw_radiation, time_utc_init
+        ONLY:  radiation, radiation_header
     
     USE spectrum,                                                              &
@@ -339,11 +334,9 @@
     CHARACTER (LEN=70) ::  run_classification  !<
     
-    CHARACTER (LEN=85) ::  roben               !<
-    CHARACTER (LEN=85) ::  runten              !<
+    CHARACTER (LEN=85) ::  r_upper             !<
+    CHARACTER (LEN=85) ::  r_lower             !<
     
     CHARACTER (LEN=86) ::  coordinates         !<
     CHARACTER (LEN=86) ::  gradients           !<
-    CHARACTER (LEN=86) ::  leaf_area_density   !<
-    CHARACTER (LEN=86) ::  roots               !<
     CHARACTER (LEN=86) ::  slices              !<
     CHARACTER (LEN=86) ::  temperatures        !<
@@ -383,5 +376,5 @@
     INTEGER(iwp) ::  npe_total      !<
     
-    REAL(wp) ::  canopy_height                    !< canopy height (in m)
+
     REAL(wp) ::  cpuseconds_per_simulated_second  !<
     REAL(wp) ::  lower_left_coord_x               !< x-coordinate of nest domain
@@ -903,169 +896,78 @@
     ENDIF
 
-    IF ( plant_canopy )  THEN
-    
-       canopy_height = pch_index * dz
-
-       WRITE ( io, 280 )  canopy_mode, canopy_height, pch_index,               &
-                          canopy_drag_coeff
-       IF ( passive_scalar )  THEN
-          WRITE ( io, 281 )  leaf_scalar_exch_coeff,                           &
-                             leaf_surface_conc
-       ENDIF
-
-!
-!--    Heat flux at the top of vegetation
-       WRITE ( io, 282 )  cthf
-
-!
-!--    Leaf area density profile, calculated either from given vertical 
-!--    gradients or from beta probability density function.
-       IF (  .NOT.  calc_beta_lad_profile )  THEN
-
-!--       Building output strings, starting with surface value
-          WRITE ( leaf_area_density, '(F7.4)' )  lad_surface
-          gradients = '------'
-          slices = '     0'
-          coordinates = '   0.0'
-          i = 1
-          DO  WHILE ( i < 11  .AND.  lad_vertical_gradient_level_ind(i) /= -9999 )
-
-             WRITE (coor_chr,'(F7.2)')  lad(lad_vertical_gradient_level_ind(i))
-             leaf_area_density = TRIM( leaf_area_density ) // ' ' // TRIM( coor_chr )
- 
-             WRITE (coor_chr,'(F7.2)')  lad_vertical_gradient(i)
-             gradients = TRIM( gradients ) // ' ' // TRIM( coor_chr )
-
-             WRITE (coor_chr,'(I7)')  lad_vertical_gradient_level_ind(i)
-             slices = TRIM( slices ) // ' ' // TRIM( coor_chr )
-
-             WRITE (coor_chr,'(F7.1)')  lad_vertical_gradient_level(i)
-             coordinates = TRIM( coordinates ) // ' '  // TRIM( coor_chr )
-
-             i = i + 1
-          ENDDO
-
-          WRITE ( io, 283 )  TRIM( coordinates ), TRIM( leaf_area_density ),              &
-                             TRIM( gradients ), TRIM( slices )
-
-       ELSE
-       
-          WRITE ( leaf_area_density, '(F7.4)' )  lad_surface
-          coordinates = '   0.0'
-          
-          DO  k = 1, pch_index
-
-             WRITE (coor_chr,'(F7.2)')  lad(k)
-             leaf_area_density = TRIM( leaf_area_density ) // ' ' // TRIM( coor_chr )
- 
-             WRITE (coor_chr,'(F7.1)')  zu(k)
-             coordinates = TRIM( coordinates ) // ' '  // TRIM( coor_chr )
-
-          ENDDO       
-
-          WRITE ( io, 284 ) TRIM( coordinates ), TRIM( leaf_area_density ), alpha_lad,    &
-                            beta_lad, lai_beta
-
-       ENDIF  
-
-    ENDIF
+    IF ( plant_canopy )  CALL pcm_header ( io )
 
     IF ( land_surface )  CALL lsm_header ( io )
 
-    IF ( radiation )  THEN
-!
-!--    Write radiation model header
-       WRITE( io, 444 )
-
-       IF ( radiation_scheme == "constant" )  THEN
-          WRITE( io, 445 ) net_radiation
-       ELSEIF ( radiation_scheme == "clear-sky" )  THEN
-          WRITE( io, 446 )
-       ELSEIF ( radiation_scheme == "rrtmg" )  THEN
-          WRITE( io, 447 )
-          IF ( .NOT. lw_radiation )  WRITE( io, 458 )
-          IF ( .NOT. sw_radiation )  WRITE( io, 459 )
-       ENDIF
-
-       IF ( albedo_type == 0 )  THEN
-          WRITE( io, 448 ) albedo
-       ELSE
-          WRITE( io, 456 ) TRIM( albedo_type_name(albedo_type) )
-       ENDIF
-       IF ( constant_albedo )  THEN
-          WRITE( io, 457 )
-       ENDIF
-       WRITE( io, 449 ) dt_radiation
-    ENDIF
-
+    IF ( radiation )  CALL radiation_header ( io )
 
 !
 !-- Boundary conditions
     IF ( ibc_p_b == 0 )  THEN
-       runten = 'p(0)     = 0      |'
+       r_lower = 'p(0)     = 0      |'
     ELSEIF ( ibc_p_b == 1 )  THEN
-       runten = 'p(0)     = p(1)   |'
+       r_lower = 'p(0)     = p(1)   |'
     ENDIF
     IF ( ibc_p_t == 0 )  THEN
-       roben  = 'p(nzt+1) = 0      |'
+       r_upper  = 'p(nzt+1) = 0      |'
     ELSE
-       roben  = 'p(nzt+1) = p(nzt) |'
+       r_upper  = 'p(nzt+1) = p(nzt) |'
     ENDIF
 
     IF ( ibc_uv_b == 0 )  THEN
-       runten = TRIM( runten ) // ' uv(0)     = -uv(1)                |'
+       r_lower = TRIM( r_lower ) // ' uv(0)     = -uv(1)                |'
     ELSE
-       runten = TRIM( runten ) // ' uv(0)     = uv(1)                 |'
+       r_lower = TRIM( r_lower ) // ' uv(0)     = uv(1)                 |'
     ENDIF
     IF ( TRIM( bc_uv_t ) == 'dirichlet_0' )  THEN
-       roben  = TRIM( roben  ) // ' uv(nzt+1) = 0                     |'
+       r_upper  = TRIM( r_upper  ) // ' uv(nzt+1) = 0                     |'
     ELSEIF ( ibc_uv_t == 0 )  THEN
-       roben  = TRIM( roben  ) // ' uv(nzt+1) = ug(nzt+1), vg(nzt+1)  |'
+       r_upper  = TRIM( r_upper  ) // ' uv(nzt+1) = ug(nzt+1), vg(nzt+1)  |'
     ELSE
-       roben  = TRIM( roben  ) // ' uv(nzt+1) = uv(nzt)               |'
+       r_upper  = TRIM( r_upper  ) // ' uv(nzt+1) = uv(nzt)               |'
     ENDIF
 
     IF ( ibc_pt_b == 0 )  THEN
        IF ( land_surface )  THEN
-          runten = TRIM( runten ) // ' pt(0)     = from soil model'
-       ELSE
-          runten = TRIM( runten ) // ' pt(0)     = pt_surface'
+          r_lower = TRIM( r_lower ) // ' pt(0)     = from soil model'
+       ELSE
+          r_lower = TRIM( r_lower ) // ' pt(0)     = pt_surface'
        ENDIF
     ELSEIF ( ibc_pt_b == 1 )  THEN
-       runten = TRIM( runten ) // ' pt(0)     = pt(1)'
+       r_lower = TRIM( r_lower ) // ' pt(0)     = pt(1)'
     ELSEIF ( ibc_pt_b == 2 )  THEN
-       runten = TRIM( runten ) // ' pt(0)     = from coupled model'
+       r_lower = TRIM( r_lower ) // ' pt(0)     = from coupled model'
     ENDIF
     IF ( ibc_pt_t == 0 )  THEN
-       roben  = TRIM( roben  ) // ' pt(nzt+1) = pt_top'
+       r_upper  = TRIM( r_upper  ) // ' pt(nzt+1) = pt_top'
     ELSEIF( ibc_pt_t == 1 )  THEN
-       roben  = TRIM( roben  ) // ' pt(nzt+1) = pt(nzt)'
+       r_upper  = TRIM( r_upper  ) // ' pt(nzt+1) = pt(nzt)'
     ELSEIF( ibc_pt_t == 2 )  THEN
-       roben  = TRIM( roben  ) // ' pt(nzt+1) = pt(nzt) + dpt/dz_ini'
-
-    ENDIF
-
-    WRITE ( io, 300 )  runten, roben
+       r_upper  = TRIM( r_upper  ) // ' pt(nzt+1) = pt(nzt) + dpt/dz_ini'
+
+    ENDIF
+
+    WRITE ( io, 300 )  r_lower, r_upper
 
     IF ( .NOT. constant_diffusion )  THEN
        IF ( ibc_e_b == 1 )  THEN
-          runten = 'e(0)     = e(1)'
-       ELSE
-          runten = 'e(0)     = e(1) = (u*/0.1)**2'
-       ENDIF
-       roben = 'e(nzt+1) = e(nzt) = e(nzt-1)'
-
-       WRITE ( io, 301 )  'e', runten, roben       
+          r_lower = 'e(0)     = e(1)'
+       ELSE
+          r_lower = 'e(0)     = e(1) = (u*/0.1)**2'
+       ENDIF
+       r_upper = 'e(nzt+1) = e(nzt) = e(nzt-1)'
+
+       WRITE ( io, 301 )  'e', r_lower, r_upper       
 
     ENDIF
 
     IF ( ocean )  THEN
-       runten = 'sa(0)    = sa(1)'
+       r_lower = 'sa(0)    = sa(1)'
        IF ( ibc_sa_t == 0 )  THEN
-          roben =  'sa(nzt+1) = sa_surface'
-       ELSE
-          roben =  'sa(nzt+1) = sa(nzt)'
-       ENDIF
-       WRITE ( io, 301 ) 'sa', runten, roben
+          r_upper =  'sa(nzt+1) = sa_surface'
+       ELSE
+          r_upper =  'sa(nzt+1) = sa(nzt)'
+       ENDIF
+       WRITE ( io, 301 ) 'sa', r_lower, r_upper
     ENDIF
 
@@ -1073,32 +975,32 @@
        IF ( ibc_q_b == 0 )  THEN
           IF ( land_surface )  THEN
-             runten = 'q(0)     = from soil model'
+             r_lower = 'q(0)     = from soil model'
           ELSE
-             runten = 'q(0)     = q_surface'
-          ENDIF
-
-       ELSE
-          runten = 'q(0)     = q(1)'
+             r_lower = 'q(0)     = q_surface'
+          ENDIF
+
+       ELSE
+          r_lower = 'q(0)     = q(1)'
        ENDIF
        IF ( ibc_q_t == 0 )  THEN
-          roben =  'q(nzt)   = q_top'
-       ELSE
-          roben =  'q(nzt)   = q(nzt-1) + dq/dz'
-       ENDIF
-       WRITE ( io, 301 ) 'q', runten, roben
+          r_upper =  'q(nzt)   = q_top'
+       ELSE
+          r_upper =  'q(nzt)   = q(nzt-1) + dq/dz'
+       ENDIF
+       WRITE ( io, 301 ) 'q', r_lower, r_upper
     ENDIF
 
     IF ( passive_scalar )  THEN
        IF ( ibc_q_b == 0 )  THEN
-          runten = 's(0)     = s_surface'
-       ELSE
-          runten = 's(0)     = s(1)'
+          r_lower = 's(0)     = s_surface'
+       ELSE
+          r_lower = 's(0)     = s(1)'
        ENDIF
        IF ( ibc_q_t == 0 )  THEN
-          roben =  's(nzt)   = s_top'
-       ELSE
-          roben =  's(nzt)   = s(nzt-1) + ds/dz'
-       ENDIF
-       WRITE ( io, 301 ) 's', runten, roben
+          r_upper =  's(nzt)   = s_top'
+       ELSE
+          r_upper =  's(nzt)   = s(nzt-1) + ds/dz'
+       ENDIF
+       WRITE ( io, 301 ) 's', r_lower, r_upper
     ENDIF
 
@@ -1747,7 +1649,4 @@
 !
 !-- Geostrophic parameters
-    IF ( radiation .AND. radiation_scheme /= 'constant' )  THEN
-       WRITE ( io, 417 )  lambda
-    ENDIF
     WRITE ( io, 410 )  phi, omega, f, fs
 
@@ -1755,7 +1654,4 @@
 !-- Other quantities
     WRITE ( io, 411 )  g
-    IF ( radiation .AND. radiation_scheme /= 'constant' )  THEN
-       WRITE ( io, 418 )  day_init, time_utc_init
-    ENDIF
 
     WRITE ( io, 412 )  TRIM( reference_state )
@@ -2060,24 +1956,4 @@
 279 FORMAT (' Topography grid definition convention:'/ &
             ' cell center (scalar grid points)' /)
-280 FORMAT (//' Vegetation canopy (drag) model:'/ &
-              ' ------------------------------'// &
-              ' Canopy mode: ', A / &
-              ' Canopy height: ',F6.2,'m (',I4,' grid points)' / &
-              ' Leaf drag coefficient: ',F6.2 /)
-281 FORMAT (/ ' Scalar exchange coefficient: ',F6.2 / &
-              ' Scalar concentration at leaf surfaces in kg/m**3: ',F6.2 /)
-282 FORMAT (' Predefined constant heatflux at the top of the vegetation: ',F6.2,' K m/s')
-283 FORMAT (/ ' Characteristic levels of the leaf area density:'// &
-              ' Height:              ',A,'  m'/ &
-              ' Leaf area density:   ',A,'  m**2/m**3'/ &
-              ' Gradient:            ',A,'  m**2/m**4'/ &
-              ' Gridpoint:           ',A)
-284 FORMAT (//' Characteristic levels of the leaf area density and coefficients:'// &
-              ' Height:              ',A,'  m'/ &
-              ' Leaf area density:   ',A,'  m**2/m**3'/ &
-              ' Coefficient alpha: ',F6.2 / &
-              ' Coefficient beta: ',F6.2 / &
-              ' Leaf area index: ',F6.2,'  m**2/m**2' /)
-               
 300 FORMAT (//' Boundary conditions:'/ &
              ' -------------------'// &
@@ -2300,13 +2176,4 @@
                        '[0,1000] cm**2/s**3')
 437 FORMAT ('    Droplet collision is switched off')
-444 FORMAT (//' Radiation model information:'/                                 &
-              ' ----------------------------'/)
-445 FORMAT (' --> Using constant net radiation: net_radiation = ', F6.2, '  W/m**2')
-446 FORMAT (' --> Simple radiation scheme for clear sky is used (no clouds,',  &
-                   ' default)')
-447 FORMAT (' --> RRTMG scheme is used')
-448 FORMAT (/'     User-specific surface albedo: albedo =', F6.3)
-449 FORMAT  ('     Timestep: dt_radiation = ', F5.2, '  s')
-
 450 FORMAT (//' LES / Turbulence quantities:'/ &
               ' ---------------------------'/)
@@ -2316,8 +2183,4 @@
 454 FORMAT ('    TKE is not allowed to fall below ',E9.2,' (m/s)**2')
 455 FORMAT ('    initial TKE is prescribed as ',E9.2,' (m/s)**2')
-456 FORMAT (/'    Albedo is set for land surface type: ', A)
-457 FORMAT (/'    --> Albedo is fixed during the run')
-458 FORMAT (/'    --> Longwave radiation is disabled')
-459 FORMAT (/'    --> Shortwave radiation is disabled.')
 470 FORMAT (//' Actions during the simulation:'/ &
               ' -----------------------------'/)
Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 1825)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 1826)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! ------------------
-!
+! Renamed radiation calls.
+! Renamed canopy model calls.
 ! 
 ! Former revisions:
@@ -288,8 +289,8 @@
     
     USE plant_canopy_model_mod,                                                &
-        ONLY:  init_plant_canopy, plant_canopy
+        ONLY:  pcm_init, plant_canopy
 
     USE radiation_model_mod,                                                   &
-        ONLY:  init_radiation, radiation
+        ONLY:  radiation_init, radiation
     
     USE random_function_mod 
@@ -1631,5 +1632,7 @@
 !
 !-- If required, initialize quantities needed for the plant canopy model
-    IF ( plant_canopy )  CALL init_plant_canopy
+    CALL location_message( 'initializing plant canopy model', .FALSE. )
+    IF ( plant_canopy )  CALL pcm_init
+    CALL location_message( 'finished', .TRUE. )
 
 !
@@ -1676,5 +1679,5 @@
     IF ( radiation )  THEN
        CALL location_message( 'initializing radiation model', .FALSE. )
-       CALL init_radiation
+       CALL radiation_init
        CALL location_message( 'finished', .TRUE. )
     ENDIF
Index: palm/trunk/SOURCE/land_surface_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 1825)
+++ palm/trunk/SOURCE/land_surface_model_mod.f90	(revision 1826)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Cleanup after modularization
 ! 
 ! Former revisions:
@@ -532,19 +532,8 @@
     PUBLIC lsm_check_data_output, lsm_check_data_output_pr,                    &
            lsm_check_parameters, lsm_energy_balance, lsm_header, lsm_init,     &
-           lsm_init_arrays, lsm_parin, lsm_soil_model 
+           lsm_init_arrays, lsm_parin, lsm_soil_model, lsm_swap_timelevel 
 !
 !-- Public parameters, constants and initial values
-    PUBLIC alpha_vangenuchten, c_surface, canopy_resistance_coefficient,       &
-           conserve_water_content, field_capacity,                             &
-           f_shortwave_incoming, hydraulic_conductivity,                       &
-           lambda_surface_stable, lambda_surface_unstable,                     &
-           land_surface, leaf_area_index,                                      &
-           lsm_swap_timelevel, l_vangenuchten,                                 &
-           min_canopy_resistance, min_soil_resistance, n_vangenuchten,         &
-           pave_heat_capacity, pave_depth, pave_heat_conductivity,             &
-           residual_moisture, rho_cp, rho_lv, root_fraction,                   &
-           saturation_moisture, skip_time_do_lsm, soil_moisture,               &
-           soil_temperature, soil_type, soil_type_name, vegetation_coverage,   &
-           veg_type, veg_type_name, wilting_point, z0_eb, z0h_eb, z0q_eb
+    PUBLIC land_surface, skip_time_do_lsm
 
 !
@@ -644,7 +633,6 @@
              unit = 'K'   
              
-          CASE ( 'c_liq*', 'c_soil*', 'c_veg*', 'ghf_eb*',      &
-                 'm_liq_eb*', 'qsws_eb*',      &
-                 'qsws_liq_eb*', 'qsws_soil_eb*', 'qsws_veg_eb*', &
+          CASE ( 'lai*', 'c_liq*', 'c_soil*', 'c_veg*', 'ghf_eb*', 'm_liq_eb*',&
+                 'qsws_eb*', 'qsws_liq_eb*', 'qsws_soil_eb*', 'qsws_veg_eb*',  &
                  'r_a*', 'r_s*', 'shf_eb*' )
              IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
@@ -654,5 +642,9 @@
                 CALL message( 'check_parameters', 'PA0111', 1, 2, 0, 6, 0 )
              ENDIF
-
+             IF ( TRIM( var ) == 'lai*'  .AND.  .NOT.  land_surface )  THEN
+                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
+                                 'res land_surface = .TRUE.'
+                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
+             ENDIF
              IF ( TRIM( var ) == 'c_liq*'  .AND.  .NOT.  land_surface )  THEN
                 message_string = 'output of "' // TRIM( var ) // '" requi' //  &
@@ -716,4 +708,5 @@
              ENDIF
 
+             IF ( TRIM( var ) == 'lai*'   )  unit = 'none' 
              IF ( TRIM( var ) == 'c_liq*' )  unit = 'none'
              IF ( TRIM( var ) == 'c_soil*')  unit = 'none'
@@ -1564,8 +1557,9 @@
 1   FORMAT (//' Land surface model information:'/                              &
               ' ------------------------------'/)
-2   FORMAT (' --> Soil bottom is closed (water content is conserved, default)')
-3   FORMAT (' --> Soil bottom is open (water content is not conserved)')         
-4   FORMAT (' --> Land surface type  : ',A,/                                   &
-            ' --> Soil porosity type : ',A)
+2   FORMAT ('    --> Soil bottom is closed (water content is conserved',       &
+            ', default)')
+3   FORMAT ('    --> Soil bottom is open (water content is not conserved)')         
+4   FORMAT ('    --> Land surface type  : ',A,/                                &
+            '    --> Soil porosity type : ',A)
 5   FORMAT (/'    Initial soil temperature and moisture profile:'//            &
             '       Height:        ',A,'  m'/                                  &
@@ -1573,7 +1567,5 @@
             '       Moisture:      ',A,'  m**3/m**3'/                          &
             '       Root fraction: ',A,'  '/                                   &
-            '       Gridpoint:     ',A)
-
-
+            '       Grid point:    ',A)
 
     END SUBROUTINE lsm_header
@@ -1627,5 +1619,5 @@
 
        IF ( humidity )  THEN
-          qsws_eb = rho_l * l_v * qsws
+          qsws_eb = rho_lv * qsws
        ELSE
           qsws_eb = 0.0_wp
Index: palm/trunk/SOURCE/package_parin.f90
===================================================================
--- palm/trunk/SOURCE/package_parin.f90	(revision 1825)
+++ palm/trunk/SOURCE/package_parin.f90	(revision 1826)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! -----------------
-!
+! Reading of &radiation_par moved to radiation_model_mod.
+! Reading of &canopy_par moved to plant_canopy_model_mod.
 ! 
 ! Former revisions:
@@ -30,5 +31,5 @@
 !
 ! 1817 2016-04-06 15:44:20Z maronga
-! Reading of &lsmpar moved to land_surface_model_mod.
+! Reading of &lsm_par moved to land_surface_model_mod.
 ! 
 ! 1788 2016-03-10 11:01:04Z maronga
@@ -152,19 +153,4 @@
                vertical_particle_advection, write_particle_statistics
 
-    USE plant_canopy_model_mod,                                                &
-        ONLY:  alpha_lad, beta_lad, calc_beta_lad_profile, canopy_drag_coeff,  &
-               canopy_mode, cthf, lad_surface,                                 &
-               lad_vertical_gradient, lad_vertical_gradient_level, lai_beta,   &
-               leaf_scalar_exch_coeff, leaf_surface_conc, pch_index,           &
-               plant_canopy
-
-    USE radiation_model_mod,                                                   &
-        ONLY: albedo, albedo_type, albedo_lw_dif, albedo_lw_dir, albedo_sw_dif,&
-              albedo_sw_dir, constant_albedo, day_init, dt_radiation,          &
-              emissivity, lambda, lw_radiation, net_radiation, radiation,      &
-              radiation_scheme, skip_time_do_radiation, sw_radiation,          &
-              time_utc_init, unscheduled_radiation_calls
-                
-
     USE spectrum,                                                              &
         ONLY:  comp_spectra_level, data_output_sp, plot_spectra_level,         &
@@ -175,12 +161,5 @@
     CHARACTER (LEN=80) ::  line  !<
 
-    NAMELIST /canopy_par/         alpha_lad, beta_lad, canopy_drag_coeff,      &
-                                  canopy_mode, cthf,                           &
-                                  lad_surface,                                 & 
-                                  lad_vertical_gradient,                       &
-                                  lad_vertical_gradient_level,                 &
-                                  lai_beta,                                    &
-                                  leaf_scalar_exch_coeff,                      &
-                                  leaf_surface_conc, pch_index
+
 
     NAMELIST /dvrp_graphics_par/  clip_dvrp_l, clip_dvrp_n, clip_dvrp_r,       &
@@ -220,12 +199,4 @@
                                   write_particle_statistics
 
-    NAMELIST /radiation_par/      albedo, albedo_type, albedo_lw_dir,          &
-                                  albedo_lw_dif, albedo_sw_dir, albedo_sw_dif, &
-                                  constant_albedo, day_init, dt_radiation,     &
-                                  lambda, lw_radiation, net_radiation,         &
-                                  radiation_scheme, skip_time_do_radiation,    &
-                                  sw_radiation, time_utc_init,                 &
-                                  unscheduled_radiation_calls
-
     NAMELIST /spectra_par/        averaging_interval_sp, comp_spectra_level,   &
                                   data_output_sp, dt_dosp, plot_spectra_level, &
@@ -237,29 +208,4 @@
 !-- file at this line. Do the same for each optionally used package.
     line = ' '
-
-!
-!-- Try to find canopy package
-    REWIND ( 11 )
-    line = ' '
-    DO   WHILE ( INDEX( line, '&canopy_par' ) == 0 )
-       READ ( 11, '(A)', END=10 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, canopy_par )
-
-!
-!-- Set flag that indicates that canopy model is switched on
-    plant_canopy = .TRUE.
-
-!
-!-- Set flag that indicates that the lad-profile shall be calculated by using
-!-- a beta probability density function
-    IF ( alpha_lad /= 9999999.9_wp  .AND.  beta_lad /= 9999999.9_wp )          &
-       calc_beta_lad_profile = .TRUE.
-
- 10 CONTINUE
 
 
@@ -317,22 +263,4 @@
 
 
-!
-!-- Try to find radiation package
-    REWIND ( 11 )
-    line = ' '
-    DO   WHILE ( INDEX( line, '&radiation_par' ) == 0 )
-       READ ( 11, '(A)', END=51 )  line
-    ENDDO
-    BACKSPACE ( 11 )
-
-!
-!-- Read user-defined namelist
-    READ ( 11, radiation_par )
-
-!
-!-- Set flag that indicates that the radiation scheme is switched on
-    radiation = .TRUE.
-
- 51 CONTINUE
 
 
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 1825)
+++ palm/trunk/SOURCE/parin.f90	(revision 1826)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Added call to radiation model for reading of &radiation_par.
+! Added call to plant canopy model for reading of &canopy_par.
 ! 
 ! Former revisions:
@@ -26,5 +27,5 @@
 !
 ! 1817 2016-04-06 15:44:20Z maronga
-! Added call to land surface model for reading of &lsmpar
+! Added call to land surface model for reading of &lsm_par
 ! 
 ! 1804 2016-04-05 16:30:18Z maronga
@@ -191,4 +192,7 @@
                vg
 
+    USE plant_canopy_model_mod,                                                &
+         ONLY: pcm_parin  
+ 
     USE cloud_parameters,                                                      &
         ONLY:  c_sedimentation, curvature_solution_effects,                    &
@@ -232,4 +236,7 @@
         ONLY :  batch_job
 
+     USE radiation_model_mod,                                                  &
+         ONLY: radiation_parin  
+        
     USE statistics,                                                            &
         ONLY:  hom, hom_sum, pr_palm, region, statistic_regions
@@ -458,8 +465,15 @@
           
 !
-!--       Check if land surface model is used and read &lsmpar if required
+!--       Check if land surface model is used and read &lsm_par if required
           CALL lsm_parin
-          
-          
+ 
+!
+!--       Check if radiation model is used and read &radiation_par if required
+          CALL radiation_parin
+ 
+ 
+!--       Check if plant canopy model is used and read &canopy_par if required
+          CALL pcm_parin
+ 
 !
 !--       Read control parameters for optionally used model software packages
Index: palm/trunk/SOURCE/plant_canopy_model.f90
===================================================================
--- palm/trunk/SOURCE/plant_canopy_model.f90	(revision 1825)
+++ 	(revision )
@@ -1,952 +1,0 @@
-!> @file plant_canopy_model.f90
-!--------------------------------------------------------------------------------!
-! This file is part of PALM.
-!
-! PALM is free software: you can redistribute it and/or modify it under the terms
-! of the GNU General Public License as published by the Free Software Foundation,
-! either version 3 of the License, or (at your option) any later version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2016 Leibniz Universitaet Hannover
-!--------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-!
-! Former revisions:
-! -----------------
-! $Id$
-!
-! 1721 2015-11-16 12:56:48Z raasch
-! bugfixes: shf is reduced in areas covered with canopy only,
-!           canopy is set on top of topography
-!
-! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable 
-! 
-! 1484 2014-10-21 10:53:05Z kanani
-! Changes due to new module structure of the plant canopy model:
-!   module plant_canopy_model_mod now contains a subroutine for the 
-!   initialization of the canopy model (init_plant_canopy),
-!   limitation of the canopy drag (previously accounted for by calculation of 
-!   a limiting canopy timestep for the determination of the maximum LES timestep
-!   in subroutine timestep) is now realized by the calculation of pre-tendencies
-!   and preliminary velocities in subroutine plant_canopy_model,
-!   some redundant MPI communication removed in subroutine init_plant_canopy
-!   (was previously in init_3d_model),
-!   unnecessary 3d-arrays lad_u, lad_v, lad_w removed - lad information on the
-!   respective grid is now provided only by lad_s (e.g. in the calculation of 
-!   the tendency terms or of cum_lai_hf),
-!   drag_coefficient, lai, leaf_surface_concentration, 
-!   scalar_exchange_coefficient, sec and sls renamed to canopy_drag_coeff, 
-!   cum_lai_hf, leaf_surface_conc, leaf_scalar_exch_coeff, lsec and lsc,
-!   respectively,
-!   unnecessary 3d-arrays cdc, lsc and lsec now defined as single-value constants,
-!   USE-statements and ONLY-lists modified accordingly
-! 
-! 1340 2014-03-25 19:45:13Z kanani
-! REAL constants defined as wp-kind
-!
-! 1320 2014-03-20 08:40:49Z raasch
-! ONLY-attribute added to USE-statements,
-! kind-parameters added to all INTEGER and REAL declaration statements,
-! kinds are defined in new module kinds,
-! old module precision_kind is removed,
-! revision history before 2012 removed,
-! comment fields (!:) to be used for variable explanations added to
-! all variable declaration statements
-!
-! 1036 2012-10-22 13:43:42Z raasch
-! code put under GPL (PALM 3.9)
-!
-! 138 2007-11-28 10:03:58Z letzel
-! Initial revision
-!
-! Description:
-! ------------
-!> 1) Initialization of the canopy model, e.g. construction of leaf area density 
-!> profile (subroutine init_plant_canopy).
-!> 2) Calculation of sinks and sources of momentum, heat and scalar concentration 
-!> due to canopy elements (subroutine plant_canopy_model).
-!------------------------------------------------------------------------------!
- MODULE plant_canopy_model_mod
- 
-    USE arrays_3d,                                                             &
-        ONLY:  dzu, dzw, e, q, shf, tend, u, v, w, zu, zw 
-
-    USE indices,                                                               &
-        ONLY:  nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
-               nz, nzb, nzb_s_inner, nzb_u_inner, nzb_v_inner, nzb_w_inner, nzt
-
-    USE kinds
-
-
-    IMPLICIT NONE
-
-
-    CHARACTER (LEN=20)   ::  canopy_mode = 'block' !< canopy coverage
-
-    INTEGER(iwp) ::  pch_index = 0                 !< plant canopy height/top index
-    INTEGER(iwp) ::                                                            &
-       lad_vertical_gradient_level_ind(10) = -9999 !< lad-profile levels (index)
-
-    LOGICAL ::  calc_beta_lad_profile = .FALSE. !< switch for calc. of lad from beta func.
-    LOGICAL ::  plant_canopy = .FALSE.          !< switch for use of canopy model
-
-    REAL(wp) ::  alpha_lad = 9999999.9_wp   !< coefficient for lad calculation
-    REAL(wp) ::  beta_lad = 9999999.9_wp    !< coefficient for lad calculation
-    REAL(wp) ::  canopy_drag_coeff = 0.0_wp !< canopy drag coefficient (parameter)
-    REAL(wp) ::  cdc = 0.0_wp               !< canopy drag coeff. (abbreviation used in equations)
-    REAL(wp) ::  cthf = 0.0_wp              !< canopy top heat flux
-    REAL(wp) ::  dt_plant_canopy = 0.0_wp   !< timestep account. for canopy drag
-    REAL(wp) ::  lad_surface = 0.0_wp       !< lad surface value
-    REAL(wp) ::  lai_beta = 0.0_wp          !< leaf area index (lai) for lad calc.
-    REAL(wp) ::                                                                &
-       leaf_scalar_exch_coeff = 0.0_wp      !< canopy scalar exchange coeff.
-    REAL(wp) ::                                                                &
-       leaf_surface_conc = 0.0_wp           !< leaf surface concentration
-    REAL(wp) ::  lsec = 0.0_wp              !< leaf scalar exchange coeff.
-    REAL(wp) ::  lsc = 0.0_wp               !< leaf surface concentration
-
-    REAL(wp) ::                                                                &
-       lad_vertical_gradient(10) = 0.0_wp              !< lad gradient
-    REAL(wp) ::                                                                &
-       lad_vertical_gradient_level(10) = -9999999.9_wp !< lad-prof. levels (in m)
-
-    REAL(wp), DIMENSION(:), ALLOCATABLE ::  lad            !< leaf area density
-    REAL(wp), DIMENSION(:), ALLOCATABLE ::  pre_lad        !< preliminary lad
-    
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::                                 &
-       canopy_heat_flux                                    !< canopy heat flux
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  cum_lai_hf !< cumulative lai for heatflux calc.
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  lad_s      !< lad on scalar-grid
-
-
-    SAVE
-
-
-    PRIVATE
-    PUBLIC alpha_lad, beta_lad, calc_beta_lad_profile, canopy_drag_coeff,      &
-           canopy_mode, cdc, cthf, dt_plant_canopy, init_plant_canopy, lad,    &
-           lad_s, lad_surface, lad_vertical_gradient,                          &
-           lad_vertical_gradient_level, lad_vertical_gradient_level_ind,       &
-           lai_beta, leaf_scalar_exch_coeff, leaf_surface_conc, lsc, lsec,     &
-           pch_index, plant_canopy, plant_canopy_model
-
-
-    INTERFACE init_plant_canopy
-       MODULE PROCEDURE init_plant_canopy
-    END INTERFACE init_plant_canopy
-
-    INTERFACE plant_canopy_model
-       MODULE PROCEDURE plant_canopy_model
-       MODULE PROCEDURE plant_canopy_model_ij
-    END INTERFACE plant_canopy_model
-
-
-
-
- CONTAINS
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Initialization of the plant canopy model
-!------------------------------------------------------------------------------!
-    SUBROUTINE init_plant_canopy
-    
-
-       USE control_parameters,                                                 &
-           ONLY: dz, ocean, passive_scalar
-
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) ::  i !< running index
-       INTEGER(iwp) ::  j !< running index
-       INTEGER(iwp) ::  k !< running index
-
-       REAL(wp) ::  int_bpdf      !< vertical integral for lad-profile construction
-       REAL(wp) ::  dzh           !< vertical grid spacing in units of canopy height
-       REAL(wp) ::  gradient      !< gradient for lad-profile construction
-       REAL(wp) ::  canopy_height !< canopy height for lad-profile construction
-
-!
-!--    Allocate one-dimensional arrays for the computation of the 
-!--    leaf area density (lad) profile
-       ALLOCATE( lad(0:nz+1), pre_lad(0:nz+1) )
-       lad = 0.0_wp
-       pre_lad = 0.0_wp
-
-!
-!--    Compute the profile of leaf area density used in the plant
-!--    canopy model. The profile can either be constructed from
-!--    prescribed vertical gradients of the leaf area density or by
-!--    using a beta probability density function (see e.g. Markkanen et al., 
-!--    2003: Boundary-Layer Meteorology, 106, 437-459) 
-       IF (  .NOT.  calc_beta_lad_profile )  THEN   
-
-!
-!--       Use vertical gradients for lad-profile construction    
-          i = 1
-          gradient = 0.0_wp
-
-          IF (  .NOT.  ocean )  THEN
-
-             lad(0) = lad_surface
-             lad_vertical_gradient_level_ind(1) = 0
- 
-             DO k = 1, pch_index
-                IF ( i < 11 )  THEN
-                   IF ( lad_vertical_gradient_level(i) < zu(k)  .AND.          &
-                        lad_vertical_gradient_level(i) >= 0.0_wp )  THEN
-                      gradient = lad_vertical_gradient(i)
-                      lad_vertical_gradient_level_ind(i) = k - 1
-                      i = i + 1
-                   ENDIF
-                ENDIF
-                IF ( gradient /= 0.0_wp )  THEN
-                   IF ( k /= 1 )  THEN
-                      lad(k) = lad(k-1) + dzu(k) * gradient
-                   ELSE
-                      lad(k) = lad_surface + dzu(k) * gradient
-                   ENDIF
-                ELSE
-                   lad(k) = lad(k-1)
-                ENDIF
-             ENDDO
-
-          ENDIF
-
-!
-!--       In case of no given leaf area density gradients, choose a vanishing
-!--       gradient. This information is used for the HEADER and the RUN_CONTROL
-!--       file.
-          IF ( lad_vertical_gradient_level(1) == -9999999.9_wp )  THEN
-             lad_vertical_gradient_level(1) = 0.0_wp
-          ENDIF
-
-       ELSE
-
-! 
-!--       Use beta function for lad-profile construction
-          int_bpdf = 0.0_wp
-          canopy_height = pch_index * dz
-
-          DO k = nzb, pch_index
-             int_bpdf = int_bpdf +                                             &
-                           ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) * &
-                           ( ( 1.0_wp - ( zw(k) / canopy_height ) )**( beta_lad-1.0_wp ) ) *   &
-                           ( ( zw(k+1)-zw(k) ) / canopy_height ) )
-          ENDDO
-
-!
-!--       Preliminary lad profile (defined on w-grid)
-          DO k = nzb, pch_index
-             pre_lad(k) =  lai_beta *                                              &
-                           (   ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) *          &
-                               ( ( 1.0_wp - ( zw(k) / canopy_height ) )**( beta_lad-1.0_wp ) ) /   &
-                               int_bpdf                                            &
-                           ) / canopy_height
-          ENDDO
-
-!
-!--       Final lad profile (defined on scalar-grid level, since most prognostic
-!--       quantities are defined there, hence, less interpolation is required 
-!--       when calculating the canopy tendencies)
-          lad(0) = pre_lad(0)
-          DO k = nzb+1, pch_index
-             lad(k) = 0.5 * ( pre_lad(k-1) + pre_lad(k) )
-          ENDDO          
-
-       ENDIF
-
-!
-!--    Allocate 3D-array for the leaf area density (lad_s). In case of a 
-!--    prescribed canopy-top heat flux (cthf), allocate 3D-arrays for
-!--    the cumulative leaf area index (cum_lai_hf) and the canopy heat flux.
-       ALLOCATE( lad_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-
-       IF ( cthf /= 0.0_wp )  THEN
-          ALLOCATE( cum_lai_hf(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                 &
-                    canopy_heat_flux(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-       ENDIF
-
-!
-!--    Initialize canopy parameters cdc (canopy drag coefficient), 
-!--    lsec (leaf scalar exchange coefficient), lsc (leaf surface concentration)
-!--    with the prescribed values
-       cdc = canopy_drag_coeff
-       lsec = leaf_scalar_exch_coeff
-       lsc = leaf_surface_conc
-
-!
-!--    Initialization of the canopy coverage in the model domain:
-!--    Setting the parameter canopy_mode = 'block' initializes a canopy, which
-!--    fully covers the domain surface
-       SELECT CASE ( TRIM( canopy_mode ) )
-
-          CASE( 'block' )
-
-             DO  i = nxlg, nxrg
-                DO  j = nysg, nyng
-                   lad_s(:,j,i) = lad(:)
-                ENDDO
-             ENDDO
-
-          CASE DEFAULT
-
-!
-!--       The DEFAULT case is reached either if the parameter 
-!--       canopy mode contains a wrong character string or if the 
-!--       user has coded a special case in the user interface. 
-!--       There, the subroutine user_init_plant_canopy checks 
-!--       which of these two conditions applies.
-          CALL user_init_plant_canopy
- 
-       END SELECT
-
-!
-!--    Initialization of the canopy heat source distribution
-       IF ( cthf /= 0.0_wp )  THEN
-!
-!--       Piecewise calculation of the leaf area index by vertical
-!--       integration of the leaf area density
-          cum_lai_hf(:,:,:) = 0.0_wp
-          DO  i = nxlg, nxrg
-             DO  j = nysg, nyng
-                DO  k = pch_index-1, 0, -1
-                   IF ( k == pch_index-1 )  THEN
-                      cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) +                &
-                         ( 0.5_wp * lad_s(k+1,j,i) *                           &
-                           ( zw(k+1) - zu(k+1) ) )  +                          &
-                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) +              &
-                                                 lad_s(k,j,i) ) +              &
-                                      lad_s(k+1,j,i) ) *                       &
-                           ( zu(k+1) - zw(k) ) ) 
-                   ELSE
-                      cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) +                &
-                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+2,j,i) +              &
-                                                 lad_s(k+1,j,i) ) +            &
-                                      lad_s(k+1,j,i) ) *                       &
-                           ( zw(k+1) - zu(k+1) ) )  +                          &
-                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) +              &
-                                                 lad_s(k,j,i) ) +              &
-                                      lad_s(k+1,j,i) ) *                       &
-                           ( zu(k+1) - zw(k) ) )
-                   ENDIF
-                ENDDO
-             ENDDO
-          ENDDO
-
-!
-!--       Calculation of the upward kinematic vertical heat flux within the 
-!--       canopy
-          DO  i = nxlg, nxrg
-             DO  j = nysg, nyng
-                DO  k = 0, pch_index
-                   canopy_heat_flux(k,j,i) = cthf *                            &
-                                             exp( -0.6_wp * cum_lai_hf(k,j,i) )
-                ENDDO
-             ENDDO
-          ENDDO
-
-!
-!--       In areas covered with canopy, the surface heat flux is set to
-!--       the surface value of the above calculated in-canopy heat flux
-!--       distribution
-          DO  i = nxlg,nxrg
-             DO  j = nysg, nyng
-                IF ( canopy_heat_flux(0,j,i) /= cthf )  THEN
-                   shf(j,i) = canopy_heat_flux(0,j,i)
-                ENDIF
-             ENDDO
-          ENDDO
-
-       ENDIF
-
-
-
-    END SUBROUTINE init_plant_canopy
-
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Calculation of the tendency terms, accounting for the effect of the plant
-!> canopy on momentum and scalar quantities.
-!>
-!> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 
-!> (defined on scalar grid), as initialized in subroutine init_plant_canopy. 
-!> The lad on the w-grid is vertically interpolated from the surrounding
-!> lad_s. The upper boundary of the canopy is defined on the w-grid at 
-!> k = pch_index. Here, the lad is zero.
-!>
-!> The canopy drag must be limited (previously accounted for by calculation of 
-!> a limiting canopy timestep for the determination of the maximum LES timestep
-!> in subroutine timestep), since it is physically impossible that the canopy
-!> drag alone can locally change the sign of a velocity component. This 
-!> limitation is realized by calculating preliminary tendencies and velocities.
-!> It is subsequently checked if the preliminary new velocity has a different
-!> sign than the current velocity. If so, the tendency is limited in a way that
-!> the velocity can at maximum be reduced to zero by the canopy drag. 
-!>
-!>
-!> Call for all grid points
-!------------------------------------------------------------------------------!
-    SUBROUTINE plant_canopy_model( component )
-
-
-       USE control_parameters,                                                 &
-           ONLY:  dt_3d, message_string
-
-       USE kinds
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
-       INTEGER(iwp) ::  i         !< running index
-       INTEGER(iwp) ::  j         !< running index
-       INTEGER(iwp) ::  k         !< running index
-       INTEGER(iwp) ::  kk        !< running index for flat lad arrays
-
-       REAL(wp) ::  ddt_3d    !< inverse of the LES timestep (dt_3d)
-       REAL(wp) ::  lad_local !< local lad value
-       REAL(wp) ::  pre_tend  !< preliminary tendency
-       REAL(wp) ::  pre_u     !< preliminary u-value 
-       REAL(wp) ::  pre_v     !< preliminary v-value 
-       REAL(wp) ::  pre_w     !< preliminary w-value 
-
-
-       ddt_3d = 1.0_wp / dt_3d
- 
-!
-!--    Compute drag for the three velocity components and the SGS-TKE:
-       SELECT CASE ( component )
-
-!
-!--       u-component
-          CASE ( 1 )
-             DO  i = nxlu, nxr
-                DO  j = nys, nyn
-                   DO  k = nzb_u_inner(j,i)+1, nzb_u_inner(j,i)+pch_index
-
-                      kk = k - nzb_u_inner(j,i)  !- lad arrays are defined flat
-!
-!--                   In order to create sharp boundaries of the plant canopy, 
-!--                   the lad on the u-grid at index (k,j,i) is equal to 
-!--                   lad_s(k,j,i), rather than being interpolated from the 
-!--                   surrounding lad_s, because this would yield smaller lad 
-!--                   at the canopy boundaries than inside of the canopy.
-!--                   For the same reason, the lad at the rightmost(i+1)canopy 
-!--                   boundary on the u-grid equals lad_s(k,j,i).
-                      lad_local = lad_s(kk,j,i)
-                      IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp )&
-                      THEN
-                         lad_local = lad_s(kk,j,i-1)
-                      ENDIF
-
-                      pre_tend = 0.0_wp
-                      pre_u = 0.0_wp
-!
-!--                   Calculate preliminary value (pre_tend) of the tendency
-                      pre_tend = - cdc *                                       &
-                                   lad_local *                                 &
-                                   SQRT( u(k,j,i)**2 +                         &
-                                         ( 0.25_wp * ( v(k,j,i-1) +            &
-                                                       v(k,j,i)   +            &
-                                                       v(k,j+1,i) +            &
-                                                       v(k,j+1,i-1) )          &
-                                         )**2 +                                &
-                                         ( 0.25_wp * ( w(k-1,j,i-1) +          &
-                                                       w(k-1,j,i)   +          &
-                                                       w(k,j,i-1)   +          &
-                                                       w(k,j,i) )              &
-                                         )**2                                  &
-                                       ) *                                     &
-                                   u(k,j,i)
-
-!
-!--                   Calculate preliminary new velocity, based on pre_tend
-                      pre_u = u(k,j,i) + dt_3d * pre_tend
-!
-!--                   Compare sign of old velocity and new preliminary velocity,
-!--                   and in case the signs are different, limit the tendency
-                      IF ( SIGN(pre_u,u(k,j,i)) /= pre_u )  THEN
-                         pre_tend = - u(k,j,i) * ddt_3d
-                      ELSE
-                         pre_tend = pre_tend
-                      ENDIF
-!
-!--                   Calculate final tendency
-                      tend(k,j,i) = tend(k,j,i) + pre_tend
-
-                   ENDDO
-                ENDDO
-             ENDDO
-
-!
-!--       v-component
-          CASE ( 2 )
-             DO  i = nxl, nxr
-                DO  j = nysv, nyn
-                   DO  k = nzb_v_inner(j,i)+1, nzb_v_inner(j,i)+pch_index
-
-                      kk = k - nzb_v_inner(j,i)  !- lad arrays are defined flat
-!
-!--                   In order to create sharp boundaries of the plant canopy, 
-!--                   the lad on the v-grid at index (k,j,i) is equal to 
-!--                   lad_s(k,j,i), rather than being interpolated from the 
-!--                   surrounding lad_s, because this would yield smaller lad 
-!--                   at the canopy boundaries than inside of the canopy.
-!--                   For the same reason, the lad at the northmost(j+1) canopy 
-!--                   boundary on the v-grid equals lad_s(k,j,i).
-                      lad_local = lad_s(kk,j,i)
-                      IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp )&
-                      THEN
-                         lad_local = lad_s(kk,j-1,i)
-                      ENDIF
-
-                      pre_tend = 0.0_wp
-                      pre_v = 0.0_wp
-!
-!--                   Calculate preliminary value (pre_tend) of the tendency
-                      pre_tend = - cdc *                                       &
-                                   lad_local *                                 &
-                                   SQRT( ( 0.25_wp * ( u(k,j-1,i)   +          &
-                                                       u(k,j-1,i+1) +          &
-                                                       u(k,j,i)     +          &
-                                                       u(k,j,i+1) )            &
-                                         )**2 +                                &
-                                         v(k,j,i)**2 +                         &
-                                         ( 0.25_wp * ( w(k-1,j-1,i) +          &
-                                                       w(k-1,j,i)   +          &
-                                                       w(k,j-1,i)   +          &
-                                                       w(k,j,i) )              &
-                                         )**2                                  &
-                                       ) *                                     &
-                                   v(k,j,i)
-
-!
-!--                   Calculate preliminary new velocity, based on pre_tend
-                      pre_v = v(k,j,i) + dt_3d * pre_tend
-!
-!--                   Compare sign of old velocity and new preliminary velocity,
-!--                   and in case the signs are different, limit the tendency
-                      IF ( SIGN(pre_v,v(k,j,i)) /= pre_v )  THEN
-                         pre_tend = - v(k,j,i) * ddt_3d
-                      ELSE
-                         pre_tend = pre_tend
-                      ENDIF
-!
-!--                   Calculate final tendency
-                      tend(k,j,i) = tend(k,j,i) + pre_tend
-
-                   ENDDO
-                ENDDO
-             ENDDO
-
-!
-!--       w-component
-          CASE ( 3 )
-             DO  i = nxl, nxr
-                DO  j = nys, nyn
-                   DO  k = nzb_w_inner(j,i)+1, nzb_w_inner(j,i)+pch_index-1
-
-                      kk = k - nzb_w_inner(j,i)  !- lad arrays are defined flat
-
-                      pre_tend = 0.0_wp
-                      pre_w = 0.0_wp
-!
-!--                   Calculate preliminary value (pre_tend) of the tendency
-                      pre_tend = - cdc *                                       &
-                                   (0.5_wp *                                   &
-                                      ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *   &
-                                   SQRT( ( 0.25_wp * ( u(k,j,i)   +            &
-                                                       u(k,j,i+1) +            &
-                                                       u(k+1,j,i) +            &
-                                                       u(k+1,j,i+1) )          &
-                                         )**2 +                                &
-                                         ( 0.25_wp * ( v(k,j,i)   +            &
-                                                       v(k,j+1,i) +            &
-                                                       v(k+1,j,i) +            &
-                                                       v(k+1,j+1,i) )          &
-                                         )**2 +                                &
-                                         w(k,j,i)**2                           &
-                                       ) *                                     &
-                                   w(k,j,i)
-!
-!--                   Calculate preliminary new velocity, based on pre_tend
-                      pre_w = w(k,j,i) + dt_3d * pre_tend
-!
-!--                   Compare sign of old velocity and new preliminary velocity,
-!--                   and in case the signs are different, limit the tendency
-                      IF ( SIGN(pre_w,w(k,j,i)) /= pre_w )  THEN
-                         pre_tend = - w(k,j,i) * ddt_3d
-                      ELSE
-                         pre_tend = pre_tend
-                      ENDIF
-!
-!--                   Calculate final tendency
-                      tend(k,j,i) = tend(k,j,i) + pre_tend
-
-                   ENDDO
-                ENDDO
-             ENDDO
-
-!
-!--       potential temperature
-          CASE ( 4 )
-             DO  i = nxl, nxr
-                DO  j = nys, nyn
-                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
-                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
-                      tend(k,j,i) = tend(k,j,i) +                              &
-                                       ( canopy_heat_flux(kk,j,i) -            &
-                                         canopy_heat_flux(kk-1,j,i) ) / dzw(k)
-                   ENDDO
-                ENDDO
-             ENDDO
-
-!
-!--       scalar concentration
-          CASE ( 5 )
-             DO  i = nxl, nxr
-                DO  j = nys, nyn
-                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
-                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
-                      tend(k,j,i) = tend(k,j,i) -                              &
-                                       lsec *                                  &
-                                       lad_s(kk,j,i) *                         &
-                                       SQRT( ( 0.5_wp * ( u(k,j,i) +           &
-                                                          u(k,j,i+1) )         &
-                                             )**2 +                            &
-                                             ( 0.5_wp * ( v(k,j,i) +           &
-                                                          v(k,j+1,i) )         &
-                                             )**2 +                            &
-                                             ( 0.5_wp * ( w(k-1,j,i) +         & 
-                                                          w(k,j,i) )           &
-                                             )**2                              &
-                                           ) *                                 &
-                                       ( q(k,j,i) - lsc )
-                   ENDDO
-                ENDDO
-             ENDDO
-
-!
-!--       sgs-tke
-          CASE ( 6 )
-             DO  i = nxl, nxr
-                DO  j = nys, nyn
-                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
-                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
-                      tend(k,j,i) = tend(k,j,i) -                              &
-                                       2.0_wp * cdc *                          &
-                                       lad_s(kk,j,i) *                         &
-                                       SQRT( ( 0.5_wp * ( u(k,j,i) +           &
-                                                          u(k,j,i+1) )         &
-                                             )**2 +                            &
-                                             ( 0.5_wp * ( v(k,j,i) +           &
-                                                          v(k,j+1,i) )         &
-                                             )**2 +                            &
-                                             ( 0.5_wp * ( w(k,j,i) +           &
-                                                          w(k+1,j,i) )         &
-                                             )**2                              &
-                                           ) *                                 &
-                                       e(k,j,i)
-                   ENDDO
-                ENDDO
-             ENDDO 
-
-
-          CASE DEFAULT
-
-             WRITE( message_string, * ) 'wrong component: ', component
-             CALL message( 'plant_canopy_model', 'PA0279', 1, 2, 0, 6, 0 ) 
-
-       END SELECT
-
-    END SUBROUTINE plant_canopy_model
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Calculation of the tendency terms, accounting for the effect of the plant
-!> canopy on momentum and scalar quantities.
-!>
-!> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 
-!> (defined on scalar grid), as initialized in subroutine init_plant_canopy. 
-!> The lad on the w-grid is vertically interpolated from the surrounding
-!> lad_s. The upper boundary of the canopy is defined on the w-grid at 
-!> k = pch_index. Here, the lad is zero.
-!>
-!> The canopy drag must be limited (previously accounted for by calculation of 
-!> a limiting canopy timestep for the determination of the maximum LES timestep
-!> in subroutine timestep), since it is physically impossible that the canopy
-!> drag alone can locally change the sign of a velocity component. This 
-!> limitation is realized by calculating preliminary tendencies and velocities.
-!> It is subsequently checked if the preliminary new velocity has a different
-!> sign than the current velocity. If so, the tendency is limited in a way that
-!> the velocity can at maximum be reduced to zero by the canopy drag. 
-!>
-!>
-!> Call for grid point i,j
-!------------------------------------------------------------------------------!
-    SUBROUTINE plant_canopy_model_ij( i, j, component )
-
-
-       USE control_parameters,                                                 &
-           ONLY:  dt_3d, message_string
-
-       USE kinds
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
-       INTEGER(iwp) ::  i         !< running index
-       INTEGER(iwp) ::  j         !< running index
-       INTEGER(iwp) ::  k         !< running index
-       INTEGER(iwp) ::  kk        !< running index for flat lad arrays
-
-       REAL(wp) ::  ddt_3d    !< inverse of the LES timestep (dt_3d)
-       REAL(wp) ::  lad_local !< local lad value
-       REAL(wp) ::  pre_tend  !< preliminary tendency
-       REAL(wp) ::  pre_u     !< preliminary u-value 
-       REAL(wp) ::  pre_v     !< preliminary v-value 
-       REAL(wp) ::  pre_w     !< preliminary w-value 
-
-
-       ddt_3d = 1.0_wp / dt_3d
-
-!
-!--    Compute drag for the three velocity components and the SGS-TKE
-       SELECT CASE ( component )
-
-!
-!--       u-component
-          CASE ( 1 )
-             DO  k = nzb_u_inner(j,i)+1, nzb_u_inner(j,i)+pch_index
-
-                kk = k - nzb_u_inner(j,i)  !- lad arrays are defined flat
-!
-!--             In order to create sharp boundaries of the plant canopy, 
-!--             the lad on the u-grid at index (k,j,i) is equal to lad_s(k,j,i),
-!--             rather than being interpolated from the surrounding lad_s, 
-!--             because this would yield smaller lad at the canopy boundaries 
-!--             than inside of the canopy.
-!--             For the same reason, the lad at the rightmost(i+1)canopy 
-!--             boundary on the u-grid equals lad_s(k,j,i).
-                lad_local = lad_s(kk,j,i)
-                IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp )  THEN
-                   lad_local = lad_s(kk,j,i-1)
-                ENDIF
-
-                pre_tend = 0.0_wp
-                pre_u = 0.0_wp
-!
-!--             Calculate preliminary value (pre_tend) of the tendency
-                pre_tend = - cdc *                                             &
-                             lad_local *                                       &   
-                             SQRT( u(k,j,i)**2 +                               &
-                                   ( 0.25_wp * ( v(k,j,i-1)  +                 &
-                                                 v(k,j,i)    +                 &
-                                                 v(k,j+1,i)  +                 &
-                                                 v(k,j+1,i-1) )                &
-                                   )**2 +                                      &
-                                   ( 0.25_wp * ( w(k-1,j,i-1) +                &
-                                                 w(k-1,j,i)   +                &
-                                                 w(k,j,i-1)   +                &
-                                                 w(k,j,i) )                    &
-                                   )**2                                        &
-                                 ) *                                           &
-                             u(k,j,i)
-
-!
-!--             Calculate preliminary new velocity, based on pre_tend
-                pre_u = u(k,j,i) + dt_3d * pre_tend
-!
-!--             Compare sign of old velocity and new preliminary velocity,
-!--             and in case the signs are different, limit the tendency
-                IF ( SIGN(pre_u,u(k,j,i)) /= pre_u )  THEN
-                   pre_tend = - u(k,j,i) * ddt_3d
-                ELSE
-                   pre_tend = pre_tend
-                ENDIF
-!
-!--             Calculate final tendency
-                tend(k,j,i) = tend(k,j,i) + pre_tend
-             ENDDO
-
-
-!
-!--       v-component
-          CASE ( 2 )
-             DO  k = nzb_v_inner(j,i)+1, nzb_v_inner(j,i)+pch_index
-
-                kk = k - nzb_v_inner(j,i)  !- lad arrays are defined flat
-!
-!--             In order to create sharp boundaries of the plant canopy, 
-!--             the lad on the v-grid at index (k,j,i) is equal to lad_s(k,j,i),
-!--             rather than being interpolated from the surrounding lad_s, 
-!--             because this would yield smaller lad at the canopy boundaries 
-!--             than inside of the canopy.
-!--             For the same reason, the lad at the northmost(j+1)canopy 
-!--             boundary on the v-grid equals lad_s(k,j,i).
-                lad_local = lad_s(kk,j,i)
-                IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp )  THEN
-                   lad_local = lad_s(kk,j-1,i)
-                ENDIF
-
-                pre_tend = 0.0_wp
-                pre_v = 0.0_wp
-!
-!--             Calculate preliminary value (pre_tend) of the tendency
-                pre_tend = - cdc *                                             &
-                             lad_local *                                       &
-                             SQRT( ( 0.25_wp * ( u(k,j-1,i)   +                &
-                                                 u(k,j-1,i+1) +                &
-                                                 u(k,j,i)     +                &
-                                                 u(k,j,i+1) )                  &
-                                   )**2 +                                      &
-                                   v(k,j,i)**2 +                               &
-                                   ( 0.25_wp * ( w(k-1,j-1,i) +                &
-                                                 w(k-1,j,i)   +                &
-                                                 w(k,j-1,i)   +                &
-                                                 w(k,j,i) )                    &
-                                   )**2                                        &
-                                 ) *                                           &
-                             v(k,j,i)
-
-!
-!--             Calculate preliminary new velocity, based on pre_tend
-                pre_v = v(k,j,i) + dt_3d * pre_tend
-!
-!--             Compare sign of old velocity and new preliminary velocity,
-!--             and in case the signs are different, limit the tendency
-                IF ( SIGN(pre_v,v(k,j,i)) /= pre_v )  THEN
-                   pre_tend = - v(k,j,i) * ddt_3d
-                ELSE
-                   pre_tend = pre_tend
-                ENDIF
-!
-!--             Calculate final tendency
-                tend(k,j,i) = tend(k,j,i) + pre_tend
-             ENDDO
-
-
-!
-!--       w-component
-          CASE ( 3 )
-             DO  k = nzb_w_inner(j,i)+1, nzb_w_inner(j,i)+pch_index-1
-
-                kk = k - nzb_w_inner(j,i)  !- lad arrays are defined flat
-
-                pre_tend = 0.0_wp
-                pre_w = 0.0_wp
-!
-!--             Calculate preliminary value (pre_tend) of the tendency
-                pre_tend = - cdc *                                             &
-                             (0.5_wp *                                         &
-                                ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *         &
-                             SQRT( ( 0.25_wp * ( u(k,j,i)    +                 &  
-                                                 u(k,j,i+1)  +                 &
-                                                 u(k+1,j,i)  +                 &
-                                                 u(k+1,j,i+1) )                &
-                                   )**2 +                                      &
-                                   ( 0.25_wp * ( v(k,j,i)    +                 &
-                                                 v(k,j+1,i)  +                 &
-                                                 v(k+1,j,i)  +                 &
-                                                 v(k+1,j+1,i) )                &
-                                   )**2 +                                      &
-                                   w(k,j,i)**2                                 &
-                                 ) *                                           &
-                             w(k,j,i)
-!
-!--             Calculate preliminary new velocity, based on pre_tend
-                pre_w = w(k,j,i) + dt_3d * pre_tend
-!
-!--             Compare sign of old velocity and new preliminary velocity,
-!--             and in case the signs are different, limit the tendency
-                IF ( SIGN(pre_w,w(k,j,i)) /= pre_w )  THEN
-                   pre_tend = - w(k,j,i) * ddt_3d
-                ELSE
-                   pre_tend = pre_tend
-                ENDIF
-!
-!--             Calculate final tendency
-                tend(k,j,i) = tend(k,j,i) + pre_tend
-             ENDDO
-
-!
-!--       potential temperature
-          CASE ( 4 )
-             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
-                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
-                tend(k,j,i) = tend(k,j,i) +                                    &
-                                 ( canopy_heat_flux(kk,j,i) -                  &
-                                   canopy_heat_flux(kk-1,j,i) ) / dzw(k)
-             ENDDO
-
-
-!
-!--       scalar concentration 
-          CASE ( 5 )
-             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
-                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
-                tend(k,j,i) = tend(k,j,i) -                                    &
-                                 lsec *                                        &
-                                 lad_s(kk,j,i) *                               &
-                                 SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
-                                                    u(k,j,i+1) )               &
-                                       )**2  +                                 &
-                                       ( 0.5_wp * ( v(k,j,i) +                 &
-                                                    v(k,j+1,i) )               &
-                                       )**2 +                                  &
-                                       ( 0.5_wp * ( w(k-1,j,i) +               &
-                                                    w(k,j,i) )                 &
-                                       )**2                                    &
-                                     ) *                                       &
-                                 ( q(k,j,i) - lsc )
-             ENDDO   
-
-!
-!--       sgs-tke
-          CASE ( 6 )
-             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
-                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
-                tend(k,j,i) = tend(k,j,i) -                                    &
-                                 2.0_wp * cdc *                                &
-                                 lad_s(kk,j,i) *                               &
-                                 SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
-                                                    u(k,j,i+1) )               &
-                                       )**2 +                                  &  
-                                       ( 0.5_wp * ( v(k,j,i) +                 &
-                                                    v(k,j+1,i) )               &
-                                       )**2 +                                  &
-                                       ( 0.5_wp * ( w(k,j,i) +                 &
-                                                    w(k+1,j,i) )               &
-                                       )**2                                    &
-                                     ) *                                       &
-                                 e(k,j,i)
-             ENDDO
-
-       CASE DEFAULT
-
-          WRITE( message_string, * ) 'wrong component: ', component
-          CALL message( 'plant_canopy_model', 'PA0279', 1, 2, 0, 6, 0 ) 
-
-       END SELECT
-
-    END SUBROUTINE plant_canopy_model_ij
-
- END MODULE plant_canopy_model_mod
Index: palm/trunk/SOURCE/plant_canopy_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 1826)
+++ palm/trunk/SOURCE/plant_canopy_model_mod.f90	(revision 1826)
@@ -0,0 +1,1192 @@
+!> @file plant_canopy_model_mod.f90
+!--------------------------------------------------------------------------------!
+! This file is part of PALM.
+!
+! PALM is free software: you can redistribute it and/or modify it under the terms
+! of the GNU General Public License as published by the Free Software Foundation,
+! either version 3 of the License, or (at your option) any later version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2016 Leibniz Universitaet Hannover
+!--------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! Further modularization
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! 1721 2015-11-16 12:56:48Z raasch
+! bugfixes: shf is reduced in areas covered with canopy only,
+!           canopy is set on top of topography
+!
+! 1682 2015-10-07 23:56:08Z knoop
+! Code annotations made doxygen readable 
+! 
+! 1484 2014-10-21 10:53:05Z kanani
+! Changes due to new module structure of the plant canopy model:
+!   module plant_canopy_model_mod now contains a subroutine for the 
+!   initialization of the canopy model (pcm_init),
+!   limitation of the canopy drag (previously accounted for by calculation of 
+!   a limiting canopy timestep for the determination of the maximum LES timestep
+!   in subroutine timestep) is now realized by the calculation of pre-tendencies
+!   and preliminary velocities in subroutine pcm_tendency,
+!   some redundant MPI communication removed in subroutine pcm_init
+!   (was previously in init_3d_model),
+!   unnecessary 3d-arrays lad_u, lad_v, lad_w removed - lad information on the
+!   respective grid is now provided only by lad_s (e.g. in the calculation of 
+!   the tendency terms or of cum_lai_hf),
+!   drag_coefficient, lai, leaf_surface_concentration, 
+!   scalar_exchange_coefficient, sec and sls renamed to canopy_drag_coeff, 
+!   cum_lai_hf, leaf_surface_conc, leaf_scalar_exch_coeff, lsec and lsc,
+!   respectively,
+!   unnecessary 3d-arrays cdc, lsc and lsec now defined as single-value constants,
+!   USE-statements and ONLY-lists modified accordingly
+! 
+! 1340 2014-03-25 19:45:13Z kanani
+! REAL constants defined as wp-kind
+!
+! 1320 2014-03-20 08:40:49Z raasch
+! ONLY-attribute added to USE-statements,
+! kind-parameters added to all INTEGER and REAL declaration statements,
+! kinds are defined in new module kinds,
+! old module precision_kind is removed,
+! revision history before 2012 removed,
+! comment fields (!:) to be used for variable explanations added to
+! all variable declaration statements
+!
+! 1036 2012-10-22 13:43:42Z raasch
+! code put under GPL (PALM 3.9)
+!
+! 138 2007-11-28 10:03:58Z letzel
+! Initial revision
+!
+! Description:
+! ------------
+!> 1) Initialization of the canopy model, e.g. construction of leaf area density 
+!> profile (subroutine pcm_init).
+!> 2) Calculation of sinks and sources of momentum, heat and scalar concentration 
+!> due to canopy elements (subroutine pcm_tendency).
+!------------------------------------------------------------------------------!
+ MODULE plant_canopy_model_mod
+ 
+    USE arrays_3d,                                                             &
+        ONLY:  dzu, dzw, e, q, shf, tend, u, v, w, zu, zw 
+
+    USE indices,                                                               &
+        ONLY:  nbgp, nxl, nxlg, nxlu, nxr, nxrg, nyn, nyng, nys, nysg, nysv,   &
+               nz, nzb, nzb_s_inner, nzb_u_inner, nzb_v_inner, nzb_w_inner, nzt
+
+    USE kinds
+
+
+    IMPLICIT NONE
+
+
+    CHARACTER (LEN=20)   ::  canopy_mode = 'block' !< canopy coverage
+
+    INTEGER(iwp) ::  pch_index = 0                 !< plant canopy height/top index
+    INTEGER(iwp) ::                                                            &
+       lad_vertical_gradient_level_ind(10) = -9999 !< lad-profile levels (index)
+
+    LOGICAL ::  calc_beta_lad_profile = .FALSE. !< switch for calc. of lad from beta func.
+    LOGICAL ::  plant_canopy = .FALSE.          !< switch for use of canopy model
+
+    REAL(wp) ::  alpha_lad = 9999999.9_wp   !< coefficient for lad calculation
+    REAL(wp) ::  beta_lad = 9999999.9_wp    !< coefficient for lad calculation
+    REAL(wp) ::  canopy_drag_coeff = 0.0_wp !< canopy drag coefficient (parameter)
+    REAL(wp) ::  cdc = 0.0_wp               !< canopy drag coeff. (abbreviation used in equations)
+    REAL(wp) ::  cthf = 0.0_wp              !< canopy top heat flux
+    REAL(wp) ::  dt_plant_canopy = 0.0_wp   !< timestep account. for canopy drag
+    REAL(wp) ::  lad_surface = 0.0_wp       !< lad surface value
+    REAL(wp) ::  lai_beta = 0.0_wp          !< leaf area index (lai) for lad calc.
+    REAL(wp) ::                                                                &
+       leaf_scalar_exch_coeff = 0.0_wp      !< canopy scalar exchange coeff.
+    REAL(wp) ::                                                                &
+       leaf_surface_conc = 0.0_wp           !< leaf surface concentration
+    REAL(wp) ::  lsec = 0.0_wp              !< leaf scalar exchange coeff.
+    REAL(wp) ::  lsc = 0.0_wp               !< leaf surface concentration
+
+    REAL(wp) ::                                                                &
+       lad_vertical_gradient(10) = 0.0_wp              !< lad gradient
+    REAL(wp) ::                                                                &
+       lad_vertical_gradient_level(10) = -9999999.9_wp !< lad-prof. levels (in m)
+
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  lad            !< leaf area density
+    REAL(wp), DIMENSION(:), ALLOCATABLE ::  pre_lad        !< preliminary lad
+    
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::                                 &
+       canopy_heat_flux                                    !< canopy heat flux
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  cum_lai_hf !< cumulative lai for heatflux calc.
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  lad_s      !< lad on scalar-grid
+
+
+    SAVE
+
+
+    PRIVATE
+  
+!
+!-- Public functions
+    PUBLIC pcm_check_parameters, pcm_header, pcm_init, pcm_parin, pcm_tendency
+
+!
+!-- Public variables and constants
+    PUBLIC canopy_mode, cthf, dt_plant_canopy, plant_canopy
+
+
+    INTERFACE pcm_check_parameters
+       MODULE PROCEDURE pcm_check_parameters
+    END INTERFACE pcm_check_parameters     
+    
+     INTERFACE pcm_header
+       MODULE PROCEDURE pcm_header
+    END INTERFACE pcm_header        
+    
+    INTERFACE pcm_init
+       MODULE PROCEDURE pcm_init
+    END INTERFACE pcm_init
+
+    INTERFACE pcm_parin
+       MODULE PROCEDURE pcm_parin
+    END INTERFACE pcm_parin  
+    
+    INTERFACE pcm_tendency
+       MODULE PROCEDURE pcm_tendency
+       MODULE PROCEDURE pcm_tendency_ij
+    END INTERFACE pcm_tendency
+
+
+ CONTAINS
+
+ 
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Check parameters routine for plant canopy model
+!------------------------------------------------------------------------------!
+    SUBROUTINE pcm_check_parameters
+
+       USE control_parameters,                                                 &
+           ONLY: cloud_physics, message_string, microphysics_seifert
+                 
+    
+       IMPLICIT NONE
+
+    
+       IF ( canopy_drag_coeff == 0.0_wp )  THEN
+          message_string = 'plant_canopy = .TRUE. requires a non-zero drag '// &
+                           'coefficient & given value is canopy_drag_coeff = 0.0'
+          CALL message( 'check_parameters', 'PA0041', 1, 2, 0, 6, 0 )
+       ENDIF
+    
+       IF ( ( alpha_lad /= 9999999.9_wp  .AND.  beta_lad == 9999999.9_wp )  .OR.&
+              beta_lad /= 9999999.9_wp   .AND.  alpha_lad == 9999999.9_wp )  THEN
+          message_string = 'using the beta function for the construction ' //  &
+                           'of the leaf area density profile requires '    //  &
+                           'both alpha_lad and beta_lad to be /= 9999999.9'
+          CALL message( 'check_parameters', 'PA0118', 1, 2, 0, 6, 0 )
+       ENDIF
+    
+       IF ( calc_beta_lad_profile  .AND.  lai_beta == 0.0_wp )  THEN
+          message_string = 'using the beta function for the construction ' //  &
+                           'of the leaf area density profile requires '    //  &
+                           'a non-zero lai_beta, but given value is '      //  &
+                           'lai_beta = 0.0'
+          CALL message( 'check_parameters', 'PA0119', 1, 2, 0, 6, 0 )
+       ENDIF
+
+       IF ( calc_beta_lad_profile  .AND.  lad_surface /= 0.0_wp )  THEN
+          message_string = 'simultaneous setting of alpha_lad /= 9999999.9' // &
+                           'and lad_surface /= 0.0 is not possible, '       // &
+                           'use either vertical gradients or the beta '     // &
+                           'function for the construction of the leaf area '// &
+                           'density profile'
+          CALL message( 'check_parameters', 'PA0120', 1, 2, 0, 6, 0 )
+       ENDIF 
+
+       IF ( cloud_physics  .AND.  microphysics_seifert )  THEN
+          message_string = 'plant_canopy = .TRUE. requires cloud_scheme /=' // &
+                          ' seifert_beheng'
+          CALL message( 'check_parameters', 'PA0360', 1, 2, 0, 6, 0 )
+       ENDIF
+
+ 
+    END SUBROUTINE pcm_check_parameters 
+ 
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Header output for plant canopy model
+!------------------------------------------------------------------------------!
+    SUBROUTINE pcm_header ( io )
+
+       USE control_parameters,                                                 &
+           ONLY: dz, passive_scalar
+
+
+       IMPLICIT NONE
+ 
+       CHARACTER (LEN=10) ::  coor_chr            !<
+
+       CHARACTER (LEN=86) ::  coordinates         !<
+       CHARACTER (LEN=86) ::  gradients           !<
+       CHARACTER (LEN=86) ::  leaf_area_density   !<
+       CHARACTER (LEN=86) ::  slices              !<
+ 
+       INTEGER(iwp) :: i                !< 
+       INTEGER(iwp),  INTENT(IN) ::  io !< Unit of the output file
+       INTEGER(iwp) :: k                !<       
+   
+       REAL(wp) ::  canopy_height       !< canopy height (in m)
+       
+       canopy_height = pch_index * dz
+
+       WRITE ( io, 1 )  canopy_mode, canopy_height, pch_index,                 &
+                          canopy_drag_coeff
+       IF ( passive_scalar )  THEN
+          WRITE ( io, 2 )  leaf_scalar_exch_coeff,                             &
+                             leaf_surface_conc
+       ENDIF
+
+!
+!--    Heat flux at the top of vegetation
+       WRITE ( io, 3 )  cthf
+
+!
+!--    Leaf area density profile, calculated either from given vertical 
+!--    gradients or from beta probability density function.
+       IF (  .NOT.  calc_beta_lad_profile )  THEN
+
+!--       Building output strings, starting with surface value
+          WRITE ( leaf_area_density, '(F7.4)' )  lad_surface
+          gradients = '------'
+          slices = '     0'
+          coordinates = '   0.0'
+          i = 1
+          DO  WHILE ( i < 11  .AND.  lad_vertical_gradient_level_ind(i)        &
+                      /= -9999 )
+
+             WRITE (coor_chr,'(F7.2)')  lad(lad_vertical_gradient_level_ind(i))
+             leaf_area_density = TRIM( leaf_area_density ) // ' ' //           &
+                                 TRIM( coor_chr )
+ 
+             WRITE (coor_chr,'(F7.2)')  lad_vertical_gradient(i)
+             gradients = TRIM( gradients ) // ' ' // TRIM( coor_chr )
+
+             WRITE (coor_chr,'(I7)')  lad_vertical_gradient_level_ind(i)
+             slices = TRIM( slices ) // ' ' // TRIM( coor_chr )
+
+             WRITE (coor_chr,'(F7.1)')  lad_vertical_gradient_level(i)
+             coordinates = TRIM( coordinates ) // ' '  // TRIM( coor_chr )
+
+             i = i + 1
+          ENDDO
+
+          WRITE ( io, 4 )  TRIM( coordinates ), TRIM( leaf_area_density ),     &
+                             TRIM( gradients ), TRIM( slices )
+
+       ELSE
+       
+          WRITE ( leaf_area_density, '(F7.4)' )  lad_surface
+          coordinates = '   0.0'
+          
+          DO  k = 1, pch_index
+
+             WRITE (coor_chr,'(F7.2)')  lad(k)
+             leaf_area_density = TRIM( leaf_area_density ) // ' ' //           &
+                                 TRIM( coor_chr )
+ 
+             WRITE (coor_chr,'(F7.1)')  zu(k)
+             coordinates = TRIM( coordinates ) // ' '  // TRIM( coor_chr )
+
+          ENDDO       
+
+          WRITE ( io, 5 ) TRIM( coordinates ), TRIM( leaf_area_density ),      &
+                          alpha_lad, beta_lad, lai_beta
+
+       ENDIF  
+
+1 FORMAT (//' Vegetation canopy (drag) model:'/                                &
+              ' ------------------------------'//                              &
+              ' Canopy mode: ', A /                                            &
+              ' Canopy height: ',F6.2,'m (',I4,' grid points)' /               &
+              ' Leaf drag coefficient: ',F6.2 /)
+2 FORMAT (/ ' Scalar exchange coefficient: ',F6.2 /                            &
+              ' Scalar concentration at leaf surfaces in kg/m**3: ',F6.2 /)
+3 FORMAT (' Predefined constant heatflux at the top of the vegetation: ',F6.2, &
+          ' K m/s')
+4 FORMAT (/ ' Characteristic levels of the leaf area density:'//               &
+              ' Height:              ',A,'  m'/                                &
+              ' Leaf area density:   ',A,'  m**2/m**3'/                        &
+              ' Gradient:            ',A,'  m**2/m**4'/                        &
+              ' Gridpoint:           ',A)
+5 FORMAT (//' Characteristic levels of the leaf area density and coefficients:'&
+          //  ' Height:              ',A,'  m'/                                &
+              ' Leaf area density:   ',A,'  m**2/m**3'/                        &
+              ' Coefficient alpha: ',F6.2 /                                    &
+              ' Coefficient beta: ',F6.2 /                                     &
+              ' Leaf area index: ',F6.2,'  m**2/m**2' /)   
+       
+    END SUBROUTINE pcm_header
+ 
+ 
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Initialization of the plant canopy model
+!------------------------------------------------------------------------------!
+    SUBROUTINE pcm_init
+    
+
+       USE control_parameters,                                                 &
+           ONLY: dz, ocean, passive_scalar
+
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  i !< running index
+       INTEGER(iwp) ::  j !< running index
+       INTEGER(iwp) ::  k !< running index
+
+       REAL(wp) ::  int_bpdf      !< vertical integral for lad-profile construction
+       REAL(wp) ::  dzh           !< vertical grid spacing in units of canopy height
+       REAL(wp) ::  gradient      !< gradient for lad-profile construction
+       REAL(wp) ::  canopy_height !< canopy height for lad-profile construction
+
+!
+!--    Allocate one-dimensional arrays for the computation of the 
+!--    leaf area density (lad) profile
+       ALLOCATE( lad(0:nz+1), pre_lad(0:nz+1) )
+       lad = 0.0_wp
+       pre_lad = 0.0_wp
+
+!
+!--    Set flag that indicates that the lad-profile shall be calculated by using
+!--    a beta probability density function
+       IF ( alpha_lad /= 9999999.9_wp  .AND.  beta_lad /= 9999999.9_wp )  THEN
+          calc_beta_lad_profile = .TRUE.
+       ENDIF
+       
+       
+!
+!--    Compute the profile of leaf area density used in the plant
+!--    canopy model. The profile can either be constructed from
+!--    prescribed vertical gradients of the leaf area density or by
+!--    using a beta probability density function (see e.g. Markkanen et al., 
+!--    2003: Boundary-Layer Meteorology, 106, 437-459) 
+       IF (  .NOT.  calc_beta_lad_profile )  THEN   
+
+!
+!--       Use vertical gradients for lad-profile construction    
+          i = 1
+          gradient = 0.0_wp
+
+          IF (  .NOT.  ocean )  THEN
+
+             lad(0) = lad_surface
+             lad_vertical_gradient_level_ind(1) = 0
+ 
+             DO k = 1, pch_index
+                IF ( i < 11 )  THEN
+                   IF ( lad_vertical_gradient_level(i) < zu(k)  .AND.          &
+                        lad_vertical_gradient_level(i) >= 0.0_wp )  THEN
+                      gradient = lad_vertical_gradient(i)
+                      lad_vertical_gradient_level_ind(i) = k - 1
+                      i = i + 1
+                   ENDIF
+                ENDIF
+                IF ( gradient /= 0.0_wp )  THEN
+                   IF ( k /= 1 )  THEN
+                      lad(k) = lad(k-1) + dzu(k) * gradient
+                   ELSE
+                      lad(k) = lad_surface + dzu(k) * gradient
+                   ENDIF
+                ELSE
+                   lad(k) = lad(k-1)
+                ENDIF
+             ENDDO
+
+          ENDIF
+
+!
+!--       In case of no given leaf area density gradients, choose a vanishing
+!--       gradient. This information is used for the HEADER and the RUN_CONTROL
+!--       file.
+          IF ( lad_vertical_gradient_level(1) == -9999999.9_wp )  THEN
+             lad_vertical_gradient_level(1) = 0.0_wp
+          ENDIF
+
+       ELSE
+
+! 
+!--       Use beta function for lad-profile construction
+          int_bpdf = 0.0_wp
+          canopy_height = pch_index * dz
+
+          DO k = nzb, pch_index
+             int_bpdf = int_bpdf +                                             &
+                      ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) ) *  &
+                      ( ( 1.0_wp - ( zw(k) / canopy_height ) )**(              &
+                          beta_lad-1.0_wp ) )                                  &
+                      * ( ( zw(k+1)-zw(k) ) / canopy_height ) )
+          ENDDO
+
+!
+!--       Preliminary lad profile (defined on w-grid)
+          DO k = nzb, pch_index
+             pre_lad(k) =  lai_beta *                                          &
+                        ( ( ( zw(k) / canopy_height )**( alpha_lad-1.0_wp ) )  &
+                        * ( ( 1.0_wp - ( zw(k) / canopy_height ) )**(          &
+                              beta_lad-1.0_wp ) ) / int_bpdf                   &
+                        ) / canopy_height
+          ENDDO
+
+!
+!--       Final lad profile (defined on scalar-grid level, since most prognostic
+!--       quantities are defined there, hence, less interpolation is required 
+!--       when calculating the canopy tendencies)
+          lad(0) = pre_lad(0)
+          DO k = nzb+1, pch_index
+             lad(k) = 0.5 * ( pre_lad(k-1) + pre_lad(k) )
+          ENDDO          
+
+       ENDIF
+
+!
+!--    Allocate 3D-array for the leaf area density (lad_s). In case of a 
+!--    prescribed canopy-top heat flux (cthf), allocate 3D-arrays for
+!--    the cumulative leaf area index (cum_lai_hf) and the canopy heat flux.
+       ALLOCATE( lad_s(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+
+       IF ( cthf /= 0.0_wp )  THEN
+          ALLOCATE( cum_lai_hf(nzb:nzt+1,nysg:nyng,nxlg:nxrg),                 &
+                    canopy_heat_flux(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       ENDIF
+
+!
+!--    Initialize canopy parameters cdc (canopy drag coefficient), 
+!--    lsec (leaf scalar exchange coefficient), lsc (leaf surface concentration)
+!--    with the prescribed values
+       cdc = canopy_drag_coeff
+       lsec = leaf_scalar_exch_coeff
+       lsc = leaf_surface_conc
+
+!
+!--    Initialization of the canopy coverage in the model domain:
+!--    Setting the parameter canopy_mode = 'block' initializes a canopy, which
+!--    fully covers the domain surface
+       SELECT CASE ( TRIM( canopy_mode ) )
+
+          CASE( 'block' )
+
+             DO  i = nxlg, nxrg
+                DO  j = nysg, nyng
+                   lad_s(:,j,i) = lad(:)
+                ENDDO
+             ENDDO
+
+          CASE DEFAULT
+
+!
+!--       The DEFAULT case is reached either if the parameter 
+!--       canopy mode contains a wrong character string or if the 
+!--       user has coded a special case in the user interface. 
+!--       There, the subroutine user_init_plant_canopy checks 
+!--       which of these two conditions applies.
+          CALL user_init_plant_canopy
+ 
+       END SELECT
+
+!
+!--    Initialization of the canopy heat source distribution
+       IF ( cthf /= 0.0_wp )  THEN
+!
+!--       Piecewise calculation of the leaf area index by vertical
+!--       integration of the leaf area density
+          cum_lai_hf(:,:,:) = 0.0_wp
+          DO  i = nxlg, nxrg
+             DO  j = nysg, nyng
+                DO  k = pch_index-1, 0, -1
+                   IF ( k == pch_index-1 )  THEN
+                      cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) +                &
+                         ( 0.5_wp * lad_s(k+1,j,i) *                           &
+                           ( zw(k+1) - zu(k+1) ) )  +                          &
+                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) +              &
+                                                 lad_s(k,j,i) ) +              &
+                                      lad_s(k+1,j,i) ) *                       &
+                           ( zu(k+1) - zw(k) ) ) 
+                   ELSE
+                      cum_lai_hf(k,j,i) = cum_lai_hf(k+1,j,i) +                &
+                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+2,j,i) +              &
+                                                 lad_s(k+1,j,i) ) +            &
+                                      lad_s(k+1,j,i) ) *                       &
+                           ( zw(k+1) - zu(k+1) ) )  +                          &
+                         ( 0.5_wp * ( 0.5_wp * ( lad_s(k+1,j,i) +              &
+                                                 lad_s(k,j,i) ) +              &
+                                      lad_s(k+1,j,i) ) *                       &
+                           ( zu(k+1) - zw(k) ) )
+                   ENDIF
+                ENDDO
+             ENDDO
+          ENDDO
+
+!
+!--       Calculation of the upward kinematic vertical heat flux within the 
+!--       canopy
+          DO  i = nxlg, nxrg
+             DO  j = nysg, nyng
+                DO  k = 0, pch_index
+                   canopy_heat_flux(k,j,i) = cthf *                            &
+                                             exp( -0.6_wp * cum_lai_hf(k,j,i) )
+                ENDDO
+             ENDDO
+          ENDDO
+
+!
+!--       In areas covered with canopy, the surface heat flux is set to
+!--       the surface value of the above calculated in-canopy heat flux
+!--       distribution
+          DO  i = nxlg,nxrg
+             DO  j = nysg, nyng
+                IF ( canopy_heat_flux(0,j,i) /= cthf )  THEN
+                   shf(j,i) = canopy_heat_flux(0,j,i)
+                ENDIF
+             ENDDO
+          ENDDO
+
+       ENDIF
+
+
+
+    END SUBROUTINE pcm_init
+
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculation of the tendency terms, accounting for the effect of the plant
+!> canopy on momentum and scalar quantities.
+!>
+!> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 
+!> (defined on scalar grid), as initialized in subroutine pcm_init. 
+!> The lad on the w-grid is vertically interpolated from the surrounding
+!> lad_s. The upper boundary of the canopy is defined on the w-grid at 
+!> k = pch_index. Here, the lad is zero.
+!>
+!> The canopy drag must be limited (previously accounted for by calculation of 
+!> a limiting canopy timestep for the determination of the maximum LES timestep
+!> in subroutine timestep), since it is physically impossible that the canopy
+!> drag alone can locally change the sign of a velocity component. This 
+!> limitation is realized by calculating preliminary tendencies and velocities.
+!> It is subsequently checked if the preliminary new velocity has a different
+!> sign than the current velocity. If so, the tendency is limited in a way that
+!> the velocity can at maximum be reduced to zero by the canopy drag. 
+!>
+!>
+!> Call for all grid points
+!------------------------------------------------------------------------------!
+    SUBROUTINE pcm_tendency( component )
+
+
+       USE control_parameters,                                                 &
+           ONLY:  dt_3d, message_string
+
+       USE kinds
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
+       INTEGER(iwp) ::  i         !< running index
+       INTEGER(iwp) ::  j         !< running index
+       INTEGER(iwp) ::  k         !< running index
+       INTEGER(iwp) ::  kk        !< running index for flat lad arrays
+
+       REAL(wp) ::  ddt_3d    !< inverse of the LES timestep (dt_3d)
+       REAL(wp) ::  lad_local !< local lad value
+       REAL(wp) ::  pre_tend  !< preliminary tendency
+       REAL(wp) ::  pre_u     !< preliminary u-value 
+       REAL(wp) ::  pre_v     !< preliminary v-value 
+       REAL(wp) ::  pre_w     !< preliminary w-value 
+
+
+       ddt_3d = 1.0_wp / dt_3d
+ 
+!
+!--    Compute drag for the three velocity components and the SGS-TKE:
+       SELECT CASE ( component )
+
+!
+!--       u-component
+          CASE ( 1 )
+             DO  i = nxlu, nxr
+                DO  j = nys, nyn
+                   DO  k = nzb_u_inner(j,i)+1, nzb_u_inner(j,i)+pch_index
+
+                      kk = k - nzb_u_inner(j,i)  !- lad arrays are defined flat
+!
+!--                   In order to create sharp boundaries of the plant canopy, 
+!--                   the lad on the u-grid at index (k,j,i) is equal to 
+!--                   lad_s(k,j,i), rather than being interpolated from the 
+!--                   surrounding lad_s, because this would yield smaller lad 
+!--                   at the canopy boundaries than inside of the canopy.
+!--                   For the same reason, the lad at the rightmost(i+1)canopy 
+!--                   boundary on the u-grid equals lad_s(k,j,i).
+                      lad_local = lad_s(kk,j,i)
+                      IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp )&
+                      THEN
+                         lad_local = lad_s(kk,j,i-1)
+                      ENDIF
+
+                      pre_tend = 0.0_wp
+                      pre_u = 0.0_wp
+!
+!--                   Calculate preliminary value (pre_tend) of the tendency
+                      pre_tend = - cdc *                                       &
+                                   lad_local *                                 &
+                                   SQRT( u(k,j,i)**2 +                         &
+                                         ( 0.25_wp * ( v(k,j,i-1) +            &
+                                                       v(k,j,i)   +            &
+                                                       v(k,j+1,i) +            &
+                                                       v(k,j+1,i-1) )          &
+                                         )**2 +                                &
+                                         ( 0.25_wp * ( w(k-1,j,i-1) +          &
+                                                       w(k-1,j,i)   +          &
+                                                       w(k,j,i-1)   +          &
+                                                       w(k,j,i) )              &
+                                         )**2                                  &
+                                       ) *                                     &
+                                   u(k,j,i)
+
+!
+!--                   Calculate preliminary new velocity, based on pre_tend
+                      pre_u = u(k,j,i) + dt_3d * pre_tend
+!
+!--                   Compare sign of old velocity and new preliminary velocity,
+!--                   and in case the signs are different, limit the tendency
+                      IF ( SIGN(pre_u,u(k,j,i)) /= pre_u )  THEN
+                         pre_tend = - u(k,j,i) * ddt_3d
+                      ELSE
+                         pre_tend = pre_tend
+                      ENDIF
+!
+!--                   Calculate final tendency
+                      tend(k,j,i) = tend(k,j,i) + pre_tend
+
+                   ENDDO
+                ENDDO
+             ENDDO
+
+!
+!--       v-component
+          CASE ( 2 )
+             DO  i = nxl, nxr
+                DO  j = nysv, nyn
+                   DO  k = nzb_v_inner(j,i)+1, nzb_v_inner(j,i)+pch_index
+
+                      kk = k - nzb_v_inner(j,i)  !- lad arrays are defined flat
+!
+!--                   In order to create sharp boundaries of the plant canopy, 
+!--                   the lad on the v-grid at index (k,j,i) is equal to 
+!--                   lad_s(k,j,i), rather than being interpolated from the 
+!--                   surrounding lad_s, because this would yield smaller lad 
+!--                   at the canopy boundaries than inside of the canopy.
+!--                   For the same reason, the lad at the northmost(j+1) canopy 
+!--                   boundary on the v-grid equals lad_s(k,j,i).
+                      lad_local = lad_s(kk,j,i)
+                      IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp )&
+                      THEN
+                         lad_local = lad_s(kk,j-1,i)
+                      ENDIF
+
+                      pre_tend = 0.0_wp
+                      pre_v = 0.0_wp
+!
+!--                   Calculate preliminary value (pre_tend) of the tendency
+                      pre_tend = - cdc *                                       &
+                                   lad_local *                                 &
+                                   SQRT( ( 0.25_wp * ( u(k,j-1,i)   +          &
+                                                       u(k,j-1,i+1) +          &
+                                                       u(k,j,i)     +          &
+                                                       u(k,j,i+1) )            &
+                                         )**2 +                                &
+                                         v(k,j,i)**2 +                         &
+                                         ( 0.25_wp * ( w(k-1,j-1,i) +          &
+                                                       w(k-1,j,i)   +          &
+                                                       w(k,j-1,i)   +          &
+                                                       w(k,j,i) )              &
+                                         )**2                                  &
+                                       ) *                                     &
+                                   v(k,j,i)
+
+!
+!--                   Calculate preliminary new velocity, based on pre_tend
+                      pre_v = v(k,j,i) + dt_3d * pre_tend
+!
+!--                   Compare sign of old velocity and new preliminary velocity,
+!--                   and in case the signs are different, limit the tendency
+                      IF ( SIGN(pre_v,v(k,j,i)) /= pre_v )  THEN
+                         pre_tend = - v(k,j,i) * ddt_3d
+                      ELSE
+                         pre_tend = pre_tend
+                      ENDIF
+!
+!--                   Calculate final tendency
+                      tend(k,j,i) = tend(k,j,i) + pre_tend
+
+                   ENDDO
+                ENDDO
+             ENDDO
+
+!
+!--       w-component
+          CASE ( 3 )
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
+                   DO  k = nzb_w_inner(j,i)+1, nzb_w_inner(j,i)+pch_index-1
+
+                      kk = k - nzb_w_inner(j,i)  !- lad arrays are defined flat
+
+                      pre_tend = 0.0_wp
+                      pre_w = 0.0_wp
+!
+!--                   Calculate preliminary value (pre_tend) of the tendency
+                      pre_tend = - cdc *                                       &
+                                   (0.5_wp *                                   &
+                                      ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *   &
+                                   SQRT( ( 0.25_wp * ( u(k,j,i)   +            &
+                                                       u(k,j,i+1) +            &
+                                                       u(k+1,j,i) +            &
+                                                       u(k+1,j,i+1) )          &
+                                         )**2 +                                &
+                                         ( 0.25_wp * ( v(k,j,i)   +            &
+                                                       v(k,j+1,i) +            &
+                                                       v(k+1,j,i) +            &
+                                                       v(k+1,j+1,i) )          &
+                                         )**2 +                                &
+                                         w(k,j,i)**2                           &
+                                       ) *                                     &
+                                   w(k,j,i)
+!
+!--                   Calculate preliminary new velocity, based on pre_tend
+                      pre_w = w(k,j,i) + dt_3d * pre_tend
+!
+!--                   Compare sign of old velocity and new preliminary velocity,
+!--                   and in case the signs are different, limit the tendency
+                      IF ( SIGN(pre_w,w(k,j,i)) /= pre_w )  THEN
+                         pre_tend = - w(k,j,i) * ddt_3d
+                      ELSE
+                         pre_tend = pre_tend
+                      ENDIF
+!
+!--                   Calculate final tendency
+                      tend(k,j,i) = tend(k,j,i) + pre_tend
+
+                   ENDDO
+                ENDDO
+             ENDDO
+
+!
+!--       potential temperature
+          CASE ( 4 )
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
+                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
+                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
+                      tend(k,j,i) = tend(k,j,i) +                              &
+                                       ( canopy_heat_flux(kk,j,i) -            &
+                                         canopy_heat_flux(kk-1,j,i) ) / dzw(k)
+                   ENDDO
+                ENDDO
+             ENDDO
+
+!
+!--       scalar concentration
+          CASE ( 5 )
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
+                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
+                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
+                      tend(k,j,i) = tend(k,j,i) -                              &
+                                       lsec *                                  &
+                                       lad_s(kk,j,i) *                         &
+                                       SQRT( ( 0.5_wp * ( u(k,j,i) +           &
+                                                          u(k,j,i+1) )         &
+                                             )**2 +                            &
+                                             ( 0.5_wp * ( v(k,j,i) +           &
+                                                          v(k,j+1,i) )         &
+                                             )**2 +                            &
+                                             ( 0.5_wp * ( w(k-1,j,i) +         & 
+                                                          w(k,j,i) )           &
+                                             )**2                              &
+                                           ) *                                 &
+                                       ( q(k,j,i) - lsc )
+                   ENDDO
+                ENDDO
+             ENDDO
+
+!
+!--       sgs-tke
+          CASE ( 6 )
+             DO  i = nxl, nxr
+                DO  j = nys, nyn
+                   DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
+                      kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
+                      tend(k,j,i) = tend(k,j,i) -                              &
+                                       2.0_wp * cdc *                          &
+                                       lad_s(kk,j,i) *                         &
+                                       SQRT( ( 0.5_wp * ( u(k,j,i) +           &
+                                                          u(k,j,i+1) )         &
+                                             )**2 +                            &
+                                             ( 0.5_wp * ( v(k,j,i) +           &
+                                                          v(k,j+1,i) )         &
+                                             )**2 +                            &
+                                             ( 0.5_wp * ( w(k,j,i) +           &
+                                                          w(k+1,j,i) )         &
+                                             )**2                              &
+                                           ) *                                 &
+                                       e(k,j,i)
+                   ENDDO
+                ENDDO
+             ENDDO 
+
+
+          CASE DEFAULT
+
+             WRITE( message_string, * ) 'wrong component: ', component
+             CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) 
+
+       END SELECT
+
+    END SUBROUTINE pcm_tendency
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Parin for &canopy_par for plant canopy model
+!------------------------------------------------------------------------------!
+    SUBROUTINE pcm_parin
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file 
+       
+        NAMELIST /canopy_par/     alpha_lad, beta_lad, canopy_drag_coeff,      &
+                                  canopy_mode, cthf,                           &
+                                  lad_surface,                                 & 
+                                  lad_vertical_gradient,                       &
+                                  lad_vertical_gradient_level,                 &
+                                  lai_beta,                                    &
+                                  leaf_scalar_exch_coeff,                      &
+                                  leaf_surface_conc, pch_index
+       
+       line = ' '
+       
+!
+!--    Try to find radiation model package
+       REWIND ( 11 )
+       line = ' '
+       DO   WHILE ( INDEX( line, '&canopy_par' ) == 0 )
+          READ ( 11, '(A)', END=10 )  line
+       ENDDO
+       BACKSPACE ( 11 )
+
+!
+!--    Read user-defined namelist
+       READ ( 11, canopy_par )
+
+!
+!--    Set flag that indicates that the radiation model is switched on
+       plant_canopy = .TRUE.
+
+ 10    CONTINUE
+       
+
+    END SUBROUTINE pcm_parin    
+    
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculation of the tendency terms, accounting for the effect of the plant
+!> canopy on momentum and scalar quantities.
+!>
+!> The canopy is located where the leaf area density lad_s(k,j,i) > 0.0 
+!> (defined on scalar grid), as initialized in subroutine pcm_init. 
+!> The lad on the w-grid is vertically interpolated from the surrounding
+!> lad_s. The upper boundary of the canopy is defined on the w-grid at 
+!> k = pch_index. Here, the lad is zero.
+!>
+!> The canopy drag must be limited (previously accounted for by calculation of 
+!> a limiting canopy timestep for the determination of the maximum LES timestep
+!> in subroutine timestep), since it is physically impossible that the canopy
+!> drag alone can locally change the sign of a velocity component. This 
+!> limitation is realized by calculating preliminary tendencies and velocities.
+!> It is subsequently checked if the preliminary new velocity has a different
+!> sign than the current velocity. If so, the tendency is limited in a way that
+!> the velocity can at maximum be reduced to zero by the canopy drag. 
+!>
+!>
+!> Call for grid point i,j
+!------------------------------------------------------------------------------!
+    SUBROUTINE pcm_tendency_ij( i, j, component )
+
+
+       USE control_parameters,                                                 &
+           ONLY:  dt_3d, message_string
+
+       USE kinds
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  component !< prognostic variable (u,v,w,pt,q,e)
+       INTEGER(iwp) ::  i         !< running index
+       INTEGER(iwp) ::  j         !< running index
+       INTEGER(iwp) ::  k         !< running index
+       INTEGER(iwp) ::  kk        !< running index for flat lad arrays
+
+       REAL(wp) ::  ddt_3d    !< inverse of the LES timestep (dt_3d)
+       REAL(wp) ::  lad_local !< local lad value
+       REAL(wp) ::  pre_tend  !< preliminary tendency
+       REAL(wp) ::  pre_u     !< preliminary u-value 
+       REAL(wp) ::  pre_v     !< preliminary v-value 
+       REAL(wp) ::  pre_w     !< preliminary w-value 
+
+
+       ddt_3d = 1.0_wp / dt_3d
+
+!
+!--    Compute drag for the three velocity components and the SGS-TKE
+       SELECT CASE ( component )
+
+!
+!--       u-component
+          CASE ( 1 )
+             DO  k = nzb_u_inner(j,i)+1, nzb_u_inner(j,i)+pch_index
+
+                kk = k - nzb_u_inner(j,i)  !- lad arrays are defined flat
+!
+!--             In order to create sharp boundaries of the plant canopy, 
+!--             the lad on the u-grid at index (k,j,i) is equal to lad_s(k,j,i),
+!--             rather than being interpolated from the surrounding lad_s, 
+!--             because this would yield smaller lad at the canopy boundaries 
+!--             than inside of the canopy.
+!--             For the same reason, the lad at the rightmost(i+1)canopy 
+!--             boundary on the u-grid equals lad_s(k,j,i).
+                lad_local = lad_s(kk,j,i)
+                IF ( lad_local == 0.0_wp .AND. lad_s(kk,j,i-1) > 0.0_wp )  THEN
+                   lad_local = lad_s(kk,j,i-1)
+                ENDIF
+
+                pre_tend = 0.0_wp
+                pre_u = 0.0_wp
+!
+!--             Calculate preliminary value (pre_tend) of the tendency
+                pre_tend = - cdc *                                             &
+                             lad_local *                                       &   
+                             SQRT( u(k,j,i)**2 +                               &
+                                   ( 0.25_wp * ( v(k,j,i-1)  +                 &
+                                                 v(k,j,i)    +                 &
+                                                 v(k,j+1,i)  +                 &
+                                                 v(k,j+1,i-1) )                &
+                                   )**2 +                                      &
+                                   ( 0.25_wp * ( w(k-1,j,i-1) +                &
+                                                 w(k-1,j,i)   +                &
+                                                 w(k,j,i-1)   +                &
+                                                 w(k,j,i) )                    &
+                                   )**2                                        &
+                                 ) *                                           &
+                             u(k,j,i)
+
+!
+!--             Calculate preliminary new velocity, based on pre_tend
+                pre_u = u(k,j,i) + dt_3d * pre_tend
+!
+!--             Compare sign of old velocity and new preliminary velocity,
+!--             and in case the signs are different, limit the tendency
+                IF ( SIGN(pre_u,u(k,j,i)) /= pre_u )  THEN
+                   pre_tend = - u(k,j,i) * ddt_3d
+                ELSE
+                   pre_tend = pre_tend
+                ENDIF
+!
+!--             Calculate final tendency
+                tend(k,j,i) = tend(k,j,i) + pre_tend
+             ENDDO
+
+
+!
+!--       v-component
+          CASE ( 2 )
+             DO  k = nzb_v_inner(j,i)+1, nzb_v_inner(j,i)+pch_index
+
+                kk = k - nzb_v_inner(j,i)  !- lad arrays are defined flat
+!
+!--             In order to create sharp boundaries of the plant canopy, 
+!--             the lad on the v-grid at index (k,j,i) is equal to lad_s(k,j,i),
+!--             rather than being interpolated from the surrounding lad_s, 
+!--             because this would yield smaller lad at the canopy boundaries 
+!--             than inside of the canopy.
+!--             For the same reason, the lad at the northmost(j+1)canopy 
+!--             boundary on the v-grid equals lad_s(k,j,i).
+                lad_local = lad_s(kk,j,i)
+                IF ( lad_local == 0.0_wp .AND. lad_s(kk,j-1,i) > 0.0_wp )  THEN
+                   lad_local = lad_s(kk,j-1,i)
+                ENDIF
+
+                pre_tend = 0.0_wp
+                pre_v = 0.0_wp
+!
+!--             Calculate preliminary value (pre_tend) of the tendency
+                pre_tend = - cdc *                                             &
+                             lad_local *                                       &
+                             SQRT( ( 0.25_wp * ( u(k,j-1,i)   +                &
+                                                 u(k,j-1,i+1) +                &
+                                                 u(k,j,i)     +                &
+                                                 u(k,j,i+1) )                  &
+                                   )**2 +                                      &
+                                   v(k,j,i)**2 +                               &
+                                   ( 0.25_wp * ( w(k-1,j-1,i) +                &
+                                                 w(k-1,j,i)   +                &
+                                                 w(k,j-1,i)   +                &
+                                                 w(k,j,i) )                    &
+                                   )**2                                        &
+                                 ) *                                           &
+                             v(k,j,i)
+
+!
+!--             Calculate preliminary new velocity, based on pre_tend
+                pre_v = v(k,j,i) + dt_3d * pre_tend
+!
+!--             Compare sign of old velocity and new preliminary velocity,
+!--             and in case the signs are different, limit the tendency
+                IF ( SIGN(pre_v,v(k,j,i)) /= pre_v )  THEN
+                   pre_tend = - v(k,j,i) * ddt_3d
+                ELSE
+                   pre_tend = pre_tend
+                ENDIF
+!
+!--             Calculate final tendency
+                tend(k,j,i) = tend(k,j,i) + pre_tend
+             ENDDO
+
+
+!
+!--       w-component
+          CASE ( 3 )
+             DO  k = nzb_w_inner(j,i)+1, nzb_w_inner(j,i)+pch_index-1
+
+                kk = k - nzb_w_inner(j,i)  !- lad arrays are defined flat
+
+                pre_tend = 0.0_wp
+                pre_w = 0.0_wp
+!
+!--             Calculate preliminary value (pre_tend) of the tendency
+                pre_tend = - cdc *                                             &
+                             (0.5_wp *                                         &
+                                ( lad_s(kk+1,j,i) + lad_s(kk,j,i) )) *         &
+                             SQRT( ( 0.25_wp * ( u(k,j,i)    +                 &  
+                                                 u(k,j,i+1)  +                 &
+                                                 u(k+1,j,i)  +                 &
+                                                 u(k+1,j,i+1) )                &
+                                   )**2 +                                      &
+                                   ( 0.25_wp * ( v(k,j,i)    +                 &
+                                                 v(k,j+1,i)  +                 &
+                                                 v(k+1,j,i)  +                 &
+                                                 v(k+1,j+1,i) )                &
+                                   )**2 +                                      &
+                                   w(k,j,i)**2                                 &
+                                 ) *                                           &
+                             w(k,j,i)
+!
+!--             Calculate preliminary new velocity, based on pre_tend
+                pre_w = w(k,j,i) + dt_3d * pre_tend
+!
+!--             Compare sign of old velocity and new preliminary velocity,
+!--             and in case the signs are different, limit the tendency
+                IF ( SIGN(pre_w,w(k,j,i)) /= pre_w )  THEN
+                   pre_tend = - w(k,j,i) * ddt_3d
+                ELSE
+                   pre_tend = pre_tend
+                ENDIF
+!
+!--             Calculate final tendency
+                tend(k,j,i) = tend(k,j,i) + pre_tend
+             ENDDO
+
+!
+!--       potential temperature
+          CASE ( 4 )
+             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
+                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
+                tend(k,j,i) = tend(k,j,i) +                                    &
+                                 ( canopy_heat_flux(kk,j,i) -                  &
+                                   canopy_heat_flux(kk-1,j,i) ) / dzw(k)
+             ENDDO
+
+
+!
+!--       scalar concentration 
+          CASE ( 5 )
+             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
+                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
+                tend(k,j,i) = tend(k,j,i) -                                    &
+                                 lsec *                                        &
+                                 lad_s(kk,j,i) *                               &
+                                 SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
+                                                    u(k,j,i+1) )               &
+                                       )**2  +                                 &
+                                       ( 0.5_wp * ( v(k,j,i) +                 &
+                                                    v(k,j+1,i) )               &
+                                       )**2 +                                  &
+                                       ( 0.5_wp * ( w(k-1,j,i) +               &
+                                                    w(k,j,i) )                 &
+                                       )**2                                    &
+                                     ) *                                       &
+                                 ( q(k,j,i) - lsc )
+             ENDDO   
+
+!
+!--       sgs-tke
+          CASE ( 6 )
+             DO  k = nzb_s_inner(j,i)+1, nzb_s_inner(j,i)+pch_index
+                kk = k - nzb_s_inner(j,i)  !- lad arrays are defined flat
+                tend(k,j,i) = tend(k,j,i) -                                    &
+                                 2.0_wp * cdc *                                &
+                                 lad_s(kk,j,i) *                               &
+                                 SQRT( ( 0.5_wp * ( u(k,j,i) +                 &
+                                                    u(k,j,i+1) )               &
+                                       )**2 +                                  &  
+                                       ( 0.5_wp * ( v(k,j,i) +                 &
+                                                    v(k,j+1,i) )               &
+                                       )**2 +                                  &
+                                       ( 0.5_wp * ( w(k,j,i) +                 &
+                                                    w(k+1,j,i) )               &
+                                       )**2                                    &
+                                     ) *                                       &
+                                 e(k,j,i)
+             ENDDO
+
+       CASE DEFAULT
+
+          WRITE( message_string, * ) 'wrong component: ', component
+          CALL message( 'pcm_tendency', 'PA0279', 1, 2, 0, 6, 0 ) 
+
+       END SELECT
+
+    END SUBROUTINE pcm_tendency_ij
+
+ END MODULE plant_canopy_model_mod
Index: palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- palm/trunk/SOURCE/prognostic_equations.f90	(revision 1825)
+++ palm/trunk/SOURCE/prognostic_equations.f90	(revision 1826)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! ------------------
-!
+! Renamed canopy model calls.
 ! 
 ! Former revisions:
@@ -284,5 +284,5 @@
 
     USE plant_canopy_model_mod,                                                &
-        ONLY:  cthf, plant_canopy, plant_canopy_model
+        ONLY:  cthf, plant_canopy, pcm_tendency
 
     USE production_e_mod,                                                      &
@@ -403,5 +403,5 @@
 !
 !--          Drag by plant canopy
-             IF ( plant_canopy )  CALL plant_canopy_model( i, j, 1 )
+             IF ( plant_canopy )  CALL pcm_tendency( i, j, 1 )
 
 !
@@ -462,5 +462,5 @@
 !
 !--          Drag by plant canopy
-             IF ( plant_canopy )  CALL plant_canopy_model( i, j, 2 )        
+             IF ( plant_canopy )  CALL pcm_tendency( i, j, 2 )        
 
 !
@@ -531,5 +531,5 @@
 !
 !--       Drag by plant canopy
-          IF ( plant_canopy )  CALL plant_canopy_model( i, j, 3 )
+          IF ( plant_canopy )  CALL pcm_tendency( i, j, 3 )
 
           CALL user_actions( i, j, 'w-tendency' )
@@ -586,5 +586,5 @@
 !--          Consideration of heat sources within the plant canopy
              IF ( plant_canopy  .AND.  cthf /= 0.0_wp )  THEN
-                CALL plant_canopy_model( i, j, 4 )
+                CALL pcm_tendency( i, j, 4 )
              ENDIF
 
@@ -720,5 +720,5 @@
 !
 !--          Sink or source of scalar concentration due to canopy elements
-             IF ( plant_canopy )  CALL plant_canopy_model( i, j, 5 )
+             IF ( plant_canopy )  CALL pcm_tendency( i, j, 5 )
 
 !
@@ -888,5 +888,5 @@
 !
 !--          Additional sink term for flows through plant canopies
-             IF ( plant_canopy )  CALL plant_canopy_model( i, j, 6 ) 
+             IF ( plant_canopy )  CALL pcm_tendency( i, j, 6 ) 
 
              CALL user_actions( i, j, 'e-tendency' )
@@ -982,5 +982,5 @@
 !
 !-- Drag by plant canopy
-    IF ( plant_canopy )  CALL plant_canopy_model( 1 )
+    IF ( plant_canopy )  CALL pcm_tendency( 1 )
 
 !
@@ -1058,5 +1058,5 @@
 !
 !-- Drag by plant canopy
-    IF ( plant_canopy )  CALL plant_canopy_model( 2 )
+    IF ( plant_canopy )  CALL pcm_tendency( 2 )
 
 !
@@ -1146,5 +1146,5 @@
 !
 !-- Drag by plant canopy
-    IF ( plant_canopy )  CALL plant_canopy_model( 3 )
+    IF ( plant_canopy )  CALL pcm_tendency( 3 )
 
     CALL user_actions( 'w-tendency' )
@@ -1235,5 +1235,5 @@
 !--    Consideration of heat sources within the plant canopy
        IF ( plant_canopy .AND. ( cthf /= 0.0_wp ) ) THEN
-          CALL plant_canopy_model( 4 )
+          CALL pcm_tendency( 4 )
        ENDIF
 
@@ -1433,5 +1433,5 @@
 !
 !--    Sink or source of scalar concentration due to canopy elements
-       IF ( plant_canopy ) CALL plant_canopy_model( 5 )
+       IF ( plant_canopy ) CALL pcm_tendency( 5 )
 
 !
@@ -1531,4 +1531,6 @@
 
           CALL diffusion_s( qr, qrsws, qrswst, wall_qrflux )
+
+          CALL user_actions( 'qr-tendency' )
 
 !
@@ -1703,5 +1705,5 @@
 !
 !--    Additional sink term for flows through plant canopies
-       IF ( plant_canopy )  CALL plant_canopy_model( 6 )
+       IF ( plant_canopy )  CALL pcm_tendency( 6 )
        CALL user_actions( 'e-tendency' )
 
@@ -1816,5 +1818,5 @@
 !
 !-- Drag by plant canopy
-    IF ( plant_canopy )  CALL plant_canopy_model( 1 )
+    IF ( plant_canopy )  CALL pcm_tendency( 1 )
 
 !
@@ -1883,5 +1885,5 @@
 !
 !-- Drag by plant canopy
-    IF ( plant_canopy )  CALL plant_canopy_model( 2 )
+    IF ( plant_canopy )  CALL pcm_tendency( 2 )
 
 !
@@ -1962,5 +1964,5 @@
 !
 !-- Drag by plant canopy
-    IF ( plant_canopy )  CALL plant_canopy_model( 3 )
+    IF ( plant_canopy )  CALL pcm_tendency( 3 )
 
     CALL user_actions( 'w-tendency' )
@@ -2043,5 +2045,5 @@
 !--    Consideration of heat sources within the plant canopy
        IF ( plant_canopy .AND. ( cthf /= 0.0_wp ) ) THEN
-          CALL plant_canopy_model( 4 )
+          CALL pcm_tendency( 4 )
        ENDIF
 
@@ -2213,5 +2215,5 @@
 !
 !--    Sink or source of scalar concentration due to canopy elements
-       IF ( plant_canopy ) CALL plant_canopy_model( 5 )
+       IF ( plant_canopy ) CALL pcm_tendency( 5 )
 
 !
@@ -2435,5 +2437,5 @@
 !
 !--    Additional sink term for flows through plant canopies
-       IF ( plant_canopy )  CALL plant_canopy_model( 6 )
+       IF ( plant_canopy )  CALL pcm_tendency( 6 )
        CALL user_actions( 'e-tendency' )
 
Index: palm/trunk/SOURCE/radiation_model.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model.f90	(revision 1825)
+++ 	(revision )
@@ -1,1705 +1,0 @@
-!> @file radiation_model.f90
-!--------------------------------------------------------------------------------!
-! This file is part of PALM.
-!
-! PALM is free software: you can redistribute it and/or modify it under the terms
-! of the GNU General Public License as published by the Free Software Foundation,
-! either version 3 of the License, or (at your option) any later version.
-!
-! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License along with
-! PALM. If not, see <http://www.gnu.org/licenses/>.
-!
-! Copyright 1997-2016 Leibniz Universitaet Hannover
-!--------------------------------------------------------------------------------!
-!
-! Current revisions:
-! -----------------
-! 
-! 
-! Former revisions:
-! -----------------
-! $Id$
-!
-! 1788 2016-03-10 11:01:04Z maronga
-! Added new albedo class for pavements / roads.
-!
-! 1783 2016-03-06 18:36:17Z raasch
-! palm-netcdf-module removed in order to avoid a circular module dependency,
-! netcdf-variables moved to netcdf-module, new routine netcdf_handle_error_rad
-! added
-!
-! 1757 2016-02-22 15:49:32Z maronga
-! Added parameter unscheduled_radiation_calls. Bugfix: interpolation of sounding
-! profiles for pressure and temperature above the LES domain.
-! 
-! 1709 2015-11-04 14:47:01Z maronga
-! Bugfix: set initial value for rrtm_lwuflx_dt to zero, small formatting
-! corrections
-! 
-! 1701 2015-11-02 07:43:04Z maronga
-! Bugfixes: wrong index for output of timeseries, setting of nz_snd_end
-! 
-! 1691 2015-10-26 16:17:44Z maronga
-! Added option for spin-up runs without radiation (skip_time_do_radiation). Bugfix
-! in calculation of pressure profiles. Bugfix in calculation of trace gas profiles.
-! Added output of radiative heating rates.
-! 
-! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable 
-! 
-! 1606 2015-06-29 10:43:37Z maronga
-! Added preprocessor directive __netcdf to allow for compiling without netCDF.
-! Note, however, that RRTMG cannot be used without netCDF.
-! 
-! 1590 2015-05-08 13:56:27Z maronga
-! Bugfix: definition of character strings requires same length for all elements
-! 
-! 1587 2015-05-04 14:19:01Z maronga
-! Added albedo class for snow
-! 
-! 1585 2015-04-30 07:05:52Z maronga
-! Added support for RRTMG
-! 
-! 1571 2015-03-12 16:12:49Z maronga
-! Added missing KIND attribute. Removed upper-case variable names
-! 
-! 1551 2015-03-03 14:18:16Z maronga
-! Added support for data output. Various variables have been renamed. Added
-! interface for different radiation schemes (currently: clear-sky, constant, and
-! RRTM (not yet implemented).
-! 
-! 1496 2014-12-02 17:25:50Z maronga
-! Initial revision
-! 
-!
-! Description:
-! ------------
-!> Radiation models and interfaces
-!> @todo move variable definitions used in init_radiation only to the subroutine
-!>       as they are no longer required after initialization.
-!> @todo Output of full column vertical profiles used in RRTMG
-!> @todo Output of other rrtm arrays (such as volume mixing ratios)
-!> @todo Adapt for use with topography
-!>
-!> @note Many variables have a leading dummy dimension (0:0) in order to
-!>       match the assume-size shape expected by the RRTMG model.
-!------------------------------------------------------------------------------!
- MODULE radiation_model_mod
- 
-    USE arrays_3d,                                                             &
-        ONLY:  dzw, hyp, pt, q, ql, zw
-
-    USE cloud_parameters,                                                      &
-        ONLY:  cp, l_d_cp, nc_const, rho_l, sigma_gc  
-
-    USE constants,                                                             &
-        ONLY:  pi
-
-    USE control_parameters,                                                    &
-        ONLY:  cloud_droplets, cloud_physics, g, initializing_actions,         &
-               large_scale_forcing, lsf_surf, phi, pt_surface, rho_surface,    &
-               surface_pressure, time_since_reference_point
-
-    USE indices,                                                               &
-        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb_s_inner, nzb, nzt
-
-    USE kinds
-
-#if defined ( __netcdf )
-    USE NETCDF
-#endif
-
-#if defined ( __rrtmg )
-
-!     USE netcdf_interface,                                                      &
-!         ONLY:  nc_stat, netcdf_handle_error
-
-    USE parrrsw,                                                               &
-        ONLY:  naerec, nbndsw
-
-    USE parrrtm,                                                               &
-        ONLY:  nbndlw
-
-    USE rrtmg_lw_init,                                                         &
-        ONLY:  rrtmg_lw_ini
-
-    USE rrtmg_sw_init,                                                         &
-        ONLY:  rrtmg_sw_ini
-
-    USE rrtmg_lw_rad,                                                          &
-        ONLY:  rrtmg_lw
-
-    USE rrtmg_sw_rad,                                                          &
-        ONLY:  rrtmg_sw
-#endif
-
-
-
-    IMPLICIT NONE
-
-    CHARACTER(10) :: radiation_scheme = 'clear-sky' ! 'constant', 'clear-sky', or 'rrtmg'
-
-!
-!-- Predefined Land surface classes (albedo_type) after Briegleb (1992)
-    CHARACTER(37), DIMENSION(0:17), PARAMETER :: albedo_type_name = (/      &
-                                   'user defined                         ', & !  0 
-                                   'ocean                                ', & !  1
-                                   'mixed farming, tall grassland        ', & !  2
-                                   'tall/medium grassland                ', & !  3 
-                                   'evergreen shrubland                  ', & !  4
-                                   'short grassland/meadow/shrubland     ', & !  5
-                                   'evergreen needleleaf forest          ', & !  6
-                                   'mixed deciduous evergreen forest     ', & !  7
-                                   'deciduous forest                     ', & !  8
-                                   'tropical evergreen broadleaved forest', & !  9
-                                   'medium/tall grassland/woodland       ', & ! 10
-                                   'desert, sandy                        ', & ! 11 
-                                   'desert, rocky                        ', & ! 12 
-                                   'tundra                               ', & ! 13
-                                   'land ice                             ', & ! 14 
-                                   'sea ice                              ', & ! 15 
-                                   'snow                                 ', & ! 16
-                                   'pavement/roads                       '  & ! 17
-                                                         /)
-
-    INTEGER(iwp) :: albedo_type  = 5,    & !< Albedo surface type (default: short grassland)
-                    day,                 & !< current day of the year
-                    day_init     = 172,  & !< day of the year at model start (21/06)
-                    dots_rad     = 0       !< starting index for timeseries output 
-
-    LOGICAL ::  unscheduled_radiation_calls = .TRUE., & !< flag parameter indicating whether additional calls of the radiation code are allowed
-                constant_albedo = .FALSE.,            & !< flag parameter indicating whether the albedo may change depending on zenith
-                force_radiation_call = .FALSE.,       & !< flag parameter for unscheduled radiation calls
-                lw_radiation = .TRUE.,                & !< flag parameter indicating whether longwave radiation shall be calculated
-                radiation = .FALSE.,                  & !< flag parameter indicating whether the radiation model is used
-                sun_up    = .TRUE.,                   & !< flag parameter indicating whether the sun is up or down
-                sw_radiation = .TRUE.                   !< flag parameter indicing whether shortwave radiation shall be calculated
-
-
-    REAL(wp), PARAMETER :: d_seconds_hour  = 0.000277777777778_wp,  & !< inverse of seconds per hour (1/3600)
-                           d_hours_day    = 0.0416666666667_wp,     & !< inverse of hours per day (1/24)
-                           sigma_sb       = 5.67037321E-8_wp,       & !< Stefan-Boltzmann constant
-                           solar_constant = 1368.0_wp                 !< solar constant at top of atmosphere
-
-    REAL(wp) :: albedo = 9999999.9_wp,           & !< NAMELIST alpha
-                albedo_lw_dif = 9999999.9_wp,    & !< NAMELIST aldif
-                albedo_lw_dir = 9999999.9_wp,    & !< NAMELIST aldir
-                albedo_sw_dif = 9999999.9_wp,    & !< NAMELIST asdif
-                albedo_sw_dir = 9999999.9_wp,    & !< NAMELIST asdir
-                decl_1,                          & !< declination coef. 1
-                decl_2,                          & !< declination coef. 2
-                decl_3,                          & !< declination coef. 3
-                dt_radiation = 0.0_wp,           & !< radiation model timestep
-                emissivity = 0.98_wp,            & !< NAMELIST surface emissivity
-                lambda = 0.0_wp,                 & !< longitude in degrees
-                lon = 0.0_wp,                    & !< longitude in radians
-                lat = 0.0_wp,                    & !< latitude in radians
-                net_radiation = 0.0_wp,          & !< net radiation at surface
-                skip_time_do_radiation = 0.0_wp, & !< Radiation model is not called before this time
-                sky_trans,                       & !< sky transmissivity
-                time_radiation = 0.0_wp,         & !< time since last call of radiation code
-                time_utc,                        & !< current time in UTC
-                time_utc_init = 43200.0_wp         !< UTC time at model start (noon)
-
-    REAL(wp), DIMENSION(0:0) ::  zenith        !< solar zenith angle
-
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE :: &
-                alpha,                       & !< surface broadband albedo (used for clear-sky scheme)
-                rad_lw_out_change_0,         & !< change in LW out due to change in surface temperature
-                rad_net,                     & !< net radiation at the surface
-                rad_net_av                     !< average of rad_net
-
-!
-!-- Land surface albedos for solar zenith angle of 60Â° after Briegleb (1992)     
-!-- (shortwave, longwave, broadband):   sw,      lw,      bb,
-    REAL(wp), DIMENSION(0:2,1:17), PARAMETER :: albedo_pars = RESHAPE( (/& 
-                                   0.06_wp, 0.06_wp, 0.06_wp,            & !  1
-                                   0.09_wp, 0.28_wp, 0.19_wp,            & !  2
-                                   0.11_wp, 0.33_wp, 0.23_wp,            & !  3
-                                   0.11_wp, 0.33_wp, 0.23_wp,            & !  4
-                                   0.14_wp, 0.34_wp, 0.25_wp,            & !  5
-                                   0.06_wp, 0.22_wp, 0.14_wp,            & !  6
-                                   0.06_wp, 0.27_wp, 0.17_wp,            & !  7
-                                   0.06_wp, 0.31_wp, 0.19_wp,            & !  8
-                                   0.06_wp, 0.22_wp, 0.14_wp,            & !  9
-                                   0.06_wp, 0.28_wp, 0.18_wp,            & ! 10
-                                   0.35_wp, 0.51_wp, 0.43_wp,            & ! 11
-                                   0.24_wp, 0.40_wp, 0.32_wp,            & ! 12
-                                   0.10_wp, 0.27_wp, 0.19_wp,            & ! 13
-                                   0.90_wp, 0.65_wp, 0.77_wp,            & ! 14
-                                   0.90_wp, 0.65_wp, 0.77_wp,            & ! 15
-                                   0.95_wp, 0.70_wp, 0.82_wp,            & ! 16
-                                   0.08_wp, 0.08_wp, 0.08_wp             & ! 17
-                                 /), (/ 3, 17 /) )
-
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: &
-                        rad_lw_cs_hr,                  & !< longwave clear sky radiation heating rate (K/s)
-                        rad_lw_cs_hr_av,               & !< average of rad_lw_cs_hr
-                        rad_lw_hr,                     & !< longwave radiation heating rate (K/s)
-                        rad_lw_hr_av,                  & !< average of rad_sw_hr
-                        rad_lw_in,                     & !< incoming longwave radiation (W/m2)
-                        rad_lw_in_av,                  & !< average of rad_lw_in
-                        rad_lw_out,                    & !< outgoing longwave radiation (W/m2)
-                        rad_lw_out_av,                 & !< average of rad_lw_out
-                        rad_sw_cs_hr,                  & !< shortwave clear sky radiation heating rate (K/s)
-                        rad_sw_cs_hr_av,               & !< average of rad_sw_cs_hr
-                        rad_sw_hr,                     & !< shortwave radiation heating rate (K/s)
-                        rad_sw_hr_av,                  & !< average of rad_sw_hr
-                        rad_sw_in,                     & !< incoming shortwave radiation (W/m2)
-                        rad_sw_in_av,                  & !< average of rad_sw_in
-                        rad_sw_out,                    & !< outgoing shortwave radiation (W/m2)
-                        rad_sw_out_av                    !< average of rad_sw_out
-
-
-!
-!-- Variables and parameters used in RRTMG only
-#if defined ( __rrtmg )
-    CHARACTER(LEN=12) :: rrtm_input_file = "RAD_SND_DATA" !< name of the NetCDF input file (sounding data)
-
-
-!
-!-- Flag parameters for RRTMGS (should not be changed)
-    INTEGER(iwp), PARAMETER :: rrtm_inflglw  = 2, & !< flag for lw cloud optical properties (0,1,2)
-                               rrtm_iceflglw = 0, & !< flag for lw ice particle specifications (0,1,2,3)
-                               rrtm_liqflglw = 1, & !< flag for lw liquid droplet specifications
-                               rrtm_inflgsw  = 2, & !< flag for sw cloud optical properties (0,1,2)
-                               rrtm_iceflgsw = 0, & !< flag for sw ice particle specifications (0,1,2,3)
-                               rrtm_liqflgsw = 1    !< flag for sw liquid droplet specifications
-
-!
-!-- The following variables should be only changed with care, as this will 
-!-- require further setting of some variables, which is currently not
-!-- implemented (aerosols, ice phase).
-    INTEGER(iwp) :: nzt_rad,           & !< upper vertical limit for radiation calculations
-                    rrtm_icld = 0,     & !< cloud flag (0: clear sky column, 1: cloudy column)
-                    rrtm_iaer = 0,     & !< aerosol option flag (0: no aerosol layers, for lw only: 6 (requires setting of rrtm_sw_ecaer), 10: one or more aerosol layers (not implemented)
-                    rrtm_idrv = 1        !< longwave upward flux calculation option (0,1)
-
-    INTEGER(iwp) :: nc_stat !< local variable for storin the result of netCDF calls for error message handling
-
-    LOGICAL :: snd_exists = .FALSE.      !< flag parameter to check whether a user-defined input files exists
-
-    REAL(wp), PARAMETER :: mol_mass_air_d_wv = 1.607793_wp !< molecular weight dry air / water vapor
-
-    REAL(wp), DIMENSION(:), ALLOCATABLE :: hyp_snd,     & !< hypostatic pressure from sounding data (hPa)
-                                           q_snd,       & !< specific humidity from sounding data (kg/kg) - dummy at the moment
-                                           rrtm_tsfc,   & !< dummy array for storing surface temperature
-                                           t_snd          !< actual temperature from sounding data (hPa)
-
-    REAL(wp), DIMENSION(:,:), ALLOCATABLE :: aldif,          & !< longwave diffuse albedo solar angle of 60Â°
-                                             aldir,          & !< longwave direct albedo solar angle of 60Â°
-                                             asdif,          & !< shortwave diffuse albedo solar angle of 60Â°
-                                             asdir,          & !< shortwave direct albedo solar angle of 60Â°
-                                             rrtm_ccl4vmr,   & !< CCL4 volume mixing ratio (g/mol)
-                                             rrtm_cfc11vmr,  & !< CFC11 volume mixing ratio (g/mol)
-                                             rrtm_cfc12vmr,  & !< CFC12 volume mixing ratio (g/mol)
-                                             rrtm_cfc22vmr,  & !< CFC22 volume mixing ratio (g/mol)
-                                             rrtm_ch4vmr,    & !< CH4 volume mixing ratio
-                                             rrtm_cicewp,    & !< in-cloud ice water path (g/mÂ²)
-                                             rrtm_cldfr,     & !< cloud fraction (0,1)
-                                             rrtm_cliqwp,    & !< in-cloud liquid water path (g/mÂ²)
-                                             rrtm_co2vmr,    & !< CO2 volume mixing ratio (g/mol)
-                                             rrtm_emis,      & !< surface emissivity (0-1)    
-                                             rrtm_h2ovmr,    & !< H2O volume mixing ratio
-                                             rrtm_n2ovmr,    & !< N2O volume mixing ratio
-                                             rrtm_o2vmr,     & !< O2 volume mixing ratio
-                                             rrtm_o3vmr,     & !< O3 volume mixing ratio
-                                             rrtm_play,      & !< pressure layers (hPa, zu-grid)
-                                             rrtm_plev,      & !< pressure layers (hPa, zw-grid)
-                                             rrtm_reice,     & !< cloud ice effective radius (microns)
-                                             rrtm_reliq,     & !< cloud water drop effective radius (microns)
-                                             rrtm_tlay,      & !< actual temperature (K, zu-grid)
-                                             rrtm_tlev,      & !< actual temperature (K, zw-grid)
-                                             rrtm_lwdflx,    & !< RRTM output of incoming longwave radiation flux (W/m2)
-                                             rrtm_lwdflxc,   & !< RRTM output of outgoing clear sky longwave radiation flux (W/m2) 
-                                             rrtm_lwuflx,    & !< RRTM output of outgoing longwave radiation flux (W/m2)
-                                             rrtm_lwuflxc,   & !< RRTM output of incoming clear sky longwave radiation flux (W/m2)
-                                             rrtm_lwuflx_dt, & !< RRTM output of incoming clear sky longwave radiation flux (W/m2)
-                                             rrtm_lwuflxc_dt,& !< RRTM output of outgoing clear sky longwave radiation flux (W/m2)
-                                             rrtm_lwhr,      & !< RRTM output of longwave radiation heating rate (K/d)
-                                             rrtm_lwhrc,     & !< RRTM output of incoming longwave clear sky radiation heating rate (K/d)
-                                             rrtm_swdflx,    & !< RRTM output of incoming shortwave radiation flux (W/m2)
-                                             rrtm_swdflxc,   & !< RRTM output of outgoing clear sky shortwave radiation flux (W/m2) 
-                                             rrtm_swuflx,    & !< RRTM output of outgoing shortwave radiation flux (W/m2)
-                                             rrtm_swuflxc,   & !< RRTM output of incoming clear sky shortwave radiation flux (W/m2)
-                                             rrtm_swhr,      & !< RRTM output of shortwave radiation heating rate (K/d)
-                                             rrtm_swhrc        !< RRTM output of incoming shortwave clear sky radiation heating rate (K/d) 
-
-!
-!-- Definition of arrays that are currently not used for calling RRTMG (due to setting of flag parameters)
-    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  rad_lw_cs_in,   & !< incoming clear sky longwave radiation (W/m2) (not used)
-                                                rad_lw_cs_out,  & !< outgoing clear sky longwave radiation (W/m2) (not used)
-                                                rad_sw_cs_in,   & !< incoming clear sky shortwave radiation (W/m2) (not used)
-                                                rad_sw_cs_out,  & !< outgoing clear sky shortwave radiation (W/m2) (not used)
-                                                rrtm_aldif,     & !< surface albedo for longwave diffuse radiation
-                                                rrtm_aldir,     & !< surface albedo for longwave direct radiation
-                                                rrtm_asdif,     & !< surface albedo for shortwave diffuse radiation
-                                                rrtm_asdir,     & !< surface albedo for shortwave direct radiation
-                                                rrtm_lw_tauaer, & !< lw aerosol optical depth
-                                                rrtm_lw_taucld, & !< lw in-cloud optical depth
-                                                rrtm_sw_taucld, & !< sw in-cloud optical depth
-                                                rrtm_sw_ssacld, & !< sw in-cloud single scattering albedo
-                                                rrtm_sw_asmcld, & !< sw in-cloud asymmetry parameter
-                                                rrtm_sw_fsfcld, & !< sw in-cloud forward scattering fraction
-                                                rrtm_sw_tauaer, & !< sw aerosol optical depth
-                                                rrtm_sw_ssaaer, & !< sw aerosol single scattering albedo
-                                                rrtm_sw_asmaer, & !< sw aerosol asymmetry parameter
-                                                rrtm_sw_ecaer     !< sw aerosol optical detph at 0.55 microns (rrtm_iaer = 6 only)
-
-#endif
-
-    INTERFACE init_radiation
-       MODULE PROCEDURE init_radiation
-    END INTERFACE init_radiation
-
-    INTERFACE radiation_clearsky
-       MODULE PROCEDURE radiation_clearsky
-    END INTERFACE radiation_clearsky
-
-    INTERFACE radiation_rrtmg
-       MODULE PROCEDURE radiation_rrtmg
-    END INTERFACE radiation_rrtmg
-
-    INTERFACE radiation_tendency
-       MODULE PROCEDURE radiation_tendency
-       MODULE PROCEDURE radiation_tendency_ij
-    END INTERFACE radiation_tendency
-
-    SAVE
-
-    PRIVATE
-
-    PUBLIC albedo, albedo_type, albedo_type_name, albedo_lw_dif, albedo_lw_dir,&
-           albedo_sw_dif, albedo_sw_dir, constant_albedo, day_init, dots_rad,  &
-           dt_radiation, emissivity, force_radiation_call, init_radiation,     &
-           lambda, lw_radiation, net_radiation, rad_net, rad_net_av, radiation,&
-           radiation_clearsky, radiation_rrtmg, radiation_scheme,              &
-           radiation_tendency, rad_lw_in, rad_lw_in_av, rad_lw_out,            &
-           rad_lw_out_av, rad_lw_out_change_0, rad_lw_cs_hr, rad_lw_cs_hr_av,  &
-           rad_lw_hr, rad_lw_hr_av, rad_sw_in, rad_sw_in_av, rad_sw_out,       &
-           rad_sw_out_av, rad_sw_cs_hr, rad_sw_cs_hr_av, rad_sw_hr,            &
-           rad_sw_hr_av, sigma_sb, skip_time_do_radiation, sw_radiation,       &
-           time_radiation, time_utc_init, unscheduled_radiation_calls
-
-
-#if defined ( __rrtmg )
-    PUBLIC rrtm_aldif, rrtm_aldir, rrtm_asdif, rrtm_asdir, rrtm_idrv
-#endif
-
- CONTAINS
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Initialization of the radiation model
-!------------------------------------------------------------------------------!
-    SUBROUTINE init_radiation
-    
-       IMPLICIT NONE
-
-!
-!--    Allocate array for storing the surface net radiation
-       IF ( .NOT. ALLOCATED ( rad_net ) )  THEN
-          ALLOCATE ( rad_net(nysg:nyng,nxlg:nxrg) )
-          rad_net = 0.0_wp
-       ENDIF
-
-!
-!--    Allocate array for storing the surface net radiation
-       IF ( .NOT. ALLOCATED ( rad_lw_out_change_0 ) )  THEN
-          ALLOCATE ( rad_lw_out_change_0(nysg:nyng,nxlg:nxrg) )
-          rad_lw_out_change_0 = 0.0_wp
-       ENDIF
-
-!
-!--    Fix net radiation in case of radiation_scheme = 'constant'
-       IF ( radiation_scheme == 'constant' )  THEN
-          rad_net = net_radiation
-          radiation = .FALSE.
-!
-!--    Calculate orbital constants
-       ELSE
-          decl_1 = SIN(23.45_wp * pi / 180.0_wp)
-          decl_2 = 2.0_wp * pi / 365.0_wp
-          decl_3 = decl_2 * 81.0_wp
-          lat    = phi * pi / 180.0_wp
-          lon    = lambda * pi / 180.0_wp
-       ENDIF
-
-
-       IF ( radiation_scheme == 'clear-sky' )  THEN
-
-          ALLOCATE ( alpha(nysg:nyng,nxlg:nxrg) )
-
-          IF ( .NOT. ALLOCATED ( rad_sw_in ) )  THEN
-             ALLOCATE ( rad_sw_in(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-          IF ( .NOT. ALLOCATED ( rad_sw_out ) )  THEN
-             ALLOCATE ( rad_sw_out(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_in_av ) )  THEN
-             ALLOCATE ( rad_sw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-          IF ( .NOT. ALLOCATED ( rad_sw_out_av ) )  THEN
-             ALLOCATE ( rad_sw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_in ) )  THEN
-             ALLOCATE ( rad_lw_in(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-          IF ( .NOT. ALLOCATED ( rad_lw_out ) )  THEN
-             ALLOCATE ( rad_lw_out(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_in_av ) )  THEN
-             ALLOCATE ( rad_lw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-          IF ( .NOT. ALLOCATED ( rad_lw_out_av ) )  THEN
-             ALLOCATE ( rad_lw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          rad_sw_in  = 0.0_wp
-          rad_sw_out = 0.0_wp
-          rad_lw_in  = 0.0_wp
-          rad_lw_out = 0.0_wp
-
-!
-!--       Overwrite albedo if manually set in parameter file
-          IF ( albedo_type /= 0 .AND. albedo == 9999999.9_wp )  THEN
-             albedo = albedo_pars(2,albedo_type)
-          ENDIF
-    
-          alpha = albedo
-  
-!
-!--    Initialization actions for RRTMG
-       ELSEIF ( radiation_scheme == 'rrtmg' )  THEN
-#if defined ( __rrtmg )
-!
-!--       Allocate albedos
-          ALLOCATE ( rrtm_aldif(0:0,nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( rrtm_aldir(0:0,nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( rrtm_asdif(0:0,nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( rrtm_asdir(0:0,nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( aldif(nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( aldir(nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( asdif(nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( asdir(nysg:nyng,nxlg:nxrg) )
-
-          IF ( albedo_type /= 0 )  THEN
-             IF ( albedo_lw_dif == 9999999.9_wp )  THEN
-                albedo_lw_dif = albedo_pars(0,albedo_type)
-                albedo_lw_dir = albedo_lw_dif
-             ENDIF
-             IF ( albedo_sw_dif == 9999999.9_wp )  THEN
-                albedo_sw_dif = albedo_pars(1,albedo_type)
-                albedo_sw_dir = albedo_sw_dif
-             ENDIF
-          ENDIF
-
-          aldif(:,:) = albedo_lw_dif
-          aldir(:,:) = albedo_lw_dir
-          asdif(:,:) = albedo_sw_dif
-          asdir(:,:) = albedo_sw_dir
-!
-!--       Calculate initial values of current (cosine of) the zenith angle and 
-!--       whether the sun is up
-          CALL calc_zenith     
-!
-!--       Calculate initial surface albedo
-          IF ( .NOT. constant_albedo )  THEN
-             CALL calc_albedo
-          ELSE
-             rrtm_aldif(0,:,:) = aldif(:,:)
-             rrtm_aldir(0,:,:) = aldir(:,:)
-             rrtm_asdif(0,:,:) = asdif(:,:) 
-             rrtm_asdir(0,:,:) = asdir(:,:)   
-          ENDIF
-
-!
-!--       Allocate surface emissivity
-          ALLOCATE ( rrtm_emis(0:0,1:nbndlw+1) )
-          rrtm_emis = emissivity
-
-!
-!--       Allocate 3d arrays of radiative fluxes and heating rates
-          IF ( .NOT. ALLOCATED ( rad_sw_in ) )  THEN
-             ALLOCATE ( rad_sw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_sw_in = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_in_av ) )  THEN
-             ALLOCATE ( rad_sw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_out ) )  THEN
-             ALLOCATE ( rad_sw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_sw_out = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_out_av ) )  THEN
-             ALLOCATE ( rad_sw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_hr ) )  THEN
-             ALLOCATE ( rad_sw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_sw_hr = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_hr_av ) )  THEN
-             ALLOCATE ( rad_sw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_sw_hr_av = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_cs_hr ) )  THEN
-             ALLOCATE ( rad_sw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_sw_cs_hr = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_sw_cs_hr_av ) )  THEN
-             ALLOCATE ( rad_sw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_sw_cs_hr_av = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_in ) )  THEN
-             ALLOCATE ( rad_lw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_lw_in     = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_in_av ) )  THEN
-             ALLOCATE ( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_out ) )  THEN
-             ALLOCATE ( rad_lw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-            rad_lw_out    = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_out_av ) )  THEN
-             ALLOCATE ( rad_lw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_hr ) )  THEN
-             ALLOCATE ( rad_lw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_lw_hr = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_hr_av ) )  THEN
-             ALLOCATE ( rad_lw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_lw_hr_av = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_cs_hr ) )  THEN
-             ALLOCATE ( rad_lw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_lw_cs_hr = 0.0_wp
-          ENDIF
-
-          IF ( .NOT. ALLOCATED ( rad_lw_cs_hr_av ) )  THEN
-             ALLOCATE ( rad_lw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-             rad_lw_cs_hr_av = 0.0_wp
-          ENDIF
-
-          ALLOCATE ( rad_sw_cs_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( rad_sw_cs_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          rad_sw_cs_in  = 0.0_wp
-          rad_sw_cs_out = 0.0_wp
-
-          ALLOCATE ( rad_lw_cs_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          ALLOCATE ( rad_lw_cs_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          rad_lw_cs_in  = 0.0_wp
-          rad_lw_cs_out = 0.0_wp
-
-!
-!--       Allocate dummy array for storing surface temperature
-          ALLOCATE ( rrtm_tsfc(1) )
-
-!
-!--       Initialize RRTMG
-          IF ( lw_radiation )  CALL rrtmg_lw_ini ( cp )
-          IF ( sw_radiation )  CALL rrtmg_sw_ini ( cp )
-
-!
-!--       Set input files for RRTMG
-          INQUIRE(FILE="RAD_SND_DATA", EXIST=snd_exists) 
-          IF ( .NOT. snd_exists )  THEN
-             rrtm_input_file = "rrtmg_lw.nc"
-          ENDIF
-
-!
-!--       Read vertical layers for RRTMG from sounding data
-!--       The routine provides nzt_rad, hyp_snd(1:nzt_rad),
-!--       t_snd(nzt+2:nzt_rad), rrtm_play(1:nzt_rad), rrtm_plev(1_nzt_rad+1), 
-!--       rrtm_tlay(nzt+2:nzt_rad), rrtm_tlev(nzt+2:nzt_rad+1)
-          CALL read_sounding_data
-
-!
-!--       Read trace gas profiles from file. This routine provides
-!--       the rrtm_ arrays (1:nzt_rad+1)
-          CALL read_trace_gas_data
-#endif
-       ENDIF
-
-!
-!--    Perform user actions if required
-       CALL user_init_radiation
-
-!
-!--    Calculate radiative fluxes at model start
-       IF (  TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
-          IF ( radiation_scheme == 'clear-sky' )  THEN
-             CALL radiation_clearsky
-          ELSEIF ( radiation_scheme == 'rrtmg' )  THEN
-             CALL radiation_rrtmg
-          ENDIF
-       ENDIF
-
-       RETURN
-
-    END SUBROUTINE init_radiation
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> A simple clear sky radiation model
-!------------------------------------------------------------------------------!
-    SUBROUTINE radiation_clearsky
-
-       USE indices,                                                            &
-           ONLY:  nbgp
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) :: i, j, k   !< loop indices
-       REAL(wp)     :: exn,   &  !< Exner functions at surface
-                       exn1,  &  !< Exner functions at first grid level
-                       pt1       !< potential temperature at first grid level
-
-!
-!--    Calculate current zenith angle
-       CALL calc_zenith
-
-!
-!--    Calculate sky transmissivity
-       sky_trans = 0.6_wp + 0.2_wp * zenith(0)
-
-!
-!--    Calculate value of the Exner function
-       exn = (surface_pressure / 1000.0_wp )**0.286_wp
-!
-!--    Calculate radiation fluxes and net radiation (rad_net) for each grid 
-!--    point
-       DO i = nxlg, nxrg
-          DO j = nysg, nyng
-             k = nzb_s_inner(j,i)
-
-             exn1 = (hyp(k+1) / 100000.0_wp )**0.286_wp
-
-             rad_sw_in(0,j,i)  = solar_constant * sky_trans * zenith(0)
-             rad_sw_out(0,j,i) = alpha(j,i) * rad_sw_in(0,j,i)
-             rad_lw_out(0,j,i) = emissivity * sigma_sb * (pt(k,j,i) * exn)**4
-
-             IF ( cloud_physics )  THEN
-                pt1 = pt(k+1,j,i) + l_d_cp / exn1 * ql(k+1,j,i)
-                rad_lw_in(0,j,i)  = 0.8_wp * sigma_sb * (pt1 * exn1)**4
-             ELSE
-                rad_lw_in(0,j,i)  = 0.8_wp * sigma_sb * (pt(k+1,j,i) * exn1)**4
-             ENDIF
-
-             rad_net(j,i) = rad_sw_in(0,j,i) - rad_sw_out(0,j,i)               &
-                            + rad_lw_in(0,j,i) - rad_lw_out(0,j,i)
-
-          ENDDO
-       ENDDO
-
-    END SUBROUTINE radiation_clearsky
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Implementation of the RRTMG radiation_scheme
-!------------------------------------------------------------------------------!
-    SUBROUTINE radiation_rrtmg
-
-       USE indices,                                                            &
-           ONLY:  nbgp
-
-       USE particle_attributes,                                                &
-           ONLY:  grid_particles, number_of_particles, particles,              &
-                  particle_advection_start, prt_count
-
-       IMPLICIT NONE
-
-#if defined ( __rrtmg )
-
-       INTEGER(iwp) :: i, j, k, n !< loop indices
-
-       REAL(wp)     ::  s_r2, &   !< weighted sum over all droplets with r^2
-                        s_r3      !< weighted sum over all droplets with r^3
-
-!
-!--    Calculate current (cosine of) zenith angle and whether the sun is up
-       CALL calc_zenith     
-!
-!--    Calculate surface albedo
-       IF ( .NOT. constant_albedo )  THEN
-          CALL calc_albedo
-       ENDIF
-
-!
-!--    Prepare input data for RRTMG
-
-!
-!--    In case of large scale forcing with surface data, calculate new pressure
-!--    profile. nzt_rad might be modified by these calls and all required arrays
-!--    will then be re-allocated
-       IF ( large_scale_forcing  .AND.  lsf_surf )  THEN
-          CALL read_sounding_data
-          CALL read_trace_gas_data
-       ENDIF
-!
-!--    Loop over all grid points
-       DO i = nxl, nxr
-          DO j = nys, nyn
-
-!
-!--          Prepare profiles of temperature and H2O volume mixing ratio
-             rrtm_tlev(0,nzb+1) = pt(nzb,j,i) * ( surface_pressure             &
-                                                  / 1000.0_wp )**0.286_wp
-
-             DO k = nzb+1, nzt+1
-                rrtm_tlay(0,k) = pt(k,j,i) * ( (hyp(k) ) / 100000.0_wp         &
-                                 )**0.286_wp + l_d_cp * ql(k,j,i)
-                rrtm_h2ovmr(0,k) = mol_mass_air_d_wv * (q(k,j,i) - ql(k,j,i))
-
-             ENDDO
-
-!
-!--          Avoid temperature/humidity jumps at the top of the LES domain by 
-!--          linear interpolation from nzt+2 to nzt+7
-             DO k = nzt+2, nzt+7
-                rrtm_tlay(0,k) = rrtm_tlay(0,nzt+1)                            &
-                              + ( rrtm_tlay(0,nzt+8) - rrtm_tlay(0,nzt+1) )    &
-                              / ( rrtm_play(0,nzt+8) - rrtm_play(0,nzt+1) )    &
-                              * ( rrtm_play(0,k) - rrtm_play(0,nzt+1) )
-
-                rrtm_h2ovmr(0,k) = rrtm_h2ovmr(0,nzt+1)                        &
-                              + ( rrtm_h2ovmr(0,nzt+8) - rrtm_h2ovmr(0,nzt+1) )&
-                              / ( rrtm_play(0,nzt+8)   - rrtm_play(0,nzt+1)   )&
-                              * ( rrtm_play(0,k) - rrtm_play(0,nzt+1) )
-
-             ENDDO
-
-!--          Linear interpolate to zw grid
-             DO k = nzb+2, nzt+8
-                rrtm_tlev(0,k)   = rrtm_tlay(0,k-1) + (rrtm_tlay(0,k) -        &
-                                   rrtm_tlay(0,k-1))                           &
-                                   / ( rrtm_play(0,k) - rrtm_play(0,k-1) )     &
-                                   * ( rrtm_plev(0,k) - rrtm_play(0,k-1) )
-             ENDDO
-
-
-!
-!--          Calculate liquid water path and cloud fraction for each column.
-!--          Note that LWP is required in g/mÂ² instead of kg/kg m.
-             rrtm_cldfr  = 0.0_wp
-             rrtm_reliq  = 0.0_wp
-             rrtm_cliqwp = 0.0_wp
-             rrtm_icld   = 0
-
-             DO k = nzb+1, nzt+1
-                rrtm_cliqwp(0,k) =  ql(k,j,i) * 1000.0_wp *                    &
-                                    (rrtm_plev(0,k) - rrtm_plev(0,k+1))        &
-                                    * 100.0_wp / g 
-
-                IF ( rrtm_cliqwp(0,k) > 0.0_wp )  THEN
-                   rrtm_cldfr(0,k) = 1.0_wp
-                   IF ( rrtm_icld == 0 )  rrtm_icld = 1
-
-!
-!--                Calculate cloud droplet effective radius
-                   IF ( cloud_physics )  THEN
-                      rrtm_reliq(0,k) = 1.0E6_wp * ( 3.0_wp * ql(k,j,i)        &
-                                        * rho_surface                          &
-                                        / ( 4.0_wp * pi * nc_const * rho_l )   &
-                                        )**0.33333333333333_wp                 &
-                                        * EXP( LOG( sigma_gc )**2 )
-
-                   ELSEIF ( cloud_droplets )  THEN
-                      number_of_particles = prt_count(k,j,i)
-
-                      IF (number_of_particles <= 0)  CYCLE
-                      particles => grid_particles(k,j,i)%particles(1:number_of_particles)
-                      s_r2 = 0.0_wp
-                      s_r3 = 0.0_wp
-
-                      DO  n = 1, number_of_particles
-                         IF ( particles(n)%particle_mask )  THEN
-                            s_r2 = s_r2 + particles(n)%radius**2 * &
-                                   particles(n)%weight_factor
-                            s_r3 = s_r3 + particles(n)%radius**3 * &
-                                   particles(n)%weight_factor
-                         ENDIF
-                      ENDDO
-
-                      IF ( s_r2 > 0.0_wp )  rrtm_reliq(0,k) = s_r3 / s_r2
-
-                   ENDIF
-
-!
-!--                Limit effective radius
-                   IF ( rrtm_reliq(0,k) > 0.0_wp )  THEN
-                      rrtm_reliq(0,k) = MAX(rrtm_reliq(0,k),2.5_wp)
-                      rrtm_reliq(0,k) = MIN(rrtm_reliq(0,k),60.0_wp)
-                  ENDIF
-                ENDIF
-             ENDDO
-
-!
-!--          Set surface temperature
-             rrtm_tsfc = pt(nzb,j,i) * (surface_pressure / 1000.0_wp )**0.286_wp
-
-             IF ( lw_radiation )  THEN
-               CALL rrtmg_lw( 1, nzt_rad      , rrtm_icld    , rrtm_idrv      ,&
-               rrtm_play       , rrtm_plev    , rrtm_tlay    , rrtm_tlev      ,&
-               rrtm_tsfc       , rrtm_h2ovmr  , rrtm_o3vmr   , rrtm_co2vmr    ,&
-               rrtm_ch4vmr     , rrtm_n2ovmr  , rrtm_o2vmr   , rrtm_cfc11vmr  ,&
-               rrtm_cfc12vmr   , rrtm_cfc22vmr, rrtm_ccl4vmr , rrtm_emis      ,&
-               rrtm_inflglw    , rrtm_iceflglw, rrtm_liqflglw, rrtm_cldfr     ,&
-               rrtm_lw_taucld  , rrtm_cicewp  , rrtm_cliqwp  , rrtm_reice     ,& 
-               rrtm_reliq      , rrtm_lw_tauaer,                               &
-               rrtm_lwuflx     , rrtm_lwdflx  , rrtm_lwhr  ,                   &
-               rrtm_lwuflxc    , rrtm_lwdflxc , rrtm_lwhrc ,                   &
-               rrtm_lwuflx_dt  ,  rrtm_lwuflxc_dt )
-
-!
-!--             Save fluxes
-                DO k = nzb, nzt+1
-                   rad_lw_in(k,j,i)  = rrtm_lwdflx(0,k)
-                   rad_lw_out(k,j,i) = rrtm_lwuflx(0,k)
-                ENDDO
-
-!
-!--             Save heating rates (convert from K/d to K/h)
-                DO k = nzb+1, nzt+1
-                   rad_lw_hr(k,j,i)     = rrtm_lwhr(0,k)  * d_hours_day
-                   rad_lw_cs_hr(k,j,i)  = rrtm_lwhrc(0,k) * d_hours_day
-                ENDDO
-
-!
-!--             Save change in LW heating rate
-                rad_lw_out_change_0(j,i) = rrtm_lwuflx_dt(0,nzb)
-
-             ENDIF
-
-             IF ( sw_radiation .AND. sun_up )  THEN
-                CALL rrtmg_sw( 1, nzt_rad      , rrtm_icld  , rrtm_iaer       ,&
-               rrtm_play       , rrtm_plev    , rrtm_tlay  , rrtm_tlev        ,&
-               rrtm_tsfc       , rrtm_h2ovmr  , rrtm_o3vmr , rrtm_co2vmr      ,&
-               rrtm_ch4vmr     , rrtm_n2ovmr  , rrtm_o2vmr , rrtm_asdir(:,j,i),&
-               rrtm_asdif(:,j,i), rrtm_aldir(:,j,i), rrtm_aldif(:,j,i), zenith,&
-               0.0_wp          , day          , solar_constant,   rrtm_inflgsw,&
-               rrtm_iceflgsw   , rrtm_liqflgsw, rrtm_cldfr , rrtm_sw_taucld   ,&
-               rrtm_sw_ssacld  , rrtm_sw_asmcld, rrtm_sw_fsfcld, rrtm_cicewp  ,&
-               rrtm_cliqwp     , rrtm_reice   , rrtm_reliq , rrtm_sw_tauaer   ,&
-               rrtm_sw_ssaaer     , rrtm_sw_asmaer  , rrtm_sw_ecaer ,          &
-               rrtm_swuflx     , rrtm_swdflx  , rrtm_swhr  ,                   &
-               rrtm_swuflxc    , rrtm_swdflxc , rrtm_swhrc )
-  
-!
-!--             Save fluxes
-                DO k = nzb, nzt+1
-                   rad_sw_in(k,j,i)  = rrtm_swdflx(0,k)
-                   rad_sw_out(k,j,i) = rrtm_swuflx(0,k)
-                ENDDO
-
-!
-!--             Save heating rates (convert from K/d to K/s)
-                DO k = nzb+1, nzt+1
-                   rad_sw_hr(k,j,i)     = rrtm_swhr(0,k)  * d_hours_day
-                   rad_sw_cs_hr(k,j,i)  = rrtm_swhrc(0,k) * d_hours_day
-                ENDDO
-
-             ENDIF
-
-!
-!--          Calculate surface net radiation
-             rad_net(j,i) = rad_sw_in(nzb,j,i) - rad_sw_out(nzb,j,i)           &
-                            + rad_lw_in(nzb,j,i) - rad_lw_out(nzb,j,i)
-
-          ENDDO
-       ENDDO
-
-       CALL exchange_horiz( rad_lw_in,  nbgp )
-       CALL exchange_horiz( rad_lw_out, nbgp )
-       CALL exchange_horiz( rad_lw_hr,    nbgp )
-       CALL exchange_horiz( rad_lw_cs_hr, nbgp )
-
-       CALL exchange_horiz( rad_sw_in,  nbgp )
-       CALL exchange_horiz( rad_sw_out, nbgp ) 
-       CALL exchange_horiz( rad_sw_hr,    nbgp )
-       CALL exchange_horiz( rad_sw_cs_hr, nbgp )
-
-       CALL exchange_horiz_2d( rad_net, nbgp )
-       CALL exchange_horiz_2d( rad_lw_out_change_0, nbgp )
-#endif
-
-    END SUBROUTINE radiation_rrtmg
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Calculate the cosine of the zenith angle (variable is called zenith)
-!------------------------------------------------------------------------------!
-    SUBROUTINE calc_zenith
-
-       IMPLICIT NONE
-
-       REAL(wp) ::  declination,  & !< solar declination angle
-                    hour_angle      !< solar hour angle
-!
-!--    Calculate current day and time based on the initial values and simulation
-!--    time
-       day = day_init + INT(FLOOR( (time_utc_init + time_since_reference_point)    &
-                               / 86400.0_wp ), KIND=iwp)
-       time_utc = MOD((time_utc_init + time_since_reference_point), 86400.0_wp)
-
-
-!
-!--    Calculate solar declination and hour angle   
-       declination = ASIN( decl_1 * SIN(decl_2 * REAL(day, KIND=wp) - decl_3) )
-       hour_angle  = 2.0_wp * pi * (time_utc / 86400.0_wp) + lon - pi
-
-!
-!--    Calculate zenith angle
-       zenith(0) = SIN(lat) * SIN(declination) + COS(lat) * COS(declination)      &
-                                            * COS(hour_angle)
-       zenith(0) = MAX(0.0_wp,zenith(0))
-
-!
-!--    Check if the sun is up (otheriwse shortwave calculations can be skipped)
-       IF ( zenith(0) > 0.0_wp )  THEN
-          sun_up = .TRUE.
-       ELSE
-          sun_up = .FALSE.
-       END IF
-
-    END SUBROUTINE calc_zenith
-
-#if defined ( __rrtmg ) && defined ( __netcdf )
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Calculates surface albedo components based on Briegleb (1992) and 
-!> Briegleb et al. (1986)
-!------------------------------------------------------------------------------!
-    SUBROUTINE calc_albedo
-
-        IMPLICIT NONE
-
-        IF ( sun_up )  THEN
-!
-!--        Ocean
-           IF ( albedo_type == 1 )  THEN
-              rrtm_aldir(0,:,:) = 0.026_wp / ( zenith(0)**1.7_wp + 0.065_wp )  &
-                                  + 0.15_wp * ( zenith(0) - 0.1_wp )           &
-                                            * ( zenith(0) - 0.5_wp )           &
-                                            * ( zenith(0) - 1.0_wp )
-              rrtm_asdir(0,:,:) = rrtm_aldir(0,:,:)
-!
-!--        Snow
-           ELSEIF ( albedo_type == 16 )  THEN
-              IF ( zenith(0) < 0.5_wp )  THEN
-                 rrtm_aldir(0,:,:) = 0.5_wp * (1.0_wp - aldif)                 &
-                                     * ( 3.0_wp / (1.0_wp + 4.0_wp             &
-                                     * zenith(0))) - 1.0_wp
-                 rrtm_asdir(0,:,:) = 0.5_wp * (1.0_wp - asdif)                 &
-                                     * ( 3.0_wp / (1.0_wp + 4.0_wp             &
-                                     * zenith(0))) - 1.0_wp
-
-                 rrtm_aldir(0,:,:) = MIN(0.98_wp, rrtm_aldir(0,:,:))
-                 rrtm_asdir(0,:,:) = MIN(0.98_wp, rrtm_asdir(0,:,:))
-              ELSE
-                 rrtm_aldir(0,:,:) = aldif
-                 rrtm_asdir(0,:,:) = asdif
-              ENDIF
-!
-!--        Sea ice
-           ELSEIF ( albedo_type == 15 )  THEN
-                 rrtm_aldir(0,:,:) = aldif
-                 rrtm_asdir(0,:,:) = asdif
-
-!
-!--        Asphalt
-           ELSEIF ( albedo_type == 17 )  THEN
-                 rrtm_aldir(0,:,:) = aldif
-                 rrtm_asdir(0,:,:) = asdif
-!
-!--        Land surfaces
-           ELSE
-              SELECT CASE ( albedo_type )
-
-!
-!--              Surface types with strong zenith dependence
-                 CASE ( 1, 2, 3, 4, 11, 12, 13 )
-                    rrtm_aldir(0,:,:) = aldif * 1.4_wp /                       &
-                                        (1.0_wp + 0.8_wp * zenith(0))
-                    rrtm_asdir(0,:,:) = asdif * 1.4_wp /                       &
-                                        (1.0_wp + 0.8_wp * zenith(0))
-!
-!--              Surface types with weak zenith dependence
-                 CASE ( 5, 6, 7, 8, 9, 10, 14 )
-                    rrtm_aldir(0,:,:) = aldif * 1.1_wp /                       &
-                                        (1.0_wp + 0.2_wp * zenith(0))
-                    rrtm_asdir(0,:,:) = asdif * 1.1_wp /                       &
-                                        (1.0_wp + 0.2_wp * zenith(0))
-
-                 CASE DEFAULT
-
-              END SELECT
-           ENDIF
-!
-!--        Diffusive albedo is taken from Table 2
-           rrtm_aldif(0,:,:) = aldif
-           rrtm_asdif(0,:,:) = asdif
-
-        ELSE
-
-           rrtm_aldir(0,:,:) = 0.0_wp
-           rrtm_asdir(0,:,:) = 0.0_wp
-           rrtm_aldif(0,:,:) = 0.0_wp
-           rrtm_asdif(0,:,:) = 0.0_wp
-        ENDIF
-    END SUBROUTINE calc_albedo
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Read sounding data (pressure and temperature) from RADIATION_DATA.
-!------------------------------------------------------------------------------!
-    SUBROUTINE read_sounding_data
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) :: id,           & !< NetCDF id of input file
-                       id_dim_zrad,  & !< pressure level id in the NetCDF file
-                       id_var,       & !< NetCDF variable id
-                       k,            & !< loop index
-                       nz_snd,       & !< number of vertical levels in the sounding data
-                       nz_snd_start, & !< start vertical index for sounding data to be used
-                       nz_snd_end      !< end vertical index for souding data to be used
-
-       REAL(wp) :: t_surface           !< actual surface temperature
-
-       REAL(wp), DIMENSION(:), ALLOCATABLE ::  hyp_snd_tmp, & !< temporary hydrostatic pressure profile (sounding)
-                                               t_snd_tmp      !< temporary temperature profile (sounding)
-
-!
-!--    In case of updates, deallocate arrays first (sufficient to check one
-!--    array as the others are automatically allocated). This is required
-!--    because nzt_rad might change during the update
-       IF ( ALLOCATED ( hyp_snd ) )  THEN
-          DEALLOCATE( hyp_snd )
-          DEALLOCATE( t_snd )
-          DEALLOCATE( q_snd  )
-          DEALLOCATE ( rrtm_play )
-          DEALLOCATE ( rrtm_plev )
-          DEALLOCATE ( rrtm_tlay )
-          DEALLOCATE ( rrtm_tlev )
-
-          DEALLOCATE ( rrtm_h2ovmr )
-          DEALLOCATE ( rrtm_cicewp )
-          DEALLOCATE ( rrtm_cldfr )
-          DEALLOCATE ( rrtm_cliqwp )
-          DEALLOCATE ( rrtm_reice )
-          DEALLOCATE ( rrtm_reliq )
-          DEALLOCATE ( rrtm_lw_taucld )
-          DEALLOCATE ( rrtm_lw_tauaer )
-
-          DEALLOCATE ( rrtm_lwdflx  )
-          DEALLOCATE ( rrtm_lwdflxc )
-          DEALLOCATE ( rrtm_lwuflx  )
-          DEALLOCATE ( rrtm_lwuflxc )
-          DEALLOCATE ( rrtm_lwuflx_dt )
-          DEALLOCATE ( rrtm_lwuflxc_dt )
-          DEALLOCATE ( rrtm_lwhr  )
-          DEALLOCATE ( rrtm_lwhrc )
-
-          DEALLOCATE ( rrtm_sw_taucld )
-          DEALLOCATE ( rrtm_sw_ssacld )
-          DEALLOCATE ( rrtm_sw_asmcld )
-          DEALLOCATE ( rrtm_sw_fsfcld )
-          DEALLOCATE ( rrtm_sw_tauaer )
-          DEALLOCATE ( rrtm_sw_ssaaer )
-          DEALLOCATE ( rrtm_sw_asmaer ) 
-          DEALLOCATE ( rrtm_sw_ecaer )   
- 
-          DEALLOCATE ( rrtm_swdflx  )
-          DEALLOCATE ( rrtm_swdflxc )
-          DEALLOCATE ( rrtm_swuflx  )
-          DEALLOCATE ( rrtm_swuflxc )
-          DEALLOCATE ( rrtm_swhr  )
-          DEALLOCATE ( rrtm_swhrc )
-
-       ENDIF
-
-!
-!--    Open file for reading
-       nc_stat = NF90_OPEN( rrtm_input_file, NF90_NOWRITE, id )
-       CALL netcdf_handle_error_rad( 'read_sounding_data', 549 )
-
-!
-!--    Inquire dimension of z axis and save in nz_snd
-       nc_stat = NF90_INQ_DIMID( id, "Pressure", id_dim_zrad )
-       nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim_zrad, len = nz_snd )
-       CALL netcdf_handle_error_rad( 'read_sounding_data', 551 )
-
-!
-! !--    Allocate temporary array for storing pressure data
-       ALLOCATE( hyp_snd_tmp(1:nz_snd) )
-       hyp_snd_tmp = 0.0_wp
-
-
-!--    Read pressure from file
-       nc_stat = NF90_INQ_VARID( id, "Pressure", id_var )
-       nc_stat = NF90_GET_VAR( id, id_var, hyp_snd_tmp(:), start = (/1/),      &
-                               count = (/nz_snd/) )
-       CALL netcdf_handle_error_rad( 'read_sounding_data', 552 )
-
-!
-!--    Allocate temporary array for storing temperature data
-       ALLOCATE( t_snd_tmp(1:nz_snd) )
-       t_snd_tmp = 0.0_wp
-
-!
-!--    Read temperature from file
-       nc_stat = NF90_INQ_VARID( id, "ReferenceTemperature", id_var )
-       nc_stat = NF90_GET_VAR( id, id_var, t_snd_tmp(:), start = (/1/),        &
-                               count = (/nz_snd/) )
-       CALL netcdf_handle_error_rad( 'read_sounding_data', 553 )
-
-!
-!--    Calculate start of sounding data
-       nz_snd_start = nz_snd + 1
-       nz_snd_end   = nz_snd + 1
-
-!
-!--    Start filling vertical dimension at 10hPa above the model domain (hyp is
-!--    in Pa, hyp_snd in hPa).
-       DO  k = 1, nz_snd
-          IF ( hyp_snd_tmp(k) < ( hyp(nzt+1) - 1000.0_wp) * 0.01_wp )  THEN
-             nz_snd_start = k
-             EXIT
-          END IF
-       END DO
-
-       IF ( nz_snd_start <= nz_snd )  THEN
-          nz_snd_end = nz_snd
-       END IF
-
-
-!
-!--    Calculate of total grid points for RRTMG calculations
-       nzt_rad = nzt + nz_snd_end - nz_snd_start + 1
-
-!
-!--    Save data above LES domain in hyp_snd, t_snd and q_snd
-!--    Note: q_snd_tmp is not calculated at the moment (dry residual atmosphere)
-       ALLOCATE( hyp_snd(nzb+1:nzt_rad) )
-       ALLOCATE( t_snd(nzb+1:nzt_rad)   )
-       ALLOCATE( q_snd(nzb+1:nzt_rad)   )
-       hyp_snd = 0.0_wp
-       t_snd = 0.0_wp
-       q_snd = 0.0_wp
-
-       hyp_snd(nzt+2:nzt_rad) = hyp_snd_tmp(nz_snd_start+1:nz_snd_end)
-       t_snd(nzt+2:nzt_rad)   = t_snd_tmp(nz_snd_start+1:nz_snd_end)
-
-       nc_stat = NF90_CLOSE( id )
-
-!
-!--    Calculate pressure levels on zu and zw grid. Sounding data is added at 
-!--    top of the LES domain. This routine does not consider horizontal or 
-!--    vertical variability of pressure and temperature
-       ALLOCATE ( rrtm_play(0:0,nzb+1:nzt_rad+1)   )
-       ALLOCATE ( rrtm_plev(0:0,nzb+1:nzt_rad+2)   )
-
-       t_surface = pt_surface * ( surface_pressure / 1000.0_wp )**0.286_wp
-       DO k = nzb+1, nzt+1
-          rrtm_play(0,k) = hyp(k) * 0.01_wp
-          rrtm_plev(0,k) = surface_pressure * ( (t_surface - g/cp * zw(k-1)) / &
-                         t_surface )**(1.0_wp/0.286_wp)
-       ENDDO
-
-       DO k = nzt+2, nzt_rad
-          rrtm_play(0,k) = hyp_snd(k)
-          rrtm_plev(0,k) = 0.5_wp * ( rrtm_play(0,k) + rrtm_play(0,k-1) )
-       ENDDO
-       rrtm_plev(0,nzt_rad+1) = MAX( 0.5 * hyp_snd(nzt_rad),                   &
-                                   1.5 * hyp_snd(nzt_rad)                      &
-                                 - 0.5 * hyp_snd(nzt_rad-1) )
-       rrtm_plev(0,nzt_rad+2)  = MIN( 1.0E-4_wp,                               &
-                                      0.25_wp * rrtm_plev(0,nzt_rad+1) )
-
-       rrtm_play(0,nzt_rad+1) = 0.5 * rrtm_plev(0,nzt_rad+1)
-
-!
-!--    Calculate temperature/humidity levels at top of the LES domain. 
-!--    Currently, the temperature is taken from sounding data (might lead to a 
-!--    temperature jump at interface. To do: Humidity is currently not 
-!--    calculated above the LES domain.
-       ALLOCATE ( rrtm_tlay(0:0,nzb+1:nzt_rad+1)   )
-       ALLOCATE ( rrtm_tlev(0:0,nzb+1:nzt_rad+2)   )
-       ALLOCATE ( rrtm_h2ovmr(0:0,nzb+1:nzt_rad+1) )
-
-       DO k = nzt+8, nzt_rad
-          rrtm_tlay(0,k)   = t_snd(k)
-          rrtm_h2ovmr(0,k) = q_snd(k)
-       ENDDO
-       rrtm_tlay(0,nzt_rad+1) = 2.0_wp * rrtm_tlay(0,nzt_rad)                 &
-                                - rrtm_tlay(0,nzt_rad-1)
-       DO k = nzt+9, nzt_rad+1
-          rrtm_tlev(0,k)   = rrtm_tlay(0,k-1) + (rrtm_tlay(0,k)                &
-                             - rrtm_tlay(0,k-1))                               &
-                             / ( rrtm_play(0,k) - rrtm_play(0,k-1) )           &
-                             * ( rrtm_plev(0,k) - rrtm_play(0,k-1) )
-       ENDDO
-       rrtm_h2ovmr(0,nzt_rad+1) = rrtm_h2ovmr(0,nzt_rad)
-
-       rrtm_tlev(0,nzt_rad+2)   = 2.0_wp * rrtm_tlay(0,nzt_rad+1)              &
-                                  - rrtm_tlev(0,nzt_rad)
-!
-!--    Allocate remaining RRTMG arrays
-       ALLOCATE ( rrtm_cicewp(0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_cldfr(0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_cliqwp(0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_reice(0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_reliq(0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_lw_taucld(1:nbndlw+1,0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_lw_tauaer(0:0,nzb+1:nzt_rad+1,1:nbndlw+1) )
-       ALLOCATE ( rrtm_sw_taucld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_sw_ssacld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_sw_asmcld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_sw_fsfcld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
-       ALLOCATE ( rrtm_sw_tauaer(0:0,nzb+1:nzt_rad+1,1:nbndsw+1) )
-       ALLOCATE ( rrtm_sw_ssaaer(0:0,nzb+1:nzt_rad+1,1:nbndsw+1) )
-       ALLOCATE ( rrtm_sw_asmaer(0:0,nzb+1:nzt_rad+1,1:nbndsw+1) ) 
-       ALLOCATE ( rrtm_sw_ecaer(0:0,nzb+1:nzt_rad+1,1:naerec+1) )    
-
-!
-!--    The ice phase is currently not considered in PALM
-       rrtm_cicewp = 0.0_wp
-       rrtm_reice  = 0.0_wp
-
-!
-!--    Set other parameters (move to NAMELIST parameters in the future)
-       rrtm_lw_tauaer = 0.0_wp
-       rrtm_lw_taucld = 0.0_wp
-       rrtm_sw_taucld = 0.0_wp
-       rrtm_sw_ssacld = 0.0_wp
-       rrtm_sw_asmcld = 0.0_wp
-       rrtm_sw_fsfcld = 0.0_wp
-       rrtm_sw_tauaer = 0.0_wp
-       rrtm_sw_ssaaer = 0.0_wp
-       rrtm_sw_asmaer = 0.0_wp
-       rrtm_sw_ecaer  = 0.0_wp
-
-
-       ALLOCATE ( rrtm_swdflx(0:0,nzb:nzt_rad+1)  )
-       ALLOCATE ( rrtm_swuflx(0:0,nzb:nzt_rad+1)  )
-       ALLOCATE ( rrtm_swhr(0:0,nzb+1:nzt_rad+1)  )
-       ALLOCATE ( rrtm_swuflxc(0:0,nzb:nzt_rad+1) )
-       ALLOCATE ( rrtm_swdflxc(0:0,nzb:nzt_rad+1) )
-       ALLOCATE ( rrtm_swhrc(0:0,nzb+1:nzt_rad+1) )
-
-       rrtm_swdflx  = 0.0_wp
-       rrtm_swuflx  = 0.0_wp
-       rrtm_swhr    = 0.0_wp  
-       rrtm_swuflxc = 0.0_wp
-       rrtm_swdflxc = 0.0_wp
-       rrtm_swhrc   = 0.0_wp
-
-       ALLOCATE ( rrtm_lwdflx(0:0,nzb:nzt_rad+1)  )
-       ALLOCATE ( rrtm_lwuflx(0:0,nzb:nzt_rad+1)  )
-       ALLOCATE ( rrtm_lwhr(0:0,nzb+1:nzt_rad+1)  )
-       ALLOCATE ( rrtm_lwuflxc(0:0,nzb:nzt_rad+1) )
-       ALLOCATE ( rrtm_lwdflxc(0:0,nzb:nzt_rad+1) )
-       ALLOCATE ( rrtm_lwhrc(0:0,nzb+1:nzt_rad+1) )
-
-       rrtm_lwdflx  = 0.0_wp
-       rrtm_lwuflx  = 0.0_wp
-       rrtm_lwhr    = 0.0_wp  
-       rrtm_lwuflxc = 0.0_wp
-       rrtm_lwdflxc = 0.0_wp
-       rrtm_lwhrc   = 0.0_wp
-
-       ALLOCATE ( rrtm_lwuflx_dt(0:0,nzb:nzt_rad+1) )
-       ALLOCATE ( rrtm_lwuflxc_dt(0:0,nzb:nzt_rad+1) )
-
-       rrtm_lwuflx_dt = 0.0_wp
-       rrtm_lwuflxc_dt = 0.0_wp
-
-    END SUBROUTINE read_sounding_data
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Read trace gas data from file
-!------------------------------------------------------------------------------!
-    SUBROUTINE read_trace_gas_data
-
-       USE rrsw_ncpar
-
-       IMPLICIT NONE
-
-       INTEGER(iwp), PARAMETER :: num_trace_gases = 9 !< number of trace gases (absorbers)
-
-       CHARACTER(LEN=5), DIMENSION(num_trace_gases), PARAMETER ::              & !< trace gas names
-           trace_names = (/'O3   ', 'CO2  ', 'CH4  ', 'N2O  ', 'O2   ',        &
-                           'CFC11', 'CFC12', 'CFC22', 'CCL4 '/)
-
-       INTEGER(iwp) :: id,     & !< NetCDF id
-                       k,      & !< loop index
-                       m,      & !< loop index
-                       n,      & !< loop index
-                       nabs,   & !< number of absorbers
-                       np,     & !< number of pressure levels
-                       id_abs, & !< NetCDF id of the respective absorber
-                       id_dim, & !< NetCDF id of asborber's dimension
-                       id_var    !< NetCDf id ot the absorber
-
-       REAL(wp) :: p_mls_l, p_mls_u, p_wgt_l, p_wgt_u, p_mls_m
-
-
-       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  p_mls,         & !< pressure levels for the absorbers
-                                                 rrtm_play_tmp, & !< temporary array for pressure zu-levels
-                                                 rrtm_plev_tmp, & !< temporary array for pressure zw-levels
-                                                 trace_path_tmp   !< temporary array for storing trace gas path data
-
-       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  trace_mls,      & !< array for storing the absorber amounts
-                                                 trace_mls_path, & !< array for storing trace gas path data
-                                                 trace_mls_tmp     !< temporary array for storing trace gas data
-
-
-!
-!--    In case of updates, deallocate arrays first (sufficient to check one
-!--    array as the others are automatically allocated)
-       IF ( ALLOCATED ( rrtm_o3vmr ) )  THEN
-          DEALLOCATE ( rrtm_o3vmr  )
-          DEALLOCATE ( rrtm_co2vmr )
-          DEALLOCATE ( rrtm_ch4vmr )
-          DEALLOCATE ( rrtm_n2ovmr )
-          DEALLOCATE ( rrtm_o2vmr  )
-          DEALLOCATE ( rrtm_cfc11vmr )
-          DEALLOCATE ( rrtm_cfc12vmr )
-          DEALLOCATE ( rrtm_cfc22vmr )
-          DEALLOCATE ( rrtm_ccl4vmr  )
-       ENDIF
-
-!
-!--    Allocate trace gas profiles
-       ALLOCATE ( rrtm_o3vmr(0:0,1:nzt_rad+1)  )
-       ALLOCATE ( rrtm_co2vmr(0:0,1:nzt_rad+1) )
-       ALLOCATE ( rrtm_ch4vmr(0:0,1:nzt_rad+1) )
-       ALLOCATE ( rrtm_n2ovmr(0:0,1:nzt_rad+1) )
-       ALLOCATE ( rrtm_o2vmr(0:0,1:nzt_rad+1)  )
-       ALLOCATE ( rrtm_cfc11vmr(0:0,1:nzt_rad+1) )
-       ALLOCATE ( rrtm_cfc12vmr(0:0,1:nzt_rad+1) )
-       ALLOCATE ( rrtm_cfc22vmr(0:0,1:nzt_rad+1) )
-       ALLOCATE ( rrtm_ccl4vmr(0:0,1:nzt_rad+1)  )
-
-!
-!--    Open file for reading
-       nc_stat = NF90_OPEN( rrtm_input_file, NF90_NOWRITE, id )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 549 )
-!
-!--    Inquire dimension ids and dimensions
-       nc_stat = NF90_INQ_DIMID( id, "Pressure", id_dim )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-       nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim, len = np) 
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-
-       nc_stat = NF90_INQ_DIMID( id, "Absorber", id_dim )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-       nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim, len = nabs ) 
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-   
-
-!
-!--    Allocate pressure, and trace gas arrays     
-       ALLOCATE( p_mls(1:np) )
-       ALLOCATE( trace_mls(1:num_trace_gases,1:np) ) 
-       ALLOCATE( trace_mls_tmp(1:nabs,1:np) ) 
-
-
-       nc_stat = NF90_INQ_VARID( id, "Pressure", id_var )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-       nc_stat = NF90_GET_VAR( id, id_var, p_mls )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-
-       nc_stat = NF90_INQ_VARID( id, "AbsorberAmountMLS", id_var )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-       nc_stat = NF90_GET_VAR( id, id_var, trace_mls_tmp )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
-
-
-!
-!--    Write absorber amounts (mls) to trace_mls
-       DO n = 1, num_trace_gases
-          CALL getAbsorberIndex( TRIM( trace_names(n) ), id_abs )
-
-          trace_mls(n,1:np) = trace_mls_tmp(id_abs,1:np)
-
-!
-!--       Replace missing values by zero
-          WHERE ( trace_mls(n,:) > 2.0_wp )  
-             trace_mls(n,:) = 0.0_wp
-          END WHERE
-       END DO
-
-       DEALLOCATE ( trace_mls_tmp )
-
-       nc_stat = NF90_CLOSE( id )
-       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 551 )
-
-!
-!--    Add extra pressure level for calculations of the trace gas paths
-       ALLOCATE ( rrtm_play_tmp(1:nzt_rad+1) )
-       ALLOCATE ( rrtm_plev_tmp(1:nzt_rad+2) )
-
-       rrtm_play_tmp(1:nzt_rad)   = rrtm_play(0,1:nzt_rad) 
-       rrtm_plev_tmp(1:nzt_rad+1) = rrtm_plev(0,1:nzt_rad+1)
-       rrtm_play_tmp(nzt_rad+1)   = rrtm_plev(0,nzt_rad+1) * 0.5_wp
-       rrtm_plev_tmp(nzt_rad+2)   = MIN( 1.0E-4_wp, 0.25_wp                    &
-                                         * rrtm_plev(0,nzt_rad+1) )
- 
-!
-!--    Calculate trace gas path (zero at surface) with interpolation to the
-!--    sounding levels
-       ALLOCATE ( trace_mls_path(1:nzt_rad+2,1:num_trace_gases) )
-
-       trace_mls_path(nzb+1,:) = 0.0_wp
-       
-       DO k = nzb+2, nzt_rad+2
-          DO m = 1, num_trace_gases
-             trace_mls_path(k,m) = trace_mls_path(k-1,m)
-
-!
-!--          When the pressure level is higher than the trace gas pressure
-!--          level, assume that 
-             IF ( rrtm_plev_tmp(k-1) > p_mls(1) )  THEN             
-                
-                trace_mls_path(k,m) = trace_mls_path(k,m) + trace_mls(m,1)     &
-                                      * ( rrtm_plev_tmp(k-1)                   &
-                                          - MAX( p_mls(1), rrtm_plev_tmp(k) )  &
-                                        ) / g
-             ENDIF
-
-!
-!--          Integrate for each sounding level from the contributing p_mls 
-!--          levels
-             DO n = 2, np
-!
-!--             Limit p_mls so that it is within the model level
-                p_mls_u = MIN( rrtm_plev_tmp(k-1),                             &
-                          MAX( rrtm_plev_tmp(k), p_mls(n) ) )
-                p_mls_l = MIN( rrtm_plev_tmp(k-1),                             &
-                          MAX( rrtm_plev_tmp(k), p_mls(n-1) ) )
-
-                IF ( p_mls_l > p_mls_u )  THEN
-
-!
-!--                Calculate weights for interpolation
-                   p_mls_m = 0.5_wp * (p_mls_l + p_mls_u)
-                   p_wgt_u = (p_mls(n-1) - p_mls_m) / (p_mls(n-1) - p_mls(n))
-                   p_wgt_l = (p_mls_m - p_mls(n))   / (p_mls(n-1) - p_mls(n))
-
-!
-!--                Add level to trace gas path
-                   trace_mls_path(k,m) = trace_mls_path(k,m)                   &
-                                         +  ( p_wgt_u * trace_mls(m,n)         &
-                                            + p_wgt_l * trace_mls(m,n-1) )     &
-                                         * (p_mls_l - p_mls_u) / g
-                ENDIF
-             ENDDO
-
-             IF ( rrtm_plev_tmp(k) < p_mls(np) )  THEN 
-                trace_mls_path(k,m) = trace_mls_path(k,m) + trace_mls(m,np)    &
-                                      * ( MIN( rrtm_plev_tmp(k-1), p_mls(np) ) &
-                                          - rrtm_plev_tmp(k)                   &
-                                        ) / g 
-             ENDIF  
-          ENDDO
-       ENDDO
-
-
-!
-!--    Prepare trace gas path profiles
-       ALLOCATE ( trace_path_tmp(1:nzt_rad+1) )
-
-       DO m = 1, num_trace_gases
-
-          trace_path_tmp(1:nzt_rad+1) = ( trace_mls_path(2:nzt_rad+2,m)        &
-                                       - trace_mls_path(1:nzt_rad+1,m) ) * g   &
-                                       / ( rrtm_plev_tmp(1:nzt_rad+1)          &
-                                       - rrtm_plev_tmp(2:nzt_rad+2) )
-
-!
-!--       Save trace gas paths to the respective arrays
-          SELECT CASE ( TRIM( trace_names(m) ) )
-
-             CASE ( 'O3' )
-
-                rrtm_o3vmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'CO2' )
-
-                rrtm_co2vmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'CH4' )
-
-                rrtm_ch4vmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'N2O' )
-
-                rrtm_n2ovmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'O2' )
-
-                rrtm_o2vmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'CFC11' )
-
-                rrtm_cfc11vmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'CFC12' )
-
-                rrtm_cfc12vmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'CFC22' )
-
-                rrtm_cfc22vmr(0,:) = trace_path_tmp(:)
-
-             CASE ( 'CCL4' )
-
-                rrtm_ccl4vmr(0,:) = trace_path_tmp(:)
-
-             CASE DEFAULT
-
-          END SELECT
-
-       ENDDO
-
-       DEALLOCATE ( trace_path_tmp )
-       DEALLOCATE ( trace_mls_path )
-       DEALLOCATE ( rrtm_play_tmp )
-       DEALLOCATE ( rrtm_plev_tmp )
-       DEALLOCATE ( trace_mls )
-       DEALLOCATE ( p_mls )
-
-    END SUBROUTINE read_trace_gas_data
-
-    SUBROUTINE netcdf_handle_error_rad( routine_name, errno )
-
-       USE control_parameters,                                                 &
-           ONLY:  message_string
-
-       USE NETCDF
-
-       USE pegrid
-
-       IMPLICIT NONE
-
-       CHARACTER(LEN=6) ::  message_identifier
-       CHARACTER(LEN=*) ::  routine_name
-
-       INTEGER(iwp) ::  errno
-
-       IF ( nc_stat /= NF90_NOERR )  THEN
-
-          WRITE( message_identifier, '(''NC'',I4.4)' )  errno
-          message_string = TRIM( NF90_STRERROR( nc_stat ) )
-
-          CALL message( routine_name, message_identifier, 2, 2, 0, 6, 1 )
-
-       ENDIF
-
-    END SUBROUTINE netcdf_handle_error_rad
-#endif
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Calculate temperature tendency due to radiative cooling/heating.
-!> Cache-optimized version.
-!------------------------------------------------------------------------------!
-    SUBROUTINE radiation_tendency_ij ( i, j, tend )
-
-       USE cloud_parameters,                                                   &
-           ONLY:  pt_d_t
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) :: i, j, k !< loop indices
-
-       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tend !< pt tendency term
-
-#if defined ( __rrtmg )
-!
-!--    Calculate tendency based on heating rate
-       DO k = nzb+1, nzt+1
-          tend(k,j,i) = tend(k,j,i) + (rad_lw_hr(k,j,i) + rad_sw_hr(k,j,i))    &
-                                      * pt_d_t(k) * d_seconds_hour
-       ENDDO
-
-#endif
-
-    END SUBROUTINE radiation_tendency_ij
-
-
-!------------------------------------------------------------------------------!
-! Description:
-! ------------
-!> Calculate temperature tendency due to radiative cooling/heating.
-!> Vector-optimized version
-!------------------------------------------------------------------------------!
-    SUBROUTINE radiation_tendency ( tend )
-
-       USE cloud_parameters,                                                   &
-           ONLY:  pt_d_t
-
-       USE indices,                                                            &
-           ONLY:  nxl, nxr, nyn, nys
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) :: i, j, k !< loop indices
-
-       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tend !< pt tendency term
-
-#if defined ( __rrtmg )
-!
-!--    Calculate tendency based on heating rate
-       DO  i = nxl, nxr
-          DO  j = nys, nyn
-             DO k = nzb+1, nzt+1
-                tend(k,j,i) = tend(k,j,i) + ( rad_lw_hr(k,j,i)                 &
-                                            +  rad_sw_hr(k,j,i) ) * pt_d_t(k)  &
-                                            * d_seconds_hour
-             ENDDO
-         ENDDO
-       ENDDO
-#endif
-
-    END SUBROUTINE radiation_tendency
-
- END MODULE radiation_model_mod
Index: palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- palm/trunk/SOURCE/radiation_model_mod.f90	(revision 1826)
+++ palm/trunk/SOURCE/radiation_model_mod.f90	(revision 1826)
@@ -0,0 +1,2145 @@
+!> @file radiation_model_mod.f90
+!--------------------------------------------------------------------------------!
+! This file is part of PALM.
+!
+! PALM is free software: you can redistribute it and/or modify it under the terms
+! of the GNU General Public License as published by the Free Software Foundation,
+! either version 3 of the License, or (at your option) any later version.
+!
+! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
+! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License along with
+! PALM. If not, see <http://www.gnu.org/licenses/>.
+!
+! Copyright 1997-2016 Leibniz Universitaet Hannover
+!--------------------------------------------------------------------------------!
+!
+! Current revisions:
+! -----------------
+! Further modularization.
+! 
+! Former revisions:
+! -----------------
+! $Id$
+!
+! 1788 2016-03-10 11:01:04Z maronga
+! Added new albedo class for pavements / roads.
+!
+! 1783 2016-03-06 18:36:17Z raasch
+! palm-netcdf-module removed in order to avoid a circular module dependency,
+! netcdf-variables moved to netcdf-module, new routine netcdf_handle_error_rad
+! added
+!
+! 1757 2016-02-22 15:49:32Z maronga
+! Added parameter unscheduled_radiation_calls. Bugfix: interpolation of sounding
+! profiles for pressure and temperature above the LES domain.
+! 
+! 1709 2015-11-04 14:47:01Z maronga
+! Bugfix: set initial value for rrtm_lwuflx_dt to zero, small formatting
+! corrections
+! 
+! 1701 2015-11-02 07:43:04Z maronga
+! Bugfixes: wrong index for output of timeseries, setting of nz_snd_end
+! 
+! 1691 2015-10-26 16:17:44Z maronga
+! Added option for spin-up runs without radiation (skip_time_do_radiation). Bugfix
+! in calculation of pressure profiles. Bugfix in calculation of trace gas profiles.
+! Added output of radiative heating rates.
+! 
+! 1682 2015-10-07 23:56:08Z knoop
+! Code annotations made doxygen readable 
+! 
+! 1606 2015-06-29 10:43:37Z maronga
+! Added preprocessor directive __netcdf to allow for compiling without netCDF.
+! Note, however, that RRTMG cannot be used without netCDF.
+! 
+! 1590 2015-05-08 13:56:27Z maronga
+! Bugfix: definition of character strings requires same length for all elements
+! 
+! 1587 2015-05-04 14:19:01Z maronga
+! Added albedo class for snow
+! 
+! 1585 2015-04-30 07:05:52Z maronga
+! Added support for RRTMG
+! 
+! 1571 2015-03-12 16:12:49Z maronga
+! Added missing KIND attribute. Removed upper-case variable names
+! 
+! 1551 2015-03-03 14:18:16Z maronga
+! Added support for data output. Various variables have been renamed. Added
+! interface for different radiation schemes (currently: clear-sky, constant, and
+! RRTM (not yet implemented).
+! 
+! 1496 2014-12-02 17:25:50Z maronga
+! Initial revision
+! 
+!
+! Description:
+! ------------
+!> Radiation models and interfaces
+!> @todo move variable definitions used in radiation_init only to the subroutine
+!>       as they are no longer required after initialization.
+!> @todo Output of full column vertical profiles used in RRTMG
+!> @todo Output of other rrtm arrays (such as volume mixing ratios)
+!> @todo Adapt for use with topography
+!>
+!> @note Many variables have a leading dummy dimension (0:0) in order to
+!>       match the assume-size shape expected by the RRTMG model.
+!------------------------------------------------------------------------------!
+ MODULE radiation_model_mod
+ 
+    USE arrays_3d,                                                             &
+        ONLY:  dzw, hyp, pt, q, ql, zw
+
+    USE cloud_parameters,                                                      &
+        ONLY:  cp, l_d_cp, nc_const, rho_l, sigma_gc  
+
+    USE constants,                                                             &
+        ONLY:  pi
+
+    USE control_parameters,                                                    &
+        ONLY:  cloud_droplets, cloud_physics, g, initializing_actions,         &
+               large_scale_forcing, lsf_surf, phi, pt_surface, rho_surface,    &
+               surface_pressure, time_since_reference_point
+
+    USE indices,                                                               &
+        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb_s_inner, nzb, nzt
+
+    USE kinds
+
+#if defined ( __netcdf )
+    USE NETCDF
+#endif
+
+#if defined ( __rrtmg )
+
+    USE parrrsw,                                                               &
+        ONLY:  naerec, nbndsw
+
+    USE parrrtm,                                                               &
+        ONLY:  nbndlw
+
+    USE rrtmg_lw_init,                                                         &
+        ONLY:  rrtmg_lw_ini
+
+    USE rrtmg_sw_init,                                                         &
+        ONLY:  rrtmg_sw_ini
+
+    USE rrtmg_lw_rad,                                                          &
+        ONLY:  rrtmg_lw
+
+    USE rrtmg_sw_rad,                                                          &
+        ONLY:  rrtmg_sw
+#endif
+
+
+
+    IMPLICIT NONE
+
+    CHARACTER(10) :: radiation_scheme = 'clear-sky' ! 'constant', 'clear-sky', or 'rrtmg'
+
+!
+!-- Predefined Land surface classes (albedo_type) after Briegleb (1992)
+    CHARACTER(37), DIMENSION(0:17), PARAMETER :: albedo_type_name = (/      &
+                                   'user defined                         ', & !  0 
+                                   'ocean                                ', & !  1
+                                   'mixed farming, tall grassland        ', & !  2
+                                   'tall/medium grassland                ', & !  3 
+                                   'evergreen shrubland                  ', & !  4
+                                   'short grassland/meadow/shrubland     ', & !  5
+                                   'evergreen needleleaf forest          ', & !  6
+                                   'mixed deciduous evergreen forest     ', & !  7
+                                   'deciduous forest                     ', & !  8
+                                   'tropical evergreen broadleaved forest', & !  9
+                                   'medium/tall grassland/woodland       ', & ! 10
+                                   'desert, sandy                        ', & ! 11 
+                                   'desert, rocky                        ', & ! 12 
+                                   'tundra                               ', & ! 13
+                                   'land ice                             ', & ! 14 
+                                   'sea ice                              ', & ! 15 
+                                   'snow                                 ', & ! 16
+                                   'pavement/roads                       '  & ! 17
+                                                         /)
+
+    INTEGER(iwp) :: albedo_type  = 5,    & !< Albedo surface type (default: short grassland)
+                    day,                 & !< current day of the year
+                    day_init     = 172,  & !< day of the year at model start (21/06)
+                    dots_rad     = 0       !< starting index for timeseries output 
+
+    LOGICAL ::  unscheduled_radiation_calls = .TRUE., & !< flag parameter indicating whether additional calls of the radiation code are allowed
+                constant_albedo = .FALSE.,            & !< flag parameter indicating whether the albedo may change depending on zenith
+                force_radiation_call = .FALSE.,       & !< flag parameter for unscheduled radiation calls
+                lw_radiation = .TRUE.,                & !< flag parameter indicating whether longwave radiation shall be calculated
+                radiation = .FALSE.,                  & !< flag parameter indicating whether the radiation model is used
+                sun_up    = .TRUE.,                   & !< flag parameter indicating whether the sun is up or down
+                sw_radiation = .TRUE.                   !< flag parameter indicing whether shortwave radiation shall be calculated
+
+
+    REAL(wp), PARAMETER :: d_seconds_hour  = 0.000277777777778_wp,  & !< inverse of seconds per hour (1/3600)
+                           d_hours_day    = 0.0416666666667_wp,     & !< inverse of hours per day (1/24)
+                           sigma_sb       = 5.67037321E-8_wp,       & !< Stefan-Boltzmann constant
+                           solar_constant = 1368.0_wp                 !< solar constant at top of atmosphere
+
+    REAL(wp) :: albedo = 9999999.9_wp,           & !< NAMELIST alpha
+                albedo_lw_dif = 9999999.9_wp,    & !< NAMELIST aldif
+                albedo_lw_dir = 9999999.9_wp,    & !< NAMELIST aldir
+                albedo_sw_dif = 9999999.9_wp,    & !< NAMELIST asdif
+                albedo_sw_dir = 9999999.9_wp,    & !< NAMELIST asdir
+                decl_1,                          & !< declination coef. 1
+                decl_2,                          & !< declination coef. 2
+                decl_3,                          & !< declination coef. 3
+                dt_radiation = 0.0_wp,           & !< radiation model timestep
+                emissivity = 0.98_wp,            & !< NAMELIST surface emissivity
+                lambda = 0.0_wp,                 & !< longitude in degrees
+                lon = 0.0_wp,                    & !< longitude in radians
+                lat = 0.0_wp,                    & !< latitude in radians
+                net_radiation = 0.0_wp,          & !< net radiation at surface
+                skip_time_do_radiation = 0.0_wp, & !< Radiation model is not called before this time
+                sky_trans,                       & !< sky transmissivity
+                time_radiation = 0.0_wp,         & !< time since last call of radiation code
+                time_utc,                        & !< current time in UTC
+                time_utc_init = 43200.0_wp         !< UTC time at model start (noon)
+
+    REAL(wp), DIMENSION(0:0) ::  zenith        !< solar zenith angle
+
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE :: &
+                alpha,                       & !< surface broadband albedo (used for clear-sky scheme)
+                rad_lw_out_change_0,         & !< change in LW out due to change in surface temperature
+                rad_net,                     & !< net radiation at the surface
+                rad_net_av                     !< average of rad_net
+
+!
+!-- Land surface albedos for solar zenith angle of 60Â° after Briegleb (1992)     
+!-- (shortwave, longwave, broadband):   sw,      lw,      bb,
+    REAL(wp), DIMENSION(0:2,1:17), PARAMETER :: albedo_pars = RESHAPE( (/& 
+                                   0.06_wp, 0.06_wp, 0.06_wp,            & !  1
+                                   0.09_wp, 0.28_wp, 0.19_wp,            & !  2
+                                   0.11_wp, 0.33_wp, 0.23_wp,            & !  3
+                                   0.11_wp, 0.33_wp, 0.23_wp,            & !  4
+                                   0.14_wp, 0.34_wp, 0.25_wp,            & !  5
+                                   0.06_wp, 0.22_wp, 0.14_wp,            & !  6
+                                   0.06_wp, 0.27_wp, 0.17_wp,            & !  7
+                                   0.06_wp, 0.31_wp, 0.19_wp,            & !  8
+                                   0.06_wp, 0.22_wp, 0.14_wp,            & !  9
+                                   0.06_wp, 0.28_wp, 0.18_wp,            & ! 10
+                                   0.35_wp, 0.51_wp, 0.43_wp,            & ! 11
+                                   0.24_wp, 0.40_wp, 0.32_wp,            & ! 12
+                                   0.10_wp, 0.27_wp, 0.19_wp,            & ! 13
+                                   0.90_wp, 0.65_wp, 0.77_wp,            & ! 14
+                                   0.90_wp, 0.65_wp, 0.77_wp,            & ! 15
+                                   0.95_wp, 0.70_wp, 0.82_wp,            & ! 16
+                                   0.08_wp, 0.08_wp, 0.08_wp             & ! 17
+                                 /), (/ 3, 17 /) )
+
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, TARGET :: &
+                        rad_lw_cs_hr,                  & !< longwave clear sky radiation heating rate (K/s)
+                        rad_lw_cs_hr_av,               & !< average of rad_lw_cs_hr
+                        rad_lw_hr,                     & !< longwave radiation heating rate (K/s)
+                        rad_lw_hr_av,                  & !< average of rad_sw_hr
+                        rad_lw_in,                     & !< incoming longwave radiation (W/m2)
+                        rad_lw_in_av,                  & !< average of rad_lw_in
+                        rad_lw_out,                    & !< outgoing longwave radiation (W/m2)
+                        rad_lw_out_av,                 & !< average of rad_lw_out
+                        rad_sw_cs_hr,                  & !< shortwave clear sky radiation heating rate (K/s)
+                        rad_sw_cs_hr_av,               & !< average of rad_sw_cs_hr
+                        rad_sw_hr,                     & !< shortwave radiation heating rate (K/s)
+                        rad_sw_hr_av,                  & !< average of rad_sw_hr
+                        rad_sw_in,                     & !< incoming shortwave radiation (W/m2)
+                        rad_sw_in_av,                  & !< average of rad_sw_in
+                        rad_sw_out,                    & !< outgoing shortwave radiation (W/m2)
+                        rad_sw_out_av                    !< average of rad_sw_out
+
+
+!
+!-- Variables and parameters used in RRTMG only
+#if defined ( __rrtmg )
+    CHARACTER(LEN=12) :: rrtm_input_file = "RAD_SND_DATA" !< name of the NetCDF input file (sounding data)
+
+
+!
+!-- Flag parameters for RRTMGS (should not be changed)
+    INTEGER(iwp), PARAMETER :: rrtm_inflglw  = 2, & !< flag for lw cloud optical properties (0,1,2)
+                               rrtm_iceflglw = 0, & !< flag for lw ice particle specifications (0,1,2,3)
+                               rrtm_liqflglw = 1, & !< flag for lw liquid droplet specifications
+                               rrtm_inflgsw  = 2, & !< flag for sw cloud optical properties (0,1,2)
+                               rrtm_iceflgsw = 0, & !< flag for sw ice particle specifications (0,1,2,3)
+                               rrtm_liqflgsw = 1    !< flag for sw liquid droplet specifications
+
+!
+!-- The following variables should be only changed with care, as this will 
+!-- require further setting of some variables, which is currently not
+!-- implemented (aerosols, ice phase).
+    INTEGER(iwp) :: nzt_rad,           & !< upper vertical limit for radiation calculations
+                    rrtm_icld = 0,     & !< cloud flag (0: clear sky column, 1: cloudy column)
+                    rrtm_iaer = 0,     & !< aerosol option flag (0: no aerosol layers, for lw only: 6 (requires setting of rrtm_sw_ecaer), 10: one or more aerosol layers (not implemented)
+                    rrtm_idrv = 1        !< longwave upward flux calculation option (0,1)
+
+    INTEGER(iwp) :: nc_stat !< local variable for storin the result of netCDF calls for error message handling
+
+    LOGICAL :: snd_exists = .FALSE.      !< flag parameter to check whether a user-defined input files exists
+
+    REAL(wp), PARAMETER :: mol_mass_air_d_wv = 1.607793_wp !< molecular weight dry air / water vapor
+
+    REAL(wp), DIMENSION(:), ALLOCATABLE :: hyp_snd,     & !< hypostatic pressure from sounding data (hPa)
+                                           q_snd,       & !< specific humidity from sounding data (kg/kg) - dummy at the moment
+                                           rrtm_tsfc,   & !< dummy array for storing surface temperature
+                                           t_snd          !< actual temperature from sounding data (hPa)
+
+    REAL(wp), DIMENSION(:,:), ALLOCATABLE :: aldif,          & !< longwave diffuse albedo solar angle of 60Â°
+                                             aldir,          & !< longwave direct albedo solar angle of 60Â°
+                                             asdif,          & !< shortwave diffuse albedo solar angle of 60Â°
+                                             asdir,          & !< shortwave direct albedo solar angle of 60Â°
+                                             rrtm_ccl4vmr,   & !< CCL4 volume mixing ratio (g/mol)
+                                             rrtm_cfc11vmr,  & !< CFC11 volume mixing ratio (g/mol)
+                                             rrtm_cfc12vmr,  & !< CFC12 volume mixing ratio (g/mol)
+                                             rrtm_cfc22vmr,  & !< CFC22 volume mixing ratio (g/mol)
+                                             rrtm_ch4vmr,    & !< CH4 volume mixing ratio
+                                             rrtm_cicewp,    & !< in-cloud ice water path (g/mÂ²)
+                                             rrtm_cldfr,     & !< cloud fraction (0,1)
+                                             rrtm_cliqwp,    & !< in-cloud liquid water path (g/mÂ²)
+                                             rrtm_co2vmr,    & !< CO2 volume mixing ratio (g/mol)
+                                             rrtm_emis,      & !< surface emissivity (0-1)    
+                                             rrtm_h2ovmr,    & !< H2O volume mixing ratio
+                                             rrtm_n2ovmr,    & !< N2O volume mixing ratio
+                                             rrtm_o2vmr,     & !< O2 volume mixing ratio
+                                             rrtm_o3vmr,     & !< O3 volume mixing ratio
+                                             rrtm_play,      & !< pressure layers (hPa, zu-grid)
+                                             rrtm_plev,      & !< pressure layers (hPa, zw-grid)
+                                             rrtm_reice,     & !< cloud ice effective radius (microns)
+                                             rrtm_reliq,     & !< cloud water drop effective radius (microns)
+                                             rrtm_tlay,      & !< actual temperature (K, zu-grid)
+                                             rrtm_tlev,      & !< actual temperature (K, zw-grid)
+                                             rrtm_lwdflx,    & !< RRTM output of incoming longwave radiation flux (W/m2)
+                                             rrtm_lwdflxc,   & !< RRTM output of outgoing clear sky longwave radiation flux (W/m2) 
+                                             rrtm_lwuflx,    & !< RRTM output of outgoing longwave radiation flux (W/m2)
+                                             rrtm_lwuflxc,   & !< RRTM output of incoming clear sky longwave radiation flux (W/m2)
+                                             rrtm_lwuflx_dt, & !< RRTM output of incoming clear sky longwave radiation flux (W/m2)
+                                             rrtm_lwuflxc_dt,& !< RRTM output of outgoing clear sky longwave radiation flux (W/m2)
+                                             rrtm_lwhr,      & !< RRTM output of longwave radiation heating rate (K/d)
+                                             rrtm_lwhrc,     & !< RRTM output of incoming longwave clear sky radiation heating rate (K/d)
+                                             rrtm_swdflx,    & !< RRTM output of incoming shortwave radiation flux (W/m2)
+                                             rrtm_swdflxc,   & !< RRTM output of outgoing clear sky shortwave radiation flux (W/m2) 
+                                             rrtm_swuflx,    & !< RRTM output of outgoing shortwave radiation flux (W/m2)
+                                             rrtm_swuflxc,   & !< RRTM output of incoming clear sky shortwave radiation flux (W/m2)
+                                             rrtm_swhr,      & !< RRTM output of shortwave radiation heating rate (K/d)
+                                             rrtm_swhrc        !< RRTM output of incoming shortwave clear sky radiation heating rate (K/d) 
+
+!
+!-- Definition of arrays that are currently not used for calling RRTMG (due to setting of flag parameters)
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  rad_lw_cs_in,   & !< incoming clear sky longwave radiation (W/m2) (not used)
+                                                rad_lw_cs_out,  & !< outgoing clear sky longwave radiation (W/m2) (not used)
+                                                rad_sw_cs_in,   & !< incoming clear sky shortwave radiation (W/m2) (not used)
+                                                rad_sw_cs_out,  & !< outgoing clear sky shortwave radiation (W/m2) (not used)
+                                                rrtm_aldif,     & !< surface albedo for longwave diffuse radiation
+                                                rrtm_aldir,     & !< surface albedo for longwave direct radiation
+                                                rrtm_asdif,     & !< surface albedo for shortwave diffuse radiation
+                                                rrtm_asdir,     & !< surface albedo for shortwave direct radiation
+                                                rrtm_lw_tauaer, & !< lw aerosol optical depth
+                                                rrtm_lw_taucld, & !< lw in-cloud optical depth
+                                                rrtm_sw_taucld, & !< sw in-cloud optical depth
+                                                rrtm_sw_ssacld, & !< sw in-cloud single scattering albedo
+                                                rrtm_sw_asmcld, & !< sw in-cloud asymmetry parameter
+                                                rrtm_sw_fsfcld, & !< sw in-cloud forward scattering fraction
+                                                rrtm_sw_tauaer, & !< sw aerosol optical depth
+                                                rrtm_sw_ssaaer, & !< sw aerosol single scattering albedo
+                                                rrtm_sw_asmaer, & !< sw aerosol asymmetry parameter
+                                                rrtm_sw_ecaer     !< sw aerosol optical detph at 0.55 microns (rrtm_iaer = 6 only)
+
+#endif
+
+    INTERFACE radiation_check_data_output
+       MODULE PROCEDURE radiation_check_data_output
+    END INTERFACE radiation_check_data_output
+
+    INTERFACE radiation_check_data_output_pr
+       MODULE PROCEDURE radiation_check_data_output_pr
+    END INTERFACE radiation_check_data_output_pr
+  
+    INTERFACE radiation_check_parameters
+       MODULE PROCEDURE radiation_check_parameters
+    END INTERFACE radiation_check_parameters
+  
+    INTERFACE radiation_clearsky
+       MODULE PROCEDURE radiation_clearsky
+    END INTERFACE radiation_clearsky
+  
+    INTERFACE radiation_header
+       MODULE PROCEDURE radiation_header
+    END INTERFACE radiation_header 
+  
+    INTERFACE radiation_init
+       MODULE PROCEDURE radiation_init
+    END INTERFACE radiation_init
+
+    INTERFACE radiation_parin
+       MODULE PROCEDURE radiation_parin
+    END INTERFACE radiation_parin
+    
+    INTERFACE radiation_rrtmg
+       MODULE PROCEDURE radiation_rrtmg
+    END INTERFACE radiation_rrtmg
+
+    INTERFACE radiation_tendency
+       MODULE PROCEDURE radiation_tendency
+       MODULE PROCEDURE radiation_tendency_ij
+    END INTERFACE radiation_tendency
+
+    SAVE
+
+    PRIVATE
+
+!
+!-- Public functions
+    PUBLIC radiation_check_data_output, radiation_check_data_output_pr,        &
+           radiation_check_parameters, radiation_clearsky, radiation_header,   &
+           radiation_init, radiation_parin, radiation_rrtmg, radiation_tendency
+    
+!
+!-- Public variables and constants
+    PUBLIC dots_rad, dt_radiation, force_radiation_call,                       &
+           rad_net, rad_net_av, radiation, radiation_scheme, rad_lw_in,        &
+           rad_lw_in_av, rad_lw_out, rad_lw_out_av, rad_lw_out_change_0,       &
+           rad_lw_cs_hr, rad_lw_cs_hr_av, rad_lw_hr, rad_lw_hr_av, rad_sw_in,  &
+           rad_sw_in_av, rad_sw_out, rad_sw_out_av, rad_sw_cs_hr,              &
+           rad_sw_cs_hr_av, rad_sw_hr, rad_sw_hr_av, sigma_sb,                 &
+           skip_time_do_radiation, time_radiation, unscheduled_radiation_calls
+
+
+#if defined ( __rrtmg )
+    PUBLIC rrtm_aldif, rrtm_aldir, rrtm_asdif, rrtm_asdir, rrtm_idrv
+#endif
+
+ CONTAINS
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Check data output for radiation model
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_check_data_output( var, unit, i, ilen, k )
+ 
+ 
+       USE control_parameters,                                                 &
+           ONLY: data_output, message_string
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=*) ::  unit     !< 
+       CHARACTER (LEN=*) ::  var      !<
+
+       INTEGER(iwp) :: i
+       INTEGER(iwp) :: ilen
+       INTEGER(iwp) :: k
+
+       SELECT CASE ( TRIM( var ) )
+
+         CASE ( 'rad_lw_in', 'rad_lw_out', 'rad_lw_cs_hr', 'rad_lw_hr',       &
+                 'rad_sw_in', 'rad_sw_out', 'rad_sw_cs_hr', 'rad_sw_hr' )
+             IF (  .NOT.  radiation  .OR.  radiation_scheme /= 'rrtmg' )  THEN
+                message_string = '"output of "' // TRIM( var ) // '" requi' // &
+                                 'res radiation = .TRUE. and ' //              &
+                                 'radiation_scheme = "rrtmg"'
+                CALL message( 'check_parameters', 'PA0406', 1, 2, 0, 6, 0 )
+             ENDIF
+             unit = 'W/m2'     
+
+          CASE ( 'rad_net*', 'rrtm_aldif*', 'rrtm_aldir*', 'rrtm_asdif*',      &
+                 'rrtm_asdir*' )
+             IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
+                message_string = 'illegal value for data_output: "' //         &
+                                 TRIM( var ) // '" & only 2d-horizontal ' //   &
+                                 'cross sections are allowed for this value'
+                CALL message( 'check_parameters', 'PA0111', 1, 2, 0, 6, 0 )
+             ENDIF
+             IF (  .NOT.  radiation  .OR.  radiation_scheme /= "rrtmg" )  THEN
+                IF ( TRIM( var ) == 'rrtm_aldif*'  .OR.                        &
+                     TRIM( var ) == 'rrtm_aldir*'  .OR.                        &
+                     TRIM( var ) == 'rrtm_asdif*'  .OR.                        &
+                     TRIM( var ) == 'rrtm_asdir*'      )                       &
+                THEN
+                   message_string = 'output of "' // TRIM( var ) // '" require'&
+                                    // 's radiation = .TRUE. and radiation_sch'&
+                                    // 'eme = "rrtmg"'
+                   CALL message( 'check_parameters', 'PA0409', 1, 2, 0, 6, 0 )
+                ENDIF
+             ENDIF
+
+             IF ( TRIM( var ) == 'rad_net*'      ) unit = 'W/m2'   
+             IF ( TRIM( var ) == 'rrtm_aldif*'   ) unit = ''   
+             IF ( TRIM( var ) == 'rrtm_aldir*'   ) unit = '' 
+             IF ( TRIM( var ) == 'rrtm_asdif*'   ) unit = '' 
+             IF ( TRIM( var ) == 'rrtm_asdir*'   ) unit = '' 
+
+          CASE DEFAULT
+             unit = 'illegal'
+
+       END SELECT
+
+
+    END SUBROUTINE radiation_check_data_output
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Check data output of profiles for radiation model
+!------------------------------------------------------------------------------!  
+    SUBROUTINE radiation_check_data_output_pr( variable, var_count, unit, dopr_unit )
+ 
+       USE arrays_3d,                                                          &
+           ONLY: zu
+
+       USE control_parameters,                                                 &
+           ONLY: data_output_pr, message_string
+
+       USE indices
+
+       USE profil_parameter
+
+       USE statistics
+
+       IMPLICIT NONE
+   
+       CHARACTER (LEN=*) ::  unit      !< 
+       CHARACTER (LEN=*) ::  variable  !< 
+       CHARACTER (LEN=*) ::  dopr_unit !< local value of dopr_unit
+ 
+       INTEGER(iwp) ::  user_pr_index !< 
+       INTEGER(iwp) ::  var_count     !< 
+
+       SELECT CASE ( TRIM( variable ) )
+       
+         CASE ( 'rad_net' )
+             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme == 'constant' )&
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme = "constant"'
+                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 101
+                dopr_unit  = 'W/m2'
+                hom(:,2,101,:)  = SPREAD( zw, 2, statistic_regions+1 )
+                unit = dopr_unit
+             ENDIF
+
+          CASE ( 'rad_lw_in' )
+             IF ( (  .NOT.  radiation)  .OR.  radiation_scheme == 'constant' ) &
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme = "constant"'
+                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 102
+                dopr_unit  = 'W/m2'
+                hom(:,2,102,:)  = SPREAD( zw, 2, statistic_regions+1 )
+                unit = dopr_unit 
+             ENDIF
+
+          CASE ( 'rad_lw_out' )
+             IF ( (  .NOT. radiation )  .OR.  radiation_scheme == 'constant' ) &
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme = "constant"'
+                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 103
+                dopr_unit  = 'W/m2'
+                hom(:,2,103,:)  = SPREAD( zw, 2, statistic_regions+1 )
+                unit = dopr_unit   
+             ENDIF
+
+          CASE ( 'rad_sw_in' )
+             IF ( (  .NOT. radiation )  .OR.  radiation_scheme == 'constant' ) &
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme = "constant"'
+                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 104
+                dopr_unit  = 'W/m2'
+                hom(:,2,104,:)  = SPREAD( zw, 2, statistic_regions+1 )
+                unit = dopr_unit
+             ENDIF
+
+          CASE ( 'rad_sw_out')
+             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme == 'constant' )&
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme = "constant"'
+                CALL message( 'check_parameters', 'PA0408', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 105
+                dopr_unit  = 'W/m2'
+                hom(:,2,105,:)  = SPREAD( zw, 2, statistic_regions+1 )
+                unit = dopr_unit
+             ENDIF
+
+          CASE ( 'rad_lw_cs_hr' )
+             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme /= "rrtmg"'
+                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 106
+                dopr_unit  = 'K/h'
+                hom(:,2,106,:)  = SPREAD( zu, 2, statistic_regions+1 )
+                unit = dopr_unit
+             ENDIF
+
+          CASE ( 'rad_lw_hr' )
+             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme /= "rrtmg"'
+                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 107
+                dopr_unit  = 'K/h'
+                hom(:,2,107,:)  = SPREAD( zu, 2, statistic_regions+1 )
+                unit = dopr_unit
+             ENDIF
+
+          CASE ( 'rad_sw_cs_hr' )
+             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme /= "rrtmg"'
+                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 108
+                dopr_unit  = 'K/h'
+                hom(:,2,108,:)  = SPREAD( zu, 2, statistic_regions+1 )
+                unit = dopr_unit
+             ENDIF
+
+          CASE ( 'rad_sw_hr' )
+             IF ( (  .NOT.  radiation )  .OR.  radiation_scheme /= 'rrtmg' )   &
+             THEN
+                message_string = 'data_output_pr = ' //                        &
+                                 TRIM( data_output_pr(var_count) ) // ' is' // &
+                                 'not available for radiation = .FALSE. or ' //&
+                                 'radiation_scheme /= "rrtmg"'
+                CALL message( 'check_parameters', 'PA0413', 1, 2, 0, 6, 0 )
+             ELSE
+                dopr_index(var_count) = 109
+                dopr_unit  = 'K/h'
+                hom(:,2,109,:)  = SPREAD( zu, 2, statistic_regions+1 )
+                unit = dopr_unit
+             ENDIF
+
+
+          CASE DEFAULT
+             unit = 'illegal'
+
+       END SELECT
+
+
+    END SUBROUTINE radiation_check_data_output_pr
+ 
+ 
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Check parameters routine for radiation model
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_check_parameters
+
+       USE control_parameters,                                                 &
+           ONLY: message_string, topography
+                 
+    
+       IMPLICIT NONE
+
+       IF ( radiation_scheme /= 'constant'   .AND.                             &
+            radiation_scheme /= 'clear-sky'  .AND.                             &
+            radiation_scheme /= 'rrtmg' )  THEN
+          message_string = 'unknown radiation_scheme = '//                     &
+                           TRIM( radiation_scheme )
+          CALL message( 'check_parameters', 'PA0405', 1, 2, 0, 6, 0 )
+       ELSEIF ( radiation_scheme == 'rrtmg' )  THEN
+#if ! defined ( __rrtmg )
+          message_string = 'radiation_scheme = "rrtmg" requires ' //           & 
+                           'compilation of PALM with pre-processor ' //        &
+                           'directive -D__rrtmg'
+          CALL message( 'check_parameters', 'PA0407', 1, 2, 0, 6, 0 )
+#endif
+#if defined ( __rrtmg ) && ! defined( __netcdf )
+          message_string = 'radiation_scheme = "rrtmg" requires ' //           & 
+                           'the use of NetCDF (preprocessor directive ' //     &
+                           '-D__netcdf'
+          CALL message( 'check_parameters', 'PA0412', 1, 2, 0, 6, 0 )
+#endif
+
+       ENDIF
+
+       IF ( albedo_type == 0  .AND.  albedo == 9999999.9_wp  .AND.             &
+            radiation_scheme == 'clear-sky')  THEN
+          message_string = 'radiation_scheme = "clear-sky" in combination' //  & 
+                           'with albedo_type = 0 requires setting of albedo'// &
+                           ' /= 9999999.9'
+          CALL message( 'check_parameters', 'PA0410', 1, 2, 0, 6, 0 )
+       ENDIF
+
+       IF ( albedo_type == 0  .AND.  radiation_scheme == 'rrtmg'  .AND.        &
+          (    albedo_lw_dif == 9999999.9_wp .OR. albedo_lw_dir == 9999999.9_wp&
+          .OR. albedo_sw_dif == 9999999.9_wp .OR. albedo_sw_dir == 9999999.9_wp& 
+          ) ) THEN
+          message_string = 'radiation_scheme = "rrtmg" in combination' //      & 
+                           'with albedo_type = 0 requires setting of ' //      &
+                           'albedo_lw_dif /= 9999999.9' //                     &
+                           'albedo_lw_dir /= 9999999.9' //                     &
+                           'albedo_sw_dif /= 9999999.9 and' //                 &
+                           'albedo_sw_dir /= 9999999.9'
+          CALL message( 'check_parameters', 'PA0411', 1, 2, 0, 6, 0 )
+       ENDIF
+
+       IF ( topography /= 'flat' )  THEN
+          message_string = 'radiation scheme cannot be used ' //               & 
+                           'in combination with  topography /= "flat"'
+          CALL message( 'check_parameters', 'PA0414', 1, 2, 0, 6, 0 )
+       ENDIF
+ 
+    END SUBROUTINE radiation_check_parameters 
+ 
+ 
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Initialization of the radiation model
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_init
+    
+       IMPLICIT NONE
+
+!
+!--    Allocate array for storing the surface net radiation
+       IF ( .NOT. ALLOCATED ( rad_net ) )  THEN
+          ALLOCATE ( rad_net(nysg:nyng,nxlg:nxrg) )
+          rad_net = 0.0_wp
+       ENDIF
+
+!
+!--    Allocate array for storing the surface net radiation
+       IF ( .NOT. ALLOCATED ( rad_lw_out_change_0 ) )  THEN
+          ALLOCATE ( rad_lw_out_change_0(nysg:nyng,nxlg:nxrg) )
+          rad_lw_out_change_0 = 0.0_wp
+       ENDIF
+
+!
+!--    Fix net radiation in case of radiation_scheme = 'constant'
+       IF ( radiation_scheme == 'constant' )  THEN
+          rad_net = net_radiation
+          radiation = .FALSE.
+!
+!--    Calculate orbital constants
+       ELSE
+          decl_1 = SIN(23.45_wp * pi / 180.0_wp)
+          decl_2 = 2.0_wp * pi / 365.0_wp
+          decl_3 = decl_2 * 81.0_wp
+          lat    = phi * pi / 180.0_wp
+          lon    = lambda * pi / 180.0_wp
+       ENDIF
+
+
+       IF ( radiation_scheme == 'clear-sky' )  THEN
+
+          ALLOCATE ( alpha(nysg:nyng,nxlg:nxrg) )
+
+          IF ( .NOT. ALLOCATED ( rad_sw_in ) )  THEN
+             ALLOCATE ( rad_sw_in(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+          IF ( .NOT. ALLOCATED ( rad_sw_out ) )  THEN
+             ALLOCATE ( rad_sw_out(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_in_av ) )  THEN
+             ALLOCATE ( rad_sw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+          IF ( .NOT. ALLOCATED ( rad_sw_out_av ) )  THEN
+             ALLOCATE ( rad_sw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_in ) )  THEN
+             ALLOCATE ( rad_lw_in(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+          IF ( .NOT. ALLOCATED ( rad_lw_out ) )  THEN
+             ALLOCATE ( rad_lw_out(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_in_av ) )  THEN
+             ALLOCATE ( rad_lw_in_av(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+          IF ( .NOT. ALLOCATED ( rad_lw_out_av ) )  THEN
+             ALLOCATE ( rad_lw_out_av(0:0,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          rad_sw_in  = 0.0_wp
+          rad_sw_out = 0.0_wp
+          rad_lw_in  = 0.0_wp
+          rad_lw_out = 0.0_wp
+
+!
+!--       Overwrite albedo if manually set in parameter file
+          IF ( albedo_type /= 0 .AND. albedo == 9999999.9_wp )  THEN
+             albedo = albedo_pars(2,albedo_type)
+          ENDIF
+    
+          alpha = albedo
+  
+!
+!--    Initialization actions for RRTMG
+       ELSEIF ( radiation_scheme == 'rrtmg' )  THEN
+#if defined ( __rrtmg )
+!
+!--       Allocate albedos
+          ALLOCATE ( rrtm_aldif(0:0,nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( rrtm_aldir(0:0,nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( rrtm_asdif(0:0,nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( rrtm_asdir(0:0,nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( aldif(nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( aldir(nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( asdif(nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( asdir(nysg:nyng,nxlg:nxrg) )
+
+          IF ( albedo_type /= 0 )  THEN
+             IF ( albedo_lw_dif == 9999999.9_wp )  THEN
+                albedo_lw_dif = albedo_pars(0,albedo_type)
+                albedo_lw_dir = albedo_lw_dif
+             ENDIF
+             IF ( albedo_sw_dif == 9999999.9_wp )  THEN
+                albedo_sw_dif = albedo_pars(1,albedo_type)
+                albedo_sw_dir = albedo_sw_dif
+             ENDIF
+          ENDIF
+
+          aldif(:,:) = albedo_lw_dif
+          aldir(:,:) = albedo_lw_dir
+          asdif(:,:) = albedo_sw_dif
+          asdir(:,:) = albedo_sw_dir
+!
+!--       Calculate initial values of current (cosine of) the zenith angle and 
+!--       whether the sun is up
+          CALL calc_zenith     
+!
+!--       Calculate initial surface albedo
+          IF ( .NOT. constant_albedo )  THEN
+             CALL calc_albedo
+          ELSE
+             rrtm_aldif(0,:,:) = aldif(:,:)
+             rrtm_aldir(0,:,:) = aldir(:,:)
+             rrtm_asdif(0,:,:) = asdif(:,:) 
+             rrtm_asdir(0,:,:) = asdir(:,:)   
+          ENDIF
+
+!
+!--       Allocate surface emissivity
+          ALLOCATE ( rrtm_emis(0:0,1:nbndlw+1) )
+          rrtm_emis = emissivity
+
+!
+!--       Allocate 3d arrays of radiative fluxes and heating rates
+          IF ( .NOT. ALLOCATED ( rad_sw_in ) )  THEN
+             ALLOCATE ( rad_sw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_sw_in = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_in_av ) )  THEN
+             ALLOCATE ( rad_sw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_out ) )  THEN
+             ALLOCATE ( rad_sw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_sw_out = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_out_av ) )  THEN
+             ALLOCATE ( rad_sw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_hr ) )  THEN
+             ALLOCATE ( rad_sw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_sw_hr = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_hr_av ) )  THEN
+             ALLOCATE ( rad_sw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_sw_hr_av = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_cs_hr ) )  THEN
+             ALLOCATE ( rad_sw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_sw_cs_hr = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_sw_cs_hr_av ) )  THEN
+             ALLOCATE ( rad_sw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_sw_cs_hr_av = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_in ) )  THEN
+             ALLOCATE ( rad_lw_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_lw_in     = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_in_av ) )  THEN
+             ALLOCATE ( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_out ) )  THEN
+             ALLOCATE ( rad_lw_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+            rad_lw_out    = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_out_av ) )  THEN
+             ALLOCATE ( rad_lw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_hr ) )  THEN
+             ALLOCATE ( rad_lw_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_lw_hr = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_hr_av ) )  THEN
+             ALLOCATE ( rad_lw_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_lw_hr_av = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_cs_hr ) )  THEN
+             ALLOCATE ( rad_lw_cs_hr(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_lw_cs_hr = 0.0_wp
+          ENDIF
+
+          IF ( .NOT. ALLOCATED ( rad_lw_cs_hr_av ) )  THEN
+             ALLOCATE ( rad_lw_cs_hr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             rad_lw_cs_hr_av = 0.0_wp
+          ENDIF
+
+          ALLOCATE ( rad_sw_cs_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( rad_sw_cs_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          rad_sw_cs_in  = 0.0_wp
+          rad_sw_cs_out = 0.0_wp
+
+          ALLOCATE ( rad_lw_cs_in(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          ALLOCATE ( rad_lw_cs_out(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+          rad_lw_cs_in  = 0.0_wp
+          rad_lw_cs_out = 0.0_wp
+
+!
+!--       Allocate dummy array for storing surface temperature
+          ALLOCATE ( rrtm_tsfc(1) )
+
+!
+!--       Initialize RRTMG
+          IF ( lw_radiation )  CALL rrtmg_lw_ini ( cp )
+          IF ( sw_radiation )  CALL rrtmg_sw_ini ( cp )
+
+!
+!--       Set input files for RRTMG
+          INQUIRE(FILE="RAD_SND_DATA", EXIST=snd_exists) 
+          IF ( .NOT. snd_exists )  THEN
+             rrtm_input_file = "rrtmg_lw.nc"
+          ENDIF
+
+!
+!--       Read vertical layers for RRTMG from sounding data
+!--       The routine provides nzt_rad, hyp_snd(1:nzt_rad),
+!--       t_snd(nzt+2:nzt_rad), rrtm_play(1:nzt_rad), rrtm_plev(1_nzt_rad+1), 
+!--       rrtm_tlay(nzt+2:nzt_rad), rrtm_tlev(nzt+2:nzt_rad+1)
+          CALL read_sounding_data
+
+!
+!--       Read trace gas profiles from file. This routine provides
+!--       the rrtm_ arrays (1:nzt_rad+1)
+          CALL read_trace_gas_data
+#endif
+       ENDIF
+
+!
+!--    Perform user actions if required
+       CALL user_init_radiation
+
+!
+!--    Calculate radiative fluxes at model start
+       IF (  TRIM( initializing_actions ) /= 'read_restart_data' )  THEN
+          IF ( radiation_scheme == 'clear-sky' )  THEN
+             CALL radiation_clearsky
+          ELSEIF ( radiation_scheme == 'rrtmg' )  THEN
+             CALL radiation_rrtmg
+          ENDIF
+       ENDIF
+
+       RETURN
+
+    END SUBROUTINE radiation_init
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> A simple clear sky radiation model
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_clearsky
+
+       USE indices,                                                            &
+           ONLY:  nbgp
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) :: i, j, k   !< loop indices
+       REAL(wp)     :: exn,   &  !< Exner functions at surface
+                       exn1,  &  !< Exner functions at first grid level
+                       pt1       !< potential temperature at first grid level
+
+!
+!--    Calculate current zenith angle
+       CALL calc_zenith
+
+!
+!--    Calculate sky transmissivity
+       sky_trans = 0.6_wp + 0.2_wp * zenith(0)
+
+!
+!--    Calculate value of the Exner function
+       exn = (surface_pressure / 1000.0_wp )**0.286_wp
+!
+!--    Calculate radiation fluxes and net radiation (rad_net) for each grid 
+!--    point
+       DO i = nxlg, nxrg
+          DO j = nysg, nyng
+             k = nzb_s_inner(j,i)
+
+             exn1 = (hyp(k+1) / 100000.0_wp )**0.286_wp
+
+             rad_sw_in(0,j,i)  = solar_constant * sky_trans * zenith(0)
+             rad_sw_out(0,j,i) = alpha(j,i) * rad_sw_in(0,j,i)
+             rad_lw_out(0,j,i) = emissivity * sigma_sb * (pt(k,j,i) * exn)**4
+
+             IF ( cloud_physics )  THEN
+                pt1 = pt(k+1,j,i) + l_d_cp / exn1 * ql(k+1,j,i)
+                rad_lw_in(0,j,i)  = 0.8_wp * sigma_sb * (pt1 * exn1)**4
+             ELSE
+                rad_lw_in(0,j,i)  = 0.8_wp * sigma_sb * (pt(k+1,j,i) * exn1)**4
+             ENDIF
+
+             rad_net(j,i) = rad_sw_in(0,j,i) - rad_sw_out(0,j,i)               &
+                            + rad_lw_in(0,j,i) - rad_lw_out(0,j,i)
+
+          ENDDO
+       ENDDO
+
+    END SUBROUTINE radiation_clearsky
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Header output for radiation model
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_header ( io )
+
+
+       IMPLICIT NONE
+ 
+       INTEGER(iwp), INTENT(IN) ::  io            !< Unit of the output file
+    
+
+       
+!
+!--    Write radiation model header
+       WRITE( io, 3 )
+
+       IF ( radiation_scheme == "constant" )  THEN
+          WRITE( io, 4 ) net_radiation
+       ELSEIF ( radiation_scheme == "clear-sky" )  THEN
+          WRITE( io, 5 )
+       ELSEIF ( radiation_scheme == "rrtmg" )  THEN
+          WRITE( io, 6 )
+          IF ( .NOT. lw_radiation )  WRITE( io, 10 )
+          IF ( .NOT. sw_radiation )  WRITE( io, 11 )
+       ENDIF 
+
+       IF ( albedo_type == 0 )  THEN
+          WRITE( io, 7 ) albedo
+       ELSE
+          WRITE( io, 8 ) TRIM( albedo_type_name(albedo_type) )
+       ENDIF
+       IF ( constant_albedo )  THEN
+          WRITE( io, 9 )
+       ENDIF
+       
+       IF ( radiation .AND. radiation_scheme /= 'constant' )  THEN
+          WRITE ( io, 1 )  lambda
+          WRITE ( io, 2 )  day_init, time_utc_init
+       ENDIF
+
+       WRITE( io, 12 ) dt_radiation
+ 
+
+ 1 FORMAT ('    Geograph. longitude            :   lambda = ',F4.1,' degr')
+ 2 FORMAT ('    Day of the year at model start :   day_init = ',I3   &
+            /'    UTC time at model start        :   time_utc_init = ',F7.1' s')
+ 3 FORMAT (//' Radiation model information:'/                                  &
+              ' ----------------------------'/)
+ 4 FORMAT ('    --> Using constant net radiation: net_radiation = ', F6.2,        &
+           // 'W/m**2')
+ 5 FORMAT ('    --> Simple radiation scheme for clear sky is used (no clouds,',   &
+                   ' default)')
+ 6 FORMAT ('    --> RRTMG scheme is used')
+ 7 FORMAT (/'    User-specific surface albedo: albedo =', F6.3)
+ 8 FORMAT (/'    Albedo is set for land surface type: ', A)
+ 9 FORMAT (/'    --> Albedo is fixed during the run')
+10 FORMAT (/'    --> Longwave radiation is disabled')
+11 FORMAT (/'    --> Shortwave radiation is disabled.')
+12 FORMAT  ('    Timestep: dt_radiation = ', F6.2, '  s')
+
+
+    END SUBROUTINE radiation_header
+   
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Parin for &radiation_par for radiation model
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_parin
+
+
+       IMPLICIT NONE
+
+       CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file 
+       
+       NAMELIST /radiation_par/   albedo, albedo_type, albedo_lw_dir,          &
+                                  albedo_lw_dif, albedo_sw_dir, albedo_sw_dif, &
+                                  constant_albedo, day_init, dt_radiation,     &
+                                  lambda, lw_radiation, net_radiation,         &
+                                  radiation_scheme, skip_time_do_radiation,    &
+                                  sw_radiation, time_utc_init,                 &
+                                  unscheduled_radiation_calls
+       
+       line = ' '
+       
+!
+!--    Try to find radiation model package
+       REWIND ( 11 )
+       line = ' '
+       DO   WHILE ( INDEX( line, '&radiation_par' ) == 0 )
+          READ ( 11, '(A)', END=10 )  line
+       ENDDO
+       BACKSPACE ( 11 )
+
+!
+!--    Read user-defined namelist
+       READ ( 11, radiation_par )
+
+!
+!--    Set flag that indicates that the radiation model is switched on
+       radiation = .TRUE.
+
+ 10    CONTINUE
+       
+
+    END SUBROUTINE radiation_parin
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Implementation of the RRTMG radiation_scheme
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_rrtmg
+
+       USE indices,                                                            &
+           ONLY:  nbgp
+
+       USE particle_attributes,                                                &
+           ONLY:  grid_particles, number_of_particles, particles,              &
+                  particle_advection_start, prt_count
+
+       IMPLICIT NONE
+
+#if defined ( __rrtmg )
+
+       INTEGER(iwp) :: i, j, k, n !< loop indices
+
+       REAL(wp)     ::  s_r2, &   !< weighted sum over all droplets with r^2
+                        s_r3      !< weighted sum over all droplets with r^3
+
+!
+!--    Calculate current (cosine of) zenith angle and whether the sun is up
+       CALL calc_zenith     
+!
+!--    Calculate surface albedo
+       IF ( .NOT. constant_albedo )  THEN
+          CALL calc_albedo
+       ENDIF
+
+!
+!--    Prepare input data for RRTMG
+
+!
+!--    In case of large scale forcing with surface data, calculate new pressure
+!--    profile. nzt_rad might be modified by these calls and all required arrays
+!--    will then be re-allocated
+       IF ( large_scale_forcing  .AND.  lsf_surf )  THEN
+          CALL read_sounding_data
+          CALL read_trace_gas_data
+       ENDIF
+!
+!--    Loop over all grid points
+       DO i = nxl, nxr
+          DO j = nys, nyn
+
+!
+!--          Prepare profiles of temperature and H2O volume mixing ratio
+             rrtm_tlev(0,nzb+1) = pt(nzb,j,i) * ( surface_pressure             &
+                                                  / 1000.0_wp )**0.286_wp
+
+             DO k = nzb+1, nzt+1
+                rrtm_tlay(0,k) = pt(k,j,i) * ( (hyp(k) ) / 100000.0_wp         &
+                                 )**0.286_wp + l_d_cp * ql(k,j,i)
+                rrtm_h2ovmr(0,k) = mol_mass_air_d_wv * (q(k,j,i) - ql(k,j,i))
+
+             ENDDO
+
+!
+!--          Avoid temperature/humidity jumps at the top of the LES domain by 
+!--          linear interpolation from nzt+2 to nzt+7
+             DO k = nzt+2, nzt+7
+                rrtm_tlay(0,k) = rrtm_tlay(0,nzt+1)                            &
+                              + ( rrtm_tlay(0,nzt+8) - rrtm_tlay(0,nzt+1) )    &
+                              / ( rrtm_play(0,nzt+8) - rrtm_play(0,nzt+1) )    &
+                              * ( rrtm_play(0,k) - rrtm_play(0,nzt+1) )
+
+                rrtm_h2ovmr(0,k) = rrtm_h2ovmr(0,nzt+1)                        &
+                              + ( rrtm_h2ovmr(0,nzt+8) - rrtm_h2ovmr(0,nzt+1) )&
+                              / ( rrtm_play(0,nzt+8)   - rrtm_play(0,nzt+1)   )&
+                              * ( rrtm_play(0,k) - rrtm_play(0,nzt+1) )
+
+             ENDDO
+
+!--          Linear interpolate to zw grid
+             DO k = nzb+2, nzt+8
+                rrtm_tlev(0,k)   = rrtm_tlay(0,k-1) + (rrtm_tlay(0,k) -        &
+                                   rrtm_tlay(0,k-1))                           &
+                                   / ( rrtm_play(0,k) - rrtm_play(0,k-1) )     &
+                                   * ( rrtm_plev(0,k) - rrtm_play(0,k-1) )
+             ENDDO
+
+
+!
+!--          Calculate liquid water path and cloud fraction for each column.
+!--          Note that LWP is required in g/mÂ² instead of kg/kg m.
+             rrtm_cldfr  = 0.0_wp
+             rrtm_reliq  = 0.0_wp
+             rrtm_cliqwp = 0.0_wp
+             rrtm_icld   = 0
+
+             DO k = nzb+1, nzt+1
+                rrtm_cliqwp(0,k) =  ql(k,j,i) * 1000.0_wp *                    &
+                                    (rrtm_plev(0,k) - rrtm_plev(0,k+1))        &
+                                    * 100.0_wp / g 
+
+                IF ( rrtm_cliqwp(0,k) > 0.0_wp )  THEN
+                   rrtm_cldfr(0,k) = 1.0_wp
+                   IF ( rrtm_icld == 0 )  rrtm_icld = 1
+
+!
+!--                Calculate cloud droplet effective radius
+                   IF ( cloud_physics )  THEN
+                      rrtm_reliq(0,k) = 1.0E6_wp * ( 3.0_wp * ql(k,j,i)        &
+                                        * rho_surface                          &
+                                        / ( 4.0_wp * pi * nc_const * rho_l )   &
+                                        )**0.33333333333333_wp                 &
+                                        * EXP( LOG( sigma_gc )**2 )
+
+                   ELSEIF ( cloud_droplets )  THEN
+                      number_of_particles = prt_count(k,j,i)
+
+                      IF (number_of_particles <= 0)  CYCLE
+                      particles => grid_particles(k,j,i)%particles(1:number_of_particles)
+                      s_r2 = 0.0_wp
+                      s_r3 = 0.0_wp
+
+                      DO  n = 1, number_of_particles
+                         IF ( particles(n)%particle_mask )  THEN
+                            s_r2 = s_r2 + particles(n)%radius**2 * &
+                                   particles(n)%weight_factor
+                            s_r3 = s_r3 + particles(n)%radius**3 * &
+                                   particles(n)%weight_factor
+                         ENDIF
+                      ENDDO
+
+                      IF ( s_r2 > 0.0_wp )  rrtm_reliq(0,k) = s_r3 / s_r2
+
+                   ENDIF
+
+!
+!--                Limit effective radius
+                   IF ( rrtm_reliq(0,k) > 0.0_wp )  THEN
+                      rrtm_reliq(0,k) = MAX(rrtm_reliq(0,k),2.5_wp)
+                      rrtm_reliq(0,k) = MIN(rrtm_reliq(0,k),60.0_wp)
+                  ENDIF
+                ENDIF
+             ENDDO
+
+!
+!--          Set surface temperature
+             rrtm_tsfc = pt(nzb,j,i) * (surface_pressure / 1000.0_wp )**0.286_wp
+
+             IF ( lw_radiation )  THEN
+               CALL rrtmg_lw( 1, nzt_rad      , rrtm_icld    , rrtm_idrv      ,&
+               rrtm_play       , rrtm_plev    , rrtm_tlay    , rrtm_tlev      ,&
+               rrtm_tsfc       , rrtm_h2ovmr  , rrtm_o3vmr   , rrtm_co2vmr    ,&
+               rrtm_ch4vmr     , rrtm_n2ovmr  , rrtm_o2vmr   , rrtm_cfc11vmr  ,&
+               rrtm_cfc12vmr   , rrtm_cfc22vmr, rrtm_ccl4vmr , rrtm_emis      ,&
+               rrtm_inflglw    , rrtm_iceflglw, rrtm_liqflglw, rrtm_cldfr     ,&
+               rrtm_lw_taucld  , rrtm_cicewp  , rrtm_cliqwp  , rrtm_reice     ,& 
+               rrtm_reliq      , rrtm_lw_tauaer,                               &
+               rrtm_lwuflx     , rrtm_lwdflx  , rrtm_lwhr  ,                   &
+               rrtm_lwuflxc    , rrtm_lwdflxc , rrtm_lwhrc ,                   &
+               rrtm_lwuflx_dt  ,  rrtm_lwuflxc_dt )
+
+!
+!--             Save fluxes
+                DO k = nzb, nzt+1
+                   rad_lw_in(k,j,i)  = rrtm_lwdflx(0,k)
+                   rad_lw_out(k,j,i) = rrtm_lwuflx(0,k)
+                ENDDO
+
+!
+!--             Save heating rates (convert from K/d to K/h)
+                DO k = nzb+1, nzt+1
+                   rad_lw_hr(k,j,i)     = rrtm_lwhr(0,k)  * d_hours_day
+                   rad_lw_cs_hr(k,j,i)  = rrtm_lwhrc(0,k) * d_hours_day
+                ENDDO
+
+!
+!--             Save change in LW heating rate
+                rad_lw_out_change_0(j,i) = rrtm_lwuflx_dt(0,nzb)
+
+             ENDIF
+
+             IF ( sw_radiation .AND. sun_up )  THEN
+                CALL rrtmg_sw( 1, nzt_rad      , rrtm_icld  , rrtm_iaer       ,&
+               rrtm_play       , rrtm_plev    , rrtm_tlay  , rrtm_tlev        ,&
+               rrtm_tsfc       , rrtm_h2ovmr  , rrtm_o3vmr , rrtm_co2vmr      ,&
+               rrtm_ch4vmr     , rrtm_n2ovmr  , rrtm_o2vmr , rrtm_asdir(:,j,i),&
+               rrtm_asdif(:,j,i), rrtm_aldir(:,j,i), rrtm_aldif(:,j,i), zenith,&
+               0.0_wp          , day          , solar_constant,   rrtm_inflgsw,&
+               rrtm_iceflgsw   , rrtm_liqflgsw, rrtm_cldfr , rrtm_sw_taucld   ,&
+               rrtm_sw_ssacld  , rrtm_sw_asmcld, rrtm_sw_fsfcld, rrtm_cicewp  ,&
+               rrtm_cliqwp     , rrtm_reice   , rrtm_reliq , rrtm_sw_tauaer   ,&
+               rrtm_sw_ssaaer     , rrtm_sw_asmaer  , rrtm_sw_ecaer ,          &
+               rrtm_swuflx     , rrtm_swdflx  , rrtm_swhr  ,                   &
+               rrtm_swuflxc    , rrtm_swdflxc , rrtm_swhrc )
+  
+!
+!--             Save fluxes
+                DO k = nzb, nzt+1
+                   rad_sw_in(k,j,i)  = rrtm_swdflx(0,k)
+                   rad_sw_out(k,j,i) = rrtm_swuflx(0,k)
+                ENDDO
+
+!
+!--             Save heating rates (convert from K/d to K/s)
+                DO k = nzb+1, nzt+1
+                   rad_sw_hr(k,j,i)     = rrtm_swhr(0,k)  * d_hours_day
+                   rad_sw_cs_hr(k,j,i)  = rrtm_swhrc(0,k) * d_hours_day
+                ENDDO
+
+             ENDIF
+
+!
+!--          Calculate surface net radiation
+             rad_net(j,i) = rad_sw_in(nzb,j,i) - rad_sw_out(nzb,j,i)           &
+                            + rad_lw_in(nzb,j,i) - rad_lw_out(nzb,j,i)
+
+          ENDDO
+       ENDDO
+
+       CALL exchange_horiz( rad_lw_in,  nbgp )
+       CALL exchange_horiz( rad_lw_out, nbgp )
+       CALL exchange_horiz( rad_lw_hr,    nbgp )
+       CALL exchange_horiz( rad_lw_cs_hr, nbgp )
+
+       CALL exchange_horiz( rad_sw_in,  nbgp )
+       CALL exchange_horiz( rad_sw_out, nbgp ) 
+       CALL exchange_horiz( rad_sw_hr,    nbgp )
+       CALL exchange_horiz( rad_sw_cs_hr, nbgp )
+
+       CALL exchange_horiz_2d( rad_net, nbgp )
+       CALL exchange_horiz_2d( rad_lw_out_change_0, nbgp )
+#endif
+
+    END SUBROUTINE radiation_rrtmg
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculate the cosine of the zenith angle (variable is called zenith)
+!------------------------------------------------------------------------------!
+    SUBROUTINE calc_zenith
+
+       IMPLICIT NONE
+
+       REAL(wp) ::  declination,  & !< solar declination angle
+                    hour_angle      !< solar hour angle
+!
+!--    Calculate current day and time based on the initial values and simulation
+!--    time
+       day = day_init + INT(FLOOR( (time_utc_init + time_since_reference_point)    &
+                               / 86400.0_wp ), KIND=iwp)
+       time_utc = MOD((time_utc_init + time_since_reference_point), 86400.0_wp)
+
+
+!
+!--    Calculate solar declination and hour angle   
+       declination = ASIN( decl_1 * SIN(decl_2 * REAL(day, KIND=wp) - decl_3) )
+       hour_angle  = 2.0_wp * pi * (time_utc / 86400.0_wp) + lon - pi
+
+!
+!--    Calculate zenith angle
+       zenith(0) = SIN(lat) * SIN(declination) + COS(lat) * COS(declination)      &
+                                            * COS(hour_angle)
+       zenith(0) = MAX(0.0_wp,zenith(0))
+
+!
+!--    Check if the sun is up (otheriwse shortwave calculations can be skipped)
+       IF ( zenith(0) > 0.0_wp )  THEN
+          sun_up = .TRUE.
+       ELSE
+          sun_up = .FALSE.
+       END IF
+
+    END SUBROUTINE calc_zenith
+
+#if defined ( __rrtmg ) && defined ( __netcdf )
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculates surface albedo components based on Briegleb (1992) and 
+!> Briegleb et al. (1986)
+!------------------------------------------------------------------------------!
+    SUBROUTINE calc_albedo
+
+        IMPLICIT NONE
+
+        IF ( sun_up )  THEN
+!
+!--        Ocean
+           IF ( albedo_type == 1 )  THEN
+              rrtm_aldir(0,:,:) = 0.026_wp / ( zenith(0)**1.7_wp + 0.065_wp )  &
+                                  + 0.15_wp * ( zenith(0) - 0.1_wp )           &
+                                            * ( zenith(0) - 0.5_wp )           &
+                                            * ( zenith(0) - 1.0_wp )
+              rrtm_asdir(0,:,:) = rrtm_aldir(0,:,:)
+!
+!--        Snow
+           ELSEIF ( albedo_type == 16 )  THEN
+              IF ( zenith(0) < 0.5_wp )  THEN
+                 rrtm_aldir(0,:,:) = 0.5_wp * (1.0_wp - aldif)                 &
+                                     * ( 3.0_wp / (1.0_wp + 4.0_wp             &
+                                     * zenith(0))) - 1.0_wp
+                 rrtm_asdir(0,:,:) = 0.5_wp * (1.0_wp - asdif)                 &
+                                     * ( 3.0_wp / (1.0_wp + 4.0_wp             &
+                                     * zenith(0))) - 1.0_wp
+
+                 rrtm_aldir(0,:,:) = MIN(0.98_wp, rrtm_aldir(0,:,:))
+                 rrtm_asdir(0,:,:) = MIN(0.98_wp, rrtm_asdir(0,:,:))
+              ELSE
+                 rrtm_aldir(0,:,:) = aldif
+                 rrtm_asdir(0,:,:) = asdif
+              ENDIF
+!
+!--        Sea ice
+           ELSEIF ( albedo_type == 15 )  THEN
+                 rrtm_aldir(0,:,:) = aldif
+                 rrtm_asdir(0,:,:) = asdif
+
+!
+!--        Asphalt
+           ELSEIF ( albedo_type == 17 )  THEN
+                 rrtm_aldir(0,:,:) = aldif
+                 rrtm_asdir(0,:,:) = asdif
+!
+!--        Land surfaces
+           ELSE
+              SELECT CASE ( albedo_type )
+
+!
+!--              Surface types with strong zenith dependence
+                 CASE ( 1, 2, 3, 4, 11, 12, 13 )
+                    rrtm_aldir(0,:,:) = aldif * 1.4_wp /                       &
+                                        (1.0_wp + 0.8_wp * zenith(0))
+                    rrtm_asdir(0,:,:) = asdif * 1.4_wp /                       &
+                                        (1.0_wp + 0.8_wp * zenith(0))
+!
+!--              Surface types with weak zenith dependence
+                 CASE ( 5, 6, 7, 8, 9, 10, 14 )
+                    rrtm_aldir(0,:,:) = aldif * 1.1_wp /                       &
+                                        (1.0_wp + 0.2_wp * zenith(0))
+                    rrtm_asdir(0,:,:) = asdif * 1.1_wp /                       &
+                                        (1.0_wp + 0.2_wp * zenith(0))
+
+                 CASE DEFAULT
+
+              END SELECT
+           ENDIF
+!
+!--        Diffusive albedo is taken from Table 2
+           rrtm_aldif(0,:,:) = aldif
+           rrtm_asdif(0,:,:) = asdif
+
+        ELSE
+
+           rrtm_aldir(0,:,:) = 0.0_wp
+           rrtm_asdir(0,:,:) = 0.0_wp
+           rrtm_aldif(0,:,:) = 0.0_wp
+           rrtm_asdif(0,:,:) = 0.0_wp
+        ENDIF
+    END SUBROUTINE calc_albedo
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Read sounding data (pressure and temperature) from RADIATION_DATA.
+!------------------------------------------------------------------------------!
+    SUBROUTINE read_sounding_data
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) :: id,           & !< NetCDF id of input file
+                       id_dim_zrad,  & !< pressure level id in the NetCDF file
+                       id_var,       & !< NetCDF variable id
+                       k,            & !< loop index
+                       nz_snd,       & !< number of vertical levels in the sounding data
+                       nz_snd_start, & !< start vertical index for sounding data to be used
+                       nz_snd_end      !< end vertical index for souding data to be used
+
+       REAL(wp) :: t_surface           !< actual surface temperature
+
+       REAL(wp), DIMENSION(:), ALLOCATABLE ::  hyp_snd_tmp, & !< temporary hydrostatic pressure profile (sounding)
+                                               t_snd_tmp      !< temporary temperature profile (sounding)
+
+!
+!--    In case of updates, deallocate arrays first (sufficient to check one
+!--    array as the others are automatically allocated). This is required
+!--    because nzt_rad might change during the update
+       IF ( ALLOCATED ( hyp_snd ) )  THEN
+          DEALLOCATE( hyp_snd )
+          DEALLOCATE( t_snd )
+          DEALLOCATE( q_snd  )
+          DEALLOCATE ( rrtm_play )
+          DEALLOCATE ( rrtm_plev )
+          DEALLOCATE ( rrtm_tlay )
+          DEALLOCATE ( rrtm_tlev )
+
+          DEALLOCATE ( rrtm_h2ovmr )
+          DEALLOCATE ( rrtm_cicewp )
+          DEALLOCATE ( rrtm_cldfr )
+          DEALLOCATE ( rrtm_cliqwp )
+          DEALLOCATE ( rrtm_reice )
+          DEALLOCATE ( rrtm_reliq )
+          DEALLOCATE ( rrtm_lw_taucld )
+          DEALLOCATE ( rrtm_lw_tauaer )
+
+          DEALLOCATE ( rrtm_lwdflx  )
+          DEALLOCATE ( rrtm_lwdflxc )
+          DEALLOCATE ( rrtm_lwuflx  )
+          DEALLOCATE ( rrtm_lwuflxc )
+          DEALLOCATE ( rrtm_lwuflx_dt )
+          DEALLOCATE ( rrtm_lwuflxc_dt )
+          DEALLOCATE ( rrtm_lwhr  )
+          DEALLOCATE ( rrtm_lwhrc )
+
+          DEALLOCATE ( rrtm_sw_taucld )
+          DEALLOCATE ( rrtm_sw_ssacld )
+          DEALLOCATE ( rrtm_sw_asmcld )
+          DEALLOCATE ( rrtm_sw_fsfcld )
+          DEALLOCATE ( rrtm_sw_tauaer )
+          DEALLOCATE ( rrtm_sw_ssaaer )
+          DEALLOCATE ( rrtm_sw_asmaer ) 
+          DEALLOCATE ( rrtm_sw_ecaer )   
+ 
+          DEALLOCATE ( rrtm_swdflx  )
+          DEALLOCATE ( rrtm_swdflxc )
+          DEALLOCATE ( rrtm_swuflx  )
+          DEALLOCATE ( rrtm_swuflxc )
+          DEALLOCATE ( rrtm_swhr  )
+          DEALLOCATE ( rrtm_swhrc )
+
+       ENDIF
+
+!
+!--    Open file for reading
+       nc_stat = NF90_OPEN( rrtm_input_file, NF90_NOWRITE, id )
+       CALL netcdf_handle_error_rad( 'read_sounding_data', 549 )
+
+!
+!--    Inquire dimension of z axis and save in nz_snd
+       nc_stat = NF90_INQ_DIMID( id, "Pressure", id_dim_zrad )
+       nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim_zrad, len = nz_snd )
+       CALL netcdf_handle_error_rad( 'read_sounding_data', 551 )
+
+!
+! !--    Allocate temporary array for storing pressure data
+       ALLOCATE( hyp_snd_tmp(1:nz_snd) )
+       hyp_snd_tmp = 0.0_wp
+
+
+!--    Read pressure from file
+       nc_stat = NF90_INQ_VARID( id, "Pressure", id_var )
+       nc_stat = NF90_GET_VAR( id, id_var, hyp_snd_tmp(:), start = (/1/),      &
+                               count = (/nz_snd/) )
+       CALL netcdf_handle_error_rad( 'read_sounding_data', 552 )
+
+!
+!--    Allocate temporary array for storing temperature data
+       ALLOCATE( t_snd_tmp(1:nz_snd) )
+       t_snd_tmp = 0.0_wp
+
+!
+!--    Read temperature from file
+       nc_stat = NF90_INQ_VARID( id, "ReferenceTemperature", id_var )
+       nc_stat = NF90_GET_VAR( id, id_var, t_snd_tmp(:), start = (/1/),        &
+                               count = (/nz_snd/) )
+       CALL netcdf_handle_error_rad( 'read_sounding_data', 553 )
+
+!
+!--    Calculate start of sounding data
+       nz_snd_start = nz_snd + 1
+       nz_snd_end   = nz_snd + 1
+
+!
+!--    Start filling vertical dimension at 10hPa above the model domain (hyp is
+!--    in Pa, hyp_snd in hPa).
+       DO  k = 1, nz_snd
+          IF ( hyp_snd_tmp(k) < ( hyp(nzt+1) - 1000.0_wp) * 0.01_wp )  THEN
+             nz_snd_start = k
+             EXIT
+          END IF
+       END DO
+
+       IF ( nz_snd_start <= nz_snd )  THEN
+          nz_snd_end = nz_snd
+       END IF
+
+
+!
+!--    Calculate of total grid points for RRTMG calculations
+       nzt_rad = nzt + nz_snd_end - nz_snd_start + 1
+
+!
+!--    Save data above LES domain in hyp_snd, t_snd and q_snd
+!--    Note: q_snd_tmp is not calculated at the moment (dry residual atmosphere)
+       ALLOCATE( hyp_snd(nzb+1:nzt_rad) )
+       ALLOCATE( t_snd(nzb+1:nzt_rad)   )
+       ALLOCATE( q_snd(nzb+1:nzt_rad)   )
+       hyp_snd = 0.0_wp
+       t_snd = 0.0_wp
+       q_snd = 0.0_wp
+
+       hyp_snd(nzt+2:nzt_rad) = hyp_snd_tmp(nz_snd_start+1:nz_snd_end)
+       t_snd(nzt+2:nzt_rad)   = t_snd_tmp(nz_snd_start+1:nz_snd_end)
+
+       nc_stat = NF90_CLOSE( id )
+
+!
+!--    Calculate pressure levels on zu and zw grid. Sounding data is added at 
+!--    top of the LES domain. This routine does not consider horizontal or 
+!--    vertical variability of pressure and temperature
+       ALLOCATE ( rrtm_play(0:0,nzb+1:nzt_rad+1)   )
+       ALLOCATE ( rrtm_plev(0:0,nzb+1:nzt_rad+2)   )
+
+       t_surface = pt_surface * ( surface_pressure / 1000.0_wp )**0.286_wp
+       DO k = nzb+1, nzt+1
+          rrtm_play(0,k) = hyp(k) * 0.01_wp
+          rrtm_plev(0,k) = surface_pressure * ( (t_surface - g/cp * zw(k-1)) / &
+                         t_surface )**(1.0_wp/0.286_wp)
+       ENDDO
+
+       DO k = nzt+2, nzt_rad
+          rrtm_play(0,k) = hyp_snd(k)
+          rrtm_plev(0,k) = 0.5_wp * ( rrtm_play(0,k) + rrtm_play(0,k-1) )
+       ENDDO
+       rrtm_plev(0,nzt_rad+1) = MAX( 0.5 * hyp_snd(nzt_rad),                   &
+                                   1.5 * hyp_snd(nzt_rad)                      &
+                                 - 0.5 * hyp_snd(nzt_rad-1) )
+       rrtm_plev(0,nzt_rad+2)  = MIN( 1.0E-4_wp,                               &
+                                      0.25_wp * rrtm_plev(0,nzt_rad+1) )
+
+       rrtm_play(0,nzt_rad+1) = 0.5 * rrtm_plev(0,nzt_rad+1)
+
+!
+!--    Calculate temperature/humidity levels at top of the LES domain. 
+!--    Currently, the temperature is taken from sounding data (might lead to a 
+!--    temperature jump at interface. To do: Humidity is currently not 
+!--    calculated above the LES domain.
+       ALLOCATE ( rrtm_tlay(0:0,nzb+1:nzt_rad+1)   )
+       ALLOCATE ( rrtm_tlev(0:0,nzb+1:nzt_rad+2)   )
+       ALLOCATE ( rrtm_h2ovmr(0:0,nzb+1:nzt_rad+1) )
+
+       DO k = nzt+8, nzt_rad
+          rrtm_tlay(0,k)   = t_snd(k)
+          rrtm_h2ovmr(0,k) = q_snd(k)
+       ENDDO
+       rrtm_tlay(0,nzt_rad+1) = 2.0_wp * rrtm_tlay(0,nzt_rad)                 &
+                                - rrtm_tlay(0,nzt_rad-1)
+       DO k = nzt+9, nzt_rad+1
+          rrtm_tlev(0,k)   = rrtm_tlay(0,k-1) + (rrtm_tlay(0,k)                &
+                             - rrtm_tlay(0,k-1))                               &
+                             / ( rrtm_play(0,k) - rrtm_play(0,k-1) )           &
+                             * ( rrtm_plev(0,k) - rrtm_play(0,k-1) )
+       ENDDO
+       rrtm_h2ovmr(0,nzt_rad+1) = rrtm_h2ovmr(0,nzt_rad)
+
+       rrtm_tlev(0,nzt_rad+2)   = 2.0_wp * rrtm_tlay(0,nzt_rad+1)              &
+                                  - rrtm_tlev(0,nzt_rad)
+!
+!--    Allocate remaining RRTMG arrays
+       ALLOCATE ( rrtm_cicewp(0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_cldfr(0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_cliqwp(0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_reice(0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_reliq(0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_lw_taucld(1:nbndlw+1,0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_lw_tauaer(0:0,nzb+1:nzt_rad+1,1:nbndlw+1) )
+       ALLOCATE ( rrtm_sw_taucld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_sw_ssacld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_sw_asmcld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_sw_fsfcld(1:nbndsw+1,0:0,nzb+1:nzt_rad+1) )
+       ALLOCATE ( rrtm_sw_tauaer(0:0,nzb+1:nzt_rad+1,1:nbndsw+1) )
+       ALLOCATE ( rrtm_sw_ssaaer(0:0,nzb+1:nzt_rad+1,1:nbndsw+1) )
+       ALLOCATE ( rrtm_sw_asmaer(0:0,nzb+1:nzt_rad+1,1:nbndsw+1) ) 
+       ALLOCATE ( rrtm_sw_ecaer(0:0,nzb+1:nzt_rad+1,1:naerec+1) )    
+
+!
+!--    The ice phase is currently not considered in PALM
+       rrtm_cicewp = 0.0_wp
+       rrtm_reice  = 0.0_wp
+
+!
+!--    Set other parameters (move to NAMELIST parameters in the future)
+       rrtm_lw_tauaer = 0.0_wp
+       rrtm_lw_taucld = 0.0_wp
+       rrtm_sw_taucld = 0.0_wp
+       rrtm_sw_ssacld = 0.0_wp
+       rrtm_sw_asmcld = 0.0_wp
+       rrtm_sw_fsfcld = 0.0_wp
+       rrtm_sw_tauaer = 0.0_wp
+       rrtm_sw_ssaaer = 0.0_wp
+       rrtm_sw_asmaer = 0.0_wp
+       rrtm_sw_ecaer  = 0.0_wp
+
+
+       ALLOCATE ( rrtm_swdflx(0:0,nzb:nzt_rad+1)  )
+       ALLOCATE ( rrtm_swuflx(0:0,nzb:nzt_rad+1)  )
+       ALLOCATE ( rrtm_swhr(0:0,nzb+1:nzt_rad+1)  )
+       ALLOCATE ( rrtm_swuflxc(0:0,nzb:nzt_rad+1) )
+       ALLOCATE ( rrtm_swdflxc(0:0,nzb:nzt_rad+1) )
+       ALLOCATE ( rrtm_swhrc(0:0,nzb+1:nzt_rad+1) )
+
+       rrtm_swdflx  = 0.0_wp
+       rrtm_swuflx  = 0.0_wp
+       rrtm_swhr    = 0.0_wp  
+       rrtm_swuflxc = 0.0_wp
+       rrtm_swdflxc = 0.0_wp
+       rrtm_swhrc   = 0.0_wp
+
+       ALLOCATE ( rrtm_lwdflx(0:0,nzb:nzt_rad+1)  )
+       ALLOCATE ( rrtm_lwuflx(0:0,nzb:nzt_rad+1)  )
+       ALLOCATE ( rrtm_lwhr(0:0,nzb+1:nzt_rad+1)  )
+       ALLOCATE ( rrtm_lwuflxc(0:0,nzb:nzt_rad+1) )
+       ALLOCATE ( rrtm_lwdflxc(0:0,nzb:nzt_rad+1) )
+       ALLOCATE ( rrtm_lwhrc(0:0,nzb+1:nzt_rad+1) )
+
+       rrtm_lwdflx  = 0.0_wp
+       rrtm_lwuflx  = 0.0_wp
+       rrtm_lwhr    = 0.0_wp  
+       rrtm_lwuflxc = 0.0_wp
+       rrtm_lwdflxc = 0.0_wp
+       rrtm_lwhrc   = 0.0_wp
+
+       ALLOCATE ( rrtm_lwuflx_dt(0:0,nzb:nzt_rad+1) )
+       ALLOCATE ( rrtm_lwuflxc_dt(0:0,nzb:nzt_rad+1) )
+
+       rrtm_lwuflx_dt = 0.0_wp
+       rrtm_lwuflxc_dt = 0.0_wp
+
+    END SUBROUTINE read_sounding_data
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Read trace gas data from file
+!------------------------------------------------------------------------------!
+    SUBROUTINE read_trace_gas_data
+
+       USE rrsw_ncpar
+
+       IMPLICIT NONE
+
+       INTEGER(iwp), PARAMETER :: num_trace_gases = 9 !< number of trace gases (absorbers)
+
+       CHARACTER(LEN=5), DIMENSION(num_trace_gases), PARAMETER ::              & !< trace gas names
+           trace_names = (/'O3   ', 'CO2  ', 'CH4  ', 'N2O  ', 'O2   ',        &
+                           'CFC11', 'CFC12', 'CFC22', 'CCL4 '/)
+
+       INTEGER(iwp) :: id,     & !< NetCDF id
+                       k,      & !< loop index
+                       m,      & !< loop index
+                       n,      & !< loop index
+                       nabs,   & !< number of absorbers
+                       np,     & !< number of pressure levels
+                       id_abs, & !< NetCDF id of the respective absorber
+                       id_dim, & !< NetCDF id of asborber's dimension
+                       id_var    !< NetCDf id ot the absorber
+
+       REAL(wp) :: p_mls_l, p_mls_u, p_wgt_l, p_wgt_u, p_mls_m
+
+
+       REAL(wp), DIMENSION(:), ALLOCATABLE   ::  p_mls,         & !< pressure levels for the absorbers
+                                                 rrtm_play_tmp, & !< temporary array for pressure zu-levels
+                                                 rrtm_plev_tmp, & !< temporary array for pressure zw-levels
+                                                 trace_path_tmp   !< temporary array for storing trace gas path data
+
+       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  trace_mls,      & !< array for storing the absorber amounts
+                                                 trace_mls_path, & !< array for storing trace gas path data
+                                                 trace_mls_tmp     !< temporary array for storing trace gas data
+
+
+!
+!--    In case of updates, deallocate arrays first (sufficient to check one
+!--    array as the others are automatically allocated)
+       IF ( ALLOCATED ( rrtm_o3vmr ) )  THEN
+          DEALLOCATE ( rrtm_o3vmr  )
+          DEALLOCATE ( rrtm_co2vmr )
+          DEALLOCATE ( rrtm_ch4vmr )
+          DEALLOCATE ( rrtm_n2ovmr )
+          DEALLOCATE ( rrtm_o2vmr  )
+          DEALLOCATE ( rrtm_cfc11vmr )
+          DEALLOCATE ( rrtm_cfc12vmr )
+          DEALLOCATE ( rrtm_cfc22vmr )
+          DEALLOCATE ( rrtm_ccl4vmr  )
+       ENDIF
+
+!
+!--    Allocate trace gas profiles
+       ALLOCATE ( rrtm_o3vmr(0:0,1:nzt_rad+1)  )
+       ALLOCATE ( rrtm_co2vmr(0:0,1:nzt_rad+1) )
+       ALLOCATE ( rrtm_ch4vmr(0:0,1:nzt_rad+1) )
+       ALLOCATE ( rrtm_n2ovmr(0:0,1:nzt_rad+1) )
+       ALLOCATE ( rrtm_o2vmr(0:0,1:nzt_rad+1)  )
+       ALLOCATE ( rrtm_cfc11vmr(0:0,1:nzt_rad+1) )
+       ALLOCATE ( rrtm_cfc12vmr(0:0,1:nzt_rad+1) )
+       ALLOCATE ( rrtm_cfc22vmr(0:0,1:nzt_rad+1) )
+       ALLOCATE ( rrtm_ccl4vmr(0:0,1:nzt_rad+1)  )
+
+!
+!--    Open file for reading
+       nc_stat = NF90_OPEN( rrtm_input_file, NF90_NOWRITE, id )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 549 )
+!
+!--    Inquire dimension ids and dimensions
+       nc_stat = NF90_INQ_DIMID( id, "Pressure", id_dim )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+       nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim, len = np) 
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+
+       nc_stat = NF90_INQ_DIMID( id, "Absorber", id_dim )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+       nc_stat = NF90_INQUIRE_DIMENSION( id, id_dim, len = nabs ) 
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+   
+
+!
+!--    Allocate pressure, and trace gas arrays     
+       ALLOCATE( p_mls(1:np) )
+       ALLOCATE( trace_mls(1:num_trace_gases,1:np) ) 
+       ALLOCATE( trace_mls_tmp(1:nabs,1:np) ) 
+
+
+       nc_stat = NF90_INQ_VARID( id, "Pressure", id_var )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+       nc_stat = NF90_GET_VAR( id, id_var, p_mls )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+
+       nc_stat = NF90_INQ_VARID( id, "AbsorberAmountMLS", id_var )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+       nc_stat = NF90_GET_VAR( id, id_var, trace_mls_tmp )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 550 )
+
+
+!
+!--    Write absorber amounts (mls) to trace_mls
+       DO n = 1, num_trace_gases
+          CALL getAbsorberIndex( TRIM( trace_names(n) ), id_abs )
+
+          trace_mls(n,1:np) = trace_mls_tmp(id_abs,1:np)
+
+!
+!--       Replace missing values by zero
+          WHERE ( trace_mls(n,:) > 2.0_wp )  
+             trace_mls(n,:) = 0.0_wp
+          END WHERE
+       END DO
+
+       DEALLOCATE ( trace_mls_tmp )
+
+       nc_stat = NF90_CLOSE( id )
+       CALL netcdf_handle_error_rad( 'read_trace_gas_data', 551 )
+
+!
+!--    Add extra pressure level for calculations of the trace gas paths
+       ALLOCATE ( rrtm_play_tmp(1:nzt_rad+1) )
+       ALLOCATE ( rrtm_plev_tmp(1:nzt_rad+2) )
+
+       rrtm_play_tmp(1:nzt_rad)   = rrtm_play(0,1:nzt_rad) 
+       rrtm_plev_tmp(1:nzt_rad+1) = rrtm_plev(0,1:nzt_rad+1)
+       rrtm_play_tmp(nzt_rad+1)   = rrtm_plev(0,nzt_rad+1) * 0.5_wp
+       rrtm_plev_tmp(nzt_rad+2)   = MIN( 1.0E-4_wp, 0.25_wp                    &
+                                         * rrtm_plev(0,nzt_rad+1) )
+ 
+!
+!--    Calculate trace gas path (zero at surface) with interpolation to the
+!--    sounding levels
+       ALLOCATE ( trace_mls_path(1:nzt_rad+2,1:num_trace_gases) )
+
+       trace_mls_path(nzb+1,:) = 0.0_wp
+       
+       DO k = nzb+2, nzt_rad+2
+          DO m = 1, num_trace_gases
+             trace_mls_path(k,m) = trace_mls_path(k-1,m)
+
+!
+!--          When the pressure level is higher than the trace gas pressure
+!--          level, assume that 
+             IF ( rrtm_plev_tmp(k-1) > p_mls(1) )  THEN             
+                
+                trace_mls_path(k,m) = trace_mls_path(k,m) + trace_mls(m,1)     &
+                                      * ( rrtm_plev_tmp(k-1)                   &
+                                          - MAX( p_mls(1), rrtm_plev_tmp(k) )  &
+                                        ) / g
+             ENDIF
+
+!
+!--          Integrate for each sounding level from the contributing p_mls 
+!--          levels
+             DO n = 2, np
+!
+!--             Limit p_mls so that it is within the model level
+                p_mls_u = MIN( rrtm_plev_tmp(k-1),                             &
+                          MAX( rrtm_plev_tmp(k), p_mls(n) ) )
+                p_mls_l = MIN( rrtm_plev_tmp(k-1),                             &
+                          MAX( rrtm_plev_tmp(k), p_mls(n-1) ) )
+
+                IF ( p_mls_l > p_mls_u )  THEN
+
+!
+!--                Calculate weights for interpolation
+                   p_mls_m = 0.5_wp * (p_mls_l + p_mls_u)
+                   p_wgt_u = (p_mls(n-1) - p_mls_m) / (p_mls(n-1) - p_mls(n))
+                   p_wgt_l = (p_mls_m - p_mls(n))   / (p_mls(n-1) - p_mls(n))
+
+!
+!--                Add level to trace gas path
+                   trace_mls_path(k,m) = trace_mls_path(k,m)                   &
+                                         +  ( p_wgt_u * trace_mls(m,n)         &
+                                            + p_wgt_l * trace_mls(m,n-1) )     &
+                                         * (p_mls_l - p_mls_u) / g
+                ENDIF
+             ENDDO
+
+             IF ( rrtm_plev_tmp(k) < p_mls(np) )  THEN 
+                trace_mls_path(k,m) = trace_mls_path(k,m) + trace_mls(m,np)    &
+                                      * ( MIN( rrtm_plev_tmp(k-1), p_mls(np) ) &
+                                          - rrtm_plev_tmp(k)                   &
+                                        ) / g 
+             ENDIF  
+          ENDDO
+       ENDDO
+
+
+!
+!--    Prepare trace gas path profiles
+       ALLOCATE ( trace_path_tmp(1:nzt_rad+1) )
+
+       DO m = 1, num_trace_gases
+
+          trace_path_tmp(1:nzt_rad+1) = ( trace_mls_path(2:nzt_rad+2,m)        &
+                                       - trace_mls_path(1:nzt_rad+1,m) ) * g   &
+                                       / ( rrtm_plev_tmp(1:nzt_rad+1)          &
+                                       - rrtm_plev_tmp(2:nzt_rad+2) )
+
+!
+!--       Save trace gas paths to the respective arrays
+          SELECT CASE ( TRIM( trace_names(m) ) )
+
+             CASE ( 'O3' )
+
+                rrtm_o3vmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'CO2' )
+
+                rrtm_co2vmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'CH4' )
+
+                rrtm_ch4vmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'N2O' )
+
+                rrtm_n2ovmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'O2' )
+
+                rrtm_o2vmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'CFC11' )
+
+                rrtm_cfc11vmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'CFC12' )
+
+                rrtm_cfc12vmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'CFC22' )
+
+                rrtm_cfc22vmr(0,:) = trace_path_tmp(:)
+
+             CASE ( 'CCL4' )
+
+                rrtm_ccl4vmr(0,:) = trace_path_tmp(:)
+
+             CASE DEFAULT
+
+          END SELECT
+
+       ENDDO
+
+       DEALLOCATE ( trace_path_tmp )
+       DEALLOCATE ( trace_mls_path )
+       DEALLOCATE ( rrtm_play_tmp )
+       DEALLOCATE ( rrtm_plev_tmp )
+       DEALLOCATE ( trace_mls )
+       DEALLOCATE ( p_mls )
+
+    END SUBROUTINE read_trace_gas_data
+
+
+    SUBROUTINE netcdf_handle_error_rad( routine_name, errno )
+
+       USE control_parameters,                                                 &
+           ONLY:  message_string
+
+       USE NETCDF
+
+       USE pegrid
+
+       IMPLICIT NONE
+
+       CHARACTER(LEN=6) ::  message_identifier
+       CHARACTER(LEN=*) ::  routine_name
+
+       INTEGER(iwp) ::  errno
+
+       IF ( nc_stat /= NF90_NOERR )  THEN
+
+          WRITE( message_identifier, '(''NC'',I4.4)' )  errno
+          message_string = TRIM( NF90_STRERROR( nc_stat ) )
+
+          CALL message( routine_name, message_identifier, 2, 2, 0, 6, 1 )
+
+       ENDIF
+
+    END SUBROUTINE netcdf_handle_error_rad
+#endif
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculate temperature tendency due to radiative cooling/heating.
+!> Cache-optimized version.
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_tendency_ij ( i, j, tend )
+
+       USE cloud_parameters,                                                   &
+           ONLY:  pt_d_t
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) :: i, j, k !< loop indices
+
+       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tend !< pt tendency term
+
+#if defined ( __rrtmg )
+!
+!--    Calculate tendency based on heating rate
+       DO k = nzb+1, nzt+1
+          tend(k,j,i) = tend(k,j,i) + (rad_lw_hr(k,j,i) + rad_sw_hr(k,j,i))    &
+                                      * pt_d_t(k) * d_seconds_hour
+       ENDDO
+
+#endif
+
+    END SUBROUTINE radiation_tendency_ij
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Calculate temperature tendency due to radiative cooling/heating.
+!> Vector-optimized version
+!------------------------------------------------------------------------------!
+    SUBROUTINE radiation_tendency ( tend )
+
+       USE cloud_parameters,                                                   &
+           ONLY:  pt_d_t
+
+       USE indices,                                                            &
+           ONLY:  nxl, nxr, nyn, nys
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) :: i, j, k !< loop indices
+
+       REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: tend !< pt tendency term
+
+#if defined ( __rrtmg )
+!
+!--    Calculate tendency based on heating rate
+       DO  i = nxl, nxr
+          DO  j = nys, nyn
+             DO k = nzb+1, nzt+1
+                tend(k,j,i) = tend(k,j,i) + ( rad_lw_hr(k,j,i)                 &
+                                            +  rad_sw_hr(k,j,i) ) * pt_d_t(k)  &
+                                            * d_seconds_hour
+             ENDDO
+         ENDDO
+       ENDDO
+#endif
+
+    END SUBROUTINE radiation_tendency
+
+ END MODULE radiation_model_mod
