Index: codes/icosagcm/trunk/src/caldyn_gcm.f90
===================================================================
--- codes/icosagcm/trunk/src/caldyn_gcm.f90	(revision 55)
+++ codes/icosagcm/trunk/src/caldyn_gcm.f90	(revision 56)
@@ -17,11 +17,12 @@
     IMPLICIT NONE
     REAL(rstd),INTENT(IN) :: dt
-    INTEGER :: write_period
+    REAL :: write_period
     
     write_period=0
     CALL getin('write_period',write_period)
     write_period=write_period/scale_factor
-    itau_out=INT(write_period/dt)
-  
+    itau_out=FLOOR(.5+write_period/dt)
+    PRINT *, 'Output frequency (scaled) set to ',write_period, ' : itau_out = ',itau_out
+ 
     CALL allocate_caldyn
   
@@ -43,14 +44,5 @@
 
   END SUBROUTINE allocate_caldyn
-  
-  SUBROUTINE swap_caldyn(ind)
-  IMPLICIT NONE
-    INTEGER,INTENT(IN) :: ind
-!    out=f_out(ind) 
-    out_u=f_out_u(ind) 
-!    out_z=f_out_z(ind) 
-      
-  END SUBROUTINE swap_caldyn
- 
+   
   SUBROUTINE check_mass_conservation(f_ps,f_dps)
   USE icosa
@@ -120,14 +112,10 @@
     CALL transfert_request(f_theta_rhodz,req_i1) 
     CALL transfert_request(f_u,req_e1)
-!    CALL transfert_request(f_u,req_e1) 
-   
-
-!    CALL vorticity(f_u,f_out_z)
     
     DO ind=1,ndomain
       CALL swap_dimensions(ind)
       CALL swap_geometry(ind)
-      CALL swap_caldyn(ind)
       
+      out_u=f_out_u(ind) 
       phis=f_phis(ind)
       ps=f_ps(ind)
@@ -137,30 +125,8 @@
       dtheta_rhodz=f_dtheta_rhodz(ind)
       du=f_du(ind)
-!      ij=(jj_end-1-1)*iim+ii_begin
-!      PRINT *,"--> ind=",ind,ij
-!      PRINT *,u(ij+u_right,1)
-!      PRINT *,u(ij+u_rup,1)
-!      PRINT *,u(ij+u_lup,1)
-!      PRINT *,u(ij+u_left,1)
-!      PRINT *,u(ij+u_ldown,1)
-!      PRINT *,u(ij+u_rdown,1)
-
-!      ij=(jj_end-1-1)*iim+ii_end
-!      PRINT *,"--> ind=",ind,ij
-!      PRINT *,u(ij+u_right,1)
-!      PRINT *,u(ij+u_rup,1)
-!      PRINT *,u(ij+u_lup,1)
-!      PRINT *,u(ij+u_left,1)
-!      PRINT *,u(ij+u_ldown,1)
-!      PRINT *,u(ij+u_rdown,1)      
 !$OMP PARALLEL DEFAULT(SHARED)
       CALL compute_caldyn(phis, ps, theta_rhodz, u, dps, dtheta_rhodz, du)
 !$OMP END PARALLEL
     ENDDO
-
-!    CALL transfert_request(f_out_u,req_e1)
-!    CALL transfert_request(f_out_u,req_e1) 
-
-!    CALL vorticity(f_u,f_out_z)
 
     IF (mod(it,itau_out)==0 ) THEN
@@ -169,5 +135,4 @@
             f_buf_i, f_buf_v, f_buf_u3d, f_buf_ulon, f_buf_ulat, f_buf_s, f_buf_p)
     END IF
-
 
 !    CALL check_mass_conservation(f_ps,f_dps)
@@ -192,5 +157,5 @@
     REAL(rstd) :: ww,uu 
     REAL(rstd) :: delta
-    REAL(rstd) :: etav,hv    
+    REAL(rstd) :: etav,hv, du2
 
 !   REAL(rstd) :: theta(iim*jjm,llm)  ! potential temperature
@@ -272,6 +237,7 @@
 !    berni=1e10
     
- !!! Compute pression
- 
+ !!! Compute pressure
+
+!    PRINT *, 'Computing pressure'
     DO    l    = 1, llm+1
 !$OMP DO
@@ -285,7 +251,9 @@
       
  !!! Compute Exner function
+!    PRINT *, 'Computing Exner'
     CALL compute_exner(ps,p,pks,pk,1) 
 
 !!! Compute mass
+   ! PRINT *, 'Computing mass'
    DO l = 1, llm
 !$OMP DO
@@ -300,4 +268,5 @@
 
 !! compute theta
+   ! PRINT *, 'Computing theta'
     DO    l    = 1, llm
 !$OMP DO
@@ -336,5 +305,4 @@
    
 !!!  Compute mass flux
-!! question ï¿œ thomas : meilleure pondï¿œration de la masse sur les liens ?
 
   DO l = 1, llm
@@ -416,17 +384,6 @@
     ENDDO
   ENDDO
-  
-
-!  DO l = 1, llm
-!!$OMP DO
-!   DO j=jj_begin,jj_end
-!    DO i=ii_begin,ii_end
-!      ij=(j-1)*iim+i
-!      out(ij,l)=theta(ij,l)-288
-!    ENDDO
-!  ENDDO
-! ENDDO
-
-
+
+  
 !!! Compute dps
 !$OMP DO
@@ -440,5 +397,4 @@
 
 
-
 !!! Compute vertical velocity
   DO l = 1,llm-1
@@ -455,4 +411,5 @@
 
 !$OMP DO
+  ! vertical mass flux at the surface = 0
   DO j=jj_begin,jj_end
     DO i=ii_begin,ii_end
@@ -463,5 +420,5 @@
 
 
-!!! Compute potential vorticity
+!!! Compute shallow-water potential vorticity
   DO l = 1,llm
 !$OMP DO
@@ -494,5 +451,5 @@
     ENDDO
 
-!!! Compute potential vorticity contribution to du
+!!! Compute potential vorticity (Coriolis) contribution to du
   DO l=1,llm
 !$OMP DO
@@ -565,5 +522,5 @@
   
  
-!!! second contribution to du
+!!! second contribution to du (gradients of Bernoulli and Exner functions)
   DO l=1,llm
 !$OMP DO
@@ -590,5 +547,5 @@
   ENDDO
  
-!!! second contribution to du
+!!! save second contribution to du for debugging output
   DO l=1,llm
 !$OMP DO
@@ -615,5 +572,5 @@
   ENDDO
 
-!!! contribution due to vertical advection
+!!! contributions due to vertical advection
  
  ! Contribution to dtheta
