Index: /palm/trunk/SOURCE/netcdf_data_input_mod.f90
===================================================================
--- /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4297)
+++ /palm/trunk/SOURCE/netcdf_data_input_mod.f90	(revision 4298)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Open input files with read-only attribute instead of write attribute.
+! 
+! 4280 2019-10-29 14:34:15Z monakurppa
 ! Remove id_emis flags from get_variable_4d_to_3d_real and
 ! get_variable_5d_to_4d_real
@@ -4154,10 +4157,10 @@
 #if defined( __netcdf4_parallel )
 !
-!--    If __netcdf4_parallel is defined, parrallel NetCDF will be used
-!--    unconditionally
-       nc_stat = NF90_OPEN( filename, IOR( NF90_WRITE, NF90_MPIIO ), id,  &
+!--    If __netcdf4_parallel is defined, parrallel NetCDF will be used.
+       nc_stat = NF90_OPEN( filename, IOR( NF90_NOWRITE, NF90_MPIIO ), id,     &
                             COMM = comm2d, INFO = MPI_INFO_NULL )
 !
-!--    Check for possible Netcdf 3 file. 
+!--    In case the previous open call fails, check for possible Netcdf 3 file,
+!--    and open it. However, this case, disable parallel access. 
        IF( nc_stat /= NF90_NOERR )  THEN
           nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id )
@@ -4167,5 +4170,6 @@
        ENDIF
 #else
-!      All MPI processes open und read
+!
+!--    All MPI processes open the file and read it (but not in parallel).
        nc_stat = NF90_OPEN( filename, NF90_NOWRITE, id )
 #endif
Index: /palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- /palm/trunk/SOURCE/salsa_mod.f90	(revision 4297)
+++ /palm/trunk/SOURCE/salsa_mod.f90	(revision 4298)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Bugfix, close netcdf input files after reading
+! 
+! 4295 2019-11-14 06:15:31Z monakurppa
 ! 
 ! 
@@ -2154,4 +2157,7 @@
 
           DEALLOCATE( pr_z, pr_mass_fracs_a, pr_mass_fracs_b )
+!
+!--       Close input file
+          CALL close_input_file( id_dyn )
 
        ELSE
@@ -2159,7 +2165,5 @@
                            ' for SALSA missing!'
           CALL message( 'salsa_mod: aerosol_init', 'PA0607', 1, 2, 0, 6, 0 )
-!
-!--       Close input file
-          CALL close_input_file( id_dyn )
+
        ENDIF   ! netcdf_extend
 
@@ -2253,4 +2257,7 @@
              ENDIF
           ENDDO
+!
+!--       Close input file
+          CALL close_input_file( id_dyn )
 
        ELSEIF ( .NOT. netcdf_extend  .AND.  .NOT.  salsa_gases_from_chem )  THEN
@@ -2258,7 +2265,5 @@
                            ' for SALSA missing!'
           CALL message( 'salsa_mod: aerosol_init', 'PA0610', 1, 2, 0, 6, 0 )
-!
-!--       Close input file
-          CALL close_input_file( id_dyn )
+
        ENDIF   ! netcdf_extend
 #else
@@ -12702,4 +12707,6 @@
                         'PA0662', 2, 2, 0, 6, 0 )
        ENDIF
+       
+       CALL close_input_file( salsa_nest_offl%id_dynamic )
 #endif
     ENDIF
Index: /palm/trunk/SOURCE/surface_layer_fluxes_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 4297)
+++ /palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 4298)
@@ -26,4 +26,8 @@
 ! -----------------
 ! $Id$
+! Calculation of 2-m temperature adjusted to the case the 2-m level is above 
+! the first grid point.
+! 
+! 4258 2019-10-07 13:29:08Z suehring
 ! Initialization of Obukhov lenght also at vertical surfaces (if allocated).
 ! 
@@ -105,9 +109,8 @@
                debug_output_timestep,                                          &
                do_output_at_2m, humidity,                                      &
-               ibc_e_b, ibc_pt_b, indoor_model, initializing_actions,          &
-               intermediate_timestep_count, intermediate_timestep_count_max,   &
+               ibc_e_b, ibc_pt_b, indoor_model,                                &
                land_surface, large_scale_forcing, lsf_surf, message_string,    &
                neutral, passive_scalar, pt_surface, q_surface,                 &
-               run_coupled, surface_pressure, simulated_time, terminate_run,   &
+               run_coupled, surface_pressure, simulated_time,                  &
                time_since_reference_point, urban_surface,                      &
                use_free_convection_scaling, zeta_max, zeta_min
@@ -117,5 +120,5 @@
 
     USE indices,                                                               &
-        ONLY:  nxl, nxr, nys, nyn, nzb
+        ONLY:  nzt
 
     USE kinds
@@ -1856,6 +1859,10 @@
        IMPLICIT NONE
 
-       CHARACTER (LEN = *), INTENT(IN)       :: z_char       !< string identifier to identify z level
-       INTEGER(iwp)                          :: i, j, k, m   !< running indices
+       CHARACTER (LEN = *), INTENT(IN) :: z_char !< string identifier to identify z level
+       INTEGER(iwp)                    :: i      !< grid index x-dimension
+       INTEGER(iwp)                    :: j      !< grid index y-dimension 
+       INTEGER(iwp)                    :: k      !< grid index z-dimension
+       INTEGER(iwp)                    :: kk     !< running index along the z-dimension
+       INTEGER(iwp)                    :: m      !< running index for surface elements
 
        
@@ -1873,10 +1880,12 @@
                 surf%pt_10cm(m) = surf%pt_surface(m) + surf%ts(m) / kappa      &
                                    * ( LOG( 0.1_wp /  surf%z0h(m) )            &
-                                  - psi_h( 0.1_wp / surf%ol(m) )               &
+                                     - psi_h( 0.1_wp / surf%ol(m) )            &
                                      + psi_h( surf%z0h(m) / surf%ol(m) ) )
                                     
              ENDDO
 
-
+!
+!--       2-m temperature. Note, this is only calculated for output reasons at
+!--       horizontal upward-facing surfaces. 
           CASE ( '2m' )
       
@@ -1886,9 +1895,32 @@
                 j = surf%j(m)
                 k = surf%k(m)
-
-                surf%pt_2m(m) = surf%pt_surface(m) + surf%ts(m) / kappa        &
+!
+!--             If 2-m level is below the first grid level, MOST is 
+!--             used for calculation of 2-m temperature.
+                IF ( surf%z_mo(m) > 2.0_wp )  THEN
+                   surf%pt_2m(m) = surf%pt_surface(m) + surf%ts(m) / kappa     &
                                    * ( LOG( 2.0_wp /  surf%z0h(m) )            &
                                      - psi_h( 2.0_wp / surf%ol(m) )            &
                                      + psi_h( surf%z0h(m) / surf%ol(m) ) )
+!
+!--             If 2-m level is above the first grid level, 2-m temperature
+!--             is linearly interpolated between the two nearest vertical grid
+!--             levels. Note, since 2-m temperature is only computed for
+!--             horizontal upward-facing surfaces, only a vertical 
+!--             interpolation is necessary. 
+                ELSE
+!
+!--                zw(k-1) defines the height of the surface. 
+                   kk = k
+                   DO WHILE ( zu(kk) - zw(k-1) < 2.0_wp  .AND.  kk <= nzt )
+                      kk = kk + 1 
+                   ENDDO               
+!
+!--                kk defines the index of the first grid level >= 2m. 
+                   surf%pt_2m(m) = pt(kk-1,j,i) +                              &
+                                 ( zw(k-1) + 2.0_wp - zu(kk-1)     ) *         &
+                                 ( pt(kk,j,i)       - pt(kk-1,j,i) ) /         &
+                                 ( zu(kk)           - zu(kk-1)     )
+                ENDIF
 
              ENDDO
