Index: trunk/LMDZ.GENERIC/README
===================================================================
--- trunk/LMDZ.GENERIC/README	(revision 1616)
+++ trunk/LMDZ.GENERIC/README	(revision 1621)
@@ -1262,2 +1262,15 @@
   should not return the maximum index (leads to out-of-bounds index use in 
   the caller).
+
+== 25/10/2016 == EM
+Updates for full physics/dynamics separation:
+- introduced module vertical_layers_mod.F90 in phy_common to store information
+  about the vertical grid to be used in the physics. Routines in the physics
+  should "use vertical_layers_mod" and not "use comvert_mod".
+- added nqtot to tracer_h.F90. Always "use tracer_h" in physics instead of
+  infotrac (which is in the dynamics).
+- removed some purely dynamics-related outputs (etot0, zoom parameters, etc.)
+  from diagfi.nc and stats.nc outputs as these informations are not available
+  in the physics.
+- added scalheight (atmospheric scale height) in comvert_mod.
+
Index: trunk/LMDZ.GENERIC/libf/dyn3d/comvert_mod.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/dyn3d/comvert_mod.F90	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/dyn3d/comvert_mod.F90	(revision 1621)
@@ -10,4 +10,5 @@
 ! Mars Ce qui suit vient de gcm
 REAL sig(llm+1),ds(llm),aps(llm),bps(llm),pseudoalt(llm)
+REAL scaleheight ! atmospheric scale height (km)
 
 END MODULE comvert_mod
Index: trunk/LMDZ.GENERIC/libf/dyn3d/disvert.F
===================================================================
--- trunk/LMDZ.GENERIC/libf/dyn3d/disvert.F	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/dyn3d/disvert.F	(revision 1621)
@@ -5,5 +5,5 @@
       USE callkeys_mod, ONLY: kastprof,pceil
       USE comvert_mod, ONLY: ap,bp,sig,nivsigs,nivsig,pa,preff,
-     .			aps,bps,presnivs,pseudoalt
+     .			aps,bps,presnivs,pseudoalt,scaleheight
 
 c    Auteur :  F. Forget Y. Wanherdrick, P. Levan
@@ -31,5 +31,5 @@
       INTEGER l,ll
       REAL snorm
-      REAL alpha,beta,gama,delta,deltaz,h,quoi,quand
+      REAL alpha,beta,gama,delta,deltaz,quoi,quand
       REAL zsig(llm)
       INTEGER np,ierr
@@ -108,5 +108,5 @@
          PRINT*,'****************************'
 
-         READ(99,*) h
+         READ(99,*) scaleheight
          do l=1,llm
             read(99,*) zsig(l)
@@ -117,5 +117,5 @@
          if(autozlevs)then
             open(91,file="z2sig.def",form='formatted')
-            read(91,*) h
+            read(91,*) scaleheight
             DO l=1,llm-2
                read(91,*) Hmax
@@ -126,11 +126,12 @@
             print*,'Auto-shifting h in disvert.F to:'
 !            h = Hmax / log(psurf/100.0)
-            h = Hmax / log(psurf/pceil)
-            print*,'h = ',h,' km'
+            scaleheight = Hmax / log(psurf/pceil)
+            print*,'h = ',scaleheight,' km'
         endif
        
         sig(1)=1
         do l=2,llm
-           sig(l) = 0.5 * ( exp(-zsig(l)/h) + exp(-zsig(l-1)/h) )
+           sig(l) = 0.5 * ( exp(-zsig(l)/scaleheight) + 
+     &                      exp(-zsig(l-1)/scaleheight) )
         end do
         sig(llm+1)=0
@@ -223,5 +224,5 @@
       DO l = 1, llm
        presnivs(l) = aps(l)+bps(l)*preff
-       pseudoalt(l) = -h*log(presnivs(l)/preff)
+       pseudoalt(l) = -scaleheight*log(presnivs(l)/preff)
       ENDDO
 
Index: trunk/LMDZ.GENERIC/libf/dynphy_lonlat/inigeomphy_mod.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 1621)
@@ -21,4 +21,7 @@
   USE mod_interface_dyn_phys, ONLY :  init_interface_dyn_phys
   USE nrtype, ONLY: pi
+  USE comvert_mod, ONLY: preff, ap, bp, aps, bps, presnivs, &
+                         scaleheight, pseudoalt
+  USE vertical_layers_mod, ONLY: init_vertical_layers
   IMPLICIT NONE
 
@@ -213,4 +216,8 @@
                      airefi,cufi,cvfi)
 
+  ! copy over preff , ap(), bp(), etc 
+  CALL init_vertical_layers(nlayer,preff,scaleheight, &
+                            ap,bp,aps,bps,presnivs,pseudoalt)
+
 !$OMP END PARALLEL
 
Index: trunk/LMDZ.GENERIC/libf/phy_common/vertical_layers_mod.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phy_common/vertical_layers_mod.F90	(revision 1621)
+++ trunk/LMDZ.GENERIC/libf/phy_common/vertical_layers_mod.F90	(revision 1621)
@@ -0,0 +1,56 @@
+! $Id: $
+
+MODULE vertical_layers_mod
+
+   REAL,SAVE             :: preff  ! reference surface pressure (Pa)
+   REAL,SAVE             :: scaleheight ! atmospheric reference scale height (km)
+   REAL,SAVE,ALLOCATABLE :: ap(:) ! hybrid (pressure contribution) coordinate 
+                                  ! at layer interfaces (Pa)
+   REAL,SAVE,ALLOCATABLE :: bp(:) ! hybrid (sigma contribution) coordinate 
+                                  ! at layer interfaces
+   REAL,SAVE,ALLOCATABLE :: aps(:) ! hybrid (pressure contribution) coordinate 
+                                   ! at mid-layer (Pa)
+   REAL,SAVE,ALLOCATABLE :: bps(:) ! hybrid (sigma contribution) coordinate 
+                                   ! at mid-layer
+   REAL,SAVE,ALLOCATABLE :: presnivs(:) ! reference pressure at mid-layer (Pa),
+                                        ! based on preff, ap and bp
+   REAL,SAVE,ALLOCATABLE :: pseudoalt(:) ! pseudo-altitude of model layers (km),
+                                         ! based on preff and scaleheight
+   
+!$OMP THREADPRIVATE(preff,scaleheight,ap,bp,aps,bps,presnivs,pseudoalt)
+
+
+CONTAINS
+
+  SUBROUTINE init_vertical_layers(nlayer,preff_,scaleheight_,ap_,bp_,&
+                                 aps_,bps_,presnivs_, pseudoalt_)
+    IMPLICIT NONE
+    INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
+    REAL,INTENT(IN)    :: preff_ ! reference surface pressure (Pa)
+    REAL,INTENT(IN)    :: scaleheight_ ! atmospheric scale height (km)
+    REAL,INTENT(IN)    :: ap_(nlayer+1) ! hybrid coordinate at interfaces
+    REAL,INTENT(IN)    :: bp_(nlayer+1) ! hybrid coordinate at interfaces
+    REAL,INTENT(IN)    :: aps_(nlayer) ! hybrid coordinate at mid-layer
+    REAL,INTENT(IN)    :: bps_(nlayer) ! hybrid coordinate at mid-layer
+    REAL,INTENT(IN)    :: presnivs_(nlayer) ! Appproximative pressure of atm. layers (Pa)
+    REAL,INTENT(IN)    :: pseudoalt_(nlayer) ! pseudo-altitude of atm. layers (km)
+  
+    ALLOCATE(ap(nlayer+1))
+    ALLOCATE(bp(nlayer+1))
+    ALLOCATE(aps(nlayer))
+    ALLOCATE(bps(nlayer))
+    ALLOCATE(presnivs(nlayer))
+    ALLOCATE(pseudoalt(nlayer))
+  
+    preff = preff_
+    scaleheight=scaleheight_
+    ap(:) = ap_(:)
+    bp(:) = bp_(:)
+    aps(:) = aps_(:)
+    bps(:) = bps_(:)
+    presnivs(:) = presnivs_(:)
+    pseudoalt(:) = pseudoalt_(:)
+
+  END SUBROUTINE init_vertical_layers
+
+END MODULE vertical_layers_mod
Index: trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/dyn1d/rcm1d.F	(revision 1621)
@@ -24,5 +24,7 @@
       use callkeys_mod, only: tracer,check_cpp_match,rings_shadow,
      &	                      specOLR,water,pceil,ok_slab_ocean
-      USE comvert_mod, ONLY: ap,bp,aps,bps,pa,preff
+      USE comvert_mod, ONLY: ap,bp,aps,bps,pa,preff, sig,
+     &                       presnivs,pseudoalt,scaleheight
+      USE vertical_layers_mod, ONLY: init_vertical_layers
       USE logic_mod, ONLY: hybrid,autozlevs
       use regular_lonlat_mod, only: init_regular_lonlat
@@ -502,4 +504,7 @@
      &                   (/0.,0.,0.,0./),(/0.,0.,0.,0./),
      &                   cell_area)
+! Ehouarn: init_vertial_layers called later (because disvert not called yet)
+!      call init_vertical_layers(nlayer,preff,scaleheight,
+!     &                      ap,bp,aps,bps,presnivs,pseudoalt)
       call init_dimphy(1,nlayer) ! Initialize dimphy module
       call ini_planete_mod(nlayer,preff,ap,bp)
@@ -734,4 +739,7 @@
 
       call disvert
+      ! now that disvert has been called, initialize module vertical_layers_mod
+      call init_vertical_layers(nlayer,preff,scaleheight,
+     &                      ap,bp,aps,bps,presnivs,pseudoalt)
 
          if(.not.autozlevs)then
Index: trunk/LMDZ.GENERIC/libf/phystd/inistats.F
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/inistats.F	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/inistats.F	(revision 1621)
@@ -3,6 +3,7 @@
       use statto_mod, only: istats,istime
       use mod_phys_lmdz_para, only : is_master
-      USE comvert_mod, ONLY: ap,bp,aps,bps,preff,pseudoalt,presnivs
-      USE comconst_mod, ONLY: pi
+      USE vertical_layers_mod, ONLY: ap,bp,aps,bps,preff,
+     &                               pseudoalt,presnivs
+      USE nrtype, ONLY: pi
       USE time_phylmdz_mod, ONLY: daysec,dtphys
       USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
Index: trunk/LMDZ.GENERIC/libf/phystd/initracer.F
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/initracer.F	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/initracer.F	(revision 1621)
@@ -46,4 +46,5 @@
 c-----------------------------------------------------------------------
 
+       nqtot=nq
        !! we allocate once for all arrays in common in tracer_h.F90
        !! (supposedly those are not used before call to initracer)
Index: trunk/LMDZ.GENERIC/libf/phystd/iniwrite.F
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/iniwrite.F	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/iniwrite.F	(revision 1621)
@@ -3,9 +3,9 @@
       use comsoil_h, only: mlayer, nsoilmx
       USE comcstfi_mod, only: g, mugaz, omeg, rad, rcp, pi 
-      USE comvert_mod, ONLY: ap,bp,aps,bps,pseudoalt
-      USE logic_mod, ONLY: fxyhypb,ysinus
-      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
+      USE vertical_layers_mod, ONLY: ap,bp,aps,bps,pseudoalt
+!      USE logic_mod, ONLY: fxyhypb,ysinus
+!      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
       USE time_phylmdz_mod, ONLY: daysec, dtphys
-      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+!      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
       USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
       USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
@@ -75,30 +75,30 @@
       tab_cntrl(10) = daysec
       tab_cntrl(11) = dtphys
-      tab_cntrl(12) = etot0
-      tab_cntrl(13) = ptot0
-      tab_cntrl(14) = ztot0
-      tab_cntrl(15) = stot0
-      tab_cntrl(16) = ang0
+!      tab_cntrl(12) = etot0
+!      tab_cntrl(13) = ptot0
+!      tab_cntrl(14) = ztot0
+!      tab_cntrl(15) = stot0
+!      tab_cntrl(16) = ang0
 c
 c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
 c         .....        parametres  pour le zoom          ......   
-      tab_cntrl(17)  = clon
-      tab_cntrl(18)  = clat
-      tab_cntrl(19)  = grossismx
-      tab_cntrl(20)  = grossismy
+!      tab_cntrl(17)  = clon
+!      tab_cntrl(18)  = clat
+!      tab_cntrl(19)  = grossismx
+!      tab_cntrl(20)  = grossismy
 c
 c     .....   ajout  le 6/05/97 et le 15/10/97  .......
 c
-      IF ( fxyhypb )   THEN
-        tab_cntrl(21) = 1.
-        tab_cntrl(22) = dzoomx
-        tab_cntrl(23) = dzoomy
-      ELSE
-        tab_cntrl(21) = 0.
-        tab_cntrl(22) = dzoomx
-        tab_cntrl(23) = dzoomy
-        tab_cntrl(24) = 0.
-        IF( ysinus )  tab_cntrl(24) = 1.
-      ENDIF
+!      IF ( fxyhypb )   THEN
+!        tab_cntrl(21) = 1.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!      ELSE
+!        tab_cntrl(21) = 0.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!        tab_cntrl(24) = 0.
+!        IF( ysinus )  tab_cntrl(24) = 1.
+!      ENDIF
 
 c    .........................................................
Index: trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specIR.F
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specIR.F	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specIR.F	(revision 1621)
@@ -5,7 +5,7 @@
       use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, pi
       use time_phylmdz_mod, only: daysec, dtphys
-      USE logic_mod, ONLY: fxyhypb,ysinus
-      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
-      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+!      USE logic_mod, ONLY: fxyhypb,ysinus
+!      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
+!      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
       USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
       USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
@@ -77,30 +77,30 @@
       tab_cntrl(10) = daysec
       tab_cntrl(11) = dtphys
-      tab_cntrl(12) = etot0
-      tab_cntrl(13) = ptot0
-      tab_cntrl(14) = ztot0
-      tab_cntrl(15) = stot0
-      tab_cntrl(16) = ang0
+!      tab_cntrl(12) = etot0
+!      tab_cntrl(13) = ptot0
+!      tab_cntrl(14) = ztot0
+!      tab_cntrl(15) = stot0
+!      tab_cntrl(16) = ang0
 c
 c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
 c         .....        parametres  pour le zoom          ......   
-      tab_cntrl(17)  = clon
-      tab_cntrl(18)  = clat
-      tab_cntrl(19)  = grossismx
-      tab_cntrl(20)  = grossismy
+!      tab_cntrl(17)  = clon
+!      tab_cntrl(18)  = clat
+!      tab_cntrl(19)  = grossismx
+!      tab_cntrl(20)  = grossismy
 c
 c     .....   ajout  le 6/05/97 et le 15/10/97  .......
 c
-      IF ( fxyhypb )   THEN
-        tab_cntrl(21) = 1.
-        tab_cntrl(22) = dzoomx
-        tab_cntrl(23) = dzoomy
-      ELSE
-        tab_cntrl(21) = 0.
-        tab_cntrl(22) = dzoomx
-        tab_cntrl(23) = dzoomy
-        tab_cntrl(24) = 0.
-        IF( ysinus )  tab_cntrl(24) = 1.
-      ENDIF
+!      IF ( fxyhypb )   THEN
+!        tab_cntrl(21) = 1.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!      ELSE
+!        tab_cntrl(21) = 0.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!        tab_cntrl(24) = 0.
+!        IF( ysinus )  tab_cntrl(24) = 1.
+!      ENDIF
 
 c    .........................................................
Index: trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specVI.F
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specVI.F	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/iniwrite_specVI.F	(revision 1621)
@@ -5,7 +5,7 @@
       use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, pi
       use time_phylmdz_mod, only: daysec, dtphys
-      USE logic_mod, ONLY: fxyhypb,ysinus
-      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
-      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+!      USE logic_mod, ONLY: fxyhypb,ysinus
+!      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
+!      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
       USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
       USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
@@ -77,30 +77,30 @@
       tab_cntrl(10) = daysec
       tab_cntrl(11) = dtphys
-      tab_cntrl(12) = etot0
-      tab_cntrl(13) = ptot0
-      tab_cntrl(14) = ztot0
-      tab_cntrl(15) = stot0
-      tab_cntrl(16) = ang0
+!      tab_cntrl(12) = etot0
+!      tab_cntrl(13) = ptot0
+!      tab_cntrl(14) = ztot0
+!      tab_cntrl(15) = stot0
+!      tab_cntrl(16) = ang0
 c
 c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
 c         .....        parametres  pour le zoom          ......   
-      tab_cntrl(17)  = clon
-      tab_cntrl(18)  = clat
-      tab_cntrl(19)  = grossismx
-      tab_cntrl(20)  = grossismy
+!      tab_cntrl(17)  = clon
+!      tab_cntrl(18)  = clat
+!      tab_cntrl(19)  = grossismx
+!      tab_cntrl(20)  = grossismy
 c
 c     .....   ajout  le 6/05/97 et le 15/10/97  .......
 c
-      IF ( fxyhypb )   THEN
-        tab_cntrl(21) = 1.
-        tab_cntrl(22) = dzoomx
-        tab_cntrl(23) = dzoomy
-      ELSE
-        tab_cntrl(21) = 0.
-        tab_cntrl(22) = dzoomx
-        tab_cntrl(23) = dzoomy
-        tab_cntrl(24) = 0.
-        IF( ysinus )  tab_cntrl(24) = 1.
-      ENDIF
+!      IF ( fxyhypb )   THEN
+!        tab_cntrl(21) = 1.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!      ELSE
+!        tab_cntrl(21) = 0.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!        tab_cntrl(24) = 0.
+!        IF( ysinus )  tab_cntrl(24) = 1.
+!      ENDIF
 
 c    .........................................................
Index: trunk/LMDZ.GENERIC/libf/phystd/iostart.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/iostart.F90	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/iostart.F90	(revision 1621)
@@ -467,5 +467,5 @@
   USE mod_grid_phy_lmdz, only: klon_glo
   USE dimphy, only: klev, klevp1
-  USE infotrac, only: nqtot
+  USE tracer_h, only: nqtot
   USE comsoil_h, only: nsoilmx
   USE slab_ice_h, only: noceanmx
Index: trunk/LMDZ.GENERIC/libf/phystd/phyetat0.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/phyetat0.F90	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/phyetat0.F90	(revision 1621)
@@ -5,5 +5,5 @@
 
 
-  USE infotrac, ONLY: tname
+  USE tracer_h, ONLY: noms
   USE surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe
   use iostart, only: nid_start, open_startphy, close_startphy, &
@@ -375,5 +375,5 @@
 if (nq.ge.1) then
   do iq=1,nq
-    txt=tname(iq)
+    txt=noms(iq)
     
     !! There was a bug here. MT2015.
Index: trunk/LMDZ.GENERIC/libf/phystd/phyredem.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/phyredem.F90	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/phyredem.F90	(revision 1621)
@@ -141,5 +141,5 @@
   use iostart, only : open_restartphy, close_restartphy, & 
                       put_var, put_field
-  use infotrac, only: tname
+  use tracer_h, only: noms
   use slab_ice_h, only: noceanmx
   use callkeys_mod, only: ok_slab_ocean
@@ -207,5 +207,5 @@
   if (nq>0) then
     do iq=1,nq
-      call put_field(tname(iq),"tracer on surface",qsurf(:,iq))
+      call put_field(noms(iq),"tracer on surface",qsurf(:,iq))
     enddo
   endif ! of if (nq>0)
Index: trunk/LMDZ.GENERIC/libf/phystd/tracer_h.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/tracer_h.F90	(revision 1616)
+++ trunk/LMDZ.GENERIC/libf/phystd/tracer_h.F90	(revision 1621)
@@ -3,4 +3,8 @@
 
        implicit none
+
+! nqtot : total number of tracers
+       INTEGER, SAVE :: nqtot
+!$OMP THREADPRIVATE(nqtot)
 
        character*20, DIMENSION(:), ALLOCATABLE :: noms   ! name of the tracer
