Index: /LMDZ5/trunk/libf/dyn3d/advect.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/advect.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/advect.F	(revision 2603)
@@ -5,4 +5,5 @@
 
       USE comconst_mod, ONLY: daysec
+      USE logic_mod, ONLY: conser
       
       IMPLICIT NONE
@@ -29,5 +30,4 @@
       include "paramet.h"
       include "comgeom.h"
-      include "logic.h"
       include "ener.h"
 
Index: /LMDZ5/trunk/libf/dyn3d/advtrac.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/advtrac.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/advtrac.F90	(revision 2603)
@@ -19,5 +19,4 @@
   include "comdissip.h"
   include "comgeom2.h"
-  include "logic.h"
   include "ener.h"
   include "description.h"
Index: /LMDZ5/trunk/libf/dyn3d/conf_gcm.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/conf_gcm.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/conf_gcm.F90	(revision 2603)
@@ -16,4 +16,7 @@
                           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
@@ -37,5 +40,4 @@
   include "dimensions.h"
   include "paramet.h"
-  include "logic.h"
   include "comdissnew.h"
   include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3d/dteta1.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/dteta1.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/dteta1.F	(revision 2603)
@@ -21,7 +21,6 @@
 
 
-#include "dimensions.h"
-#include "paramet.h"
-#include "logic.h"
+      include "dimensions.h"
+      include "paramet.h"
 
       REAL teta( ip1jmp1,llm ),pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
Index: /LMDZ5/trunk/libf/dyn3d/dynetat0.f90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/dynetat0.f90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/dynetat0.f90	(revision 2603)
@@ -13,4 +13,5 @@
   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_ini, day_ref, itau_dyn, start_time
@@ -22,5 +23,4 @@
   include "ener.h"
   include "description.h"
-  include "logic.h"
   include "iniprint.h"
 !===============================================================================
Index: /LMDZ5/trunk/libf/dyn3d/dynredem.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/dynredem.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/dynredem.F90	(revision 2603)
@@ -14,4 +14,5 @@
                               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
@@ -23,5 +24,4 @@
   include "comgeom2.h"
   include "ener.h"
-  include "logic.h"
   include "description.h"
   include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3d/gcm.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/gcm.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/gcm.F90	(revision 2603)
@@ -26,4 +26,5 @@
                      itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end
   USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, r, rad
+  USE logic_mod, ONLY: ecripar, iflag_phys, read_start
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -72,5 +73,4 @@
   include "comdissnew.h"
   include "comgeom.h"
-  include "logic.h"
   include "ener.h"
   include "description.h"
Index: /LMDZ5/trunk/libf/dyn3d/iniacademic.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/iniacademic.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/iniacademic.F90	(revision 2603)
@@ -17,4 +17,5 @@
   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
@@ -35,5 +36,4 @@
   include "ener.h"
   include "iniprint.h"
-  include "logic.h"
 
   !   Arguments:
Index: /LMDZ5/trunk/libf/dyn3d/integrd.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/integrd.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/integrd.F	(revision 2603)
@@ -9,4 +9,5 @@
       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
@@ -33,5 +34,4 @@
       include "paramet.h"
       include "comgeom.h"
-      include "logic.h"
       include "iniprint.h"
 
Index: /LMDZ5/trunk/libf/dyn3d/leapfrog.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/leapfrog.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/leapfrog.F	(revision 2603)
@@ -22,4 +22,6 @@
       USE comvert_mod, ONLY: ap,bp,pressure_exner,presnivs
       USE comconst_mod, ONLY: cpp, dtphys, dtvr, pi, ihf
+      USE logic_mod, ONLY: iflag_phys,ok_guide,forward,leapf,apphys,
+     &                     statcl,conser,apdiss,purmats,ok_strato
       USE temps_mod, ONLY: jD_ref,jH_ref,itaufin,day_ini,day_ref,
      &                        start_time,dt
@@ -62,5 +64,4 @@
       include "comdissnew.h"
       include "comgeom.h"
-      include "logic.h"
       include "ener.h"
       include "description.h"
Index: DZ5/trunk/libf/dyn3d/logic.h
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/logic.h	(revision 2602)
+++ 	(revision )
@@ -1,26 +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
-!-----------------------------------------------------------------------
Index: /LMDZ5/trunk/libf/dyn3d/logic_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/logic_mod.F90	(revision 2603)
+++ /LMDZ5/trunk/libf/dyn3d/logic_mod.F90	(revision 2603)
@@ -0,0 +1,35 @@
+!
+! $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
+
+END MODULE logic_mod
Index: /LMDZ5/trunk/libf/dyn3d/vlsplt.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/vlsplt.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/vlsplt.F	(revision 2603)
@@ -23,5 +23,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 
 c
@@ -155,5 +154,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "iniprint.h"
 c
@@ -529,5 +527,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
 c
@@ -890,5 +887,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 c
 c
Index: /LMDZ5/trunk/libf/dyn3d/vlspltqs.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d/vlspltqs.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d/vlspltqs.F	(revision 2603)
@@ -30,5 +30,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 
 c
@@ -195,5 +194,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 c
 c
@@ -565,5 +563,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
 c
Index: /LMDZ5/trunk/libf/dyn3d_common/adaptdt.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/adaptdt.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/adaptdt.F	(revision 2603)
@@ -12,5 +12,4 @@
       include "comdissip.h"
       include "comgeom2.h"
-      include "logic.h"
       include "ener.h"
       include "description.h"
Index: /LMDZ5/trunk/libf/dyn3d_common/advn.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/advn.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/advn.F	(revision 2603)
@@ -19,5 +19,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
       include "iniprint.h"
@@ -484,5 +483,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "iniprint.h"
 c
Index: /LMDZ5/trunk/libf/dyn3d_common/bernoui.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/bernoui.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/bernoui.F	(revision 2603)
@@ -25,7 +25,6 @@
 c   -------------
 c
-#include "dimensions.h"
-#include "paramet.h"
-#include "logic.h"
+      include "dimensions.h"
+      include "paramet.h"
 c
 c   Arguments:
Index: /LMDZ5/trunk/libf/dyn3d_common/convmas.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/convmas.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/convmas.F90	(revision 2603)
@@ -9,5 +9,4 @@
   include "paramet.h"
   include "comgeom.h"
-  include "logic.h"
 !===============================================================================
 ! Arguments:
Index: /LMDZ5/trunk/libf/dyn3d_common/disvert.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/disvert.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/disvert.F90	(revision 2603)
@@ -12,4 +12,5 @@
   USE comvert_mod, ONLY: ap, bp, nivsigs, nivsig, dpres, presnivs, &
                          pa, preff, scaleheight
+  USE logic_mod, ONLY: ok_strato
 
   IMPLICIT NONE
@@ -18,5 +19,4 @@
   include "paramet.h"
   include "iniprint.h"
-  include "logic.h"
 
 !-------------------------------------------------------------------------------
Index: /LMDZ5/trunk/libf/dyn3d_common/disvert_noterre.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/disvert_noterre.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/disvert_noterre.F	(revision 2603)
@@ -15,4 +15,5 @@
      &                       nivsig,nivsigs,pa,preff,scaleheight
       USE comconst_mod, ONLY: kappa
+      USE logic_mod, ONLY: hybrid
 
       IMPLICIT NONE
@@ -20,5 +21,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "iniprint.h"
 c
Index: /LMDZ5/trunk/libf/dyn3d_common/divgrad.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/divgrad.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/divgrad.F	(revision 2603)
@@ -20,9 +20,8 @@
 c   -------------
 c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "comdissipn.h"
-#include "logic.h"
+      include "dimensions.h"
+      include "paramet.h"
+      include "comgeom.h"
+      include "comdissipn.h"
 c
       INTEGER klevel
Index: /LMDZ5/trunk/libf/dyn3d_common/gradiv.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/gradiv.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/gradiv.F	(revision 2603)
@@ -19,8 +19,7 @@
       IMPLICIT NONE
 c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comdissipn.h"
-#include "logic.h"
+      include "dimensions.h"
+      include "paramet.h"
+      include "comdissipn.h"
 
       INTEGER klevel
Index: /LMDZ5/trunk/libf/dyn3d_common/inidissip.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/inidissip.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/inidissip.F90	(revision 2603)
@@ -20,5 +20,4 @@
   include "paramet.h"
   include "comdissipn.h"
-  include "logic.h"
   include "iniprint.h"
 
Index: /LMDZ5/trunk/libf/dyn3d_common/inigeom.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/inigeom.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/inigeom.F	(revision 2603)
@@ -19,4 +19,5 @@
       use fyhyp_m, only: fyhyp
       USE comconst_mod, ONLY: pi, g, omeg, rad
+      USE logic_mod, ONLY: fxyhypb, ysinus
       USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy,
      &		alphax,alphay,taux,tauy,transx,transy,pxo,pyo
@@ -26,5 +27,4 @@
       include "paramet.h"
       include "comgeom2.h"
-      include "logic.h"
       include "comdissnew.h"
 
Index: /LMDZ5/trunk/libf/dyn3d_common/initdynav.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/initdynav.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/initdynav.F90	(revision 2603)
@@ -40,5 +40,4 @@
   include "comgeom.h"
   include "ener.h"
-  include "logic.h"
   include "description.h"
   include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3d_common/initfluxsto.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/initfluxsto.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/initfluxsto.F	(revision 2603)
@@ -46,5 +46,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3d_common/inithist.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/inithist.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/inithist.F	(revision 2603)
@@ -45,5 +45,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3d_common/interpre.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/interpre.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/interpre.F	(revision 2603)
@@ -15,5 +15,4 @@
       include "comdissip.h"
       include "comgeom2.h"
-      include "logic.h"
       include "ener.h"
       include "description.h"
Index: /LMDZ5/trunk/libf/dyn3d_common/limx.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/limx.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/limx.F	(revision 2603)
@@ -17,5 +17,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
 c
Index: /LMDZ5/trunk/libf/dyn3d_common/limy.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/limy.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/limy.F	(revision 2603)
@@ -19,5 +19,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
 c
Index: /LMDZ5/trunk/libf/dyn3d_common/limz.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/limz.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/limz.F	(revision 2603)
@@ -17,5 +17,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
 c
Index: /LMDZ5/trunk/libf/dyn3d_common/nxgrarot.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/nxgrarot.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/nxgrarot.F	(revision 2603)
@@ -19,8 +19,7 @@
 c
 c
-#include "dimensions.h"
-#include "paramet.h"
-#include "comdissipn.h"
-#include "logic.h"
+      include "dimensions.h"
+      include "paramet.h"
+      include "comdissipn.h"
 c
       INTEGER klevel
Index: /LMDZ5/trunk/libf/dyn3d_common/sortvarc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/sortvarc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/sortvarc.F	(revision 2603)
@@ -8,4 +8,6 @@
       USE control_mod, ONLY: resetvarc 
       USE comconst_mod, ONLY: dtvr, daysec, g, rad, omeg
+      USE logic_mod, ONLY: read_start
+      
       IMPLICIT NONE
 
@@ -30,5 +32,4 @@
       INCLUDE "comgeom.h"
       INCLUDE "ener.h"
-      INCLUDE "logic.h"
       INCLUDE "iniprint.h"
 
Index: /LMDZ5/trunk/libf/dyn3d_common/tourpot.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/tourpot.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/tourpot.F90	(revision 2603)
@@ -9,5 +9,4 @@
   include "paramet.h"
   include "comgeom.h"
-  include "logic.h"
 !===============================================================================
 ! Arguments:
Index: /LMDZ5/trunk/libf/dyn3d_common/traceurpole.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/traceurpole.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/traceurpole.F	(revision 2603)
@@ -10,5 +10,4 @@
       include "comdissip.h"
       include "comgeom2.h"
-      include "logic.h"
       include "ener.h"
       include "description.h"
Index: /LMDZ5/trunk/libf/dyn3d_common/writedynav.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/writedynav.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/writedynav.F90	(revision 2603)
@@ -35,5 +35,4 @@
   include "comgeom.h"
   include "ener.h"
-  include "logic.h"
   include "description.h"
   include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3d_common/writehist.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3d_common/writehist.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3d_common/writehist.F	(revision 2603)
@@ -39,5 +39,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/advect_new_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/advect_new_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/advect_new_loc.F	(revision 2603)
@@ -8,4 +8,6 @@
       USE advect_new_mod
       USE comconst_mod, ONLY: daysec
+      USE logic_mod, ONLY: conser
+      
       IMPLICIT NONE
 c=======================================================================
@@ -31,5 +33,4 @@
       include "paramet.h"
       include "comgeom.h"
-      include "logic.h"
       include "ener.h"
 
Index: /LMDZ5/trunk/libf/dyn3dmem/advtrac_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/advtrac_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/advtrac_loc.F	(revision 2603)
@@ -34,5 +34,4 @@
       include "comdissip.h"
       include "comgeom2.h"
-      include "logic.h"
       include "ener.h"
       include "description.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/bernoui_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/bernoui_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/bernoui_loc.F	(revision 2603)
@@ -24,7 +24,6 @@
 c   -------------
 c
-#include "dimensions.h"
-#include "paramet.h"
-#include "logic.h"
+      include "dimensions.h"
+      include "paramet.h"
 c
 c   Arguments:
Index: /LMDZ5/trunk/libf/dyn3dmem/call_calfis_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/call_calfis_mod.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/call_calfis_mod.F90	(revision 2603)
@@ -83,9 +83,9 @@
   USE write_field
   USE comconst_mod, ONLY: dtphys
+  USE logic_mod, ONLY: leapf, forward, ok_strato
   USE comvert_mod, ONLY: ap, bp, pressure_exner
   USE temps_mod, ONLY: day_ini, day_ref, jd_ref, jh_ref, start_time
   
   IMPLICIT NONE
-    INCLUDE "logic.h"
     INCLUDE "iniprint.h"
 
Index: /LMDZ5/trunk/libf/dyn3dmem/conf_gcm.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/conf_gcm.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/conf_gcm.F90	(revision 2603)
@@ -20,4 +20,7 @@
                           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
@@ -41,5 +44,4 @@
   include "dimensions.h"
   include "paramet.h"
-  include "logic.h"
   include "comdissnew.h"
   include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/convmas1_loc.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/convmas1_loc.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/convmas1_loc.F90	(revision 2603)
@@ -12,5 +12,4 @@
   include "paramet.h"
   include "comgeom.h"
-  include "logic.h"
 !===============================================================================
 ! Arguments:
Index: /LMDZ5/trunk/libf/dyn3dmem/convmas2_loc.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/convmas2_loc.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/convmas2_loc.F90	(revision 2603)
@@ -11,5 +11,4 @@
   include "paramet.h"
   include "comgeom.h"
-  include "logic.h"
 !===============================================================================
 ! Arguments:
Index: /LMDZ5/trunk/libf/dyn3dmem/convmas_loc.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/convmas_loc.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/convmas_loc.F90	(revision 2603)
@@ -11,5 +11,4 @@
   include "paramet.h"
   include "comgeom.h"
-  include "logic.h"
 !===============================================================================
 ! Arguments:
Index: /LMDZ5/trunk/libf/dyn3dmem/dteta1_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/dteta1_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/dteta1_loc.F	(revision 2603)
@@ -21,7 +21,6 @@
 
 
-#include "dimensions.h"
-#include "paramet.h"
-#include "logic.h"
+      include "dimensions.h"
+      include "paramet.h"
 
       REAL teta( ijb_u:ije_u,llm )
Index: /LMDZ5/trunk/libf/dyn3dmem/dynetat0_loc.f90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/dynetat0_loc.f90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/dynetat0_loc.f90	(revision 2603)
@@ -15,4 +15,5 @@
   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, &
@@ -25,5 +26,4 @@
   include "ener.h"
   include "description.h"
-  include "logic.h"
   include "iniprint.h"
 !===============================================================================
Index: /LMDZ5/trunk/libf/dyn3dmem/dynredem_loc.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/dynredem_loc.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/dynredem_loc.F90	(revision 2603)
@@ -16,4 +16,5 @@
                          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
@@ -25,5 +26,4 @@
   include "comgeom.h"
   include "ener.h"
-  include "logic.h"
   include "description.h"
   include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/gcm.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/gcm.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/gcm.F90	(revision 2603)
@@ -22,4 +22,5 @@
 #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, &
@@ -61,5 +62,4 @@
   include "comdissnew.h"
   include "comgeom.h"
-  include "logic.h"
   include "ener.h"
   include "description.h"
@@ -453,8 +453,13 @@
 
   !!$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logici/,/logicl/)
-  !$OMP PARALLEL DEFAULT(SHARED) COPYIN(/logici/,/logicl/) &
+  !$OMP PARALLEL DEFAULT(SHARED) &
   !     Copy all threadprivate variables in temps_mod
   !$OMP COPYIN(dt,jD_ref,jH_ref,start_time,hour_ini,day_ini,day_end) &
-  !$OMP COPYIN(annee_ref,day_ref,itau_dyn,itau_phy,itaufin,calend)
+  !$OMP COPYIN(annee_ref,day_ref,itau_dyn,itau_phy,itaufin,calend) &
+  !     Copy all threadprivate variables from logic_mod
+  !$OMP COPYIN(purmats,forward,leapf,apphys,statcl,conser,apdiss,apdelq) &
+  !$OMP COPYIN(saison,ecripar,fxyhypb,ysinus,read_start,ok_guide) &
+  !$OMP COPYIN(ok_strato,ok_gradsfile,ok_limit,ok_etat0) &
+  !$OMP COPYIN(iflag_phys,iflag_trac)
   CALL leapfrog_loc(ucov,vcov,teta,ps,masse,phis,q,time_0)
   !$OMP END PARALLEL
Index: /LMDZ5/trunk/libf/dyn3dmem/iniacademic_loc.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/iniacademic_loc.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/iniacademic_loc.F90	(revision 2603)
@@ -19,4 +19,5 @@
   USE Write_Field
   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
@@ -37,5 +38,4 @@
   include "ener.h"
   include "iniprint.h"
-  include "logic.h"
 
   !   Arguments:
Index: /LMDZ5/trunk/libf/dyn3dmem/initdynav_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/initdynav_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/initdynav_loc.F	(revision 2603)
@@ -49,5 +49,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/initfluxsto_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/initfluxsto_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/initfluxsto_p.F	(revision 2603)
@@ -50,5 +50,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/inithist_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/inithist_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/inithist_loc.F	(revision 2603)
@@ -48,5 +48,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/integrd_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/integrd_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/integrd_loc.F	(revision 2603)
@@ -13,4 +13,5 @@
       USE infotrac, ONLY: ok_iso_verif ! ajout CRisi
       USE comconst_mod, ONLY: pi
+      USE logic_mod, ONLY: leapf
       USE comvert_mod, ONLY: ap, bp
       USE temps_mod, ONLY: dt
@@ -37,5 +38,4 @@
       include "paramet.h"
       include "comgeom.h"
-      include "logic.h"
       include "iniprint.h"
 
Index: /LMDZ5/trunk/libf/dyn3dmem/leapfrog_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/leapfrog_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/leapfrog_loc.F	(revision 2603)
@@ -34,4 +34,6 @@
        USE comconst_mod, ONLY: cpp, dtvr, ihf
        USE comvert_mod, ONLY: ap, bp, pressure_exner
+       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
@@ -74,5 +76,4 @@
       include "comdissnew.h"
       include "comgeom.h"
-      include "logic.h"
       include "ener.h"
       include "description.h"
Index: DZ5/trunk/libf/dyn3dmem/logic.h
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/logic.h	(revision 2602)
+++ 	(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/trunk/libf/dyn3dmem/logic_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/logic_mod.F90	(revision 2603)
+++ /LMDZ5/trunk/libf/dyn3dmem/logic_mod.F90	(revision 2603)
@@ -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/trunk/libf/dyn3dmem/tourpot_loc.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/tourpot_loc.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/tourpot_loc.F90	(revision 2603)
@@ -11,5 +11,4 @@
   include "paramet.h"
   include "comgeom.h"
-  include "logic.h"
 !===============================================================================
 ! Arguments:
Index: /LMDZ5/trunk/libf/dyn3dmem/vlsplt_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/vlsplt_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/vlsplt_loc.F	(revision 2603)
@@ -19,5 +19,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 c
 c
@@ -420,5 +419,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
 c
@@ -874,5 +872,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 c
 c
Index: /LMDZ5/trunk/libf/dyn3dmem/vlspltgen_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/vlspltgen_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/vlspltgen_loc.F	(revision 2603)
@@ -37,5 +37,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 
 c
Index: /LMDZ5/trunk/libf/dyn3dmem/vlspltqs_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/vlspltqs_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/vlspltqs_loc.F	(revision 2603)
@@ -14,5 +14,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
 c
 c
@@ -423,5 +422,4 @@
       include "dimensions.h"
       include "paramet.h"
-      include "logic.h"
       include "comgeom.h"
 c
Index: /LMDZ5/trunk/libf/dyn3dmem/writedynav_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/writedynav_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/writedynav_loc.F	(revision 2603)
@@ -48,5 +48,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dmem/writehist_loc.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dmem/writehist_loc.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dmem/writehist_loc.F	(revision 2603)
@@ -48,5 +48,4 @@
       include "comgeom.h"
       include "ener.h"
-      include "logic.h"
       include "description.h"
       include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/advect_new_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/advect_new_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/advect_new_p.F	(revision 2603)
@@ -7,4 +7,6 @@
       USE write_field_p
       USE comconst_mod, ONLY: daysec
+      USE logic_mod, ONLY: conser
+      
       IMPLICIT NONE
 c=======================================================================
@@ -30,5 +32,4 @@
 #include "paramet.h"
 #include "comgeom.h"
-#include "logic.h"
 #include "ener.h"
 
@@ -116,5 +117,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
          
@@ -249,6 +250,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
@@ -265,6 +266,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      
@@ -275,6 +276,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/trunk/libf/dyn3dpar/advect_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/advect_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/advect_p.F	(revision 2603)
@@ -6,4 +6,6 @@
       USE write_field_p
       USE comconst_mod, ONLY: daysec
+      USE logic_mod, ONLY: conser
+      
       IMPLICIT NONE
 c=======================================================================
@@ -29,5 +31,4 @@
 #include "paramet.h"
 #include "comgeom.h"
-#include "logic.h"
 #include "ener.h"
 
Index: /LMDZ5/trunk/libf/dyn3dpar/advtrac_p.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/advtrac_p.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/advtrac_p.F90	(revision 2603)
@@ -26,5 +26,4 @@
   include "comdissip.h"
   include "comgeom2.h"
-  include "logic.h"
   include "ener.h"
   include "description.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/bernoui_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/bernoui_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/bernoui_p.F	(revision 2603)
@@ -25,5 +25,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 c
 c   Arguments:
Index: /LMDZ5/trunk/libf/dyn3dpar/conf_gcm.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/conf_gcm.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/conf_gcm.F90	(revision 2603)
@@ -19,4 +19,7 @@
                           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
@@ -40,5 +43,4 @@
   include "dimensions.h"
   include "paramet.h"
-  include "logic.h"
   include "comdissnew.h"
   include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/convmas1_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/convmas1_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/convmas1_p.F	(revision 2603)
@@ -32,5 +32,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm )
Index: /LMDZ5/trunk/libf/dyn3dpar/convmas2_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/convmas2_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/convmas2_p.F	(revision 2603)
@@ -32,5 +32,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm )
Index: /LMDZ5/trunk/libf/dyn3dpar/convmas_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/convmas_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/convmas_p.F	(revision 2603)
@@ -32,5 +32,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm )
Index: /LMDZ5/trunk/libf/dyn3dpar/divgrad_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/divgrad_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/divgrad_p.F	(revision 2603)
@@ -23,5 +23,4 @@
 #include "comgeom.h"
 #include "comdissipn.h"
-#include "logic.h"
 c
       INTEGER klevel
Index: /LMDZ5/trunk/libf/dyn3dpar/dteta1_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/dteta1_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/dteta1_p.F	(revision 2603)
@@ -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/trunk/libf/dyn3dpar/dynetat0.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/dynetat0.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/dynetat0.F	(revision 2603)
@@ -12,5 +12,5 @@
       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,
@@ -40,5 +40,4 @@
 #include "netcdf.inc"
 #include "description.h"
-#include "logic.h"
 #include "iniprint.h"
 
Index: /LMDZ5/trunk/libf/dyn3dpar/dynredem.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/dynredem.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/dynredem.F	(revision 2603)
@@ -12,4 +12,5 @@
      &                        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
@@ -27,5 +28,4 @@
 #include "comgeom2.h"
 #include "ener.h"
-#include "logic.h"
 #include "netcdf.inc"
 #include "description.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/dynredem_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/dynredem_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/dynredem_p.F	(revision 2603)
@@ -13,4 +13,5 @@
      &                        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
@@ -28,5 +29,4 @@
 #include "comgeom2.h"
 #include "ener.h"
-#include "logic.h"
 #include "netcdf.inc"
 #include "description.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/gcm.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/gcm.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/gcm.F	(revision 2603)
@@ -33,4 +33,5 @@
 #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,
@@ -72,5 +73,4 @@
 #include "comdissnew.h"
 #include "comgeom.h"
-#include "logic.h"
 #include "ener.h"
 #include "description.h"
@@ -501,8 +501,13 @@
 
 !c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logici/,/logicl/)
-c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/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/trunk/libf/dyn3dpar/gradiv_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/gradiv_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/gradiv_p.F	(revision 2603)
@@ -21,5 +21,4 @@
 #include "paramet.h"
 #include "comdissipn.h"
-#include "logic.h"
 
       INTEGER klevel
Index: /LMDZ5/trunk/libf/dyn3dpar/iniacademic.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/iniacademic.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/iniacademic.F90	(revision 2603)
@@ -17,4 +17,5 @@
   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
@@ -35,5 +36,4 @@
   include "ener.h"
   include "iniprint.h"
-  include "logic.h"
 
   !   Arguments:
Index: /LMDZ5/trunk/libf/dyn3dpar/initdynav_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/initdynav_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/initdynav_p.F	(revision 2603)
@@ -48,5 +48,4 @@
 #include "comgeom.h"
 #include "ener.h"
-#include "logic.h"
 #include "description.h"
 #include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/initfluxsto_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/initfluxsto_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/initfluxsto_p.F	(revision 2603)
@@ -50,5 +50,4 @@
 #include "comgeom.h"
 #include "ener.h"
-#include "logic.h"
 #include "description.h"
 #include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/inithist_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/inithist_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/inithist_p.F	(revision 2603)
@@ -50,5 +50,4 @@
 #include "comgeom.h"
 #include "ener.h"
-#include "logic.h"
 #include "description.h"
 #include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/integrd_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/integrd_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/integrd_p.F	(revision 2603)
@@ -8,4 +8,5 @@
       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
@@ -32,5 +33,4 @@
 #include "paramet.h"
 #include "comgeom.h"
-#include "logic.h"
 #include "iniprint.h"
 
Index: /LMDZ5/trunk/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/leapfrog_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/leapfrog_p.F	(revision 2603)
@@ -30,4 +30,6 @@
        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
@@ -70,5 +72,4 @@
 #include "comdissnew.h"
 #include "comgeom.h"
-#include "logic.h"
 #include "ener.h"
 #include "description.h"
Index: DZ5/trunk/libf/dyn3dpar/logic.h
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/logic.h	(revision 2602)
+++ 	(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/trunk/libf/dyn3dpar/logic_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/logic_mod.F90	(revision 2603)
+++ /LMDZ5/trunk/libf/dyn3dpar/logic_mod.F90	(revision 2603)
@@ -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/trunk/libf/dyn3dpar/nxgrarot_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/nxgrarot_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/nxgrarot_p.F	(revision 2603)
@@ -22,5 +22,4 @@
 #include "paramet.h"
 #include "comdissipn.h"
-#include "logic.h"
 c
       INTEGER klevel
Index: /LMDZ5/trunk/libf/dyn3dpar/tourpot_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/tourpot_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/tourpot_p.F	(revision 2603)
@@ -23,5 +23,4 @@
 #include "paramet.h"
 #include "comgeom.h"
-#include "logic.h"
 
       REAL  rot( ip1jm,llm )
Index: /LMDZ5/trunk/libf/dyn3dpar/vlsplt_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/vlsplt_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/vlsplt_p.F	(revision 2603)
@@ -25,5 +25,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 
 c
@@ -206,5 +205,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 c
 c
@@ -540,5 +538,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 #include "comgeom.h"
 c
@@ -927,5 +924,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 c
 c
Index: /LMDZ5/trunk/libf/dyn3dpar/vlspltgen_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/vlspltgen_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/vlspltgen_p.F	(revision 2603)
@@ -33,5 +33,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 
 c
Index: /LMDZ5/trunk/libf/dyn3dpar/vlspltqs_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/vlspltqs_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/vlspltqs_p.F	(revision 2603)
@@ -31,5 +31,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 
 c
@@ -235,5 +234,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 c
 c
@@ -586,5 +584,4 @@
 #include "dimensions.h"
 #include "paramet.h"
-#include "logic.h"
 #include "comgeom.h"
 c
Index: /LMDZ5/trunk/libf/dyn3dpar/writedynav_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/writedynav_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/writedynav_p.F	(revision 2603)
@@ -47,5 +47,4 @@
 #include "comgeom.h"
 #include "ener.h"
-#include "logic.h"
 #include "description.h"
 #include "iniprint.h"
Index: /LMDZ5/trunk/libf/dyn3dpar/writehist_p.F
===================================================================
--- /LMDZ5/trunk/libf/dyn3dpar/writehist_p.F	(revision 2602)
+++ /LMDZ5/trunk/libf/dyn3dpar/writehist_p.F	(revision 2603)
@@ -47,5 +47,4 @@
 #include "comgeom.h"
 #include "ener.h"
-#include "logic.h"
 #include "description.h"
 #include "iniprint.h"
Index: /LMDZ5/trunk/libf/dynphy_lonlat/phylmd/ce0l.F90
===================================================================
--- /LMDZ5/trunk/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 2603)
@@ -36,4 +36,5 @@
   USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, kappa, omeg, r, rad, &
                           pi, jmp1
+  USE logic_mod, ONLY: iflag_phys, ok_etat0, ok_limit
   USE comvert_mod, ONLY: pa, preff, pressure_exner
   USE temps_mod, ONLY: calend, day_ini, dt
@@ -47,5 +48,4 @@
   include "comgeom2.h"
   include "iniprint.h"
-  include "logic.h"
   REAL               :: masque(iip1,jjp1)             !--- CONTINENTAL MASK
   REAL               :: phis  (iip1,jjp1)             !--- GROUND GEOPOTENTIAL
Index: /LMDZ5/trunk/libf/dynphy_lonlat/phylmd/limit_netcdf.F90
===================================================================
--- /LMDZ5/trunk/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/dynphy_lonlat/phylmd/limit_netcdf.F90	(revision 2603)
@@ -67,5 +67,5 @@
                   NF90_DEF_DIM, NF90_DEF_VAR, NF90_PUT_VAR, NF90_PUT_ATT,      &
                   NF90_NOERR,   NF90_NOWRITE, NF90_DOUBLE,  NF90_GLOBAL,       &
-		  NF90_CLOBBER, NF90_ENDDEF,  NF90_UNLIMITED, NF90_FLOAT
+                  NF90_CLOBBER, NF90_ENDDEF,  NF90_UNLIMITED, NF90_FLOAT
   USE inter_barxy_m,      ONLY: inter_barxy
   USE netcdf95,           ONLY: nf95_def_var, nf95_put_att, nf95_put_var
@@ -82,5 +82,4 @@
 !-------------------------------------------------------------------------------
 ! Local variables:
-  include "logic.h"
   include "comgeom2.h"
 
Index: /LMDZ5/trunk/libf/filtrez/filtreg_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/filtrez/filtreg_mod.F90	(revision 2602)
+++ /LMDZ5/trunk/libf/filtrez/filtreg_mod.F90	(revision 2603)
@@ -15,4 +15,5 @@
 #endif
   USE serre_mod, ONLY: alphax
+  USE logic_mod, ONLY: fxyhypb, ysinus
     !    ... H. Upadhyaya, O.Sharma   ...
     !
@@ -28,5 +29,4 @@
     include "comgeom.h"
     include "coefils.h"
-    include "logic.h"
 
     REAL  dlonu(iim),dlatu(jjm)
Index: /LMDZ5/trunk/libf/phylmd/dyn1d/1DUTILS.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/dyn1d/1DUTILS.h	(revision 2602)
+++ /LMDZ5/trunk/libf/phylmd/dyn1d/1DUTILS.h	(revision 2603)
@@ -436,4 +436,5 @@
       use control_mod
       USE comconst_mod, ONLY: im, jm, lllm
+      USE logic_mod, ONLY: fxyhypb, ysinus
       USE temps_mod, ONLY: annee_ref, day_ini, day_ref, itau_dyn
 
@@ -446,5 +447,4 @@
       include "dimensions.h"
 !!#include "control.h"
-      include "logic.h"
       include "netcdf.inc"
 
@@ -580,4 +580,5 @@
       use control_mod
       USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad
+      USE logic_mod, ONLY: fxyhypb, ysinus
       USE temps_mod, ONLY: annee_ref,day_end,day_ref,itau_dyn,itaufin
 
@@ -590,5 +591,4 @@
       include "dimensions.h"
 !!#include "control.h"
-      include "logic.h"
       include "netcdf.inc"
 
Index: DZ5/trunk/libf/phylmd/dyn1d/logic.h
===================================================================
--- /LMDZ5/trunk/libf/phylmd/dyn1d/logic.h	(revision 2602)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../dyn3d/logic.h
Index: /LMDZ5/trunk/libf/phylmd/dyn1d/logic_mod.F90
===================================================================
--- /LMDZ5/trunk/libf/phylmd/dyn1d/logic_mod.F90	(revision 2603)
+++ /LMDZ5/trunk/libf/phylmd/dyn1d/logic_mod.F90	(revision 2603)
@@ -0,0 +1,1 @@
+link ../../dyn3d/logic_mod.F90
