Index: /palm/trunk/SOURCE/Makefile
===================================================================
--- /palm/trunk/SOURCE/Makefile	(revision 1746)
+++ /palm/trunk/SOURCE/Makefile	(revision 1747)
@@ -20,5 +20,5 @@
 # Current revisions:
 # ------------------
-# 
+# dependencies for routine palm updated
 # 
 # Former revisions:
@@ -419,5 +419,6 @@
 package_parin.o: modules.o mod_kinds.o land_surface_model.o\
                  plant_canopy_model.o radiation_model.o
-palm.o: modules.o cpulog.o ls_forcing.o mod_kinds.o nudging.o
+palm.o: modules.o cpulog.o ls_forcing.o mod_kinds.o nudging.o\
+	 surface_layer_fluxes.o
 parin.o: modules.o cpulog.o mod_kinds.o progress_bar.o
 plant_canopy_model.o: modules.o mod_kinds.o
Index: /palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- /palm/trunk/SOURCE/flow_statistics.f90	(revision 1746)
+++ /palm/trunk/SOURCE/flow_statistics.f90	(revision 1747)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! -----------------
-!
+! small bugfixes for accelerator version
 !
 ! Former revisions:
@@ -1658,6 +1658,6 @@
         ONLY :  average_count_pr, cloud_droplets, cloud_physics, do_sum,       &
                 dt_3d, g, humidity, icloud_scheme, kappa, large_scale_forcing, &
-                large_scale_subsidence, max_pr_user, message_string, ocean,    &
-                passive_scalar, precipitation, simulated_time,                 &
+                large_scale_subsidence, max_pr_user, message_string, neutral,  &
+                ocean, passive_scalar, precipitation, simulated_time,          &
                 use_subsidence_tendencies, use_surface_fluxes, use_top_fluxes, &
                 ws_scheme_mom, ws_scheme_sca
@@ -3009,7 +3009,7 @@
                    sums_ll(k,1) = sums_ll(k,1) + 0.5_wp * w(k,j,i) * (         &
                   ( 0.25_wp * ( u(k,j,i)+u(k+1,j,i)+u(k,j,i+1)+u(k+1,j,i+1) )  &
-                            - 0.5_wp * ( hom(k,1,1,sr) + hom(k+1,1,1,sr) ) )**2&                                           &
+                            - 0.5_wp * ( hom(k,1,1,sr) + hom(k+1,1,1,sr) ) )**2&
                 + ( 0.25_wp * ( v(k,j,i)+v(k+1,j,i)+v(k,j+1,i)+v(k+1,j+1,i) )  &
-                            - 0.5_wp * ( hom(k,1,2,sr) + hom(k+1,1,2,sr) ) )**2&                                          &
+                            - 0.5_wp * ( hom(k,1,2,sr) + hom(k+1,1,2,sr) ) )**2&
                 + w(k,j,i)**2                                        )
 
Index: /palm/trunk/SOURCE/palm.f90
===================================================================
--- /palm/trunk/SOURCE/palm.f90	(revision 1746)
+++ /palm/trunk/SOURCE/palm.f90	(revision 1747)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! openacc-adjustment for new surface layer parameterization
 ! 
 ! Former revisions:
@@ -145,4 +145,7 @@
         ONLY:  hom, rmask, weight_pres, weight_substep
 
+    USE surface_layer_fluxes_mod,                                              &
+        ONLY:  pt1, qv1, uv_total
+
 #if defined( __openacc )
     USE OPENACC
@@ -312,5 +315,5 @@
     !$acc  data copyin( d, diss, e, e_p, kh, km, p, pt, pt_p, q, ql, tend, te_m, tpt_m, tu_m, tv_m, tw_m, u, u_p, v, vpt, v_p, w, w_p )          &
     !$acc       copyin( tri, tric, dzu, ddzu, ddzw, dd2zu, l_grid, l_wall, ptdf_x, ptdf_y, pt_init, rdf, rdf_sc, ref_state, ug, u_init, vg, v_init, zu, zw )   &
-    !$acc       copyin( hom, qs, qsws, qswst, rif, rif_wall, shf, ts, tswst, us, usws, uswst, vsws, vswst, z0, z0h )      &
+    !$acc       copyin( hom, ol, pt1, qs, qsws, qswst, qv1, rif_wall, shf, ts, tswst, us, usws, uswst, uv_total, vsws, vswst, z0, z0h )      &
     !$acc       copyin( fxm, fxp, fym, fyp, fwxm, fwxp, fwym, fwyp, nzb_diff_s_inner, nzb_diff_s_outer, nzb_diff_u )       &
     !$acc       copyin( nzb_diff_v, nzb_s_inner, nzb_s_outer, nzb_u_inner )    &
Index: /palm/trunk/SOURCE/surface_layer_fluxes.f90
===================================================================
--- /palm/trunk/SOURCE/surface_layer_fluxes.f90	(revision 1746)
+++ /palm/trunk/SOURCE/surface_layer_fluxes.f90	(revision 1747)
@@ -18,6 +18,6 @@
 !--------------------------------------------------------------------------------!
 ! Current revisions:
-! -----------------
-! 
+! ------------------
+! adjustments for OpenACC usage
 ! 
 ! Former revisions:
@@ -168,5 +168,5 @@
     PRIVATE
 
-    PUBLIC init_surface_layer_fluxes, surface_layer_fluxes
+    PUBLIC init_surface_layer_fluxes, pt1, qv1, surface_layer_fluxes, uv_total
 
     INTERFACE init_surface_layer_fluxes
@@ -406,6 +406,6 @@
 
 
-       !$OMP PARALLEL DO PRIVATE( k, z_mo )
-       !$acc kernels loop
+       !$OMP PARALLEL DO PRIVATE( k )
+       !$acc kernels loop present( nzb_s_inner, u, uv_total, v ) private( j, k )
        DO  i = nxl, nxr
           DO  j = nys, nyn
@@ -455,9 +455,10 @@
                        ol_u      !< Upper bound of L for Newton iteration
 
-
        IF ( TRIM( most_method ) /= 'circular' )  THEN
       
+          !$acc data present( nzb_s_inner, pt, q, qsws, rib, shf, uv_total, vpt, zu, zw )
+
           !$OMP PARALLEL DO PRIVATE( k, z_mo )
-          !$acc kernels loop
+          !$acc kernels loop private( j, k, z_mo )
           DO  i = nxl, nxr
              DO  j = nys, nyn
@@ -498,4 +499,5 @@
              ENDDO
           ENDDO 
+          !$acc end data
 
        ENDIF
@@ -507,5 +509,6 @@
 
           !$OMP PARALLEL DO PRIVATE( k, z_mo )
-          !$acc kernels loop
+          !# WARNING: does not work on GPU so far
+          !!!!!!$acc kernels loop
           DO  i = nxl, nxr
              DO  j = nys, nyn
@@ -626,5 +629,6 @@
 
           !$OMP PARALLEL DO PRIVATE( k, z_mo )
-          !$acc kernels loop
+          !# WARNING: does not work on GPU so far
+          !!!!!!$acc kernels loop
           DO  i = nxl, nxr
              DO  j = nys, nyn
@@ -668,5 +672,5 @@
 
           !$OMP PARALLEL DO PRIVATE( k, z_mo )
-          !$acc kernels loop
+          !$acc kernels loop present( nzb_s_inner, ol, pt, pt1, q, ql, qs, qv1, ts, us, vpt, zu, zw ) private( j, k, z_mo )
           DO  i = nxl, nxr
              DO  j = nys, nyn
@@ -719,5 +723,7 @@
 
        !$OMP PARALLEL DO PRIVATE( k, z_mo )
-       !$acc kernels loop
+       ! ### WARNING: does not work on GPU because of function calls
+       !!!!!$acc kernels loop
+       !$acc update host( ol, uv_total )
        DO  i = nxlg, nxrg
           DO  j = nysg, nyng
@@ -733,4 +739,5 @@
           ENDDO
        ENDDO
+       !$acc update device( us )
 
     END SUBROUTINE calc_us
@@ -742,4 +749,5 @@
        IMPLICIT NONE
 
+       !$acc kernels loop present( nzb_s_inner, pt, pt1, pt_d_t, q, ql, qv1 ) private( j, k )
        DO  i = nxlg, nxrg
           DO  j = nysg, nyng
@@ -770,5 +778,5 @@
 !--       For a given heat flux in the surface layer:
           !$OMP PARALLEL DO
-          !$acc kernels loop
+          !$acc kernels loop private( j )
           DO  i = nxlg, nxrg
              DO  j = nysg, nyng
@@ -787,5 +795,5 @@
           IF ( large_scale_forcing .AND. lsf_surf )  THEN
              !$OMP PARALLEL DO
-             !$acc kernels loop
+             !$acc kernels loop private( j, k )
              DO  i = nxlg, nxrg
                 DO  j = nysg, nyng
@@ -797,5 +805,6 @@
 
           !$OMP PARALLEL DO PRIVATE( k, z_mo )
-          !$acc kernels loop
+          ! ### WARNING: leads to severe compile error
+          !!!!$acc kernels loop
           DO  i = nxlg, nxrg
              DO  j = nysg, nyng
@@ -827,5 +836,5 @@
 !--          For a given water flux in the Prandtl layer:
              !$OMP PARALLEL DO
-             !$acc kernels loop
+             !$acc kernels loop private( j )
              DO  i = nxlg, nxrg
                 DO  j = nysg, nyng
@@ -840,5 +849,5 @@
              IF ( large_scale_forcing .AND. lsf_surf )  THEN
                 !$OMP PARALLEL DO
-                !$acc kernels loop
+                !$acc kernels loop private( j, k )
                 DO  i = nxlg, nxrg
                    DO  j = nysg, nyng
@@ -850,7 +859,8 @@
 
              !$OMP PARALLEL DO PRIVATE( e_s, k, z_mo )
-             !$acc kernels loop independent
+             ! ### WARNING: leads to severe compile error
+             !!!!$acc kernels loop independent
              DO  i = nxlg, nxrg
-                !$acc loop independent
+                !!!!$acc loop independent
                 DO  j = nysg, nyng
 
@@ -892,7 +902,8 @@
 
           !$OMP PARALLEL DO PRIVATE( k, z_mo )
-          !$acc kernels loop independent
+          ! ### WARNING: leads to severe compile error
+          !!!!!$acc kernels loop independent
           DO  i = nxlg, nxrg
-             !$acc loop independent
+             !!!!$acc loop independent
              DO  j = nysg, nyng
 
@@ -913,4 +924,5 @@
 
        ENDIF
+       !$acc end data
 
     END SUBROUTINE calc_scaling_parameters
@@ -930,5 +942,7 @@
 !--    First compute the corresponding component of u* and square it.
        !$OMP PARALLEL DO PRIVATE( k, ol_mid, z_mo )
-       !$acc kernels loop
+       ! ### WARNING: leads to severe compile error
+       !!!!!$acc kernels loop
+       !$acc update host( ol, u, us, v )
        DO  i = nxl, nxr
           DO  j = nys, nyn
@@ -957,5 +971,6 @@
 !--    First compute the corresponding component of u* and square it.
        !$OMP PARALLEL DO PRIVATE( k, ol_mid, z_mo )
-       !$acc kernels loop
+       ! ### WARNING: leads to severe compile error
+       !!!!!!$acc kernels loop
        DO  i = nxl, nxr
           DO  j = nys, nyn
@@ -983,5 +998,5 @@
 !
 !--    Exchange the boundaries for the momentum fluxes (is this still required?)
-       !$acc update host( usws, vsws )
+       !!!!!!!!$acc update host( usws, vsws )
        CALL exchange_horiz_2d( usws )
        CALL exchange_horiz_2d( vsws )
@@ -993,5 +1008,5 @@
             skip_time_do_lsm .OR. .NOT. land_surface ) )  THEN
           !$OMP PARALLEL DO
-          !$acc kernels loop independent
+          !$acc kernels loop independent present( shf, ts, us )
           DO  i = nxlg, nxrg
              !$acc loop independent
@@ -1009,5 +1024,5 @@
             land_surface ) )  THEN
           !$OMP PARALLEL DO
-          !$acc kernels loop independent
+          !$acc kernels loop independent present( qs, qsws, us )
           DO  i = nxlg, nxrg
              !$acc loop independent
@@ -1024,5 +1039,5 @@
             precipitation )  THEN
           !$OMP PARALLEL DO
-          !$acc kernels loop independent
+          !$acc kernels loop independent present( nrs, nrsws, qrs, qrsws, us )
           DO  i = nxlg, nxrg
              !$acc loop independent
@@ -1038,5 +1053,5 @@
        IF ( ibc_e_b == 2 )  THEN
           !$OMP PARALLEL DO
-          !$acc kernels loop independent
+          !$acc kernels loop independent present( e, nzb_s_inner, us )
           DO  i = nxlg, nxrg
              !$acc loop independent
@@ -1050,5 +1065,4 @@
           ENDDO
        ENDIF
-       !$acc end data
 
     END SUBROUTINE calc_surface_fluxes
Index: /palm/trunk/SOURCE/swap_timelevel.f90
===================================================================
--- /palm/trunk/SOURCE/swap_timelevel.f90	(revision 1746)
+++ /palm/trunk/SOURCE/swap_timelevel.f90	(revision 1747)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! explicit loops in nopointer case to omit craypointer option of pgi compiler
 ! 
 ! Former revisions:
@@ -94,5 +94,9 @@
                neutral, ocean, passive_scalar, precipitation, timestep_count
 
+    USE indices,                                                               &
+        ONLY:  nxlg, nxrg, nyng, nysg, nzb, nzt
     IMPLICIT NONE
+
+    INTEGER ::  i, j, k   !: loop indices
 
 !
@@ -106,12 +110,35 @@
 
     !$acc kernels present( pt, pt_p, u, u_p, v, v_p, w, w_p )
-    u  = u_p
-    v  = v_p
-    w  = w_p
-    pt = pt_p
+    !$acc loop independent
+    DO  i = nxlg, nxrg
+       !$acc loop independent
+       DO  j = nysg, nyng
+          !$acc loop independent
+          DO  k = nzb, nzt+1
+             u(k,j,i)  = u_p(k,j,i)
+             v(k,j,i)  = v_p(k,j,i)
+             w(k,j,i)  = w_p(k,j,i)
+             pt(k,j,i) = pt_p(k,j,i)
+          ENDDO
+       ENDDO
+    ENDDO
+!    u  = u_p
+!    v  = v_p
+!    w  = w_p
+!    pt = pt_p
     !$acc end kernels
     IF ( .NOT. constant_diffusion )  THEN
        !$acc kernels present( e, e_p )
-       e = e_p
+       !$acc loop independent
+       DO  i = nxlg, nxrg
+          !$acc loop independent
+          DO  j = nysg, nyng
+             !$acc loop independent
+             DO  k = nzb, nzt+1
+                e(k,j,i) = e_p(k,j,i)
+             ENDDO
+          ENDDO
+       ENDDO
+!       e = e_p
        !$acc end kernels
     ENDIF
