Index: codes/icosagcm/devel/src/dynamics/caldyn_gcm.F90
===================================================================
--- codes/icosagcm/devel/src/dynamics/caldyn_gcm.F90	(revision 919)
+++ codes/icosagcm/devel/src/dynamics/caldyn_gcm.F90	(revision 920)
@@ -236,4 +236,5 @@
        f_geopot, f_hflux, f_wflux, f_dps, f_dmass, f_dtheta_rhodz, f_du)
     USE observable_mod
+    USE compute_geopot_mod, ONLY : compute_geopot => compute_geopot_manual
     USE disvert_mod, ONLY : caldyn_eta, eta_mass
     USE trace
Index: codes/icosagcm/devel/src/dynamics/caldyn_hevi.f90
===================================================================
--- codes/icosagcm/devel/src/dynamics/caldyn_hevi.f90	(revision 919)
+++ codes/icosagcm/devel/src/dynamics/caldyn_hevi.f90	(revision 920)
@@ -6,4 +6,5 @@
   USE caldyn_kernels_base_mod
   USE compute_theta_mod, ONLY : compute_theta => compute_theta_manual
+  USE compute_geopot_mod, ONLY : compute_geopot => compute_geopot_manual
   USE compute_caldyn_kv_mod, ONLY : compute_caldyn_kv
   USE compute_caldyn_Coriolis_mod, ONLY : compute_caldyn_Coriolis
Index: codes/icosagcm/devel/src/dynamics/caldyn_kernels_base.F90
===================================================================
--- codes/icosagcm/devel/src/dynamics/caldyn_kernels_base.F90	(revision 919)
+++ codes/icosagcm/devel/src/dynamics/caldyn_kernels_base.F90	(revision 920)
@@ -10,148 +10,8 @@
   SAVE
 
-  PUBLIC :: compute_geopot, compute_caldyn_vert, compute_caldyn_vert_nh
+  PUBLIC :: compute_caldyn_vert, compute_caldyn_vert_nh
 
 CONTAINS
 
-  !**************************** Geopotential *****************************
-
-  SUBROUTINE compute_geopot(rhodz,theta, ps,pk,geopot) 
-    REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm)
-    REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm,nqdyn) ! active scalars : theta/entropy, moisture, ...
-    REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)
-    REAL(rstd),INTENT(OUT)   :: pk(iim*jjm,llm)       ! Exner function (compressible) /Lagrange multiplier (Boussinesq)
-    REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) ! geopotential
-
-    INTEGER :: i,j,ij,l
-    REAL(rstd) :: p_ik, exner_ik, Cp_ik, temp_ik, qv, chi, Rmix, gv
-    INTEGER    :: ij_omp_begin_ext, ij_omp_end_ext
-
-    CALL trace_start("compute_geopot")
-
-!$OMP BARRIER
-
-    CALL distrib_level(ij_begin_ext,ij_end_ext, ij_omp_begin_ext,ij_omp_end_ext)
-
-    IF(dysl_geopot) THEN
-#include "../kernels_hex/compute_geopot.k90"
-    ELSE
-    ! Pressure is computed first top-down (temporarily stored in pk)
-    ! Then Exner pressure and geopotential are computed bottom-up
-    ! Works also when caldyn_eta=eta_mass          
-
-    IF(boussinesq) THEN ! compute geopotential and pk=Lagrange multiplier
-       ! specific volume 1 = dphi/g/rhodz
-       !         IF (is_omp_level_master) THEN ! no openMP on vertical due to dependency
-       DO l = 1,llm
-          !DIR$ SIMD
-          DO ij=ij_omp_begin_ext,ij_omp_end_ext         
-             geopot(ij,l+1) = geopot(ij,l) + g*rhodz(ij,l)
-          ENDDO
-       ENDDO
-       ! use hydrostatic balance with theta*rhodz to find pk (Lagrange multiplier=pressure) 
-       ! uppermost layer
-       !DIR$ SIMD
-       DO ij=ij_begin_ext,ij_end_ext         
-          pk(ij,llm) = ptop + (.5*g)*theta(ij,llm,1)*rhodz(ij,llm)
-       END DO
-       ! other layers
-       DO l = llm-1, 1, -1
-          !          !$OMP DO SCHEDULE(STATIC) 
-          !DIR$ SIMD
-          DO ij=ij_begin_ext,ij_end_ext         
-             pk(ij,l) = pk(ij,l+1) + (.5*g)*(theta(ij,l,1)*rhodz(ij,l)+theta(ij,l+1,1)*rhodz(ij,l+1))
-          END DO
-       END DO
-       ! now pk contains the Lagrange multiplier (pressure)
-    ELSE ! non-Boussinesq, compute pressure, Exner pressure or temperature, then geopotential
-       ! uppermost layer
-       
-       SELECT CASE(caldyn_thermo)
-          CASE(thermo_theta, thermo_entropy)
-             !DIR$ SIMD
-             DO ij=ij_omp_begin_ext,ij_omp_end_ext
-                pk(ij,llm) = ptop + (.5*g)*rhodz(ij,llm)
-             END DO
-             ! other layers
-             DO l = llm-1, 1, -1
-                !DIR$ SIMD
-                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
-                   pk(ij,l) = pk(ij,l+1) + (.5*g)*(rhodz(ij,l)+rhodz(ij,l+1))
-                END DO
-             END DO
-             ! surface pressure (for diagnostics)
-             IF(caldyn_eta==eta_lag) THEN
-                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
-                   ps(ij) = pk(ij,1) + (.5*g)*rhodz(ij,1)
-                END DO
-             END IF
-          CASE(thermo_moist) ! theta(ij,l,2) = qv = mv/md
-             !DIR$ SIMD
-             DO ij=ij_omp_begin_ext,ij_omp_end_ext
-                pk(ij,llm) = ptop + (.5*g)*rhodz(ij,llm)*(1.+theta(ij,l,2))
-             END DO
-             ! other layers
-             DO l = llm-1, 1, -1
-                !DIR$ SIMD
-                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
-                   pk(ij,l) = pk(ij,l+1) + (.5*g)*(          &
-                        rhodz(ij,l)  *(1.+theta(ij,l,2)) +   &
-                        rhodz(ij,l+1)*(1.+theta(ij,l+1,2)) )
-                END DO
-             END DO
-             ! surface pressure (for diagnostics)
-             IF(caldyn_eta==eta_lag) THEN
-                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
-                   ps(ij) = pk(ij,1) + (.5*g)*rhodz(ij,1)*(1.+theta(ij,l,2))
-                END DO
-             END IF
-          END SELECT
-
-       DO l = 1,llm
-          SELECT CASE(caldyn_thermo)
-          CASE(thermo_theta)
-             !DIR$ SIMD
-             DO ij=ij_omp_begin_ext,ij_omp_end_ext
-                p_ik = pk(ij,l)
-                exner_ik = cpp * (p_ik/preff) ** kappa
-                pk(ij,l) = exner_ik
-                ! specific volume v = kappa*theta*pi/p = dphi/g/rhodz
-                geopot(ij,l+1) = geopot(ij,l) + (g*kappa)*rhodz(ij,l)*theta(ij,l,1)*exner_ik/p_ik
-             ENDDO
-          CASE(thermo_entropy) ! theta is in fact entropy = cpp*log(theta/Treff) = cpp*log(T/Treff) - Rd*log(p/preff)
-             !DIR$ SIMD
-             DO ij=ij_omp_begin_ext,ij_omp_end_ext
-                p_ik = pk(ij,l)
-                temp_ik = Treff*exp((theta(ij,l,1) + Rd*log(p_ik/preff))/cpp)
-                pk(ij,l) = temp_ik
-                ! specific volume v = Rd*T/p = dphi/g/rhodz
-                geopot(ij,l+1) = geopot(ij,l) + (g*Rd)*rhodz(ij,l)*temp_ik/p_ik
-             ENDDO
-          CASE(thermo_moist) ! theta is moist pseudo-entropy per dry air mass
-             DO ij=ij_omp_begin_ext,ij_omp_end_ext
-                p_ik = pk(ij,l)
-                qv = theta(ij,l,2) ! water vaper mixing ratio = mv/md
-                Rmix = Rd+qv*Rv
-                chi = ( theta(ij,l,1) + Rmix*log(p_ik/preff) ) / (cpp + qv*cppv) ! log(T/Treff)
-                temp_ik = Treff*exp(chi)
-                pk(ij,l) = temp_ik
-                ! specific volume v = R*T/p = dphi/g/rhodz
-                ! R = (Rd + qv.Rv)/(1+qv)
-                geopot(ij,l+1) = geopot(ij,l) + g*Rmix*rhodz(ij,l)*temp_ik/(p_ik*(1+qv))
-             ENDDO
-          CASE DEFAULT
-             STOP
-          END SELECT
-       ENDDO
-    END IF
-
-    END IF ! dysl
-
-    !ym flush geopot
-    !$OMP BARRIER
-
-    CALL trace_end("compute_geopot")
-
-  END SUBROUTINE compute_geopot
 
   SUBROUTINE compute_caldyn_vert(u,theta,rhodz,convm, wflux,wwuu, dps,dtheta_rhodz,du)
@@ -160,5 +20,4 @@
     REAL(rstd),INTENT(IN)  :: rhodz(iim*jjm,llm)
     REAL(rstd),INTENT(INOUT)  :: convm(iim*jjm,llm)  ! mass flux convergence
-
     REAL(rstd),INTENT(INOUT) :: wflux(iim*jjm,llm+1) ! vertical mass flux (kg/m2/s)
     REAL(rstd),INTENT(INOUT) :: wwuu(iim*3*jjm,llm+1)
@@ -341,3 +200,4 @@
 
   END SUBROUTINE compute_caldyn_vert_NH
+
 END MODULE caldyn_kernels_base_mod
Index: codes/icosagcm/devel/src/dynamics/compute_geopot.F90
===================================================================
--- codes/icosagcm/devel/src/dynamics/compute_geopot.F90	(revision 920)
+++ codes/icosagcm/devel/src/dynamics/compute_geopot.F90	(revision 920)
@@ -0,0 +1,172 @@
+MODULE compute_geopot_mod
+  USE prec, ONLY : rstd
+  USE grid_param
+  USE earth_const
+  USE disvert_mod
+  USE omp_para
+  USE trace
+  IMPLICIT NONE
+  PRIVATE
+  SAVE
+
+  PUBLIC :: compute_geopot_hex, compute_geopot_manual
+
+CONTAINS
+
+  !**************************** Geopotential *****************************
+
+  SUBROUTINE compute_geopot_hex(rhodz,theta, ps,pk,geopot) 
+    REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm)
+    REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm,nqdyn) ! active scalars : theta/entropy, moisture, ...
+    REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)
+    REAL(rstd),INTENT(OUT)   :: pk(iim*jjm,llm)       ! Exner function (compressible) /Lagrange multiplier (Boussinesq)
+    REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) ! geopotential
+
+    INTEGER :: i,j,ij,l
+    REAL(rstd) :: p_ik, exner_ik, Cp_ik, temp_ik, qv, chi, Rmix, gv
+    INTEGER    :: ij_omp_begin_ext, ij_omp_end_ext
+
+    CALL trace_start("compute_geopot")
+    !$OMP BARRIER
+    CALL distrib_level(ij_begin_ext,ij_end_ext, ij_omp_begin_ext,ij_omp_end_ext)
+#include "../kernels_hex/compute_geopot.k90"
+    !$OMP BARRIER
+
+    CALL trace_end("compute_geopot")
+  END SUBROUTINE compute_geopot_hex
+
+  SUBROUTINE compute_geopot_manual(rhodz,theta, ps,pk,geopot) 
+    REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm)
+    REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm,nqdyn) ! active scalars : theta/entropy, moisture, ...
+    REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)
+    REAL(rstd),INTENT(OUT)   :: pk(iim*jjm,llm)       ! Exner function (compressible) /Lagrange multiplier (Boussinesq)
+    REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) ! geopotential
+
+    INTEGER :: i,j,ij,l
+    REAL(rstd) :: p_ik, exner_ik, Cp_ik, temp_ik, qv, chi, Rmix, gv
+    INTEGER    :: ij_omp_begin_ext, ij_omp_end_ext
+
+    CALL trace_start("compute_geopot")
+
+!$OMP BARRIER
+
+    CALL distrib_level(ij_begin_ext,ij_end_ext, ij_omp_begin_ext,ij_omp_end_ext)
+
+    ! Pressure is computed first top-down (temporarily stored in pk)
+    ! Then Exner pressure and geopotential are computed bottom-up
+    ! Works also when caldyn_eta=eta_mass          
+
+    IF(boussinesq) THEN ! compute geopotential and pk=Lagrange multiplier
+       ! specific volume 1 = dphi/g/rhodz
+       !         IF (is_omp_level_master) THEN ! no openMP on vertical due to dependency
+       DO l = 1,llm
+          !DIR$ SIMD
+          DO ij=ij_omp_begin_ext,ij_omp_end_ext         
+             geopot(ij,l+1) = geopot(ij,l) + g*rhodz(ij,l)
+          ENDDO
+       ENDDO
+       ! use hydrostatic balance with theta*rhodz to find pk (Lagrange multiplier=pressure) 
+       ! uppermost layer
+       !DIR$ SIMD
+       DO ij=ij_begin_ext,ij_end_ext         
+          pk(ij,llm) = ptop + (.5*g)*theta(ij,llm,1)*rhodz(ij,llm)
+       END DO
+       ! other layers
+       DO l = llm-1, 1, -1
+          !          !$OMP DO SCHEDULE(STATIC) 
+          !DIR$ SIMD
+          DO ij=ij_begin_ext,ij_end_ext         
+             pk(ij,l) = pk(ij,l+1) + (.5*g)*(theta(ij,l,1)*rhodz(ij,l)+theta(ij,l+1,1)*rhodz(ij,l+1))
+          END DO
+       END DO
+       ! now pk contains the Lagrange multiplier (pressure)
+    ELSE ! non-Boussinesq, compute pressure, Exner pressure or temperature, then geopotential
+       ! uppermost layer
+       
+       SELECT CASE(caldyn_thermo)
+          CASE(thermo_theta, thermo_entropy)
+             !DIR$ SIMD
+             DO ij=ij_omp_begin_ext,ij_omp_end_ext
+                pk(ij,llm) = ptop + (.5*g)*rhodz(ij,llm)
+             END DO
+             ! other layers
+             DO l = llm-1, 1, -1
+                !DIR$ SIMD
+                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
+                   pk(ij,l) = pk(ij,l+1) + (.5*g)*(rhodz(ij,l)+rhodz(ij,l+1))
+                END DO
+             END DO
+             ! surface pressure (for diagnostics)
+             IF(caldyn_eta==eta_lag) THEN
+                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
+                   ps(ij) = pk(ij,1) + (.5*g)*rhodz(ij,1)
+                END DO
+             END IF
+          CASE(thermo_moist) ! theta(ij,l,2) = qv = mv/md
+             !DIR$ SIMD
+             DO ij=ij_omp_begin_ext,ij_omp_end_ext
+                pk(ij,llm) = ptop + (.5*g)*rhodz(ij,llm)*(1.+theta(ij,l,2))
+             END DO
+             ! other layers
+             DO l = llm-1, 1, -1
+                !DIR$ SIMD
+                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
+                   pk(ij,l) = pk(ij,l+1) + (.5*g)*(          &
+                        rhodz(ij,l)  *(1.+theta(ij,l,2)) +   &
+                        rhodz(ij,l+1)*(1.+theta(ij,l+1,2)) )
+                END DO
+             END DO
+             ! surface pressure (for diagnostics)
+             IF(caldyn_eta==eta_lag) THEN
+                DO ij=ij_omp_begin_ext,ij_omp_end_ext         
+                   ps(ij) = pk(ij,1) + (.5*g)*rhodz(ij,1)*(1.+theta(ij,l,2))
+                END DO
+             END IF
+          END SELECT
+
+       DO l = 1,llm
+          SELECT CASE(caldyn_thermo)
+          CASE(thermo_theta)
+             !DIR$ SIMD
+             DO ij=ij_omp_begin_ext,ij_omp_end_ext
+                p_ik = pk(ij,l)
+                exner_ik = cpp * (p_ik/preff) ** kappa
+                pk(ij,l) = exner_ik
+                ! specific volume v = kappa*theta*pi/p = dphi/g/rhodz
+                geopot(ij,l+1) = geopot(ij,l) + (g*kappa)*rhodz(ij,l)*theta(ij,l,1)*exner_ik/p_ik
+             ENDDO
+          CASE(thermo_entropy) ! theta is in fact entropy = cpp*log(theta/Treff) = cpp*log(T/Treff) - Rd*log(p/preff)
+             !DIR$ SIMD
+             DO ij=ij_omp_begin_ext,ij_omp_end_ext
+                p_ik = pk(ij,l)
+                temp_ik = Treff*exp((theta(ij,l,1) + Rd*log(p_ik/preff))/cpp)
+                pk(ij,l) = temp_ik
+                ! specific volume v = Rd*T/p = dphi/g/rhodz
+                geopot(ij,l+1) = geopot(ij,l) + (g*Rd)*rhodz(ij,l)*temp_ik/p_ik
+             ENDDO
+          CASE(thermo_moist) ! theta is moist pseudo-entropy per dry air mass
+             DO ij=ij_omp_begin_ext,ij_omp_end_ext
+                p_ik = pk(ij,l)
+                qv = theta(ij,l,2) ! water vaper mixing ratio = mv/md
+                Rmix = Rd+qv*Rv
+                chi = ( theta(ij,l,1) + Rmix*log(p_ik/preff) ) / (cpp + qv*cppv) ! log(T/Treff)
+                temp_ik = Treff*exp(chi)
+                pk(ij,l) = temp_ik
+                ! specific volume v = R*T/p = dphi/g/rhodz
+                ! R = (Rd + qv.Rv)/(1+qv)
+                geopot(ij,l+1) = geopot(ij,l) + g*Rmix*rhodz(ij,l)*temp_ik/(p_ik*(1+qv))
+             ENDDO
+          CASE DEFAULT
+             STOP
+          END SELECT
+       ENDDO
+    END IF
+
+    !ym flush geopot
+    !$OMP BARRIER
+
+    CALL trace_end("compute_geopot")
+
+  END SUBROUTINE compute_geopot_manual
+
+END MODULE compute_geopot_mod
