Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 4185)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 4186)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Design change, use variables defined in netcdf_data_input_mod to read netcd
+! variables rather than define local ones.
+! 
+! 4185 2019-08-23 13:49:38Z oliver.maas
 ! For initializing_actions = ' cyclic_fill':
 ! Overwrite u_init, v_init, pt_init, q_init and s_init with the 
@@ -160,6 +164,9 @@
                input_file_static,                                              &
                netcdf_data_input_init_3d,                                      &
+               num_var_pids,                                                   &
                open_read_file,                                                 &
-               real_2d
+               pids_id,                                                        &
+               real_2d,                                                        &
+               vars_pids
                
     USE nesting_offl_mod,                                                      &
@@ -213,6 +220,4 @@
 
     IMPLICIT NONE
-
-    CHARACTER(LEN=50), DIMENSION(:), ALLOCATABLE ::  vars_pids_static  !< variable names in static input file
     
     INTEGER(iwp) ::  i                    !< grid index in x direction
@@ -223,5 +228,4 @@
     INTEGER(iwp) ::  l                    !< running index over surface orientation   
     INTEGER(iwp) ::  m                    !< index of surface element in surface data type    
-    INTEGER(iwp) ::  num_vars_pids_static !< number of variables in static input file
     INTEGER(iwp) ::  nz_u_shift           !< topography-top index on u-grid, used to vertically shift initial profiles
     INTEGER(iwp) ::  nz_v_shift           !< topography-top index on v-grid, used to vertically shift initial profiles
@@ -233,5 +237,4 @@
     INTEGER(iwp) ::  nz_s_shift_l         !< topography-top index on scalar-grid, used to vertically shift initial profiles
     INTEGER(iwp) ::  nzt_l                !< index of top PE boundary for multigrid level
-    INTEGER(iwp) ::  pids_static_id       !< file id for static input file
     INTEGER(iwp) ::  sr                   !< index of statistic region
 
@@ -1541,21 +1544,21 @@
        CALL open_read_file( TRIM( input_file_static ) //                    &
                             TRIM( coupling_char ),                          &
-                            pids_static_id )
+                            pids_id )
                             
-       CALL inquire_num_variables( pids_static_id, num_vars_pids_static )
+       CALL inquire_num_variables( pids_id, num_var_pids )
 !
 !--    Allocate memory to store variable names and read them
-       ALLOCATE( vars_pids_static(1:num_vars_pids_static) )
-       CALL inquire_variable_names( pids_static_id, vars_pids_static )
+       ALLOCATE( vars_pids(1:num_var_pids) )
+       CALL inquire_variable_names( pids_id, vars_pids )
 !
 !--    Input roughness length. 
-       IF ( check_existence( vars_pids_static, 'z0' ) )  THEN
+       IF ( check_existence( vars_pids, 'z0' ) )  THEN
 !
 !--       Read _FillValue attribute
-          CALL get_attribute( pids_static_id, char_fill, tmp_2d%fill,          &
+          CALL get_attribute( pids_id, char_fill, tmp_2d%fill,          &
                               .FALSE., 'z0' )                                  
 !                                                                              
 !--       Read variable                                                        
-          CALL get_variable( pids_static_id, 'z0', tmp_2d%var,                 &
+          CALL get_variable( pids_id, 'z0', tmp_2d%var,                 &
                              nxl, nxr, nys, nyn )                              
 !                                                                              
@@ -1592,5 +1595,5 @@
 !
 !--    Finally, close the input file.
-       CALL close_input_file( pids_static_id )
+       CALL close_input_file( pids_id )
 #endif
        DEALLOCATE( tmp_2d%var )
Index: palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4185)
+++ palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4186)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Minor formatting adjustments
+! 
+! 4182 2019-08-22 15:20:23Z scharf
 ! Corrected "Former revisions" section
 ! 
@@ -5057,13 +5060,17 @@
 
 #if defined( __netcdf4_parallel )
-!      if __netcdf4_parallel is defined, parrallel NetCDF will be used unconditionally
+!
+!--    If __netcdf4_parallel is defined, parrallel NetCDF will be used
+!--    unconditionally
        nc_stat = NF90_OPEN( filename, IOR( NF90_WRITE, NF90_MPIIO ), id,  &
                             COMM = comm2d, INFO = MPI_INFO_NULL )
-       IF(nc_stat /= NF90_NOERR )  THEN                                       !possible NetCDF 3 file
-           nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id )
-           collective_read = .FALSE.
+!
+!--    Check for possible Netcdf 3 file. 
+       IF( nc_stat /= NF90_NOERR )  THEN
+          nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id )
+          collective_read = .FALSE.
        ELSE
-           collective_read = .TRUE.
-       END IF
+          collective_read = .TRUE.
+       ENDIF
 #else
 !      All MPI processes open und read
Index: palm/trunk/SOURCE/surface_layer_fluxes_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 4185)
+++ palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 4186)
@@ -26,4 +26,10 @@
 ! -----------------
 ! $Id$
+! - To enable limitation of Obukhov length, move it before exit-cycle construct. 
+!   Further, change the limit to 10E-5 in order to get rid-off unrealistic 
+!   peaks in the heat fluxes during nighttime
+! - Unused variable removed
+! 
+! 4182 2019-08-22 15:20:23Z scharf
 ! Corrected "Former revisions" section
 ! 
@@ -129,6 +135,4 @@
     INTEGER(iwp) ::  l              !< loop index for surf type
 
-    INTEGER(iwp), PARAMETER ::  num_steps = 15000  !< number of steps in the lookup table
-
     LOGICAL      ::  coupled_run       !< Flag for coupled atmosphere-ocean runs
     LOGICAL      ::  downward = .FALSE.!< Flag indicating downward-facing horizontal surface
@@ -1008,4 +1012,11 @@
              ENDIF
 !
+!--          Assure that Obukhov length does not become zero. If the limit is
+!--          reached, exit the loop.
+             IF ( ABS( surf%ol(m) ) < 1E-5_wp )  THEN
+                surf%ol(m) = SIGN( 1E-5_wp, surf%ol(m) )
+                EXIT
+             ENDIF
+!
 !--          Check for convergence
              IF ( ABS( ( surf%ol(m) - ol_m ) /  surf%ol(m) ) < 1.0E-4_wp )  THEN
@@ -1013,9 +1024,5 @@
              ELSE
                 CYCLE
-             ENDIF
-!
-!--          Assure that Obukhov length does not become zero
-             IF ( ABS( surf%ol(m) ) < 1E-6_wp )                                &
-                surf%ol(m) = SIGN( 10E-6_wp, surf%ol(m) )              
+             ENDIF              
 
           ENDDO
