Index: palm/trunk/SOURCE/surface_layer_fluxes_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 4593)
+++ palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 4594)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Include k index in OMP PRIVATE statements
+!
+! 4593 2020-07-09 12:48:18Z suehring
 ! - Pre-calculate ln(z/z0) at each timestep in order to reduce the number of log-calculations
 ! - Bugfix - add missing density to fluxes of passive-scalars, chemistry and cloud-phyiscal
@@ -1301,5 +1304,5 @@
 !--    Compute u* at downward-facing surfaces. This case, do not consider any stability.
        ELSE
-          !$OMP PARALLEL  DO
+          !$OMP PARALLEL DO
           !$ACC PARALLEL LOOP &
           !$ACC PRESENT(surf)
@@ -1836,5 +1839,5 @@
           !$OMP PARALLEL DO PRIVATE( k )
           DO  m = 1, surf%ns
-             k    = surf%k(m)
+             k = surf%k(m)
              surf%qsws(m) = -surf%qs(m) * surf%us(m) * rho_air_zw(k-1)
           ENDDO
@@ -1843,6 +1846,7 @@
 !--    Compute the vertical scalar flux
        IF (  .NOT.  constant_scalarflux  .AND.  passive_scalar  .AND.  .NOT.  downward )  THEN
-          !$OMP PARALLEL DO
-          DO  m = 1, surf%ns
+          !$OMP PARALLEL DO PRIVATE( k )
+          DO  m = 1, surf%ns
+             k = surf%k(m)
              surf%ssws(m) = -surf%ss(m) * surf%us(m) * rho_air_zw(k-1)
           ENDDO
@@ -1852,6 +1856,7 @@
        DO  lsp = 1, nvar
           IF (  .NOT.  constant_csflux(lsp)  .AND.  air_chemistry  .AND.  .NOT.  downward )  THEN
-             !$OMP PARALLEL DO
+             !$OMP PARALLEL DO PRIVATE( k )
              DO  m = 1, surf%ns
+                k = surf%k(m)
                 surf%cssws(lsp,m) = -surf%css(lsp,m) * surf%us(m) * rho_air_zw(k-1)
              ENDDO
@@ -1862,6 +1867,7 @@
 !--    Compute (turbulent) fluxes of cloud water content and cloud drop conc.
        IF ( bulk_cloud_model  .AND.  microphysics_morrison  .AND.  .NOT. downward)  THEN
-          !$OMP PARALLEL DO
-          DO  m = 1, surf%ns
+          !$OMP PARALLEL DO PRIVATE( k )
+          DO  m = 1, surf%ns
+             k = surf%k(m)
              surf%qcsws(m) = -surf%qcs(m) * surf%us(m) * rho_air_zw(k-1)
              surf%ncsws(m) = -surf%ncs(m) * surf%us(m) * rho_air_zw(k-1)
@@ -1871,6 +1877,7 @@
 !--    Compute (turbulent) fluxes of rain water content and rain drop conc.
        IF ( bulk_cloud_model  .AND.  microphysics_seifert  .AND.  .NOT. downward)  THEN
-          !$OMP PARALLEL DO
-          DO  m = 1, surf%ns
+          !$OMP PARALLEL DO PRIVATE( k )
+          DO  m = 1, surf%ns
+             k = surf%k(m)
              surf%qrsws(m) = -surf%qrs(m) * surf%us(m) * rho_air_zw(k-1)
              surf%nrsws(m) = -surf%nrs(m) * surf%us(m) * rho_air_zw(k-1)
Index: palm/trunk/SOURCE/surface_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_mod.f90	(revision 4593)
+++ palm/trunk/SOURCE/surface_mod.f90	(revision 4594)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Bugfix, add acc directives for scalar-roughness length
+!
+! 4593 2020-07-09 12:48:18Z suehring
 ! Add arrays for pre-calculated ln(z/z0)
 !
@@ -1542,4 +1545,6 @@
     !$ACC DELETE(surfaces%ln_z_z0q(1:surfaces%ns)) &
     !$ACC DELETE(surfaces%z0(1:surfaces%ns)) &
+    !$ACC DELETE(surfaces%z0h(1:surfaces%ns)) &
+    !$ACC DELETE(surfaces%z0q(1:surfaces%ns)) &
     !$ACC COPYOUT(surfaces%us(1:surfaces%ns)) &
     !$ACC COPYOUT(surfaces%ol(1:surfaces%ns)) &
@@ -1586,4 +1591,6 @@
     !$ACC COPYIN(surfaces%ln_z_z0q(1:surfaces%ns)) &
     !$ACC COPYIN(surfaces%z0(1:surfaces%ns)) &
+    !$ACC COPYIN(surfaces%z0h(1:surfaces%ns)) &
+    !$ACC COPYIN(surfaces%z0q(1:surfaces%ns)) &
     !$ACC COPYIN(surfaces%us(1:surfaces%ns)) &
     !$ACC COPYIN(surfaces%ol(1:surfaces%ns)) &
@@ -2099,4 +2106,6 @@
     !$ACC DELETE(surfaces%ln_z_z0q(1:surfaces%ns) ) &
     !$ACC DELETE(surfaces%z0(1:surfaces%ns)) &
+    !$ACC DELETE(surfaces%z0h(1:surfaces%ns)) &
+    !$ACC DELETE(surfaces%z0q(1:surfaces%ns)) &
     !$ACC DELETE(surfaces%rib(1:surfaces%ns)) &
     !$ACC DELETE(surfaces%mom_flux_uv(1:surfaces%ns)) &
@@ -2134,4 +2143,6 @@
     !$ACC COPYIN(surfaces%ln_z_z0q(1:surfaces%ns) ) &
     !$ACC COPYIN(surfaces%z0(1:surfaces%ns)) &
+    !$ACC COPYIN(surfaces%z0h(1:surfaces%ns)) &
+    !$ACC COPYIN(surfaces%z0q(1:surfaces%ns)) &
     !$ACC COPYIN(surfaces%rib(1:surfaces%ns)) &
     !$ACC COPYIN(surfaces%mom_flux_uv(1:surfaces%ns)) &
@@ -5570,93 +5581,93 @@
  CONTAINS
 
- SUBROUTINE restore_surface_elements( surf_target, surf_file )
-
-    IMPLICIT NONE
-
-    INTEGER(iwp) ::  lsp  !< running index chemical species
-
-    TYPE(surf_type) ::  surf_target  !< target surface type
-    TYPE(surf_type) ::  surf_file    !< surface type on file
-
-
-    IF ( ALLOCATED( surf_target%us )  .AND.  ALLOCATED( surf_file%us ) )  THEN
-       surf_target%us = surf_file%us
-    ENDIF
-
-    IF ( ALLOCATED( surf_target%ol )  .AND.  ALLOCATED( surf_file%ol ) )                           &
-       surf_target%ol = surf_file%ol
-
-    IF ( ALLOCATED( surf_target%pt_surface )  .AND.  ALLOCATED( surf_file%pt_surface ) )           &
-       surf_target%pt_surface = surf_file%pt_surface
-
-    IF ( ALLOCATED( surf_target%q_surface )  .AND.  ALLOCATED( surf_file%q_surface ) )             &
-       surf_target%q_surface = surf_file%q_surface
-
-    IF ( ALLOCATED( surf_target%vpt_surface )  .AND.  ALLOCATED( surf_file%vpt_surface ) )         &
-       surf_target%vpt_surface = surf_file%vpt_surface
-
-    IF ( ALLOCATED( surf_target%usws )  .AND.  ALLOCATED( surf_file%usws ) )                       &
-       surf_target%usws = surf_file%usws
-
-    IF ( ALLOCATED( surf_target%vsws )  .AND.  ALLOCATED( surf_file%vsws ) )                       &
-       surf_target%vsws = surf_file%vsws
-
-    IF ( ALLOCATED( surf_target%ts )  .AND.  ALLOCATED( surf_file%ts ) )                           &
-       surf_target%ts = surf_file%ts
-
-    IF ( ALLOCATED( surf_target%shf )  .AND.  ALLOCATED( surf_file%shf ) )                         &
-       surf_target%shf = surf_file%shf
-
-    IF ( ALLOCATED( surf_target%qs )  .AND.  ALLOCATED( surf_file%qs ) )                           &
-       surf_target%qs = surf_file%qs
-
-    IF ( ALLOCATED( surf_target%qsws )  .AND.  ALLOCATED( surf_file%qsws ) )                       &
-       surf_target%qsws = surf_file%qsws
-
-    IF ( ALLOCATED( surf_target%ss )  .AND.  ALLOCATED( surf_file%ss ) )                           &
-       surf_target%ss = surf_file%ss
-
-    IF ( ALLOCATED( surf_target%ssws )  .AND.  ALLOCATED( surf_file%ssws ) )                       &
-       surf_target%ssws = surf_file%ssws
-
-    IF ( ALLOCATED( surf_target%css )  .AND.  ALLOCATED( surf_file%css   ) )  THEN
-       DO  lsp = 1, nvar
-          surf_target%css(lsp,:) = surf_file%css(lsp,:)
-       ENDDO
-    ENDIF
-
-    IF ( ALLOCATED( surf_target%cssws )  .AND.  ALLOCATED( surf_file%cssws   ) )  THEN
-       DO  lsp = 1, nvar
-          surf_target%cssws(lsp,:) = surf_file%cssws(lsp,:)
-       ENDDO
-    ENDIF
-    IF ( ALLOCATED( surf_target%qcs )  .AND.  ALLOCATED( surf_file%qcs ) )                         &
-       surf_target%qcs = surf_file%qcs
-    IF ( ALLOCATED( surf_target%qcsws )  .AND.  ALLOCATED( surf_file%qcsws ) )                     &
-       surf_target%qcsws = surf_file%qcsws
-    IF ( ALLOCATED( surf_target%ncs )  .AND.  ALLOCATED( surf_file%ncs ) )                         &
-       surf_target%ncs = surf_file%ncs
-    IF ( ALLOCATED( surf_target%ncsws )  .AND.  ALLOCATED( surf_file%ncsws ) )                     &
-       surf_target%ncsws = surf_file%ncsws
-    IF ( ALLOCATED( surf_target%qrs )  .AND.  ALLOCATED( surf_file%qrs ) )                         &
-       surf_target%qrs = surf_file%qrs
-    IF ( ALLOCATED( surf_target%qrsws )  .AND.  ALLOCATED( surf_file%qrsws ) )                     &
-       surf_target%qrsws = surf_file%qrsws
-    IF ( ALLOCATED( surf_target%nrs )  .AND.  ALLOCATED( surf_file%nrs ) )                         &
-       surf_target%nrs = surf_file%nrs
-
-    IF ( ALLOCATED( surf_target%nrsws )  .AND.  ALLOCATED( surf_file%nrsws ) )                     &
-       surf_target%nrsws = surf_file%nrsws
-    IF ( ALLOCATED( surf_target%sasws )  .AND. ALLOCATED( surf_file%sasws ) )                      &
-       surf_target%sasws = surf_file%sasws
-    IF ( ALLOCATED( surf_target%mom_flux_uv )  .AND.  ALLOCATED( surf_file%mom_flux_uv ) )         &
-       surf_target%mom_flux_uv = surf_file%mom_flux_uv
-    IF ( ALLOCATED( surf_target%mom_flux_w )  .AND.  ALLOCATED( surf_file%mom_flux_w ) )           &
-       surf_target%mom_flux_w = surf_file%mom_flux_w
-    IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.  ALLOCATED( surf_file%mom_flux_tke ) )       &
-       surf_target%mom_flux_tke(0:1,:) = surf_file%mom_flux_tke(0:1,:)
-
-
- END SUBROUTINE restore_surface_elements
+!  SUBROUTINE restore_surface_elements( surf_target, surf_file )
+! 
+!     IMPLICIT NONE
+! 
+!     INTEGER(iwp) ::  lsp  !< running index chemical species
+! 
+!     TYPE(surf_type) ::  surf_target  !< target surface type
+!     TYPE(surf_type) ::  surf_file    !< surface type on file
+! 
+! 
+!     IF ( ALLOCATED( surf_target%us )  .AND.  ALLOCATED( surf_file%us ) )  THEN
+!        surf_target%us = surf_file%us
+!     ENDIF
+! 
+!     IF ( ALLOCATED( surf_target%ol )  .AND.  ALLOCATED( surf_file%ol ) )                           &
+!        surf_target%ol = surf_file%ol
+! 
+!     IF ( ALLOCATED( surf_target%pt_surface )  .AND.  ALLOCATED( surf_file%pt_surface ) )           &
+!        surf_target%pt_surface = surf_file%pt_surface
+! 
+!     IF ( ALLOCATED( surf_target%q_surface )  .AND.  ALLOCATED( surf_file%q_surface ) )             &
+!        surf_target%q_surface = surf_file%q_surface
+! 
+!     IF ( ALLOCATED( surf_target%vpt_surface )  .AND.  ALLOCATED( surf_file%vpt_surface ) )         &
+!        surf_target%vpt_surface = surf_file%vpt_surface
+! 
+!     IF ( ALLOCATED( surf_target%usws )  .AND.  ALLOCATED( surf_file%usws ) )                       &
+!        surf_target%usws = surf_file%usws
+! 
+!     IF ( ALLOCATED( surf_target%vsws )  .AND.  ALLOCATED( surf_file%vsws ) )                       &
+!        surf_target%vsws = surf_file%vsws
+! 
+!     IF ( ALLOCATED( surf_target%ts )  .AND.  ALLOCATED( surf_file%ts ) )                           &
+!        surf_target%ts = surf_file%ts
+! 
+!     IF ( ALLOCATED( surf_target%shf )  .AND.  ALLOCATED( surf_file%shf ) )                         &
+!        surf_target%shf = surf_file%shf
+! 
+!     IF ( ALLOCATED( surf_target%qs )  .AND.  ALLOCATED( surf_file%qs ) )                           &
+!        surf_target%qs = surf_file%qs
+! 
+!     IF ( ALLOCATED( surf_target%qsws )  .AND.  ALLOCATED( surf_file%qsws ) )                       &
+!        surf_target%qsws = surf_file%qsws
+! 
+!     IF ( ALLOCATED( surf_target%ss )  .AND.  ALLOCATED( surf_file%ss ) )                           &
+!        surf_target%ss = surf_file%ss
+! 
+!     IF ( ALLOCATED( surf_target%ssws )  .AND.  ALLOCATED( surf_file%ssws ) )                       &
+!        surf_target%ssws = surf_file%ssws
+! 
+!     IF ( ALLOCATED( surf_target%css )  .AND.  ALLOCATED( surf_file%css   ) )  THEN
+!        DO  lsp = 1, nvar
+!           surf_target%css(lsp,:) = surf_file%css(lsp,:)
+!        ENDDO
+!     ENDIF
+! 
+!     IF ( ALLOCATED( surf_target%cssws )  .AND.  ALLOCATED( surf_file%cssws   ) )  THEN
+!        DO  lsp = 1, nvar
+!           surf_target%cssws(lsp,:) = surf_file%cssws(lsp,:)
+!        ENDDO
+!     ENDIF
+!     IF ( ALLOCATED( surf_target%qcs )  .AND.  ALLOCATED( surf_file%qcs ) )                         &
+!        surf_target%qcs = surf_file%qcs
+!     IF ( ALLOCATED( surf_target%qcsws )  .AND.  ALLOCATED( surf_file%qcsws ) )                     &
+!        surf_target%qcsws = surf_file%qcsws
+!     IF ( ALLOCATED( surf_target%ncs )  .AND.  ALLOCATED( surf_file%ncs ) )                         &
+!        surf_target%ncs = surf_file%ncs
+!     IF ( ALLOCATED( surf_target%ncsws )  .AND.  ALLOCATED( surf_file%ncsws ) )                     &
+!        surf_target%ncsws = surf_file%ncsws
+!     IF ( ALLOCATED( surf_target%qrs )  .AND.  ALLOCATED( surf_file%qrs ) )                         &
+!        surf_target%qrs = surf_file%qrs
+!     IF ( ALLOCATED( surf_target%qrsws )  .AND.  ALLOCATED( surf_file%qrsws ) )                     &
+!        surf_target%qrsws = surf_file%qrsws
+!     IF ( ALLOCATED( surf_target%nrs )  .AND.  ALLOCATED( surf_file%nrs ) )                         &
+!        surf_target%nrs = surf_file%nrs
+! 
+!     IF ( ALLOCATED( surf_target%nrsws )  .AND.  ALLOCATED( surf_file%nrsws ) )                     &
+!        surf_target%nrsws = surf_file%nrsws
+!     IF ( ALLOCATED( surf_target%sasws )  .AND. ALLOCATED( surf_file%sasws ) )                      &
+!        surf_target%sasws = surf_file%sasws
+!     IF ( ALLOCATED( surf_target%mom_flux_uv )  .AND.  ALLOCATED( surf_file%mom_flux_uv ) )         &
+!        surf_target%mom_flux_uv = surf_file%mom_flux_uv
+!     IF ( ALLOCATED( surf_target%mom_flux_w )  .AND.  ALLOCATED( surf_file%mom_flux_w ) )           &
+!        surf_target%mom_flux_w = surf_file%mom_flux_w
+!     IF ( ALLOCATED( surf_target%mom_flux_tke )  .AND.  ALLOCATED( surf_file%mom_flux_tke ) )       &
+!        surf_target%mom_flux_tke(0:1,:) = surf_file%mom_flux_tke(0:1,:)
+! 
+! 
+!  END SUBROUTINE restore_surface_elements
 
  END SUBROUTINE surface_rrd_local_mpi
