Index: palm/trunk/SOURCE/surface_layer_fluxes_mod.f90
===================================================================
--- palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 3597)
+++ palm/trunk/SOURCE/surface_layer_fluxes_mod.f90	(revision 3634)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! OpenACC port for SPEC
+! 
+! 3597 2018-12-04 08:40:18Z maronga
 ! Added routine for calculating near surface air potential temperature (moved
 ! from urban_surface_mod)
@@ -1009,4 +1012,6 @@
        ibit = MERGE( 1, 0, .NOT. downward )
 
+       !$ACC PARALLEL LOOP PRIVATE(i, j, k, w_lfc) &
+       !$ACC PRESENT(surf, u, v)
        DO  m = 1, surf%ns
 
@@ -1297,4 +1302,6 @@
              ELSE
                 !$OMP PARALLEL DO PRIVATE( k, z_mo )
+                !$ACC PARALLEL LOOP PRIVATE(k, z_mo) &
+                !$ACC PRESENT(surf, drho_air_zw)
                 DO  m = 1, surf%ns
 
@@ -1319,4 +1326,7 @@
        IF ( TRIM( most_method ) == 'newton' )  THEN
 
+          !$ACC PARALLEL LOOP PRIVATE(i, j, z_mo) &
+          !$ACC PRIVATE(ol_old, ol_m, ol_l, ol_u, f, f_d_ol) &
+          !$ACC PRESENT(surf)
           DO  m = 1, surf%ns
 
@@ -1575,4 +1585,6 @@
           IF ( .NOT. downward )  THEN
              !$OMP PARALLEL  DO PRIVATE( z_mo )
+             !$ACC PARALLEL LOOP PRIVATE(z_mo) &
+             !$ACC PRESENT(surf)
              DO  m = 1, surf%ns
 
@@ -1591,4 +1603,6 @@
           ELSE
              !$OMP PARALLEL  DO PRIVATE( z_mo )
+             !$ACC PARALLEL LOOP PRIVATE(z_mo) &
+             !$ACC PRESENT(surf)
              DO  m = 1, surf%ns
 
@@ -1605,4 +1619,6 @@
        ELSE
           !$OMP PARALLEL DO PRIVATE( z_mo )
+          !$ACC PARALLEL LOOP PRIVATE(z_mo) &
+          !$ACC PRESENT(surf)
           DO  m = 1, surf%ns
              z_mo = surf%z_mo(m)
@@ -1624,4 +1640,6 @@
 
        !$OMP PARALLEL DO PRIVATE( i, j, k )
+       !$ACC PARALLEL LOOP PRIVATE(i, j, k) &
+       !$ACC PRESENT(surf, pt)
        DO  m = 1, surf%ns 
 
@@ -1630,4 +1648,5 @@
           k   = surf%k(m)
 
+#ifndef _OPENACC
           IF ( bulk_cloud_model ) THEN
              surf%pt1(m) = pt(k,j,i) + lv_d_cp * d_exner(k) * ql(k,j,i)
@@ -1637,9 +1656,13 @@
              surf%qv1(m) = q(k,j,i) 
           ELSE
+#endif
              surf%pt1(m) = pt(k,j,i)
+#ifndef _OPENACC
              IF ( humidity )  THEN
                 surf%qv1(m) = q(k,j,i)
              ELSE
+#endif
                 surf%qv1(m) = 0.0_wp
+#ifndef _OPENACC
              ENDIF
           ENDIF 
@@ -1648,4 +1671,5 @@
              surf%vpt1(m) = pt(k,j,i) * ( 1.0_wp + 0.61_wp * q(k,j,i) )
           ENDIF
+#endif
           
        ENDDO
@@ -1658,4 +1682,53 @@
 !-- ( only for upward-facing surfs )
     SUBROUTINE calc_pt_surface
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  k_off    !< index offset between surface and atmosphere grid point (-1 for upward-, +1 for downward-facing walls) 
+       INTEGER(iwp) ::  m       !< loop variable over all horizontal surf elements 
+       
+       k_off = surf%koff
+       !$OMP PARALLEL DO PRIVATE( i, j, k )
+       !$ACC PARALLEL LOOP PRIVATE(i, j, k) &
+       !$ACC PRESENT(surf, pt)
+       DO  m = 1, surf%ns 
+
+          i   = surf%i(m)            
+          j   = surf%j(m)
+          k   = surf%k(m)
+
+          surf%pt_surface(m) = pt(k+k_off,j,i)
+
+       ENDDO
+
+    END SUBROUTINE calc_pt_surface
+
+!
+!-- Set mixing ratio at surface grid level. ( Only for upward-facing surfs. )
+    SUBROUTINE calc_q_surface
+
+       IMPLICIT NONE
+
+       INTEGER(iwp) ::  k_off   !< index offset between surface and atmosphere grid point (-1 for upward-, +1 for downward-facing walls) 
+       INTEGER(iwp) ::  m       !< loop variable over all horizontal surf elements 
+       
+       k_off = surf%koff
+       !$OMP PARALLEL DO PRIVATE( i, j, k )
+       DO  m = 1, surf%ns 
+
+          i   = surf%i(m)            
+          j   = surf%j(m)
+          k   = surf%k(m)
+
+          surf%q_surface(m) = q(k+k_off,j,i)
+
+       ENDDO
+
+    END SUBROUTINE calc_q_surface
+    
+!
+!-- Set virtual potential temperature at surface grid level.
+!-- ( only for upward-facing surfs )
+    SUBROUTINE calc_vpt_surface
 
        IMPLICIT NONE
@@ -1672,51 +1745,4 @@
           k   = surf%k(m)
 
-          surf%pt_surface(m) = pt(k+k_off,j,i)
-
-       ENDDO
-
-    END SUBROUTINE calc_pt_surface
-
-!
-!-- Set mixing ratio at surface grid level. ( Only for upward-facing surfs. )
-    SUBROUTINE calc_q_surface
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) ::  k_off   !< index offset between surface and atmosphere grid point (-1 for upward-, +1 for downward-facing walls) 
-       INTEGER(iwp) ::  m       !< loop variable over all horizontal surf elements 
-       
-       k_off = surf%koff
-       !$OMP PARALLEL DO PRIVATE( i, j, k )
-       DO  m = 1, surf%ns 
-
-          i   = surf%i(m)            
-          j   = surf%j(m)
-          k   = surf%k(m)
-
-          surf%q_surface(m) = q(k+k_off,j,i)
-
-       ENDDO
-
-    END SUBROUTINE calc_q_surface
-    
-!
-!-- Set virtual potential temperature at surface grid level.
-!-- ( only for upward-facing surfs )
-    SUBROUTINE calc_vpt_surface
-
-       IMPLICIT NONE
-
-       INTEGER(iwp) ::  k_off    !< index offset between surface and atmosphere grid point (-1 for upward-, +1 for downward-facing walls) 
-       INTEGER(iwp) ::  m       !< loop variable over all horizontal surf elements 
-       
-       k_off = surf%koff
-       !$OMP PARALLEL DO PRIVATE( i, j, k )
-       DO  m = 1, surf%ns 
-
-          i   = surf%i(m)            
-          j   = surf%j(m)
-          k   = surf%k(m)
-
           surf%vpt_surface(m) = vpt(k+k_off,j,i)
 
@@ -1741,4 +1767,6 @@
 
           !$OMP PARALLEL DO PRIVATE( i, j, k )
+          !$ACC PARALLEL LOOP PRIVATE(i, j, k) &
+          !$ACC PRESENT(surf, drho_air_zw)
           DO  m = 1, surf%ns 
 
@@ -2039,4 +2067,6 @@
           IF ( .NOT. downward )  THEN
              !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo )
+             !$ACC PARALLEL LOOP PRIVATE(i, j, k, z_mo) &
+             !$ACC PRESENT(surf, u, rho_air_zw)
              DO  m = 1, surf%ns  
    
@@ -2086,4 +2116,6 @@
           IF ( .NOT. downward )  THEN
              !$OMP PARALLEL DO PRIVATE( i, j, k, z_mo )
+             !$ACC PARALLEL LOOP PRIVATE(i, j, k, z_mo) &
+             !$ACC PRESENT(surf, v, rho_air_zw)
              DO  m = 1, surf%ns  
                 i = surf%i(m)            
@@ -2392,4 +2424,5 @@
 !-- Integrated stability function for momentum
     FUNCTION psi_m( zeta ) 
+       !$ACC ROUTINE SEQ
        
        USE kinds
@@ -2429,4 +2462,5 @@
 !-- Integrated stability function for heat and moisture
     FUNCTION psi_h( zeta ) 
+       !$ACC ROUTINE SEQ
        
        USE kinds
@@ -2469,4 +2503,5 @@
 !------------------------------------------------------------------------------!
     FUNCTION phi_m( zeta ) 
+       !$ACC ROUTINE SEQ
    
        IMPLICIT NONE 
