Index: /trunk/LMDZ.MARS/README
===================================================================
--- /trunk/LMDZ.MARS/README	(revision 1035)
+++ /trunk/LMDZ.MARS/README	(revision 1036)
@@ -1893,5 +1893,5 @@
 - Checked: exact same results than before modifications
 
-== 09/11/2013 == EM
+== 11/09/2013 == EM
 - Bug fix in vdifc.F: in some cases, some elements of pdqsdif() were not given
   any value. In all cases, it is safer to start with clean initialization of
@@ -1899,2 +1899,18 @@
 - Bug fix in concentration.F: error in cpi() and aki() indexes led to
   wrong computation of atmospheric conductivity and specific heat.
+
+== 11/09/2013 == EM
+- IMPORTANT CHANGE: Implemented dynamic tracers. It is no longer necessary to
+  compile the model with the '-t #' option, number of tracers is simply read
+  from tracer.def file (as before).
+  Adapted makegcm_* scripts (and co.) accordingly.
+  Technical aspects of the switch to dynamic tracers are:
+  - advtrac.h (in dyn3d) removed and replaced by module infotrac.F
+  - tracer.h (in phymars) removed and replaced by module tracer_mod.F90 (which
+    contains nqmx, the number of tracers, etc. and can be used anywhere in the
+    physics).
+- Included some side cleanups: removed unused files (in dyn3d) anldoppler2.F,
+  anl_mcdstats.F and anl_stats-diag.F, and all the unecessary dimensions.*
+  files in grid/dimension.
+- Checked that changes are clean and that GCM yields identical results (in
+  debug mode) to previous svn version.
Index: /trunk/LMDZ.MARS/libf/aeronomars/calchim.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/calchim.F90	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/calchim.F90	(revision 1036)
@@ -1,7 +1,16 @@
-      subroutine calchim(ptimestep,pplay,pplev,pt,pdt,dist_sol,mu0,         &
+      subroutine calchim(nq,                                                &
+                         ptimestep,pplay,pplev,pt,pdt,dist_sol,mu0,         &
                          zzlev,zzlay,zday,pq,pdq,dqchim,dqschim,dqcloud,    &
                          dqscloud,tauref,co2ice,                            &
                          pu,pdu,pv,pdv,surfdust,surfice)
 
+      use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_o1d, igcm_o2, &
+                            igcm_o3, igcm_h, igcm_h2, igcm_oh, igcm_ho2,  &
+                            igcm_h2o2, igcm_ch4, igcm_n2, igcm_h2o_vap,   &
+                            igcm_no, igcm_n, igcm_no2, igcm_n2d,          &
+                            igcm_o2plus, igcm_co2plus, igcm_oplus,        &
+                            igcm_coplus, igcm_cplus, igcm_nplus,          &
+                            igcm_noplus, igcm_n2plus, igcm_hplus,         &
+                            igcm_hco2plus, igcm_elec, mmol
       implicit none
 
@@ -56,5 +65,5 @@
 #include "dimphys.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -63,4 +72,5 @@
 !     input:
 
+      integer,intent(in) :: nq ! number of tracers
       real :: ptimestep
       real :: pplay(ngridmx,nlayermx)    ! pressure at the middle of the layers
@@ -76,6 +86,6 @@
       real :: dist_sol                   ! distance of the sun (AU)
       real :: mu0(ngridmx)               ! cos of solar zenith angle (=1 when sun at zenith)
-      real :: pq(ngridmx,nlayermx,nqmx)  ! tracers mass mixing ratio
-      real :: pdq(ngridmx,nlayermx,nqmx) ! previous tendencies
+      real :: pq(ngridmx,nlayermx,nq)  ! tracers mass mixing ratio
+      real :: pdq(ngridmx,nlayermx,nq) ! previous tendencies
       real :: zday                       ! date (time since Ls=0, in martian days)
       real :: tauref(ngridmx)            ! optical depth at 7 hPa
@@ -86,13 +96,13 @@
 !     output:
 
-      real :: dqchim(ngridmx,nlayermx,nqmx) ! tendencies on pq due to chemistry
-      real :: dqschim(ngridmx,nqmx)         ! tendencies on qsurf 
-      real :: dqcloud(ngridmx,nlayermx,nqmx)! tendencies on pq due to condensation
-      real :: dqscloud(ngridmx,nqmx)        ! tendencies on qsurf 
+      real :: dqchim(ngridmx,nlayermx,nq) ! tendencies on pq due to chemistry
+      real :: dqschim(ngridmx,nq)         ! tendencies on qsurf 
+      real :: dqcloud(ngridmx,nlayermx,nq)! tendencies on pq due to condensation
+      real :: dqscloud(ngridmx,nq)        ! tendencies on qsurf 
 
 !     local variables:
 
       integer,save :: nbq                   ! number of tracers used in the chemistry
-      integer,save :: niq(nqmx)             ! array storing the indexes of the tracers
+      integer,allocatable,save :: niq(:)    ! array storing the indexes of the tracers
       integer :: iloc(1)            ! index of major species
       integer :: ig,l,i,iq,iqmax
@@ -133,5 +143,5 @@
 
       real    :: latvl1, lonvl1
-      real    :: zq(ngridmx,nlayermx,nqmx) ! pq+pdq*ptimestep before chemistry
+      real    :: zq(ngridmx,nlayermx,nq) ! pq+pdq*ptimestep before chemistry
                                            ! new mole fraction after
       real    :: zt(ngridmx,nlayermx)      ! temperature
@@ -149,5 +159,5 @@
       real :: ztemp(nlayermx)        !  Temperature (K)
       real :: zlocal(nlayermx)       !  Altitude (km)
-      real :: zycol(nlayermx,nqmx)   !  Composition (mole fractions)
+      real :: zycol(nlayermx,nq)   !  Composition (mole fractions)
       real :: szacol                 !  Solar zenith angle
       real :: surfice1d(nlayermx)    !  Ice surface area (cm2/cm3)
@@ -172,4 +182,5 @@
          end if
          ! find index of chemical tracers to use
+         allocate(niq(nq))
          ! Listed here are all tracers that can go into photochemistry
          nbq = 0 ! to count number of tracers
Index: /trunk/LMDZ.MARS/libf/aeronomars/chemthermos.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/chemthermos.F90	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/chemthermos.F90	(revision 1036)
@@ -2,4 +2,12 @@
            zpress,zlocal,zenit,ptimestep,zday)
 
+      use tracer_mod, only: nqmx, igcm_co2, igcm_co, igcm_o, igcm_o1d,  &
+                            igcm_o2, igcm_h, igcm_h2, igcm_oh, igcm_ho2,&
+                            igcm_h2o2, igcm_h2o_vap, igcm_o3, igcm_n2,  &
+                            igcm_n, igcm_no, igcm_no2, igcm_n2d,        &
+                            igcm_co2plus, igcm_o2plus, igcm_coplus,     &
+                            igcm_cplus, igcm_nplus, igcm_noplus,        &
+                            igcm_n2plus, igcm_hplus, igcm_hco2plus,     &
+                            igcm_elec, igcm_oplus
       IMPLICIT NONE
 !=======================================================================
@@ -28,5 +36,5 @@
 #include "param.h"
 #include "param_v4.h"
-#include"tracer.h"
+!#include"tracer.h"
 !-----------------------------------------------------------------------
 !    Input/Output
Index: /trunk/LMDZ.MARS/libf/aeronomars/concentrations.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/concentrations.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/concentrations.F	(revision 1036)
@@ -1,4 +1,12 @@
-      SUBROUTINE concentrations(pplay,pt,pdt,pq,pdq,ptimestep)
+      SUBROUTINE concentrations(nq,pplay,pt,pdt,pq,pdq,ptimestep)
                                              
+      use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_o1d,
+     &                      igcm_o2, igcm_o3, igcm_h, igcm_h2,
+     &                      igcm_oh, igcm_ho2, igcm_n2, igcm_ar,
+     &                      igcm_h2o_vap, igcm_n, igcm_no, igcm_no2,
+     &                      igcm_n2d, igcm_co2plus, igcm_oplus,
+     &                      igcm_o2plus, igcm_coplus, igcm_cplus,
+     &                      igcm_nplus, igcm_noplus, igcm_n2plus,
+     &                      igcm_hplus, igcm_hco2plus, mmol
       implicit none
 
@@ -22,25 +30,27 @@
 #include "comdiurn.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "conc.h"
 
 !     input/output
 
-      real pplay(ngridmx,nlayermx)
-      real pt(ngridmx,nlayermx)
-      real pdt(ngridmx,nlayermx)
-      real pq(ngridmx,nlayermx,nqmx)
-      real pdq(ngridmx,nlayermx,nqmx)
-      real ptimestep
+      integer,intent(in) :: nq ! number of tracers
+      real,intent(in) :: pplay(ngridmx,nlayermx)
+      real,intent(in) :: pt(ngridmx,nlayermx)
+      real,intent(in) :: pdt(ngridmx,nlayermx)
+      real,intent(in) :: pq(ngridmx,nlayermx,nq)
+      real,intent(in) :: pdq(ngridmx,nlayermx,nq)
+      real,intent(in) :: ptimestep
 
 !     local variables
 
       integer       :: i, l, ig, iq
-      integer, save :: nbq, niq(nqmx)
-      real          :: ni(nqmx), ntot
-      real          :: zq(ngridmx, nlayermx, nqmx)
+      integer, save :: nbq
+      integer,allocatable,save :: niq(:)
+      real          :: ni(nq), ntot
+      real          :: zq(ngridmx, nlayermx, nq)
       real          :: zt(ngridmx, nlayermx)
-      real, save    :: aki(nqmx)
-      real, save    :: cpi(nqmx)
+      real,allocatable,save    :: aki(:)
+      real,allocatable,save    :: cpi(:)
 
       logical, save :: firstcall = .true.
@@ -48,4 +58,8 @@
       if (firstcall) then
 
+         ! allocate local saved arrays:
+         allocate(aki(nq))
+         allocate(cpi(nq))
+         allocate(niq(nq))
 !        find index of chemical tracers to use
 !        initialize thermal conductivity and specific heat coefficients
@@ -217,5 +231,9 @@
          endif
          
-            
+         ! tell the world about it:
+         write(*,*) "concentrations: firstcall, nbq=",nbq
+         write(*,*) "  niq(1:nbq)=",niq(1:nbq)
+         write(*,*) "  aki(1:nbq)=",aki(1:nbq)
+         write(*,*) "  cpi(1:nbq)=",cpi(1:nbq)
 
          firstcall = .false.
Index: /trunk/LMDZ.MARS/libf/aeronomars/deposition.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/deposition.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/deposition.F	(revision 1036)
@@ -7,4 +7,5 @@
 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
 c
+      use tracer_mod, only: nqmx
       implicit none
 c
Index: /trunk/LMDZ.MARS/libf/aeronomars/euvheat.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/euvheat.F90	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/euvheat.F90	(revision 1036)
@@ -2,4 +2,8 @@
            mu0,ptimestep,ptime,zday,pq,pdq,pdteuv)
 
+      use tracer_mod, only: nqmx, igcm_co2, igcm_co, igcm_o, igcm_o1d,  &
+                            igcm_o2, igcm_h, igcm_h2, igcm_oh, igcm_ho2,&
+                            igcm_h2o2, igcm_h2o_vap, igcm_o3, igcm_n2,  &
+                            igcm_n, igcm_no, igcm_no2, igcm_n2d, mmol
       IMPLICIT NONE
 !=======================================================================
@@ -34,5 +38,5 @@
 #include "param_v4.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "conc.h"
 !-----------------------------------------------------------------------
Index: /trunk/LMDZ.MARS/libf/aeronomars/inichim_newstart.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/inichim_newstart.F90	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/inichim_newstart.F90	(revision 1036)
@@ -1,4 +1,5 @@
-      subroutine inichim_newstart(pq, qsurf, ps, flagh2o, flagthermo)
-
+      subroutine inichim_newstart(nq, pq, qsurf, ps, flagh2o, flagthermo)
+
+      use tracer_mod
       implicit none
 
@@ -23,6 +24,6 @@
 !  ----------
 !
-!  pq(iip1,jjp1,llm,nqmx)  Advected fields, ie chemical species here
-!  qsurf(ngridmx,nqmx)     Amount of tracer on the surface (kg/m2)
+!  pq(iip1,jjp1,llm,nq)  Advected fields, ie chemical species here
+!  qsurf(ngridmx,nq)     Amount of tracer on the surface (kg/m2)
 !  ps(iip1,jjp1)           Surface pressure (Pa)
 !  flagh2o                 flag for initialisation of h2o (1: yes / 0: no)
@@ -34,5 +35,5 @@
 #include "dimphys.h"
 #include "paramet.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "comvert.h"
 #include "callkeys.h"
@@ -41,4 +42,5 @@
 ! inputs :
 
+      integer,intent(in) :: nq                    ! number of tracers
       real,intent(in) :: ps(iip1,jjp1)            ! surface pressure in the gcm (Pa)   
       integer,intent(in) :: flagh2o               ! flag for h2o initialisation
@@ -47,6 +49,6 @@
 ! outputs :
 
-      real,intent(out) :: pq(iip1,jjp1,llm,nqmx)  ! advected fields, ie chemical species
-      real,intent(out) :: qsurf(ngridmx,nqmx)     ! surface values (kg/m2) of tracers
+      real,intent(out) :: pq(iip1,jjp1,llm,nq)  ! advected fields, ie chemical species
+      real,intent(out) :: qsurf(ngridmx,nq)     ! surface values (kg/m2) of tracers
 
 ! local :
@@ -73,5 +75,6 @@
 
 ! 1.1 initialize tracer indexes to zero:
-
+      nqmx=nq ! initialize value of nqmx
+      
       do iq = 1,nqmx
         igcm_dustbin(iq) = 0
Index: /trunk/LMDZ.MARS/libf/aeronomars/jthermcalc.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/jthermcalc.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/jthermcalc.F	(revision 1036)
@@ -1026,4 +1026,8 @@
 c**********************************************************************
 
+      use tracer_mod, only: igcm_o, igcm_co2, igcm_o2, igcm_h2,
+     &                      igcm_h2o_vap, igcm_h2o2, igcm_co, igcm_h,
+     &                      igcm_o3, igcm_n2, igcm_n, igcm_no, igcm_no2,
+     &                      mmol
       implicit none
 
@@ -1032,5 +1036,5 @@
       include "dimensions.h"
       include "dimphys.h"
-      include "tracer.h"
+!      include "tracer.h"
       include 'param.h'
       include 'param_v4.h'
Index: /trunk/LMDZ.MARS/libf/aeronomars/moldiff.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/moldiff.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/moldiff.F	(revision 1036)
@@ -2,5 +2,8 @@
      &                   zzlay,pdteuv,pdtconduc,pdqdiff)
 
-
+      use tracer_mod, only: nqmx, igcm_co2, igcm_co, igcm_o, igcm_o1d,
+     &                      igcm_o2, igcm_o3, igcm_h, igcm_h2, igcm_oh,
+     &                      igcm_ho2, igcm_h2o2, igcm_n2, igcm_ar,
+     &                      igcm_h2o_vap, mmol
       implicit none
 
@@ -11,5 +14,5 @@
 #include "comdiurn.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "conc.h"
 
Index: /trunk/LMDZ.MARS/libf/aeronomars/moldiff_red.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/moldiff_red.F90	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/moldiff_red.F90	(revision 1036)
@@ -1,3 +1,5 @@
 subroutine moldiff_red(pplay,pplev,pt,pdt,pq,pdq,ptimestep,zzlay,pdteuv,pdtconduc,pdqdiff)
+
+use tracer_mod, only: nqmx, noms, mmol
 
 implicit none
@@ -9,5 +11,5 @@
 #include "comdiurn.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "conc.h"
 #include "diffusion.h"
@@ -904,6 +906,7 @@
 
 	SUBROUTINE QMNEW(Q1,DQ,Q2,dtime,nl,nq,gc,ig)
+        use tracer_mod, only: nqmx
         IMPLICIT NONE
-#include "dimensions.h"
+!#include "dimensions.h"
 
         INTEGER,INTENT(IN) :: nl,nq
@@ -939,6 +942,7 @@
 
 	SUBROUTINE MMOY(massemoy,mmol,qq,gc,nl,nq)
-	IMPLICIT NONE
-#include "dimensions.h"
+	use tracer_mod, only: nqmx
+        IMPLICIT NONE
+!#include "dimensions.h"
 
 	INTEGER :: nl,nq,l
@@ -1023,6 +1027,7 @@
      & qq,mmol,gc,Praf,Traf,Qraf,Mraf,Zraf,                             &
      & Nraf,Nrafk,Rraf,Rrafk,il,nl,nq,nlx,ig)
+        use tracer_mod, only: nqmx
 	IMPLICIT NONE
-#include "dimensions.h"
+!#include "dimensions.h"
 	
 	INTEGER :: nl,nq,il,l,i,iq,nlx,iz,ig
@@ -1364,6 +1369,7 @@
 	SUBROUTINE GCMGRID_P(Z,P,Q,T,Nk,Rk,qq,qnew,tt,tnew,             &
      &    pp,M,gc,nl,nq,nlx,ig)
-	IMPLICIT NONE
-#include "dimensions.h"
+	use tracer_mod, only: nqmx
+        IMPLICIT NONE
+!#include "dimensions.h"
 	INTEGER :: nl,nq,nlx,il,nn,iP,ig,compteur
 	INTEGER,DIMENSION(1) :: indP
@@ -1465,6 +1471,7 @@
 	SUBROUTINE GCMGRID_P2(Z,P,Q,T,Nk,Rk,qq,qnew,tt,tnew             &
      &   ,pp,M,gc,nl,nq,nlx,facM,ig)
+        use tracer_mod, only: nqmx
         IMPLICIT NONE
-#include "dimensions.h"
+!#include "dimensions.h"
         INTEGER :: nl,nq,nlx,il,nn,iP,ig,compteur
         INTEGER,DIMENSION(1) :: indP
Index: /trunk/LMDZ.MARS/libf/aeronomars/moldiffcoeff.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/moldiffcoeff.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/moldiffcoeff.F	(revision 1036)
@@ -1,3 +1,8 @@
       subroutine moldiffcoeff(dij)
+
+      use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_o1d,
+     &                      igcm_o2, igcm_o3, igcm_h, igcm_h2, igcm_oh,
+     &                      igcm_ho2, igcm_h2o2, igcm_n2, igcm_ar,
+     &                      igcm_h2o_vap, mmol
 
        IMPLICIT NONE
@@ -16,5 +21,5 @@
 #include "comdiurn.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "conc.h"
 
Index: /trunk/LMDZ.MARS/libf/aeronomars/moldiffcoeff_red.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/moldiffcoeff_red.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/moldiffcoeff_red.F	(revision 1036)
@@ -1,4 +1,5 @@
       subroutine moldiffcoeff_red(dij,indic,gcmind,ncompdiff2)
 
+       use tracer_mod, only: nqmx, noms, mmol
        IMPLICIT NONE
 c=======================================================================
@@ -16,5 +17,5 @@
 #include "comdiurn.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "conc.h"
 #include "diffusion.h"
Index: /trunk/LMDZ.MARS/libf/aeronomars/perosat.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/perosat.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/perosat.F	(revision 1036)
@@ -2,4 +2,5 @@
      $                   pplev, pplay, zt,
      &                   zy, pdqcloud, pdqscloud)
+      use tracer_mod, only: nqmx, igcm_h2o2, mmol
       IMPLICIT NONE
 
@@ -14,5 +15,5 @@
 c
 c     WARNING : H2O2 mixing ratio is assumed to be q(igcm_h2o2)   
-c               index igcm_h2o2 is known from tracer.h 
+c               index igcm_h2o2 is known from tracer_mod
 c=======================================================================
 
@@ -25,5 +26,5 @@
 #include "comcstfi.h"
 #include "chimiedata.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "conc.h"
 c
Index: /trunk/LMDZ.MARS/libf/aeronomars/photochemistry.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/photochemistry.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/photochemistry.F	(revision 1036)
@@ -14,4 +14,5 @@
      $                  surfice1d, jo3, tau)
 c
+      use tracer_mod, only: nqmx
       implicit none
 c
@@ -20,5 +21,5 @@
 #include "chimiedata.h" 
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 c
 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
@@ -1152,4 +1153,8 @@
 c*****************************************************************
 c
+      use tracer_mod, only: nqmx, igcm_co2, igcm_co, igcm_o, igcm_o1d,
+     &                      igcm_o2, igcm_o3, igcm_h, igcm_h2, igcm_oh,
+     &                      igcm_ho2, igcm_h2o2, igcm_n2, igcm_h2o_vap,
+     &                      igcm_ch4
       implicit none
 c
@@ -1157,5 +1162,5 @@
 #include "dimphys.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 c
 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
@@ -1250,4 +1255,8 @@
 c*****************************************************************
 c
+      use tracer_mod, only: nqmx, igcm_co2, igcm_co, igcm_o, igcm_o1d,
+     &                      igcm_o2, igcm_o3, igcm_h, igcm_h2, igcm_oh,
+     &                      igcm_ho2, igcm_h2o2, igcm_n2, igcm_h2o_vap,
+     &                      igcm_ch4
       implicit none
 c
@@ -1255,5 +1264,5 @@
 #include "dimphys.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 c
 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
Index: /trunk/LMDZ.MARS/libf/aeronomars/surfacearea.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/surfacearea.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/surfacearea.F	(revision 1036)
@@ -5,4 +5,6 @@
      $                       surfdust, surfice)
 
+      use tracer_mod, only: nuice_sed, igcm_dust_number,
+     &                      igcm_ccn_number, varian, ccn_factor
       implicit none
 
@@ -19,5 +21,5 @@
 #include "comcstfi.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "dimradmars.h"
 #include "chimiedata.h"
Index: /trunk/LMDZ.MARS/libf/aeronomars/thermosphere.F
===================================================================
--- /trunk/LMDZ.MARS/libf/aeronomars/thermosphere.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/aeronomars/thermosphere.F	(revision 1036)
@@ -4,4 +4,5 @@
      $     zdteuv,zdtconduc,zdumolvis,zdvmolvis,zdqmoldiff)
 
+      use tracer_mod, only: nqmx ! number of advecter tracers
       implicit none
 
Index: unk/LMDZ.MARS/libf/dyn3d/advtrac.h
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/advtrac.h	(revision 1035)
+++ 	(revision )
@@ -1,7 +1,0 @@
-!
-! Tracers in the dynamics (E.M, oct.2008)
-!
-      COMMON/advtr/iadv,tnom
-      INTEGER :: iadv(nqmx)           ! tracer advection scheme number
-      CHARACTER (len=20) :: tnom(nqmx) ! tracer name
-      ! NB: tnom length should be compatible with noms() in physics ...
Index: unk/LMDZ.MARS/libf/dyn3d/anl_mcdstats.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/anl_mcdstats.F	(revision 1035)
+++ 	(revision )
@@ -1,1375 +1,0 @@
-      PROGRAM anldiag_nc
-      IMPLICIT NONE
-c======================================================================
-c
-c
-c Program designed to read output files from the MARS gcm
-c or the Mars Climate database.
-c
-c    Francois Forget 1999
-c    Version used by monica to interpolate in zaeroid and p coordinate
-
-c
-c=======================================================================
-c   declarations:
-c   -------------
-
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comdissip.h"
-#include "comvert.h"
-#include "comgeom2.h"
-#include "logic.h"
-#include "temps.h"
-#include "control.h"
-#include "ener.h"
-#include "description.h"
-#include "netcdf.inc"
-
-      INTEGER itau,nbpas,nbpasmx, coor,sor,varoutsize
-      integer varspecsize
-      integer varout(6),varspec(nqmx)
-      integer itau0
-      PARAMETER(nbpasmx=1000000)
-      REAL temps(nbpasmx),y
-      INTEGER unitlec
-      INTEGER i,j,l,irec,itautot,ierr,iq,n,ff,k
-      real, dimension(:),allocatable :: lat,lon,alt
-      integer:: nout,latdimout,londimout,altdimout,timedimout,timevarout
-      integer:: latdim,londim,altdim,dimid
-      integer:: latvar,lonvar,altvar,timevar
-      integer:: latlen,lonlen,altlen,timelen
-      integer, dimension(4) :: edges,corner,id
-      integer, dimension(3) :: edges2,corner2
-
-      INTEGER   unit,nvarid,nid,varid
-      REAL mugaz
-
-      REAL missing
-      PARAMETER(missing=1E+20)
-      REAL valid_range(2)
-      DATA valid_range /0., 300.0/
-c   variables meteo dans la grille verticale GCM
-c   --------------------------------------------
-      REAL v(iip1,jjp1,llm),u(iip1,jjp1,llm),w(iip1,jjp1,llm)
-      REAL t(iip1,jjp1,llm),rho(iip1,jjp1,llm),phi(iip1,jjp1,llm)
-      REAL ps(iip1,jjp1) , tsurf(iip1,jjp1)
-      REAL Rnew(iip1,jjp1,llm)
-      real euv(iip1,jjp1,llm),con(iip1,jjp1,llm),nir(iip1,jjp1,llm)
-      real nspec(iip1,jjp1,llm,nqmx),spec(iip1,jjp1,llm)
-
-      REAL v_sd(iip1,jjp1,llm),u_sd(iip1,jjp1,llm)
-      real w_sd(iip1,jjp1,llm),t_sd(iip1,jjp1,llm)
-      real rho_sd(iip1,jjp1,llm)
-      real euv_sd(iip1,jjp1,llm),con_sd(iip1,jjp1,llm)
-      real nir_sd(iip1,jjp1,llm)
-      real nspec_sd(iip1,jjp1,llm,nqmx)
-
-c   ALtitude of the GCM levels
-c   -------------------------
-      REAL zlocal(iip1,jjp1,llm) ! altitude above the local surface (m)
-      REAL zareoid(iip1,jjp1,llm) ! altitude above the mola areoid (m)
-      real tmean   ! use to integrate hydrostatic equation
-      real Rmean   ! use to integrate hydrostatic equation
-
-c    Also used to integrate hydrostatic equation:
-      real g0 ! exact mean gravity at radius=3396.km (LEMOINE ET AL 2001) 
-      data    g0 /3.7257964/
-      data    a0 /3396.0/  ! radius=3396.km
-      real gz  ! used to estimate gravity in altitude...
-
-
-c   variables meteo en coordonnee de pression
-c   --------------------------------------------
-      REAL vp(iip1,jjp1,llm),up(iip1,jjp1,llm),wp(iip1,jjp1,llm)
-      REAL tp(iip1,jjp1,llm),rhop(iip1,jjp1,llm)
-      REAL nspecp(iip1,jjp1,llm,nqmx)
-      REAL phip(iip1,jjp1,llm)
-      
-      REAL vp_sd(iip1,jjp1,llm),up_sd(iip1,jjp1,llm)
-      real wp_sd(iip1,jjp1,llm),tp_sd(iip1,jjp1,llm)
-      real rhop_sd(iip1,jjp1,llm),nspecp_sd(iip1,jjp1,llm,nqmx)
- 
-c     Niveaux de pression (Pa)
-      real pref(llm)
-
-c    Version 32 layers : ************
-c     data pref/
-c     &1000.,884., 783. , 610., 475, 370, 288, 224, 174, 140.,
-c     &115 , 80.6481, 48.0445, 26.6881, 14.1462, 7.29102, 3.70004,
-c     &1.86241, 0.933516, 0.466924, 0.233296, 0.116503, 5.81631E-02,
-c     & 2.90335E-02,1.44919E-02, 7.23328E-03, 3.61027E-03, 1.80193E-03,
-c     & 8.99364E-04,4.48881E-04, 2.15769E-04, 1.3E-04/
-
-c    Version 50 layers : ************
-      data pref/
-     &1400., 1100., 800., 565., 400., 280., 200., 140., 100.,
-     &70., 50., 35., 25., 18., 13., 9., 6.,
-     &3.63227,1.803712,0.8956969,0.4447900,0.2208762,0.1096839,
-     &5.4467395E-02,2.7047679E-02,1.3431421E-02,
-     &6.6698161E-03,3.3121328E-03,
-     &1.6447564E-03,8.1676187E-04,4.0559194E-04,2.0141099E-04,
-     &1.0001774E-04,4.9667346E-05,2.4664072E-05,1.2247816E-05,
-     &6.0820857E-06,3.0202741E-06,1.4998238E-06,7.4479044E-07,
-     &3.6985199E-07,1.8366305E-07,9.1204370E-08,4.5290751E-08,
-     &2.2490720E-08,1.1168562E-08,5.5461431E-09,2.7541311E-09,
-     &1.3676602E-09,6.7915956E-10/
-
-c   variables meteo en coordonnee de zareoid
-c   --------------------------------------------
-      REAL va(iip1,jjp1,llm),ua(iip1,jjp1,llm),wa(iip1,jjp1,llm)
-      REAL ta(iip1,jjp1,llm),rhoa(iip1,jjp1,llm),ra(iip1,jjp1,llm)
-      real euva(iip1,jjp1,llm),cona(iip1,jjp1,llm),nira(iip1,jjp1,llm)
-      real nspeca(iip1,jjp1,llm,nqmx)
-
-      REAL va_sd(iip1,jjp1,llm),ua_sd(iip1,jjp1,llm)
-      real wa_sd(iip1,jjp1,llm),ta_sd(iip1,jjp1,llm)
-      real rhoa_sd(iip1,jjp1,llm)
-      real euva_sd(iip1,jjp1,llm),cona_sd(iip1,jjp1,llm)
-      real nira_sd(iip1,jjp1,llm)
-      real nspeca_sd(iip1,jjp1,llm,nqmx)
-
-      REAL vij(llm),uij(llm),zaij(llm),wij(llm),rij(llm)
-      REAL tij(llm),rhoij(llm+1),sigij(llm)
-      real euvij(llm),conij(llm),nirij(llm)
-      real nspecij(llm+1,nqmx)
-
-      REAL vij_sd(llm),uij_sd(llm)
-      real wij_sd(llm),tij_sd(llm),rhoij_sd(llm+1)
-      real euvij_sd(llm),conij_sd(llm),nirij_sd(llm)
-      real nspecij_sd(llm+1,nqmx)
-
-c     Niveaux de zareoid (m)
-      real zaref(llm)
-      real p_zaref,p_zaij(llm+1) ! used to interpolate rho
-
-       data zaref/    
-      & -6.E+3,-4.E+3,-2.E+3,0.E+3,2.E+3,4.E+3,6.E+3,8.E+3,10.E+3,12.E+3
-      & ,14.E+3,16.E+3,18.E+3,22.E+3,26.E+3,30.E+3,34.E+3
-      & ,38.E+3,44.E+3,50.E+3,56.E+3,62.E+3,68.E+3,74.E+3
-      & ,80.E+3,86.E+3,92.E+3,98.E+3,104.E+3,110.E+3,116.E+3
-      & ,122.E+3,128.E+3,134.E+3,140.E+3,146.E+3,152.E+3,158.E+3
-      & ,164.E+3,170.E+3,176.E+3,182.E+3,188.E+3,194.E+3,200.E+3
-      & ,206.E+3,212.E+3,218.E+3,224.E+3,230.E+3/
-
-
-c   Surface data (sometime needed for some analysis):
-c   ------------------------------------------------
-      character relief*3
-      real phis(iip1,jjp1)
-      real alb(iip1,jjp1),ith(iip1,jjp1)
-      real zmeaS(iip1,jjp1),zstdS(iip1,jjp1)
-      real zsigS(iip1,jjp1),zgamS(iip1,jjp1),ztheS(iip1,jjp1)
-
-
-      real utime
-      real localtime(iip1)
-      common/temporaire/localtime
-
-      INTEGER*4 day0
-      integer nmoy(jjp1,llm),tp1,tp2,pass
-
-      CHARACTER*1 yes,yescomp
-
-      integer iformat
-       
-c   declarations de l'interface avec mywrite:
-c   -----------------------------------------
-
-      CHARACTER file*80
-      CHARACTER nomfich*60
-      CHARACTER nomfile(2)*60,nomfileout(2)*60
-      integer fichsize,fstats
-      CHARACTER fdiag*60
-
-c   externe:
-c   --------
-
-      EXTERNAL iniconst,inigeom,covcont,mywrite
-      EXTERNAL inifilr,exner
-      EXTERNAL solarlong,coordij,moy2
-      EXTERNAL SSUM
-      REAL SSUM
-      EXTERNAL lnblnk
-      INTEGER lnblnk
-
-c   Dust
-c   ----
-
-#include "fxyprim.h"
-
-      character*10  noms(nqmx),varnoms(6)
-c      data          noms/"co2","co","o","o1d","o2","o3","h","h2",
-c     $                   "oh","ho2","h2o2", "n2", "h2o"/
-c      data          varnoms/"T","U","V","W","RHO","Species"/
-
-
-c-----------------------------------------------------------------------
-c   initialisations:
-c   ----------------
-
-      unitlec=11
-      itautot=0
-
-
-c     Lecture du fichier a lire
-c     -------------------------
-
-      print*,' ' 
-      PRINT*,'File to process: 1)DIAGFI 2)STATS 3)BOTH'
-      READ(5,'(i)') fichsize
-      if(fichsize.ne.2)then
-        i=1
-        PRINT*,'   enter name of diagfi file (w/o .nc)'
-        READ(5,'(a)') nomfile(i)
-        fdiag=nomfile(i)
-        PRINT*,'   do you want to rename the output file?  
-     &  1) Yes  2) No'
-        READ(5,'(i)') sor
-        if (sor.eq.1) then
-          PRINT*,'   enter label for output file'
-          READ(5,'(a)') nomfileout(i)
-        elseif(sor.eq.2) then
-          nomfileout(i)=nomfile(i)
-        endif
-      endif
-      if(fichsize.ne.1)then
-        i=i+1
-        PRINT*,'   enter name of stats file (w/o .nc)'
-        READ(5,'(a)') nomfile(i)
-        PRINT*,'   do you want to rename the output file?  
-     &  1) Yes  2) No'
-        READ(5,'(i)') sor
-        if (sor.eq.1) then
-          PRINT*,'   enter label for output file'
-          READ(5,'(a)') nomfileout(i)
-        elseif(sor.eq.2) then
-          nomfileout(i)=nomfile(i)
-        endif
-        if(fichsize.eq.2) then
-          PRINT*,'   enter name of diagfi file for controle (w/o .nc)'
-          read(5,'(a)') fdiag
-        endif
-        fstats=1
-      endif
-      if (fichsize.ge.2) fichsize=fichsize-1
-      print*,' '
-      print*,'Output in: 1) netcdf 2) IDL 3) both ?'
-      READ(5,'(i)') sor
-      print*,' '
-      print*,'Coordinates in: 1) pressure 2) Zareoid 3) both  ?'
-      READ(5,'(i)') coor
-
-c ************* Partie a moderniser !!! FF 2004 ************
-      print*,' '
-      print*,'Fields:  T  U  V  W  Rho  Species  All   ?'
-      print*,'Type total number of desired outputs or 6 for All   '
-      READ(5,'(i)') varoutsize
-      if(varoutsize.lt.6) then
-        print*,' '
-        print*,'Fields:  T  U  V  W  Rho  Species '
-        print*,'  #   :  1  2  3  4   5      6'
-        print*,' '
-        do i=1,varoutsize
-          print*,'Type number of variable ',i
-          READ(5,'(i)') varout(i)
-        enddo
-      endif
-      if(varoutsize.eq.6) then
-        do i=1,6
-          varout(i)=i
-        enddo
-      endif
-      do i=1,varoutsize
-        if (varout(i).eq.6) then
-           print*,'Type total number of desired species or 13 for All'
-           READ(5,'(i2)') varspecsize
-           if(varspecsize.ne.13) then
-             print*,' '
-             print*,'Select Species: CO2 CO O O(1D) O2 O3' 
-             print*,'                 1  2  3   4   5  6'
-             print*,'                 H H2 OH HO2 H2O2 N2 H2O'
-             print*,'                 7 8  9  10   11  12 13'
-             do n=1,varspecsize
-               print*,'Type number of species ',i
-               read(5,'(i)') varspec(n)
-             enddo
-           else
-             do n=1,varspecsize
-               varspec(n)=n
-             enddo
-           endif
-         endif
-       enddo
-      if(varoutsize.gt.6) print*,'Value must be <= 6'
-     
-c ***************** Fin partie a moderniser ***************
-
-! LOOP ON FILES
-! =================================================================
-      do ff=1,fichsize
- 
-      file=nomfile(ff)  
-      nomfich=nomfile(ff)  
-      file=file(1:lnblnk(file))
-      PRINT*,'file',file
-
-c     Ouverture fichiers :
-c     ------------------
-      write(*,*) "opening "//trim(nomfich)//"..."
-      ierr = NF_OPEN(trim(adjustl(nomfich))//".nc",NF_NOWRITE,nid)
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: Pb opening file '//nomfich
-         stop ""
-      endif
-
-! Control & lecture on dimensions
-! =================================================================
-      ierr=NF_INQ_DIMID(nid,"latitude",latdim)
-      ierr=NF_INQ_VARID(nid,"latitude",latvar)
-      if (ierr.NE.NF_NOERR) then
-      write(*,*) 'ERROR: Field <latitude> is missing'
-      stop ""
-      endif
-      ierr=NF_INQ_DIMLEN(nid,latdim,latlen)
-!  write(*,*) "latlen: ",latlen
-
-      ierr=NF_INQ_DIMID(nid,"longitude",londim)
-      ierr=NF_INQ_VARID(nid,"longitude",lonvar)
-      if (ierr.NE.NF_NOERR) then
-      write(*,*) 'ERROR: Field <longitude> is lacking'
-      stop ""
-      endif
-      ierr=NF_INQ_DIMLEN(nid,londim,lonlen)
-!  write(*,*) "lonlen: ",lonlen
-
-      ierr=NF_INQ_DIMID(nid,"altitude",altdim)
-      ierr=NF_INQ_VARID(nid,"altitude",altvar)
-      if (ierr.NE.NF_NOERR) then
-      write(*,*) 'ERROR: Field <altitude> is lacking'
-      stop ""
-      endif
-
-      ierr=NF_INQ_DIMLEN(nid,altdim,altlen)
-!  write(*,*) "altlen: ",altlen
-
-      if (ff.eq.1) then
-        allocate(lat(latlen))
-        allocate(lon(lonlen))
-        allocate(alt(altlen))
-      endif
-
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid,latvar,lat)
-      ierr = NF_GET_VAR_DOUBLE(nid,lonvar,lon)
-      ierr = NF_GET_VAR_DOUBLE(nid,altvar,alt)
-#else
-      ierr = NF_GET_VAR_REAL(nid,latvar,lat)
-      ierr = NF_GET_VAR_REAL(nid,lonvar,lon)
-      ierr = NF_GET_VAR_REAL(nid,altvar,alt)
-#endif
-
-c   Lecture Time :
-
-      ierr= NF_INQ_DIMID (nid,"Time",dimid)
-        IF (ierr.NE.NF_NOERR) THEN
-          PRINT*, 'anl_NC: Le champ <Time> est absent'
-          CALL abort
-        ENDIF
-
-      ierr= NF_INQ_DIMLEN (nid,dimid,nbpas)
-      ierr = NF_INQ_VARID (nid, "Time", nvarid)
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, temps)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, temps)
-#endif
-        IF (ierr.NE.NF_NOERR) THEN
-          PRINT*, 'anl_NC: Lecture echouee pour <Time>'
-          CALL abort
-        ENDIF
-        PRINT*,'temps',(temps(itau),itau=1,10)
-! =================================================================
-
-! SETTING OUTPUT FILES
-
-      file=nomfileout(ff)  
-      nomfich=nomfileout(ff)  
-      file=file(1:lnblnk(file))
-
-c    layers in zareoid : ************
-          do l=1,llm
-            alt(l)=zaref(l)/1000.
-          enddo
-
-! =================================================================
-! Output in netcdf
-! =================================================================
-      if (sor.ne.2) then
-
-        if(coor.ne.2) then 					! PRESSURE COORDINATES
- 
-          ierr = NF_CREATE(trim(adjustl(nomfich))//"_P.nc",
-     &                     IOR(NF_CLOBBER,NF_64BIT_OFFSET), nout)
-          if (ierr.NE.NF_NOERR) THEN
-            write(*,*)' Pb d''ouverture du fichier '
-            write(*,*)' ierr = ', ierr
-            STOP
-          ENDIF
-          ierr = NF_PUT_ATT_TEXT(nout, NF_GLOBAL, "title", 24,
-     &                          "Pressure coordinates ")
-          ierr = NF_DEF_DIM(nout,"latitude", size(lat), latdimout)
-          ierr = NF_DEF_DIM(nout,"longitude", size(lon), londimout)
-          ierr = NF_DEF_DIM(nout,"altitude", size(pref), altdimout)
-          ierr = NF_DEF_DIM(nout,"Time", NF_UNLIMITED, timedimout)
-          ierr = NF_ENDDEF(nout)
-
-        endif
-
-        if(coor.ne.1) then 					! ZAEROID COORDINATES 
-
-          ierr = NF_CREATE(trim(adjustl(nomfich))//"_Z.nc",
-     &                     IOR(NF_CLOBBER,NF_64BIT_OFFSET), nout)
-          IF(ierr.NE.NF_NOERR) THEN
-            write(*,*)' Pb d''ouverture du fichier '
-            write(*,*)' ierr = ', ierr
-            STOP
-          ENDIF
-          ierr = NF_PUT_ATT_TEXT(nout, NF_GLOBAL, "title", 24,
-     &                           "zaeroid coordinates")
-          ierr = NF_DEF_DIM(nout,"latitude", size(lat), latdimout)
-          ierr = NF_DEF_DIM(nout,"longitude", size(lon), londimout)
-          ierr = NF_DEF_DIM(nout,"altitude ", size(pref), altdimout)
-          ierr = NF_DEF_DIM(nout,"Time", NF_UNLIMITED, timedimout)
-          ierr = NF_ENDDEF(nout)
-
-        endif
-
-        call def_var(nout,"Time","Time","days since 0000-00-0
-     &  00:00:00",1,(/timedimout/),timevarout,ierr)
-
-        ierr = NF_REDEF (nout)       
-        call def_var(nout,"latitude","latitude","degrees_north",1,
-     &               (/latdimout/),nvarid,ierr)
-
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,lat)
-#else
-        ierr = NF_PUT_VAR_REAL (nout,nvarid,lat)
-#endif
-        ierr = NF_REDEF (nout) 
-        call def_var(nout,"longitude","East longitude","degrees_east",1,
-     &               (/londimout/),nvarid,ierr)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,lon)
-#else
-        ierr = NF_PUT_VAR_REAL (nout,nvarid,lon)
-#endif
-        ierr = NF_REDEF (nout)
-
-        if(coor.ne.2) then 					! PRESSURE CCOORDINATES
-#ifdef NC_DOUBLE
-          ierr = NF_DEF_VAR (nout,"altitude",NF_DOUBLE,1,
-     &                       (/altdimout/), nvarid)
-#else
-          ierr = NF_DEF_VAR (nout,"altitude",NF_FLOAT,1,
-     &                       (/altdimout/),nvarid)
-#endif
-
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,"long_name",22,"altitude
-     &                            pression")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'units',2,"Pa")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'positive',4,"down")
-          ierr = NF_ENDDEF(nout)
-#ifdef NC_DOUBLE
-          ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,pref)
-#else
-          ierr = NF_PUT_VAR_REAL (nout,nvarid,pref)
-#endif
-        endif
-
-        if(coor.ne.1) then 					! ZAEROID COORDINATES 
-
-#ifdef NC_DOUBLE
-          ierr = NF_DEF_VAR (nout,"altitude",NF_DOUBLE,1,
-     &                       (/altdimout/), nvarid)
-#else
-          ierr = NF_DEF_VAR (nout,"altitude",NF_FLOAT,1,
-     &                       (/altdimout/),nvarid)
-#endif
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,"long_name",20,"altitude
-     &                           zaeroid")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'units',2,"km")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'positive',2,"up")
-          ierr = NF_ENDDEF(nout)
-#ifdef NC_DOUBLE
-          ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,alt)
-#else
-          ierr = NF_PUT_VAR_REAL (nout,nvarid,alt)
-#endif
-        endif
-
-      endif !end if netcdf  
-
-! Output in idl
-! =================================================================
-      if (sor.ne.1) then
-
-        if(coor.ne.2) then 					! PRESSURE COORDINATES
-          do i=1,varoutsize
-            j=121+i
-            if(varout(i).eq.6) then
-              do iq=1,varspecsize
-                file=trim(nomfileout(ff))//'_P_'
-     &               //trim(noms(iq))//'.dat'  
-                j=121+i+(iq-1)
-                open(j,file=trim(file), status='unknown')
-                write(j,117) noms(iq) 
-                write(j,120) iim,jjp1,llm
-                write(j,119) lon
-                write(j,119) lat
-                write(j,119) pref
-              enddo
-            else
-              file=trim(nomfileout(ff))//'_P_'
-     &            //trim(varnoms(varout(i)))//'.dat'  
-              open(j,file=trim(file), status='unknown')
-              write(j,117) varnoms(varout(i)) 
-              write(j,120) iim,jjp1,llm
-              write(j,119) lon
-              write(j,119) lat
-              write(j,119) pref
-            endif
-          enddo 
-        endif
-
-        if(coor.ne.1) then 					! ZAEROID COORDINATES
-          do i=1,varoutsize
-            j=1221+i
-            if(varout(i).eq.6) then
-              do iq=1,varspecsize
-                file=trim(nomfileout(ff))//'_Z_'
-     &               //trim(noms(iq))//'.dat'  
-                j=1221+i+(iq-1)
-                open(j,file=trim(file), status='unknown')
-                write(j,117) noms(iq)
-                write(j,120) iim,jjp1,llm
-                write(j,119) lon
-                write(j,119) lat
-                write(j,119) alt
-              enddo
-            else
-              file=trim(nomfileout(ff))//'_Z_'
-     &            //trim(varnoms(varout(i)))//'.dat'  
-              open(j,file=trim(file), status='unknown')
-              write(j,117) varnoms(varout(i))
-              write(j,120) iim,jjp1,llm
-              write(j,119) lon
-              write(j,119) lat
-              write(j,119) alt
-            endif
-          enddo
-              
-c              file=trim(nomfileout(ff))
-c              j=j+1
-c              open(j,file=file(1:lnblnk(file))//'_Z_EUV.dat',
-c     &               status='unknown')
-c              write(j,117) 'EUV'
-c              write(j,120) iim,jjp1,llm
-c              write(j,119) lon
-c              write(j,119) lat
-c              write(j,119) alt
-c              j=j+1
-c              open(j,file=file(1:lnblnk(file))//'_Z_CON.dat',
-c     &               status='unknown')
-c              write(j,117) 'CONDUCTION'
-c              write(j,120) iim,jjp1,llm
-c              write(j,119) lon
-c              write(j,119) lat
-c              write(j,119) alt
-c              j=j+1
-c              open(j,file=file(1:lnblnk(file))//'_Z_NIR.dat',
-c     &               status='unknown')
-c              write(j,117) 'NIR'
-c              write(j,120) iim,jjp1,llm
-c              write(j,119) lon
-c              write(j,119) lat
-c              write(j,119) alt
-        endif
-
-      endif
-120    format(3i3)
-119    format(12(e10.4,1x))
-118    format(2i3)
-117    format(6(a7))
-116    format(13(a6))
-! =================================================================
- 
-
-800   continue ! LOOP SUR LES FICHIERS
-
-
-! =================================================================
-! INITIALIZATION OF PARAMETERS
-! =================================================================
-
-      rad=3397200.              ! rayon de mars (m)  ~3397200 m
-      daysec=88775.             ! duree du sol (s)  ~88775 s
-      omeg=4.*asin(1.)/(daysec) ! vitesse de rotation (rad.s-1)
-      g=3.72                    ! gravite (m.s-2) ~3.72
-      mugaz=43.49               ! Masse molaire de l'atm (g.mol-1) ~43.49
-      kappa=.256793             ! = r/cp  ~0.256793
-      r = 191.18213
-      pi=2.*asin(1.)
-      ecritphy =1
-      iphysiq=1
-      day_ini=0.
-      day_step=1
-
-      CALL readhead_NC(trim(adjustl(fdiag))//".nc",day0,phis,R)
-      WRITE (*,*) 'day0 = ' , day0
-
-      CALL iniconst
-      CALL inigeom
-      CALL inifilr
-
-c     If needed : getting topography, albedo, thermal inertia...
-c     -------------------------------------------------------
-c     "phis" is the surface geopotential = topography (m) * g 
-       relief='mola'    ! Topography MOLA par defaut
-
-        CALL datareadnc(relief,phis,alb,ith,zmeaS,zstdS,zsigS,zgamS,
-      .          ztheS)
-
-
-! =================================================================
-! LOOP IN TIME
-! =================================================================
-
-      DO itau=1,nbpas
-
-! FILE READING : 
-! =================================================================
-        print*,'Timestep = ',itau,'/',nbpas
-
-c Cas special stats pour la base de donnee : FF 2004
-c        call lect_var(nid,'tsurf',3,ierr,itau,	tsurf)
-        call lect_var(nid,'ps',3,ierr,itau,ps)
-
-        call lect_var(nid,'temp',4,ierr,itau,t)
-        call lect_var(nid,'u',4,ierr,itau,u)
-        call lect_var(nid,'v',4,ierr,itau,v)
-        call lect_var(nid,'w',4,ierr,itau,		w)
-        call lect_var(nid,'rho',4,ierr,itau,	rho)
-        
-
-
-        do n=1,varspecsize
-          i=varspec(n)
-        call lect_var(nid,'n_'//trim(noms(i)),4,ierr,itau,spec)
-        do l=1,llm
-          do j=1,jjp1
-            do i=1,iip1
-              nspec(i,j,l,n)=spec(i,j,l)
-            enddo
-          enddo
-        enddo
-        enddo
-
-        if(fstats*ff-fichsize .eq. 0) then
-          call lect_var(nid,'temp_sd',4,ierr,itau,	t_sd)
-          call lect_var(nid,'u_sd',4,ierr,itau,		u_sd)
-          call lect_var(nid,'v_sd',4,ierr,itau,		v_sd)
-c          call lect_var(nid,'w_sd',4,ierr,itau,		w_sd)
-c          call lect_var(nid,'rho_sd',4,ierr,itau,	rho_sd)
-          do n=1,varspecsize
-            i=varspec(n)
-            call lect_var(nid,'n_'//trim(noms(i))//'_sd',4,ierr,
-     &                    itau,	spec)
-            do l=1,llm
-              do j=1,jjp1
-                do i=1,iip1
-                  nspec_sd(i,j,l,n)=spec(i,j,l)
-                enddo
-              enddo
-            enddo
-          enddo
-        endif
-
-! =================================================================
-! COMPUTING ALTITUDE OF GCM LEVELS IN GCM GRID
-! =================================================================
-
-c  ---------------------------------------------------------------
-c   Computing Molecular Gas Constant at every grid point (J kg-1 K-1)
-c   later used to integrate the hydrostatic equation
-c  ---------------------------------------------------------------
-        do l=1,llm
-          do j=1,jjp1
-            do i=1,iip1
-c              Rnew = P/(rho*T)
-              Rnew(i,j,l) =  (aps(l) + bps(l)*ps(i,j))
-     &                      / ( rho(i,j,l) * T(i,j,l) )
-            enddo
-          enddo
-        enddo
-
-
-c      ALTITUDE OF GCM LEVELS 
-c      ----------------------
-c      zlocal 	! altitude above the local surface (m)
-c      zareoid 	! altitude above the mola areoid (m)
-c      phis(i,j)/g ! altitude of the local surface above the mola areoid (m)
-
-        do j=1,jjp1
-          do i=1,iip1
-            sigij(1)=aps(1)/ps(i,j)+bps(1)
-            zlocal(i,j,1)=-log(sigij(1))* Rnew(i,j,1)*t(i,j,1)/g
-            zareoid(i,j,1) = zlocal(i,j,1) + phis(i,j)/g0
-
-            do l=2,llm
-              sigij(l)=aps(l)/ps(i,j)+bps(l)
-              tmean=t(i,j,l)
-              if(t(i,j,l).ne.t(i,j,l-1))
-     &          tmean=(t(i,j,l)-t(i,j,l-1))/log(t(i,j,l)/t(i,j,l-1))
-                Rmean = 0.5*(Rnew(i,j,l) + Rnew(i,j,l-1))
-                gz= g0*a0**2/(a0+zareoid(i,j,l-1))**2
-
-              zlocal(i,j,l)=zlocal(i,j,l-1) 
-     &                -log(sigij(l)/sigij(l-1))*Rmean*tmean/gz
-              zareoid(i,j,l) = zlocal(i,j,l) + phis(i,j)/g
-            enddo
-  
-          enddo
-        enddo
-
-
-c Local time
-c ----------
-c universal time (in stats oe MCD files)
-        utime = (itau-1)*2.
-
-c local time (in stats file)
-        DO i = 1,iim
-          localtime(i)=utime + 12.*rlonv(i)/pi
-          if(localtime(i).gt.24) localtime(i)=localtime(i)-24.
-          if(localtime(i).lt.0) localtime(i)=localtime(i)+24.
-        ENDDO
-
-c c Passage en niveaux de pression
-c ------------------------------
-        if(coor.ne.2) then 					! PRESSURE COORDINATES
-          call xsig2p (ps,T,pref,llm,Tp)
-          call xsig2p (ps,u,pref,llm,up)
-          call xsig2p (ps,v,pref,llm,vp)
-          call xsig2p (ps,w,pref,llm,wp)
-          call xsig2p (ps,rho,pref,llm,rhop)
-          do iq=1,varspecsize
-            call xsig2p (ps,nspec(1,1,1,iq),pref,llm,nspecp(1,1,1,iq))
-          enddo
-           if(fstats*ff-fichsize .eq. 0) then
-             call xsig2p (ps,u_sd,pref,llm,up_sd)
-             call xsig2p (ps,v_sd,pref,llm,vp_sd)
-             call xsig2p(ps,t_sd,pref,llm,Tp_sd)
-             call xsig2p (ps,w_sd,pref,llm,wp_sd)
-             call xsig2p (ps,rho_sd,pref,llm,rhop_sd)
-             do iq=1,varspecsize
-               call xsig2p (ps,nspec_sd(1,1,1,iq),pref,llm,
-     $                      nspecp_sd(1,1,1,iq))
-             enddo
-           endif
-         endif
-
-c c Passage en niveaux de zareoid
-c ------------------------------
-        if(coor.ne.1) then 					! ZAEROID COORDINATES
-        do j=1,jjp1
-          do i=1,iip1
-            do l=1,llm
-              Tij(l)=T(i,j,l)
-              uij(l)=u(i,j,l)
-              vij(l)=v(i,j,l)
-              wij(l)=w(i,j,l)
-              rhoij(l)=rho(i,j,l)
-              do iq=1,varspecsize
-                nspecij(l,iq)=nspec(i,j,l,iq)
-                if(l.eq.llm) nspecij(l+1,iq)=nspecij(l,iq)*1.e-3
-              enddo
-c              euvij(l)=euv(i,j,l)
-c              conij(l)=con(i,j,l)
-c              nirij(l)=nir(i,j,l)
-              zaij(l)=zareoid(i,j,l)
-              p_zaij(l)=exp(-zareoid(i,j,l)/1.e4) ! used to interpolate rho
-              if(fstats*ff-fichsize .eq. 0) then
-                Tij_sd(l)=T_sd(i,j,l)
-                uij_sd(l)=u_sd(i,j,l)
-                vij_sd(l)=v_sd(i,j,l)
-                wij_sd(l)=w_sd(i,j,l)
-                rhoij_sd(l)=rho_sd(i,j,l)
-                do iq=1,varspecsize
-                  nspecij_sd(l,iq)=nspec_sd(i,j,l,iq)
-                  if(l.eq.llm) nspecij_sd(l+1,iq)=nspecij_sd(l,iq)*1.e-3
-                enddo
-              endif
-            enddo
-
-            do l=1,llm
-              call interpolf(zaref(l),y,zaij,Tij,llm)
-              Ta(i,j,l)=y
-              call interpolf(zaref(l),y,zaij,uij,llm)
-              ua(i,j,l)=y
-              call interpolf(zaref(l),y,zaij,vij,llm)
-              va(i,j,l)=y
-              call interpolf(zaref(l),y,zaij,wij,llm)
-              wa(i,j,l)=y
-c              call interpolf(zaref(l),y,zaij,euvij,llm)
-c              euva(i,j,l)=y
-c              call interpolf(zaref(l),y,zaij,conij,llm)
-c              cona(i,j,l)=y
-c              call interpolf(zaref(l),y,zaij,nirij,llm)
-c              nira(i,j,l)=y
-
-              p_zaref=exp(-zaref(l)/1.e4)
-              call interpolf(p_zaref,y,p_zaij,rhoij,llm+1)
-              rhoa(i,j,l)=y
-               
-              do iq=1,varspecsize
-                call interpolf(p_zaref,y,p_zaij,nspecij(1,iq),llm+1)
-c                call interpolf(zaref(l),y,zaij,nspecij(1,iq),llm)
-                nspeca(i,j,l,iq)=y
-              enddo
-
-              if(fstats*ff-fichsize .eq. 0) then
-                call interpolf(zaref(l),y,zaij,Tij_sd,llm)
-                Ta_sd(i,j,l)=y
-                call interpolf(zaref(l),y,zaij,uij_sd,llm)
-                ua_sd(i,j,l)=y
-                call interpolf(zaref(l),y,zaij,vij_sd,llm)
-                va_sd(i,j,l)=y
-                call interpolf(zaref(l),y,zaij,wij_sd,llm)
-                wa_sd(i,j,l)=y
-                call interpolf(p_zaref,y,p_zaij,rhoij_sd,llm+1)
-                rhoa_sd(i,j,l)=y
-                do iq=1,varspecsize
-                  call interpolf(p_zaref,y,p_zaij,nspecij_sd(1,iq),
-     &                           llm+1)
-c                  call interpolf(zaref(l),y,zaij,nspecij_sd(1,iq),llm)
-                  nspeca_sd(i,j,l,iq)=y
-                enddo
-              endif
-
-            enddo
-          enddo
-        enddo
-
-c            do l=1,llm
-c        print*,T(32,24,l),Ta(32,24,l)
-c        print*,nspec(32,24,l,1),nspeca(32,24,l,1)
-c            enddo
-
-        endif
- 
-c Output at each time-step, in netcdf format
-! =================================================================
-        if (sor .ne. 2) then
-
-          ierr= NF_INQ_VARID(nout,"Time",nvarid)
-#ifdef NC_DOUBLE
-          ierr= NF_PUT_VARA_DOUBLE(nout,nvarid,itau,1,temps(itau))
-#else
-          ierr= NF_PUT_VARA_REAL(nout,nvarid,itau,1,temps(itau))
-#endif
-          if (ierr.ne.NF_NOERR) then
-            write(*,*) "time problem ",NF_STRERROR(ierr)
-            stop
-          endif
-
-          if (varoutsize.eq.6) n=1
-          if (varoutsize.ne.6) n=varoutsize
-          do i=1,n
-            if(varout(i).eq.1 .or. varoutsize.eq.6) then
-             if(coor.ne.1) 
-     &          call put_var(nout,'temp','temp','K',4,ierr,itau,Ta)
-             if(coor.ne.2) 
-     &          call put_var(nout,'temp','temp','K',4,ierr,itau,Tp)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'temp_sd','temp_sd','K',
-     &                                      4,ierr,itau,Ta_sd)
-                if(coor.ne.2) call put_var(nout,'temp_sd','temp_sd','K',
-     &                                      4,ierr,itau,Tp_sd)
-              endif
-            endif
-            if(varout(i).eq.2 .or. varoutsize.eq.6)  then
-              if(coor.ne.1) 
-     &          call put_var(nout,'u','u','m s-1',4,ierr,itau,ua)
-              if(coor.ne.2) 
-     &          call put_var(nout,'u','u','m s-1',4,ierr,itau,up)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'u_sd','u_sd','m s-1',
-     &                                      4,ierr,itau,ua_sd)
-                if(coor.ne.2) call put_var(nout,'u_sd','u_sd','m s-1',
-     &                                      4,ierr,itau,up_sd)
-              endif
-            endif
-            if(varout(i).eq.3 .or. varoutsize.eq.6) then
-              if(coor.ne.1) 
-     &          call put_var(nout,'v','v','m s-1',4,ierr,itau,va)
-              if(coor.ne.2) 
-     &          call put_var(nout,'v','v','m s-1',4,ierr,itau,vp)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'v_sd','v_sd','m s-1',
-     &                                      4,ierr,itau,va_sd)
-                if(coor.ne.2) call put_var(nout,'v_sd','v_sd','m s-1',
-     &                                      4,ierr,itau,vp_sd)
-              endif
-            endif
-            if(varout(i).eq.4 .or. varoutsize.eq.6) then
-              if(coor.ne.1) 
-     &          call put_var(nout,'w','w','m s-1',4,ierr,itau,wa)
-              if(coor.ne.2) 
-     &          call put_var(nout,'w','w','m s-1',4,ierr,itau,wp)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'w_sd','w_sd','m s-1',
-     &                                      4,ierr,itau,wa_sd)
-                if(coor.ne.2) call put_var(nout,'w_sd','w_sd','m s-1',
-     &                                      4,ierr,itau,wp_sd)
-              endif
-            endif
-            if(varout(i).eq.5 .or. varoutsize.eq.6)  then
-              if(coor.ne.1) call put_var(nout,'rho','rho','',4,ierr,
-     &                                    itau,rhoa)
-              if(coor.ne.2) call put_var(nout,'rho','rho','',4,ierr,
-     &                                    itau,rhop)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'rho_sd','rho_sd','',
-     &                                      4,ierr,itau,rhoa_sd)
-                if(coor.ne.2) call put_var(nout,'rho_sd','rho_sd','',
-     &                                      4,ierr,itau,rhop_sd)
-              endif
-            endif
-            if(varout(i).eq.6 .or. varoutsize.eq.6) then
-              do iq=1,varspecsize
-                j=varspec(iq)
-                if(coor.ne.1) call put_var(nout,'n_'//trim(noms(j)),
-     &       'n_'//trim(noms(j)),'cm-3',4,ierr,itau,nspeca(1,1,1,iq))
-                if(coor.ne.2) call put_var(nout,'n_'//trim(noms(j)),
-     &         'n_'//trim(noms(j)),'cm-3',4,ierr,itau,nspecp(1,1,1,iq))
-                if(fstats*ff-fichsize.eq.0) then
-                  if(coor.ne.1) call put_var(nout,
-     &                        'n_'//trim(noms(j))//'_sd',
-     &                        'n_'//trim(noms(j))//'_sd','cm-3',4,ierr,
-     &                           itau,nspeca_sd(1,1,1,iq))
-                  if(coor.ne.2) call put_var(nout,
-     &                        'n_'//trim(noms(j))//'_sd',
-     &                        'n_'//trim(noms(j))//'_sd','cm-3',4,ierr,
-     &                           itau,nspecp_sd(1,1,1,iq))
-                endif
-              enddo
-            endif     
-          enddo
-        endif !endif writing data on Netcdf file 
-
-c Output at each time-step, ASCII file for IDL
-! =================================================================
-c In pressure and zareoid coordinates:
-
-      if (sor .ne. 1) then
-       do n=1,varoutsize
-         if(varout(n).eq.1) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(k,124) ((Tp(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1) then
-               k=1221+n
-               write(k,124) ((Ta(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.2) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(k,124) ((up(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1)then
-               k=1221+n
-               write(k,124) ((ua(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif 
-         if(varout(n).eq.3) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(k,124) ((vp(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1) then
-               k=1221+n
-               write(k,124) ((va(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.4) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(122,124) ((wp(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1) then
-               k=1221+n
-               write(k,124) ((wa(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.5) then
-           do l=1,llm
-            if(coor.ne.2) then
-              k=121+n
-              write(k,124) ((rhop(i,j,l),i=1,iim),j=1,jjp1)
-            elseif(coor.ne.1) then
-               k=1221+n
-              write(k,124) ((rhoa(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.6) then
-           do iq=1,varspecsize
-             do l=1,llm
-               if(coor.ne.1) then
-                 k=1221+n+(iq-1)
-                 write(k,124) ((nspeca(i,j,l,iq),i=1,iim),j=1,jjp1)
-               endif
-             enddo
-           enddo
-         endif     
-       enddo
-c       k=k+1
-c       do l=1,llm
-c         if(coor.ne.1)write(k,124) ((euva(i,j,l),i=1,iim),j=1,jjp1)
-c       enddo
-c       k=k+1
-c       do l=1,llm
-c         if(coor.ne.1)write(k,124) ((cona(i,j,l),i=1,iim),j=1,jjp1)
-c       enddo
-c       k=k+1
-c       do l=1,llm
-c         if(coor.ne.1)write(k,124) ((nira(i,j,l),i=1,iim),j=1,jjp1)
-c       enddo
-      endif
-124   format(12(e10.4,1x))
-
-
-       ENDDO		!LOOP in TIME
-! =================================================================
-
- 900   continue
-
-
-c  ECRITURE FINALE si besoin
-c  *************************
-      ierr= NF_CLOSE(nid)
-      ierr=NF_CLOSE(nout)
-      close (33)
-      close (122)
-      close (1222)
-       
-      ENDDO		!LOOP in FILES
-! =================================================================
-
-9999  PRINT*,'Fin '
-1000  format(a5,3x,i4,i3,x,a39)
-7777  FORMAT ('latitude/longitude',4f7.1)
-
-      END
-
-c*******************************************************
-
-      subroutine  xsig2p (ps,qsig,pref,npref,qp)
-      IMPLICIT NONE
-c=======================================================================
-c
-c   Francois Forget    Avril 1996
-c
-c Cette subroutine calcule les champs interpole en niveaux de pression
-c different niveaux de pression pref
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "comconst.h"
-
-c
-c  ARGUMENTS
-c  ---------
-
-c Inputs:
-      
-      REAL qsig(iip1,jjp1,llm)
-      REAL ps(iip1,jjp1)
-      integer npref
-      real pref(npref)
-
-c outputs
-      REAL qp(iip1,jjp1,npref)
-
-
-c Variables du modele
-c -------------------
-
-      REAL lnp(llm)  , q(llm)
-      REAL x,y
-      INTEGER i,j,l ,n
-
-
-      logical firstcall
-      save firstcall
-      data firstcall/.true./
- 
-#include "fxyprim.h"
-c**********************************************************************
-         if (firstcall) then
-           write(*,*) 'kappa = ', kappa
-           write(*,*) 'cpp = ', cpp
-           firstcall = .false.
-         end if
-
-        DO j=1,jjp1
-          DO i=1,iip1
-            do l=1,llm
-              lnp(l) = -log(aps(l)+bps(l)*ps(i,j))
-              q(l) = qsig(i,j,l)
-            end do
-            do n =1,npref
-              if ( (pref(n).le.ps(i,j)) .and.
-     &          (pref(n).ge.(ps(i,j)*bps(llm)+aps(llm))) ) then
-                    x = -log(pref(n))
-                    call interpolf(x,y,lnp,q,llm)
-                    qp(i,j,n) = y
-              else
-                    qp(i,j,n) = 1E+20 
-              end if
-            end do
-          ENDDO
-        ENDDO
-
-      return
-      end 
-
-      subroutine  missing_value(nout,nvarid,valid_range,missing)
-      IMPLICIT NONE
-c=======================================================================
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-      include "netcdf.inc"
-
-      INTEGER nout,nvarid,ierr
-      REAL missing
-      REAL valid_range(2)
-c
-c  ARGUMENTS
-c  ---------
-
-c Inputs:
-      
-             ierr= NF_PUT_ATT_REAL(nout,nvarid,'valid_range',
-     $  NF_FLOAT,2,valid_range)
-        IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, 'anl_NC: valid_range attribution failed'
-            WRITE(*,*) 'NF_NOERR', NF_NOERR
-            CALL abort
-        ENDIF
-
-#ifdef NC_DOUBLE
-             ierr= NF_PUT_ATT_DOUBLE(nout,nvarid,'missing_value',
-     $  NF_DOUBLE,1,missing)
-#else
-              ierr= NF_PUT_ATT_REAL(nout,nvarid,'missing_value',
-     $  NF_FLOAT,1,missing)
-
-#endif
-
-        IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, 'anl_NC: missing value attribution failed'
-            WRITE(*,*) 'NF_NOERR', NF_NOERR
-            CALL abort
-        ENDIF
-      return
-      end
-**********************************************************
-      subroutine lect_var(nid,name,nbdim,ierr,itau,
-     $ var)
-      IMPLICIT NONE
-c=======================================================================
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-#include "netcdf.inc"
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "comconst.h"
-
-c inputs
-      character (len=*) :: name
-      INTEGER nid,nbdim,nvarid,ierr,itau
-      integer, dimension(nbdim) :: edges,corner
-c output var
-      integer, dimension(nbdim) :: var
-c  ---------
-        if (nbdim.eq.4) then
-         corner=(/1,1,1,itau/)
-         edges=(/iip1,jjp1,llm,1/)
-        endif
-
-        if (nbdim.eq.3) then
-            corner=(/1,1,itau/)
-            edges=(/iip1,jjp1,1/)
-        endif
-
-
-          ierr = NF_INQ_VARID (nid,adjustl(name), nvarid)
-#ifdef NC_DOUBLE
-          ierr = NF_GET_VARA_DOUBLE(nid, nvarid,corner,edges, var)
-#else
-          ierr = NF_GET_VARA_REAL(nid, nvarid,corner,edges, var)
-#endif
-          IF (ierr.NE.NF_NOERR) THEN
-            write(*,*) 'anl_NC: reading failed for ', name
-            CALL abort
-          ENDIF
-
-      return
-      end
-
-
-      subroutine put_var(nout,name,title,units,nbdim,ierr,itau,
-     $ var)
-      IMPLICIT NONE
-c=======================================================================
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-#include "netcdf.inc"
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "comconst.h"
-
-      character (len=*) :: title,units,name
-      INTEGER nout,nbdim,nvarid,ierr,itau
-      integer, dimension(nbdim) :: edges,corner,id,var
-      REAL valid_range(2)
-      DATA valid_range /0., 300.0/
-c  ---------
-        if (nbdim.eq.4) then
-         ierr= NF_INQ_DIMID(nout,"longitude",id(1))
-         ierr= NF_INQ_DIMID(nout,"latitude",id(2))
-         ierr= NF_INQ_DIMID(nout,"altitude",id(3))
-         ierr= NF_INQ_DIMID(nout,"Time",id(4))
-         corner=(/1,1,1,itau/)
-         edges=(/iip1,jjp1,llm,1/)
-        endif
-
-        if (nbdim.eq.3) then
-             ierr= NF_INQ_DIMID(nout,"longitude",id(1))
-             ierr= NF_INQ_DIMID(nout,"latitude",id(2))
-             ierr= NF_INQ_DIMID(nout,"Time",id(3))
-            corner=(/1,1,itau/)
-            edges=(/iip1,jjp1,1/)
-        endif
-
-
-        ierr = NF_INQ_VARID (nout,adjustl(name), nvarid)
-          if (ierr /= NF_NOERR) then
-!  choix du nom des coordonnees
-! Creation de la variable si elle n'existait pas
-             write (*,*) "====================="
-             write (*,*) "creation de  ",name
-         call def_var(nout,adjustl(title),adjustl(name),adjustl(units),
-     $   nbdim,id,nvarid,ierr)
-          if (name.eq.'temp') then
-             ierr = NF_REDEF (nout)
-             call missing_value(nout,nvarid,valid_range,1E+20)
-             ierr = NF_ENDDEF(nout)
-          endif
-          endif
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nout,nvarid,corner,edges,var)
-#else
-        ierr = NF_PUT_VARA_REAL(nout,nvarid,corner,edges,var)
-#endif
-        IF (ierr.NE.NF_NOERR) THEN
-            write(*,*) 'anl_NC: writing failed for ',name
-            CALL abort
-        ENDIF
-
-                
-      return
-      end
-
-
-      Subroutine interpolf(x,y,xd,yd,nd)
-
-c******************************************************
-c   SUBROUTINE   (interpol)
-c interpolation, give y = f(x) with array xd,yd known, size nd
-
-c  Version with CONSTANT values oustide limits
-c**********************************************************
-
-
-c Variable declaration
-c --------------------
-c  Arguments :
-      real x,y
-      real xd(*),yd(*)
-      integer nd
-c  internal
-      integer i,j
-      real y_undefined
-
-c run
-c ---
-c      y_undefined=-999.999
-      y_undefined=1.e20
-
-      y=0.
-      if ((x.le.xd(1)).and.(x.le.xd(nd))) then
-        if (xd(1).lt.xd(nd)) y = y_undefined ! yd(1)
-        if (xd(1).ge.xd(nd)) y = y_undefined ! yd(nd)
-      else if ((x.ge.xd(1)).and.(x.ge.xd(nd))) then
-        if (xd(1).lt.xd(nd)) y = y_undefined ! yd(nd)
-        if (xd(1).ge.xd(nd)) y = y_undefined ! yd(1)
-c       y = yd(nd)
-      else
-        do i=1,nd-1
-         if ( ( (x.ge.xd(i)).and.(x.lt.xd(i+1)) )
-     &     .or. ( (x.le.xd(i)).and.(x.gt.xd(i+1)) ) ) then
-           y=yd(i)+(x-xd(i))*(yd(i+1)-yd(i))/(xd(i+1)-xd(i))
-           goto 99
-         end if
-        end do
-      end if
-
-c     write (*,*)' x , y' , x,y
-c     do i=1,nd
-c       write (*,*)' i, xd , yd' , xd(i),yd(i)
-c     end do
-c     stop
-
- 99   continue
-
-      end
Index: unk/LMDZ.MARS/libf/dyn3d/anl_stats-diag.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/anl_stats-diag.F	(revision 1035)
+++ 	(revision )
@@ -1,1377 +1,0 @@
-      PROGRAM anldiag_nc
-      IMPLICIT NONE
-c======================================================================
-c
-c
-c Program designed to read output files from the MARS gcm
-c or the Mars Climate database.
-c
-c    Francois Forget 1999
-c    Version used by monica to interpolate in zaeroid and p coordinate
-
-c
-c=======================================================================
-c   declarations:
-c   -------------
-
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comdissip.h"
-#include "comvert.h"
-#include "comgeom2.h"
-#include "logic.h"
-#include "temps.h"
-#include "control.h"
-#include "ener.h"
-#include "description.h"
-#include "netcdf.inc"
-
-      INTEGER itau,nbpas,nbpasmx, coor,sor,varoutsize
-      integer varspecsize
-      integer varout(6),varspec(nqmx)
-      integer itau0
-      PARAMETER(nbpasmx=1000000)
-      REAL temps(nbpasmx),y
-      INTEGER unitlec
-      INTEGER i,j,l,irec,itautot,ierr,iq,n,ff,k
-      real, dimension(:),allocatable :: lat,lon,alt
-      integer:: nout,latdimout,londimout,altdimout,timedimout,timevarout
-      integer:: latdim,londim,altdim,dimid
-      integer:: latvar,lonvar,altvar,timevar
-      integer:: latlen,lonlen,altlen,timelen
-      integer, dimension(4) :: edges,corner,id
-      integer, dimension(3) :: edges2,corner2
-
-      INTEGER   unit,nvarid,nid,varid
-      REAL mugaz
-
-      REAL missing
-      PARAMETER(missing=1E+20)
-      REAL valid_range(2)
-      DATA valid_range /0., 300.0/
-c   variables meteo dans la grille verticale GCM
-c   --------------------------------------------
-      REAL v(iip1,jjp1,llm),u(iip1,jjp1,llm),w(iip1,jjp1,llm)
-      REAL t(iip1,jjp1,llm),rho(iip1,jjp1,llm),phi(iip1,jjp1,llm)
-      REAL ps(iip1,jjp1) , tsurf(iip1,jjp1)
-      REAL Rnew(iip1,jjp1,llm)
-      real euv(iip1,jjp1,llm),con(iip1,jjp1,llm),nir(iip1,jjp1,llm)
-      real nspec(iip1,jjp1,llm,nqmx),spec(iip1,jjp1,llm)
-
-      REAL v_sd(iip1,jjp1,llm),u_sd(iip1,jjp1,llm)
-      real w_sd(iip1,jjp1,llm),t_sd(iip1,jjp1,llm)
-      real rho_sd(iip1,jjp1,llm)
-      real euv_sd(iip1,jjp1,llm),con_sd(iip1,jjp1,llm)
-      real nir_sd(iip1,jjp1,llm)
-      real nspec_sd(iip1,jjp1,llm,nqmx)
-
-c   ALtitude of the GCM levels (+1 dummy "thermosphere level")
-c   -------------------------
-      REAL zlocal(iip1,jjp1,llm+1) ! altitude above the local surface (m)
-      REAL zareoid(iip1,jjp1,llm+1) ! altitude above the mola areoid (m)
-      real tmean   ! use to integrate hydrostatic equation
-      real sig_therm ! dummy "thermosphere level" as in atmemcd.F
-      real T_therm
-
-c   variables meteo en coordonnee de pression
-c   --------------------------------------------
-      REAL vp(iip1,jjp1,llm),up(iip1,jjp1,llm),wp(iip1,jjp1,llm)
-      REAL tp(iip1,jjp1,llm),rhop(iip1,jjp1,llm)
-      REAL nspecp(iip1,jjp1,llm,nqmx)
-      REAL phip(iip1,jjp1,llm)
-      
-      REAL vp_sd(iip1,jjp1,llm),up_sd(iip1,jjp1,llm)
-      real wp_sd(iip1,jjp1,llm),tp_sd(iip1,jjp1,llm)
-      real rhop_sd(iip1,jjp1,llm),nspecp_sd(iip1,jjp1,llm,nqmx)
- 
-c     Niveaux de pression (Pa)
-      real pref(llm)
-
-c    Version 32 layers : ************
-      data pref/
-     &1000.,884., 783. , 610., 475, 370, 288, 224, 174, 140.,
-     &115 , 80.6481, 48.0445, 26.6881, 14.1462, 7.29102, 3.70004,
-     &1.86241, 0.933516, 0.466924, 0.233296, 0.116503, 5.81631E-02,
-     & 2.90335E-02,1.44919E-02, 7.23328E-03, 3.61027E-03, 1.80193E-03,
-     & 8.99364E-04,4.48881E-04, 2.15769E-04, 1.3E-04/
-
-c    Version 50 layers : ************
-c      data pref/
-c     &1000.,884., 783. , 610., 475, 370, 288, 224, 174, 140.,
-c     &115 , 80.6481, 48.0445, 26.6881, 14.1462, 7.29102, 3.70004,
-c     &1.86241, 0.933516, 0.466924, 0.233296, 0.116503, 5.81631E-02,
-c     & 2.90335E-02,1.44919E-02, 7.23328E-03, 3.61027E-03, 1.80193E-03,
-c     & 8.99364E-04,4.48881E-04, 2.15769E-04, 1.3E-04,
-c     & 7.23328e-05, 3.61027e-05, 1.80193e-05, 8.99364e-06,
-c     & 4.48881e-06, 2.15769e-06, 1.3e-06,
-c     & 7.23328e-07, 3.61027e-07, 1.80193e-07, 8.99364e-08,
-c     & 4.48881e-08, 2.15769e-08, 1.3e-08,
-c     & 7.23328e-09, 3.61027e-09, 1.80193e-09, 8.99364e-10/
-
-c      data pref/
-c     &1000.,884., 783. , 610., 475, 370, 288, 224, 174, 140.,
-c     &115 , 80.6481, 48.0445, 26.6881, 14.1462, 7.29102, 3.70004,
-c     &1.86241, 0.933516, 0.466924, 0.233296, 0.116503, 5.81631E-02,
-c     & 2.90335E-02,1.44919E-02 / 
-c       data pref/
-c     & 101.4369,94.4369,87.4369,80.4369,73.4369,66.4369,59.4369,52.4369,
-c     & 45.4369,38.4369,31.5527,25.0626,18.9666,13.5138,8.97780,
-c     & 5.54010,3.19040,1.73630,0.907000,0.460400,0.228200,0.109700,
-c     & 0.0500,0.0200,0.0050/
-c   variables meteo en coordonnee de zareoid
-c   --------------------------------------------
-      REAL va(iip1,jjp1,llm),ua(iip1,jjp1,llm),wa(iip1,jjp1,llm)
-      REAL ta(iip1,jjp1,llm),rhoa(iip1,jjp1,llm),ra(iip1,jjp1,llm)
-      real euva(iip1,jjp1,llm),cona(iip1,jjp1,llm),nira(iip1,jjp1,llm)
-      real nspeca(iip1,jjp1,llm,nqmx)
-
-      REAL va_sd(iip1,jjp1,llm),ua_sd(iip1,jjp1,llm)
-      real wa_sd(iip1,jjp1,llm),ta_sd(iip1,jjp1,llm)
-      real rhoa_sd(iip1,jjp1,llm)
-      real euva_sd(iip1,jjp1,llm),cona_sd(iip1,jjp1,llm)
-      real nira_sd(iip1,jjp1,llm)
-      real nspeca_sd(iip1,jjp1,llm,nqmx)
-
-      REAL vij(llm),uij(llm),zaij(llm),wij(llm),rij(llm)
-      REAL tij(llm),rhoij(llm+1),sigij(llm)
-      real euvij(llm),conij(llm),nirij(llm)
-      real nspecij(llm+1,nqmx)
-
-      REAL vij_sd(llm),uij_sd(llm)
-      real wij_sd(llm),tij_sd(llm),rhoij_sd(llm+1)
-      real euvij_sd(llm),conij_sd(llm),nirij_sd(llm)
-      real nspecij_sd(llm+1,nqmx)
-
-c     Niveaux de zareoide (m)
-      real zaref(llm)
-      real p_zaref,p_zaij(llm+1) ! used to interpolate rho
-
-c   Surface data (sometime needed for some analysis):
-c   ------------------------------------------------
-      character relief*3
-      real phis(iip1,jjp1)
-      real alb(iip1,jjp1),ith(iip1,jjp1)
-      real zmeaS(iip1,jjp1),zstdS(iip1,jjp1)
-      real zsigS(iip1,jjp1),zgamS(iip1,jjp1),ztheS(iip1,jjp1)
-
-
-      real utime
-      real localtime(iip1)
-      common/temporaire/localtime
-
-      INTEGER*4 day0
-      integer nmoy(jjp1,llm),tp1,tp2,pass
-
-      CHARACTER*1 yes,yescomp
-
-      integer iformat
-       
-c   declarations de l'interface avec mywrite:
-c   -----------------------------------------
-
-      CHARACTER file*80
-      CHARACTER nomfich*60
-      CHARACTER nomfile(2)*60,nomfileout(2)*60
-      integer fichsize,fstats
-      CHARACTER fdiag*60
-
-c   externe:
-c   --------
-
-      EXTERNAL iniconst,inigeom,covcont,mywrite
-      EXTERNAL inifilr,exner
-      EXTERNAL solarlong,coordij,moy2
-      EXTERNAL SSUM
-      REAL SSUM
-      EXTERNAL lnblnk
-      INTEGER lnblnk
-
-c   Dust
-c   ----
-
-#include "fxyprim.h"
-
-      character*10  noms(nqmx),varnoms(6)
-      data          noms/"co2","co","o","o1d","o2","o3","h","h2",
-     $                   "oh","ho2","h2o2", "n2", "h2o"/
-      data          varnoms/"T","U","V","W","RHO","Species"/
-
-
-c-----------------------------------------------------------------------
-c   initialisations:
-c   ----------------
-
-      unitlec=11
-      itautot=0
-
-
-c     Lecture du fichier a lire
-c     -------------------------
-
-      print*,' ' 
-      PRINT*,'File to process: 1)DIAGFI 2)STATS 3)BOTH'
-      READ(5,'(i)') fichsize
-      if(fichsize.ne.2)then
-        i=1
-        PRINT*,'   enter name of diagfi file (w/o .nc)'
-        READ(5,'(a)') nomfile(i)
-        fdiag=nomfile(i)
-        PRINT*,'   do you want to rename the output file?  
-     &  1) Yes  2) No'
-        READ(5,'(i)') sor
-        if (sor.eq.1) then
-          PRINT*,'   enter label for output file'
-          READ(5,'(a)') nomfileout(i)
-        elseif(sor.eq.2) then
-          nomfileout(i)=nomfile(i)
-        endif
-      endif
-      if(fichsize.ne.1)then
-        i=i+1
-        PRINT*,'   enter name of stats file (w/o .nc)'
-        READ(5,'(a)') nomfile(i)
-        PRINT*,'   do you want to rename the output file?  
-     &  1) Yes  2) No'
-        READ(5,'(i)') sor
-        if (sor.eq.1) then
-          PRINT*,'   enter label for output file'
-          READ(5,'(a)') nomfileout(i)
-        elseif(sor.eq.2) then
-          nomfileout(i)=nomfile(i)
-        endif
-        if(fichsize.eq.2) then
-          PRINT*,'   enter name of diagfi file for controle (w/o .nc)'
-          read(5,'(a)') fdiag
-        endif
-        fstats=1
-      endif
-      if (fichsize.ge.2) fichsize=fichsize-1
-      print*,' '
-      print*,'Output in: 1) netcdf 2) IDL 3) both ?'
-      READ(5,'(i)') sor
-      print*,' '
-      print*,'Coordinates in: 1) pressure 2) Zareoid 3) both  ?'
-      READ(5,'(i)') coor
-      print*,' '
-      print*,'Fields:  T  U  V  W  Rho  Species  All   ?'
-      print*,'Type total number of desired outputs or 6 for All   '
-      READ(5,'(i)') varoutsize
-      if(varoutsize.lt.6) then
-        print*,' '
-        print*,'Fields:  T  U  V  W  Rho  Species '
-        print*,'  #   :  1  2  3  4   5      6'
-        print*,' '
-        do i=1,varoutsize
-          print*,'Type number of variable ',i
-          READ(5,'(i)') varout(i)
-        enddo
-      endif
-      if(varoutsize.eq.6) then
-        do i=1,6
-          varout(i)=i
-        enddo
-      endif
-      do i=1,varoutsize
-        if (varout(i).eq.6) then
-           print*,'Type total number of desired species or 13 for All'
-           READ(5,'(i2)') varspecsize
-           if(varspecsize.ne.13) then
-             print*,' '
-             print*,'Select Species: CO2 CO O O(1D) O2 O3' 
-             print*,'                 1  2  3   4   5  6'
-             print*,'                 H H2 OH HO2 H2O2 N2 H2O'
-             print*,'                 7 8  9  10   11  12 13'
-             do n=1,varspecsize
-               print*,'Type number of species ',i
-               read(5,'(i)') varspec(n)
-             enddo
-           else
-             do n=1,varspecsize
-               varspec(n)=n
-             enddo
-           endif
-         endif
-       enddo
-      if(varoutsize.gt.6) print*,'Value must be <= 6'
-     
-
-! LOOP ON FILES
-! =================================================================
-      do ff=1,fichsize
- 
-      file=nomfile(ff)  
-      nomfich=nomfile(ff)  
-      file=file(1:lnblnk(file))
-      PRINT*,'file',file
-
-c     Ouverture fichiers :
-c     ------------------
-      write(*,*) "opening "//trim(nomfich)//"..."
-      ierr = NF_OPEN(trim(adjustl(nomfich))//".nc",NF_NOWRITE,nid)
-      if (ierr.NE.NF_NOERR) then
-         write(*,*) 'ERROR: Pb opening file '//nomfich
-         stop ""
-      endif
-
-! Control & lecture on dimensions
-! =================================================================
-      ierr=NF_INQ_DIMID(nid,"latitude",latdim)
-      ierr=NF_INQ_VARID(nid,"latitude",latvar)
-      if (ierr.NE.NF_NOERR) then
-      write(*,*) 'ERROR: Field <latitude> is missing'
-      stop ""
-      endif
-      ierr=NF_INQ_DIMLEN(nid,latdim,latlen)
-!  write(*,*) "latlen: ",latlen
-
-      ierr=NF_INQ_DIMID(nid,"longitude",londim)
-      ierr=NF_INQ_VARID(nid,"longitude",lonvar)
-      if (ierr.NE.NF_NOERR) then
-      write(*,*) 'ERROR: Field <longitude> is lacking'
-      stop ""
-      endif
-      ierr=NF_INQ_DIMLEN(nid,londim,lonlen)
-!  write(*,*) "lonlen: ",lonlen
-
-      ierr=NF_INQ_DIMID(nid,"altitude",altdim)
-      ierr=NF_INQ_VARID(nid,"altitude",altvar)
-      if (ierr.NE.NF_NOERR) then
-      write(*,*) 'ERROR: Field <altitude> is lacking'
-      stop ""
-      endif
-
-      ierr=NF_INQ_DIMLEN(nid,altdim,altlen)
-!  write(*,*) "altlen: ",altlen
-
-      if (ff.eq.1) then
-        allocate(lat(latlen))
-        allocate(lon(lonlen))
-        allocate(alt(altlen))
-      endif
-
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid,latvar,lat)
-      ierr = NF_GET_VAR_DOUBLE(nid,lonvar,lon)
-      ierr = NF_GET_VAR_DOUBLE(nid,altvar,alt)
-#else
-      ierr = NF_GET_VAR_REAL(nid,latvar,lat)
-      ierr = NF_GET_VAR_REAL(nid,lonvar,lon)
-      ierr = NF_GET_VAR_REAL(nid,altvar,alt)
-#endif
-
-c   Lecture Time :
-
-      ierr= NF_INQ_DIMID (nid,"Time",dimid)
-        IF (ierr.NE.NF_NOERR) THEN
-          PRINT*, 'anl_NC: Le champ <Time> est absent'
-          CALL abort
-        ENDIF
-
-      ierr= NF_INQ_DIMLEN (nid,dimid,nbpas)
-      ierr = NF_INQ_VARID (nid, "Time", nvarid)
-#ifdef NC_DOUBLE
-      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, temps)
-#else
-      ierr = NF_GET_VAR_REAL(nid, nvarid, temps)
-#endif
-        IF (ierr.NE.NF_NOERR) THEN
-          PRINT*, 'anl_NC: Lecture echouee pour <Time>'
-          CALL abort
-        ENDIF
-        PRINT*,'temps',(temps(itau),itau=1,10)
-! =================================================================
-
-! SETTING OUTPUT FILES
-
-      file=nomfileout(ff)  
-      nomfich=nomfileout(ff)  
-      file=file(1:lnblnk(file))
-
-c    layers in zareoid : ************
-          do l=0,llm-1
-            zaref(l+1)=4500.*l
-            alt(l+1)=zaref(l+1)/1000.
-          enddo 
-
-! =================================================================
-! Output in netcdf
-! =================================================================
-      if (sor.ne.2) then
-
-        if(coor.ne.2) then 					! PRESSURE COORDINATES
- 
-          ierr = NF_CREATE(trim(adjustl(nomfich))//"_P.nc",
-     &                     IOR(NF_CLOBBER,NF_64BIT_OFFSET), nout)
-          if (ierr.NE.NF_NOERR) THEN
-            write(*,*)' Pb d''ouverture du fichier '
-            write(*,*)' ierr = ', ierr
-            STOP
-          ENDIF
-          ierr = NF_PUT_ATT_TEXT(nout, NF_GLOBAL, "title", 24,
-     &                          "Pressure coordinates ")
-          ierr = NF_DEF_DIM(nout,"latitude", size(lat), latdimout)
-          ierr = NF_DEF_DIM(nout,"longitude", size(lon), londimout)
-          ierr = NF_DEF_DIM(nout,"altitude", size(pref), altdimout)
-          ierr = NF_DEF_DIM(nout,"Time", NF_UNLIMITED, timedimout)
-          ierr = NF_ENDDEF(nout)
-
-        endif
-
-        if(coor.ne.1) then 					! ZAEROID COORDINATES 
-
-          ierr = NF_CREATE(trim(adjustl(nomfich))//"_Z.nc",
-     &                     IOR(NF_CLOBBER,NF_64BIT_OFFSET), nout)
-          IF(ierr.NE.NF_NOERR) THEN
-            write(*,*)' Pb d''ouverture du fichier '
-            write(*,*)' ierr = ', ierr
-            STOP
-          ENDIF
-          ierr = NF_PUT_ATT_TEXT(nout, NF_GLOBAL, "title", 24,
-     &                           "zaeroid coordinates")
-          ierr = NF_DEF_DIM(nout,"latitude", size(lat), latdimout)
-          ierr = NF_DEF_DIM(nout,"longitude", size(lon), londimout)
-          ierr = NF_DEF_DIM(nout,"altitude ", size(pref), altdimout)
-          ierr = NF_DEF_DIM(nout,"Time", NF_UNLIMITED, timedimout)
-          ierr = NF_ENDDEF(nout)
-
-        endif
-
-        call def_var(nout,"Time","Time","days since 0000-00-0
-     &  00:00:00",1,(/timedimout/),timevarout,ierr)
-
-        ierr = NF_REDEF (nout)       
-        call def_var(nout,"latitude","latitude","degrees_north",1,
-     &               (/latdimout/),nvarid,ierr)
-
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,lat)
-#else
-        ierr = NF_PUT_VAR_REAL (nout,nvarid,lat)
-#endif
-        ierr = NF_REDEF (nout) 
-        call def_var(nout,"longitude","East longitude","degrees_east",1,
-     &               (/londimout/),nvarid,ierr)
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,lon)
-#else
-        ierr = NF_PUT_VAR_REAL (nout,nvarid,lon)
-#endif
-        ierr = NF_REDEF (nout)
-
-        if(coor.ne.2) then 					! PRESSURE CCOORDINATES
-#ifdef NC_DOUBLE
-          ierr = NF_DEF_VAR (nout,"altitude",NF_DOUBLE,1,
-     &                       (/altdimout/), nvarid)
-#else
-          ierr = NF_DEF_VAR (nout,"altitude",NF_FLOAT,1,
-     &                       (/altdimout/),nvarid)
-#endif
-
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,"long_name",22,"altitude
-     &                            pression")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'units',2,"Pa")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'positive',4,"down")
-          ierr = NF_ENDDEF(nout)
-#ifdef NC_DOUBLE
-          ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,pref)
-#else
-          ierr = NF_PUT_VAR_REAL (nout,nvarid,pref)
-#endif
-        endif
-
-        if(coor.ne.1) then 					! ZAEROID COORDINATES 
-
-#ifdef NC_DOUBLE
-          ierr = NF_DEF_VAR (nout,"altitude",NF_DOUBLE,1,
-     &                       (/altdimout/), nvarid)
-#else
-          ierr = NF_DEF_VAR (nout,"altitude",NF_FLOAT,1,
-     &                       (/altdimout/),nvarid)
-#endif
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,"long_name",20,"altitude
-     &                           zaeroid")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'units',2,"km")
-          ierr = NF_PUT_ATT_TEXT (nout,nvarid,'positive',2,"up")
-          ierr = NF_ENDDEF(nout)
-#ifdef NC_DOUBLE
-          ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,alt)
-#else
-          ierr = NF_PUT_VAR_REAL (nout,nvarid,alt)
-#endif
-        endif
-
-      endif !end if netcdf  
-
-! Output in idl
-! =================================================================
-      if (sor.ne.1) then
-
-        if(coor.ne.2) then 					! PRESSURE COORDINATES
-          do i=1,varoutsize
-            j=121+i
-            if(varout(i).eq.6) then
-              do iq=1,varspecsize
-                file=trim(nomfileout(ff))//'_P_'
-     &               //trim(noms(iq))//'.dat'  
-                j=121+i+(iq-1)
-                open(j,file=trim(file), status='unknown')
-                write(j,117) noms(iq) 
-                write(j,120) iim,jjp1,llm
-                write(j,119) lon
-                write(j,119) lat
-                write(j,119) pref
-              enddo
-            else
-              file=trim(nomfileout(ff))//'_P_'
-     &            //trim(varnoms(varout(i)))//'.dat'  
-              open(j,file=trim(file), status='unknown')
-              write(j,117) varnoms(varout(i)) 
-              write(j,120) iim,jjp1,llm
-              write(j,119) lon
-              write(j,119) lat
-              write(j,119) pref
-            endif
-          enddo 
-        endif
-
-        if(coor.ne.1) then 					! ZAEROID COORDINATES
-          do i=1,varoutsize
-            j=1221+i
-            if(varout(i).eq.6) then
-              do iq=1,varspecsize
-                file=trim(nomfileout(ff))//'_Z_'
-     &               //trim(noms(iq))//'.dat'  
-                j=1221+i+(iq-1)
-                open(j,file=trim(file), status='unknown')
-                write(j,117) noms(iq)
-                write(j,120) iim,jjp1,llm
-                write(j,119) lon
-                write(j,119) lat
-                write(j,119) alt
-              enddo
-            else
-              file=trim(nomfileout(ff))//'_Z_'
-     &            //trim(varnoms(varout(i)))//'.dat'  
-              open(j,file=trim(file), status='unknown')
-              write(j,117) varnoms(varout(i))
-              write(j,120) iim,jjp1,llm
-              write(j,119) lon
-              write(j,119) lat
-              write(j,119) alt
-            endif
-          enddo
-              
-c              file=trim(nomfileout(ff))
-c              j=j+1
-c              open(j,file=file(1:lnblnk(file))//'_Z_EUV.dat',
-c     &               status='unknown')
-c              write(j,117) 'EUV'
-c              write(j,120) iim,jjp1,llm
-c              write(j,119) lon
-c              write(j,119) lat
-c              write(j,119) alt
-c              j=j+1
-c              open(j,file=file(1:lnblnk(file))//'_Z_CON.dat',
-c     &               status='unknown')
-c              write(j,117) 'CONDUCTION'
-c              write(j,120) iim,jjp1,llm
-c              write(j,119) lon
-c              write(j,119) lat
-c              write(j,119) alt
-c              j=j+1
-c              open(j,file=file(1:lnblnk(file))//'_Z_NIR.dat',
-c     &               status='unknown')
-c              write(j,117) 'NIR'
-c              write(j,120) iim,jjp1,llm
-c              write(j,119) lon
-c              write(j,119) lat
-c              write(j,119) alt
-        endif
-
-      endif
-120    format(3i3)
-119    format(12(e10.4,1x))
-118    format(2i3)
-117    format(6(a7))
-116    format(13(a6))
-! =================================================================
- 
-
-800   continue ! LOOP SUR LES FICHIERS
-
-
-! =================================================================
-! INITIALIZATION OF PARAMETERS
-! =================================================================
-
-      rad=3397200.              ! rayon de mars (m)  ~3397200 m
-      daysec=88775.             ! duree du sol (s)  ~88775 s
-      omeg=4.*asin(1.)/(daysec) ! vitesse de rotation (rad.s-1)
-      g=3.72                    ! gravite (m.s-2) ~3.72
-      mugaz=43.49               ! Masse molaire de l'atm (g.mol-1) ~43.49
-      kappa=.256793             ! = r/cp  ~0.256793
-      r = 191.18213
-      pi=2.*asin(1.)
-      ecritphy =1
-      iphysiq=1
-      day_ini=0.
-      day_step=1
-
-      CALL readhead_NC(trim(adjustl(fdiag))//".nc",day0,phis,R)
-      WRITE (*,*) 'day0 = ' , day0
-
-      CALL iniconst
-      CALL inigeom
-      CALL inifilr
-
-c  Dummy "thermosphere level" as in atmemcd (extrapol above top GCM level)
-      sig_therm=bps(llm)*exp(-20./7.)
-      T_therm = 200.  ! temperature (K) of the "thermosphere level"
-
-   
-c     If needed : getting topography, albedo, thermal inertia...
-c     -------------------------------------------------------
-c     "phis" is the surface geopotential = topography (m) * g 
-       relief='mola'    ! Topography MOLA par defaut
-
-c       CALL datareadnc(relief,phis,alb,ith,zmeaS,zstdS,zsigS,zgamS,
-c     .          ztheS)
-
-
-! =================================================================
-! LOOP IN TIME
-! =================================================================
-
-      DO itau=1,nbpas
-
-! FILE READING
-! =================================================================
-        print*,'Timestep = ',itau,'/',nbpas
-
-c        call lect_var(nid,'tsurf',3,ierr,itau,	tsurf)
-        call lect_var(nid,'ps',3,ierr,itau,		ps)
-
-        call lect_var(nid,'temp',4,ierr,itau,	t)
-        call lect_var(nid,'u',4,ierr,itau,		u)
-        call lect_var(nid,'v',4,ierr,itau,		v)
-c        call lect_var(nid,'w',4,ierr,itau,		w)
-c        call lect_var(nid,'rho',4,ierr,itau,	rho)
-        do l=1,llm
-          do j=1,jjp1
-            do i=1,iip1
-              Rnew(i,j,l)=8.314/mugaz*1.e3 
-! A enregistrer lors du run pour pouvoir le lire avec la ligne dessous
-            enddo
-          enddo
-        enddo
-c        call lect_var(nid,'r',4,ierr,itau,		Rnew)
-c        call lect_var(nid,'euv',4,ierr,itau,	euv)
-c        call lect_var(nid,'cond',4,ierr,itau,	con)
-c        call lect_var(nid,'nir',4,ierr,itau,	nir)
-        do n=1,varspecsize
-          i=varspec(n)
-        call lect_var(nid,'n_'//trim(noms(i)),4,ierr,itau,	spec)
-        do l=1,llm
-          do j=1,jjp1
-            do i=1,iip1
-              nspec(i,j,l,n)=spec(i,j,l)
-            enddo
-          enddo
-        enddo
-        enddo
-
-        if(fstats*ff-fichsize .eq. 0) then
-          call lect_var(nid,'temp_sd',4,ierr,itau,	t_sd)
-          call lect_var(nid,'u_sd',4,ierr,itau,		u_sd)
-          call lect_var(nid,'v_sd',4,ierr,itau,		v_sd)
-c          call lect_var(nid,'w_sd',4,ierr,itau,		w_sd)
-c          call lect_var(nid,'rho_sd',4,ierr,itau,	rho_sd)
-          do n=1,varspecsize
-            i=varspec(n)
-            call lect_var(nid,'n_'//trim(noms(i))//'_sd',4,ierr,
-     &                    itau,	spec)
-            do l=1,llm
-              do j=1,jjp1
-                do i=1,iip1
-                  nspec_sd(i,j,l,n)=spec(i,j,l)
-                enddo
-              enddo
-            enddo
-          enddo
-        endif
-! =================================================================
-
-! COMPUTING ALTITUDE OF GCM LEVELS IN GCM GRID
-! =================================================================
-c      zlocal 	! altitude above the local surface (m)
-c      zareoid 	! altitude above the mola areoid (m)
-
-        do j=1,jjp1
-          do i=1,iip1
-            sigij(1)=aps(1)/ps(i,j)+bps(1)
-            zlocal(i,j,1)=-log(sigij(1))* Rnew(i,j,1)*t(i,j,1)/g
-c            phis(i,j)=0.0
-c            phi(i,j,1)=phis(i,j)
-c            rho(i,j,1)=sigij(1)*ps(i,j)/(Rnew(i,j,1)*t(i,j,1))
-            zareoid(i,j,1) = zlocal(i,j,1) + phis(i,j)/g
-            do l=2,llm
-              sigij(l)=aps(l)/ps(i,j)+bps(l)
-              tmean=t(i,j,l)
-              if(t(i,j,l).ne.t(i,j,l-1))
-     &          tmean=(t(i,j,l)-t(i,j,l-1))/log(t(i,j,l)/t(i,j,l-1))
-              zlocal(i,j,l)=zlocal(i,j,l-1) 
-     &                -log(sigij(l)/sigij(l-1))*Rnew(i,j,l-1)*tmean/g
-              zareoid(i,j,l) = zlocal(i,j,l) + phis(i,j)/g
-c              rho(i,j,l)=sigij(l)*ps(i,j)/(Rnew(i,j,l)*t(i,j,l))
-              phi(i,j,l)=zareoid(i,j,l)*g
-            enddo
-  
-c           Altitude of the dummy thermosphere level (as in atmemcd)   
-c           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-            tmean=(T_therm-t(i,j,llm))/log(T_therm/t(i,j,llm))
-            zlocal(i,j,llm+1)=zlocal(i,j,llm) 
-     &                  -log(sig_therm/sigij(llm))*Rnew(i,j,llm)*tmean/g
-            zareoid(i,j,llm+1) = zlocal(i,j,llm+1) + phis(i,j)/g
-
-          enddo
-        enddo
-
-c            do l=1,llm
-c        print*,zareoid(32,24,l),zlocal(32,24,l),zaref(l)
-c        print*,zareoid(32,24,l),zaref(l)
-c            enddo
-
-c Local time
-c ----------
-c universal time (in stats oe MCD files)
-        utime = (itau-1)*2.
-
-c local time (in stats file)
-        DO i = 1,iim
-          localtime(i)=utime + 12.*rlonv(i)/pi
-          if(localtime(i).gt.24) localtime(i)=localtime(i)-24.
-          if(localtime(i).lt.0) localtime(i)=localtime(i)+24.
-        ENDDO
-
-c c Passage en niveaux de pression
-c ------------------------------
-        if(coor.ne.2) then 					! PRESSURE COORDINATES
-          call xsig2p (ps,T,pref,llm,Tp)
-          call xsig2p (ps,u,pref,llm,up)
-          call xsig2p (ps,v,pref,llm,vp)
-          call xsig2p (ps,w,pref,llm,wp)
-          call xsig2p (ps,rho,pref,llm,rhop)
-          do iq=1,varspecsize
-            call xsig2p (ps,nspec(1,1,1,iq),pref,llm,nspecp(1,1,1,iq))
-          enddo
-           if(fstats*ff-fichsize .eq. 0) then
-             call xsig2p (ps,u_sd,pref,llm,up_sd)
-             call xsig2p (ps,v_sd,pref,llm,vp_sd)
-             call xsig2p(ps,t_sd,pref,llm,Tp_sd)
-             call xsig2p (ps,w_sd,pref,llm,wp_sd)
-             call xsig2p (ps,rho_sd,pref,llm,rhop_sd)
-             do iq=1,varspecsize
-               call xsig2p (ps,nspec_sd(1,1,1,iq),pref,llm,
-     $                      nspecp_sd(1,1,1,iq))
-             enddo
-           endif
-         endif
-
-c c Passage en niveaux de zareoid
-c ------------------------------
-        if(coor.ne.1) then 					! ZAEROID COORDINATES
-        do j=1,jjp1
-          do i=1,iip1
-            do l=1,llm
-              Tij(l)=T(i,j,l)
-              uij(l)=u(i,j,l)
-              vij(l)=v(i,j,l)
-              wij(l)=w(i,j,l)
-              rhoij(l)=rho(i,j,l)
-              do iq=1,varspecsize
-                nspecij(l,iq)=nspec(i,j,l,iq)
-                if(l.eq.llm) nspecij(l+1,iq)=nspecij(l,iq)*1.e-3
-              enddo
-c              euvij(l)=euv(i,j,l)
-c              conij(l)=con(i,j,l)
-c              nirij(l)=nir(i,j,l)
-              zaij(l)=zareoid(i,j,l)
-              p_zaij(l)=exp(-zareoid(i,j,l)/1.e4) ! used to interpolate rho
-              if(fstats*ff-fichsize .eq. 0) then
-                Tij_sd(l)=T_sd(i,j,l)
-                uij_sd(l)=u_sd(i,j,l)
-                vij_sd(l)=v_sd(i,j,l)
-                wij_sd(l)=w_sd(i,j,l)
-                rhoij_sd(l)=rho_sd(i,j,l)
-                do iq=1,varspecsize
-                  nspecij_sd(l,iq)=nspec_sd(i,j,l,iq)
-                  if(l.eq.llm) nspecij_sd(l+1,iq)=nspecij_sd(l,iq)*1.e-3
-                enddo
-              endif
-            enddo
-            p_zaij(l+1)=exp(-zareoid(i,j,l+1)/1.e4) 
-c            rhoij(l+1)=sig_therm*ps(i,j)/(R*T_therm)!in dummy thermosphere
-            rhoij(l+1)=rhoij(llm)*1.e-3
-            rhoij_sd(l+1)=rhoij_sd(llm)*1.e-3
-
-            do l=1,llm
-              call interpolf(zaref(l),y,zaij,Tij,llm)
-              Ta(i,j,l)=y
-              call interpolf(zaref(l),y,zaij,uij,llm)
-              ua(i,j,l)=y
-              call interpolf(zaref(l),y,zaij,vij,llm)
-              va(i,j,l)=y
-              call interpolf(zaref(l),y,zaij,wij,llm)
-              wa(i,j,l)=y
-c              call interpolf(zaref(l),y,zaij,euvij,llm)
-c              euva(i,j,l)=y
-c              call interpolf(zaref(l),y,zaij,conij,llm)
-c              cona(i,j,l)=y
-c              call interpolf(zaref(l),y,zaij,nirij,llm)
-c              nira(i,j,l)=y
-
-              p_zaref=exp(-zaref(l)/1.e4)
-              call interpolf(p_zaref,y,p_zaij,rhoij,llm+1)
-              rhoa(i,j,l)=y
-               
-              do iq=1,varspecsize
-                call interpolf(p_zaref,y,p_zaij,nspecij(1,iq),llm+1)
-c                call interpolf(zaref(l),y,zaij,nspecij(1,iq),llm)
-                nspeca(i,j,l,iq)=y
-              enddo
-
-              if(fstats*ff-fichsize .eq. 0) then
-                call interpolf(zaref(l),y,zaij,Tij_sd,llm)
-                Ta_sd(i,j,l)=y
-                call interpolf(zaref(l),y,zaij,uij_sd,llm)
-                ua_sd(i,j,l)=y
-                call interpolf(zaref(l),y,zaij,vij_sd,llm)
-                va_sd(i,j,l)=y
-                call interpolf(zaref(l),y,zaij,wij_sd,llm)
-                wa_sd(i,j,l)=y
-                call interpolf(p_zaref,y,p_zaij,rhoij_sd,llm+1)
-                rhoa_sd(i,j,l)=y
-                do iq=1,varspecsize
-                  call interpolf(p_zaref,y,p_zaij,nspecij_sd(1,iq),
-     &                           llm+1)
-c                  call interpolf(zaref(l),y,zaij,nspecij_sd(1,iq),llm)
-                  nspeca_sd(i,j,l,iq)=y
-                enddo
-              endif
-
-            enddo
-          enddo
-        enddo
-
-c            do l=1,llm
-c        print*,T(32,24,l),Ta(32,24,l)
-c        print*,nspec(32,24,l,1),nspeca(32,24,l,1)
-c            enddo
-
-        endif
- 
-c Output at each time-step, in netcdf format
-! =================================================================
-        if (sor .ne. 2) then
-
-          ierr= NF_INQ_VARID(nout,"Time",nvarid)
-#ifdef NC_DOUBLE
-          ierr= NF_PUT_VARA_DOUBLE(nout,nvarid,itau,1,temps(itau))
-#else
-          ierr= NF_PUT_VARA_REAL(nout,nvarid,itau,1,temps(itau))
-#endif
-          if (ierr.ne.NF_NOERR) then
-            write(*,*) "time problem ",NF_STRERROR(ierr)
-            stop
-          endif
-
-          if (varoutsize.eq.6) n=1
-          if (varoutsize.ne.6) n=varoutsize
-          do i=1,n
-            if(varout(i).eq.1 .or. varoutsize.eq.6) then
-             if(coor.ne.1) 
-     &          call put_var(nout,'temp','temp','K',4,ierr,itau,Ta)
-             if(coor.ne.2) 
-     &          call put_var(nout,'temp','temp','K',4,ierr,itau,Tp)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'temp_sd','temp_sd','K',
-     &                                      4,ierr,itau,Ta_sd)
-                if(coor.ne.2) call put_var(nout,'temp_sd','temp_sd','K',
-     &                                      4,ierr,itau,Tp_sd)
-              endif
-            endif
-            if(varout(i).eq.2 .or. varoutsize.eq.6)  then
-              if(coor.ne.1) 
-     &          call put_var(nout,'u','u','m s-1',4,ierr,itau,ua)
-              if(coor.ne.2) 
-     &          call put_var(nout,'u','u','m s-1',4,ierr,itau,up)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'u_sd','u_sd','m s-1',
-     &                                      4,ierr,itau,ua_sd)
-                if(coor.ne.2) call put_var(nout,'u_sd','u_sd','m s-1',
-     &                                      4,ierr,itau,up_sd)
-              endif
-            endif
-            if(varout(i).eq.3 .or. varoutsize.eq.6) then
-              if(coor.ne.1) 
-     &          call put_var(nout,'v','v','m s-1',4,ierr,itau,va)
-              if(coor.ne.2) 
-     &          call put_var(nout,'v','v','m s-1',4,ierr,itau,vp)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'v_sd','v_sd','m s-1',
-     &                                      4,ierr,itau,va_sd)
-                if(coor.ne.2) call put_var(nout,'v_sd','v_sd','m s-1',
-     &                                      4,ierr,itau,vp_sd)
-              endif
-            endif
-            if(varout(i).eq.4 .or. varoutsize.eq.6) then
-              if(coor.ne.1) 
-     &          call put_var(nout,'w','w','m s-1',4,ierr,itau,wa)
-              if(coor.ne.2) 
-     &          call put_var(nout,'w','w','m s-1',4,ierr,itau,wp)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'w_sd','w_sd','m s-1',
-     &                                      4,ierr,itau,wa_sd)
-                if(coor.ne.2) call put_var(nout,'w_sd','w_sd','m s-1',
-     &                                      4,ierr,itau,wp_sd)
-              endif
-            endif
-            if(varout(i).eq.5 .or. varoutsize.eq.6)  then
-              if(coor.ne.1) call put_var(nout,'rho','rho','',4,ierr,
-     &                                    itau,rhoa)
-              if(coor.ne.2) call put_var(nout,'rho','rho','',4,ierr,
-     &                                    itau,rhop)
-              if(fstats*ff-fichsize.eq.0) then
-                if(coor.ne.1) call put_var(nout,'rho_sd','rho_sd','',
-     &                                      4,ierr,itau,rhoa_sd)
-                if(coor.ne.2) call put_var(nout,'rho_sd','rho_sd','',
-     &                                      4,ierr,itau,rhop_sd)
-              endif
-            endif
-            if(varout(i).eq.6 .or. varoutsize.eq.6) then
-              do iq=1,varspecsize
-                j=varspec(iq)
-                if(coor.ne.1) call put_var(nout,'n_'//trim(noms(j)),
-     &       'n_'//trim(noms(j)),'cm-3',4,ierr,itau,nspeca(1,1,1,iq))
-                if(coor.ne.2) call put_var(nout,'n_'//trim(noms(j)),
-     &         'n_'//trim(noms(j)),'cm-3',4,ierr,itau,nspecp(1,1,1,iq))
-                if(fstats*ff-fichsize.eq.0) then
-                  if(coor.ne.1) call put_var(nout,
-     &                        'n_'//trim(noms(j))//'_sd',
-     &                        'n_'//trim(noms(j))//'_sd','cm-3',4,ierr,
-     &                           itau,nspeca_sd(1,1,1,iq))
-                  if(coor.ne.2) call put_var(nout,
-     &                        'n_'//trim(noms(j))//'_sd',
-     &                        'n_'//trim(noms(j))//'_sd','cm-3',4,ierr,
-     &                           itau,nspecp_sd(1,1,1,iq))
-                endif
-              enddo
-            endif     
-          enddo
-        endif !endif writing data on Netcdf file 
-
-c Output at each time-step, ASCII file for IDL
-! =================================================================
-c In pressure and zareoid coordinates:
-
-      if (sor .ne. 1) then
-       do n=1,varoutsize
-         if(varout(n).eq.1) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(k,124) ((Tp(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1) then
-               k=1221+n
-               write(k,124) ((Ta(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.2) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(k,124) ((up(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1)then
-               k=1221+n
-               write(k,124) ((ua(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif 
-         if(varout(n).eq.3) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(k,124) ((vp(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1) then
-               k=1221+n
-               write(k,124) ((va(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.4) then
-           do l=1,llm
-             if(coor.ne.2) then
-               k=121+n
-               write(122,124) ((wp(i,j,l),i=1,iim),j=1,jjp1)
-             elseif(coor.ne.1) then
-               k=1221+n
-               write(k,124) ((wa(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.5) then
-           do l=1,llm
-            if(coor.ne.2) then
-              k=121+n
-              write(k,124) ((rhop(i,j,l),i=1,iim),j=1,jjp1)
-            elseif(coor.ne.1) then
-               k=1221+n
-              write(k,124) ((rhoa(i,j,l),i=1,iim),j=1,jjp1)
-             endif
-           enddo
-         endif
-         if(varout(n).eq.6) then
-           do iq=1,varspecsize
-             do l=1,llm
-               if(coor.ne.1) then
-                 k=1221+n+(iq-1)
-                 write(k,124) ((nspeca(i,j,l,iq),i=1,iim),j=1,jjp1)
-               endif
-             enddo
-           enddo
-         endif     
-       enddo
-c       k=k+1
-c       do l=1,llm
-c         if(coor.ne.1)write(k,124) ((euva(i,j,l),i=1,iim),j=1,jjp1)
-c       enddo
-c       k=k+1
-c       do l=1,llm
-c         if(coor.ne.1)write(k,124) ((cona(i,j,l),i=1,iim),j=1,jjp1)
-c       enddo
-c       k=k+1
-c       do l=1,llm
-c         if(coor.ne.1)write(k,124) ((nira(i,j,l),i=1,iim),j=1,jjp1)
-c       enddo
-      endif
-124   format(12(e10.4,1x))
-
-
-       ENDDO		!LOOP in TIME
-! =================================================================
-
- 900   continue
-
-
-c  ECRITURE FINALE si besoin
-c  *************************
-      ierr= NF_CLOSE(nid)
-      ierr=NF_CLOSE(nout)
-      close (33)
-      close (122)
-      close (1222)
-       
-      ENDDO		!LOOP in FILES
-! =================================================================
-
-9999  PRINT*,'Fin '
-1000  format(a5,3x,i4,i3,x,a39)
-7777  FORMAT ('latitude/longitude',4f7.1)
-
-      END
-
-c*******************************************************
-
-      subroutine  xsig2p (ps,qsig,pref,npref,qp)
-      IMPLICIT NONE
-c=======================================================================
-c
-c   Francois Forget    Avril 1996
-c
-c Cette subroutine calcule les champs interpole en niveaux de pression
-c different niveaux de pression pref
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "comconst.h"
-
-c
-c  ARGUMENTS
-c  ---------
-
-c Inputs:
-      
-      REAL qsig(iip1,jjp1,llm)
-      REAL ps(iip1,jjp1)
-      integer npref
-      real pref(npref)
-
-c outputs
-      REAL qp(iip1,jjp1,npref)
-
-
-c Variables du modele
-c -------------------
-
-      REAL lnp(llm)  , q(llm)
-      REAL x,y
-      INTEGER i,j,l ,n
-
-
-      logical firstcall
-      save firstcall
-      data firstcall/.true./
- 
-#include "fxyprim.h"
-c**********************************************************************
-         if (firstcall) then
-           write(*,*) 'kappa = ', kappa
-           write(*,*) 'cpp = ', cpp
-           firstcall = .false.
-         end if
-
-        DO j=1,jjp1
-          DO i=1,iip1
-            do l=1,llm
-              lnp(l) = -log(aps(l)+bps(l)*ps(i,j))
-              q(l) = qsig(i,j,l)
-            end do
-            do n =1,npref
-              if ( (pref(n).le.ps(i,j)) .and.
-     &          (pref(n).ge.(ps(i,j)*bps(llm)+aps(llm))) ) then
-                    x = -log(pref(n))
-                    call interpolf(x,y,lnp,q,llm)
-                    qp(i,j,n) = y
-              else
-                    qp(i,j,n) = 1E+20 
-              end if
-            end do
-          ENDDO
-        ENDDO
-
-      return
-      end 
-
-      subroutine  missing_value(nout,nvarid,valid_range,missing)
-      IMPLICIT NONE
-c=======================================================================
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-      include "netcdf.inc"
-
-      INTEGER nout,nvarid,ierr
-      REAL missing
-      REAL valid_range(2)
-c
-c  ARGUMENTS
-c  ---------
-
-c Inputs:
-      
-             ierr= NF_PUT_ATT_REAL(nout,nvarid,'valid_range',
-     $  NF_FLOAT,2,valid_range)
-        IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, 'anl_NC: valid_range attribution failed'
-            WRITE(*,*) 'NF_NOERR', NF_NOERR
-            CALL abort
-        ENDIF
-
-#ifdef NC_DOUBLE
-             ierr= NF_PUT_ATT_DOUBLE(nout,nvarid,'missing_value',
-     $  NF_DOUBLE,1,missing)
-#else
-              ierr= NF_PUT_ATT_REAL(nout,nvarid,'missing_value',
-     $  NF_FLOAT,1,missing)
-
-#endif
-
-        IF (ierr.NE.NF_NOERR) THEN
-            PRINT*, 'anl_NC: missing value attribution failed'
-            WRITE(*,*) 'NF_NOERR', NF_NOERR
-            CALL abort
-        ENDIF
-      return
-      end
-**********************************************************
-      subroutine lect_var(nid,name,nbdim,ierr,itau,
-     $ var)
-      IMPLICIT NONE
-c=======================================================================
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-#include "netcdf.inc"
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "comconst.h"
-
-c inputs
-      character (len=*) :: name
-      INTEGER nid,nbdim,nvarid,ierr,itau
-      integer, dimension(nbdim) :: edges,corner
-c output var
-      integer, dimension(nbdim) :: var
-c  ---------
-        if (nbdim.eq.4) then
-         corner=(/1,1,1,itau/)
-         edges=(/iip1,jjp1,llm,1/)
-        endif
-
-        if (nbdim.eq.3) then
-            corner=(/1,1,itau/)
-            edges=(/iip1,jjp1,1/)
-        endif
-
-
-          ierr = NF_INQ_VARID (nid,adjustl(name), nvarid)
-#ifdef NC_DOUBLE
-          ierr = NF_GET_VARA_DOUBLE(nid, nvarid,corner,edges, var)
-#else
-          ierr = NF_GET_VARA_REAL(nid, nvarid,corner,edges, var)
-#endif
-          IF (ierr.NE.NF_NOERR) THEN
-            write(*,*) 'anl_NC: reading failed for ', name
-            CALL abort
-          ENDIF
-
-      return
-      end
-
-
-      subroutine put_var(nout,name,title,units,nbdim,ierr,itau,
-     $ var)
-      IMPLICIT NONE
-c=======================================================================
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-#include "netcdf.inc"
-#include "dimensions.h"
-#include "paramet.h"
-#include "comgeom.h"
-#include "comvert.h"
-#include "comconst.h"
-
-      character (len=*) :: title,units,name
-      INTEGER nout,nbdim,nvarid,ierr,itau
-      integer, dimension(nbdim) :: edges,corner,id,var
-      REAL valid_range(2)
-      DATA valid_range /0., 300.0/
-c  ---------
-        if (nbdim.eq.4) then
-         ierr= NF_INQ_DIMID(nout,"longitude",id(1))
-         ierr= NF_INQ_DIMID(nout,"latitude",id(2))
-         ierr= NF_INQ_DIMID(nout,"altitude",id(3))
-         ierr= NF_INQ_DIMID(nout,"Time",id(4))
-         corner=(/1,1,1,itau/)
-         edges=(/iip1,jjp1,llm,1/)
-        endif
-
-        if (nbdim.eq.3) then
-             ierr= NF_INQ_DIMID(nout,"longitude",id(1))
-             ierr= NF_INQ_DIMID(nout,"latitude",id(2))
-             ierr= NF_INQ_DIMID(nout,"Time",id(3))
-            corner=(/1,1,itau/)
-            edges=(/iip1,jjp1,1/)
-        endif
-
-
-        ierr = NF_INQ_VARID (nout,adjustl(name), nvarid)
-          if (ierr /= NF_NOERR) then
-!  choix du nom des coordonnees
-! Creation de la variable si elle n'existait pas
-             write (*,*) "====================="
-             write (*,*) "creation de  ",name
-         call def_var(nout,adjustl(title),adjustl(name),adjustl(units),
-     $   nbdim,id,nvarid,ierr)
-          if (name.eq.'temp') then
-             ierr = NF_REDEF (nout)
-             call missing_value(nout,nvarid,valid_range,1E+20)
-             ierr = NF_ENDDEF(nout)
-          endif
-          endif
-#ifdef NC_DOUBLE
-        ierr = NF_PUT_VARA_DOUBLE(nout,nvarid,corner,edges,var)
-#else
-        ierr = NF_PUT_VARA_REAL(nout,nvarid,corner,edges,var)
-#endif
-        IF (ierr.NE.NF_NOERR) THEN
-            write(*,*) 'anl_NC: writing failed for ',name
-            CALL abort
-        ENDIF
-
-                
-      return
-      end
-
-
-      Subroutine interpolf(x,y,xd,yd,nd)
-
-c******************************************************
-c   SUBROUTINE   (interpol)
-c interpolation, give y = f(x) with array xd,yd known, size nd
-
-c  Version with CONSTANT values oustide limits
-c**********************************************************
-
-
-c Variable declaration
-c --------------------
-c  Arguments :
-      real x,y
-      real xd(*),yd(*)
-      integer nd
-c  internal
-      integer i,j
-      real y_undefined
-
-c run
-c ---
-c      y_undefined=-999.999
-      y_undefined=1.e20
-
-      y=0.
-      if ((x.le.xd(1)).and.(x.le.xd(nd))) then
-        if (xd(1).lt.xd(nd)) y = y_undefined ! yd(1)
-        if (xd(1).ge.xd(nd)) y = y_undefined ! yd(nd)
-      else if ((x.ge.xd(1)).and.(x.ge.xd(nd))) then
-        if (xd(1).lt.xd(nd)) y = y_undefined ! yd(nd)
-        if (xd(1).ge.xd(nd)) y = y_undefined ! yd(1)
-c       y = yd(nd)
-      else
-        do i=1,nd-1
-         if ( ( (x.ge.xd(i)).and.(x.lt.xd(i+1)) )
-     &     .or. ( (x.le.xd(i)).and.(x.gt.xd(i+1)) ) ) then
-           y=yd(i)+(x-xd(i))*(yd(i+1)-yd(i))/(xd(i+1)-xd(i))
-           goto 99
-         end if
-        end do
-      end if
-
-c     write (*,*)' x , y' , x,y
-c     do i=1,nd
-c       write (*,*)' i, xd , yd' , xd(i),yd(i)
-c     end do
-c     stop
-
- 99   continue
-
-      end
Index: unk/LMDZ.MARS/libf/dyn3d/anldoppler2.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/anldoppler2.F	(revision 1035)
+++ 	(revision )
@@ -1,380 +1,0 @@
-      PROGRAM anldoppler2
-      IMPLICIT NONE
-c======================================================================
-c
-c
-c Programme pour analyser vent a heure locale fixee
-c a partir d'un fichier Netcdf de la MCD
-c
-c=======================================================================
-c-----------------------------------------------------------------------
-c   declarations:
-c   -------------
-
-
-#include "dimensions.h"
-#include "paramet.h"
-#include "comconst.h"
-#include "comdissip.h"
-#include "comvert.h"
-#include "comgeom2.h"
-#include "logic.h"
-#include "temps.h"
-#include "control.h"
-#include "ener.h"
-#include "netcdf.inc"
-#include "description.h"
-
-
-      INTEGER point
-      PARAMETER(point=11)     		! nbre de points d''observation
-      real olon(point),olat(point)	! Coordonnees des points observes
-      INTEGER iraie                	! pour le choix de la raie du CO
-
-c--------------------------------------------------------
-c coordonees lon/lat des points observes
-c--------------------------------------------------------
-
-c     ANNEE 2001
-
-      DATA olon/0,-30,30,0,-90,90,-75,75,0,-70,70/
-      DATA olat/-1,0,0,40,0,0,40,40,90,-40,40/
-
-c     ANNEE 1999
-
-c      DATA olon/0,0,-30,30,-85,85,0,-90,90,0,-65,65,0/
-c      DATA olat/18,-10,0,0,0,0,55,40,40,90,-40,-40,-70/
-
-c     ANNEE 1997
-
-c      DATA olon/0,-85,85,0,0/
-c      DATA olat/24,0,0,90,-70/
-
-c     ANNEE 1992
-
-c      DATA olon/0,-85,85,0,0,-75,75,-90,90,0,0/
-c      DATA olat/8,0,0,-40,40,-40,-40,40,40,90,-90/
-
-c     ANNEE 1990
-
-c      DATA olon/0,-90,90,0,0/
-c      DATA olat/-1,0,0,70,-90/
-
-c     ANNEE 1988
-
-c      DATA olon/0,-90,90,0,0,0,-35,35,0,0,-45,45,-60,60/
-c      DATA olat/-21,0,0,-90,60,0,0,0,-35,25,-35,-35,25,25/
-
-c----------------------------------------------------------
-
-      INTEGER mcdreadnc
-      external mcdreadnc
-      INTEGER itau,nbpas,nbpasmx
-      PARAMETER(nbpasmx=1000000)
-      REAL temps(nbpasmx)
-      INTEGER unitlec
-      INTEGER i,j,l,itautot
-
-c   Declarations DRS:
-c   -----------------
-      INTEGER ierr, dimtype
-      CHARACTER*120 dimsou, dimnam*16, dimtit*80
-      CHARACTER*40 dimunit
-      CHARACTER*100  varname
-
-c   variables meteo dans la grille verticale GCM
-c   --------------------------------------------
-      REAL v(iip1,jjp1,llm),u(iip1,jjp1,llm)
-      REAL t(iip1,jjp1,llm)
-      REAL ps(iip1,jjp1) , tsurf(iip1,jjp1)
-
-c   variables meteo en coordonnee de pression
-c   --------------------------------------------
-      REAL vp(iip1,jjp1,llm),up(iip1,jjp1,llm)
-      REAL tp(iip1,jjp1,llm)
-
-c     Niveaux de pression (Pa)
-      real pref(llm)
-
-c     version 25 couches
-
-c      data pref/1291.37,1005.720,783.255,600.,475.069,350.,
-c     &          288.144,174.768,106.002,64.2935,38.9960,
-c     &          23.6523,14.3458,8.70000,5.28000,3.20000,
-c     &          1.94000,1.18000,0.714000,0.433000,0.263000,
-c     &          0.118000,0.0614000,0.0333000,0.0163000/
-
-c     version 32 couches
-
-      data pref/1291.37,1005.720,783.255,600.,475.069,350.,
-     &          288.144,174.768,106.002,64.2935,38.9960,
-     &          23.6523,14.3458,8.70000,5.28000,3.20000,
-     &          1.94000,1.18000,0.714000,0.433000,0.263000,
-     &          0.118000,0.0614000,0.0333000,0.0163000, 
-     &          8.e-3,4.e-3,2.e-3,1.e-3,5.e-4,2.e-4,1.e-4/
-
-c   Local:
-c   ------
-      REAL phis(iip1,jjp1)
-      real utime,latst,lonst,tamp,hlst
-      real localtime(iip1),heure(iip1)
-      common/temporaire/localtime
-
-      INTEGER*4 day0
-c      integer nmoy(jjp1,llm),tp1,tp2,pass
-	
-
-      CHARACTER*1 yes
-
-      LOGICAL ldrs
-      integer iformat,nid
-       
-c   declarations de l'interface avec mywrite:
-c   -----------------------------------------
-
-      CHARACTER file*80
-      CHARACTER nomfich*60
-
-c   externe:
-c   --------
-
-      EXTERNAL iniconst,inigeom,covcont,mywrite
-      EXTERNAL inifilr,exner
-      EXTERNAL solarlong,coordij,moy2
-      EXTERNAL SSUM
-      REAL SSUM
-      EXTERNAL lnblnk
-      INTEGER lnblnk
-      logical icdf,idrs
-
-c   Dust
-c   ----
-
-#include "fxyprim.h"
-
-c-----------------------------------------------------------------------
-c   initialisations:
-c   ----------------
-
-      ldrs=.true.
-      unitlec=11
-      itautot=0
-      idrs=.false.
-      icdf=.false.
-
-c     Lecture du fichier a lire
-c     -------------------------
-
-      PRINT*,'entrer le nom du fichier NetCDF de la MCD'
-      READ(5,'(a)') nomfich
-      file=nomfich(1:lnblnk(nomfich))
-      PRINT*,'file',file
-
-
-c     Lecture des autres parametres du programme
-c     ------------------------------------------
-
-      write(*,*) 'Raie a simuler ? '
-      write(*,*)'[1]12CO(2-1) [2]:13CO(2-1) ',
-     &     ' [3]:12CO(1-0) [4]13CO(1-0) [5]H2O(183)'  
-      read(*,*) iraie
-
-      write(*,*) 'heure local du point subterrestre ? '
-      read(*,*) hlst
-
-      write(*,*) 'latitude du point subterrestre ? '
-      read(*,*) latst
-
-c---------------------------------------------------------
-c   Lecture des fichiers stats , diagfi ou histmoy
-c---------------------------------------------------------
-
-800   continue ! LOOP SUR LES FICHIERS
-
-c     Ouverture fichiers :
-c     ------------------
-
-c        Ouverture fichier NetCDF
-            ierr = NF_OPEN (file(1:lnblnk(file))//'.nc', NF_NOWRITE,nid)
-            IF (ierr.NE.NF_NOERR) THEN
-              write(6,*)' Pb d''ouverture du fichier ',file
-              write(6,*)' ierr = ', ierr
-              CALL abort
-            ENDIF
-     
-c----------------------------------------------------------------------
-c   initialisation de la physique:
-c   ------------------------------
-
-c initialisations aux valeurs martiennes
-
-      rad=3397200.              ! rayon de mars (m)  ~3397200 m
-      daysec=88775.             ! duree du sol (s)  ~88775 s
-      omeg=4.*asin(1.)/(daysec) ! vitesse de rotation (rad.s-1)
-      g=3.72                    ! gravite (m.s-2) ~3.72
-      mugaz=43.49               ! Masse molaire de l''atm (g.mol-1) ~43.49
-      kappa=.256793             ! = r/cp  ~0.256793
-      r = 191.18213
-      pi=2.*asin(1.)
-      ecritphy =1
-      iphysiq=1
-      day_ini=0.
-      day_step=1
-   
-      WRITE (*,*) 'day0 = ' , day0
-
-      CALL iniconst
-      CALL inigeom
-      CALL inifilr
-
-c   sigma aux niveaux s:
-
-      DO l=1,llm
-         print*,'sig_s(',l,')  =  ',sig_s(l)
-      ENDDO
-
-c      Format Grads (Stats) : On suppose que l'on a 12 pas de temps :
-c      --------------------
-
-      nbpas=12
-      print*,'nbpas=',nbpas
-
-c======================================================================
-c   debut de la boucle sur les etats dans un fichier histoire:
-c======================================================================
-
-       itau= 1
-
-801    continue ! LOOP SUR LES PAS DE TEMPS START HERE
-
-       varname='u'
-       ierr =mcdreadnc(nid,varname,llm,u,itau)
-       varname='v'
-       ierr =mcdreadnc(nid,varname,llm,v,itau)
-       varname='temp'
-       ierr =mcdreadnc(nid,varname,llm,t,itau)
-       varname='ps'
-       ierr =mcdreadnc(nid,varname,1,ps,itau)
-c      PRINT*,'ps',ps(iip1/2,jjp1/2)
-       varname='tsurf'
-       ierr =mcdreadnc(nid,varname,1,tsurf,itau)
-c      PRINT*,'tsurf',tsurf(iip1/2,jjp1/2)
-
-c**********************************************************
-c  Traitement des donnees : (we are in LOOP on timestep)
-c**********************************************************
-
-
-c universal time (in stats file)
-c-------------------------------
-      utime = (itau-1)*2.
-
-c Longitude du point subterrestre
-c -------------------------------
-
-      tamp=(hlst-utime)*(iip1/24.)
-      if(tamp.GT.iip1) then
-      tamp=tamp-iip1
-      endif
-      if(tamp.LT.0)  then
-      tamp=iip1+tamp
-      endif
-      lonst=rlonv(nint(tamp))*180./pi
-      write(*,*) hlst,latst,lonst
-
-       lonst=(hlst-utime)*15
-       if(lonst.gt.180) lonst=lonst-180.
-       if(lonst.lt.-180) lonst=lonst+180.
-       write(*,*) hlst,latst,lonst
-
-c Local time
-c ----------
-
-c local time (in stats file)
-            DO i = 1,iim
-              localtime(i)=utime + 12.*rlonv(i)/pi
-              if(localtime(i).gt.24) localtime(i)=localtime(i)-24.
-              if(localtime(i).lt.0) localtime(i)=localtime(i)+24.
-	      heure(i)=localtime(i)
-c	      if(itau.EQ.1) heure(i)=0.375*(i-1)
-c	      if(itau.EQ.1) print*,heure(i)
-            ENDDO
-
-c              if(itau.EQ.1) heure(iip1)=24.
-	       heure(iip1)=localtime(1)
-
-c ******************************************
-
-
-c c Passage en niveaux de pression
-c --------------------------------
-
-          call xsig2p (ps,T,pref,llm,Tp)
-          call xsig2p (ps,u,pref,llm,up)
-          call xsig2p (ps,v,pref,llm,vp)
-
-c         Test temporaire
-c          do l=1, llm
-c             write(77,*) pref(l),up(1,1,l)
-c          end do
-
-c Traitement des donnees -> creation de spectres synthetiques
-c -----------------------------------------------------------
-
-c calcul des vitesses projetees
-
-      do l=1,llm
-         do j=1,jjp1
-            do i=1,iip1
-
-
-               up(i,j,l)=(242.*cos(rlatu(j))+up(i,j,l))*
-     .              sin(rlonv(i)-lonst*pi/180)*cos(latst*pi/180)
-
-
-           vp(i,j,l)=vp(i,j,l)*(cos(rlonv(i)-lonst*pi/180)*sin(rlatu(j))
-     .    *cos(latst*pi/180)-sin(latst*pi/180)*cos(rlatu(j)))
-
-
-            enddo
-         enddo
-      enddo
-
-c synthese des spectres
-
-c	print*,'itau=',itau,nbpas
-
-      call spectre2(itau,iraie,latst,lonst,olon,olat,
-     .vp,up,tp,ps,tsurf)
-
-
-	
-c  Fin de la boucle sur les pas de temps ? : (we are in LOOP on timestep)
-c  ****************************************
-
-      itau=itau+1
-
-      if(itau.gt.nbpas) then
-         ierr = NF_CLOSE(nid)
-         write(*,*) 'Si vous voulez entrer un nouveau fichier'
-         print*,'entrez son nom. Sinon, RETURN'
-            READ(5,'(a)') nomfich
-         if (nomfich(1:lnblnk(nomfich)).eq."") then
-            print*,'OK, on termine la'
-         else
-            file=nomfich(1:lnblnk(nomfich))
-            PRINT*,'file',file
-            goto 800
-         endif
-      else
-         goto 801
-      endif
-
- 900   continue
-
-
-9999  PRINT*,'Fin '
-1000  format(a5,3x,i4,i3,x,a39)
-7777  FORMAT ('latitude/longitude',4f7.1)
-
-      END
Index: /trunk/LMDZ.MARS/libf/dyn3d/calfis.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/calfis.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/calfis.F	(revision 1036)
@@ -82,5 +82,5 @@
       REAL pteta(iip1,jjp1,llm)
       REAL pmasse(iip1,jjp1,llm)
-      REAL pq(iip1,jjp1,llm,nqmx)
+      REAL pq(iip1,jjp1,llm,nq)
       REAL pphis(iip1,jjp1)
       REAL pphi(iip1,jjp1,llm)
@@ -89,5 +89,5 @@
       REAL pducov(iip1,jjp1,llm)
       REAL pdteta(iip1,jjp1,llm)
-      REAL pdq(iip1,jjp1,llm,nqmx)
+      REAL pdq(iip1,jjp1,llm,nq)
 c
       REAL pw(iip1,jjp1,llm)
@@ -100,5 +100,5 @@
       REAL pdufi(iip1,jjp1,llm)
       REAL pdhfi(iip1,jjp1,llm)
-      REAL pdqfi(iip1,jjp1,llm,nqmx)
+      REAL pdqfi(iip1,jjp1,llm,nq)
       REAL pdpsfi(iip1,jjp1)
       logical tracer
@@ -113,10 +113,10 @@
 c
       REAL zufi(ngridmx,llm), zvfi(ngridmx,llm)
-      REAL ztfi(ngridmx,llm),zqfi(ngridmx,llm,nqmx)
+      REAL ztfi(ngridmx,llm),zqfi(ngridmx,llm,nq)
 c
       REAL zvervel(ngridmx,llm)
 c
       REAL zdufi(ngridmx,llm),zdvfi(ngridmx,llm)
-      REAL zdtfi(ngridmx,llm),zdqfi(ngridmx,llm,nqmx)
+      REAL zdtfi(ngridmx,llm),zdqfi(ngridmx,llm,nq)
       REAL zdpsrf(ngridmx)
 c
@@ -185,5 +185,5 @@
          airefi(ngridmx)=airefi(ngridmx)*iim
 
-         CALL inifis(ngridmx,llm,day_ini,daysec,dtphys,
+         CALL inifis(ngridmx,llm,nq,day_ini,daysec,dtphys,
      .                latfi,lonfi,airefi,rad,g,r,cpp)
       ENDIF
@@ -275,5 +275,5 @@
 c   43.bis Taceurs (en kg/kg)
 c   --------------------------
-      DO iq=1,nqmx
+      DO iq=1,nq
          DO l=1,llm
             zqfi(1,l,iq) = pq(1,1,l,iq)
@@ -466,5 +466,5 @@
 c   ---------------------
 
-      DO iq=1,nqmx
+      DO iq=1,nq
          DO l=1,llm
             DO i=1,iip1
Index: /trunk/LMDZ.MARS/libf/dyn3d/dynetat0.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/dynetat0.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/dynetat0.F	(revision 1036)
@@ -3,4 +3,5 @@
       
       use netcdf
+      use infotrac, only: tnom
       
       IMPLICIT NONE
@@ -37,5 +38,5 @@
 #include "serre.h"
 #include "logic.h"
-#include "advtrac.h"
+!#include "advtrac.h"
 #include "control.h"
 
@@ -380,5 +381,5 @@
 !           WRITE(str3(2:3),'(i2.2)') iq
 !           ierr =  NF_INQ_VARID (nid, str3, nvarid)
-! NB: tracers are now read in using their name ('tnom' from advtrac.h)
+! NB: tracers are now read in using their name ('tnom' from infotrac)
 !           write(*,*) "  loading tracer:",trim(tnom(iq))
            ierr=nf90_inq_varid(nid,tnom(iq),nvarid)
@@ -404,9 +405,9 @@
 c        case when new tracer are added in addition to old ones
              write(*,*)'tracers 1 to ', nqold,'were already present'
-             write(*,*)'tracers ', nqold+1,' to ', nqmx,'are new'
+             write(*,*)'tracers ', nqold+1,' to ', nq,'are new'
 !             yes=' '
 !            do while ((yes.ne.'y').and.(yes.ne.'n'))
 !             write(*,*) 'Would you like to reindex tracer # 1 ->',nqold
-!             write(*,*) 'to #',nqmx-nqold+1,'->', nqmx,'   (y or n) ?'
+!             write(*,*) 'to #',nq-nqold+1,'->', nq,'   (y or n) ?'
 !             read(*,fmt='(a)') yes
 !            end do
@@ -416,8 +417,8 @@
 !                do j=1,jjp1
 !                  do i=1,iip1
-!                    do iq=nqmx,nqmx-nqold+1,-1
-!                       q(i,j,l,iq)=q(i,j,l,iq-nqmx+nqold)   
+!                    do iq=nq,nq-nqold+1,-1
+!                       q(i,j,l,iq)=q(i,j,l,iq-nq+nqold)   
 !                    end do
-!                    do iq=nqmx-nqold,1,-1
+!                    do iq=nq-nqold,1,-1
 !                       q(i,j,l,iq)= 0.
 !                    end do
Index: /trunk/LMDZ.MARS/libf/dyn3d/dynredem.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/dynredem.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/dynredem.F	(revision 1036)
@@ -1,3 +1,4 @@
       SUBROUTINE dynredem0(fichnom,idayref,anneeref,phis,nq)
+      use infotrac, only: tnom
       IMPLICIT NONE
 c=======================================================================
@@ -17,5 +18,5 @@
 #include "description.h"
 #include "serre.h"
-#include "advtrac.h"
+!#include "advtrac.h"
 c   Arguments:
 c   ----------
@@ -963,4 +964,5 @@
       SUBROUTINE dynredem1(fichnom,time,
      .                     vcov,ucov,teta,q,nq,masse,ps)
+      use infotrac, only: nqtot, tnom
       IMPLICIT NONE
 c=================================================================
@@ -973,5 +975,5 @@
 #include "comvert.h"
 #include "comgeom.h"
-#include"advtrac.h"
+!#include"advtrac.h"
 
       INTEGER nq, l
@@ -979,5 +981,5 @@
       REAL teta(ip1jmp1,llm)                   
       REAL ps(ip1jmp1),masse(ip1jmp1,llm)                   
-      REAL q(iip1,jjp1,llm,nqmx)
+      REAL q(iip1,jjp1,llm,nqtot)
       REAL q3d(iip1,jjp1,llm) !temporary variable
       CHARACTER*(*) fichnom
Index: /trunk/LMDZ.MARS/libf/dyn3d/gcm.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/gcm.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/gcm.F	(revision 1036)
@@ -1,4 +1,5 @@
       PROGRAM gcm
 
+      use infotrac, only: iniadvtrac, nqtot, iadv
       IMPLICIT NONE
 
@@ -48,5 +49,5 @@
 #include "tracstoke.h"
 #include "sponge.h"
-#include"advtrac.h"
+!#include"advtrac.h"
 
       INTEGER*4  iday ! jour julien
@@ -57,5 +58,5 @@
       REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
       real, dimension(ip1jmp1,llm) :: teta   ! temperature potentielle 
-      REAL q(ip1jmp1,llm,nqmx)               ! champs advectes
+      REAL,allocatable :: q(:,:,:)           ! champs advectes
       REAL ps(ip1jmp1)                       ! pression  au sol
       REAL pext(ip1jmp1)                     ! pression  extensive
@@ -80,5 +81,6 @@
 c   tendances dynamiques
       REAL dv(ip1jm,llm),du(ip1jmp1,llm)
-      REAL dteta(ip1jmp1,llm),dq(ip1jmp1,llm,nqmx),dp(ip1jmp1)
+      REAL dteta(ip1jmp1,llm),dp(ip1jmp1)
+      REAL,ALLOCATABLE :: dq(:,:,:)
 
 c   tendances de la dissipation
@@ -88,5 +90,6 @@
 c   tendances physiques
       REAL dvfi(ip1jm,llm),dufi(ip1jmp1,llm)
-      REAL dhfi(ip1jmp1,llm),dqfi(ip1jmp1,llm,nqmx),dpfi(ip1jmp1)
+      REAL dhfi(ip1jmp1,llm),dpfi(ip1jmp1)
+      REAL,ALLOCATABLE :: dqfi(:,:,:)
 
 c   variables pour le fichier histoire
@@ -95,5 +98,4 @@
       REAL tppn(iim),tpps(iim),tpn,tps
 c
-!      INTEGER iadv(nqmx) ! indice schema de transport pour le traceur iq
 
       INTEGER itau,itaufinp1,iav
@@ -124,5 +126,5 @@
       LOGICAL tracer
 	  data tracer/.true./
-      INTEGER nq
+!      INTEGER nq
 
 C Calendrier
@@ -142,10 +144,14 @@
 
 c-----------------------------------------------------------------------
-c  Initialize tracers using iniadvtrac (Ehouarn, oct 2008)
       CALL defrun_new( 99, .TRUE. )
 
-      CALL iniadvtrac(nq,numvanle)
-      
-      CALL dynetat0("start.nc",nqmx,vcov,ucov,
+! Initialize tracers
+      call iniadvtrac(nqtot,numvanle)
+! Allocation de la tableau q : champs advectes   
+      allocate(q(ip1jmp1,llm,nqtot))
+      allocate(dq(ip1jmp1,llm,nqtot))
+      allocate(dqfi(ip1jmp1,llm,nqtot))
+
+      CALL dynetat0("start.nc",nqtot,vcov,ucov,
      .              teta,q,masse,ps,phis,time_0)
 
@@ -245,5 +251,5 @@
      . 'c''est a dire du jour',i7,3x,'au jour',i7//)
 
-      CALL dynredem0("restart.nc",day_ini,anne_ini,phis,nqmx)
+      CALL dynredem0("restart.nc",day_ini,anne_ini,phis,nqtot)
 
       ecripar = .TRUE.
@@ -253,5 +259,5 @@
 
 c   Quelques initialisations pour les traceurs
-      call initial0(ijp1llm*nqmx,dq)
+      dq(:,:,:)=0
 c     istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
 c     istphy=istdyn/iphysiq
@@ -348,10 +354,10 @@
        IF( forward. OR . leapf )  THEN
 
-        DO iq = 1, nqmx
+        DO iq = 1, nqtot
 c
          IF ( iadv(iq).EQ.1.OR.iadv(iq).EQ.2 )  THEN
             CALL traceur( iq,iadv,q,teta,pk,w, pbaru, pbarv, dq )
 
-         ELSE IF( iq.EQ. nqmx )   THEN
+         ELSE IF( iq.EQ. nqtot )   THEN
 c
             iapp_tracvl = 5
@@ -361,5 +367,5 @@
 c
 
-            CALL vanleer(numvanle,iapp_tracvl,nqmx,q,pbaru,pbarv,
+            CALL vanleer(numvanle,iapp_tracvl,nqtot,q,pbaru,pbarv,
      *                      p, masse, dq,  iadv(1), teta, pk     )
 
@@ -422,5 +428,5 @@
            ENDIF
 c
-        CALL calfis( nqmx, lafin ,rdayvrai,rday_ecri,time  ,
+        CALL calfis( nqtot, lafin ,rdayvrai,rday_ecri,time  ,
      $                 ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
      $     du,dv,dteta,dq,w, dufi,dvfi,dhfi,dqfi,dpfi,tracer)
@@ -429,5 +435,5 @@
 c      ajout des tendances physiques:
 c      ------------------------------
-          CALL addfi( nqmx, dtphys, leapf, forward   ,
+          CALL addfi( nqtot, dtphys, leapf, forward   ,
      $                  ucov, vcov, teta , q   ,ps , masse,
      $                 dufi, dvfi, dhfi , dqfi ,dpfi  )
@@ -540,5 +546,5 @@
 c                 iav=0
 c              ENDIF
-c              CALL writedynav(histaveid, nqmx, itau,vcov ,
+c              CALL writedynav(histaveid, nqtot, itau,vcov ,
 c    ,                          ucov,teta,pk,phi,q,masse,ps,phis)
 c           ENDIF
@@ -556,5 +562,5 @@
      .  ' date=',REAL(itau)/REAL(day_step)
        CALL dynredem1("restart.nc",REAL(itau)/REAL(day_step),
-     .                vcov,ucov,teta,q,nqmx,masse,ps)
+     .                vcov,ucov,teta,q,nqtot,masse,ps)
      
       CLOSE(99)
@@ -625,5 +631,5 @@
                   iav=0
                ENDIF
-c              CALL writedynav(histaveid, nqmx, itau,vcov ,
+c              CALL writedynav(histaveid, nqtot, itau,vcov ,
 c    ,                          ucov,teta,pk,phi,q,masse,ps,phis)
 
@@ -636,5 +642,5 @@
               CALL dynredem1("restart.nc",
      .                REAL(itau)/REAL(day_step),
-     .                vcov,ucov,teta,q,nqmx,masse,ps)
+     .                vcov,ucov,teta,q,nqtot,masse,ps)
      
               forward = .TRUE.
Index: /trunk/LMDZ.MARS/libf/dyn3d/infotrac.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/infotrac.F90	(revision 1036)
+++ /trunk/LMDZ.MARS/libf/dyn3d/infotrac.F90	(revision 1036)
@@ -0,0 +1,135 @@
+MODULE infotrac
+
+IMPLICIT NONE
+! nqtot : total number of tracers and higher order of moment, water vapor and liquid included
+  INTEGER, SAVE :: nqtot
+  INTEGER,allocatable :: iadv(:)   ! tracer advection scheme number
+  CHARACTER(len=20),allocatable ::  tnom(:) ! tracer name
+
+CONTAINS
+
+      subroutine iniadvtrac(nq,numvanle)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! routine which initializes tracer names and advection schemes
+! reads these infos from file 'traceur.def' but uses default values
+! if that file is not found.
+! Ehouarn Millour. Oct. 2008  (made this LMDZ4-like) for future compatibility 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      IMPLICIT NONE
+
+#include "dimensions.h"
+!#include "advtrac.h"
+#include "control.h"
+
+! routine arguments:
+      INTEGER,INTENT(out) :: nq ! number of tracers
+      INTEGER,INTENT(out) :: numvanle
+
+! local variables:
+      LOGICAL :: first
+      INTEGER :: iq
+      INTEGER :: ierr
+      CHARACTER(len=3) :: qname
+
+! Look for file traceur.def
+      OPEN(90,file='traceur.def',form='formatted',status='old', &
+              iostat=ierr)
+      IF (ierr.eq.0) THEN
+        write(*,*) "iniadvtrac: Reading file traceur.def"
+        ! read number of tracers:
+        read(90,*,iostat=ierr) nq
+        if (ierr.ne.0) then
+          write(*,*) "iniadvtrac: error reading number of tracers"
+          write(*,*) "   (first line of traceur.def) "
+          stop
+        endif
+        
+        ! allocate arrays:
+        allocate(iadv(nq))
+        allocate(tnom(nq))
+        
+        ! initialize advection schemes to Van-Leer for all tracers
+        do iq=1,nq
+          iadv(iq)=3 ! Van-Leer
+        enddo
+        
+        do iq=1,nq
+        ! minimal version, just read in the tracer names, 1 per line
+          read(90,*,iostat=ierr) tnom(iq)
+          if (ierr.ne.0) then
+            write(*,*) 'iniadvtrac: error reading tracer names...'
+            stop
+          endif
+        enddo !of do iq=1,nq
+        close(90) ! done reading tracer names, close file
+      ENDIF ! of IF (ierr.eq.0)
+
+!  ....  Choix  des shemas d'advection pour l'eau et les traceurs  ...
+!  ...................................................................
+!
+!     iadv = 1    shema  transport type "humidite specifique LMD"  
+!     iadv = 2    shema   amont
+!     iadv = 3    shema  Van-leer
+!     iadv = 4    schema  Van-leer + humidite specifique
+!                        Modif F.Codron
+! 
+!
+      DO  iq = 1, nq-1
+       IF( iadv(iq).EQ.1 ) PRINT *,' Choix du shema humidite specifique'&
+       ,' pour le traceur no ', iq
+       IF( iadv(iq).EQ.2 ) PRINT *,' Choix du shema  amont',' pour le'  &
+       ,' traceur no ', iq
+       IF( iadv(iq).EQ.3 ) PRINT *,' Choix du shema  Van-Leer ',' pour' &
+       ,'le traceur no ', iq
+
+       IF( iadv(iq).EQ.4 )  THEN
+         PRINT *,' Le shema  Van-Leer + humidite specifique ',          &
+       ' est  uniquement pour la vapeur d eau .'
+         PRINT *,' Corriger iadv( ',iq, ')  et repasser ! '
+         CALL ABORT
+       ENDIF
+
+       IF( iadv(iq).LE.0.OR.iadv(iq).GT.4 )   THEN
+        PRINT *,' Erreur dans le choix de iadv (nqtot).Corriger et '    &
+       ,' repasser car  iadv(iq) = ', iadv(iq)
+         CALL ABORT
+       ENDIF
+      ENDDO
+
+       IF( iadv(nq).EQ.1 ) PRINT *,' Choix du shema humidite '          &
+       ,'specifique pour la vapeur d''eau'
+       IF( iadv(nq).EQ.2 ) PRINT *,' Choix du shema  amont',' pour la'  &
+       ,' vapeur d''eau '
+       IF( iadv(nq).EQ.3 ) PRINT *,' Choix du shema  Van-Leer '         &
+       ,' pour la vapeur d''eau'
+       IF( iadv(nq).EQ.4 ) PRINT *,' Choix du shema  Van-Leer + '       &
+       ,' humidite specifique pour la vapeur d''eau'
+!
+       IF( (iadv(nq).LE.0).OR.(iadv(nq).GT.4) )   THEN
+        PRINT *,' Erreur dans le choix de iadv (nqtot).Corriger et '    &
+       ,' repasser car  iadv(nqtot) = ', iadv(nqtot)
+         CALL ABORT
+       ENDIF
+
+      first = .TRUE.
+      numvanle = nq + 1
+      DO  iq = 1, nq
+        IF(((iadv(iq).EQ.3).OR.(iadv(iq).EQ.4)).AND.first ) THEN
+          numvanle = iq
+          first    = .FALSE. 
+        ENDIF
+      ENDDO
+!
+      DO  iq = 1, nq
+
+      IF( (iadv(iq).NE.3.AND.iadv(iq).NE.4).AND.iq.GT.numvanle )  THEN
+          PRINT *,' Il y a discontinuite dans le choix du shema de ',   &
+          'Van-leer pour les traceurs . Corriger et repasser . '
+           CALL ABORT
+      ENDIF
+
+      ENDDO
+!
+      end subroutine iniadvtrac
+
+END MODULE infotrac
Index: unk/LMDZ.MARS/libf/dyn3d/iniadvtrac.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/iniadvtrac.F	(revision 1035)
+++ 	(revision )
@@ -1,144 +1,0 @@
-      subroutine iniadvtrac(nq,numvanle)
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! routine which initializes tracer names and advection schemes
-! reads these infos from file 'traceur.def' but uses default values
-! if that file is not found.
-! Ehouarn Millour. Oct. 2008  (made this LMDZ4-like) for future compatibility 
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-      IMPLICIT NONE
-
-#include "dimensions.h"
-#include "advtrac.h"
-#include "control.h"
-
-! routine arguments:
-      INTEGER,INTENT(out) :: nq ! number of tracers
-      INTEGER,INTENT(out) :: numvanle
-
-! local variables:
-      LOGICAL :: first
-      INTEGER :: iq
-      INTEGER :: ierr
-      CHARACTER(len=3) :: qname
-
-! Look for file traceur.def
-      OPEN(90,file='traceur.def',form='formatted',status='old',
-     &        iostat=ierr)
-      IF (ierr.eq.0) THEN
-        write(*,*) "iniadvtrac: Reading file traceur.def"
-        ! read number of tracers:
-        read(90,*,iostat=ierr) nq
-        if (ierr.ne.0) then
-          write(*,*) "iniadvtrac: error reading number of tracers"
-          write(*,*) "   (first line of traceur.def) "
-          stop
-        else
-          ! check that the number of tracers is indeed nqmx
-          if (nq.ne.nqmx) then
-            write(*,*) "iniadvtrac: error, wrong number of tracers:"
-            write(*,*) "nq=",nq," whereas nqmx=",nqmx
-            stop
-          endif
-        endif
-        
-        ! initialize advection schemes to Van-Leer for all tracers
-        do iq=1,nq
-          iadv(iq)=3 ! Van-Leer
-        enddo
-        
-        do iq=1,nq
-        ! minimal version, just read in the tracer names, 1 per line
-          read(90,*,iostat=ierr) tnom(iq)
-          if (ierr.ne.0) then
-            write(*,*) 'iniadvtrac: error reading tracer names...'
-            stop
-          endif
-        enddo !of do iq=1,nq
-        close(90) ! done reading tracer names, close file
-      ELSE
-        write(*,*) "iniadvtrac: file traceur.def not found !"
-        write(*,*) "            using default names (q01,q02,...)",
-     &             "for tracers"
-        ! build default 'q01','q02',... names
-        DO iq=1,nqmx
-          write(qname,'(a1,i2.2)')'q',iq
-          tnom(iq)=qname
-        ENDDO
-        ! set advection scheme type to Van-Leer
-        DO iq = 1, nqmx
-         iadv( iq ) = 3    ! Van-Leer 
-        ENDDO
-        ! set value of nq to nqmx
-        nq=nqmx
-      ENDIF ! of IF (ierr.eq.0)
-
-c  ....  Choix  des shemas d'advection pour l'eau et les traceurs  ...
-c  ...................................................................
-c
-c     iadv = 1    shema  transport type "humidite specifique LMD"  
-c     iadv = 2    shema   amont
-c     iadv = 3    shema  Van-leer
-c     iadv = 4    schema  Van-leer + humidite specifique
-c                        Modif F.Codron
-c 
-c
-      DO  iq = 1, nqmx-1
-       IF( iadv(iq).EQ.1 ) PRINT *,' Choix du shema humidite specifique'
-     * ,' pour le traceur no ', iq
-       IF( iadv(iq).EQ.2 ) PRINT *,' Choix du shema  amont',' pour le'
-
-     * ,' traceur no ', iq
-       IF( iadv(iq).EQ.3 ) PRINT *,' Choix du shema  Van-Leer ',' pour'
-     * ,'le traceur no ', iq
-
-       IF( iadv(iq).EQ.4 )  THEN
-         PRINT *,' Le shema  Van-Leer + humidite specifique ',
-     * ' est  uniquement pour la vapeur d eau .'
-         PRINT *,' Corriger iadv( ',iq, ')  et repasser ! '
-         CALL ABORT
-       ENDIF
-
-       IF( iadv(iq).LE.0.OR.iadv(iq).GT.4 )   THEN
-        PRINT *,' Erreur dans le choix de iadv (nqmx).Corriger et '
-     * ,' repasser car  iadv(iq) = ', iadv(iq)
-         CALL ABORT
-       ENDIF
-      ENDDO
-
-       IF( iadv(nqmx).EQ.1 ) PRINT *,' Choix du shema humidite '
-     * ,'specifique pour la vapeur d''eau'
-       IF( iadv(nqmx).EQ.2 ) PRINT *,' Choix du shema  amont',' pour la'
-     * ,' vapeur d''eau '
-       IF( iadv(nqmx).EQ.3 ) PRINT *,' Choix du shema  Van-Leer '
-     * ,' pour la vapeur d''eau'
-       IF( iadv(nqmx).EQ.4 ) PRINT *,' Choix du shema  Van-Leer + '
-     * ,' humidite specifique pour la vapeur d''eau'
-c
-       IF( (iadv(nqmx).LE.0).OR.(iadv(nqmx).GT.4) )   THEN
-        PRINT *,' Erreur dans le choix de iadv (nqmx).Corriger et '
-     * ,' repasser car  iadv(nqmx) = ', iadv(nqmx)
-         CALL ABORT
-       ENDIF
-
-      first = .TRUE.
-      numvanle = nqmx + 1
-      DO  iq = 1, nqmx
-        IF(((iadv(iq).EQ.3).OR.(iadv(iq).EQ.4)).AND.first ) THEN
-          numvanle = iq
-          first    = .FALSE. 
-        ENDIF
-      ENDDO
-c
-      DO  iq = 1, nqmx
-
-      IF( (iadv(iq).NE.3.AND.iadv(iq).NE.4).AND.iq.GT.numvanle )  THEN
-          PRINT *,' Il y a discontinuite dans le choix du shema de ',
-     *    'Van-leer pour les traceurs . Corriger et repasser . '
-           CALL ABORT
-      ENDIF
-
-      ENDDO
-c
-
-
-      end
Index: /trunk/LMDZ.MARS/libf/dyn3d/lect_start_archive.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/lect_start_archive.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/lect_start_archive.F	(revision 1036)
@@ -1,3 +1,3 @@
-      SUBROUTINE lect_start_archive(date,tsurf,tsoil,emis,q2,
+      SUBROUTINE lect_start_archive(nqtot,date,tsurf,tsoil,emis,q2,
      &     t,ucov,vcov,ps,co2ice,h,phisold_newgrid,
      &     q,qsurf,surfith,nid)
@@ -16,5 +16,5 @@
 c
 c=======================================================================
-
+      use infotrac, only: tnom
       implicit none
 
@@ -38,5 +38,5 @@
 #include "netcdf.inc"
 !#include "tracer.h"
-#include"advtrac.h"
+!#include"advtrac.h"
 c=======================================================================
 c   Declarations
@@ -49,6 +49,5 @@
 c et autres:
 c----------
-      INTEGER lnblnk
-      EXTERNAL lnblnk
+      integer,intent(in) :: nqtot ! number of advected tracers
 
 c Variables pour les lectures des fichiers "ini" 
@@ -85,5 +84,5 @@
       REAL vcov(iip1,jjm,llm),ucov(iip1,jjp1,llm) ! vents covariants
       REAL h(iip1,jjp1,llm),ps(iip1,jjp1)
-      REAL q(iip1,jjp1,llm,nqmx),qtot(iip1,jjp1,llm)
+      REAL q(iip1,jjp1,llm,nqtot),qtot(iip1,jjp1,llm)
 
 c autre variables dynamique nouvelle grille
@@ -103,5 +102,5 @@
       REAL co2ice(ngridmx) ! CO2 ice layer
       REAL emis(ngridmx)
-      REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqmx)
+      REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqtot)
 c     REAL phisfi(ngridmx)
 
@@ -130,5 +129,5 @@
       real inertiedatS(iip1,jjp1,nsoilmx)
       real co2iceS(iip1,jjp1),emisS(iip1,jjp1)
-      REAL q2S(iip1,jjp1,llm+1),qsurfS(iip1,jjp1,nqmx)
+      REAL q2S(iip1,jjp1,llm+1),qsurfS(iip1,jjp1,nqtot)
 
       real ptotal, co2icetotal
@@ -193,5 +192,5 @@
 ! check if tracers follow old naming convention (q01, q02, q03, ...)
       counter=0
-      do iq=1,nqmx
+      do iq=1,nqtot
         txt= " "
         write(txt,'(a1,i2.2)')'q',iq
@@ -205,5 +204,5 @@
         endif
       enddo
-      if (counter.eq.nqmx) then
+      if (counter.eq.nqtot) then
         write(*,*) "lect_start_archive: tracers seem to follow old ",
      &             "naming convention (q01, q02,...)"
@@ -318,5 +317,5 @@
       allocate(psold(imold+1,jmold+1))
       allocate(phisold(imold+1,jmold+1))
-      allocate(qold(imold+1,jmold+1,lmold,nqmx))
+      allocate(qold(imold+1,jmold+1,lmold,nqtot))
       allocate(co2iceold(imold+1,jmold+1))
       allocate(tsurfold(imold+1,jmold+1))
@@ -331,5 +330,5 @@
       allocate(surfithold(imold+1,jmold+1))
       allocate(mlayerold(nsoilold))
-      allocate(qsurfold(imold+1,jmold+1,nqmx))
+      allocate(qsurfold(imold+1,jmold+1,nqtot))
 
       allocate(var (imold+1,jmold+1,llm))
@@ -748,7 +747,7 @@
 c -------------------------------------------
 ! Surface tracers:      
-      qsurfold(1:imold+1,1:jmold+1,1:nqmx)=0
-
-      DO iq=1,nqmx
+      qsurfold(1:imold+1,1:jmold+1,1:nqtot)=0
+
+      DO iq=1,nqtot
         IF (oldtracernames) THEN
           txt=" "
@@ -787,5 +786,5 @@
         ENDIF
 
-      ENDDO ! of DO iq=1,nqmx
+      ENDDO ! of DO iq=1,nqtot
 
 !-----------------------------------------------------------------------
@@ -936,7 +935,7 @@
 c -------------------------------------------
 ! Tracers:
-      qold(1:imold+1,1:jmold+1,1:lmold,1:nqmx)=0
-
-      DO iq=1,nqmx
+      qold(1:imold+1,1:jmold+1,1:lmold,1:nqtot)=0
+
+      DO iq=1,nqtot
         IF (oldtracernames) THEN
           txt=" "
@@ -966,5 +965,5 @@
         ENDIF
 
-      ENDDO ! of DO iq=1,nqmx
+      ENDDO ! of DO iq=1,nqtot
 
 
@@ -1273,5 +1272,5 @@
 
 c traceurs surface
-      do iq = 1, nqmx
+      do iq = 1, nqtot
             call interp_horiz(qsurfold(1,1,iq) ,qsurfs(1,1,iq),
      &                  imold,jmold,iim,jjm,1,
@@ -1279,8 +1278,8 @@
       enddo
 
-      call gr_dyn_fi (nqmx,iim+1,jjm+1,ngridmx,qsurfs,qsurf)
+      call gr_dyn_fi (nqtot,iim+1,jjm+1,ngridmx,qsurfs,qsurf)
 
 c traceurs 3D
-      do  iq = 1, nqmx
+      do  iq = 1, nqtot
             call interp_vert(qold(1,1,1,iq),var,lmold,llm,
      &        apsold,bpsold,aps,bps,psold,(imold+1)*(jmold+1))
@@ -1322,5 +1321,5 @@
 
 c     Periodicite :
-      do  iq = 1, nqmx
+      do  iq = 1, nqtot
          do l=1, llm
             do j = 1, jjp1
Index: /trunk/LMDZ.MARS/libf/dyn3d/newstart.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/newstart.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/newstart.F	(revision 1036)
@@ -16,6 +16,7 @@
 
 ! to use  'getin'
-      USE ioipsl_getincom 
-
+      use ioipsl_getincom, only: getin 
+      use infotrac, only: iniadvtrac, nqtot, tnom
+      use tracer_mod, only: noms, igcm_h2o_vap, igcm_h2o_ice
       implicit none
 
@@ -41,6 +42,6 @@
 #include "serre.h"
 #include "netcdf.inc"
-#include"advtrac.h"
-#include"tracer.h"
+!#include"advtrac.h"
+!#include"tracer.h"
 #include "datafile.h"
 c=======================================================================
@@ -72,5 +73,5 @@
       REAL vcov(iip1,jjm,llm),ucov(iip1,jjp1,llm) ! vents covariants
       REAL phis(iip1,jjp1)
-      REAL q(iip1,jjp1,llm,nqmx)               ! champs advectes
+      REAL,ALLOCATABLE :: q(:,:,:,:)               ! champs advectes
 
 c autre variables dynamique nouvelle grille
@@ -98,5 +99,5 @@
       REAL co2ice(ngridmx)	! CO2 ice layer
       REAL emis(ngridmx)	! surface emissivity
-      REAL qsurf(ngridmx,nqmx)
+      REAL,ALLOCATABLE :: qsurf(:,:)
       REAL q2(ngridmx,nlayermx+1)
 !      REAL rnaturfi(ngridmx)
@@ -179,4 +180,10 @@
       pa= 20           ! for Mars, instead of 500 (Earth)
 
+! Load tracer number and names:
+      call iniadvtrac(nqtot,numvanle)
+! allocate arrays
+      allocate(q(iip1,jjp1,llm,nqtot))
+      allocate(qsurf(ngridmx,nqtot))
+      
 c=======================================================================
 c   Choice of the start file(s) to use
@@ -323,6 +330,4 @@
 c  INITIALISATIONS DIVERSES
 c=======================================================================
-! Load tracer names:
-      call iniadvtrac(nq,numvanle)
 
       day_step=180 !?! Note: day_step is a common in "control.h"
@@ -357,5 +362,5 @@
 !    (for instance initracer needs to know about some flags, and/or
 !      'datafile' path may be changed by user)
-      call inifis(ngridmx,llm,day_ini,daysec,dtphys,
+      call inifis(ngridmx,llm,nqtot,day_ini,daysec,dtphys,
      &                latfi,lonfi,airefi,rad,g,r,cpp)
 
@@ -399,5 +404,5 @@
 
         write(*,*) 'Reading file START_ARCHIVE'
-        CALL lect_start_archive(date,tsurf,tsoil,emis,q2,
+        CALL lect_start_archive(nqtot,date,tsurf,tsoil,emis,q2,
      .   t,ucov,vcov,ps,co2ice,teta,phisold_newgrid,q,qsurf,
      &   surfith,nid)
@@ -415,10 +420,10 @@
         write(*,*) 'Reading file START'
         fichnom = 'start.nc'
-        CALL dynetat0(fichnom,nqmx,vcov,ucov,teta,q,masse,
+        CALL dynetat0(fichnom,nqtot,vcov,ucov,teta,q,masse,
      .       ps,phis,time)
 
         write(*,*) 'Reading file STARTFI'
         fichnom = 'startfi.nc'
-        CALL phyetat0 (fichnom,tab0,Lmodif,nsoilmx,nqmx,
+        CALL phyetat0 (fichnom,tab0,Lmodif,nsoilmx,nqtot,
      .        day_ini,time,
      .        tsurf,tsoil,emis,q2,qsurf,co2ice)
@@ -448,5 +453,5 @@
 ! rename them
       count=0
-      do iq=1,nqmx
+      do iq=1,nqtot
         txt=" "
         write(txt,'(a1,i2.2)') 'q',iq
@@ -454,14 +459,14 @@
           count=count+1
         endif
-      enddo ! of do iq=1,nqmx
+      enddo ! of do iq=1,nqtot
       
       ! initialize tracer names noms(:) and indexes (igcm_co2, igcm_h2o_vap, ...)
-      call initracer(qsurf,co2ice)
+      call initracer(ngridmx,nqtot,qsurf,co2ice)
       
-      if (count.eq.nqmx) then
+      if (count.eq.nqtot) then
         write(*,*) 'Newstart: updating tracer names'
         ! copy noms(:) to tnom(:) to have matching tracer names in physics
         ! and dynamics
-        tnom(1:nqmx)=noms(1:nqmx)
+        tnom(1:nqtot)=noms(1:nqtot)
       endif
 
@@ -693,5 +698,5 @@
          if (yes.eq.'y') then
            write(*,*) 'OK : conservation of tracer total mass'
-           DO iq =1, nqmx
+           DO iq =1, nqtot
              DO l=1,llm
                DO j=1,jjp1
@@ -712,12 +717,12 @@
          do while (yes.eq.'y')
           write(*,*) 'Which tracer name do you want to change ?'
-          do iq=1,nqmx
+          do iq=1,nqtot
             write(*,'(i3,a3,a20)')iq,' : ',trim(tnom(iq))
           enddo
           write(*,'(a35,i3)')
-     &            '(enter tracer number; between 1 and ',nqmx
+     &            '(enter tracer number; between 1 and ',nqtot
           write(*,*)' or any other value to quit this option)'
           read(*,*) iq
-          if ((iq.ge.1).and.(iq.le.nqmx)) then
+          if ((iq.ge.1).and.(iq.le.nqtot)) then
             write(*,*)'Change tracer name ',trim(tnom(iq)),' to ?'
             read(*,*) txt
@@ -728,5 +733,5 @@
 ! inapropiate value of iq; quit this option
             yes='n'
-          endif ! of if ((iq.ge.1).and.(iq.le.nqmx))
+          endif ! of if ((iq.ge.1).and.(iq.le.nqtot))
          enddo ! of do while (yes.ne.'y')
 
@@ -736,5 +741,5 @@
 c          mise a 0 des q (traceurs)
           write(*,*) 'Tracers set to 0 (1.E-30 in fact)'
-           DO iq =1, nqmx
+           DO iq =1, nqtot
              DO l=1,llm
                DO j=1,jjp1
@@ -747,5 +752,5 @@
 
 c          set surface tracers to zero
-           DO iq =1, nqmx
+           DO iq =1, nqtot
              DO ig=1,ngridmx
                  qsurf(ig,iq)=0.
@@ -757,10 +762,10 @@
         else if (trim(modif) .eq. 'q=x') then
              write(*,*) 'Which tracer do you want to modify ?'
-             do iq=1,nqmx
+             do iq=1,nqtot
                write(*,*)iq,' : ',trim(tnom(iq))
              enddo
-             write(*,*) '(choose between 1 and ',nqmx,')'
+             write(*,*) '(choose between 1 and ',nqtot,')'
              read(*,*) iq 
-             if ((iq.lt.1).or.(iq.gt.nqmx)) then
+             if ((iq.lt.1).or.(iq.gt.nqtot)) then
                ! wrong value for iq, go back to menu
                write(*,*) "wrong input value:",iq
@@ -793,10 +798,10 @@
              write(*,*) "followed by 2nd, etc. up to top of atmosphere)"
              write(*,*) 'Which tracer do you want to set?'
-             do iq=1,nqmx
+             do iq=1,nqtot
                write(*,*)iq,' : ',trim(tnom(iq))
              enddo
-             write(*,*) '(choose between 1 and ',nqmx,')'
+             write(*,*) '(choose between 1 and ',nqtot,')'
              read(*,*) iq 
-             if ((iq.lt.1).or.(iq.gt.nqmx)) then
+             if ((iq.lt.1).or.(iq.gt.nqtot)) then
                ! wrong value for iq, go back to menu
                write(*,*) "wrong input value:",iq
@@ -853,10 +858,10 @@
           endif
           
-          call inichim_newstart(q, qsurf, ps, flagh2o, flagthermo)
+          call inichim_newstart(nq, q, qsurf, ps, flagh2o, flagthermo)
 
          ! We want to have the very same value at lon -180 and lon 180
           do l = 1,llm
              do j = 1,jjp1
-                do iq = 1,nqmx
+                do iq = 1,nqtot
                    q(iip1,j,l,iq) = q(1,j,l,iq)
                 end do
@@ -892,5 +897,5 @@
           do l = 1,llm
              do j = 1,jjp1
-                do iq = 1,nqmx
+                do iq = 1,nqtot
                    q(iip1,j,l,iq) = q(1,j,l,iq)
                 end do
@@ -1460,15 +1465,15 @@
 c    $    phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, day_ini )
 
-      CALL dynredem0("restart.nc",day_ini,anneeref,phis,nqmx)
+      CALL dynredem0("restart.nc",day_ini,anneeref,phis,nqtot)
       CALL dynredem1("restart.nc",hour_ini,vcov,ucov,teta,q,
-     .               nqmx,masse,ps)
+     .               nqtot,masse,ps)
 C
 C Ecriture etat initial physique
 C
 
-      call physdem0("restartfi.nc",lonfi,latfi,nsoilmx,nqmx,
+      call physdem0("restartfi.nc",lonfi,latfi,nsoilmx,nqtot,
      .              dtphys,real(day_ini),0.0,
      .              airefi,albfi,ithfi,zmea,zstd,zsig,zgam,zthe)
-      call physdem1("restartfi.nc",nsoilmx,nqmx,
+      call physdem1("restartfi.nc",nsoilmx,nqtot,
      .              dtphys,hour_ini,
      .              tsurf,tsoil,co2ice,emis,q2,qsurf)
Index: /trunk/LMDZ.MARS/libf/dyn3d/paramet.h
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/paramet.h	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/paramet.h	(revision 1036)
@@ -3,5 +3,5 @@
 
       INTEGER  iip1,iip2,iip3,jjp1,llmp1,llmp2,llmm1
-      INTEGER  kftd,ip1jm,ip1jmp1,ip1jmi1,ijp1llm
+      INTEGER  ip1jm,ip1jmp1,ip1jmi1,ijp1llm
       INTEGER  ijmllm,mvar
       INTEGER jcfil,jcfllm
@@ -10,5 +10,4 @@
       PARAMETER( jjp1=jjm+1-1/jjm)
       PARAMETER( llmp1 = llm+1,  llmp2 = llm+2, llmm1 = llm-1 )
-      PARAMETER( kftd  = iim/2 -ndm )
       PARAMETER( ip1jm  = iip1*jjm,  ip1jmp1= iip1*jjp1 )
       PARAMETER( ip1jmi1= ip1jm - iip1 )
Index: /trunk/LMDZ.MARS/libf/dyn3d/start2archive.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/start2archive.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/start2archive.F	(revision 1036)
@@ -19,4 +19,5 @@
 c=======================================================================
 
+      use infotrac, only: iniadvtrac, nqtot, tnom
       implicit none
 
@@ -35,5 +36,5 @@
 #include "dimphys.h"
 #include "comsoil.h"
-#include"advtrac.h"
+!#include"advtrac.h"
 #include "netcdf.inc"
 
@@ -46,5 +47,5 @@
       REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
       REAL teta(ip1jmp1,llm)                    ! temperature potentielle 
-      REAL q(ip1jmp1,llm,nqmx)               ! champs advectes
+      REAL,ALLOCATABLE :: q(:,:,:)   ! champs advectes
       REAL pks(ip1jmp1)                      ! exner (f pour filtre)
       REAL pk(ip1jmp1,llm)
@@ -61,5 +62,6 @@
       REAL tsoil(ngridmx,nsoilmx) ! Soil temperature
       REAL co2ice(ngridmx)	! CO2 ice layer
-      REAL q2(ngridmx,nlayermx+1),qsurf(ngridmx,nqmx)
+      REAL q2(ngridmx,nlayermx+1)
+      REAL,ALLOCATABLE :: qsurf(:,:)
       REAL emis(ngridmx)
       INTEGER start,length
@@ -75,5 +77,6 @@
       REAL ithS(ip1jmp1,nsoilmx) ! Soil Thermal Inertia
       REAL co2iceS(ip1jmp1)
-      REAL q2S(ip1jmp1,llm+1),qsurfS(ip1jmp1,nqmx)
+      REAL q2S(ip1jmp1,llm+1)
+      REAL,ALLOCATABLE :: qsurfS(:,:)
       REAL emisS(ip1jmp1)
 
@@ -116,9 +119,14 @@
 c Lecture des donnees
 c=======================================================================
-! Load tracer names:
-      call iniadvtrac(nq,numvanle)
+! Load tracer number and names:
+      call iniadvtrac(nqtot,numvanle)
+
+! allocate arrays:
+      allocate(q(ip1jmp1,llm,nqtot))
+      allocate(qsurf(ngridmx,nqtot))
+      allocate(qsurfS(ip1jmp1,nqtot))
 
       fichnom = 'start.nc'
-      CALL dynetat0(fichnom,nqmx,vcov,ucov,teta,q,masse,
+      CALL dynetat0(fichnom,nqtot,vcov,ucov,teta,q,masse,
      .       ps,phis,timedyn)
 
@@ -127,5 +135,5 @@
       Lmodif=0
 
-      CALL phyetat0 (fichnom,0,Lmodif,nsoilmx,nqmx,day_ini_fi,timefi,
+      CALL phyetat0 (fichnom,0,Lmodif,nsoilmx,nqtot,day_ini_fi,timefi,
      .      tsurf,tsoil,emis,q2,qsurf,co2ice)
 
@@ -233,5 +241,5 @@
       call gr_fi_dyn(1,ngridmx,iip1,jjp1,emis,emisS)
       call gr_fi_dyn(llm+1,ngridmx,iip1,jjp1,q2,q2S)
-      call gr_fi_dyn(nqmx,ngridmx,iip1,jjp1,qsurf,qsurfS)
+      call gr_fi_dyn(nqtot,ngridmx,iip1,jjp1,qsurf,qsurfS)
 
 c=======================================================================
@@ -334,7 +342,7 @@
 
 c-----------------------------------------------------------------------
-c Ecriture du champs  q  ( q[1,nqmx] )
-c-----------------------------------------------------------------------
-      do iq=1,nqmx
+c Ecriture du champs  q  ( q[1,nqtot] )
+c-----------------------------------------------------------------------
+      do iq=1,nqtot
 c       write(str2,'(i2.2)') iq
 c        call write_archive(nid,ntime,'q'//str2,'tracer','kg/kg',
@@ -344,7 +352,7 @@
       end do
 c-----------------------------------------------------------------------
-c Ecriture du champs  qsurf  ( qsurf[1,nqmx] )
-c-----------------------------------------------------------------------
-      do iq=1,nqmx
+c Ecriture du champs  qsurf  ( qsurf[1,nqtot] )
+c-----------------------------------------------------------------------
+      do iq=1,nqtot
 c       write(str2,'(i2.2)') iq
 c       call write_archive(nid,ntime,'qsurf'//str2,'Tracer on surface',
Index: /trunk/LMDZ.MARS/libf/dyn3d/test_period.F
===================================================================
--- /trunk/LMDZ.MARS/libf/dyn3d/test_period.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/dyn3d/test_period.F	(revision 1036)
@@ -6,5 +6,6 @@
 c                           teta, q , p et phis                 .......... 
 c
-c     IMPLICIT NONE
+      use infotrac,only: nqtot
+      IMPLICIT NONE
 c
 #include "dimensions.h"
@@ -14,5 +15,5 @@
 c
       REAL ucov(ip1jmp1,llm), vcov(ip1jm,llm), teta(ip1jmp1,llm) ,
-     ,      q(ip1jmp1,llm,nqmx), p(ip1jmp1,llmp1), phis(ip1jmp1)
+     ,      q(ip1jmp1,llm,nqtot), p(ip1jmp1,llmp1), phis(ip1jmp1)
 c
 c   .....  Variables  locales  .....
@@ -56,5 +57,5 @@
       
 c
-      DO nq =1, nqmx
+      DO nq =1, nqtot
         DO l =1, llm
           DO ij = 1, ip1jmp1, iip1
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.1.1.32.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.1.1.32.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.10.48.55.t6
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.10.48.55.t6	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 10
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=55
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=6
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t15
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t15	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=15
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.25.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.32.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.32.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.32.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.24.32.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.32.25.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.32.25.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=32
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.16.32.25.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.16.32.25.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 16
-      INTEGER, parameter :: jjm=32
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.176.90.18.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.176.90.18.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 176
-      INTEGER, parameter :: jjm=90
-      INTEGER, parameter :: llm=18
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.2.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.2.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=2
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t15
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t15	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=15
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t32
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.25.t32	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=32
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.256.180.18.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.256.180.18.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 256
-      INTEGER, parameter :: jjm=180
-      INTEGER, parameter :: llm=18
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.25.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.25.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.26.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.26.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=26
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.32.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.32.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.32.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.32.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.32.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.32.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.50.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.50.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.50.t13
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.50.t13	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=13
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.50.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.50.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=60
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t12
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t12	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=60
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=12
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=60
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t60
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.24.60.t60	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=24
-      INTEGER, parameter :: llm=60
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=60
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.34.60.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.34.60.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 32
-      INTEGER, parameter :: jjm=34
-      INTEGER, parameter :: llm=60
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t15
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t15	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=15
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.32.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.352.180.18.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.352.180.18.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 352
-      INTEGER, parameter :: jjm=180
-      INTEGER, parameter :: llm=18
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.352.180.36.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.352.180.36.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 352
-      INTEGER, parameter :: jjm=180
-      INTEGER, parameter :: llm=36
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.50.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.50.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.50.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.50.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.50.t15
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.50.t15	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 1
-      INTEGER, parameter :: jjm=1
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=15
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.18.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.18.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=18
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.24.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.24.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=24
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t-p
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t-p	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=-p
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.25.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=25
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t12
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t12	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=12
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t13
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t13	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=13
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t15
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t15	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=15
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t4
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.32.t4	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=4
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.325.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.325.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=325
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.50.t1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.50.t1	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=1
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.50.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.50.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.50.t15
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.50.t15	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h contient les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=50
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=15
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.54.t14
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.54.t14	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=54
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=14
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.54.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.64.48.54.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 64
-      INTEGER, parameter :: jjm=48
-      INTEGER, parameter :: llm=54
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/dimensions.72.36.32.t2
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/dimensions.72.36.32.t2	(revision 1035)
+++ 	(revision )
@@ -1,16 +1,0 @@
-!-----------------------------------------------------------------------
-!   INCLUDE 'dimensions.h'
-!
-!   dimensions.h continet les dimensions du modele
-!   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
-!-----------------------------------------------------------------------
-
-      INTEGER, parameter :: iim= 72
-      INTEGER, parameter :: jjm=36
-      INTEGER, parameter :: llm=32
-      INTEGER, parameter :: ndm=1
-
-      integer, parameter :: nqmx=2
-
-!-----------------------------------------------------------------------
Index: /trunk/LMDZ.MARS/libf/grid/dimension/makdim
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/makdim	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/grid/dimension/makdim	(revision 1036)
@@ -1,8 +1,7 @@
-nqmx=$1
-shift
+
 for i in $* ; do
    list=$list.$i
 done
-fichdim=dimensions${list}.t${nqmx}
+fichdim=dimensions${list}
 
 
@@ -15,5 +14,5 @@
    lm=$3
    n2=$1
-   ndm=1
+#   ndm=1
 
 #  while [ "$n2" -gt 2 ]; do
@@ -30,10 +29,10 @@
        jm=$1
       lm=$2
-      ndm=1
+#      ndm=1
  else if [ $# -ge 1 ] ; then
          im=1
          jm=1
          lm=$1
-         ndm=1
+#         ndm=1
  else
          echo il faut au moins une dimension
@@ -49,13 +48,9 @@
 !   dimensions.h contient les dimensions du modele
 !   ndm est tel que iim=2**ndm
-!   nqmx est la dimension de la variable traceur q
 !-----------------------------------------------------------------------
 
-      INTEGER, parameter :: iim= $im
+      INTEGER, parameter :: iim=$im
       INTEGER, parameter :: jjm=$jm
       INTEGER, parameter :: llm=$lm
-      INTEGER, parameter :: ndm=$ndm
-
-      integer, parameter :: nqmx=$nqmx
 
 !-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/makdim.bak
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/makdim.bak	(revision 1035)
+++ 	(revision )
@@ -1,63 +1,0 @@
-nqmx=$1
-shift
-for i in $* ; do
-   list=$list.$i
-done
-fichdim=dimensions${list}.t${nqmx}
-
-if [ ! -f $fichdim ] ; then
-# si le fichier de dimensions n'existe pas, on le cree
-
- if [ $# -ge 3 ] ; then
-   im=$1
-   jm=$2
-   lm=$3
-   n2=$1
-   ndm=1
-   while [ "$n2" -gt 2 ]; do
-      n2=`expr $n2 / 2`
-      ndm=`expr $ndm + 1`
-   done
-   if [ "$n2" != 2 ] ; then
-      echo le nombre de longitude doit etre une puissance de 2
-      exit
-   fi
- else if [ $# -ge 2 ] ; then
-      im=1
-      jm=$1
-      lm=$2
-      ndm=1
- else if [ $# -ge 1 ] ; then
-         im=1
-         jm=1
-         lm=$1
-         ndm=1
- else
-         echo il faut au moins une dimension
-         exit
- fi
-fi
-fi
-
-cat << EOF > $fichdim
-c-----------------------------------------------------------------------
-c   INCLUDE 'dimensions.h'
-c
-c   dimensions.h continet les dimensions du modele
-c   ndm est tel que iim=2**ndm
-c   nqmx est la dimension de la variable traceur q
-c-----------------------------------------------------------------------
-
-      INTEGER iim,jjm,llm,ndm
-
-      PARAMETER (iim= $im,jjm=$jm,llm=$lm,ndm=$ndm)
-
-      integer nqmx
-      parameter (nqmx=$nqmx)
-
-c-----------------------------------------------------------------------
-EOF
-fi
-
-\rm ../dimensions.h
-tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimensions.h )
Index: unk/LMDZ.MARS/libf/grid/dimension/makdim.moi
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/makdim.moi	(revision 1035)
+++ 	(revision )
@@ -1,68 +1,0 @@
-nqmx=$1
-shift
-for i in $* ; do
-   list=$list.$i
-done
-fichdim=dimensions${list}.t${nqmx}
-
-
-if [ ! -f $fichdim ] ; then
-# si le fichier de dimensions n'existe pas, on le cree
-
-echo $#
-if [ $# -ge 3 ] ; then
-   im=$1
-   jm=$2
-   lm=$3
-   n2=$1
-   ndm=1
-
-#  while [ "$n2" -gt 2 ]; do
-#      n2=`expr $n2 / 2`
-#     ndm=`expr $ndm + 1`
-#   done
-#   if [ "$n2" != 2 ] ; then
-#      echo le nombre de longitude doit etre une puissance de 2
-#      exit
-#   fi
-
-echo $#
-    if [ $# -ge 2 ] ; then
-      im=1
-       jm=$1
-      lm=$2
-      ndm=1
-      else if [ $# -ge 1 ] ; then
-         im=1
-         jm=1
-         lm=$1
-         ndm=1
-      else
-         echo il faut au moins une dimension
-         exit
-      fi
-    fi
-fi
-
-cat << EOF > $fichdim
-c-----------------------------------------------------------------------
-c   INCLUDE 'dimensions.h'
-c
-c   dimensions.h continet les dimensions du modele
-c   ndm est tel que iim=2**ndm
-c   nqmx est la dimension de la variable traceur q
-c-----------------------------------------------------------------------
-
-      INTEGER iim,jjm,llm,ndm
-
-      PARAMETER (iim= $im,jjm=$jm,llm=$lm,ndm=$ndm)
-
-      integer nqmx
-      parameter (nqmx=$nqmx)
-
-c-----------------------------------------------------------------------
-EOF
-fi
-
-\rm ../dimensions.h
-tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimensions.h )
Index: unk/LMDZ.MARS/libf/grid/dimension/makdim.n
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/makdim.n	(revision 1035)
+++ 	(revision )
@@ -1,65 +1,0 @@
-for i in $* ; do
-   list=$list.$i
-done
-fichdim=dimensions$list
-
-if [ ! -f $fichdim ] ; then
-# si le fichier de dimensions n'existe pas, on le cree
-
-if [ $# -ge 4 ] ; then
-   nqmx=$1
-   im=$2
-   jm=$3
-   lm=$4
-   n2=$2
-   ndm=1
-   while [ "$n2" -gt 2 ]; do
-      n2=`expr $n2 / 2`
-      ndm=`expr $ndm + 1`
-   done
-   if [ "$n2" != 2 ] ; then
-      echo le nombre de longitude doit etre une puissance de 2
-      exit
-   fi
-else if [ $# -ge 3 ] ; then
-   nqmx=$1
-   im=1
-   jm=$2
-   lm=$3
-   ndm=1
-   else if [ $# -ge 2 ] ; then
-      nqmx=$1
-      im=1
-      jm=1
-      lm=$2
-      ndm=1
-   else
-      echo il faut au moins une dimension
-      exit
-   fi
-fi
-
-fi
-
-cat << EOF > $fichdim
-c-----------------------------------------------------------------------
-c   INCLUDE 'dimensions.h'
-c
-c   dimensions.h continet les dimensions du modele
-c   ndm est tel que iim=2**ndm
-c   nqmx est la dimension de la variable traceur q
-c-----------------------------------------------------------------------
-
-      INTEGER iim,jjm,llm,ndm
-
-      PARAMETER (iim= $im,jjm=$jm,llm=$lm,ndm=$ndm)
-
-      integer nqmx
-      parameter (nqmx=$nqmx)
-
-c-----------------------------------------------------------------------
-EOF
-fi
-
-\rm ../dimensions.h
-tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimensions.h )
Index: unk/LMDZ.MARS/libf/grid/dimension/makdim.old
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/makdim.old	(revision 1035)
+++ 	(revision )
@@ -1,57 +1,0 @@
-for i in $* ; do
-   list=$list.$i
-done
-fichdim=dimensions$list
-
-if [ ! -f $fichdim ] ; then
-# si le fichier de dimensions n'existe pas, on le cree
-
-if [ $# -ge 3 ] ; then
-   im=$1
-   jm=$2
-   lm=$3
-   n2=$1
-   ndm=1
-   while [ "$n2" -gt 2 ]; do
-      n2=`expr $n2 / 2`
-      ndm=`expr $ndm + 1`
-   done
-   if [ "$n2" != 2 ] ; then
-      echo le nombre de longitude doit etre une puissance de 2
-      exit
-   fi
-   else if [ $# -ge 2 ] ; then
-      im=1
-      jm=$1
-      lm=$2
-      ndm=1
-      else if [ $# -ge 1 ] ; then
-         im=1
-         jm=1
-         lm=$1
-         ndm=1
-      else
-         echo il faut au moins une dimension
-         exit
-      fi
-   fi
-fi
-
-cat << EOF > $fichdim
-c-----------------------------------------------------------------------
-c   INCLUDE 'dimensions.h'
-c
-c   dimensions.h continet les trois dimensions du modele
-c   ndm est tel que iim=2**ndm
-c-----------------------------------------------------------------------
-
-      INTEGER iim,jjm,llm,ndm
-
-      PARAMETER (iim= $im,jjm=$jm,llm=$lm,ndm=$ndm)
-
-c-----------------------------------------------------------------------
-EOF
-fi
-
-\rm ../dimensions.h
-tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimensions.h )
Index: unk/LMDZ.MARS/libf/grid/dimension/makdimphy
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/makdimphy	(revision 1035)
+++ 	(revision )
@@ -1,28 +1,0 @@
-for i in $* ; do
-   list=$list.$i
-done
-fichdim=dimphy$list
-
-if [ ! -f $fichdim ] ; then
-# si le fichier de dimensions n'existe pas, on le cree
-
-if [ $# -ge 3 ] ; then
-   im=$1
-   jm=$2
-   lm=$3
-else
-   echo il faut preciser les dimensions
-   exit
-fi
-
-cat << EOF > $fichdim
-c-----------------------------------------------------------------------
-      INTEGER KIDIA, KFDIA, KLON, KLEV
-      PARAMETER (KIDIA=1,KFDIA=$im*($jm-1)+2,
-     .           KLON=KFDIA-KIDIA+1,KLEV=$lm)
-c-----------------------------------------------------------------------
-EOF
-fi
-
-/bin/rm ../dimphy.h
-tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimphy.h )
Index: unk/LMDZ.MARS/libf/grid/dimension/makntrac
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/makntrac	(revision 1035)
+++ 	(revision )
@@ -1,23 +1,0 @@
-fichntrac=ntraceur.$1
-
-if [ ! -f $fichntrac ] ; then
-# si le fichier de dimensions n'existe pas, on le cree
-
-cat << EOF > $fichntrac
-c-----------------------------------------------------------------------
-c   INCLUDE 'ntraceur.h'
-c
-c   ntraceur.h contient la dimension de la variable traceur q
-c   Generalement egale au nombre de traceur.
-c-----------------------------------------------------------------------
-
-      INTEGER nqmx
-
-      PARAMETER (nqmx=$1)
-
-c-----------------------------------------------------------------------
-EOF
-fi
-
-\rm ../ntraceur.h
-tar cf - $fichntrac | ( cd .. ; tar xf - ; mv $fichntrac ntraceur.h )
Index: unk/LMDZ.MARS/libf/grid/dimension/ntraceur.1
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/ntraceur.1	(revision 1035)
+++ 	(revision )
@@ -1,12 +1,0 @@
-c-----------------------------------------------------------------------
-c   INCLUDE 'ntraceur.h'
-c
-c   ntraceur.h contient la dimension de la variable traceur q
-c   Generalement egale au nombre de traceur.
-c-----------------------------------------------------------------------
-
-      INTEGER nqmx
-
-      PARAMETER (nqmx=1)
-
-c-----------------------------------------------------------------------
Index: unk/LMDZ.MARS/libf/grid/dimension/ntraceur.5
===================================================================
--- /trunk/LMDZ.MARS/libf/grid/dimension/ntraceur.5	(revision 1035)
+++ 	(revision )
@@ -1,12 +1,0 @@
-c-----------------------------------------------------------------------
-c   INCLUDE 'ntraceur.h'
-c
-c   ntraceur.h contient la dimension de la variable traceur q
-c   Generalement egale au nombre de traceur.
-c-----------------------------------------------------------------------
-
-      INTEGER nqmx
-
-      PARAMETER (nqmx=5)
-
-c-----------------------------------------------------------------------
Index: /trunk/LMDZ.MARS/libf/phymars/aeropacity.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/aeropacity.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/aeropacity.F	(revision 1036)
@@ -4,5 +4,7 @@
                                                    
 ! to use  'getin'
-      USE ioipsl_getincom 
+      USE ioipsl_getincom, only: getin
+      use tracer_mod, only: noms, igcm_h2o_ice, igcm_dust_mass,
+     &                      igcm_dust_submicron, rho_dust, rho_ice
        IMPLICIT NONE
 c=======================================================================
@@ -53,5 +55,5 @@
 #include "dimradmars.h"
 #include "yomaer.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "planete.h"
 #include "aerkind.h"
@@ -119,5 +121,5 @@
 
 ! indexes of water ice and dust tracers:
-      INTEGER,SAVE :: nqdust(nqmx) ! to store the indexes of dust tracers
+      INTEGER,ALLOCATABLE,SAVE :: nqdust(:) ! to store the indexes of dust tracers
       INTEGER,SAVE :: i_ice=0  ! water ice
       real,parameter :: odpref=610. ! DOD reference pressure (Pa)
@@ -143,4 +145,5 @@
         ENDDO
         ! identify tracers which are dust
+        allocate(nqdust(nq))
         i=0
         DO iq=1,nq
Index: /trunk/LMDZ.MARS/libf/phymars/callradite.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/callradite.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/callradite.F	(revision 1036)
@@ -272,5 +272,5 @@
           name_iaer(1) = "dust_conrath"   !! default choice is good old Conrath profile
           IF (doubleq.AND.active) name_iaer(1) = "dust_doubleq" !! two-moment scheme
-          if (nqmx.gt.1) then
+          if (nq.gt.1) then
            ! trick to avoid problems compiling with 1 tracer
            ! and picky compilers who know name_iaer(2) is out of bounds
@@ -278,5 +278,5 @@
           IF (water.AND.activice) name_iaer(j) = "h2o_ice"      !! radiatively-active clouds
           IF (submicron.AND.active) name_iaer(j) = "dust_submicron" !! JBM experimental stuff
-          endif ! of if (nqmx.gt.1)
+          endif ! of if (nq.gt.1)
 c        ----------------------------------------------------------
 
Index: /trunk/LMDZ.MARS/libf/phymars/callsedim.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/callsedim.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/callsedim.F	(revision 1036)
@@ -5,6 +5,10 @@
      &                tau,tauscaling)
 ! to use  'getin'
-      USE ioipsl_getincom
-      USE updaterad,only: updaterdust,updaterice_micro,updaterice_typ
+      USE ioipsl_getincom, only: getin
+      USE updaterad, only: updaterdust,updaterice_micro,updaterice_typ
+      USE tracer_mod, only: noms, igcm_dust_mass, igcm_dust_number,
+     &                      rho_dust, rho_q, radius, varian,
+     &                      igcm_ccn_mass, igcm_ccn_number,
+     &                      igcm_h2o_ice, nuice_sed, nuice_ref 
       IMPLICIT NONE
 
@@ -28,5 +32,5 @@
 #include "dimphys.h"
 #include "comcstfi.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "callkeys.h"
 
Index: /trunk/LMDZ.MARS/libf/phymars/calltherm_interface.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/calltherm_interface.F90	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/calltherm_interface.F90	(revision 1036)
@@ -45,4 +45,5 @@
 
       use comtherm_h
+      use tracer_mod, only: nqmx,noms
       implicit none
 
Index: /trunk/LMDZ.MARS/libf/phymars/convadj.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/convadj.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/convadj.F	(revision 1036)
@@ -6,4 +6,6 @@
      &                   pdqadj)
 
+      use tracer_mod, only: noms, ! tracer names
+     &                      igcm_h2o_vap ! index of water vapor tracer
       implicit none
 
@@ -33,5 +35,5 @@
 #include "comcstfi.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 
 
@@ -73,6 +75,6 @@
       INTEGER iq,ico2
       save ico2
-      REAL zq(ngridmx,nlayermx,nqmx), zq2(ngridmx,nlayermx,nqmx)
-      REAL zqm(nqmx),zqco2m
+      REAL zq(ngridmx,nlayermx,nq), zq2(ngridmx,nlayermx,nq)
+      REAL zqm(nq),zqco2m
       real m_co2, m_noco2, A , B
       save A, B
@@ -101,5 +103,5 @@
         if (tracer) then
 !     Prepare Special treatment if one of the tracers is CO2 gas
-           do iq=1,nqmx
+           do iq=1,nq
              if (noms(iq).eq."co2") then
                 ico2=iq
Index: /trunk/LMDZ.MARS/libf/phymars/dustdevil.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/dustdevil.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/dustdevil.F	(revision 1036)
@@ -1,4 +1,6 @@
       SUBROUTINE dustdevil(ngrid,nlay,nq, pplev,pu,pv,pt, ptsurf,pq2,
      &                pdqdev,pdqs_dev)
+
+      use tracer_mod, only: alpha_devil
       IMPLICIT NONE
 
@@ -32,5 +34,5 @@
 #include "surfdat.h"
 #include "comgeomfi.h"
-#include "tracer.h"
+!#include "tracer.h"
 c   arguments:
 c   ----------
Index: /trunk/LMDZ.MARS/libf/phymars/dustlift.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/dustlift.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/dustlift.F	(revision 1036)
@@ -2,4 +2,6 @@
      $                  pcdh_true,pcdh,co2ice,
      $                  dqslift)
+
+      use tracer_mod, only: alpha_lift, radius
       IMPLICIT NONE
 
@@ -19,5 +21,5 @@
 #include "dimphys.h"
 #include "comcstfi.h"
-#include "tracer.h"
+!#include "tracer.h"
 
 c
Index: /trunk/LMDZ.MARS/libf/phymars/growthrate.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/growthrate.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/growthrate.F	(revision 1036)
@@ -1,4 +1,5 @@
       subroutine growthrate(temp,pmid,psat,rcrystal,res)
 
+      use tracer_mod, only: rho_ice
       IMPLICIT NONE
 
@@ -21,5 +22,5 @@
 #include "dimphys.h"
 #include "comcstfi.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "microphys.h"
 
Index: /trunk/LMDZ.MARS/libf/phymars/improvedclouds.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/improvedclouds.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/improvedclouds.F	(revision 1036)
@@ -6,4 +6,8 @@
       USE ioipsl_getincom
       USE updaterad
+      use tracer_mod, only: rho_ice, nuice_sed, igcm_h2o_vap,
+     &                      igcm_h2o_ice, igcm_dust_mass,
+     &                      igcm_dust_number, igcm_ccn_mass,
+     &                      igcm_ccn_number
       implicit none
       
@@ -33,5 +37,5 @@
 #include "comcstfi.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "comgeomfi.h"
 #include "dimradmars.h"
@@ -73,6 +77,6 @@
       INTEGER ig,l,i
       
-      REAL zq(ngridmx,nlayermx,nqmx)  ! local value of tracers
-      REAL zq0(ngridmx,nlayermx,nqmx) ! local initial value of tracers
+      REAL zq(ngridmx,nlayermx,nq)  ! local value of tracers
+      REAL zq0(ngridmx,nlayermx,nq) ! local initial value of tracers
       REAL zt(ngridmx,nlayermx)       ! local value of temperature
       REAL zqsat(ngridmx,nlayermx)    ! saturation
Index: /trunk/LMDZ.MARS/libf/phymars/inifis.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/inifis.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/inifis.F	(revision 1036)
@@ -1,4 +1,4 @@
       SUBROUTINE inifis(
-     $           ngrid,nlayer
+     $           ngrid,nlayer,nq
      $           ,day_ini,pdaysec,ptimestep
      $           ,plat,plon,parea
@@ -46,5 +46,7 @@
 !   -------------
 ! to use  'getin'
-      USE ioipsl_getincom 
+      USE ioipsl_getincom, only : getin
+      use tracer_mod, only : nqmx, nuice_sed, ccn_factor
+      
       IMPLICIT NONE
 #include "dimensions.h"
@@ -62,16 +64,16 @@
 #include "slope.h"
 #include "microphys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #ifdef MESOSCALE
 #include "comsoil.h"     !!MESOSCALE -- needed to fill volcapa
 #include "meso_inc/meso_inc_inifisvar.F"
 #endif
-      REAL prad,pg,pr,pcpp,pdaysec
-
-      REAL ptimestep 
-      INTEGER day_ini
-
-      INTEGER ngrid,nlayer
-      REAL plat(ngrid),plon(ngrid),parea(ngridmx)
+      REAL,INTENT(IN) :: prad,pg,pr,pcpp,pdaysec
+
+      REAL,INTENT(IN) :: ptimestep 
+      INTEGER,INTENT(IN) :: day_ini
+
+      INTEGER,INTENT(IN) :: ngrid,nlayer,nq
+      REAL,INTENT(IN) :: plat(ngrid),plon(ngrid),parea(ngrid)
       INTEGER ig,ierr
  
@@ -95,4 +97,7 @@
       daysec=pdaysec
       dtphys=ptimestep
+
+      nqmx=nq
+
 #ifdef MESOSCALE
 #include "meso_inc/meso_inc_inifisini.F"
@@ -375,5 +380,5 @@
            stop
          endif
-         if (doubleq.and.submicron.and.(nqmx.LT.3)) then
+         if (doubleq.and.submicron.and.(nq.LT.3)) then
            print*,'If doubleq is used with a submicron tracer,'
            print*,' then the number of tracers has to be'
@@ -804,5 +809,5 @@
 !         print*,' 1 water vapour tracer'
 !         print*,' 1 water ice tracer'
-!         print*,nqmx-4,' chemistry tracers'
+!         print*,nq-4,' chemistry tracers'
 !       endif
 !
@@ -812,6 +817,6 @@
 !         print*,' 1 water vapour tracer'
 !         print*,' 1 water ice tracer'
-!         if (nqmx.LT.4) then
-!           print*,'nqmx should be at least equal to'
+!         if (nq.LT.4) then
+!           print*,'nq should be at least equal to'
 !           print*,'4 with these options.'
 !           stop
@@ -824,5 +829,5 @@
 !           print*,dustbin,' dust bins'
 !         endif
-!         print*,nqmx-2-dustbin,' chemistry tracers'
+!         print*,nq-2-dustbin,' chemistry tracers'
 !         print*,' 1 water vapour tracer'
 !         print*,' 1 water ice tracer'
@@ -836,11 +841,11 @@
 !         print*,' 1 water vapour tracer'
 !         print*,' 1 water ice tracer'
-!         if (nqmx.gt.(dustbin+2)) then
-!           print*,'nqmx should be ',(dustbin+2),
+!         if (nq.gt.(dustbin+2)) then
+!           print*,'nq should be ',(dustbin+2),
 !     $            ' with these options...'
 !		   print*,'(or check callphys.def)'
 !         endif
-!         if (nqmx.lt.(dustbin+2)) then
-!           write(*,*) "inifis: nqmx.lt.(dustbin+2)"
+!         if (nq.lt.(dustbin+2)) then
+!           write(*,*) "inifis: nq.lt.(dustbin+2)"
 !           stop
 !         endif
Index: /trunk/LMDZ.MARS/libf/phymars/initracer.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/initracer.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/initracer.F	(revision 1036)
@@ -1,4 +1,6 @@
-      SUBROUTINE initracer(qsurf,co2ice)
-
+      SUBROUTINE initracer(ngrid,nq,qsurf,co2ice)
+
+       use infotrac, only: tnom
+       use tracer_mod
        IMPLICIT NONE
 c=======================================================================
@@ -11,6 +13,6 @@
 c
 c   Test of dimension :
-c   Initialize COMMON tracer in tracer.h, using tracer names provided
-c   by the dynamics in "advtrac.h"
+c   Initialize tracer related data in tracer_mod, using tracer names provided
+c   by the dynamics in "infotrac"
 c
 c
@@ -26,12 +28,15 @@
 #include "comcstfi.h"
 #include "callkeys.h"
-#include "tracer.h"
-#include "advtrac.h"
+!#include "tracer.h"
+!#include "advtrac.h"
 #include "comgeomfi.h"
 
 #include "surfdat.h"
 
-      real qsurf(ngridmx,nqmx)       ! tracer on surface (e.g.  kg.m-2)
-      real co2ice(ngridmx)           ! co2 ice mass on surface (e.g.  kg.m-2)
+      integer,intent(in) :: ngrid ! number of atmospheric columns
+      integer,intent(in) :: nq ! number of tracers
+      real,intent(out) :: qsurf(ngrid,nq) ! tracer on surface (e.g.  kg.m-2)
+      real,intent(out) :: co2ice(ngrid) ! co2 ice mass on surface (e.g.  kg.m-2)
+
       integer iq,ig,count
       real r0_lift , reff_lift, nueff_lift
@@ -43,8 +48,8 @@
 
 c-----------------------------------------------------------------------
-c  radius(nqmx)      ! aerosol particle radius (m)
-c  rho_q(nqmx)       ! tracer densities (kg.m-3)
-c  alpha_lift(nqmx)  ! saltation vertical flux/horiz flux ratio (m-1)
-c  alpha_devil(nqmx) ! lifting coeeficient by dust devil
+c  radius(nq)      ! aerosol particle radius (m)
+c  rho_q(nq)       ! tracer densities (kg.m-3)
+c  alpha_lift(nq)  ! saltation vertical flux/horiz flux ratio (m-1)
+c  alpha_devil(nq) ! lifting coeeficient by dust devil
 c  rho_dust          ! Mars dust density
 c  rho_ice           ! Water ice density
@@ -55,4 +60,14 @@
 c-----------------------------------------------------------------------
 
+! Initialization: allocate arrays in tracer_mod
+      allocate(noms(nq))
+      allocate(mmol(nq))
+      allocate(radius(nq))
+      allocate(rho_q(nq))
+      allocate(alpha_lift(nq))
+      allocate(alpha_devil(nq))
+      allocate(dryness(ngridmx))
+      allocate(igcm_dustbin(nq))
+
 ! Initialization: get tracer names from the dynamics and check if we are
 !                 using 'old' tracer convention ('q01',q02',...)
@@ -60,5 +75,5 @@
       ! check if tracers have 'old' names
       count=0
-      do iq=1,nqmx
+      do iq=1,nq
         txt=" "
         write(txt,'(a1,i2.2)') 'q',iq
@@ -66,7 +81,7 @@
           count=count+1
         endif
-      enddo ! of do iq=1,nqmx
+      enddo ! of do iq=1,nq
       
-      if (count.eq.nqmx) then
+      if (count.eq.nq) then
         write(*,*) "initracer: tracers seem to follow old naming ",
      &             "convention (q01,q02,...)"
@@ -76,5 +91,5 @@
 
       ! copy tracer names from dynamics
-      do iq=1,nqmx
+      do iq=1,nq
         noms(iq)=tnom(iq)
       enddo
@@ -86,7 +101,6 @@
 ! Identify tracers by their names: (and set corresponding values of mmol)
       ! 0. initialize tracer indexes to zero:
-      do iq=1,nqmx
-        igcm_dustbin(iq)=0
-      enddo
+      igcm_dustbin(1:nq)=0
+
       igcm_dust_mass=0
       igcm_dust_number=0
@@ -130,5 +144,5 @@
       count=0
       if (dustbin.gt.0) then
-        do iq=1,nqmx
+        do iq=1,nq
           txt=" "
           write(txt,'(a4,i2.2)')'dust',count+1
@@ -138,8 +152,8 @@
             mmol(iq)=100.
           endif
-        enddo !do iq=1,nqmx
+        enddo !do iq=1,nq
       endif ! of if (dustbin.gt.0)
       if (doubleq) then
-        do iq=1,nqmx
+        do iq=1,nq
           if (noms(iq).eq."dust_mass") then
             igcm_dust_mass=iq
@@ -153,5 +167,5 @@
       endif ! of if (doubleq)
       if (microphys) then
-        do iq=1,nqmx
+        do iq=1,nq
           if (noms(iq).eq."ccn_mass") then
             igcm_ccn_mass=iq
@@ -165,5 +179,5 @@
       endif ! of if (microphys)
       if (submicron) then
-        do iq=1,nqmx
+        do iq=1,nq
           if (noms(iq).eq."dust_submicron") then
             igcm_dust_submicron=iq
@@ -174,5 +188,5 @@
       endif ! of if (submicron)
       ! 2. find chemistry and water tracers
-      do iq=1,nqmx
+      do iq=1,nq
         if (noms(iq).eq."co2") then
           igcm_co2=iq
@@ -337,10 +351,10 @@
         endif
 
-      enddo ! of do iq=1,nqmx
+      enddo ! of do iq=1,nq
       
       ! check that we identified all tracers:
-      if (count.ne.nqmx) then
+      if (count.ne.nq) then
         write(*,*) "initracer: found only ",count," tracers"
-        write(*,*) "               expected ",nqmx
+        write(*,*) "               expected ",nq
         do iq=1,count
           write(*,*)'      ',iq,' ',trim(noms(iq))
@@ -349,5 +363,5 @@
       else
         write(*,*) "initracer: found all expected tracers, namely:"
-        do iq=1,nqmx
+        do iq=1,nq
           write(*,*)'      ',iq,' ',trim(noms(iq))
         enddo
@@ -365,16 +379,16 @@
        ! as qsurf(i_h2o_vap) & as qsurf(i_h2o_ice), so to be clean:
        if (igcm_h2o_vap.ne.0) then
-         qsurf(1:ngridmx,igcm_h2o_vap)=0
+         qsurf(1:ngrid,igcm_h2o_vap)=0
        endif
       endif
 
 c------------------------------------------------------------
-c     Initialize tracers .... (in tracer.h)
+c     Initialize tracers .... (in tracer_mod)
 c------------------------------------------------------------
       ! start by setting everything to (default) zero
-      rho_q(1:nqmx)=0     ! tracer density (kg.m-3)
-      radius(1:nqmx)=0.   ! tracer particle radius (m)
-      alpha_lift(1:nqmx) =0.  ! tracer saltation vertical flux/horiz flux ratio (m-1)
-      alpha_devil(1:nqmx)=0.  ! tracer lifting coefficient by dust devils
+      rho_q(1:nq)=0     ! tracer density (kg.m-3)
+      radius(1:nq)=0.   ! tracer particle radius (m)
+      alpha_lift(1:nq) =0.  ! tracer saltation vertical flux/horiz flux ratio (m-1)
+      alpha_devil(1:nq)=0.  ! tracer lifting coefficient by dust devils
 
 
@@ -393,6 +407,6 @@
 c       iq=1: Q mass mixing ratio, iq=2: N number mixing ratio
 
-        if( (nqmx.lt.2).or.(water.and.(nqmx.lt.4)) ) then
-          write(*,*)'initracer: nqmx is too low : nqmx=', nqmx
+        if( (nq.lt.2).or.(water.and.(nq.lt.4)) ) then
+          write(*,*)'initracer: nq is too low : nq=', nq
           write(*,*)'water= ',water,' doubleq= ',doubleq   
         end if
@@ -499,11 +513,11 @@
          alpha_lift(igcm_h2o_vap) =0.
          alpha_devil(igcm_h2o_vap)=0.
-         if(water.and.(nqmx.ge.2)) then
+         if(water.and.(nq.ge.2)) then
            radius(igcm_h2o_ice)=3.e-6
            rho_q(igcm_h2o_ice)=rho_ice
            alpha_lift(igcm_h2o_ice) =0.
            alpha_devil(igcm_h2o_ice)=0.
-         elseif(water.and.(nqmx.lt.2)) then
-            write(*,*) 'nqmx is too low : nqmx=', nqmx
+         elseif(water.and.(nq.lt.2)) then
+            write(*,*) 'nq is too low : nq=', nq
             write(*,*) 'water= ',water
          endif
Index: /trunk/LMDZ.MARS/libf/phymars/newcondens.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/newcondens.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/newcondens.F	(revision 1036)
@@ -6,4 +6,5 @@
      $                  fluxsurf_sw,zls)
                                                    
+       use tracer_mod, only: noms
        IMPLICIT NONE
 c=======================================================================
@@ -61,5 +62,5 @@
 #include "paramet.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 
 c-----------------------------------------------------------------------
@@ -195,5 +196,5 @@
          if (tracer) then
 c          Prepare Special treatment if one of the tracer is CO2 gas
-           do iq=1,nqmx
+           do iq=1,nq
              if (noms(iq).eq."co2") then
                 ico2=iq
@@ -238,5 +239,5 @@
       END DO
          
-      DO iq=1,nqmx         
+      DO iq=1,nq
       DO l=1,nlayer
          DO ig=1,ngrid
@@ -531,5 +532,5 @@
              zu(l)   =pu(ig,l)   +pdu( ig,l)  *ptimestep
              zv(l)   =pv(ig,l)   +pdv( ig,l)  *ptimestep
-            do iq=1,nqmx
+            do iq=1,nq
              zq(l,iq)=pq(ig,l,iq)+pdq(ig,l,iq)*ptimestep
             enddo
@@ -564,5 +565,5 @@
             zum(1) = 0  
             zvm(1) = 0  
-            do iq=1,nqmx
+            do iq=1,nq
               zqm(1,iq)=0. ! most tracer do not condense !
             enddo
@@ -577,5 +578,5 @@
             call vl1d(zu ,2.,masse,w,zum) 
             call vl1d(zv ,2.,masse,w,zvm) 
-            do iq=1,nqmx
+            do iq=1,nq
              do l=1,nlayer
               zq1(l)=zq(l,iq)
@@ -602,5 +603,5 @@
             zum(nlayer+1)= zu(nlayer)  ! should not be used, but...
             zvm(nlayer+1)= zv(nlayer)  ! should not be used, but...
-            do iq=1,nqmx
+            do iq=1,nq
              zqm(nlayer+1,iq)= zq(nlayer,iq)
             enddo
@@ -637,5 +638,5 @@
 
 c           Tendencies on Q
-            do iq=1,nqmx
+            do iq=1,nq
 !              if (noms(iq).eq.'co2') then 
               if (iq.eq.ico2) then 
@@ -668,5 +669,5 @@
              if(pq(ig,1,ico2)+(pdq(ig,1,ico2)+pdqc(ig,1,ico2))*ptimestep
      &       .lt.qco2min) then 
-                do iq=1,nqmx
+                do iq=1,nq
                   zq(1,iq)=pq(ig,1,iq)
      &                     +(pdq(ig,1,iq)+pdqc(ig,1,iq))*ptimestep
@@ -675,5 +676,5 @@
                 Sm(1)  = masse(1)
                 do l =2,nlayermx
-                  do iq=1,nqmx
+                  do iq=1,nq
                      zq(l,iq)=pq(ig,l,iq)
      &                        +(pdq(ig,l,iq)+pdqc(ig,l,iq))*ptimestep
@@ -693,5 +694,5 @@
                  end do
  99              continue 
-                 do iq=1,nqmx
+                 do iq=1,nq
                    qmix=zq(nmix,iq) 
      &             +(Smq(nmix-1,iq)-zq(nmix,iq)*Sm(nmix-1))/mixmas
Index: /trunk/LMDZ.MARS/libf/phymars/nirco2abs.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/nirco2abs.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/nirco2abs.F	(revision 1036)
@@ -2,4 +2,5 @@
      $     mu0,fract,declin,pdtnirco2)
                                                    
+       use tracer_mod, only: igcm_co2, igcm_o
        IMPLICIT NONE
 c=======================================================================
@@ -50,5 +51,5 @@
 #include "comdiurn.h"
 #include "nirdata.h"
-#include "tracer.h"
+!#include "tracer.h"
 
 c-----------------------------------------------------------------------
Index: /trunk/LMDZ.MARS/libf/phymars/nltecool.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/nltecool.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/nltecool.F	(revision 1036)
@@ -30,4 +30,5 @@
 c***************************************************************************
 
+      use tracer_mod, only: igcm_co2, igcm_co, igcm_o, igcm_n2, mmol
       implicit none
 
@@ -37,5 +38,5 @@
 #include "chimiedata.h"
 #include "conc.h" !Added to have "dynamic composition" in the scheme
-#include "tracer.h" !"
+!#include "tracer.h" !"
 #include "callkeys.h"
 
Index: /trunk/LMDZ.MARS/libf/phymars/nuclea.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/nuclea.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/nuclea.F	(revision 1036)
@@ -17,5 +17,5 @@
 #include "dimphys.h"
 #include "comcstfi.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "microphys.h"
 
Index: /trunk/LMDZ.MARS/libf/phymars/phyetat0.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/phyetat0.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/phyetat0.F	(revision 1036)
@@ -4,4 +4,5 @@
 
       use netcdf
+      use infotrac, only: nqtot, tnom
 
       implicit none
@@ -25,5 +26,5 @@
 #include "comcstfi.h"
 !#include "tracer.h"
-#include "advtrac.h"
+!#include "advtrac.h"
 #include "control.h"
 c======================================================================
@@ -96,5 +97,5 @@
 !                    qsurf02, ...)
       count=0
-      do iq=1,nqmx
+      do iq=1,nqtot
         txt= " "
         write(txt,'(a5,i2.2)')'qsurf',iq
@@ -108,5 +109,5 @@
         endif
       enddo
-      if (count.eq.nqmx) then
+      if (count.eq.nqtot) then
         write(*,*) "phyetat0:tracers seem to follow old naming ",
      &             "convention (qsurf01,qsurf02,...)"
@@ -650,9 +651,9 @@
 c        case when new tracer are added in addition to old ones
              write(*,*)'qsurf 1 to ', nqold,'were already present'
-             write(*,*)'qsurf ', nqold+1,' to ', nqmx,'are new'
+             write(*,*)'qsurf ', nqold+1,' to ', nqtot,'are new'
 !            yes=' '
 !            do while ((yes.ne.'y').and.(yes.ne.'n'))
 !             write(*,*) 'Would you like to reindex qsurf # 1 ->',nqold
-!             write(*,*) 'to #',nqmx-nqold+1,'->', nqmx,'   (y or n) ?'
+!             write(*,*) 'to #',nqtot-nqold+1,'->', nqtot,'   (y or n) ?'
 !             read(*,fmt='(a)') yes
 !            end do
@@ -660,8 +661,8 @@
 !              write(*,*) 'OK, let s reindex qsurf'
 !                 do ig=1,ngridmx
-!                    do iq=nqmx,nqmx-nqold+1,-1
-!                       qsurf(ig,iq)=qsurf(ig,iq-nqmx+nqold)
+!                    do iq=nqtot,nqtot-nqold+1,-1
+!                       qsurf(ig,iq)=qsurf(ig,iq-nqtot+nqold)
 !                    end do
-!                    do iq=nqmx-nqold,1,-1
+!                    do iq=nqtot-nqold,1,-1
 !                       qsurf(ig,iq)= 0.
 !                    end do
Index: /trunk/LMDZ.MARS/libf/phymars/physdem.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/physdem.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/physdem.F	(revision 1036)
@@ -3,4 +3,5 @@
      .                   alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe)
 
+      use infotrac, only: nqtot, tnom
       implicit none
 c
@@ -32,5 +33,5 @@
 #include "netcdf.inc"
 #include "dimphys.h"
-#include "advtrac.h"
+!#include "advtrac.h"
 #include "callkeys.h"
 c
@@ -585,5 +586,5 @@
 !                    qsurf02, ...)
       count=0
-      do iq=1,nqmx
+      do iq=1,nqtot
         txt= " "
         write(txt,'(a1,i2.2)')'q',iq
@@ -596,5 +597,5 @@
         endif
       enddo
-      if (count.eq.nqmx) then
+      if (count.eq.nqtot) then
         write(*,*) "physdem0:tracers seem to follow old naming ",
      &             "convention (qsurf01,qsurf02,...)"
@@ -602,5 +603,5 @@
         write(*,*) "     but you should run newstart to rename them"
         oldtracernames=.true.
-      endif ! of if (count.eq.nqmx)
+      endif ! of if (count.eq.nqtot)
 
       IF(nq.GE.1) THEN
@@ -693,4 +694,5 @@
      .                   phystep,time,
      .                   tsurf,tsoil,co2ice,emis,q2,qsurf)
+      use infotrac, only: nqtot, tnom
       implicit none
 c
@@ -720,5 +722,5 @@
 #include "netcdf.inc"
 #include "dimphys.h"
-#include "advtrac.h"
+!#include "advtrac.h"
 #include "callkeys.h"
 c
@@ -918,5 +920,5 @@
       IF (firstcall) THEN
         count=0
-        do iq=1,nqmx
+        do iq=1,nqtot
           txt= " "
           write(txt,'(a1,i2.2)')'q',iq
@@ -929,5 +931,5 @@
           endif
         enddo
-        if (count.eq.nqmx) then
+        if (count.eq.nqtot) then
           write(*,*) "physdem1:tracers seem to follow old naming ",
      &               "convention (qsurf01,qsurf02,...)"
@@ -935,13 +937,13 @@
           write(*,*) "     but you should run newstart to rename them"
           oldtracernames=.true.
-        endif ! of if (count.eq.nqmx)
+        endif ! of if (count.eq.nqtot)
       ENDIF ! of if(firstcall)
       
       ! If computing water cycle with ice, move surface ice
-      ! back to qsurf(nqmx)
+      ! back to qsurf(nqtot)
       IF (oldtracernames .and. water) THEN
        !"loop" to avoid potential out-of-bounds on arrays
-        write(*,*)'physdem1: moving surface water ice to index ',nqmx
-        do iq=nqmx,nqmx
+        write(*,*)'physdem1: moving surface water ice to index ',nqtot
+        do iq=nqtot,nqtot
           qsurf(1:ngridmx,iq)=qsurf(1:ngridmx,iq-1)
           qsurf(1:ngridmx,iq-1)=0
Index: /trunk/LMDZ.MARS/libf/phymars/physiq.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/physiq.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/physiq.F	(revision 1036)
@@ -12,5 +12,13 @@
      $            )
 
-
+      use tracer_mod, only: noms, mmol, igcm_co2, igcm_n2,
+     &                      igcm_co, igcm_o, igcm_h2o_vap, igcm_h2o_ice,
+     &                      igcm_ccn_mass, igcm_ccn_number,
+     &                      igcm_dust_mass, igcm_dust_number, igcm_h2o2,
+     &                      nuice_ref, rho_ice, rho_dust, ref_r0
+
+#ifdef MESOSCALE
+      use infotrac !!! this is necessary for tracers 
+#endif
       IMPLICIT NONE
 c=======================================================================
@@ -103,5 +111,5 @@
 c    pdv(ngrid,nlayermx)       |  Temporal derivative of the corresponding
 c    pdt(ngrid,nlayermx)       |  variables due to physical processes.
-c    pdq(ngrid,nlayermx,nqmx)  |
+c    pdq(ngrid,nlayermx,nq)    |
 c    pdpsrf(ngrid)             |
 c    tracerdyn                 call tracer in dynamical part of GCM ?
@@ -126,5 +134,5 @@
 #include "dimradmars.h"
 #include "comg1d.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "nlteparams.h"
 #include "comvert.h"
@@ -142,5 +150,5 @@
 #include "wrf_output_2d.h"
 #include "wrf_output_3d.h"
-#include "advtrac.h"   !!! this is necessary for tracers (in dyn3d)
+!#include "advtrac.h"   !!! this is necessary for tracers (in dyn3d)
 #include "meso_inc/meso_inc_var.F"
 #endif
@@ -192,5 +200,5 @@
       REAL capcal(ngridmx)           ! surface heat capacity (J m-2 K-1)
       REAL fluxgrd(ngridmx)          ! surface conduction flux (W.m-2)
-      REAL qsurf(ngridmx,nqmx)       ! tracer on surface (e.g. kg.m-2)
+      REAL,ALLOCATABLE,SAVE :: qsurf(:,:) ! tracer on surface (e.g. kg.m-2)
       REAL q2(ngridmx,nlayermx+1)    ! Turbulent Kinetic Energy
       
@@ -217,5 +225,5 @@
       SAVE aerosol, tsurf,tsoil
       SAVE co2ice,albedo,emis, q2
-      SAVE capcal,fluxgrd,dtrad,fluxrad,fluxrad_sky,qsurf
+      SAVE capcal,fluxgrd,dtrad,fluxrad,fluxrad_sky
 
       REAL stephan   
@@ -229,6 +237,6 @@
       EXTERNAL CBRT
 
-      CHARACTER*80 fichier 
-      INTEGER l,ig,ierr,igout,iq,i, tapphys
+!      CHARACTER*80 fichier 
+      INTEGER l,ig,ierr,igout,iq,tapphys
 
       REAL fluxsurf_lw(ngridmx)      !incident LW (IR) surface flux (W.m-2)
@@ -243,12 +251,12 @@
       REAL zzlay(ngridmx,nlayermx)   ! altitude at the middle of the layers
       REAL zzlev(ngridmx,nlayermx+1) ! altitude at layer boundaries
-      REAL latvl1,lonvl1             ! Viking Lander 1 point (for diagnostic)
+!      REAL latvl1,lonvl1             ! Viking Lander 1 point (for diagnostic)
 
 c     Tendancies due to various processes:
-      REAL dqsurf(ngridmx,nqmx)
+      REAL dqsurf(ngridmx,nq)
       REAL zdtlw(ngridmx,nlayermx)     ! (K/s)
       REAL zdtsw(ngridmx,nlayermx)     ! (K/s)
-      REAL cldtlw(ngridmx,nlayermx)     ! (K/s) LW heating rate for clear area
-      REAL cldtsw(ngridmx,nlayermx)     ! (K/s) SW heating rate for clear area
+!      REAL cldtlw(ngridmx,nlayermx)     ! (K/s) LW heating rate for clear area
+!      REAL cldtsw(ngridmx,nlayermx)     ! (K/s) SW heating rate for clear area
       REAL zdtnirco2(ngridmx,nlayermx) ! (K/s)
       REAL zdtnlte(ngridmx,nlayermx)   ! (K/s)
@@ -264,13 +272,13 @@
       REAL zdvc(ngridmx,nlayermx),zduc(ngridmx,nlayermx)
 
-      REAL zdqdif(ngridmx,nlayermx,nqmx), zdqsdif(ngridmx,nqmx)
-      REAL zdqsed(ngridmx,nlayermx,nqmx), zdqssed(ngridmx,nqmx)
-      REAL zdqdev(ngridmx,nlayermx,nqmx), zdqsdev(ngridmx,nqmx)
-      REAL zdqadj(ngridmx,nlayermx,nqmx)
-      REAL zdqc(ngridmx,nlayermx,nqmx)
-      REAL zdqcloud(ngridmx,nlayermx,nqmx)
-      REAL zdqscloud(ngridmx,nqmx)
-      REAL zdqchim(ngridmx,nlayermx,nqmx)
-      REAL zdqschim(ngridmx,nqmx)
+      REAL zdqdif(ngridmx,nlayermx,nq), zdqsdif(ngridmx,nq)
+      REAL zdqsed(ngridmx,nlayermx,nq), zdqssed(ngridmx,nq)
+      REAL zdqdev(ngridmx,nlayermx,nq), zdqsdev(ngridmx,nq)
+      REAL zdqadj(ngridmx,nlayermx,nq)
+      REAL zdqc(ngridmx,nlayermx,nq)
+      REAL zdqcloud(ngridmx,nlayermx,nq)
+      REAL zdqscloud(ngridmx,nq)
+      REAL zdqchim(ngridmx,nlayermx,nq)
+      REAL zdqschim(ngridmx,nq)
 
       REAL zdteuv(ngridmx,nlayermx)    ! (K/s)
@@ -278,5 +286,5 @@
       REAL zdumolvis(ngridmx,nlayermx)
       REAL zdvmolvis(ngridmx,nlayermx)
-      real zdqmoldiff(ngridmx,nlayermx,nqmx)
+      real zdqmoldiff(ngridmx,nlayermx,nq)
 
 c     Local variable for local intermediate calcul:
@@ -295,8 +303,8 @@
       REAL ps(ngridmx), zt(ngridmx,nlayermx)
       REAL zu(ngridmx,nlayermx),zv(ngridmx,nlayermx)
-      REAL zq(ngridmx,nlayermx,nqmx)
+      REAL zq(ngridmx,nlayermx,nq)
       REAL fluxtop_sw_tot(ngridmx), fluxsurf_sw_tot(ngridmx)
       character*2 str2
-      character*5 str5
+!      character*5 str5
       real zdtdif(ngridmx,nlayermx), zdtadj(ngridmx,nlayermx)
       REAL tauscaling(ngridmx)   ! Convertion factor for qdust and Ndust
@@ -310,10 +318,10 @@
       ! instead, use zplay and zplev :
       REAL zplev(ngrid,nlayermx+1),zplay(ngrid,nlayermx) 
-      REAL zstress(ngrid), cd
-      real hco2(nqmx),tmean, zlocal(nlayermx)
+!      REAL zstress(ngrid),cd
+      real tmean, zlocal(nlayermx)
       real rho(ngridmx,nlayermx)  ! density
       real vmr(ngridmx,nlayermx)  ! volume mixing ratio
       real rhopart(ngridmx,nlayermx) ! number density of a given species
-      real colden(ngridmx,nqmx)   ! vertical column of tracers
+      real colden(ngridmx,nq)     ! vertical column of tracers
       REAL mtot(ngridmx)          ! Total mass of water vapor (kg/m2)
       REAL icetot(ngridmx)        ! Total mass of water ice (kg/m2)
@@ -357,5 +365,5 @@
       REAL, SAVE :: hfmax_th(ngridmx)
       REAL pdu_th(ngridmx,nlayermx),pdv_th(ngridmx,nlayermx)
-      REAL pdt_th(ngridmx,nlayermx),pdq_th(ngridmx,nlayermx,nqmx)
+      REAL pdt_th(ngridmx,nlayermx),pdq_th(ngridmx,nlayermx,nq)
       INTEGER lmax_th(ngridmx),dimout,n_out,n
       CHARACTER(50) zstring
@@ -364,9 +372,11 @@
       REAL, ALLOCATABLE, DIMENSION(:,:) :: T_out
       REAL, ALLOCATABLE, DIMENSION(:,:) :: u_out ! Interpolated teta and u at z_out
-      REAL u_out1(ngridmx), T_out1(ngridmx)
+!      REAL u_out1(ngridmx)
+      REAL T_out1(ngridmx)
       REAL, ALLOCATABLE, DIMENSION(:) :: z_out     ! height of interpolation between z0 and z1 [meters]
       REAL ustar(ngridmx),tstar(ngridmx)  ! friction velocity and friction potential temp
       REAL L_mo(ngridmx),vhf(ngridmx),vvv(ngridmx)
-      REAL zu2(ngridmx),sensibFlux(ngridmx)
+!      REAL zu2(ngridmx)
+      REAL sensibFlux(ngridmx)
 
 c=======================================================================
@@ -379,4 +389,7 @@
       IF (firstcall) THEN
 
+        ! allocate local (saved) arrays:
+        allocate(qsurf(ngrid,nq))
+        
 c        variables set to 0
 c        ~~~~~~~~~~~~~~~~~~
@@ -417,5 +430,5 @@
          tracerdyn=tracer
          IF (tracer) THEN
-            CALL initracer(qsurf,co2ice)
+            CALL initracer(ngrid,nq,qsurf,co2ice)
          ENDIF  ! end tracer
 
@@ -570,5 +583,5 @@
 
       if(photochem.or.callthermos) then
-         call concentrations(zplay,pt,pdt,pq,pdq,ptimestep)
+         call concentrations(nq,zplay,pt,pdt,pq,pdq,ptimestep)
       endif
 #endif
@@ -1214,5 +1227,6 @@
      $                       surfdust, surfice)
 !           call photochemistry
-            call calchim(ptimestep,zplay,zplev,pt,pdt,dist_sol,mu0,
+            call calchim(nq,
+     &                   ptimestep,zplay,zplev,pt,pdt,dist_sol,mu0,
      $                   zzlev,zzlay,zday,pq,pdq,zdqchim,zdqschim,
      $                   zdqcloud,zdqscloud,tauref,co2ice,
Index: /trunk/LMDZ.MARS/libf/phymars/simpleclouds.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/simpleclouds.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/simpleclouds.F	(revision 1036)
@@ -4,4 +4,5 @@
      &             nq,tau,rice)
       USE updaterad
+      use tracer_mod, only: igcm_h2o_vap, igcm_h2o_ice
       implicit none
 c------------------------------------------------------------------
@@ -32,5 +33,5 @@
 #include "comcstfi.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "comgeomfi.h"
 #include "dimradmars.h"
@@ -73,6 +74,6 @@
       INTEGER ig,l
 
-      REAL zq(ngridmx,nlayermx,nqmx)  ! local value of tracers
-      REAL zq0(ngridmx,nlayermx,nqmx) ! local initial value of tracers
+      REAL zq(ngridmx,nlayermx,nq)    ! local value of tracers
+      REAL zq0(ngridmx,nlayermx,nq)   ! local initial value of tracers
       REAL zt(ngridmx,nlayermx)       ! local value of temperature
       REAL zqsat(ngridmx,nlayermx)    ! saturation
@@ -91,5 +92,5 @@
 c    -----------------
 
-c    On "update" la valeur de q(nqmx) (water vapor) et temperature.
+c    On "update" la valeur de q(nq) (water vapor) et temperature.
 c    On effectue qqes calculs preliminaires sur les couches : 
 
Index: /trunk/LMDZ.MARS/libf/phymars/soil_tifeedback.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/soil_tifeedback.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/soil_tifeedback.F	(revision 1036)
@@ -1,3 +1,5 @@
       SUBROUTINE soil_tifeedback(ngrid,nsoil,icecover,newtherm_i)
+
+      use tracer_mod, only: nqmx, igcm_h2o_ice, rho_ice
       IMPLICIT NONE
 
@@ -24,5 +26,5 @@
 #include "dimphys.h"
 #include "comsoil.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "surfdat.h"
 
@@ -41,5 +43,5 @@
 
       REAL icecover(ngrid,nqmx)         ! tracer on the surface (kg.m-2)
-                                        ! last one (iq=nqmx) is surface
+                                        ! (iq=igcm_h2o_ice) is surface
                                         ! water ice
 c Outputs
Index: /trunk/LMDZ.MARS/libf/phymars/surfini.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/surfini.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/surfini.F	(revision 1036)
@@ -3,4 +3,5 @@
       USE ioipsl_getincom
       use netcdf
+      use tracer_mod, only: nqmx, noms, dryness
       IMPLICIT NONE
 c=======================================================================
@@ -16,5 +17,5 @@
 #include "surfdat.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "comgeomfi.h"
 #include "comcstfi.h"
Index: /trunk/LMDZ.MARS/libf/phymars/testphys1d.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/testphys1d.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/testphys1d.F	(revision 1036)
@@ -2,5 +2,6 @@
       PROGRAM testphys1d
 ! to use  'getin'
-      USE ioipsl_getincom 
+      USE ioipsl_getincom, only: getin
+      use infotrac, only: nqtot, tnom
       IMPLICIT NONE
 
@@ -42,5 +43,5 @@
 #include "comg1d.h"
 #include "logic.h"
-#include "advtrac.h"
+!#include "advtrac.h"
 
 c --------------------------------------------------------------
@@ -64,6 +65,6 @@
       REAL gru,grv   ! prescribed "geostrophic" background wind
       REAL temp(nlayermx)   ! temperature at the middle of the layers
-      REAL q(nlayermx,nqmx) ! tracer mixing ratio (e.g. kg/kg)
-      REAL qsurf(nqmx)      ! tracer surface budget (e.g. kg.m-2)
+      REAL,ALLOCATABLE :: q(:,:) ! tracer mixing ratio (e.g. kg/kg)
+      REAL,ALLOCATABLE :: qsurf(:) ! tracer surface budget (e.g. kg.m-2)
       REAL tsoil(nsoilmx)   ! subsurface soik temperature (K)
       REAL co2ice           ! co2ice layer (kg.m-2)
@@ -76,6 +77,6 @@
       REAL dudyn(nlayermx),dvdyn(nlayermx),dtempdyn(nlayermx)
       REAL dpsurf    
-      REAL dq(nlayermx,nqmx)
-      REAL dqdyn(nlayermx,nqmx)
+      REAL,ALLOCATABLE :: dq(:,:)
+      REAL,ALLOCATABLE :: dqdyn(:,:)
 
 c   Various intermediate variables
@@ -84,5 +85,6 @@
       REAL phi(nlayermx),h(nlayermx),s(nlayermx)
       REAL pks, ptif, w(nlayermx)
-      REAL qtotinit, mqtot(nqmx),qtot
+      REAL qtotinit,qtot
+      real,allocatable :: mqtot(:)
       INTEGER ierr, aslun
       REAL tmp1(0:nlayermx),tmp2(0:nlayermx)
@@ -169,5 +171,5 @@
 
 ! while we're at it, check if there is a 'traceur.def' file
-! and preocess it, if necessary. Otherwise initialize tracer names
+! and process it.
       if (tracer) then
       ! load tracer names from file 'traceur.def'
@@ -183,19 +185,21 @@
           ! read number of tracers:
           read(90,*,iostat=ierr) nq
+          nqtot=nq ! set value of nqtot (in infotrac module) as nq
           if (ierr.ne.0) then
             write(*,*) "testphys1d: error reading number of tracers"
             write(*,*) "   (first line of traceur.def) "
             stop
-          else
-            ! check that the number of tracers is indeed nqmx
-            if (nq.ne.nqmx) then
-              write(*,*) "testphys1d: error, wrong number of tracers:"
-              write(*,*) "nq=",nq," whereas nqmx=",nqmx
-              stop
-            endif
           endif
         endif
+        ! allocate arrays:
+        allocate(tnom(nq))
+        allocate(q(nlayermx,nq))
+        allocate(qsurf(nq))
+        allocate(dq(nlayermx,nq))
+        allocate(dqdyn(nlayermx,nq))
+        allocate(mqtot(nq))
+        
         ! read tracer names from file traceur.def
-        do iq=1,nqmx
+        do iq=1,nq
           read(90,*,iostat=ierr) tnom(iq)
           if (ierr.ne.0) then
@@ -212,5 +216,5 @@
         ! "smarter" initialization of some tracers
         ! (get values from "profile_*" files, if these are available)
-        do iq=1,nqmx
+        do iq=1,nq
           txt=""
           write(txt,"(a)") tnom(iq)
@@ -346,9 +350,16 @@
             close(91)
           endif ! of if (txt.eq."ccn_number")
-        enddo ! of do iq=1,nqmx
+        enddo ! of do iq=1,nq
 
       else
-      ! we still need to set (dummy) tracer names for physdem1
-        nq=nqmx
+      ! we still need to set (dummy) tracer number and names for physdem1
+        nq=1
+        ! allocate arrays:
+        allocate(tnom(nq))
+        allocate(q(nlayermx,nq))
+        allocate(qsurf(nq))
+        allocate(dq(nlayermx,nq))
+        allocate(dqdyn(nlayermx,nq))
+        allocate(mqtot(nq))
         do iq=1,nq
           write(str7,'(a1,i2.2)')'q',iq
@@ -496,5 +507,5 @@
 
 !Mars possible matter with dtphys in input and include!!!
-      CALL inifis(1,llm,day0,daysec,dtphys,
+      CALL inifis(1,llm,nq,day0,daysec,dtphys,
      .            lati,long,area,rad,g,r,cpp)
 
@@ -612,5 +623,5 @@
          ! thermo=0: initialize over all atmospheric layers
          thermo=0
-         call inichim_newstart(q,psurf,sig,nqmx,lati,long,area,
+         call inichim_newstart(q,psurf,sig,nq,lati,long,area,
      $   thermo,qsurf)
       endif
@@ -641,8 +652,8 @@
 c  It is needed to transfert physics variables to "physiq"...
 
-      call physdem0("startfi.nc",long,lati,nsoilmx,nqmx,
+      call physdem0("startfi.nc",long,lati,nsoilmx,nq,
      .              dtphys,float(day0),time,area,
      .              albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe)
-      call physdem1("startfi.nc",nsoilmx,nqmx,
+      call physdem1("startfi.nc",nsoilmx,nq,
      .              dtphys,time,
      .              tsurf,tsoil,co2ice,emis,q2,qsurf)
@@ -688,5 +699,5 @@
 c       --------------------
 !      write(*,*) "testphys1d avant q", q(1,:)
-      CALL physiq (1,llm,nqmx,
+      CALL physiq (1,llm,nq,
      ,     firstcall,lastcall,
      ,     day,time,dtphys,
@@ -749,5 +760,5 @@
 
 !       increment tracers
-        DO iq = 1, nqmx
+        DO iq = 1, nq
           DO ilayer=1,nlayer
              q(ilayer,iq)=q(ilayer,iq)+dtphys*dq(ilayer,iq)
Index: unk/LMDZ.MARS/libf/phymars/tracer.h
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/tracer.h	(revision 1035)
+++ 	(revision )
@@ -1,90 +1,0 @@
-!-----------------------------------------------------------------------
-! INCLUDE 'tracer.h'
-
-      character*20  noms(nqmx)  ! name of the tracer
-      real mmol(nqmx)           ! mole mass of tracer (g/mol-1) 
-      real radius(nqmx)   ! dust and ice particle radius (m)
-      real rho_q(nqmx)    ! tracer densities (kg.m-3)
-      real alpha_lift(nqmx) ! saltation vertical flux/horiz flux ratio (m-1)
-      real alpha_devil(nqmx) ! lifting coeeficient by dust devil
-
-      real varian      ! Characteristic variance of log-normal distribution
-      real r3n_q     ! used to compute r0 from number and mass mixing ratio
-      real rho_dust     ! Mars dust density (kg.m-3)
-      real rho_ice     ! Water ice density (kg.m-3)
-      real nuice_ref   ! Effective variance of the water ice dist.
-      real nuice_sed   ! Sedimentation effective variance of the water ice dist.
-      real ref_r0        ! for computing reff=ref_r0*r0 (in log.n. distribution)
-      
-      real ccn_factor  ! ratio of nuclei for water ice particles
-
-      real dryness(ngridmx)!"Dryness coefficient" for grnd water ice sublimation
-      
-! tracer indexes: these are initialized in initracer and should be 0 if the
-!                 corresponding tracer does not exist
-      ! dust
-      integer :: igcm_dustbin(nqmx) ! for dustbin 'dust' tracers
-      ! dust, special doubleq case
-      integer :: igcm_dust_mass   ! dust mass mixing ratio
-                                  !   (for transported dust)
-      integer :: igcm_dust_number ! dust number mixing ratio
-                                  !   (transported dust)
-      integer :: igcm_ccn_mass   ! CCN mass mixing ratio
-      integer :: igcm_ccn_number ! CCN number mixing ratio
-      integer :: igcm_dust_submicron ! submicron dust mixing ratio
-                                     !   (transported dust)
-      ! water
-      integer :: igcm_h2o_vap ! water vapour
-      integer :: igcm_h2o_ice ! water ice
-      ! chemistry:
-      integer :: igcm_co2
-      integer :: igcm_co
-      integer :: igcm_o
-      integer :: igcm_o1d
-      integer :: igcm_o2
-      integer :: igcm_o3
-      integer :: igcm_h
-      integer :: igcm_h2
-      integer :: igcm_oh
-      integer :: igcm_ho2
-      integer :: igcm_h2o2
-      integer :: igcm_n2
-      integer :: igcm_ar
-      integer :: igcm_n
-      integer :: igcm_no
-      integer :: igcm_no2
-      integer :: igcm_n2d
-      integer :: igcm_ch4
-      ! Ions
-      integer :: igcm_co2plus
-      integer :: igcm_oplus
-      integer :: igcm_o2plus
-      integer :: igcm_coplus
-      integer :: igcm_cplus
-      integer :: igcm_nplus
-      integer :: igcm_noplus
-      integer :: igcm_n2plus 
-      integer :: igcm_hplus
-      integer :: igcm_hco2plus
-      integer :: igcm_elec
-      ! other tracers
-      integer :: igcm_ar_n2 ! for simulations using co2 +neutral gas
-
-
-! NB: to keep commons aligned: 
-!     split them in groups (reals, integers and characters)
-      COMMON/tracer/radius,rho_q,alpha_lift,alpha_devil,mmol,           &
-     & varian,r3n_q,rho_dust,rho_ice,nuice_ref,nuice_sed,               &
-     & ref_r0,ccn_factor,dryness
-      COMMON/tracer2/                                                   &
-     & igcm_dustbin,igcm_dust_mass,igcm_dust_number,                    &
-     & igcm_ccn_mass,igcm_ccn_number,igcm_dust_submicron,               &
-     & igcm_h2o_vap,igcm_h2o_ice,igcm_co2,igcm_co,igcm_o,igcm_o1d,      &
-     & igcm_o2,igcm_o3,igcm_h,igcm_h2,igcm_oh,igcm_ho2,igcm_h2o2,       &
-     & igcm_n2,igcm_ar,igcm_n,igcm_no,igcm_no2,igcm_n2d,                &
-     & igcm_ch4,                                                        &
-     & igcm_co2plus,igcm_oplus,igcm_o2plus,igcm_coplus,igcm_cplus,      &
-     & igcm_nplus,igcm_noplus,igcm_n2plus,igcm_hplus,igcm_elec,         &
-     & igcm_hco2plus,igcm_ar_n2!,nbqchem,niqchem
-      COMMON/tracer3/noms
-!-----------------------------------------------------------------------
Index: /trunk/LMDZ.MARS/libf/phymars/tracer_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/tracer_mod.F90	(revision 1036)
+++ /trunk/LMDZ.MARS/libf/phymars/tracer_mod.F90	(revision 1036)
@@ -0,0 +1,80 @@
+module tracer_mod
+
+ implicit none
+ 
+      ! number of tracers:
+      integer,save :: nqmx ! initialized in inifis
+      
+      character*20,allocatable,save ::  noms(:)  ! name of the tracer
+      real,allocatable,save :: mmol(:)           ! mole mass of tracer (g/mol-1) 
+      real,allocatable,save :: radius(:)   ! dust and ice particle radius (m)
+      real,allocatable,save :: rho_q(:)    ! tracer densities (kg.m-3)
+      real,allocatable,save :: alpha_lift(:) ! saltation vertical flux/horiz flux ratio (m-1)
+      real,allocatable,save :: alpha_devil(:) ! lifting coeeficient by dust devil
+
+      real,save :: varian      ! Characteristic variance of log-normal distribution
+      real,save :: r3n_q     ! used to compute r0 from number and mass mixing ratio
+      real,save :: rho_dust     ! Mars dust density (kg.m-3)
+      real,save :: rho_ice     ! Water ice density (kg.m-3)
+      real,save :: nuice_ref   ! Effective variance of the water ice dist.
+      real,save :: nuice_sed   ! Sedimentation effective variance of the water ice dist.
+      real,save :: ref_r0        ! for computing reff=ref_r0*r0 (in log.n. distribution)
+      
+      real,save :: ccn_factor  ! ratio of nuclei for water ice particles
+
+      real,allocatable,save :: dryness(:)!"Dryness coefficient" for grnd water ice sublimation
+      
+! tracer indexes: these are initialized in initracer and should be 0 if the
+!                 corresponding tracer does not exist
+      ! dust
+      integer,allocatable,save :: igcm_dustbin(:) ! for dustbin 'dust' tracers
+      ! dust, special doubleq case
+      integer,save :: igcm_dust_mass   ! dust mass mixing ratio
+                                  !   (for transported dust)
+      integer,save :: igcm_dust_number ! dust number mixing ratio
+                                  !   (transported dust)
+      integer,save :: igcm_ccn_mass   ! CCN mass mixing ratio
+      integer,save :: igcm_ccn_number ! CCN number mixing ratio
+      integer,save :: igcm_dust_submicron ! submicron dust mixing ratio
+                                     !   (transported dust)
+      ! water
+      integer,save :: igcm_h2o_vap ! water vapour
+      integer,save :: igcm_h2o_ice ! water ice
+      ! chemistry:
+      integer,save :: igcm_co2
+      integer,save :: igcm_co
+      integer,save :: igcm_o
+      integer,save :: igcm_o1d
+      integer,save :: igcm_o2
+      integer,save :: igcm_o3
+      integer,save :: igcm_h
+      integer,save :: igcm_h2
+      integer,save :: igcm_oh
+      integer,save :: igcm_ho2
+      integer,save :: igcm_h2o2
+      integer,save :: igcm_n2
+      integer,save :: igcm_ar
+      integer,save :: igcm_n
+      integer,save :: igcm_no
+      integer,save :: igcm_no2
+      integer,save :: igcm_n2d
+      integer,save :: igcm_ch4
+      ! Ions
+      integer,save :: igcm_co2plus
+      integer,save :: igcm_oplus
+      integer,save :: igcm_o2plus
+      integer,save :: igcm_coplus
+      integer,save :: igcm_cplus
+      integer,save :: igcm_nplus
+      integer,save :: igcm_noplus
+      integer,save :: igcm_n2plus 
+      integer,save :: igcm_hplus
+      integer,save :: igcm_hco2plus
+      integer,save :: igcm_elec
+      ! other tracers
+      integer,save :: igcm_ar_n2 ! for simulations using co2 +neutral gas
+
+
+!-----------------------------------------------------------------------
+
+end module tracer_mod
Index: /trunk/LMDZ.MARS/libf/phymars/updaterad.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/updaterad.F90	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/updaterad.F90	(revision 1036)
@@ -62,10 +62,11 @@
 ! Update ice radius if microphys == true 
 subroutine updaterice_micro(qice,qccn,nccn,coeff,rice,rhocloud)
-implicit none
-
-#include "dimensions.h"
-#include "dimphys.h"
-#include "comcstfi.h"
-#include "tracer.h"
+use tracer_mod, only: rho_dust, rho_ice
+implicit none
+
+#include "dimensions.h"
+#include "dimphys.h"
+#include "comcstfi.h"
+!#include "tracer.h"
 
 real, intent(in)  :: qice,qccn,nccn
@@ -118,10 +119,11 @@
 ! Update ice radius from a typical profile if microphys == false
 subroutine updaterice_typ(qice,tau,pzlay,rice)
-implicit none
-
-#include "dimensions.h"
-#include "dimphys.h"
-#include "comcstfi.h"
-#include "tracer.h"
+use tracer_mod, only: rho_ice
+implicit none
+
+#include "dimensions.h"
+#include "dimphys.h"
+#include "comcstfi.h"
+!#include "tracer.h"
 
 real, intent(in)  :: qice
@@ -175,10 +177,11 @@
 ! To be used with doubleq == true. otherwise, rdust is constant !!!
 subroutine updaterdust(qdust,ndust,rdust,tauscaling)
-implicit none
-
-#include "dimensions.h"
-#include "dimphys.h"
-#include "comcstfi.h"
-#include "tracer.h"
+use tracer_mod, only: r3n_q
+implicit none
+
+#include "dimensions.h"
+#include "dimphys.h"
+#include "comcstfi.h"
+!#include "tracer.h"
 
 real, intent(in) :: qdust,ndust ! needed if doubleq
@@ -230,10 +233,11 @@
 ! geometric mean radius = mass mean radius x exp(-1.5 sigma0^2)
 subroutine updaterccn(qccn,nccn,rccn,tauscaling)
-implicit none
-
-#include "dimensions.h"
-#include "dimphys.h"
-#include "comcstfi.h"
-#include "tracer.h"
+use tracer_mod, only: rho_dust
+implicit none
+
+#include "dimensions.h"
+#include "dimphys.h"
+#include "comcstfi.h"
+!#include "tracer.h"
 
 real, intent(in) :: qccn,nccn ! needed if doubleq
Index: /trunk/LMDZ.MARS/libf/phymars/updatereffrad.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/updatereffrad.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/updatereffrad.F	(revision 1036)
@@ -4,4 +4,8 @@
      &                pq,tauscaling,tau,pplay)
        USE updaterad
+       use tracer_mod, only: nqmx, igcm_dust_mass, igcm_dust_number,
+     &                       igcm_h2o_ice, igcm_ccn_mass, radius,
+     &                       igcm_ccn_number, nuice_ref, varian,
+     &                       ref_r0, igcm_dust_submicron
        IMPLICIT NONE
 c=======================================================================
@@ -31,5 +35,5 @@
 #include "callkeys.h"
 #include "dimradmars.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "aerkind.h"
 #include "yomaer.h"
Index: /trunk/LMDZ.MARS/libf/phymars/vdif_kc.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/vdif_kc.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/vdif_kc.F	(revision 1036)
@@ -1,8 +1,10 @@
       SUBROUTINE vdif_kc(dt,g,zlev,zlay,u,v,teta,cd,q2,km,kn,zq)
+
+      use tracer_mod, only: nqmx, noms
       IMPLICIT NONE
 c.......................................................................
 #include "dimensions.h"
 #include "dimphys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "callkeys.h"
 c.......................................................................
Index: /trunk/LMDZ.MARS/libf/phymars/vdifc.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/vdifc.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/vdifc.F	(revision 1036)
@@ -11,4 +11,7 @@
 #endif
      &                )
+      use tracer_mod, only: noms, igcm_dust_mass, igcm_dust_number,
+     &                      igcm_dust_submicron, igcm_h2o_vap,
+     &                      igcm_h2o_ice, dryness, alpha_lift, nqmx
       IMPLICIT NONE
 
@@ -39,5 +42,5 @@
 #include "surfdat.h"
 #include "comgeomfi.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "microphys.h"
 
@@ -46,32 +49,36 @@
 c   ----------
 
-      INTEGER ngrid,nlay
-      REAL ptimestep
-      REAL pplay(ngrid,nlay),pplev(ngrid,nlay+1)
-      REAL pzlay(ngrid,nlay),pzlev(ngrid,nlay+1)
-      REAL pu(ngrid,nlay),pv(ngrid,nlay),ph(ngrid,nlay),pt(ngrid,nlay)
-      REAL ptsrf(ngrid),pemis(ngrid)
-      REAL pdufi(ngrid,nlay),pdvfi(ngrid,nlay),pdhfi(ngrid,nlay)
-      REAL pfluxsrf(ngrid)
-      REAL pdudif(ngrid,nlay),pdvdif(ngrid,nlay),pdhdif(ngrid,nlay)
-      REAL pdtsrf(ngrid),pcapcal(ngrid)
+      INTEGER,INTENT(IN) :: ngrid,nlay
+      REAL,INTENT(IN) :: ptimestep
+      REAL,INTENT(IN) :: pplay(ngrid,nlay),pplev(ngrid,nlay+1)
+      REAL,INTENT(IN) :: pzlay(ngrid,nlay),pzlev(ngrid,nlay+1)
+      REAL,INTENT(IN) :: pu(ngrid,nlay),pv(ngrid,nlay)
+      REAL,INTENT(IN) :: ph(ngrid,nlay)
+      REAL :: pt(ngrid,nlay)
+      REAL,INTENT(IN) :: ptsrf(ngrid),pemis(ngrid)
+      REAL,INTENT(IN) :: pdufi(ngrid,nlay),pdvfi(ngrid,nlay)
+      REAL,INTENT(IN) :: pdhfi(ngrid,nlay)
+      REAL,INTENT(IN) :: pfluxsrf(ngrid)
+      REAL,INTENT(OUT) :: pdudif(ngrid,nlay),pdvdif(ngrid,nlay)
+      REAL,INTENT(OUT) :: pdtsrf(ngrid),pdhdif(ngrid,nlay)
+      REAL,INTENT(IN) ::pcapcal(ngrid)
       REAL pq2(ngrid,nlay+1)
 
 c    Argument added for condensation:
-      REAL co2ice (ngrid), ppopsk(ngrid,nlay)
-      logical lecrit
-
-      REAL pz0(ngridmx) ! surface roughness length (m)
+      REAL,INTENT(IN) :: co2ice (ngrid), ppopsk(ngrid,nlay)
+      logical,INTENT(IN) :: lecrit
+
+      REAL,INTENT(IN) :: pz0(ngrid) ! surface roughness length (m)
 
 c    Argument added to account for subgrid gustiness :
 
-      REAL wstar(ngridmx), hfmax(ngridmx), zi(ngridmx)
+      REAL wstar(ngrid), hfmax(ngrid)!, zi(ngrid)
 
 c    Traceurs :
-      integer nq 
-      REAL pqsurf(ngrid,nq)
-      real pq(ngrid,nlay,nq), pdqfi(ngrid,nlay,nq) 
-      real pdqdif(ngrid,nlay,nq) 
-      real pdqsdif(ngrid,nq) 
+      integer,intent(in) :: nq 
+      REAL,INTENT(IN) :: pqsurf(ngrid,nq)
+      real,intent(in) :: pq(ngrid,nlay,nq), pdqfi(ngrid,nlay,nq) 
+      real,intent(out) :: pdqdif(ngrid,nlay,nq) 
+      real,intent(out) :: pdqsdif(ngrid,nq) 
       
 c   local:
@@ -99,6 +106,5 @@
       EXTERNAL SSUM,SCOPY
       REAL SSUM
-      LOGICAL firstcall
-      SAVE firstcall
+      LOGICAL,SAVE :: firstcall=.true.
 
 
@@ -112,6 +118,6 @@
       
 c     For latent heat release from ground ice sublimation    
-      REAL tsrf_lw(ngridmx)
-      REAL alpha
+!      REAL tsrf_lw(ngridmx)
+!      REAL alpha
       REAL T1,T2
       SAVE T1,T2
@@ -125,5 +131,4 @@
       REAL rho(ngridmx) ! near surface air density
       REAL qsat(ngridmx)
-      DATA firstcall/.true./
 
       REAL kmixmin
@@ -179,5 +184,5 @@
          if (tracer) then
 c          Prepare Special treatment if one of the tracer is CO2 gas
-           do iq=1,nqmx
+           do iq=1,nq
              if (noms(iq).eq."co2") then
                 ico2=iq
@@ -196,7 +201,4 @@
         firstcall=.false.
       ENDIF
-
-
-
 
 
@@ -398,8 +400,7 @@
 
       pt(:,:)=ph(:,:)*ppopsk(:,:)
-      CALL yamada4(ngrid,nlay,ptimestep,g,r,pplev,pt
+      CALL yamada4(ngrid,nlay,nq,ptimestep,g,r,pplev,pt
      s   ,pzlev,pzlay,pu,pv,ph,pq,zcdv_true,pq2,zkv,zkh,zkq,ust
      s   ,9)
-
       ENDIF
 
@@ -900,3 +901,3 @@
 
       RETURN
-      END
+      END SUBROUTINE vdifc
Index: /trunk/LMDZ.MARS/libf/phymars/watercloud.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/watercloud.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/watercloud.F	(revision 1036)
@@ -7,4 +7,8 @@
       USE ioipsl_getincom
       USE updaterad
+      use tracer_mod, only: nqmx, igcm_h2o_vap, igcm_h2o_ice,
+     &                      igcm_dust_mass, igcm_dust_number,
+     &                      igcm_ccn_mass, igcm_ccn_number,
+     &                      rho_dust, nuice_sed, nuice_ref
       IMPLICIT NONE
 
@@ -34,5 +38,5 @@
 #include "comcstfi.h"
 #include "callkeys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "comgeomfi.h"
 #include "dimradmars.h"
Index: /trunk/LMDZ.MARS/libf/phymars/yamada4.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/yamada4.F	(revision 1035)
+++ /trunk/LMDZ.MARS/libf/phymars/yamada4.F	(revision 1036)
@@ -8,7 +8,8 @@
 !************************************************************
 !************************************************************
-      SUBROUTINE yamada4(ngrid,nlay,dt,g,rconst,plev,temp
+      SUBROUTINE yamada4(ngrid,nlay,nq,dt,g,rconst,plev,temp
      s   ,zlev,zlay,u,v,phc,pq,cd,q2,km,kn,kq,ustar
      s   ,iflag_pbl)
+      use tracer_mod, only: noms
       IMPLICIT NONE
 !.......................................................................
@@ -16,5 +17,5 @@
 #include "dimensions.h"
 #include "dimphys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "callkeys.h"
 !.......................................................................
@@ -61,4 +62,5 @@
       INTEGER, INTENT(IN)    :: iflag_pbl,ngrid
       INTEGER, INTENT(IN)    :: nlay
+      INTEGER, INTENT(IN)    :: nq
       REAL,    INTENT(INOUT) :: q2(ngrid,nlay+1)
       REAL,    INTENT(OUT)   :: km(ngrid,nlay+1)
@@ -119,5 +121,5 @@
       SAVE A, B
       REAL teta(ngrid,nlay)
-      REAL pq(ngrid,nlay,nqmx)
+      REAL pq(ngrid,nlay,nq)
       REAL kminfact
       INTEGER i
@@ -135,5 +137,5 @@
         if (tracer) then
 !     Prepare Special treatment if one of the tracers is CO2 gas
-           do iq=1,nqmx
+           do iq=1,nq
              if (noms(iq).eq."co2") then
                 ico2=iq
@@ -603,5 +605,5 @@
 #include "dimensions.h"
 #include "dimphys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "callkeys.h"
 !.......................................................................
@@ -684,5 +686,5 @@
 #include "dimensions.h"
 #include "dimphys.h"
-#include "tracer.h"
+!#include "tracer.h"
 #include "callkeys.h"
 !.......................................................................
Index: /trunk/LMDZ.MARS/makegcm_g95
===================================================================
--- /trunk/LMDZ.MARS/makegcm_g95	(revision 1035)
+++ /trunk/LMDZ.MARS/makegcm_g95	(revision 1036)
@@ -530,5 +530,5 @@
 # Build the appropriate 'dimensions.h' file
 cd dimension
-./makdim $ntrac $dim
+./makdim $dim
 # echo contents of dimensions.h to standard output
 cat $libf/grid/dimensions.h
@@ -556,6 +556,9 @@
 echo dimension $dimension dim $dim
 if ( $dimension == 1 ) then
-  echo pas de dynamique
-  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+  echo "No dynamics"
+##  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+## NB: we still need to have L_DYN=libdyn3d to reach routines and module
+## objects which are located in dyn3d
+  set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique "
 endif
 endif
Index: /trunk/LMDZ.MARS/makegcm_gfortran
===================================================================
--- /trunk/LMDZ.MARS/makegcm_gfortran	(revision 1035)
+++ /trunk/LMDZ.MARS/makegcm_gfortran	(revision 1036)
@@ -528,5 +528,5 @@
 # Build the appropriate 'dimensions.h' file
 cd dimension
-./makdim $ntrac $dim
+./makdim $dim
 # echo contents of dimensions.h to standard output
 cat $libf/grid/dimensions.h
@@ -554,6 +554,9 @@
 echo dimension $dimension dim $dim
 if ( $dimension == 1 ) then
-  echo pas de dynamique
-  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+  echo "No dynamics"
+##  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+## NB: we still need to have L_DYN=libdyn3d to reach routines and module
+## objects which are located in dyn3d
+  set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique "
 endif
 endif
Index: /trunk/LMDZ.MARS/makegcm_ifort
===================================================================
--- /trunk/LMDZ.MARS/makegcm_ifort	(revision 1035)
+++ /trunk/LMDZ.MARS/makegcm_ifort	(revision 1036)
@@ -184,7 +184,7 @@
 # Ehouarn 'ifort' compiler
    #NB: on gnome -O3 ==> NaNs ...
-   set optim=" -O2 -fp-model precise -ip -mkl=sequential -align all "
-   set optim90=" -O2 -fp-model precise -ip -mkl=sequential -align all "
-   set optimtru90=" -O2 -fp-model precise -ip -mkl=sequential -align all "
+   set optim="-auto -O2 -fp-model precise -ip -mkl=sequential -align all "
+   set optim90="-auto -O2 -fp-model precise -ip -mkl=sequential -align all "
+   set optimtru90="-auto -O2 -fp-model precise -ip -mkl=sequential -align all "
 #   set opt_link=" -Mfree -lpgf90 -lpgftnrtl -lpghpf -lpghpf2 -L$NCDFLIB -lnetcdf -Bstatic "
 #   set mod_loc_dir=$LIBOGCM
@@ -531,5 +531,5 @@
 # Build the appropriate 'dimensions.h' file
 cd dimension
-./makdim $ntrac $dim
+./makdim $dim
 # echo contents of dimensions.h to standard output
 cat $libf/grid/dimensions.h
@@ -557,6 +557,9 @@
 echo dimension $dimension dim $dim
 if ( $dimension == 1 ) then
-  echo pas de dynamique
-  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+  echo "No dynamics"
+##  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+## NB: we still need to have L_DYN=libdyn3d to reach routines and module
+## objects which are located in dyn3d
+  set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique "
 endif
 endif
Index: /trunk/LMDZ.MARS/makegcm_pgf
===================================================================
--- /trunk/LMDZ.MARS/makegcm_pgf	(revision 1035)
+++ /trunk/LMDZ.MARS/makegcm_pgf	(revision 1036)
@@ -532,5 +532,5 @@
 # Build the appropriate 'dimensions.h' file
 cd dimension
-./makdim $ntrac $dim
+./makdim $dim
 # echo contents of dimensions.h to standard output
 cat $libf/grid/dimensions.h
@@ -558,6 +558,9 @@
 echo dimension $dimension dim $dim
 if ( $dimension == 1 ) then
-  echo pas de dynamique
-  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+  echo "No dynamics"
+##  set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+## NB: we still need to have L_DYN=libdyn3d to reach routines and module
+## objects which are located in dyn3d
+  set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique "
 endif
 endif
