Index: LMDZ5/branches/testing/libf/dyn3dpar/addfi_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/addfi_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/addfi_p.F	(revision 2641)
@@ -48,7 +48,5 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom.h"
-#include "serre.h"
 c
 c    Arguments :
Index: LMDZ5/branches/testing/libf/dyn3dpar/advect_new_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/advect_new_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/advect_new_p.F	(revision 2641)
@@ -6,4 +6,7 @@
       USE parallel_lmdz
       USE write_field_p
+      USE comconst_mod, ONLY: daysec
+      USE logic_mod, ONLY: conser
+      
       IMPLICIT NONE
 c=======================================================================
@@ -28,9 +31,5 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "logic.h"
-#include "ener.h"
 
 c   Arguments:
@@ -117,5 +116,5 @@
                   
            uav(ij,l)=0.25*(ucov(ij,l)+ucov(ij-iip1,l))
-     .	             +0.25*(ucov(ij+iip1,l)+ucov(ij,l))
+     .                     +0.25*(ucov(ij+iip1,l)+ucov(ij,l))
          ENDDO
          
@@ -250,6 +249,6 @@
       DO l=1,llm
         DO ij=ijb,ije-1
-	  du(ij,l)=du(ij,l)+du2(ij,l)-du1(ij,l)
-	ENDDO
+          du(ij,l)=du(ij,l)+du2(ij,l)-du1(ij,l)
+        ENDDO
 
         DO   ij   = ijb+iip1-1, ije, iip1
@@ -266,6 +265,6 @@
       DO l=1,llm
         DO ij=ijb,ije
-	  dv(ij,l)=dv(ij,l)+dv2(ij,l)-dv1(ij,l)
-	ENDDO
+          dv(ij,l)=dv(ij,l)+dv2(ij,l)-dv1(ij,l)
+        ENDDO
       ENDDO
 c$OMP END DO NOWAIT      
@@ -276,6 +275,6 @@
       DO l=1,llm
         DO ij=ijb,ije
-	  dteta(ij,l)=dteta(ij,l)+dteta2(ij,l)-dteta1(ij,l)
-	ENDDO
+          dteta(ij,l)=dteta(ij,l)+dteta2(ij,l)-dteta1(ij,l)
+        ENDDO
       ENDDO
 c$OMP END DO NOWAIT      
Index: LMDZ5/branches/testing/libf/dyn3dpar/advect_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/advect_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/advect_p.F	(revision 2641)
@@ -5,4 +5,7 @@
       USE parallel_lmdz
       USE write_field_p
+      USE comconst_mod, ONLY: daysec
+      USE logic_mod, ONLY: conser
+      
       IMPLICIT NONE
 c=======================================================================
@@ -27,9 +30,5 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "logic.h"
-#include "ener.h"
 
 c   Arguments:
@@ -86,5 +85,5 @@
                   
            uav(ij,l)=0.25*(ucov(ij,l)+ucov(ij-iip1,l))
-     .	             +0.25*(ucov(ij+iip1,l)+ucov(ij,l))
+     .                     +0.25*(ucov(ij+iip1,l)+ucov(ij,l))
          ENDDO
          
Index: LMDZ5/branches/testing/libf/dyn3dpar/advtrac_p.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/advtrac_p.F90	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/advtrac_p.F90	(revision 2641)
@@ -19,15 +19,11 @@
   USE infotrac, ONLY: nqtot, iadv
   USE control_mod, ONLY: iapp_tracvl, day_step, planet_type
+  USE comconst_mod, ONLY: dtvr
   IMPLICIT NONE
   !
   include "dimensions.h"
   include "paramet.h"
-  include "comconst.h"
-  include "comvert.h"
   include "comdissip.h"
   include "comgeom2.h"
-  include "logic.h"
-  include "temps.h"
-  include "ener.h"
   include "description.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/bernoui_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/bernoui_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/bernoui_p.F	(revision 2641)
@@ -25,5 +25,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 c
 c   Arguments:
Index: LMDZ5/branches/testing/libf/dyn3dpar/bilan_dyn_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/bilan_dyn_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/bilan_dyn_p.F	(revision 2641)
@@ -17,12 +17,13 @@
       use misc_mod
       use write_field_p
+      USE comconst_mod, ONLY: cpp, pi
+      USE comvert_mod, ONLY: presnivs
+      USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
+      
       IMPLICIT NONE
 
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom2.h"
-#include "temps.h"
 #include "iniprint.h"
 
@@ -202,7 +203,7 @@
 
 !        if (i_sortie.eq.1) then
-!	 file='dynzon'
+!         file='dynzon'
 !         if (mpi_rank==0) then
-!	 call inigrads(ifile,1
+!         call inigrads(ifile,1
 !     s  ,0.,180./pi,0.,0.,jjm,rlatv,-90.,90.,180./pi
 !     s  ,llm,presnivs,1.
@@ -568,5 +569,5 @@
         do l=1,llm
           Q_cum(:,jjb:jje,l,iQ)=Q_cum(:,jjb:jje,l,iQ) 
-     .	                        /masse_cum(:,jjb:jje,l)
+     .                                /masse_cum(:,jjb:jje,l)
         enddo
 !$OMP ENDDO NOWAIT 
Index: LMDZ5/branches/testing/libf/dyn3dpar/caladvtrac_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/caladvtrac_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/caladvtrac_p.F	(revision 2641)
@@ -10,4 +10,5 @@
       USE infotrac, ONLY : nqtot
       USE control_mod, ONLY : iapp_tracvl,planet_type
+      USE comconst_mod, ONLY: dtvr
 c
       IMPLICIT NONE
@@ -25,5 +26,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 
 c   Arguments:
Index: LMDZ5/branches/testing/libf/dyn3dpar/caldyn_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/caldyn_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/caldyn_p.F	(revision 2641)
@@ -10,4 +10,5 @@
       USE parallel_lmdz
       USE Write_Field_p
+      USE comvert_mod, ONLY: ap, bp
       
       IMPLICIT NONE
@@ -31,6 +32,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/conf_gcm.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/conf_gcm.F90	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/conf_gcm.F90	(revision 2641)
@@ -16,4 +16,13 @@
   USE infotrac, ONLY : type_trac
   use assert_m, only: assert
+  USE comconst_mod, ONLY: dissip_deltaz, dissip_factz, dissip_zref, &
+                          iflag_top_bound, mode_top_bound, tau_top_bound, &
+                          ngroup
+  USE logic_mod, ONLY: fxyhypb, iflag_phys, ok_etat0, ok_gradsfile, &
+                       ok_guide, ok_limit, ok_strato, purmats, read_start, &
+                       ysinus
+  USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy, &
+                       alphax,alphay,taux,tauy
+  USE temps_mod, ONLY: calend
 
   IMPLICIT NONE
@@ -34,9 +43,5 @@
   include "dimensions.h"
   include "paramet.h"
-  include "logic.h"
-  include "serre.h"
   include "comdissnew.h"
-  include "temps.h"
-  include "comconst.h"
   include "iniprint.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/convmas1_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/convmas1_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/convmas1_p.F	(revision 2641)
@@ -32,6 +32,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
-#include "logic.h"
 
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm )
Index: LMDZ5/branches/testing/libf/dyn3dpar/convmas2_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/convmas2_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/convmas2_p.F	(revision 2641)
@@ -32,6 +32,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
-#include "logic.h"
 
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm )
Index: LMDZ5/branches/testing/libf/dyn3dpar/convmas_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/convmas_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/convmas_p.F	(revision 2641)
@@ -32,6 +32,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
-#include "logic.h"
 
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm )
Index: LMDZ5/branches/testing/libf/dyn3dpar/dissip_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/dissip_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/dissip_p.F	(revision 2641)
@@ -6,4 +6,5 @@
       USE parallel_lmdz
       USE write_field_p
+      USE comconst_mod, ONLY: dtdiss
       IMPLICIT NONE
 
@@ -29,5 +30,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom.h"
 #include "comdissnew.h"
Index: LMDZ5/branches/testing/libf/dyn3dpar/divgrad_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/divgrad_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/divgrad_p.F	(revision 2641)
@@ -23,5 +23,4 @@
 #include "comgeom.h"
 #include "comdissipn.h"
-#include "logic.h"
 c
       INTEGER klevel
Index: LMDZ5/branches/testing/libf/dyn3dpar/dteta1_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/dteta1_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/dteta1_p.F	(revision 2641)
@@ -22,5 +22,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 
       REAL teta( ip1jmp1,llm ),pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
Index: LMDZ5/branches/testing/libf/dyn3dpar/dudv2_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/dudv2_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/dudv2_p.F	(revision 2641)
@@ -25,5 +25,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
 
       REAL teta( ip1jmp1,llm ),pkf( ip1jmp1,llm ) ,bern( ip1jmp1,llm ),
Index: LMDZ5/branches/testing/libf/dyn3dpar/dynetat0.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/dynetat0.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/dynetat0.F	(revision 2641)
@@ -9,4 +9,12 @@
 
       use control_mod, only : planet_type
+      USE comvert_mod, ONLY: pa,preff
+      USE comconst_mod, ONLY: cpp, daysec, dtvr, g, im, jm, kappa,
+     &                        lllm, omeg, rad
+      USE logic_mod, ONLY: fxyhypb, ysinus
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy
+      USE temps_mod, ONLY: annee_ref,day_ref,itau_dyn,
+     &                     start_time,day_ini,hour_ini
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
 
       IMPLICIT NONE
@@ -29,13 +37,7 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "temps.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom2.h"
-#include "ener.h"
 #include "netcdf.inc"
 #include "description.h"
-#include "serre.h"
-#include "logic.h"
 #include "iniprint.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/dynredem.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/dynredem.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/dynredem.F	(revision 2641)
@@ -9,4 +9,13 @@
       USE infotrac
       use netcdf95, only: NF95_PUT_VAR
+      USE comvert_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt,pa,preff,
+     &                        nivsig,nivsigs
+      USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad
+      USE logic_mod, ONLY: fxyhypb, ysinus
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy,
+     &                     taux,tauy
+      USE temps_mod, ONLY: annee_ref,day_ref,itau_dyn,itaufin,
+     &                        start_time,hour_ini
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
  
       IMPLICIT NONE
@@ -18,13 +27,7 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom2.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
 #include "netcdf.inc"
 #include "description.h"
-#include "serre.h"
 #include "iniprint.h"
 
@@ -471,4 +474,5 @@
       use netcdf, only: NF90_get_VAR
       use netcdf95, only: NF95_PUT_VAR
+      USE temps_mod, ONLY: itau_dyn, itaufin
  
       IMPLICIT NONE
@@ -480,7 +484,5 @@
 #include "description.h"
 #include "netcdf.inc"
-#include "comvert.h"
 #include "comgeom.h"
-#include "temps.h"
 #include "iniprint.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/dynredem_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/dynredem_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/dynredem_p.F	(revision 2641)
@@ -10,4 +10,13 @@
       USE infotrac
       use netcdf95, only: NF95_PUT_VAR
+      USE comvert_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt,pa,preff,
+     &                        nivsig,nivsigs
+      USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad
+      USE logic_mod, ONLY: fxyhypb, ysinus
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy,
+     &                     taux,tauy
+      USE temps_mod, ONLY: annee_ref,day_ref,itau_dyn,itaufin,
+     &                        start_time,hour_ini
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
  
       IMPLICIT NONE
@@ -19,13 +28,7 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom2.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
 #include "netcdf.inc"
 #include "description.h"
-#include "serre.h"
 
 c   Arguments:
@@ -472,4 +475,5 @@
       use netcdf, only: NF90_get_VAR
       use netcdf95, only: NF95_PUT_VAR
+      USE temps_mod, ONLY: itau_dyn, itaufin
  
       IMPLICIT NONE
@@ -481,7 +485,5 @@
 #include "description.h"
 #include "netcdf.inc"
-#include "comvert.h"
 #include "comgeom.h"
-#include "temps.h"
 
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/exner_hyb_p_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/exner_hyb_p_m.F90	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/exner_hyb_p_m.F90	(revision 2641)
@@ -33,11 +33,10 @@
     !
     USE parallel_lmdz
+    USE comconst_mod, ONLY: cpp, kappa, r, jmp1
+    USE comvert_mod, ONLY: preff
     !
     include "dimensions.h"
     include "paramet.h"
-    include "comconst.h"
     include "comgeom.h"
-    include "comvert.h"
-    include "serre.h"
 
     INTEGER  ngrid
Index: LMDZ5/branches/testing/libf/dyn3dpar/exner_milieu_p_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/exner_milieu_p_m.F90	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/exner_milieu_p_m.F90	(revision 2641)
@@ -30,11 +30,10 @@
     !
     USE parallel_lmdz
+    USE comconst_mod, ONLY: cpp, kappa, r, jmp1
+    USE comvert_mod, ONLY: preff
     !
     include "dimensions.h"
     include "paramet.h"
-    include "comconst.h"
     include "comgeom.h"
-    include "comvert.h"
-    include "serre.h"
 
     INTEGER  ngrid
Index: LMDZ5/branches/testing/libf/dyn3dpar/fluxstokenc_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/fluxstokenc_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/fluxstokenc_p.F	(revision 2641)
@@ -21,9 +21,6 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
 #include "tracstoke.h"
-#include "temps.h"
 #include "iniprint.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/friction_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/friction_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/friction_p.F	(revision 2641)
@@ -12,4 +12,5 @@
       USE ioipsl_getincom
 #endif
+      USE comconst_mod, ONLY: pi
       IMPLICIT NONE
 
@@ -29,5 +30,4 @@
 #include "paramet.h"
 #include "comgeom2.h"
-#include "comconst.h"
 #include "iniprint.h"
 #include "academic.h"
Index: LMDZ5/branches/testing/libf/dyn3dpar/gcm.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/gcm.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/gcm.F	(revision 2641)
@@ -32,4 +32,10 @@
       USE iniphysiq_mod, ONLY: iniphysiq
 #endif
+      USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, r, rad
+      USE logic_mod ! all of it, because of copyin clause when calling leapfrog
+      USE temps_mod, ONLY: calend,start_time,annee_ref,day_ref,
+     &                itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end,
+     &                dt,hour_ini,itaufin
+
       IMPLICIT NONE
 
@@ -65,13 +71,7 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comdissnew.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "logic.h"
-#include "temps.h"
-#include "ener.h"
 #include "description.h"
-#include "serre.h"
 !#include "com_io_dyn.h"
 #include "iniprint.h"
@@ -499,5 +499,14 @@
 c       write(78,*) 'q',q
 
-c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logici/,/logicl/)
+!c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logici/,/logicl/)
+c$OMP PARALLEL DEFAULT(SHARED)
+c        Copy all threadprivate variables from temps_mod
+c$OMP1 COPYIN(dt,jD_ref,jH_ref,start_time,hour_ini,day_ini,day_end)
+c$OMP1 COPYIN(annee_ref,day_ref,itau_dyn,itau_phy,itaufin,calend)
+c	Copy all threadprivate variables from logic_mod
+c$OMP1 COPYIN(purmats,forward,leapf,apphys,statcl,conser,apdiss,apdelq)
+c$OMP1 COPYIN(saison,ecripar,fxyhypb,ysinus,read_start,ok_guide)
+c$OMP1 COPYIN(ok_strato,ok_gradsfile,ok_limit,ok_etat0)
+c$OMP1 COPYIN(iflag_phys,iflag_trac)
       CALL leapfrog_p(ucov,vcov,teta,ps,masse,phis,q,time_0)
 c$OMP END PARALLEL
Index: LMDZ5/branches/testing/libf/dyn3dpar/geopot_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/geopot_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/geopot_p.F	(revision 2641)
@@ -28,5 +28,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
 
 c   Arguments:
Index: LMDZ5/branches/testing/libf/dyn3dpar/gradiv_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/gradiv_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/gradiv_p.F	(revision 2641)
@@ -21,5 +21,4 @@
 #include "paramet.h"
 #include "comdissipn.h"
-#include "logic.h"
 
       INTEGER klevel
Index: LMDZ5/branches/testing/libf/dyn3dpar/groupe_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/groupe_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/groupe_p.F	(revision 2641)
@@ -1,4 +1,5 @@
       subroutine groupe_p(pext,pbaru,pbarv,pbarum,pbarvm,wm)
       USE parallel_lmdz
+      USE comconst_mod, ONLY: ngroup
       implicit none
 
@@ -16,7 +17,5 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom2.h"
-#include "comvert.h"
 
 !     integer ngroup
Index: LMDZ5/branches/testing/libf/dyn3dpar/groupeun_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/groupeun_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/groupeun_p.F	(revision 2641)
@@ -2,9 +2,9 @@
       USE parallel_lmdz
       USE Write_Field_p
+      USE comconst_mod, ONLY: ngroup
       IMPLICIT NONE
 
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom2.h"
 
@@ -136,9 +136,9 @@
 
       USE parallel_lmdz
+      USE comconst_mod, ONLY: ngroup
       IMPLICIT NONE
 
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom2.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/guide_p_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/guide_p_mod.F90	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/guide_p_mod.F90	(revision 2641)
@@ -68,5 +68,6 @@
   SUBROUTINE guide_init
 
-    USE control_mod
+    USE control_mod, ONLY: day_step
+    USE serre_mod, ONLY: grossismx
 
     IMPLICIT NONE
@@ -75,7 +76,4 @@
     INCLUDE "paramet.h"
     INCLUDE "netcdf.inc"
-
-    ! For grossismx:
-    include "serre.h"
 
     INTEGER                :: error,ncidpl,rid,rcod
@@ -341,4 +339,6 @@
     USE parallel_lmdz
     USE control_mod
+    USE comconst_mod, ONLY: daysec, dtvr, cpp, kappa
+    USE comvert_mod, ONLY: ap, bp, preff, presnivs, pressure_exner
     
     IMPLICIT NONE
@@ -346,6 +346,4 @@
     INCLUDE "dimensions.h"
     INCLUDE "paramet.h"
-    INCLUDE "comconst.h"
-    INCLUDE "comvert.h"
 
     ! Variables entree
@@ -619,4 +617,6 @@
   SUBROUTINE guide_zonave(typ,hsize,vsize,field)
 
+    USE comconst_mod, ONLY: pi
+    
     IMPLICIT NONE
 
@@ -624,5 +624,4 @@
     INCLUDE "paramet.h"
     INCLUDE "comgeom.h"
-    INCLUDE "comconst.h"
     
     ! input/output variables
@@ -707,11 +706,11 @@
   USE mod_hallo
   USE Bands
+  USE comconst_mod, ONLY: cpp, kappa
+  USE comvert_mod, ONLY: preff, pressure_exner, bp, ap
   IMPLICIT NONE
 
   include "dimensions.h"
   include "paramet.h"
-  include "comvert.h"
   include "comgeom2.h"
-  include "comconst.h"
 
   REAL, DIMENSION (iip1,jjp1),     INTENT(IN) :: psi ! Psol gcm
@@ -1099,11 +1098,12 @@
 ! Calcul des constantes de rappel alpha (=1/tau)
 
+    use comconst_mod, only: pi
+    use serre_mod, only: clat, clon, grossismx, grossismy
+    
     implicit none
 
     include "dimensions.h"
     include "paramet.h"
-    include "comconst.h"
     include "comgeom2.h"
-    include "serre.h"
 
 ! input arguments :
@@ -1813,4 +1813,6 @@
   SUBROUTINE guide_out(varname,hsize,vsize,field,factt)
     USE parallel_lmdz
+    USE comconst_mod, ONLY: pi
+    USE comvert_mod, ONLY: presnivs
     IMPLICIT NONE
 
@@ -1819,6 +1821,4 @@
     INCLUDE "netcdf.inc"
     INCLUDE "comgeom2.h"
-    INCLUDE "comconst.h"
-    INCLUDE "comvert.h"
     
     ! Variables entree
Index: LMDZ5/branches/testing/libf/dyn3dpar/iniacademic.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/iniacademic.F90	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/iniacademic.F90	(revision 2641)
@@ -16,4 +16,9 @@
   use exner_hyb_m, only: exner_hyb
   use exner_milieu_m, only: exner_milieu
+  USE comconst_mod, ONLY: cpp, kappa, g, daysec, dtvr, pi, im, jm
+  USE logic_mod, ONLY: iflag_phys, read_start
+  USE comvert_mod, ONLY: ap, bp, preff, presnivs, pressure_exner
+  USE temps_mod, ONLY: annee_ref, day_ini, day_ref
+  USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
 
   !   Author:    Frederic Hourdin      original: 15/01/93
@@ -28,12 +33,7 @@
   include "dimensions.h"
   include "paramet.h"
-  include "comvert.h"
-  include "comconst.h"
   include "comgeom.h"
   include "academic.h"
-  include "ener.h"
-  include "temps.h"
   include "iniprint.h"
-  include "logic.h"
 
   !   Arguments:
Index: LMDZ5/branches/testing/libf/dyn3dpar/initdynav_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/initdynav_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/initdynav_p.F	(revision 2641)
@@ -12,4 +12,7 @@
        use misc_mod
        USE infotrac
+       USE comconst_mod, ONLY: pi
+       USE comvert_mod, ONLY: nivsigs
+       USE temps_mod, ONLY: itau_dyn
 
       implicit none
@@ -43,12 +46,6 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
 #include "description.h"
-#include "serre.h"
 #include "iniprint.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/initfluxsto_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/initfluxsto_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/initfluxsto_p.F	(revision 2641)
@@ -13,4 +13,7 @@
        use Write_field
        use misc_mod
+       USE comconst_mod, ONLY: pi
+       USE comvert_mod, ONLY: nivsigs
+       USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
        
       implicit none
@@ -45,12 +48,6 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
 #include "description.h"
-#include "serre.h"
 #include "iniprint.h"
 
@@ -106,6 +103,6 @@
       CALL ymds2ju(zan, 1, idayref, 0.0, zjulian)
       tau0 = itau_dyn
-	
-	do jj = 1, jjp1
+        
+        do jj = 1, jjp1
         do ii = 1, iip1
           rlong(ii,jj) = rlonu(ii) * 180. / pi
@@ -165,6 +162,6 @@
      .             1, iip1, 1, jjn,tau0, zjulian, tstep, vhoriid,
      .             filevid,dynv_domain_id)
-	
-      rl(1,1) = 1.	
+        
+      rl(1,1) = 1.        
       
       if (mpi_rank==0) then
@@ -191,5 +188,5 @@
       call histhori(fileid, iip1, rlong(:,jjb:jje),jjn,rlat(:,jjb:jje),
      .             'scalar','Grille points scalaires', thoriid)
-	
+        
 C
 C  Appel a histvert pour la grille verticale
@@ -211,6 +208,6 @@
 C
 C  Appels a histdef pour la definition des variables a sauvegarder
-	
-	CALL histdef(fileid, "phis", "Surface geop. height", "-",
+        
+        CALL histdef(fileid, "phis", "Surface geop. height", "-",
      .                iip1,jjn,thoriid, 1,1,1, -99, 32,
      .                "once", t_ops, t_wrt)
@@ -219,8 +216,8 @@
      .                iip1,jjn,thoriid, 1,1,1, -99, 32,
      .                "once", t_ops, t_wrt)
-	
+        
         if (mpi_rank==0) then
-	
-	CALL histdef(filedid, "dtvr", "tps dyn", "s",
+        
+        CALL histdef(filedid, "dtvr", "tps dyn", "s",
      .                1,1,dhoriid, 1,1,1, -99, 32,
      .                "once", t_ops, t_wrt)
@@ -289,5 +286,5 @@
         if (mpi_rank==0) call histsync(filedid)
       endif
-	
+        
 #else
       write(lunout,*)'initfluxsto_p: Needs IOIPSL to function'
Index: LMDZ5/branches/testing/libf/dyn3dpar/inithist_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/inithist_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/inithist_p.F	(revision 2641)
@@ -13,4 +13,7 @@
        use misc_mod
        USE infotrac
+       USE comconst_mod, ONLY: pi
+       USE comvert_mod, ONLY: nivsigs
+       USE temps_mod, ONLY: itau_dyn
 
       implicit none
@@ -45,12 +48,6 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
 #include "description.h"
-#include "serre.h"
 #include "iniprint.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/integrd_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/integrd_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/integrd_p.F	(revision 2641)
@@ -7,4 +7,9 @@
       USE parallel_lmdz
       USE control_mod, only : planet_type
+      USE comconst_mod, ONLY: pi
+      USE logic_mod, ONLY: leapf
+      USE comvert_mod, ONLY: ap, bp
+      USE temps_mod, ONLY: dt
+      
       IMPLICIT NONE
 
@@ -27,10 +32,5 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom.h"
-#include "comvert.h"
-#include "logic.h"
-#include "temps.h"
-#include "serre.h"
 #include "iniprint.h"
 
@@ -284,5 +284,5 @@
       ije=ij_end
 
-	 if (planet_type.eq."earth") then
+         if (planet_type.eq."earth") then
 ! Earth-specific treatment of first 2 tracers (water)
 c$OMP BARRIER
@@ -385,6 +385,6 @@
           DO l = 1, llm
             massem1(ijb:ije,l)=massescr(ijb:ije,l)
-	  ENDDO
-c$OMP END DO NOWAIT	  
+          ENDDO
+c$OMP END DO NOWAIT  
       END IF
 c$OMP BARRIER
Index: LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/leapfrog_p.F	(revision 2641)
@@ -28,4 +28,11 @@
      &                       periodav, ok_dyn_ave, output_grads_dyn,
      &                       iapp_tracvl
+       USE comvert_mod, ONLY: ap,bp,pressure_exner,presnivs
+       USE comconst_mod, ONLY: cpp, dtvr, ihf, dtphys, pi, jmp1
+       USE logic_mod, ONLY: iflag_phys,ok_guide,forward,leapf,apphys,
+     &                      statcl,conser,apdiss,purmats,ok_strato
+       USE temps_mod, ONLY: itaufin,jD_ref,jH_ref,day_ini,
+     &                        day_ref,start_time,dt
+
       IMPLICIT NONE
 
@@ -63,13 +70,7 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comdissnew.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "logic.h"
-#include "temps.h"
-#include "ener.h"
 #include "description.h"
-#include "serre.h"
 !#include "com_io_dyn.h"
 #include "iniprint.h"
@@ -1455,15 +1456,15 @@
                 call Gather_Field(teta,ip1jmp1,llm,0)
                 call Gather_Field(pk,ip1jmp1,llm,0)
-		call Gather_Field(phi,ip1jmp1,llm,0)
+                call Gather_Field(phi,ip1jmp1,llm,0)
                 do iq=1,nqtot
                   call Gather_Field(q(1,1,iq),ip1jmp1,llm,0)
                 enddo
-		call Gather_Field(masse,ip1jmp1,llm,0)
+                call Gather_Field(masse,ip1jmp1,llm,0)
                 call Gather_Field(ps,ip1jmp1,1,0)
-		call Gather_Field(phis,ip1jmp1,1,0)
+                call Gather_Field(phis,ip1jmp1,1,0)
                 if (mpi_rank==0) then
                  CALL writedynav(itau,vcov,
      &                 ucov,teta,pk,phi,q,masse,ps,phis)
-		endif
+                endif
 #endif
 !$OMP END MASTER
@@ -1477,5 +1478,5 @@
             IF( MOD(itau,iecri).EQ.0) THEN
              ! Ehouarn: output only during LF or Backward Matsuno
-	     if (leapf.or.(.not.leapf.and.(.not.forward))) then
+             if (leapf.or.(.not.leapf.and.(.not.forward))) then
 c$OMP BARRIER
 c$OMP MASTER
@@ -1515,14 +1516,14 @@
                 call Gather_Field(ucov,ip1jmp1,llm,0)
                 call Gather_Field(teta,ip1jmp1,llm,0)
-		call Gather_Field(phi,ip1jmp1,llm,0)
+                call Gather_Field(phi,ip1jmp1,llm,0)
                 do iq=1,nqtot
                   call Gather_Field(q(1,1,iq),ip1jmp1,llm,0)
                 enddo
-		call Gather_Field(masse,ip1jmp1,llm,0)
+                call Gather_Field(masse,ip1jmp1,llm,0)
                 call Gather_Field(ps,ip1jmp1,1,0)
-		call Gather_Field(phis,ip1jmp1,1,0)
+                call Gather_Field(phis,ip1jmp1,1,0)
                 if (mpi_rank==0) then
-	         CALL writehist(itau,vcov,ucov,teta,phi,q,masse,ps,phis)
-		endif
+                 CALL writehist(itau,vcov,ucov,teta,phi,q,masse,ps,phis)
+                endif
 !              CALL writehist_p(histid,histvid, itau,vcov, 
 !     &                         ucov,teta,phi,q,masse,ps,phis)
@@ -1650,15 +1651,15 @@
                 call Gather_Field(teta,ip1jmp1,llm,0)
                 call Gather_Field(pk,ip1jmp1,llm,0)
-		call Gather_Field(phi,ip1jmp1,llm,0)
+                call Gather_Field(phi,ip1jmp1,llm,0)
                 do iq=1,nqtot
                   call Gather_Field(q(1,1,iq),ip1jmp1,llm,0)
                 enddo
-		call Gather_Field(masse,ip1jmp1,llm,0)
+                call Gather_Field(masse,ip1jmp1,llm,0)
                 call Gather_Field(ps,ip1jmp1,1,0)
-		call Gather_Field(phis,ip1jmp1,1,0)
+                call Gather_Field(phis,ip1jmp1,1,0)
                 if (mpi_rank==0) then
                  CALL writedynav(itau,vcov,
      &                 ucov,teta,pk,phi,q,masse,ps,phis)
-		endif
+                endif
 #endif
 !$OMP END MASTER
@@ -1706,14 +1707,14 @@
                 call Gather_Field(ucov,ip1jmp1,llm,0)
                 call Gather_Field(teta,ip1jmp1,llm,0)
-		call Gather_Field(phi,ip1jmp1,llm,0)
+                call Gather_Field(phi,ip1jmp1,llm,0)
                 do iq=1,nqtot
                   call Gather_Field(q(1,1,iq),ip1jmp1,llm,0)
                 enddo
-		call Gather_Field(masse,ip1jmp1,llm,0)
+                call Gather_Field(masse,ip1jmp1,llm,0)
                 call Gather_Field(ps,ip1jmp1,1,0)
-		call Gather_Field(phis,ip1jmp1,1,0)
+                call Gather_Field(phis,ip1jmp1,1,0)
                 if (mpi_rank==0) then
                  CALL writehist(itau,vcov,ucov,teta,phi,q,masse,ps,phis)
-		endif
+                endif
 !                CALL writehist_p(histid, histvid, itau,vcov , 
 !     &                           ucov,teta,phi,q,masse,ps,phis)
Index: LMDZ5/branches/testing/libf/dyn3dpar/logic.h
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/logic.h	(revision 2471)
+++ 	(revision )
@@ -1,28 +1,0 @@
-!
-! $Id$
-!
-!
-! NB: keep items of different kinds in seperate common blocs to avoid
-!     "misaligned commons" issues
-!-----------------------------------------------------------------------
-! INCLUDE 'logic.h'
-
-      COMMON/logicl/ purmats,forward,leapf,apphys,                      &
-     &  statcl,conser,apdiss,apdelq,saison,ecripar,fxyhypb,ysinus       &
-     &  ,read_start,ok_guide,ok_strato,ok_gradsfile                     &
-     &  ,ok_limit,ok_etat0,hybrid
-
-      COMMON/logici/ iflag_phys,iflag_trac
-      
-      LOGICAL purmats,forward,leapf,apphys,statcl,conser,               &
-     & apdiss,apdelq,saison,ecripar,fxyhypb,ysinus                      &
-     &  ,read_start,ok_guide,ok_strato,ok_gradsfile                     &
-     &  ,ok_limit,ok_etat0
-
-      logical hybrid ! vertical coordinate is hybrid if true (sigma otherwise)
-                     ! (only used if disvert_type==2)
-
-      integer iflag_phys,iflag_trac
-!$OMP THREADPRIVATE(/logicl/)
-!$OMP THREADPRIVATE(/logici/)
-!-----------------------------------------------------------------------
Index: LMDZ5/branches/testing/libf/dyn3dpar/logic_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/logic_mod.F90	(revision 2641)
+++ LMDZ5/branches/testing/libf/dyn3dpar/logic_mod.F90	(revision 2641)
@@ -0,0 +1,45 @@
+!
+! $Id$
+!
+MODULE logic_mod
+
+IMPLICIT NONE
+
+  LOGICAL purmats ! true if time stepping is purely Matsuno scheme
+                  ! false implies Matsuno-Leapfrog time stepping scheme
+  LOGICAL forward ! true if during forward phase of Matsuno step
+  LOGICAL leapf ! true if during a leapfrog time stepping step
+  LOGICAL apphys ! true if during a time step when physics will be called
+  LOGICAL statcl
+  LOGICAL conser
+  LOGICAL apdiss ! true if during a time step when dissipation will be called
+  LOGICAL apdelq
+  LOGICAL saison
+  LOGICAL ecripar
+  LOGICAL fxyhypb ! true if using hyperbolic function discretization
+                  ! for latitudinal grid 
+  LOGICAL ysinus ! true if using sine function discretiation
+                 ! for latitudinal grid
+  LOGICAL read_start ! true if reading a start.nc file to initialize fields
+  LOGICAL ok_guide ! true if nudging
+  LOGICAL ok_strato
+  LOGICAL ok_gradsfile
+  LOGICAL ok_limit
+  LOGICAL ok_etat0
+  LOGICAL hybrid ! vertical coordinate is hybrid if true (sigma otherwise)
+                 ! (only used if disvert_type==2)
+  INTEGER iflag_phys ! type of physics to call: 0 none, 1: phy*** package,
+                     ! 2: Held & Suarez, 101-200: aquaplanets & terraplanets
+  INTEGER iflag_trac
+
+!$OMP THREADPRIVATE(purmats,forward,leapf,apphys,statcl,conser, &
+!$OMP     apdiss,apdelq,saison,ecripar,fxyhypb,ysinus, &
+!$OMP     read_start,ok_guide,ok_strato,ok_gradsfile, &
+!$OMP     ok_limit,ok_etat0,hybrid)
+!$OMP THREADPRIVATE(iflag_phys,iflag_trac)
+
+!WARNING: when adding a threadprivate variable in this module
+!        do not forget to add it to the copyin clause when opening an OpenMP
+!        parallel section. e.g. in gcm before call leapfrog_loc 
+
+END MODULE logic_mod
Index: LMDZ5/branches/testing/libf/dyn3dpar/massbar_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/massbar_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/massbar_p.F	(revision 2641)
@@ -18,5 +18,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom.h"
 c
Index: LMDZ5/branches/testing/libf/dyn3dpar/massbarxy_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/massbarxy_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/massbarxy_p.F	(revision 2641)
@@ -17,5 +17,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom.h"
 c
Index: LMDZ5/branches/testing/libf/dyn3dpar/massdair_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/massdair_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/massdair_p.F	(revision 2641)
@@ -18,5 +18,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
 #include "comgeom.h"
 c
Index: LMDZ5/branches/testing/libf/dyn3dpar/nxgrarot_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/nxgrarot_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/nxgrarot_p.F	(revision 2641)
@@ -22,5 +22,4 @@
 #include "paramet.h"
 #include "comdissipn.h"
-#include "logic.h"
 c
       INTEGER klevel
Index: LMDZ5/branches/testing/libf/dyn3dpar/qminimum_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/qminimum_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/qminimum_p.F	(revision 2641)
@@ -8,5 +8,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
 c
       INTEGER nq
Index: LMDZ5/branches/testing/libf/dyn3dpar/sw_case_williamson91_6.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/sw_case_williamson91_6.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/sw_case_williamson91_6.F	(revision 2641)
@@ -26,4 +26,7 @@
 c
 c=======================================================================
+      USE comconst_mod, ONLY: cpp, omeg, rad
+      USE comvert_mod, ONLY: ap, bp, preff
+      
       IMPLICIT NONE
 c-----------------------------------------------------------------------
@@ -33,6 +36,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
-#include "comconst.h"
 #include "comgeom.h"
 #include "iniprint.h"
Index: LMDZ5/branches/testing/libf/dyn3dpar/temps.h
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/temps.h	(revision 2471)
+++ 	(revision )
@@ -1,27 +1,0 @@
-!
-! $Id$
-!
-!  ATTENTION!!!!: ce fichier include est compatible format fixe/format libre
-!                 veillez  n'utiliser que des ! pour les commentaires
-!                 et  bien positionner les & des lignes de continuation
-!                 (les placer en colonne 6 et en colonne 73)
-!
-!
-! jD_ref = jour julien de la date de reference (lancement de l'experience)
-! hD_ref = "heure" julienne de la date de reference
-!-----------------------------------------------------------------------
-! INCLUDE 'temps.h'
-
-      COMMON/temps/ dt, jD_ref, jH_ref, start_time,                     &
-     &             day_ini, day_end, annee_ref, day_ref,                &
-     &             itau_dyn, itau_phy, itaufin, calend
-
-
-      INTEGER   itaufin
-      INTEGER itau_dyn, itau_phy 
-      INTEGER day_ini, day_end, annee_ref, day_ref
-      REAL      dt, jD_ref, jH_ref, start_time
-      CHARACTER (len=10) :: calend
-
-!$OMP THREADPRIVATE(/temps/)
-!-----------------------------------------------------------------------
Index: LMDZ5/branches/testing/libf/dyn3dpar/temps_mod.F90
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/temps_mod.F90	(revision 2641)
+++ LMDZ5/branches/testing/libf/dyn3dpar/temps_mod.F90	(revision 2641)
@@ -0,0 +1,33 @@
+!
+! $Id$
+!
+MODULE temps_mod
+
+IMPLICIT NONE  
+
+  INTEGER   itaufin ! total number of dynamical steps for the run
+  INTEGER   itau_dyn
+  INTEGER   itau_phy
+  INTEGER   day_ini ! initial day # of simulation sequence
+  INTEGER   day_end ! final day # ; i.e. day # when this simulation ends
+  INTEGER   annee_ref
+  INTEGER   day_ref
+  REAL      dt ! (dynamics) time step (changes if doing Matsuno or LF step)
+  REAL      jD_ref ! reference julian day date (beginning of experiment)
+  REAL      jH_ref ! reference julian "hour" of reference julian date
+  REAL      start_time
+  CHARACTER (len=10) :: calend ! calendar type
+
+  ! Additionnal Mars stuff:
+  REAL hour_ini ! initial fraction of day of simulation sequence (0=<hour_ini<1)
+
+!$OMP THREADPRIVATE(dt,jD_ref,jH_ref,start_time,hour_ini,                        &
+!$OMP                day_ini,day_end,annee_ref,day_ref,itau_dyn,itau_phy,itaufin,&
+!$OMP                calend)        
+
+!WARNING: when adding a threadprivate variable in this module
+!        do not forget to add it to the copyin clause when opening an OpenMP
+!        parallel section. e.g. in gcm before call leapfrog_loc and/or
+!        possibly in iniphysiq
+
+END MODULE temps_mod
Index: LMDZ5/branches/testing/libf/dyn3dpar/top_bound_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/top_bound_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/top_bound_p.F	(revision 2641)
@@ -4,10 +4,12 @@
       SUBROUTINE top_bound_p(vcov,ucov,teta,masse,dt)
       USE parallel_lmdz
+      USE comconst_mod, ONLY: iflag_top_bound, mode_top_bound,
+     &                        tau_top_bound
+      USE comvert_mod, ONLY: presnivs, preff, scaleheight
+      
       IMPLICIT NONE
 c
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom2.h"
 
@@ -40,5 +42,5 @@
 ! NB: top_bound sponge is only called from leapfrog if ok_strato=.true.
 
-! sponge parameters: (loaded/set in conf_gcm.F ; stored in comconst.h)
+! sponge parameters: (loaded/set in conf_gcm.F ; stored in comconst_mod)
 !    iflag_top_bound=0 for no sponge
 !    iflag_top_bound=1 for sponge over 4 topmost layers
@@ -69,5 +71,5 @@
       REAL uzon(jjp1,llm),vzon(jjm,llm),tzon(jjp1,llm)
       
-      integer i	
+      integer i
       REAL,SAVE :: rdamp(llm) ! quenching coefficient
       real,save :: lambda(llm) ! inverse or quenching time scale (Hz)
Index: LMDZ5/branches/testing/libf/dyn3dpar/tourpot_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/tourpot_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/tourpot_p.F	(revision 2641)
@@ -23,5 +23,4 @@
 #include "paramet.h"
 #include "comgeom.h"
-#include "logic.h"
 
       REAL  rot( ip1jm,llm )
Index: LMDZ5/branches/testing/libf/dyn3dpar/vitvert_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/vitvert_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/vitvert_p.F	(revision 2641)
@@ -2,4 +2,6 @@
 c
       USE parallel_lmdz
+      USE comvert_mod, ONLY: bp
+      
       IMPLICIT NONE
 
@@ -28,5 +30,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comvert.h"
 
       REAL w(ip1jmp1,llm),convm(ip1jmp1,llm)
Index: LMDZ5/branches/testing/libf/dyn3dpar/vlsplt_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/vlsplt_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/vlsplt_p.F	(revision 2641)
@@ -25,7 +25,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 
 c
@@ -208,7 +205,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 c
 c
@@ -539,11 +533,9 @@
 c   --------------------------------------------------------------------
       USE parallel_lmdz
+      USE comconst_mod, ONLY: pi
       IMPLICIT NONE
 c
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 #include "comgeom.h"
 c
@@ -932,7 +924,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 c
 c
Index: LMDZ5/branches/testing/libf/dyn3dpar/vlspltgen_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/vlspltgen_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/vlspltgen_p.F	(revision 2641)
@@ -27,4 +27,5 @@
       USE VAMPIR
       USE infotrac, ONLY : nqtot
+      USE comconst_mod, ONLY: cpp
       IMPLICIT NONE
 
@@ -32,7 +33,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 
 c
@@ -105,11 +103,11 @@
 
         
-	ijb=ij_begin-iip1
-	ije=ij_end+iip1
-	if (pole_nord) ijb=ij_begin
-	if (pole_sud) ije=ij_end
-	
+        ijb=ij_begin-iip1
+        ije=ij_end+iip1
+        if (pole_nord) ijb=ij_begin
+        if (pole_sud) ije=ij_end
+        
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) 
-	DO l = 1, llm
+        DO l = 1, llm
          DO ij = ijb, ije
           tempe(ij) = teta(ij,l) * pk(ij,l) /cpp
@@ -191,17 +189,17 @@
 
         if(iadv(iq) == 0) then
-	
-	  cycle 
-	
-	else if (iadv(iq)==10) then
+        
+          cycle 
+        
+        else if (iadv(iq)==10) then
 
 #ifdef _ADV_HALO        
-	  call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
-     &	             ij_begin,ij_begin+2*iip1-1)
+          call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
+     &                     ij_begin,ij_begin+2*iip1-1)
           call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
      &               ij_end-2*iip1+1,ij_end)
 #else
-	  call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
-     &	             ij_begin,ij_end)
+          call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
+     &                     ij_begin,ij_end)
 #endif
 
@@ -215,5 +213,5 @@
           call VTe(VTHallo)
 c$OMP END MASTER
-	else if (iadv(iq)==14) then
+        else if (iadv(iq)==14) then
 
 #ifdef _ADV_HALO           
@@ -239,6 +237,6 @@
 c$OMP END MASTER 
         else
-	
-	  stop 'vlspltgen_p : schema non parallelise'
+        
+          stop 'vlspltgen_p : schema non parallelise'
       
         endif
@@ -261,8 +259,8 @@
 
         if(iadv(iq) == 0) then
-	
-	  cycle 
-	
-	else if (iadv(iq)==10) then
+        
+          cycle 
+        
+        else if (iadv(iq)==10) then
 
 #ifdef _ADV_HALLO
@@ -270,5 +268,5 @@
      &               ij_begin+2*iip1,ij_end-2*iip1)
 #endif        
-	else if (iadv(iq)==14) then
+        else if (iadv(iq)==14) then
 #ifdef _ADV_HALLO
           call vlxqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,qsat,
@@ -276,6 +274,6 @@
 #endif    
         else
-	
-	  stop 'vlspltgen_p : schema non parallelise'
+        
+          stop 'vlspltgen_p : schema non parallelise'
       
         endif
@@ -301,18 +299,18 @@
 
         if(iadv(iq) == 0) then
-	
-	  cycle 
-	
-	else if (iadv(iq)==10) then
+        
+          cycle 
+        
+        else if (iadv(iq)==10) then
         
           call vly_p(zq(1,1,iq),pente_max,zm(1,1,iq),mv)
   
-	else if (iadv(iq)==14) then
+        else if (iadv(iq)==14) then
       
           call vlyqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mv,qsat)
  
         else
-	
-	  stop 'vlspltgen_p : schema non parallelise'
+        
+          stop 'vlspltgen_p : schema non parallelise'
       
         endif
@@ -324,8 +322,8 @@
 
         if(iadv(iq) == 0) then 
-	  
-	  cycle 
-	
-	else if (iadv(iq)==10 .or. iadv(iq)==14 ) then
+          
+          cycle 
+        
+        else if (iadv(iq)==10 .or. iadv(iq)==14 ) then
 
 c$OMP BARRIER        
@@ -350,9 +348,9 @@
 c$OMP MASTER
           call VTe(VTHallo)
-c$OMP END MASTER	
-c$OMP BARRIER
-        else
-	
-	  stop 'vlspltgen_p : schema non parallelise'
+c$OMP END MASTER        
+c$OMP BARRIER
+        else
+        
+          stop 'vlspltgen_p : schema non parallelise'
       
         endif
@@ -369,5 +367,5 @@
 c$OMP MASTER
       call VTe(VTHallo)
-c$OMP END MASTER	
+c$OMP END MASTER        
 
 c$OMP BARRIER
@@ -375,8 +373,8 @@
 
         if(iadv(iq) == 0) then
-	  
-	  cycle 
-	
-	else if (iadv(iq)==10 .or. iadv(iq)==14 ) then
+          
+          cycle 
+        
+        else if (iadv(iq)==10 .or. iadv(iq)==14 ) then
 c$OMP BARRIER        
 
@@ -388,6 +386,6 @@
 c$OMP BARRIER        
         else
-	
-	  stop 'vlspltgen_p : schema non parallelise'
+        
+          stop 'vlspltgen_p : schema non parallelise'
       
         endif
@@ -414,18 +412,18 @@
 
         if(iadv(iq) == 0) then
-	
-	  cycle 
-	
-	else if (iadv(iq)==10) then
+        
+          cycle 
+        
+        else if (iadv(iq)==10) then
         
           call vly_p(zq(1,1,iq),pente_max,zm(1,1,iq),mv)
   
-	else if (iadv(iq)==14) then
+        else if (iadv(iq)==14) then
       
           call vlyqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mv,qsat)
  
         else
-	
-	  stop 'vlspltgen_p : schema non parallelise'
+        
+          stop 'vlspltgen_p : schema non parallelise'
       
         endif
@@ -436,13 +434,13 @@
 
         if(iadv(iq) == 0) then 
-	  
-	  cycle 
-	
-	else if (iadv(iq)==10) then
+          
+          cycle 
+        
+        else if (iadv(iq)==10) then
         
           call vlx_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,
      &               ij_begin,ij_end)
   
-	else if (iadv(iq)==14) then
+        else if (iadv(iq)==14) then
       
           call vlxqs_p(zq(1,1,iq),pente_max,zm(1,1,iq),mu,qsat,
@@ -450,5 +448,5 @@
  
         else
-	
+        
           stop 'vlspltgen_p : schema non parallelise'
       
@@ -469,6 +467,6 @@
            DO ij=ijb,ije
 c             print *,'zq-->',ij,l,iq,zq(ij,l,iq)
-c	     print *,'q-->',ij,l,iq,q(ij,l,iq)
-	     q(ij,l,iq)=zq(ij,l,iq)
+c             print *,'q-->',ij,l,iq,q(ij,l,iq)
+             q(ij,l,iq)=zq(ij,l,iq)
            ENDDO
         ENDDO
Index: LMDZ5/branches/testing/libf/dyn3dpar/vlspltqs_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/vlspltqs_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/vlspltqs_p.F	(revision 2641)
@@ -25,4 +25,5 @@
       USE mod_hallo
       USE VAMPIR
+      USE comconst_mod, ONLY: cpp
       IMPLICIT NONE
 
@@ -30,7 +31,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 
 c
@@ -236,7 +234,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 c
 c
@@ -584,11 +579,9 @@
 c   --------------------------------------------------------------------
       USE parallel_lmdz
+      USE comconst_mod, ONLY: pi
       IMPLICIT NONE
 c
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
-#include "comvert.h"
-#include "comconst.h"
 #include "comgeom.h"
 c
Index: LMDZ5/branches/testing/libf/dyn3dpar/writedynav_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/writedynav_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/writedynav_p.F	(revision 2641)
@@ -12,4 +12,7 @@
       USE misc_mod
       USE infotrac
+      USE comconst_mod, ONLY: cpp
+      USE temps_mod, ONLY: itau_dyn
+      
       implicit none
 
@@ -42,12 +45,6 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
 #include "description.h"
-#include "serre.h"
 #include "iniprint.h"
 
Index: LMDZ5/branches/testing/libf/dyn3dpar/writehist_p.F
===================================================================
--- LMDZ5/branches/testing/libf/dyn3dpar/writehist_p.F	(revision 2471)
+++ LMDZ5/branches/testing/libf/dyn3dpar/writehist_p.F	(revision 2641)
@@ -12,4 +12,6 @@
       USE misc_mod
       USE infotrac
+      USE temps_mod, ONLY: itau_dyn
+      
       implicit none
 
@@ -43,12 +45,6 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "comconst.h"
-#include "comvert.h"
 #include "comgeom.h"
-#include "temps.h"
-#include "ener.h"
-#include "logic.h"
 #include "description.h"
-#include "serre.h"
 #include "iniprint.h"
 
