Index: codes/icosagcm/devel/src/unstructured/caldyn_unstructured.F90
===================================================================
--- codes/icosagcm/devel/src/unstructured/caldyn_unstructured.F90	(revision 650)
+++ codes/icosagcm/devel/src/unstructured/caldyn_unstructured.F90	(revision 658)
@@ -21,5 +21,4 @@
 #define DECLARE_VERTICES INTEGER VERTICES
 #define PHI_BOT(ij) Phi_bot
-#define PHI_BOT_VAR 0.
 
 #define BINDC_(thename) BIND(C, name=#thename)
@@ -40,13 +39,46 @@
 #define HASNAN(field) (ANY(.NOT.ABS(field)<1e20))
 
+#define START_TRACE(id,nprimal,ndual,nedge) CALL enter_trace(id, 8*llm*((nprimal)*primal_num+(ndual)*dual_num+(nedge)*edge_num) )
+#define STOP_TRACE CALL exit_trace()
+
 !----------------------------- Non-Hydrostatic -----------------------------
 
-SUBROUTINE compute_NH_geopot(tau,dummy, m_ik, m_il, theta, W_il, Phi_il)
-  FIELD_MASS   :: m_ik, theta, p_ik, A_ik, C_ik   ! IN*2,LOCAL*3
-  FIELD_GEOPOT :: m_il, W_il, Phi_il, Phi_star_il, R_il, x_il, B_il, D_il  ! IN,INOUT*2, LOCAL*5 
-  DBL :: tau, dummy, gamma, rho_ij, X_ij, Y_ij, wil, tau2_g, g2, gm2, ml_g2, c2_mik
-  DECLARE_INDICES
+SUBROUTINE compute_NH_geopot(tau, m_ik, m_il, theta, W_il, Phi_il)
+  FIELD_MASS   :: m_ik, theta   ! IN*2
+  FIELD_GEOPOT :: m_il, W_il, Phi_il, Phi_star_il  ! IN,INOUT*2, LOCAL*5 
+  DBL :: tau, gamma, tau2_g, tau2_g2, g2, gm2, vreff, Rd_preff
   INTEGER :: iter
+  DECLARE_INDICES
+  DBL :: rho_ij, X_ij, Y_ij, wil, rho_c2_mik, c2_mik, ml_g2
+#define COLUMN 0
+#if COLUMN 
+  DOUBLE1(llm)  :: pk, Ak, Ck
+  DOUBLE1(llm+1):: Rl, Bl, Dl, xl
+#define p_ik(l,ij) pk(l)
+#define A_ik(l,ij) Ak(l)
+#define C_ik(l,ij) Ck(l)
+#define R_il(l,ij) Rl(l)
+#define B_il(l,ij) Bl(l)
+#define D_il(l,ij) Dl(l)
+#define x_il(l,ij) xl(l)
+#else
+  FIELD_MASS :: p_ik, A_ik, C_ik
+  FIELD_GEOPOT :: R_il, B_il, D_il, x_il
+#endif
+
+  START_TRACE(id_NH_geopot, 7,0,0)
 #include "../kernels_unst/compute_NH_geopot.k90"
+  STOP_TRACE  
+
+#if COLUMN
+#undef p_ik
+#undef A_ik
+#undef C_ik
+#undef R_il
+#undef B_il
+#undef D_il
+#undef x_il
+#endif
+#undef COLUMN
 END SUBROUTINE compute_NH_geopot
 
@@ -59,5 +91,7 @@
   DECLARE_EDGES
   DBL :: W_el, W2_el, gPhi2, dP, divG, u2, uu
+  START_TRACE(id_slow_NH, 5,0,3)
 #include "../kernels_unst/caldyn_slow_NH.k90"
+  STOP_TRACE
 END SUBROUTINE compute_caldyn_slow_NH
 
@@ -69,6 +103,12 @@
   FIELD_U      :: du                     ! OUT
   DECLARE_INDICES
-  DBL :: X_ij, rho_ij, T_ij, gamma, Cvd, vreff
+  DBL :: X_ij, rho_ij, T_ij, gamma, Cvd, vreff, Rd_preff
+#include "../kernels_unst/caldyn_mil.k90"
+  IF(tau>0) THEN ! solve implicit problem for geopotential
+    CALL compute_NH_geopot(tau, rhodz, m_il, theta, W, geopot)
+  END IF
+  START_TRACE(id_solver, 7,0,1)
 #include "../kernels_unst/caldyn_solver.k90"
+  STOP_TRACE
 END SUBROUTINE compute_caldyn_solver
 
@@ -79,5 +119,7 @@
   DECLARE_INDICES
   DBL :: w_ij, wflux_ij
+  START_TRACE(id_vert_NH, 6,0,1)
 #include "../kernels_unst/caldyn_vert_NH.k90"
+  STOP_TRACE
 END SUBROUTINE compute_caldyn_vert_NH
 
@@ -91,5 +133,7 @@
   DECLARE_INDICES
   DBL :: gdz, ke, uu, chi, gv, exner_ik, temp_ik, p_ik, qv, Rmix
+  START_TRACE(id_geopot, 3,0,3)
 #include "../kernels_unst/compute_geopot.k90"
+  STOP_TRACE
 END SUBROUTINE compute_geopot
 !
@@ -102,5 +146,7 @@
   LOGICAL, PARAMETER :: zero=.TRUE.
   DBL :: ke, uu
+  START_TRACE(id_slow_hydro, 3,0,3)
 #include "../kernels_unst/caldyn_slow_hydro.k90"
+  STOP_TRACE
 END SUBROUTINE compute_caldyn_slow_hydro
 
@@ -118,7 +164,9 @@
   wwuu=0.
   !$OMP BARRIER
+  START_TRACE(id_vert, 5,0,3)
 #include "../kernels_unst/caldyn_wflux.k90"
 #include "../kernels_unst/caldyn_dmass.k90"
 #include "../kernels_unst/caldyn_vert.k90"
+  STOP_TRACE
 END SUBROUTINE caldyn_vert
 
@@ -130,5 +178,7 @@
   DECLARE_EDGES
   DBL :: divF, du_trisk
+  START_TRACE(id_coriolis, 3,4,0) ! primal, dual, edge
 #include "../kernels_unst/coriolis.k90"
+  STOP_TRACE
 END SUBROUTINE
 
@@ -139,5 +189,7 @@
   DECLARE_INDICES
   DBL :: m
+  START_TRACE(id_theta, 3,0,0) ! primal, dual, edge
 #include "../kernels_unst/theta.k90"
+  STOP_TRACE
 END SUBROUTINE
 
@@ -150,5 +202,7 @@
   DECLARE_VERTICES
   DBL :: etav, hv
+  START_TRACE(id_pvort_only, 1,1,2) ! primal, dual, edge
 #include "../kernels_unst/pvort_only.k90"
+  STOP_TRACE
 END SUBROUTINE compute_pvort_only
 
@@ -162,7 +216,7 @@
   DECLARE_EDGES
   DBL          :: due
-
+  START_TRACE(id_fast, 4,0,2) ! primal, dual, edge
 #include "../kernels_unst/caldyn_fast.k90"
-
+  STOP_TRACE
 END SUBROUTINE compute_caldyn_fast
 
