Index: /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90	(revision 1643)
+++ /trunk/LMDZ.COMMON/libf/dyn3d/gcm.F90	(revision 1644)
@@ -372,4 +372,6 @@
     write(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
     write(lunout,*)jD_ref+jH_ref,an, mois, jour, heure
+  else if (planet_type.eq.'titan') then
+    jD_ref=1 ! Because we use old Titan starts (J.V.O 2016)
   else
 ! A voir pour Titan et Venus
Index: /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 1643)
+++ /trunk/LMDZ.COMMON/libf/dyn3dpar/gcm.F	(revision 1644)
@@ -396,4 +396,6 @@
       write(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
       write(lunout,*)jD_ref+jH_ref,an, mois, jour, heure
+      else if (planet_type.eq.'titan') then
+        jD_ref=1 ! Because we use old Titan starts (J.V.O 2016)
       else
 ! A voir pour Titan et Venus
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../../LMDZ.TITAN/libf/dynphy_lonlat/phytitan
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/callphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/callphysiq_mod.F90	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/callphysiq_mod.F90	(revision 1644)
@@ -0,0 +1,97 @@
+!
+! $Id: $
+!
+MODULE callphysiq_mod
+
+IMPLICIT NONE
+
+CONTAINS
+
+SUBROUTINE call_physiq(klon,llm,nqtot,tname,                              &
+                       debut_split,lafin_split,                           &
+                       jD_cur,jH_cur_split,zdt_split,                     &
+                       zplev_omp,zplay_omp,                               &
+                       zpk_omp,zphi_omp,zphis_omp,                        &
+                       presnivs_omp,                                      &
+                       zufi_omp,zvfi_omp,zrfi_omp,ztfi_omp,zqfi_omp,      &
+                       flxwfi_omp,pducov,                                 &
+                       zdufi_omp,zdvfi_omp,zdtfi_omp,zdqfi_omp,zdpsrf_omp)
+
+  USE control_mod, ONLY: planet_type
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+  USE physiq_mod, ONLY: physiq
+  IMPLICIT NONE
+
+  INTEGER,INTENT(IN) :: klon ! (local) number of atmospheric columns
+  INTEGER,INTENT(IN) :: llm  ! number of atmospheric layers
+  INTEGER,INTENT(IN) :: nqtot ! number of tracers
+  CHARACTER(len=*),INTENT(IN) :: tname(nqtot) ! tracer names
+  LOGICAL,INTENT(IN) :: debut_split ! .true. if very first call to physics
+  LOGICAL,INTENT(IN) :: lafin_split ! .true. if last call to physics
+  REAL,INTENT(IN) :: JD_cur ! Julian day
+  REAL,INTENT(IN) :: JH_cur_split ! Julian hour (fraction of day)
+  REAL,INTENT(IN) :: zdt_split ! time step over which the physics are evaluated
+  REAL,INTENT(IN) :: zplev_omp(klon,llm+1) ! interlayer pressure (Pa)
+  REAL,INTENT(IN) :: zplay_omp(klon,llm) ! mid-layer pressure (Pa)
+  REAL,INTENT(IN) :: zpk_omp(klon,llm)
+  REAL,INTENT(IN) :: zphi_omp(klon,llm) ! geopotential at midlayer
+  REAL,INTENT(IN) :: zphis_omp(klon) ! surface geopotential
+  REAL,INTENT(IN) :: presnivs_omp(llm) ! approximate pressure of atm. layers
+  REAL,INTENT(IN) :: zufi_omp(klon,llm) ! zonal wind (m/s)
+  REAL,INTENT(IN) :: zvfi_omp(klon,llm) ! meridional wind (m/s)
+  REAL,INTENT(IN) :: zrfi_omp(klon,llm) ! relative wind vorticity, in s-1
+  REAL,INTENT(IN) :: ztfi_omp(klon,llm) ! temperature (K)
+  REAL,INTENT(IN) :: zqfi_omp(klon,llm,nqtot) ! tracers (*/kg of air)
+  REAL,INTENT(IN) :: flxwfi_omp(klon,llm) ! Vertical mass flux on lower mesh interfaces (kg/s) 
+  REAL,INTENT(IN) :: pducov(nbp_lon+1,nbp_lat,llm) ! dynamical tendency on ucov
+  ! tendencies (in */s) from the physics:
+  REAL,INTENT(OUT) :: zdufi_omp(klon,llm) ! tendency on zonal winds
+  REAL,INTENT(OUT) :: zdvfi_omp(klon,llm) ! tendency on meridional winds
+  REAL,INTENT(OUT) :: zdtfi_omp(klon,llm) ! tendency on temperature
+  REAL,INTENT(OUT) :: zdqfi_omp(klon,llm,nqtot) ! tendency on tracers
+  REAL,INTENT(OUT) :: zdpsrf_omp(klon) ! tendency on surface pressure
+
+  ! Local variables
+  CHARACTER(len=11) :: modname="call_physiq"
+  LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+
+! Sanity check on physics package type
+  IF (firstcall) THEN
+    IF (planet_type.ne."titan") THEN
+      CALL abort_gcm(modname,"wrong planet_type for this physics package",1)
+    ENDIF
+    firstcall=.false.
+  ENDIF
+
+
+! Call physics package with required inputs/outputs
+  CALL physiq(klon,           &
+              llm,            &
+              nqtot,          &
+              debut_split,    &
+              lafin_split,    &
+              jD_cur,         &
+              jH_cur_split,   &
+              zdt_split,      &
+              zplev_omp,      &
+              zplay_omp,      &
+              zpk_omp,        &
+              zphi_omp,       &
+              zphis_omp,      &
+              presnivs_omp,   &
+              zufi_omp,       &
+              zvfi_omp,       &
+              ztfi_omp,       &
+              zqfi_omp,       &
+              flxwfi_omp,     &
+              zdufi_omp,      &
+              zdvfi_omp,      &
+              zdtfi_omp,      &
+              zdqfi_omp,      &
+              zdpsrf_omp)
+
+
+END SUBROUTINE call_physiq
+
+END MODULE callphysiq_mod
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/conf_dat3d.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/conf_dat3d.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/conf_dat3d.F	(revision 1644)
@@ -0,0 +1,296 @@
+!
+! $Header$
+!
+C
+C
+      SUBROUTINE conf_dat3d( title, lons,lats,levs,xd,yd,zd,xf,yf,zf,
+     ,                                 champd , interbar             )
+c
+c     Auteur : P. Le Van
+c
+c    Ce s-pr. configure le champ de donnees 3D 'champd' de telle facon 
+c       qu'on ait     - pi    a    pi    en longitude
+c       qu'on ait      pi/2.  a - pi/2.  en latitude
+c      et qu'on ait les niveaux verticaux variant du sol vers le ht de l'atmos.
+c           (     en Pascals   ) .
+c
+c      xd et yd  sont les longitudes et latitudes initiales
+c      zd  les pressions initiales
+c
+c      xf et yf  sont les longitudes et latitudes en sortie , eventuellement
+c       modifiees pour etre configurees comme ci-dessus .
+c      zf  les pressions en sortie
+c
+c      champd   en meme temps le champ initial et  final
+c
+c      interbar = .TRUE.  si on appelle l'interpo. barycentrique inter_barxy
+c          sinon , l'interpolation   grille_m  ( grid_atob ) .
+c
+
+      IMPLICIT NONE
+ 
+c    ***       Arguments en  entree      ***
+      CHARACTER*(*) :: title
+      INTEGER lons, lats, levs
+      REAL xd(lons), yd(lats), zd(levs)
+      LOGICAL interbar
+c
+c    ***       Arguments en  sortie      ***
+      REAL xf(lons), yf(lats), zf(levs)
+
+c    ***  Arguments en entree et  sortie ***
+      REAL  champd(lons,lats,levs)
+
+c    ***  Variables locales  ***
+c
+      REAL pi,pis2,depi,presmax
+      LOGICAL radianlon, invlon ,radianlat, invlat, invlev, alloc
+      REAL rlatmin,rlatmax,oldxd1
+      INTEGER i,j,ip180,ind,l
+
+      REAL, ALLOCATABLE :: xtemp(:)
+      REAL, ALLOCATABLE :: ytemp(:)
+      REAL, ALLOCATABLE :: ztemp(:)
+      REAL, ALLOCATABLE :: champf(:,:,:)
+     
+
+c      WRITE(6,*) '  Conf_dat3d  pour  ',title
+
+      ALLOCATE(xtemp(lons))
+      ALLOCATE(ytemp(lats))
+      ALLOCATE(ztemp(levs))
+
+      DO i = 1, lons
+       xtemp(i) = xd(i)
+      ENDDO
+      DO j = 1, lats
+       ytemp(j) = yd(j)
+      ENDDO
+      DO l = 1, levs
+       ztemp(l) = zd(l)
+      ENDDO
+
+      pi   = 2. * ASIN(1.) 
+      pis2 = pi/2.
+      depi = 2. * pi
+
+      IF( xtemp(1).GE.-pi-0.5.AND. xtemp(lons).LE.pi+0.5 )  THEN
+            radianlon = .TRUE.
+            invlon    = .FALSE.
+      ELSE IF (xtemp(1).GE.-0.5.AND.xtemp(lons).LE.depi+0.5 ) THEN
+            radianlon = .TRUE.
+            invlon    = .TRUE.
+      ELSE IF ( xtemp(1).GE.-180.5.AND. xtemp(lons).LE.180.5 )   THEN
+            radianlon = .FALSE.
+            invlon    = .FALSE.
+      ELSE IF ( xtemp(1).GE.-0.5.AND.xtemp(lons).LE.360.5 )   THEN
+            radianlon = .FALSE.
+            invlon    = .TRUE.
+      ELSE
+        WRITE(6,*) 'Pbs. sur les longitudes des donnees pour le fichier'
+     ,  , title
+      ENDIF
+
+      invlat = .FALSE.
+      
+      IF( ytemp(1).LT.ytemp(lats) ) THEN
+        invlat = .TRUE.
+      ENDIF
+
+      rlatmin = MIN( ytemp(1), ytemp(lats) )
+      rlatmax = MAX( ytemp(1), ytemp(lats) )
+      
+      IF( rlatmin.GE.-pis2-0.5.AND.rlatmax.LE.pis2+0.5)THEN
+             radianlat = .TRUE.
+      ELSE IF ( rlatmin.GE.-90.-0.5.AND.rlatmax.LE.90.+0.5 ) THEN
+             radianlat = .FALSE.
+      ELSE
+        WRITE(6,*) ' Pbs. sur les latitudes des donnees pour le fichier'
+     ,  , title
+      ENDIF
+
+       IF( .NOT. radianlon )  THEN
+         DO i = 1, lons
+          xtemp(i) = xtemp(i) * pi/180.
+         ENDDO
+       ENDIF
+
+       IF( .NOT. radianlat )  THEN
+         DO j = 1, lats
+          ytemp(j) = ytemp(j) * pi/180.
+         ENDDO   
+       ENDIF
+
+
+        alloc =.FALSE.
+
+        IF ( invlon )   THEN
+
+            ALLOCATE(champf(lons,lats,levs))
+            alloc = .TRUE.
+
+            DO i = 1 ,lons
+             xf(i) = xtemp(i)
+            ENDDO
+
+            DO l = 1, levs
+             DO j = 1, lats
+              DO i= 1, lons
+               champf (i,j,l)  = champd (i,j,l)
+              ENDDO
+             ENDDO
+            ENDDO
+c
+c    ***  On tourne les longit.  pour avoir  - pi  a  +  pi  ****
+c
+            DO i=1,lons
+             IF( xf(i).GT. pi )  THEN
+              GO TO 88
+             ENDIF
+            ENDDO
+
+88          CONTINUE
+c
+            ip180 = i
+
+            DO i = 1,lons
+             IF (xf(i).GT. pi)  THEN
+              xf(i) = xf(i) - depi
+             ENDIF
+            ENDDO
+
+            DO i= ip180,lons
+             ind = i-ip180 +1
+             xtemp(ind) = xf(i)
+            ENDDO
+
+            DO i= ind +1,lons
+             xtemp(i) = xf(i-ind)
+            ENDDO
+
+c   .....    on tourne les longitudes  pour champf  ....
+c
+            DO l = 1,levs
+              DO j = 1,lats
+               DO i = ip180,lons
+                ind  = i-ip180 +1
+                champd (ind,j,l) = champf (i,j,l)
+               ENDDO
+   
+               DO i= ind +1,lons
+                champd (i,j,l)  = champf (i-ind,j,l)
+               ENDDO
+              ENDDO
+            ENDDO
+
+        ENDIF
+c
+c    *****   fin  de   IF(invlon)   ****
+         
+         IF ( invlat )    THEN
+
+           IF(.NOT.alloc)  THEN 
+            ALLOCATE(champf(lons,lats,levs))
+            alloc = .TRUE.
+           ENDIF
+
+           DO j = 1, lats
+            yf(j) = ytemp(j)
+           ENDDO
+         
+           DO l = 1,levs
+            DO j = 1, lats
+             DO i = 1,lons
+              champf(i,j,l) = champd(i,j,l)
+             ENDDO
+            ENDDO
+
+            DO j = 1, lats
+              ytemp( lats-j+1 ) = yf(j)
+              DO i = 1, lons
+               champd (i,lats-j+1,l) = champf (i,j,l)
+              ENDDO
+            ENDDO
+          ENDDO
+
+
+         ENDIF
+
+c    *****  fin  de  IF(invlat)   ****
+c
+c
+      IF( interbar )  THEN
+        oldxd1 = xtemp(1)
+        DO i = 1, lons -1
+          xtemp(i) = 0.5 * ( xtemp(i) + xtemp(i+1) )
+        ENDDO
+          xtemp(lons) = 0.5 * ( xtemp(lons) + oldxd1 + depi )
+
+        DO j = 1, lats -1
+          ytemp(j) = 0.5 * ( ytemp(j) + ytemp(j+1) )
+        ENDDO
+      ENDIF
+c
+
+      invlev = .FALSE.
+      IF( ztemp(1).LT.ztemp(levs) )  invlev = .TRUE.
+
+      presmax = MAX( ztemp(1), ztemp(levs) )
+      IF( presmax.LT.1200. ) THEN
+         DO l = 1,levs
+           ztemp(l) = ztemp(l) * 100.
+         ENDDO
+      ENDIF
+
+      IF( invlev )  THEN
+
+          IF(.NOT.alloc)  THEN
+            ALLOCATE(champf(lons,lats,levs))
+            alloc = .TRUE.
+          ENDIF
+
+          DO l = 1,levs
+            zf(l) = ztemp(l)
+          ENDDO
+
+          DO l = 1,levs
+            DO j = 1, lats
+             DO i = 1,lons
+              champf(i,j,l) = champd(i,j,l)
+             ENDDO
+            ENDDO
+          ENDDO
+
+          DO l = 1,levs
+            ztemp(levs+1-l) = zf(l)
+          ENDDO
+
+          DO l = 1,levs
+            DO j = 1, lats
+             DO i = 1,lons
+              champd(i,j,levs+1-l) = champf(i,j,l)
+             ENDDO
+            ENDDO
+          ENDDO
+
+
+      ENDIF
+
+         IF(alloc)  DEALLOCATE(champf)
+
+         DO i = 1, lons
+           xf(i) = xtemp(i)
+         ENDDO
+         DO j = 1, lats
+           yf(j) = ytemp(j)
+         ENDDO
+         DO l = 1, levs
+           zf(l) = ztemp(l)
+         ENDDO
+
+      DEALLOCATE(xtemp)
+      DEALLOCATE(ytemp)
+      DEALLOCATE(ztemp)
+
+      RETURN
+      END
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/ini_archive.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/ini_archive.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/ini_archive.F	(revision 1644)
@@ -0,0 +1,353 @@
+c=======================================================================
+      subroutine ini_archive(nid,phis,tab_cntrl_dyn,tab_cntrl_fi)
+c=======================================================================
+c
+c
+c   Date:    01/1997
+c   ----
+c
+c   Objet:  ecriture de l'entete du fichier "start_archive"
+c   -----
+c
+c	 Proche de iniwrite.F
+c
+c   Arguments:
+c   ---------
+c
+c	Inputs:
+c   ------
+c
+c       nid            unite logique du fichier "start_archive"
+c       phis           geopotentiel au sol
+c       tab_cntrl_dyn  tableau des param dynamiques
+c       tab_cntrl_fi   tableau des param physiques
+c
+
+c=======================================================================
+ 
+      USE control_mod
+      USE comconst_mod
+      USE comvert_mod, ONLY: ap,bp,presnivs,pa,preff,nivsigs,nivsig,
+     .                       aps,bps,scaleheight,pseudoalt,
+     .                       disvert_type,pressure_exner
+
+      implicit none
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "description.h"
+#include "netcdf.inc"
+
+c-----------------------------------------------------------------------
+c   Declarations
+c-----------------------------------------------------------------------
+
+c   Local:
+c   ------
+      INTEGER	length,l
+      parameter (length = 100)
+      REAL	tab_cntrl(2*length) ! tableau des parametres du run
+      INTEGER	loop
+      INTEGER	ierr, setvdim, putvdim, putdat, setname,cluvdb
+      INTEGER	setdim
+      INTEGER	ind1,indlast
+
+c   Arguments:
+c   ----------
+      REAL	phis(ip1jmp1)
+      REAL	tab_cntrl_dyn(length)
+      REAL	tab_cntrl_fi(length)
+
+!Mars --------Ajouts-----------
+c   Variables locales pour NetCDF:
+c
+      INTEGER dims2(2), dims3(3), dims4(4)
+      INTEGER idim_index
+      INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv
+      INTEGER idim_llmp1,idim_llm
+      INTEGER idim_tim
+      INTEGER nid,nvarid
+      real sig_s(llm),s(llm)
+
+      pi  = 2. * ASIN(1.)
+
+
+c-----------------------------------------------------------------------
+c   Remplissage du tableau des parametres de controle du RUN  
+c-----------------------------------------------------------------------
+
+      DO l=1,length
+         tab_cntrl(l)       = tab_cntrl_dyn(l)
+         tab_cntrl(length+l)= tab_cntrl_fi(l)
+      ENDDO
+
+c=======================================================================
+c	Ecriture NetCDF de l''entete du fichier "start_archive"
+c=======================================================================
+
+c
+c Preciser quelques attributs globaux:
+c
+      ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 27,
+     .                       "Fichier start_archive")
+c
+c Definir les dimensions du fichiers:
+c
+c     CHAMPS AJOUTES POUR LA VISUALISATION T,ps, etc... avec Grads ou ferret:
+      ierr = NF_DEF_DIM (nid,"index", 2*length, idim_index)
+      ierr = NF_DEF_DIM (nid,"rlonu", iip1, idim_rlonu)
+      ierr = NF_DEF_DIM (nid,"rlatu", jjp1, idim_rlatu)
+      ierr = NF_DEF_DIM (nid,"rlonv", iip1, idim_rlonv)
+      ierr = NF_DEF_DIM (nid,"rlatv", jjm, idim_rlatv)
+      ierr = NF_DEF_DIM (nid,"sigs",  llm, idim_llm)
+      ierr = NF_DEF_DIM (nid,"sig", llmp1, idim_llmp1)
+      ierr = NF_DEF_DIM (nid,"Time", NF_UNLIMITED, idim_tim)
+
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+
+c-----------------------------------------------------------------------
+c  Ecriture du tableau des parametres du run
+c-----------------------------------------------------------------------
+
+      call def_var(nid,"Time","Time","days since 00:00:00",1,
+     .            idim_tim,nvarid,ierr)
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"controle",NF_DOUBLE,1,idim_index,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"controle",NF_FLOAT,1,idim_index,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Parametres de controle")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture des longitudes et latitudes
+c-----------------------------------------------------------------------
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture des niveaux verticaux
+c-----------------------------------------------------------------------
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"nivsigs",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"nivsigs",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 28,
+     .                       "Numero naturel des couches s")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsigs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsigs)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"nivsig",NF_DOUBLE,1,idim_llmp1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"nivsig",NF_FLOAT,1,idim_llmp1,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 28,
+     .                       "Numero naturel des couches sigma")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsig)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsig)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_llmp1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_llmp1,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 32,
+     .                       "Coef A: niveaux pression hybride")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_llmp1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_llmp1,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 35,
+     .                       "Coefficient B niveaux sigma hybride")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bp)
+#endif
+c
+c ----------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,presnivs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,presnivs)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture aire et coefficients de passage cov. <-> contra. <--> naturel
+c-----------------------------------------------------------------------
+
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonu
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cu",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cu",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatv
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cv",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cv",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
+#endif
+c
+c Aire de chaque maille:
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"aire",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"aire",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Aires de chaque maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture du geopentiel au sol
+c-----------------------------------------------------------------------
+
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
+     .                       "Geopotentiel au sol")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,phis)
+#endif
+
+      RETURN
+      END
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/iniphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/iniphysiq_mod.F90	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/iniphysiq_mod.F90	(revision 1644)
@@ -0,0 +1,149 @@
+!
+! $Id: iniphysiq.F90 2225 2015-03-11 14:55:23Z emillour $
+!
+MODULE iniphysiq_mod
+
+CONTAINS
+
+SUBROUTINE iniphysiq(ii,jj,nlayer, &
+                     nbp, communicator, &
+                     punjours, pdayref,ptimestep, &
+                     rlatudyn,rlatvdyn,rlonudyn,rlonvdyn, &
+                     airedyn,cudyn,cvdyn, &
+                     prad,pg,pr,pcpp,iflag_phys)
+
+  USE temps_mod, ONLY: annee_ref, day_ref, day_ini, day_end
+  USE comconst_mod, ONLY: cpp
+  USE cpdet_phy_mod, ONLY: init_cpdet_phy
+  USE infotrac, ONLY: nqtot, tname, ttext
+  USE logic_mod, ONLY: iflag_trac
+  USE infotrac_phy, ONLY: init_infotrac_phy
+  USE time_phylmdz_mod, ONLY: init_time
+  USE inigeomphy_mod, ONLY: inigeomphy
+  USE control_mod, ONLY: nday
+  USE dimphy, ONLY: init_dimphy
+  USE mod_phys_lmdz_para, ONLY: klon_omp ! number of columns (on local omp grid)
+  IMPLICIT NONE
+
+  ! =======================================================================
+  ! Initialisation of the physical constants and some positional and
+  ! geometrical arrays for the physics
+  ! =======================================================================
+
+  include "YOMCST.h"
+  include "iniprint.h"
+
+  REAL, INTENT (IN) :: prad ! radius of the planet (m)
+  REAL, INTENT (IN) :: pg ! gravitational acceleration (m/s2)
+  REAL, INTENT (IN) :: pr ! ! reduced gas constant R/mu
+  REAL, INTENT (IN) :: pcpp ! specific heat Cp
+  REAL, INTENT (IN) :: punjours ! length (in s) of a standard day
+  INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers
+  INTEGER, INTENT (IN) :: ii ! number of atmospheric columns along longitudes
+  INTEGER, INTENT (IN) :: jj ! number of atompsheric columns along latitudes
+  INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process
+  INTEGER, INTENT(IN) :: communicator ! MPI communicator
+  REAL, INTENT (IN) :: rlatudyn(jj+1) ! latitudes of the physics grid
+  REAL, INTENT (IN) :: rlatvdyn(jj) ! latitude boundaries of the physics grid
+  REAL, INTENT (IN) :: rlonvdyn(ii+1) ! longitudes of the physics grid
+  REAL, INTENT (IN) :: rlonudyn(ii+1) ! longitude boundaries of the physics grid
+  REAL, INTENT (IN) :: airedyn(ii+1,jj+1) ! area of the dynamics grid (m2)
+  REAL, INTENT (IN) :: cudyn((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
+  REAL, INTENT (IN) :: cvdyn((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
+  INTEGER, INTENT (IN) :: pdayref ! reference day of for the simulation
+  REAL, INTENT (IN) :: ptimestep !physics time step (s)
+  INTEGER, INTENT (IN) :: iflag_phys ! type of physics to be called
+
+  CHARACTER (LEN=20) :: modname = 'iniphysiq'
+  CHARACTER (LEN=80) :: abort_message
+
+  ! the common part for all planetary physics
+  !------------------------------------------
+  ! --> initialize physics distribution, global fields and geometry
+  ! (i.e. things in phy_common or dynphy_lonlat)
+  CALL inigeomphy(ii,jj,nlayer, &
+               nbp, communicator, &
+               rlatudyn,rlatvdyn, &
+               rlonudyn,rlonvdyn, &
+               airedyn,cudyn,cvdyn)
+
+  ! the distinct part for all planetary physics  (ie. things in phytitan)
+  !------------------------------------------
+
+!$OMP PARALLEL
+
+  ! Initialize dimphy module
+  call init_dimphy(klon_omp,nlayer)
+
+  ! Initialize some physical constants
+  call suphec
+  
+  ! Initialize cpdet_phy module
+  call init_cpdet_phy(cpp)
+
+  ! Initialize some "temporal and calendar" related variables
+  CALL init_time(annee_ref,day_ref,day_ini,day_end,nday,ptimestep)
+
+  ! Initialize tracers in physics
+  CALL init_infotrac_phy(iflag_trac,nqtot,tname,ttext)
+
+!$OMP END PARALLEL
+
+
+  ! check that physical constants set in 'suphec' are coherent
+  ! with values set in the dynamics:
+  IF (rday/=punjours) THEN
+    WRITE (lunout, *) 'iniphysiq: length of day discrepancy!!!'
+    WRITE (lunout, *) '  in the dynamics punjours=', punjours
+    WRITE (lunout, *) '   but in the physics RDAY=', rday
+    IF (abs(rday-punjours)>0.01*punjours) THEN
+        ! stop here if the relative difference is more than 1%
+      abort_message = 'length of day discrepancy'
+      CALL abort_gcm(modname, abort_message, 1)
+    END IF
+  END IF
+
+  IF (rg/=pg) THEN
+    WRITE (lunout, *) 'iniphysiq: gravity discrepancy !!!'
+    WRITE (lunout, *) '     in the dynamics pg=', pg
+    WRITE (lunout, *) '  but in the physics RG=', rg
+    IF (abs(rg-pg)>0.01*pg) THEN
+        ! stop here if the relative difference is more than 1%
+      abort_message = 'gravity discrepancy'
+      CALL abort_gcm(modname, abort_message, 1)
+    END IF
+  END IF
+  IF (ra/=prad) THEN
+    WRITE (lunout, *) 'iniphysiq: planet radius discrepancy !!!'
+    WRITE (lunout, *) '   in the dynamics prad=', prad
+    WRITE (lunout, *) '  but in the physics RA=', ra
+    IF (abs(ra-prad)>0.01*prad) THEN
+        ! stop here if the relative difference is more than 1%
+      abort_message = 'planet radius discrepancy'
+      CALL abort_gcm(modname, abort_message, 1)
+    END IF
+  END IF
+  IF (rd/=pr) THEN
+    WRITE (lunout, *) 'iniphysiq: reduced gas constant discrepancy !!!'
+    WRITE (lunout, *) '     in the dynamics pr=', pr
+    WRITE (lunout, *) '  but in the physics RD=', rd
+    IF (abs(rd-pr)>0.01*pr) THEN
+        ! stop here if the relative difference is more than 1%
+      abort_message = 'reduced gas constant discrepancy'
+      CALL abort_gcm(modname, abort_message, 1)
+    END IF
+  END IF
+  IF (rcpd/=pcpp) THEN
+    WRITE (lunout, *) 'iniphysiq: specific heat discrepancy !!!'
+    WRITE (lunout, *) '     in the dynamics pcpp=', pcpp
+    WRITE (lunout, *) '  but in the physics RCPD=', rcpd
+    IF (abs(rcpd-pcpp)>0.01*pcpp) THEN
+        ! stop here if the relative difference is more than 1%
+      abort_message = 'specific heat discrepancy'
+      CALL abort_gcm(modname, abort_message, 1)
+    END IF
+  END IF
+
+END SUBROUTINE iniphysiq
+
+END MODULE iniphysiq_mod
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/newstart.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/newstart.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/newstart.F	(revision 1644)
@@ -0,0 +1,1144 @@
+C======================================================================
+      PROGRAM newstart
+c=======================================================================
+c
+c
+c   Auteur:   S. Lebonnois, 
+c    a partir des newstart/start_archive/lect_start_archive martiens
+c
+c             Derniere modif : 02/09 (ecriture des q*)
+c                              01/12 (inclusion dans svn dyn3d)
+c
+c   Objet:  Modify the grid for the initial state (LMD GCM VENUS/TITAN)
+c   -----           (from file NetCDF start_archive.nc)
+c
+c
+c=======================================================================
+
+      use IOIPSL
+      USE filtreg_mod
+      USE startvar
+      USE control_mod
+      USE infotrac
+      use cpdet_mod, only: ini_cpdet,t2tpot
+      use exner_hyb_m, only: exner_hyb
+      use exner_milieu_m, only: exner_milieu
+      USE comconst_mod
+      USE comvert_mod, ONLY: ap,bp,presnivs,pa,preff,nivsigs,nivsig,
+     .                       aps,bps,scaleheight,pseudoalt,
+     .                       disvert_type,pressure_exner
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,
+     &                     dzoomx,dzoomy,taux,tauy
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      USE logic_mod, ONLY: iflag_trac,fxyhypb,ysinus
+      USE temps_mod, ONLY: day_ref,annee_ref
+      implicit none
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissnew.h"
+#include "comgeom2.h"
+#include "description.h"
+#include "dimsoil.h"
+#include "netcdf.inc"
+
+c-----------------------------------------------------------------------
+c   Declarations
+c-----------------------------------------------------------------------
+
+c Variables pour fichier "ini"
+c------------------------------------
+      INTEGER   imold,jmold,lmold,nqold,ip1jmp1old
+      INTEGER   length
+      parameter (length = 100)
+      real      tab_cntrl(2*length) 
+      INTEGER isoil,iq,iqmax
+      CHARACTER*2   str2
+
+c Variable histoire 
+c------------------
+      REAL vcov(iip1,jjm,llm),ucov(iip1,jjp1,llm) ! vents covariants
+      REAL teta(iip1,jjp1,llm),ps(iip1,jjp1)
+      REAL phis(iip1,jjp1)                     ! geopotentiel au sol
+      REAL masse(ip1jmp1,llm)                ! masse de l'atmosphere
+      REAL, ALLOCATABLE, DIMENSION(:,:,:,:):: q! champs advectes
+      REAL tab_cntrl_dyn(length) ! tableau des parametres de start
+
+c variable physique
+c------------------
+      integer    ngridmx
+      parameter (ngridmx=(2+(jjm-1)*iim - 1/jjm))
+      REAL tab_cntrl_fi(length) ! tableau des parametres de startfi
+      real rlat(ngridmx),rlon(ngridmx)
+      REAL tsurf(ngridmx),tsoil(ngridmx,nsoilmx)
+      REAL albe(ngridmx),radsol(ngridmx),sollw(ngridmx)
+      real solsw(ngridmx),dlw(ngridmx)
+      REAL zmea(ngridmx), zstd(ngridmx)
+      REAL zsig(ngridmx), zgam(ngridmx), zthe(ngridmx)
+      REAL zpic(ngridmx), zval(ngridmx)
+      real t_fi(ngridmx,llm)
+
+c Variable nouvelle grille naturelle au point scalaire
+c------------------------------------------------------
+      real us(iip1,jjp1,llm),vs(iip1,jjp1,llm)
+      REAL p3d(iip1,jjp1,llm+1)            ! pression aux interfaces
+      REAL phisold_newgrid(iip1,jjp1)
+      REAL T(iip1,jjp1,llm)
+      real rlonS(iip1,jjp1),rlatS(iip1,jjp1)
+      real tsurfS(iip1,jjp1),tsoilS(iip1,jjp1,nsoilmx)
+      real albeS(ip1jmp1),radsolS(ip1jmp1),sollwS(ip1jmp1)
+      real solswS(ip1jmp1),dlwS(ip1jmp1)
+      real zmeaS(ip1jmp1),zstdS(ip1jmp1),zsigS(ip1jmp1)
+      real zgamS(ip1jmp1),ztheS(ip1jmp1),zpicS(ip1jmp1)
+      real zvalS(ip1jmp1)
+
+      real ptotal
+
+c Var intermediaires : vent naturel, mais pas coord scalaire
+c-----------------------------------------------------------
+      real vnat(iip1,jjm,llm),unat(iip1,jjp1,llm)
+
+      REAL pks(iip1,jjp1)                      ! exner (f pour filtre)
+      REAL pk(iip1,jjp1,llm)
+      REAL pkf(iip1,jjp1,llm)
+      REAL alpha(iip1,jjp1,llm),beta(iip1,jjp1,llm)
+
+
+c Variable de l'ancienne grille 
+c---------------------------------------------------------
+
+      real, dimension(:),     allocatable :: rlonuold, rlatvold
+      real, dimension(:),     allocatable :: rlonvold, rlatuold
+      real, dimension(:),     allocatable :: nivsigsold,nivsigold
+      real, dimension(:),     allocatable :: apold,bpold
+      real, dimension(:),     allocatable :: presnivsold
+      real, dimension(:,:,:), allocatable :: uold,vold,told
+      real, dimension(:,:,:,:), allocatable :: qold
+      real, dimension(:,:,:), allocatable :: tsoilold
+      real, dimension(:,:),   allocatable :: psold,phisold
+      real, dimension(:,:),   allocatable :: tsurfold
+      real, dimension(:,:),   allocatable :: albeold,radsolold
+      real, dimension(:,:),   allocatable :: sollwold,solswold
+      real, dimension(:,:),   allocatable :: dlwold
+      real, dimension(:,:),   allocatable :: zmeaold,zstdold,zsigold
+      real, dimension(:,:),   allocatable :: zgamold,ztheold,zpicold
+      real, dimension(:,:),   allocatable :: zvalold
+
+      real ptotalold
+
+c Variable intermediaires iutilise pour l'extrapolation verticale 
+c----------------------------------------------------------------
+      real, dimension(:,:,:), allocatable :: var,varp1 
+
+c divers local
+c-----------------
+
+      integer ierr,nid,nvarid
+      INTEGER ij, l,i,j
+      character*80      fichnom      
+      integer, dimension(4) :: start,counter
+      REAL phisinverse(iip1,jjp1)  ! geopotentiel au sol avant inversion
+      logical topoflag,albedoflag,razvitu,razvitv 
+      real    albedo
+      
+c=======================================================================
+c  INITIALISATIONS DIVERSES
+c=======================================================================
+
+c VENUS/TITAN
+
+        iflag_trac = 1
+c-----------------------------------------------------------------------
+c   Initialisation des traceurs
+c   ---------------------------
+c  Choix du nombre de traceurs et du schema pour l'advection
+c  dans fichier traceur.def, par default ou via INCA
+      call infotrac_init
+
+c Allocation de la tableau q : champs advectes   
+      allocate(q(iip1,jjp1,llm,nqtot))
+
+c-----------------------------------------------------------------------
+c   Ouverture du fichier a modifier (start_archive.nc)
+c-----------------------------------------------------------------------
+
+        write(*,*) 'Creation d un etat initial a partir de'
+        write(*,*) './start_archive.nc'
+        write(*,*)
+        fichnom = 'start_archive.nc'
+        ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
+        IF (ierr.NE.NF_NOERR) THEN
+          write(6,*)' Pb d''ouverture du fichier ',fichnom
+          write(6,*)' ierr = ', ierr
+          CALL ABORT
+        ENDIF
+ 
+c-----------------------------------------------------------------------
+c Lecture du tableau des parametres du run (pour la dynamique)
+c-----------------------------------------------------------------------
+
+        write(*,*) 'lecture tab_cntrl START_ARCHIVE'
+c
+        ierr = NF_INQ_VARID (nid, "controle", nvarid)
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl)
+#else
+        ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl)
+#endif
+c
+      write(*,*) 'Impression de tab_cntrl'
+      do i=1,200
+        write(*,*) i,tab_cntrl(i)
+      enddo
+      
+c-----------------------------------------------------------------------
+c		Initialisation des constantes
+c-----------------------------------------------------------------------
+
+      imold      = tab_cntrl(1)
+      jmold      = tab_cntrl(2)
+      lmold      = tab_cntrl(3)
+      day_ref    = tab_cntrl(4)
+      annee_ref  = tab_cntrl(5)
+      rad        = tab_cntrl(6)
+      omeg       = tab_cntrl(7)
+      g          = tab_cntrl(8)
+      cpp        = tab_cntrl(9)
+      kappa      = tab_cntrl(10)
+      daysec     = tab_cntrl(11)
+      dtvr       = tab_cntrl(12)
+      etot0      = tab_cntrl(13)
+      ptot0      = tab_cntrl(14)
+      ztot0      = tab_cntrl(15)
+      stot0      = tab_cntrl(16)
+      ang0       = tab_cntrl(17)
+      pa         = tab_cntrl(18)
+      preff      = tab_cntrl(19)
+c
+      clon       = tab_cntrl(20)
+      clat       = tab_cntrl(21)
+      grossismx  = tab_cntrl(22)
+      grossismy  = tab_cntrl(23)
+
+      IF ( tab_cntrl(24).EQ.1. )  THEN
+        fxyhypb  = . TRUE .
+        dzoomx   = tab_cntrl(25)
+        dzoomy   = tab_cntrl(26)
+        taux     = tab_cntrl(28)
+        tauy     = tab_cntrl(29)
+      ELSE
+        fxyhypb = . FALSE .
+        ysinus  = . FALSE .
+        IF( tab_cntrl(27).EQ.1. ) ysinus = . TRUE.
+      ENDIF
+
+      ptotalold  = tab_cntrl(2*length)
+
+      write(*,*) "Old dimensions:"
+      write(*,*) "longitude: ",imold
+      write(*,*) "latitude: ",jmold
+      write(*,*) "altitude: ",lmold
+      write(*,*) 
+
+      ip1jmp1old = (imold+1-1/imold)*(jmold+1-1/jmold)
+      
+c dans run.def
+      CALL getin('planet_type',planet_type)
+      call ini_cpdet
+
+c=======================================================================
+c   CHANGEMENT DE CONSTANTES CONTENUES DANS tab_cntrl
+c=======================================================================
+c  changement de la resolution dans le fichier de controle
+      tab_cntrl(1)  = REAL(iim)
+      tab_cntrl(2)  = REAL(jjm)
+      tab_cntrl(3)  = REAL(llm)
+
+c--------------------------------
+c We use a specific run.def to read new parameters that need to be changed
+c--------------------------------
+      
+c Changement de cpp:
+      CALL getin('cpp',cpp)
+      kappa = (8.314511/43.44E-3)/cpp
+      tab_cntrl(9)  = cpp
+      tab_cntrl(10) = kappa
+
+c CHANGING THE ZOOM PARAMETERS TO CHANGE THE GRID
+      CALL getin('clon',clon)
+      CALL getin('clat',clat)
+      tab_cntrl(20) = clon
+      tab_cntrl(21) = clat
+      CALL getin('grossismx',grossismx)
+      CALL getin('grossismy',grossismy)
+      tab_cntrl(22) = grossismx
+      tab_cntrl(23) = grossismy
+      CALL getin('fxyhypb',fxyhypb)
+      IF ( fxyhypb )  THEN
+        CALL getin('dzoomx',dzoomx)
+        CALL getin('dzoomy',dzoomy)
+        tab_cntrl(25) = dzoomx
+        tab_cntrl(26) = dzoomy
+        CALL getin('taux',taux)
+        CALL getin('tauy',tauy)
+        tab_cntrl(28) = taux
+        tab_cntrl(29) = tauy
+      ELSE
+        CALL getin('ysinus',ysinus)
+        IF (ysinus) THEN
+          tab_cntrl(27) = 1
+        ELSE
+          tab_cntrl(27) = 0
+        ENDIF
+      ENDIF
+
+c changes must be done BEFORE these lines...
+      DO l=1,length
+         tab_cntrl_dyn(l)= tab_cntrl(l)
+         tab_cntrl_fi(l) = tab_cntrl(l+length)
+      ENDDO
+
+c-----------------------------------------------------------------------
+c	Autres initialisations 
+c-----------------------------------------------------------------------
+
+      CALL iniconst 
+      CALL inigeom
+      call inifilr
+
+c-----------------------------------------------------------------------
+c		Allocations des anciennes variables
+c-----------------------------------------------------------------------
+
+      allocate(rlonuold(imold+1), rlatvold(jmold))
+      allocate(rlonvold(imold+1), rlatuold(jmold+1))
+      allocate(nivsigsold(lmold+1),nivsigold(lmold))
+      allocate(apold(lmold),bpold(lmold))
+      allocate(presnivsold(lmold))
+      allocate(uold(imold+1,jmold+1,lmold))
+      allocate(vold(imold+1,jmold+1,lmold))
+      allocate(told(imold+1,jmold+1,lmold))
+      allocate(qold(imold+1,jmold+1,lmold,nqtot))
+      allocate(psold(imold+1,jmold+1))
+      allocate(phisold(imold+1,jmold+1))
+      allocate(tsurfold(imold+1,jmold+1))
+      allocate(tsoilold(imold+1,jmold+1,nsoilmx))
+      allocate(albeold(imold+1,jmold+1),radsolold(imold+1,jmold+1))
+      allocate(sollwold(imold+1,jmold+1),solswold(imold+1,jmold+1))
+      allocate(dlwold(imold+1,jmold+1))
+      allocate(zmeaold(imold+1,jmold+1),zstdold(imold+1,jmold+1))
+      allocate(zsigold(imold+1,jmold+1),zgamold(imold+1,jmold+1))
+      allocate(ztheold(imold+1,jmold+1),zpicold(imold+1,jmold+1))
+      allocate(zvalold(imold+1,jmold+1))
+
+      allocate(var (imold+1,jmold+1,llm))
+      allocate(varp1 (imold+1,jmold+1,llm+1))
+
+      print*,"Initialisations OK"
+
+c-----------------------------------------------------------------------
+c Lecture des longitudes et latitudes
+c-----------------------------------------------------------------------
+c
+      ierr = NF_INQ_VARID (nid, "rlonv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Le champ <rlonv> est absent de start.nc"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonvold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonvold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Lecture echouee pour <rlonv>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "rlatu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Le champ <rlatu> est absent de start.nc"
+         CALL abort
+      ENDIF 
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatuold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatuold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Lecture echouee pour <rlatu>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "rlonu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Le champ <rlonu> est absent de start.nc"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonuold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonuold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Lecture echouee pour <rlonu>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "rlatv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Le champ <rlatv> est absent de start.nc"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatvold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatvold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Lecture echouee pour <rlatv>"
+         CALL abort
+      ENDIF
+c
+
+      print*,"Lecture lon/lat OK"
+
+c-----------------------------------------------------------------------
+c Lecture des niveaux verticaux
+c-----------------------------------------------------------------------
+c
+      ierr = NF_INQ_VARID (nid, "nivsigs", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <nivsigs> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, nivsigsold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, nivsigsold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <nivsigs>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "nivsig", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <nivsig> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, nivsigold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, nivsigold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <nivsig>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "ap", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Le champ <ap> est absent de start.nc"
+         CALL abort
+      ELSE
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, apold)
+#else
+         ierr = NF_GET_VAR_REAL(nid, nvarid, apold)
+#endif
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "new_grid: Lecture echouee pour <ap>"
+         ENDIF
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "bp", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Le champ <bp> est absent de start.nc"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, bpold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, bpold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Lecture echouee pour <bp>"
+         CALL abort
+      END IF
+
+      ierr = NF_INQ_VARID (nid, "presnivs", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <presnivs> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, presnivsold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, presnivsold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <presnivs>"
+         CALL abort
+      ENDIF
+
+c-----------------------------------------------------------------------
+c Lecture geopotentiel au sol
+c-----------------------------------------------------------------------
+c
+      ierr = NF_INQ_VARID (nid, "phisinit", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Le champ <phisinit> est absent de start.nc"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, phisold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, phisold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "new_grid: Lecture echouee pour <phisinit>"
+         CALL abort
+      ENDIF
+
+      print*,"Lecture niveaux et geopot OK"
+
+c-----------------------------------------------------------------------
+c Lecture des champs 2D ()
+c-----------------------------------------------------------------------
+
+      start=(/1,1,1,0/)
+      counter=(/imold+1,jmold+1,1,0/)
+
+      ierr = NF_INQ_VARID (nid, "ps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <ps> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,psold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,psold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <ps>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "tsurf", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <tsurf> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,tsurfold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,tsurfold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <tsurf>"
+         CALL abort
+      ENDIF
+c
+      do isoil=1,nsoilmx
+         write(str2,'(i2.2)') isoil
+c
+         ierr = NF_INQ_VARID (nid, "Tsoil"//str2, nvarid)
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "lect_start_archive: 
+     .              Le champ <","Tsoil"//str2,"> est absent"
+            CALL abort
+         ENDIF
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,
+     .          tsoilold(1,1,isoil))
+#else
+         ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,
+     .          tsoilold(1,1,isoil))
+#endif
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "lect_start_archive: 
+     .            Lecture echouee pour <","Tsoil"//str2,">"
+            CALL abort
+         ENDIF
+      end do
+c
+      ierr = NF_INQ_VARID (nid, "albe", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <albe> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,albeold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,albeold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <albe>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "radsol", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <radsol> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,radsolold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,radsolold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <radsol>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "sollw", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <sollw> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,sollwold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,sollwold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <sollw>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "solsw", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <solsw> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,solswold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,solswold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <solsw>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "dlw", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <dlw> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,dlwold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,dlwold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <dlw>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "zmea", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <zmea> est absent"
+         PRINT*, "          Il est donc initialise a zero"
+         zmeaold=0.
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,zmeaold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,zmeaold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <zmea>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "zstd", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <zstd> est absent"
+         PRINT*, "          Il est donc initialise a zero"
+         zstdold=0.
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,zstdold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,zstdold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <zstd>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "zsig", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <zsig> est absent"
+         PRINT*, "          Il est donc initialise a zero"
+         zsigold=0.
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,zsigold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,zsigold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <zsig>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "zgam", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <zgam> est absent"
+         PRINT*, "          Il est donc initialise a zero"
+         zgamold=0.
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,zgamold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,zgamold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <zgam>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "zthe", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <zthe> est absent"
+         PRINT*, "          Il est donc initialise a zero"
+         ztheold=0.
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,ztheold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,ztheold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <zthe>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "zpic", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <zpic> est absent"
+         PRINT*, "          Il est donc initialise a zero"
+         zpicold=0.
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,zpicold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,zpicold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <zpic>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "zval", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <zval> est absent"
+         PRINT*, "          Il est donc initialise a zero"
+         zvalold=0.
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,zvalold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,zvalold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <zval>"
+         CALL abort
+      ENDIF
+c
+
+      print*,"Lecture champs 2D OK"
+
+c-----------------------------------------------------------------------
+c	Lecture des champs 3D ()
+c-----------------------------------------------------------------------
+
+      start=(/1,1,1,1/)
+      counter=(/imold+1,jmold+1,lmold,1/)
+c
+      ierr = NF_INQ_VARID (nid,"temp", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <temp> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid, start, counter, told)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid, start, counter, told)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <temp>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid,"u", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <u> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,uold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,uold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <u>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid,"v", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <v> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,counter,vold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,vold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <v>"
+         CALL abort
+      ENDIF
+c
+
+c TNAME: IL EST LU A PARTIR DE traceur.def (mettre l'ancien si
+c                changement du nombre de traceurs)
+
+      IF(iflag_trac.eq.1) THEN
+      DO iq=1,nqtot
+        ierr =  NF_INQ_VARID (nid, tname(iq), nvarid)
+        IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "dynetat0: Le champ <"//tname(iq)//"> est absent"
+            PRINT*, "          Il est donc initialise a zero"
+            qold(:,:,:,iq)=0.
+        ELSE
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid,nvarid,start,counter,qold(1,1,1,iq))
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,counter,qold(1,1,1,iq))
+#endif
+          IF (ierr .NE. NF_NOERR) THEN
+             PRINT*, "dynetat0: Lecture echouee pour "//tname(iq)
+             CALL abort
+          ENDIF
+        ENDIF
+      ENDDO
+      ENDIF
+
+
+      print*,"Lecture champs 3D OK"
+
+c=======================================================================
+c   INTERPOLATION DANS LA NOUVELLE GRILLE et initialisation des variables
+c=======================================================================
+c  Interpolation horizontale puis passage dans la grille physique pour 
+c  les variables physique 
+c  Interpolation verticale puis horizontale pour chaque variable 3D
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c	Variable 2d :
+c-----------------------------------------------------------------------
+
+c Relief 
+! topoflag = F: we keep the existing topography
+!          = T: we read it from the Relief.nc file
+! topoflag need to be in the specific run.def for newstart
+       topoflag = . FALSE .
+       CALL getin('topoflag',topoflag)
+
+       IF ( topoflag ) then
+         print*,"Topography (phis) read in file Relief.nc"
+         print*,"For Venus, map directly inverted in Relief.nc"
+         CALL startget_phys2d('surfgeo',iip1,jjp1,rlonv,rlatu,phis,0.0,
+     .                jjm ,rlonu,rlatv,.true.)
+c needed ?
+          phis(iip1,:) = phis(1,:)
+
+         CALL startget_phys1d('zmea',iip1,jjp1,rlonv,rlatu,ngridmx,zmea,
+     .            0.0,jjm,rlonu,rlatv,.true.)
+         CALL startget_phys1d('zstd',iip1,jjp1,rlonv,rlatu,ngridmx,zstd,
+     .            0.0,jjm,rlonu,rlatv,.true.)
+         CALL startget_phys1d('zsig',iip1,jjp1,rlonv,rlatu,ngridmx,zsig,
+     .            0.0,jjm,rlonu,rlatv,.true.)
+         CALL startget_phys1d('zgam',iip1,jjp1,rlonv,rlatu,ngridmx,zgam,
+     .            0.0,jjm,rlonu,rlatv,.true.)
+         CALL startget_phys1d('zthe',iip1,jjp1,rlonv,rlatu,ngridmx,zthe,
+     .            0.0,jjm,rlonu,rlatv,.true.)
+         CALL startget_phys1d('zpic',iip1,jjp1,rlonv,rlatu,ngridmx,zpic,
+     .            0.0,jjm,rlonu,rlatv,.true.)
+         CALL startget_phys1d('zval',iip1,jjp1,rlonv,rlatu,ngridmx,zval,
+     .            0.0,jjm,rlonu,rlatv,.true.)
+
+       ELSE
+          print*,'Using existing topography'
+          call interp_horiz (phisold,phis,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+
+          call interp_horiz (zmeaold,zmeaS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+          call gr_dyn_fi (1,iip1,jjp1,ngridmx,zmeaS,zmea)
+          call interp_horiz (zstdold,zstdS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+          call gr_dyn_fi (1,iip1,jjp1,ngridmx,zstdS,zstd)
+          call interp_horiz (zsigold,zsigS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+          call gr_dyn_fi (1,iip1,jjp1,ngridmx,zsigS,zsig)
+          call interp_horiz (zgamold,zgamS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+          call gr_dyn_fi (1,iip1,jjp1,ngridmx,zgamS,zgam)
+          call interp_horiz (ztheold,ztheS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+          call gr_dyn_fi (1,iip1,jjp1,ngridmx,ztheS,zthe)
+          call interp_horiz (zpicold,zpicS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+          call gr_dyn_fi (1,iip1,jjp1,ngridmx,zpicS,zpic)
+          call interp_horiz (zvalold,zvalS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+          call gr_dyn_fi (1,iip1,jjp1,ngridmx,zvalS,zval)
+       ENDIF
+
+       print*,"New surface geopotential OK"
+
+c Lat et lon pour physique
+      do i=1,iip1
+        rlatS(i,:)=rlatu(:)*180./pi
+      enddo
+      call gr_dyn_fi (1,iip1,jjp1,ngridmx,rlatS,rlat)
+
+      do j=2,jjm
+        rlonS(:,j)=rlonv(:)*180./pi
+      enddo
+      rlonS(:,1)=0.
+      rlonS(:,jjp1)=0.
+      call gr_dyn_fi (1,iip1,jjp1,ngridmx,rlonS,rlon)
+
+c Temperature de surface
+      call interp_horiz (tsurfold,tsurfS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iip1,jjp1,ngridmx,tsurfS,tsurf)
+c     write(44,*) 'tsurf', tsurf
+
+c Temperature du sous-sol
+      call interp_horiz(tsoilold,tsoilS,
+     &                  imold,jmold,iim,jjm,nsoilmx,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (nsoilmx,iip1,jjp1,ngridmx,tsoilS,tsoil)
+c     write(45,*) 'tsoil',tsoil
+
+! CHANGING ALBEDO: may be done through run.def
+       albedoflag = . FALSE .
+       CALL getin('albedoflag',albedoflag)
+
+       IF ( albedoflag ) then
+         print*,"Albedo is reinitialized to the albedo value in run.def"
+         print*,"We may want to consider a map later on..."
+         albedo=0.1
+         CALL getin('albedo',albedo)
+         albe=albedo
+       ELSE
+         call interp_horiz (albeold,albeS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+         call gr_dyn_fi (1,iip1,jjp1,ngridmx,albeS,albe)
+       ENDIF
+
+      call interp_horiz (radsolold,radsolS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iip1,jjp1,ngridmx,radsolS,radsol)
+
+      call interp_horiz (sollwold,sollwS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iip1,jjp1,ngridmx,sollwS,sollw)
+
+      call interp_horiz (solswold,solswS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iip1,jjp1,ngridmx,solswS,solsw)
+
+      call interp_horiz (dlwold,dlwS,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iip1,jjp1,ngridmx,dlwS,dlw)
+
+      print*,"Nouvelles var physiques OK"
+
+c-----------------------------------------------------------------------
+c	Traitement special de la pression au sol :
+c-----------------------------------------------------------------------
+
+c  Extrapolation la pression dans la nouvelle grille
+      call interp_horiz(psold,ps,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+
+c	On assure la conservation de la masse de l'atmosphere 
+c--------------------------------------------------------------
+
+!!! ATTENTION TEMPORAIRE
+c     ps(:,:)=146700.
+
+      ptotal =  0.
+      DO j=1,jjp1
+         DO i=1,iim
+            ptotal=ptotal+ps(i,j)*aire(i,j)/g
+         END DO
+      END DO
+
+      write(*,*)
+      write(*,*)'Ancienne grille: masse de l atm :',ptotalold
+      write(*,*)'Nouvelle grille: masse de l atm :',ptotal
+      write (*,*) 'Ratio new atm./ old atm =', ptotal/ptotalold 
+      write(*,*)
+
+
+      DO j=1,jjp1
+         DO i=1,iip1
+            ps(i,j)=ps(i,j) * ptotalold/ptotal
+         END DO
+      END DO
+
+c la pression de surface et les temperatures ne sont pas reequilibrees en fonction
+c de la nouvelle topographie... 
+c Si l'ajustement inevitable du debut pose des problemes, voir le newstart martien.
+
+      print*,"Nouvelle ps OK"
+      print*,"If changes done on topography, beware !"
+      print*,"Some time may be needed for adjustments at the beginning"
+      print*,"so if unstable, relax the timestep and/or dissipation."
+
+c-----------------------------------------------------------------------
+c	Variable 3d :
+c-----------------------------------------------------------------------
+
+      CALL pression(ip1jmp1, ap, bp, ps, p3d)
+         if (disvert_type==1) then
+           CALL exner_hyb(  ip1jmp1, ps, p3d, pks, pk, pkf )
+         else ! we assume that we are in the disvert_type==2 case
+           CALL exner_milieu( ip1jmp1, ps, p3d, pks, pk, pkf )
+         endif
+      
+c temperatures atmospheriques
+
+c ATTENTION: peut servir, mais bon...
+c     do l=1,lmold
+c      do j=1,jmold+1
+c       do i=1,imold+1
+c modif: profil uniforme
+c          told(i,j,l)=told(1,jmold/2,l)
+c mean T profile:
+c       told(i,j,l) = 142.1*exp(-((p3d(i,j,l)/100.+21.45)/40.11)**2.) 
+c    .              + 106.3*exp(-((p3d(i,j,l)/100.-3183.)/4737.)**2.)
+c       enddo
+c      enddo
+c     enddo
+
+      write (*,*) 'told ', told (1,jmold+1,1)  ! INFO
+      call interp_vert
+     &    (told,var,lmold,llm,apold,bpold,ap,bp,
+     &     psold,(imold+1)*(jmold+1))
+      write (*,*) 'var ', var (1,jmold+1,1)  ! INFO
+      call interp_horiz(var,t,imold,jmold,iim,jjm,llm,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      write (*,*) 'T ', T(1,jjp1,1)  ! INFO
+! pour info:
+! Si extension verticale, la T est extrapolee constante au-dessus de lmold
+
+c passage grille physique pour restartphy.nc 
+      call gr_dyn_fi (llm,iip1,jjp1,ngridmx,T,t_fi)
+
+! ADAPTATION GCM POUR CP(T)
+c passage en temperature potentielle
+      call t2tpot(ip1jmp1*llm,T,teta,pk)
+c on assure la periodicite
+      teta(iip1,:,:) =  teta(1,:,:)
+
+! RESETING U TO 0: may be done through run.def
+       razvitu = . FALSE .
+       CALL getin('razvitu',razvitu)
+       razvitv = . FALSE .
+       CALL getin('razvitv',razvitv)
+
+c calcul des champ de vent; passage en vent covariant
+      write (*,*) 'uold ', uold (1,2,1)  ! INFO
+      call interp_vert
+     & (uold,var,lmold,llm,apold,bpold,ap,bp,
+     &  psold,(imold+1)*(jmold+1))
+      write (*,*) 'var ', var (1,2,1)  ! INFO
+      call interp_horiz(var,us,imold,jmold,iim,jjm,llm,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      write (*,*) 'us ', us (1,2,1)   ! INFO
+
+      call interp_vert
+     & (vold,var,lmold,llm,
+     &  apold,bpold,ap,bp,psold,(imold+1)*(jmold+1))
+      call interp_horiz(var,vs,imold,jmold,iim,jjm,llm,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call scal_wind(us,vs,unat,vnat)
+! Reseting u=0
+      if (razvitu) then
+           unat(:,:,:) = 0.
+      endif
+      write (*,*) 'unat ', unat (1,2,1)    ! INFO
+      do l=1,llm
+        do j = 1, jjp1
+          do i=1,iip1
+            ucov( i,j,l ) = unat( i,j,l ) * cu(i,j)
+! pour info:
+! Si extension verticale, on impose u=0 au-dessus de lmold
+            if (l.gt.lmold) ucov( i,j,l ) = 0
+          end do
+        end do
+      end do 
+      write (*,*) 'ucov ', ucov (1,2,1)  ! INFO
+c     write(48,*) 'ucov',ucov
+! Reseting v=0
+      if (razvitv) then
+           vnat(:,:,:) = 0.
+      endif
+      write (*,*) 'vnat ', vnat (1,2,1)    ! INFO
+      do l=1,llm
+        do j = 1, jjm
+          do i=1,iim
+            vcov( i,j,l ) = vnat( i,j,l ) * cv(i,j)
+! pour info:
+! Si extension verticale, on impose v=0 au-dessus de lmold
+            if (l.gt.lmold) vcov( i,j,l ) = 0
+          end do
+          vcov( iip1,j,l ) = vcov( 1,j,l )
+        end do
+      end do
+c     write(49,*) 'ucov',vcov
+
+c masse: on la recalcule (ps a été ajustée pour conserver la masse totale)
+      call massdair(p3d,masse)
+      
+c traceurs 3D
+      do  iq = 1, nqtot
+            call interp_vert(qold(1,1,1,iq),var,lmold,llm,
+     &        apold,bpold,ap,bp,psold,(imold+1)*(jmold+1))
+            call interp_horiz(var,q(1,1,1,iq),imold,jmold,iim,jjm,llm,
+     &                  rlonuold,rlatvold,rlonu,rlatv)
+      enddo
+
+      print*,"Nouvelles var dynamiques OK"
+
+c=======================================================================
+c    Ecriture des restart.nc et restartphy.nc :
+c=======================================================================
+
+      call writerestart('restart.nc',tab_cntrl_dyn,
+     .                    phis,vcov,ucov,teta,masse,q,ps)
+
+      print*,"restart OK"
+
+      call writerestartphy('restartphy.nc',tab_cntrl_fi,ngridmx,llm,
+     .           rlat,rlon,tsurf,tsoil,albe,solsw, sollw,dlw,
+     .           radsol,
+     .           zmea,zstd,zsig,zgam,zthe,zpic,zval,
+     .           t_fi)
+
+      print*,"restartphy OK"
+
+      end
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/readstart.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/readstart.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/readstart.F	(revision 1644)
@@ -0,0 +1,499 @@
+!
+! $Header: /home/cvsroot/LMDZ4/libf/dyn3d/dynetat0.F,v 1.2 2004/06/22 11:45:30 lmdzadmin Exp $
+!
+      SUBROUTINE readstart(fichnom,nq,vcov,ucov,
+     .                    teta,q,masse,ps,phis,tab_cntrl)
+
+      USE infotrac
+      USE comconst_mod
+      USE comvert_mod, ONLY: ap,bp,presnivs,pa,preff,nivsigs,nivsig,
+     .                       aps,bps,scaleheight,pseudoalt,
+     .                       disvert_type,pressure_exner
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      USE temps_mod, ONLY: day_ref,annee_ref,day_ini,itau_dyn,
+     &                     start_time
+      USE logic_mod, ONLY: fxyhypb,ysinus,iflag_trac
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van / L.Fairhead
+c   -------
+c
+c   objet:
+c   ------
+c
+c   Lecture de l'etat initial
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "description.h"
+#include "netcdf.inc"
+
+c   Arguments:
+c   ----------
+
+      CHARACTER*(*) fichnom
+      INTEGER nq
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm),teta(ip1jmp1,llm)
+      REAL q(ip1jmp1,llm,nq),masse(ip1jmp1,llm)
+      REAL ps(ip1jmp1),phis(ip1jmp1)
+      REAL time
+      INTEGER length
+      PARAMETER (length=100)
+      REAL tab_cntrl(length) ! tableau des parametres du run
+
+c   Variables 
+c
+      INTEGER iq,i,j,ij,l
+      INTEGER ierr, nid, nvarid
+
+c   local, cas particulier compo.dat
+      integer nyread
+      real    qy(jjp1,llm,nq)
+      character*10 nomy(nq)
+
+c-----------------------------------------------------------------------
+
+c  Ouverture NetCDF du fichier etat initial
+
+      ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
+      IF (ierr.NE.NF_NOERR) THEN
+        write(6,*)' Pb d''ouverture du fichier start.nc'
+        write(6,*)' ierr = ', ierr
+        CALL ABORT
+      ENDIF
+
+c
+      ierr = NF_INQ_VARID (nid, "controle", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <controle> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echoue pour <controle>"
+         CALL abort
+      ENDIF
+
+      im         = tab_cntrl(1)
+      jm         = tab_cntrl(2)
+      lllm       = tab_cntrl(3)
+      day_ref    = tab_cntrl(4)
+      annee_ref  = tab_cntrl(5)
+      rad        = tab_cntrl(6)
+      omeg       = tab_cntrl(7)
+      g          = tab_cntrl(8)
+      cpp        = tab_cntrl(9)
+      kappa      = tab_cntrl(10)
+      daysec     = tab_cntrl(11)
+      dtvr       = tab_cntrl(12)
+      etot0      = tab_cntrl(13)
+      ptot0      = tab_cntrl(14)
+      ztot0      = tab_cntrl(15)
+      stot0      = tab_cntrl(16)
+      ang0       = tab_cntrl(17)
+      pa         = tab_cntrl(18)
+      preff      = tab_cntrl(19)
+c
+      clon       = tab_cntrl(20)
+      clat       = tab_cntrl(21)
+      grossismx  = tab_cntrl(22)
+      grossismy  = tab_cntrl(23)
+c
+      IF ( tab_cntrl(24).EQ.1. )  THEN
+        fxyhypb  = . TRUE .
+c        dzoomx   = tab_cntrl(25)
+c        dzoomy   = tab_cntrl(26)
+c        taux     = tab_cntrl(28)
+c        tauy     = tab_cntrl(29)
+      ELSE
+        fxyhypb = . FALSE .
+        ysinus  = . FALSE .
+        IF( tab_cntrl(27).EQ.1. ) ysinus = . TRUE. 
+      ENDIF
+
+      day_ini = tab_cntrl(30)
+      itau_dyn = tab_cntrl(31)
+      start_time = tab_cntrl(32)
+c   .................................................................
+c
+c
+      PRINT*,'rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa
+
+      IF(   im.ne.iim           )  THEN
+          PRINT 1,im,iim
+          STOP
+      ELSE  IF( jm.ne.jjm       )  THEN
+          PRINT 2,jm,jjm
+          STOP
+      ELSE  IF( lllm.ne.llm     )  THEN
+          PRINT 3,lllm,llm
+          STOP
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlonu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlonu> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonu)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonu)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <rlonu>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlatu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlatu> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatu)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatu)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <rlatu>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlonv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlonv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonv)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonv)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <rlonv>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlatv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlatv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatv)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatv)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour rlatv"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "nivsigs", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <nivsigs> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, nivsigs)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, nivsigs)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <nivsigs>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "nivsig", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <nivsig> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, nivsig)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, nivsig)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <nivsig>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "ap", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <ap> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ap)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, ap)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <ap>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "bp", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <bp> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, bp)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, bp)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <bp>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "presnivs", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <presnivs> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, presnivs)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, presnivs)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <presnivs>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "cu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <cu> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, cu)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, cu)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <cu>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "cv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <cv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, cv)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, cv)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <cv>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "aire", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <aire> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, aire)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, aire)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <aire>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "phisinit", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <phisinit> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, phis)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, phis)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <phisinit>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "temps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <temps> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, time)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, time)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee <temps>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "ucov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <ucov> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ucov)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, ucov)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <ucov>"
+         CALL abort
+      ENDIF
+ 
+      ierr = NF_INQ_VARID (nid, "vcov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <vcov> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, vcov)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, vcov)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <vcov>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "teta", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <teta> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, teta)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, teta)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <teta>"
+         CALL abort
+      ENDIF
+
+c TNAME: IL EST LU A PARTIR DE traceur.def (mettre l'ancien si
+c                changement du nombre de traceurs)
+
+      IF((nq.GE.1).and.(iflag_trac.eq.1)) THEN
+      DO iq=1,nq
+        ierr =  NF_INQ_VARID (nid, tname(iq), nvarid)
+        IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "dynetat0: Le champ <"//tname(iq)//"> est absent"
+            PRINT*, "          Il est donc initialise a zero"
+            q(:,:,iq)=0.
+        ELSE
+#ifdef NC_DOUBLE
+          ierr = NF_GET_VAR_DOUBLE(nid, nvarid, q(1,1,iq))
+#else
+          ierr = NF_GET_VAR_REAL(nid, nvarid, q(1,1,iq))
+#endif
+          IF (ierr .NE. NF_NOERR) THEN
+             PRINT*, "dynetat0: Lecture echouee pour "//tname(iq)
+             CALL abort
+          ENDIF
+        ENDIF
+      ENDDO
+      ENDIF
+
+c--------------------------------------------
+c cas particulier: lecture des traceurs 2D dans compo.dat (issu de start 2d)
+c 
+      if (1.eq.0) then
+      OPEN(10,file='compo.dat',status='old',form='formatted',
+     . iostat=ierr)
+      IF (ierr.ne.0) THEN
+       WRITE(6,*)' Pb d''ouverture du fichier de demarrage (compo.dat)'
+       WRITE(6,*)' ierr = ', ierr
+       CALL exit(1)
+      ENDIF
+      READ(10,*) nyread
+      print*,"nombre de composes chimiques ajoutes:",nyread
+      READ(10,*) (((qy(ij,l,iq),ij=1,jjp1),l=1,llm),
+     s                   iq=1,nyread)
+      do iq=1,nyread
+         READ(10,'(1X,A10)') nomy(iq)
+         print*,nomy(iq)," = ", tname(iq+10)
+         do i=1,iip1
+          do j=1,jjp1
+           ij = (j-1)*iip1+i
+           q(ij,:,iq+10) = qy(j,:,iq)
+          enddo
+         enddo
+      enddo
+      CLOSE(10)
+      endif
+c--------------------------------------------
+
+      ierr = NF_INQ_VARID (nid, "masse", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <masse> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, masse)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, masse)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <masse>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "ps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <ps> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ps)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, ps)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <ps>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_CLOSE(nid)
+
+       day_ini=day_ini+INT(time)
+       time=time-INT(time)
+
+  1   FORMAT(//10x,'la valeur de im =',i4,2x,'lue sur le fichier de dem
+     *arrage est differente de la valeur parametree iim =',i4//)
+   2  FORMAT(//10x,'la valeur de jm =',i4,2x,'lue sur le fichier de dem
+     *arrage est differente de la valeur parametree jjm =',i4//)
+   3  FORMAT(//10x,'la valeur de lmax =',i4,2x,'lue sur le fichier dema
+     *rrage est differente de la valeur parametree llm =',i4//)
+   4  FORMAT(//10x,'la valeur de dtrv =',i4,2x,'lue sur le fichier dema
+     *rrage est differente de la valeur  dtinteg =',i4//)
+
+      RETURN
+      END
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/readstartphy.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/readstartphy.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/readstartphy.F	(revision 1644)
@@ -0,0 +1,477 @@
+!
+! $Header: /home/cvsroot/LMDZ4/libf/phylmd/phyetat0.F,v 1.2 2004/06/22 11:45:33 lmdzadmin Exp $
+!
+c
+c
+      SUBROUTINE readstartphy(fichnom,
+     .            rlat,rlon, tsol,tsoil,
+     .           albe, solsw, sollw,
+     .           fder,radsol,
+     .    zmea, zstd, zsig, zgam, zthe, zpic, zval,
+     .           tabcntr0)
+c======================================================================
+c Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+c Objet: Lecture de l'etat initial pour la physique
+c======================================================================
+      use dimphy
+      IMPLICIT none
+#include "dimensions.h"
+#include "netcdf.inc"
+#include "dimsoil.h"
+c======================================================================
+      integer ngridmx
+      parameter (ngridmx=(2+(jjm-1)*iim - 1/jjm))
+
+      CHARACTER*(*) fichnom
+      REAL rlat(ngridmx), rlon(ngridmx)
+      REAL tsol(ngridmx)
+      REAL tsoil(ngridmx,nsoilmx)
+      REAL albe(ngridmx)
+cIM BEG alblw
+      REAL alblw(ngridmx)
+cIM END alblw
+      REAL radsol(ngridmx)
+      REAL sollw(ngridmx)
+      real solsw(ngridmx)
+      real fder(ngridmx)
+      REAL zmea(ngridmx), zstd(ngridmx)
+      REAL zsig(ngridmx), zgam(ngridmx), zthe(ngridmx)
+      REAL zpic(ngridmx), zval(ngridmx)
+      INTEGER length
+      PARAMETER (length=100)
+      REAL tabcntr0(length)
+
+      REAL xmin, xmax
+c
+      INTEGER nid, nvarid
+      INTEGER ierr, i, nsrf, isoil 
+      CHARACTER*2 str2
+c
+c Ouvrir le fichier contenant l'etat initial:
+c
+      print*,'fichnom',fichnom
+      ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
+      IF (ierr.NE.NF_NOERR) THEN
+        write(6,*)' Pb d''ouverture du fichier '//fichnom
+        write(6,*)' ierr = ', ierr
+        CALL ABORT
+      ENDIF
+c
+c Lecture des parametres de controle:
+c
+      ierr = NF_INQ_VARID (nid, "controle", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <controle> est absent'
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tabcntr0)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, tabcntr0)
+#endif
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <controle>'
+         CALL abort
+      ENDIF
+c
+c
+c Lecture des latitudes (coordonnees):
+c
+      ierr = NF_INQ_VARID (nid, "latitude", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <latitude> est absent'
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlat)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlat)
+#endif
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <latitude>'
+         CALL abort
+      ENDIF
+c
+c Lecture des longitudes (coordonnees):
+c
+      ierr = NF_INQ_VARID (nid, "longitude", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <longitude> est absent'
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlon)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlon)
+#endif
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <latitude>'
+         CALL abort
+      ENDIF
+C
+c Lecture des temperatures du sol:
+c
+      ierr = NF_INQ_VARID (nid, "TS", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <TS> est absent'
+         PRINT*, "phyetat0: Lecture echouee pour <TS>"
+         CALL abort
+      ELSE
+         PRINT*, 'phyetat0: Le champ <TS> est present'
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tsol)
+#else
+         ierr = NF_GET_VAR_REAL(nid, nvarid, tsol)
+#endif
+         IF (ierr.NE.NF_NOERR) THEN
+            PRINT*, "phyetat0: Lecture echouee pour <TS>"
+            CALL abort
+         ENDIF
+         xmin = 1.0E+20
+         xmax = -1.0E+20
+         DO i = 1, ngridmx
+            xmin = MIN(tsol(i),xmin)
+            xmax = MAX(tsol(i),xmax)
+         ENDDO
+         PRINT*,'Temperature du sol <TS>', xmin, xmax
+      ENDIF
+c
+c Lecture des temperatures du sol profond:
+c
+      DO isoil=1, nsoilmx
+      IF (isoil.GT.99) THEN
+         PRINT*, "Trop de couches"
+         CALL abort
+      ENDIF
+      WRITE(str2,'(i2.2)') isoil
+      ierr = NF_INQ_VARID (nid, 'Tsoil'//str2, nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, "phyetat0: Le champ <Tsoil"//str2//"> est absent"
+         PRINT*, "          Il prend donc la valeur de surface"
+         DO i=1, ngridmx
+             tsoil(i,isoil)=tsol(i)
+         ENDDO
+      ELSE
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tsoil(1,isoil))
+#else
+         ierr = NF_GET_VAR_REAL(nid, nvarid, tsoil(1,isoil))
+#endif
+         IF (ierr.NE.NF_NOERR) THEN
+            PRINT*, "Lecture echouee pour <Tsoil"//str2//">"
+            CALL abort
+         ENDIF
+      ENDIF
+      ENDDO
+
+c
+c Lecture de albedo au sol:
+c
+      ierr = NF_INQ_VARID (nid, "ALBE", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ALBE> est absent'
+         PRINT*, "phyetat0: Lecture echouee pour <ALBE>"
+         CALL abort
+      ELSE
+         PRINT*, 'phyetat0: Le champ <ALBE> est present'
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, albe(1))
+#else
+         ierr = NF_GET_VAR_REAL(nid, nvarid, albe(1))
+#endif
+         IF (ierr.NE.NF_NOERR) THEN
+            PRINT*, "phyetat0: Lecture echouee pour <ALBE>"
+            CALL abort
+         ENDIF
+         xmin = 1.0E+20
+         xmax = -1.0E+20
+         DO i = 1, ngridmx
+            xmin = MIN(albe(i),xmin)
+            xmax = MAX(albe(i),xmax)
+         ENDDO
+         PRINT*,'Albedo du sol <ALBE>', xmin, xmax
+      ENDIF
+
+c
+c Lecture rayonnement solaire au sol:
+c
+      ierr = NF_INQ_VARID (nid, "solsw", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <solsw> est absent'
+         PRINT*, 'mis a zero'
+         solsw = 0.
+      ELSE
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, solsw)
+#else
+        ierr = NF_GET_VAR_REAL(nid, nvarid, solsw)
+#endif
+        IF (ierr.NE.NF_NOERR) THEN
+          PRINT*, 'phyetat0: Lecture echouee pour <solsw>'
+          CALL abort
+        ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(solsw(i),xmin)
+         xmax = MAX(solsw(i),xmax)
+      ENDDO
+      PRINT*,'Rayonnement solaire au sol solsw:', xmin, xmax
+c
+c Lecture rayonnement IF au sol:
+c
+      ierr = NF_INQ_VARID (nid, "sollw", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <sollw> est absent'
+         PRINT*, 'mis a zero'
+         sollw = 0.
+      ELSE
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, sollw)
+#else
+        ierr = NF_GET_VAR_REAL(nid, nvarid, sollw)
+#endif
+        IF (ierr.NE.NF_NOERR) THEN
+          PRINT*, 'phyetat0: Lecture echouee pour <sollw>'
+          CALL abort
+        ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(sollw(i),xmin)
+         xmax = MAX(sollw(i),xmax)
+      ENDDO
+      PRINT*,'Rayonnement IF au sol sollw:', xmin, xmax
+
+c
+c Lecture derive des flux:
+c
+      ierr = NF_INQ_VARID (nid, "fder", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <fder> est absent'
+         PRINT*, 'mis a zero'
+         fder = 0.
+      ELSE
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, fder)
+#else
+        ierr = NF_GET_VAR_REAL(nid, nvarid, fder)
+#endif
+        IF (ierr.NE.NF_NOERR) THEN
+          PRINT*, 'phyetat0: Lecture echouee pour <fder>'
+          CALL abort
+        ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(fder(i),xmin)
+         xmax = MAX(fder(i),xmax)
+      ENDDO
+      PRINT*,'Derive des flux fder:', xmin, xmax
+
+c
+c Lecture du rayonnement net au sol:
+c
+      ierr = NF_INQ_VARID (nid, "RADS", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <RADS> est absent'
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, radsol)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, radsol)
+#endif
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <RADS>'
+         CALL abort
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(radsol(i),xmin)
+         xmax = MAX(radsol(i),xmax)
+      ENDDO
+      PRINT*,'Rayonnement net au sol radsol:', xmin, xmax
+
+c
+c Lecture des parametres orographie sous-maille:
+c
+      ierr = NF_INQ_VARID (nid, "ZMEA", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ZMEA> est absent'
+         PRINT*, 'mis a zero'
+         zmea = 0.
+      ELSE
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zmea)
+#else
+       ierr = NF_GET_VAR_REAL(nid, nvarid, zmea)
+#endif
+       IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <ZMEA>'
+         CALL abort
+       ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(zmea(i),xmin)
+         xmax = MAX(zmea(i),xmax)
+      ENDDO
+      PRINT*,'zmea:', xmin, xmax
+c
+      ierr = NF_INQ_VARID (nid, "ZSTD", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ZSTD> est absent'
+         PRINT*, 'mis a zero'
+         zstd = 0.
+      ELSE
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zstd)
+#else
+       ierr = NF_GET_VAR_REAL(nid, nvarid, zstd)
+#endif
+       IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <ZSTD>'
+         CALL abort
+       ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(zstd(i),xmin)
+         xmax = MAX(zstd(i),xmax)
+      ENDDO
+      PRINT*,'zstd:', xmin, xmax
+c
+      ierr = NF_INQ_VARID (nid, "ZSIG", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ZSIG> est absent'
+         PRINT*, 'mis a zero'
+         zsig = 0.
+      ELSE
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zsig)
+#else
+       ierr = NF_GET_VAR_REAL(nid, nvarid, zsig)
+#endif
+       IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <ZSIG>'
+         CALL abort
+       ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(zsig(i),xmin)
+         xmax = MAX(zsig(i),xmax)
+      ENDDO
+      PRINT*,'zsig:', xmin, xmax
+c
+      ierr = NF_INQ_VARID (nid, "ZGAM", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ZGAM> est absent'
+         PRINT*, 'mis a zero'
+         zgam = 0.
+      ELSE
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zgam)
+#else
+       ierr = NF_GET_VAR_REAL(nid, nvarid, zgam)
+#endif
+       IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <ZGAM>'
+         CALL abort
+       ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(zgam(i),xmin)
+         xmax = MAX(zgam(i),xmax)
+      ENDDO
+      PRINT*,'zgam:', xmin, xmax
+c
+      ierr = NF_INQ_VARID (nid, "ZTHE", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ZTHE> est absent'
+         PRINT*, 'mis a zero'
+         zthe = 0.
+      ELSE
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zthe)
+#else
+       ierr = NF_GET_VAR_REAL(nid, nvarid, zthe)
+#endif
+       IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <ZTHE>'
+         CALL abort
+       ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(zthe(i),xmin)
+         xmax = MAX(zthe(i),xmax)
+      ENDDO
+      PRINT*,'zthe:', xmin, xmax
+c
+      ierr = NF_INQ_VARID (nid, "ZPIC", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ZPIC> est absent'
+         PRINT*, 'mis a zero'
+         zpic = 0.
+      ELSE
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zpic)
+#else
+       ierr = NF_GET_VAR_REAL(nid, nvarid, zpic)
+#endif
+       IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <ZPIC>'
+         CALL abort
+       ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(zpic(i),xmin)
+         xmax = MAX(zpic(i),xmax)
+      ENDDO
+      PRINT*,'zpic:', xmin, xmax
+c
+      ierr = NF_INQ_VARID (nid, "ZVAL", nvarid)
+      IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Le champ <ZVAL> est absent'
+         PRINT*, 'mis a zero'
+         zval = 0.
+      ELSE
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid, nvarid, zval)
+#else
+       ierr = NF_GET_VAR_REAL(nid, nvarid, zval)
+#endif
+       IF (ierr.NE.NF_NOERR) THEN
+         PRINT*, 'phyetat0: Lecture echouee pour <ZVAL>'
+         CALL abort
+       ENDIF
+      ENDIF
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      DO i = 1, ngridmx
+         xmin = MIN(zval(i),xmin)
+         xmax = MAX(zval(i),xmax)
+      ENDDO
+      PRINT*,'zval:', xmin, xmax
+c
+c Fermer le fichier:
+c
+      ierr = NF_CLOSE(nid)
+c
+      RETURN
+      END
+
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/scal_wind.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/scal_wind.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/scal_wind.F	(revision 1644)
@@ -0,0 +1,54 @@
+      SUBROUTINE scal_wind(xus,xvs,xu,xv)
+c=======================================================================
+c
+c
+c   Subject:
+c   ------
+c On passe  les variable xus, xvs  aux points de vent u et v (xu et xv)
+c
+c=======================================================================
+      IMPLICIT NONE
+c-----------------------------------------------------------------------
+c   Declararations:
+c   ---------------
+
+#include "dimensions.h"
+#include "paramet.h"
+
+c   Arguments:
+c   ----------
+
+      REAL xu(iip1,jjp1,llm),xv(iip1,jjm,llm)
+      REAL xus(iip1,jjp1,llm), xvs (iip1,jjp1,llm)
+
+c   Local:
+c   ------
+
+      INTEGER i,j,l
+
+c-----------------------------------------------------------------------
+
+c   transport zonal:
+c   ----------------
+      DO l=1,llm
+        Do j=1,jjp1
+	      DO i=1,iim
+            xu(i,j,l)=0.5*(xus(i,j,l)+xus(i+1,j,l))
+	      ENDDO
+          xu(iip1,j,l)=xu(1,j,l)
+	    ENDDO
+      ENDDO
+
+
+c   Transport meridien:
+c   -------------------
+      DO l=1,llm
+         DO j=1,jjm
+           do i=1 ,iip1
+	         xv(i,j,l)=.5*(xvs(i,j,l)+xvs(i,j+1,l))
+           end do
+	     ENDDO
+	  ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/start2archive.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/start2archive.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/start2archive.F	(revision 1644)
@@ -0,0 +1,317 @@
+c=======================================================================
+      PROGRAM start2archive
+c=======================================================================
+c
+c
+c   Date:    01/1997
+c   ----
+c
+c   Version Venus: 09/2007
+c           Titan: 02/2009
+c
+c   Objet:   Passage des  fichiers netcdf d etat initial "start" et
+c   -----    "startphy" a un fichier netcdf unique "start_archive" 
+c
+c=======================================================================
+
+      USE filtreg_mod
+      USE infotrac
+      USE control_mod
+      use cpdet_mod, only: tpot2t,ini_cpdet
+      use exner_hyb_m, only: exner_hyb
+      use exner_milieu_m, only: exner_milieu
+      USE comconst_mod
+      USE comvert_mod, ONLY: ap,bp,presnivs,pa,preff,nivsigs,nivsig,
+     .                       aps,bps,scaleheight,pseudoalt,
+     .                       disvert_type,pressure_exner
+      USE logic_mod, ONLY: iflag_trac
+
+      implicit none
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissnew.h"
+#include "comgeom.h"
+#include "description.h"
+#include "dimsoil.h"
+#include "netcdf.inc"
+
+c-----------------------------------------------------------------------
+c   Declarations
+c-----------------------------------------------------------------------
+
+c variables dynamiques du GCM
+c -----------------------------
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
+      REAL teta(ip1jmp1,llm)                    ! temperature potentielle 
+      REAL, ALLOCATABLE, DIMENSION(:,:,:):: q! champs advectes
+      REAL pks(ip1jmp1)                      ! exner (f pour filtre)
+      REAL pk(ip1jmp1,llm)
+      REAL pkf(ip1jmp1,llm)
+      REAL alpha(iip1,jjp1,llm),beta(iip1,jjp1,llm)
+      REAL phis(ip1jmp1)                     ! geopotentiel au sol
+      REAL masse(ip1jmp1,llm)                ! masse de l'atmosphere
+      REAL ps(ip1jmp1)                       ! pression au sol
+      REAL p3d(iip1, jjp1, llm+1)            ! pression aux interfaces
+      
+c Variable Physiques (grille physique)
+c ------------------------------------
+      integer ngridmx,nlayermx
+      parameter (ngridmx=(2+(jjm-1)*iim - 1/jjm))
+      parameter (nlayermx=llm)
+
+      real rlat(ngridmx),rlon(ngridmx)
+      REAL tsurf(ngridmx),tsoil(ngridmx,nsoilmx)
+      REAL albe(ngridmx),radsol(ngridmx),sollw(ngridmx)
+      real solsw(ngridmx),dlw(ngridmx)
+      REAL zmea(ngridmx), zstd(ngridmx)
+      REAL zsig(ngridmx), zgam(ngridmx), zthe(ngridmx)
+      REAL zpic(ngridmx), zval(ngridmx)
+      
+      INTEGER start,length
+      PARAMETER (length = 100)
+      REAL tab_cntrl_fi(length) ! tableau des parametres de startfi
+      REAL tab_cntrl_dyn(length) ! tableau des parametres de start
+      INTEGER*4 day_ini_fi
+
+c Variable naturelle / grille scalaire
+c ------------------------------------
+      REAL T(ip1jmp1,llm),us(ip1jmp1,llm),vs(ip1jmp1,llm)
+      REAL tsurfS(ip1jmp1),tsoilS(ip1jmp1,nsoilmx)
+      real rlatS(ip1jmp1),rlonS(ip1jmp1)
+      real albeS(ip1jmp1),radsolS(ip1jmp1),sollwS(ip1jmp1)
+      real solswS(ip1jmp1),dlwS(ip1jmp1)
+      real zmeaS(ip1jmp1),zstdS(ip1jmp1),zsigS(ip1jmp1)
+      real zgamS(ip1jmp1),ztheS(ip1jmp1),zpicS(ip1jmp1)
+      real zvalS(ip1jmp1)
+      
+c Variables intermediaires : vent naturel, mais pas coord scalaire
+c----------------------------------------------------------------
+      REAL vn(ip1jm,llm),un(ip1jmp1,llm)
+
+c Autres  variables
+c -----------------
+      REAL ptotal
+
+      CHARACTER*2 str2
+
+      INTEGER ij, l,i,j,isoil,iq
+      character*80      fichnom
+      integer :: ierr
+
+c Netcdf
+c-------
+      integer varid,dimid
+      INTEGER nid
+
+c-----------------------------------------------------------------------
+c   Initialisations 
+c-----------------------------------------------------------------------
+
+c VENUS/TITAN
+
+        iflag_trac = 1
+c-----------------------------------------------------------------------
+c   Initialisation des traceurs
+c   ---------------------------
+c  Choix du nombre de traceurs et du schema pour l advection
+c  dans fichier traceur.def, par default ou via INCA
+      call infotrac_init
+
+c Allocation de la tableau q : champs advectes   
+      allocate(q(ip1jmp1,llm,nqtot))
+
+c=======================================================================
+c Lecture des donnees
+c=======================================================================
+
+      fichnom = 'start.nc'
+      CALL readstart(fichnom,nqtot,vcov,ucov,teta,q,masse,
+     .       ps,phis,tab_cntrl_dyn)
+
+      fichnom = 'startphy.nc'
+      CALL readstartphy(fichnom,
+     .       rlat,rlon,tsurf,tsoil,
+     .       albe, solsw, sollw,
+     .       dlw,radsol,
+     .       zmea,zstd,zsig,zgam,zthe,zpic,zval,
+     .       tab_cntrl_fi)
+
+c-----------------------------------------------------------------------
+c   Initialisations 
+c-----------------------------------------------------------------------
+
+      CALL conf_gcm( 99, .TRUE. )
+      call iniconst
+      call inigeom
+      call inifilr
+      call ini_cpdet
+
+      CALL pression(ip1jmp1, ap, bp, ps, p3d)
+         if (disvert_type==1) then
+           CALL exner_hyb(  ip1jmp1, ps, p3d, pks, pk, pkf )
+         else ! we assume that we are in the disvert_type==2 case
+           CALL exner_milieu( ip1jmp1, ps, p3d, pks, pk, pkf )
+         endif
+
+c=======================================================================
+c Transformation EN VARIABLE NATURELLE / GRILLE SCALAIRE si necessaire
+c=======================================================================
+c  Les variables modeles dependent de la resolution. Il faut donc
+c  eliminer les facteurs responsables de cette dependance
+c  (pour utiliser newstart)
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c Vent   (depend de la resolution horizontale) 
+c-----------------------------------------------------------------------
+c
+c ucov --> un  et  vcov --> vn
+c un --> us  et   vn --> vs
+c
+c-----------------------------------------------------------------------
+
+      call covnat(llm,ucov, vcov, un, vn) 
+      call wind_scal(un,vn,us,vs) 
+
+c-----------------------------------------------------------------------
+c Temperature  (depend de la resolution verticale => de "sigma.def")
+c-----------------------------------------------------------------------
+c
+c h --> T
+c
+c-----------------------------------------------------------------------
+! ADAPTATION GCM POUR CP(T)
+
+      call tpot2t(ip1jmp1*llm,teta,T,pk)
+
+c-----------------------------------------------------------------------
+c Variable physique 
+c-----------------------------------------------------------------------
+c
+c tsurf --> tsurfS
+c et autres...
+c
+c-----------------------------------------------------------------------
+
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,tsurf,tsurfS)
+      call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,tsoil,tsoilS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,rlat,rlatS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,rlon,rlonS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,albe,albeS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,radsol,radsolS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,sollw,sollwS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,solsw,solswS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,dlw,dlwS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,zmea,zmeaS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,zstd,zstdS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,zsig,zsigS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,zgam,zgamS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,zthe,ztheS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,zpic,zpicS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,zval,zvalS)
+
+c=======================================================================
+c Info pour controler
+c=======================================================================
+
+      ptotal =  0.
+      DO j=1,jjp1
+         DO i=1,iim
+           ptotal=ptotal+aire(i+(iim+1)*(j-1))*ps(i+(iim+1)*(j-1))/g
+         ENDDO
+      ENDDO
+      write(*,*)'Ancienne grille : masse de l''atm :',ptotal
+
+c-----------------------------------------------------------------------
+c Passage de "ptotal" par tab_cntrl_fi
+c-----------------------------------------------------------------------
+
+      tab_cntrl_fi(length) = ptotal
+
+c=======================================================================
+c Ecriture dans le fichier  "start_archive"
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c Ouverture de "start_archive" 
+c-----------------------------------------------------------------------
+
+      ierr = NF_OPEN ('start_archive.nc', NF_WRITE,nid)
+ 
+c-----------------------------------------------------------------------
+c  si "start_archive" n'existe pas:
+c    1_ ouverture
+c    2_ creation de l'entete dynamique ("ini_archive")
+c-----------------------------------------------------------------------
+c ini_archive:
+c On met dans l'entete le tab_cntrl_dyn (1 a length) 
+c  On y ajoute les valeurs du tab_cntrl_fi (length+1 a 2*length)
+c-----------------------------------------------------------------------
+
+      if (ierr.ne.NF_NOERR) then
+         write(*,*)'OK, Could not open file "start_archive.nc"'
+         write(*,*)'So let s create a new "start_archive"'
+         ierr = NF_CREATE('start_archive.nc', NF_CLOBBER, nid)
+         call ini_archive(nid,phis,tab_cntrl_dyn,tab_cntrl_fi)
+      else
+         write(*,*)'Attention, start_archive.nc existe deja...'
+	 call abort
+      endif
+
+c-----------------------------------------------------------------------
+c Ecriture des champs 
+c-----------------------------------------------------------------------
+
+      call write_archive(nid,'u','Vent zonal','m.s-1',3,us)
+      call write_archive(nid,'v','Vent merid','m.s-1',3,vs)
+      call write_archive(nid,'temp','temperature','K',3,T)
+c-----------------------------------------------------------------------
+c Ecriture du champs  q  ( q[1,nqtot] )
+c-----------------------------------------------------------------------
+       do iq=1,nqtot
+        write(str2,'(i2.2)') iq
+         call write_archive(nid,tname(iq),'tracer','kg/kg',
+     .         3,q(1,1,iq))
+       end do
+c-----------------------------------------------------------------------
+      call write_archive(nid,'masse','Masse','kg',3,masse)
+      call write_archive(nid,'ps','Psurf','Pa',2,ps)
+      call write_archive(nid,'tsurf','surf T','K',2,tsurfS)
+c-----------------------------------------------------------------------
+c Ecriture du champs  tsoil  ( Tsoil[1,nsoilmx] )
+c-----------------------------------------------------------------------
+c "tsoil" Temperature au sol definie dans nsoilmx couches dans le sol
+c   Les nsoilmx couches sont lues comme nsoilmx champs 
+c  nommees Tsoil[1,nsoilmx]
+      do isoil=1,nsoilmx
+       write(str2,'(i2.2)') isoil
+       call write_archive(nid,'Tsoil'//str2,'Ground Temperature ',
+     .   'K',2,tsoilS(1,isoil))
+      enddo
+c-----------------------------------------------------------------------
+      call write_archive(nid,'rlat','Latitude','rad',2,rlatS)
+      call write_archive(nid,'rlon','Longitude','rad',2,rlonS)
+      call write_archive(nid,'albe','Albedo','',2,albeS)
+      call write_archive(nid,'radsol',
+     .             'Net flux at surface','W m-2',2,radsolS)
+      call write_archive(nid,'sollw',
+     .             'LW flux at surface','W m-2',2,sollwS)
+      call write_archive(nid,'solsw',
+     .             'SW flux at surface','W m-2',2,solswS)
+      call write_archive(nid,'dlw','LW derive','?',2,dlwS)
+      call write_archive(nid,'zmea','param oro sous-maille','m',2,zmeaS)
+      call write_archive(nid,'zstd','param oro sous-maille','m',2,zstdS)
+      call write_archive(nid,'zsig','param oro sous-maille','m',2,zsigS)
+      call write_archive(nid,'zgam','param oro sous-maille','m',2,zgamS)
+      call write_archive(nid,'zthe','param oro sous-maille','m',2,ztheS)
+      call write_archive(nid,'zpic','param oro sous-maille','m',2,zpicS)
+      call write_archive(nid,'zval','param oro sous-maille','m',2,zvalS)
+
+      ierr=NF_CLOSE(nid)
+
+c-----------------------------------------------------------------------
+c Fin 
+c-----------------------------------------------------------------------
+
+      end 
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/startvar.F90
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/startvar.F90	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/startvar.F90	(revision 1644)
@@ -0,0 +1,771 @@
+!
+! $Id: startvar.F90 1425 2010-09-02 13:45:23Z lguez $
+!
+!*******************************************************************************
+!
+MODULE startvar
+!
+!*******************************************************************************
+!
+!-------------------------------------------------------------------------------
+! Purpose: Access data from the database of atmospheric to initialize the model.
+!-------------------------------------------------------------------------------
+! Comments:
+!
+!    *  This module is designed to work for Earth (and with ioipsl)
+!
+!    *  There are three ways to acces data, depending on the type of field
+!  which needs to be extracted. In any case the call should come after a restget
+!  and should be of the type :                     CALL startget(...)
+!
+!  - A 1D variable on the physical grid :
+!    CALL startget_phys1d((varname, iml, jml,  lon_in,  lat_in,  nbindex,              &
+!           champ, val_exp,      jml2, lon_in2, lat_in2, ibar )
+!
+!  - A 2D variable on the dynamical grid :
+!    CALL startget_phys2d(varname, iml, jml,  lon_in,  lat_in,                        &
+!           champ, val_exp,      jml2, lon_in2, lat_in2, ibar )             
+!
+!  - A 3D variable on the dynamical grid :
+!    CALL startget_dyn((varname, iml, jml,  lon_in,  lat_in,  lml, pls, workvar,    &
+!           champ, val_exp,      jml2, lon_in2, lat_in2, ibar )
+!
+!    *  Data needs to be in NetCDF format
+!
+!    *  Variables should have the following names in the files:
+!            'RELIEF' : High resolution orography 
+!            'ST'     : Surface temperature
+!            'CDSW'   : Soil moisture
+!            'Z'      : Surface geopotential
+!            'SP'     : Surface pressure
+!            'U'      : East ward wind
+!            'V'      : Northward wind
+!            'TEMP'   : Temperature
+!            'R'      : Relative humidity
+!
+!   *   There is a big mess with the longitude size. Should it be iml or iml+1 ?
+!  I have chosen to use the iml+1 as an argument to this routine and we declare
+!  internaly smaller fields when needed. This needs to be cleared once and for
+!  all in LMDZ. A convention is required.
+!-------------------------------------------------------------------------------
+  USE ioipsl
+  IMPLICIT NONE
+
+  PRIVATE
+  PUBLIC startget_phys2d, startget_phys1d, startget_dyn
+!  INTERFACE startget
+!    MODULE PROCEDURE startget_phys1d, startget_phys2d, startget_dyn
+!  END INTERFACE
+
+  REAL,    SAVE :: deg2rad,  pi
+  INTEGER, SAVE ::           iml_rel,  jml_rel
+  INTEGER, SAVE :: fid_phys, iml_phys, jml_phys
+  INTEGER, SAVE :: fid_dyn,  iml_dyn,  jml_dyn,  llm_dyn,  ttm_dyn
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: lon_phys, lon_dyn
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: lat_phys, lat_dyn
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: lon_rug, lon_alb, lon_rel
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: lat_rug, lat_alb, lat_rel
+  REAL, DIMENSION(:),     ALLOCATABLE, TARGET, SAVE :: levdyn_ini
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: relief, zstd, zsig, zgam
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: zthe, zpic, zval
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: rugo, phis, tsol, qsol
+  REAL, DIMENSION(:,:),   ALLOCATABLE, TARGET, SAVE :: psol_dyn
+  REAL, DIMENSION(:,:,:), ALLOCATABLE, TARGET, SAVE :: var_ana3d
+
+   CONTAINS
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE startget_phys1d(varname, iml, jml, lon_in, lat_in, nbindex, champ,  &
+                           val_exp ,jml2, lon_in2, lat_in2, ibar)
+!
+!-------------------------------------------------------------------------------
+! Comment:
+!   This routine only works if the variable does not exist or is constant.
+!-------------------------------------------------------------------------------
+! Arguments:
+  CHARACTER(LEN=*),         INTENT(IN)    :: varname
+  INTEGER,                  INTENT(IN)    :: iml, jml
+  REAL, DIMENSION(iml),     INTENT(IN)    :: lon_in
+  REAL, DIMENSION(jml),     INTENT(IN)    :: lat_in
+  INTEGER,                  INTENT(IN)    :: nbindex
+  REAL, DIMENSION(nbindex), INTENT(INOUT) :: champ
+  REAL,                     INTENT(IN)    :: val_exp
+  INTEGER,                  INTENT(IN)    :: jml2
+  REAL, DIMENSION(iml),     INTENT(IN)    :: lon_in2
+  REAL, DIMENSION(jml2),    INTENT(IN)    :: lat_in2
+  LOGICAL,                  INTENT(IN)    :: ibar
+!-------------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+  REAL, DIMENSION(:,:), POINTER :: v2d
+!-------------------------------------------------------------------------------
+  v2d=>NULL()
+  IF(MINVAL(champ)==MAXVAL(champ).AND.MINVAL(champ)==val_exp) THEN
+
+!--- CHECKING IF THE FIELD IS KNOWN ; READING UNALLOCATED FILES
+    SELECT CASE(varname)
+      CASE('tsol')
+        IF(.NOT.ALLOCATED(tsol))                                               &
+         CALL start_init_phys(iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+      CASE('qsol')
+        IF(.NOT.ALLOCATED(qsol))                                               &
+         CALL start_init_phys(iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+      CASE('psol')
+        IF(.NOT.ALLOCATED(psol_dyn))                                           &
+         CALL start_init_dyn (iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+      CASE('zmea','zstd','zsig','zgam','zthe','zpic','zval')
+        IF(.NOT.ALLOCATED(relief))                                             &
+         CALL start_init_orog(iml,jml,lon_in,lat_in)
+      CASE('rads','snow','tslab','seaice','rugmer','agsno')
+      CASE DEFAULT
+        WRITE(lunout,*)'startget_phys1d'
+        WRITE(lunout,*)'No rule is present to extract variable '//TRIM(varname)&
+                     //' from any data set'; STOP
+    END SELECT
+
+!--- SELECTING v2d FOR WANTED VARIABLE AND CHEKING ITS SIZE
+    SELECT CASE(varname)
+      CASE('rads','snow','tslab','seaice');  champ=0.0
+      CASE('rugmer');                        champ(:)=0.001
+      CASE('agsno');                         champ(:)=50.0
+      CASE DEFAULT
+        SELECT CASE(varname)
+          CASE('tsol'); v2d=>tsol
+          CASE('qsol'); v2d=>qsol
+          CASE('psol'); v2d=>psol_dyn
+          CASE('zmea'); v2d=>relief
+          CASE('zstd'); v2d=>zstd
+          CASE('zsig'); v2d=>zsig
+          CASE('zgam'); v2d=>zgam
+          CASE('zthe'); v2d=>zthe
+          CASE('zpic'); v2d=>zpic
+          CASE('zval'); v2d=>zval
+        END SELECT
+        IF(SIZE(v2d)/=SIZE(lon_in)*SIZE(lat_in)) THEN
+         WRITE(lunout,*)'STARTVAR module has been initialized to the wrong size'
+         STOP
+        END IF
+        CALL gr_dyn_fi(1,iml,jml,nbindex,v2d,champ)
+    END SELECT
+
+  ELSE
+
+!--- SOME FIELDS ARE CAUGHT: MAY BE NEEDED FOR A 3D INTEPROLATION
+    SELECT CASE(varname)
+      CASE('tsol')
+        IF(.NOT.ALLOCATED(tsol)) ALLOCATE(tsol(iml,jml))
+        CALL gr_fi_dyn(1,iml,jml,nbindex,champ,tsol)
+    END SELECT
+
+  END IF
+
+END SUBROUTINE  startget_phys1d
+!
+!-------------------------------------------------------------------------------
+
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE startget_phys2d(varname, iml, jml, lon_in, lat_in, champ, val_exp,  &
+                           jml2, lon_in2, lat_in2 , ibar)
+!
+!-------------------------------------------------------------------------------
+! Comment:
+!   This routine only works if the variable does not exist or is constant.
+!-------------------------------------------------------------------------------
+! Arguments:
+  CHARACTER(LEN=*),         INTENT(IN)           :: varname
+  INTEGER,                  INTENT(IN)           :: iml, jml
+  REAL, DIMENSION(iml),     INTENT(IN)           :: lon_in
+  REAL, DIMENSION(jml),     INTENT(IN)           :: lat_in
+  REAL, DIMENSION(iml,jml), INTENT(INOUT)        :: champ
+  REAL,                     INTENT(IN)           :: val_exp
+  INTEGER,                  INTENT(IN)           :: jml2
+  REAL, DIMENSION(iml),     INTENT(IN)           :: lon_in2
+  REAL, DIMENSION(jml2),    INTENT(IN)           :: lat_in2
+  LOGICAL,                  INTENT(IN)           :: ibar
+!-------------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+  REAL, DIMENSION(:,:), POINTER :: v2d=>NULL()
+!-------------------------------------------------------------------------------
+  v2d=>NULL()
+  IF(MINVAL(champ)==MAXVAL(champ).AND.MINVAL(champ)==val_exp) THEN
+
+!--- CHECKING IF THE FIELD IS KNOWN ; READING UNALLOCATED FILES
+    SELECT CASE(varname)
+      CASE('psol')
+        IF(.NOT.ALLOCATED(psol_dyn))                                           &
+          CALL start_init_dyn (iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+      CASE('relief')
+        IF(.NOT.ALLOCATED(relief)) CALL start_init_orog(iml,jml,lon_in,lat_in)
+      CASE('surfgeo')
+        IF(.NOT.ALLOCATED(phis)) CALL start_init_orog(iml,jml,lon_in,lat_in)
+      CASE('rugosite')
+        IF(.NOT.ALLOCATED(rugo)) CALL start_init_orog(iml,jml,lon_in,lat_in)
+      CASE DEFAULT
+        WRITE(lunout,*)'startget_phys2d'
+        WRITE(lunout,*)'No rule is present to extract variable '//TRIM(varname)&
+                     //' from any data set'; STOP
+    END SELECT
+
+!--- SELECTING v2d FOR WANTED VARIABLE AND CHEKING ITS SIZE
+    SELECT CASE(varname)
+      CASE('psol');     v2d=>psol_dyn
+      CASE('relief');   v2d=>relief
+      CASE('rugosite'); v2d=>rugo
+      CASE('surfgeo');  v2d=>phis
+    END SELECT
+    IF(SIZE(champ)/=SIZE(v2d)) THEN
+      WRITE(lunout,*) 'STARTVAR module has been initialized to the wrong size'
+      STOP
+    END IF
+
+    champ(:,:)=v2d(:,:)
+
+  ELSE
+
+!--- SOME FIELDS ARE CAUGHT: MAY BE NEEDED FOR A 3D INTEPROLATION
+    SELECT CASE(varname)
+      CASE ('surfgeo')
+        IF(.NOT.ALLOCATED(phis)) ALLOCATE(phis(iml,jml))
+        IF(SIZE(phis)/=SIZE(champ)) THEN
+         WRITE(lunout,*)'STARTVAR module has been initialized to the wrong size'
+         STOP
+        END IF
+        phis(:,:)=champ(:,:)
+    END SELECT
+
+  END IF
+
+END SUBROUTINE startget_phys2d
+!
+!-------------------------------------------------------------------------------
+
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE startget_dyn(varname,  lon_in,  lat_in, pls,workvar,&
+                     champ, val_exp, lon_in2, lat_in2, ibar)
+
+      use assert_eq_m, only: assert_eq
+      USE comconst_mod
+
+!-------------------------------------------------------------------------------
+! Comment:
+!   This routine only works if the variable does not exist or is constant.
+!-------------------------------------------------------------------------------
+! Arguments:
+  CHARACTER(LEN=*), INTENT(IN)    :: varname
+  REAL, INTENT(IN)    :: lon_in(:) ! dim(iml)
+  REAL, INTENT(IN)    :: lat_in(:) ! dim(jml)
+  REAL, INTENT(IN)    :: pls(:, :, :) ! dim(iml, jml, lml)
+  REAL, INTENT(IN)    :: workvar(:, :, :) ! dim(iml, jml, lml)
+  REAL, INTENT(INOUT) :: champ(:, :, :) ! dim(iml, jml, lml)
+  REAL, INTENT(IN)    :: val_exp
+  REAL, INTENT(IN)    :: lon_in2(:) ! dim(iml)
+  REAL, INTENT(IN)    :: lat_in2(:) ! dim(jml2)
+  LOGICAL,                      INTENT(IN)    :: ibar
+!-------------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom2.h"
+  INTEGER    :: iml, jml
+  INTEGER    :: lml
+  INTEGER    :: jml2
+  REAL, DIMENSION(:,:,:), POINTER :: v3d=>NULL()
+  CHARACTER(LEN=10) :: vname
+  INTEGER :: il
+  REAL    :: xppn, xpps
+!-------------------------------------------------------------------------------
+  NULLIFY(v3d)
+  IF(MINVAL(champ)==MAXVAL(champ).AND.MINVAL(champ)==val_exp) THEN
+
+      iml = assert_eq((/size(lon_in), size(pls, 1), size(workvar, 1), &
+     &     size(champ, 1), size(lon_in2)/), "startget_dyn iml")
+      jml = assert_eq(size(lat_in), size(pls, 2), size(workvar, 2),   &
+     &     size(champ, 2), "startget_dyn jml")
+      lml = assert_eq(size(pls, 3), size(workvar, 3), size(champ, 3), &
+     &     "startget_dyn lml")
+      jml2 = size(lat_in2)
+
+!--- READING UNALLOCATED FILES
+    IF(.NOT.ALLOCATED(psol_dyn))                                               &
+      CALL start_init_dyn(iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+
+!--- CHECKING IF THE FIELD IS KNOWN AND INTERPOLATING 3D FIELDS
+    SELECT CASE(varname)
+      CASE('u');        vname='U'
+      CASE('v');        vname='V'
+      CASE('t','tpot'); vname='TEMP'
+      CASE('q');        vname='R'
+      CASE DEFAULT
+        WRITE(lunout,*)'startget_dyn'
+        WRITE(lunout,*)'No rule is present to extract variable '//TRIM(varname)&
+                //' from any data set'; STOP
+    END SELECT
+    CALL start_inter_3d(TRIM(vname), iml, jml, lml, lon_in, lat_in, jml2,      &
+                        lon_in2, lat_in2,  pls, champ,ibar )
+
+!--- COMPUTING THE REQUIRED FILED
+    SELECT CASE(varname)
+      CASE('u')                                            !--- Eastward wind
+        DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cu(:,1:jml); END DO
+        champ(iml,:,:)=champ(1,:,:)
+
+      CASE('v')                                            !--- Northward wind
+        DO il=1,lml; champ(:,:,il)=champ(:,:,il)*cv(:,1:jml); END DO
+        champ(iml,:,:)=champ(1,:,:)
+
+      CASE('tpot')                                         !--- Temperature
+        IF(MINVAL(workvar)/=MAXVAL(workvar)) THEN
+          champ=champ*cpp/workvar
+          DO il=1,lml
+            xppn = SUM(aire(:,1  )*champ(:,1  ,il))/apoln
+            xpps = SUM(aire(:,jml)*champ(:,jml,il))/apols
+            champ(:,1  ,il) = xppn
+            champ(:,jml,il) = xpps
+          END DO
+        ELSE
+          WRITE(lunout,*)'Could not compute potential temperature as the'
+          WRITE(lunout,*)'Exner function is missing or constant.'; STOP
+        END IF
+
+      CASE('q')                                            !--- Relat. humidity
+        IF(MINVAL(workvar)/=MAXVAL(workvar)) THEN
+          champ=0.01*champ*workvar
+          WHERE(champ<0.) champ=1.0E-10
+          DO il=1,lml
+            xppn = SUM(aire(:,1  )*champ(:,1  ,il))/apoln
+            xpps = SUM(aire(:,jml)*champ(:,jml,il))/apols
+            champ(:,1  ,il) = xppn
+            champ(:,jml,il) = xpps
+          END DO
+        ELSE
+          WRITE(lunout,*)'Could not compute specific humidity as the'
+          WRITE(lunout,*)'saturated humidity is missing or constant.'; STOP
+        END IF
+
+    END SELECT
+
+  END IF
+
+END SUBROUTINE startget_dyn
+!
+!-------------------------------------------------------------------------------
+
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE start_init_orog(iml,jml,lon_in,lat_in)
+      USE comconst_mod
+      USE grid_atob_m, ONLY: rugsoro
+
+!-------------------------------------------------------------------------------
+! Arguments:
+  INTEGER,                  INTENT(IN)           :: iml, jml
+  REAL, DIMENSION(iml),     INTENT(IN)           :: lon_in
+  REAL, DIMENSION(jml),     INTENT(IN)           :: lat_in
+!-------------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+  CHARACTER(LEN=25)     :: title
+  CHARACTER(LEN=120)    :: orofname
+  LOGICAL               :: check=.TRUE.
+  REAL,    DIMENSION(1) :: lev
+  REAL                  :: date, dt
+  INTEGER, DIMENSION(1) :: itau
+  INTEGER               :: fid, llm_tmp, ttm_tmp
+  REAL,    DIMENSION(:,:), ALLOCATABLE :: relief_hi, tmp_var
+  REAL,    DIMENSION(:),   ALLOCATABLE :: lon_rad, lat_rad, lon_ini, lat_ini
+!-------------------------------------------------------------------------------
+  pi=2.0*ASIN(1.0); deg2rad=pi/180.0
+
+  orofname = 'Relief.nc'; title='RELIEF'
+  IF(check) WRITE(lunout,*)'Reading the high resolution orography'
+  CALL flininfo(orofname, iml_rel, jml_rel, llm_tmp, ttm_tmp, fid)
+
+  ALLOCATE(lat_rel(iml_rel,jml_rel),lon_rel(iml_rel,jml_rel))
+  CALL flinopen(orofname, .FALSE., iml_rel, jml_rel, llm_tmp, lon_rel, lat_rel,&
+                lev, ttm_tmp, itau, date, dt, fid)
+  ALLOCATE(relief_hi(iml_rel,jml_rel))
+  CALL flinget(fid, title, iml_rel, jml_rel, llm_tmp, ttm_tmp, 1, 1, relief_hi)
+  CALL flinclo(fid)
+
+!--- IF ANGLES ARE IN DEGREES, THEY ARE CONVERTED INTO RADIANS
+  ALLOCATE(lon_ini(iml_rel),lat_ini(jml_rel))
+  lon_ini(:)=lon_rel(:,1); IF(MAXVAL(lon_rel)>pi) lon_ini=lon_ini*deg2rad
+  lat_ini(:)=lat_rel(1,:); IF(MAXVAL(lat_rel)>pi) lat_ini=lat_ini*deg2rad
+
+!--- FIELDS ARE PROCESSED TO BE ON STANDARD ANGULAR DOMAINS
+  ALLOCATE(lon_rad(iml_rel),lat_rad(jml_rel))
+  CALL conf_dat2d(title, iml_rel, jml_rel, lon_ini, lat_ini, lon_rad, lat_rad, &
+                  relief_hi, .FALSE.)
+  DEALLOCATE(lon_ini,lat_ini)
+
+!--- COMPUTING THE REQUIRED FIELDS USING ROUTINE grid_noro
+  IF(check) WRITE(lunout,*)'Computes all parameters needed for gravity wave dra&
+     &g code'
+
+  ALLOCATE(phis(iml,jml))      ! Geopotentiel au sol
+  ALLOCATE(zstd(iml,jml))      ! Deviation standard de l'orographie sous-maille
+  ALLOCATE(zsig(iml,jml))      ! Pente de l'orographie sous-maille 
+  ALLOCATE(zgam(iml,jml))      ! Anisotropie de l'orographie sous maille
+  ALLOCATE(zthe(iml,jml))      ! Orientation axe +grande pente d'oro sous maille
+  ALLOCATE(zpic(iml,jml))      ! Hauteur pics de la SSO
+  ALLOCATE(zval(iml,jml))      ! Hauteur vallees de la SSO
+  ALLOCATE(relief(iml,jml))    ! Orographie moyenne
+
+  CALL grid_noro(iml_rel, jml_rel, lon_rad, lat_rad, relief_hi, iml-1, jml,    &
+       lon_in, lat_in, phis, relief, zstd, zsig, zgam, zthe, zpic, zval)
+  phis = phis * g
+
+!--- SURFACE ROUGHNESS COMPUTATION (UNUSED FOR THE MOMENT !!! )
+  IF(check) WRITE(lunout,*)'Compute surface roughness induced by the orography'
+  ALLOCATE(rugo   (iml  ,jml))
+  ALLOCATE(tmp_var(iml-1,jml))
+  CALL rugsoro(lon_rad, lat_rad, relief_hi,      &
+       lon_in, lat_in, tmp_var)
+  rugo(1:iml-1,:)=tmp_var; rugo(iml,:)=tmp_var(1,:)
+  DEALLOCATE(relief_hi,tmp_var,lon_rad,lat_rad)
+  RETURN
+
+END SUBROUTINE start_init_orog
+!
+!-------------------------------------------------------------------------------
+
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE start_init_phys(iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+!
+!-------------------------------------------------------------------------------
+! Arguments:
+  INTEGER,               INTENT(IN) :: iml, jml
+  REAL, DIMENSION(iml),  INTENT(IN) :: lon_in
+  REAL, DIMENSION(jml),  INTENT(IN) :: lat_in
+  INTEGER,               INTENT(IN) :: jml2
+  REAL, DIMENSION(iml),  INTENT(IN) :: lon_in2
+  REAL, DIMENSION(jml2), INTENT(IN) :: lat_in2
+  LOGICAL,               INTENT(IN) :: ibar
+!-------------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+  CHARACTER(LEN=25)     :: title
+  CHARACTER(LEN=120)    :: physfname
+  LOGICAL               :: check=.TRUE.
+  REAL                  :: date, dt
+  INTEGER, DIMENSION(1) :: itau
+  INTEGER               :: llm_tmp, ttm_tmp
+  REAL,    DIMENSION(:,:), ALLOCATABLE :: var_ana
+  REAL,    DIMENSION(:),   ALLOCATABLE :: lon_rad, lat_rad, lon_ini, lat_ini
+  REAL,    DIMENSION(:),   ALLOCATABLE :: levphys_ini
+!-------------------------------------------------------------------------------
+  physfname = 'ECPHY.nc'; pi=2.0*ASIN(1.0); deg2rad=pi/180.0
+  IF(check) WRITE(lunout,*)'Opening the surface analysis'
+  CALL flininfo(physfname, iml_phys, jml_phys, llm_tmp, ttm_tmp, fid_phys)
+
+  ALLOCATE(lat_phys(iml_phys,jml_phys))
+  ALLOCATE(lon_phys(iml_phys,jml_phys))
+  ALLOCATE(levphys_ini(llm_tmp))
+  CALL flinopen(physfname, .FALSE., iml_phys, jml_phys, llm_tmp, lon_phys,     &
+                lat_phys, levphys_ini, ttm_tmp, itau, date, dt, fid_phys)
+  DEALLOCATE(levphys_ini)
+
+!--- IF ANGLES ARE IN DEGREES, THEY ARE CONVERTED INTO RADIANS
+  ALLOCATE(lon_ini(iml_phys),lat_ini(jml_phys))
+  lon_ini(:)=lon_phys(:,1); IF(MAXVAL(lon_phys)>pi) lon_ini=lon_ini*deg2rad
+  lat_ini(:)=lat_phys(1,:); IF(MAXVAL(lat_phys)>pi) lat_ini=lat_ini*deg2rad
+
+  ALLOCATE(var_ana(iml_phys,jml_phys),lon_rad(iml_phys),lat_rad(jml_phys))
+
+!--- SURFACE TEMPERATURE
+  title='ST'
+  ALLOCATE(tsol(iml,jml))
+  CALL flinget(fid_phys,title,iml_phys,jml_phys,llm_tmp,ttm_tmp,1,1,var_ana)
+  CALL conf_dat2d(title,iml_phys, jml_phys, lon_ini, lat_ini, lon_rad, lat_rad,&
+                  var_ana , ibar  )
+  CALL interp_startvar(title, ibar, .TRUE.,                                    &
+      iml_phys, jml_phys, lon_rad, lat_rad, var_ana, iml, jml, jml-1,          &
+      lon_in,   lat_in,   lon_in2, lat_in2, tsol)
+
+!--- SOIL MOISTURE
+  title='CDSW'
+  ALLOCATE(qsol(iml,jml))
+  CALL flinget(fid_phys,title,iml_phys,jml_phys,llm_tmp,ttm_tmp,1,1,var_ana)
+  CALL conf_dat2d(title,iml_phys, jml_phys, lon_ini, lat_ini, lon_rad, lat_rad,&
+                  var_ana, ibar  )
+  CALL interp_startvar(title, ibar, .TRUE.,                                    &
+      iml_phys, jml_phys, lon_rad, lat_rad, var_ana, iml, jml, jml-1,          &
+      lon_in,   lat_in,   lon_in2, lat_in2, qsol)
+
+  CALL flinclo(fid_phys)
+
+  DEALLOCATE(var_ana,lon_rad,lat_rad,lon_ini,lat_ini)
+
+END SUBROUTINE start_init_phys
+!
+!-------------------------------------------------------------------------------
+
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE start_init_dyn(iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+!
+!-------------------------------------------------------------------------------
+! Arguments:
+  INTEGER,               INTENT(IN) :: iml, jml
+  REAL, DIMENSION(iml),  INTENT(IN) :: lon_in
+  REAL, DIMENSION(jml),  INTENT(IN) :: lat_in
+  INTEGER,               INTENT(IN) :: jml2
+  REAL, DIMENSION(iml),  INTENT(IN) :: lon_in2
+  REAL, DIMENSION(jml2), INTENT(IN) :: lat_in2
+  LOGICAL,               INTENT(IN) :: ibar
+!-------------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom2.h"
+  CHARACTER(LEN=25)     :: title
+  CHARACTER(LEN=120)    :: physfname
+  LOGICAL               :: check=.TRUE.
+  REAL                  :: date, dt
+  INTEGER, DIMENSION(1) :: itau
+  INTEGER               :: i, j
+  REAL,    DIMENSION(:,:), ALLOCATABLE :: var_ana, z
+  REAL,    DIMENSION(:),   ALLOCATABLE :: lon_rad, lat_rad, lon_ini, lat_ini
+  REAL,    DIMENSION(:),   ALLOCATABLE :: xppn, xpps
+!-------------------------------------------------------------------------------
+
+!--- KINETIC ENERGY
+  physfname = 'ECDYN.nc'; pi=2.0*ASIN(1.0); deg2rad=pi/180.0
+  IF(check) WRITE(lunout,*) 'Opening the surface analysis'
+  CALL flininfo(physfname, iml_dyn, jml_dyn, llm_dyn, ttm_dyn, fid_dyn)
+  IF(check) WRITE(lunout,*) 'Values read: ', iml_dyn, jml_dyn, llm_dyn, ttm_dyn
+
+  ALLOCATE(lat_dyn(iml_dyn,jml_dyn))
+  ALLOCATE(lon_dyn(iml_dyn,jml_dyn))
+  ALLOCATE(levdyn_ini(llm_dyn))
+  CALL flinopen(physfname, .FALSE., iml_dyn, jml_dyn, llm_dyn, lon_dyn,lat_dyn,&
+                levdyn_ini, ttm_dyn, itau, date, dt, fid_dyn)
+
+!--- IF ANGLES ARE IN DEGREES, THEY ARE CONVERTED INTO RADIANS
+  ALLOCATE(lon_ini(iml_dyn),lat_ini(jml_dyn))
+  lon_ini(:)=lon_dyn(:,1); IF(MAXVAL(lon_dyn)>pi) lon_ini=lon_ini*deg2rad
+  lat_ini(:)=lat_dyn(1,:); IF(MAXVAL(lat_dyn)>pi) lat_ini=lat_ini*deg2rad
+
+  ALLOCATE(var_ana(iml_dyn,jml_dyn),lon_rad(iml_dyn),lat_rad(jml_dyn))
+
+!--- SURFACE GEOPOTENTIAL
+  title='Z'
+  ALLOCATE(z(iml,jml))
+  CALL flinget(fid_dyn, title, iml_dyn, jml_dyn, 0, ttm_dyn, 1, 1, var_ana)
+  CALL conf_dat2d(title, iml_dyn, jml_dyn, lon_ini, lat_ini, lon_rad, lat_rad, &
+                  var_ana, ibar)
+  CALL interp_startvar(title, ibar, .TRUE.,                                    &
+      iml_dyn, jml_dyn, lon_rad, lat_rad, var_ana, iml, jml, jml-1,            &
+      lon_in,  lat_in,  lon_in2, lat_in2, z)
+
+!--- SURFACE PRESSURE
+  title='SP'
+  ALLOCATE(psol_dyn(iml,jml))
+  CALL flinget(fid_dyn, title, iml_dyn, jml_dyn, 0, ttm_dyn, 1, 1, var_ana)
+  CALL conf_dat2d(title, iml_dyn, jml_dyn, lon_ini, lat_ini, lon_rad, lat_rad, &
+                  var_ana, ibar)
+  CALL interp_startvar(title, ibar, .TRUE.,                                    &
+      iml_dyn, jml_dyn, lon_rad, lat_rad, var_ana, iml, jml, jml-1,            &
+      lon_in,  lat_in,  lon_in2, lat_in2, psol_dyn)
+
+  DEALLOCATE(var_ana,lon_rad,lat_rad,lon_ini,lat_ini)
+
+!--- ALLOCATION OF VARIABLES CREATED IN OR COMING FROM RESTART FILE
+  IF(.NOT.ALLOCATED(tsol)) THEN
+    CALL start_init_phys(iml,jml,lon_in,lat_in,jml2,lon_in2,lat_in2,ibar)
+  ELSE
+    IF(SIZE(tsol)/=SIZE(psol_dyn)) THEN
+      WRITE(lunout,*)'start_init_dyn :'
+      WRITE(lunout,*)'The temperature field we have does not have the right size'
+      STOP
+    END IF
+  END IF
+
+  IF(.NOT.ALLOCATED(phis)) THEN
+    CALL start_init_orog(iml,jml,lon_in,lat_in)
+  ELSE
+    IF(SIZE(phis)/=SIZE(psol_dyn)) THEN
+      WRITE(lunout,*)'start_init_dyn :'
+      WRITE(lunout,*)'The orography field we have does not have the right size'
+      STOP
+    END IF
+  END IF
+
+!--- PSOL IS COMPUTED IN PASCALS
+  DO j = 1, jml
+    DO i = 1, iml-1
+      psol_dyn(i,j) = psol_dyn(i,j)*(1.0+(z(i,j)-phis(i,j))/287.0/tsol(i,j))
+    END DO
+    psol_dyn(iml,j) = psol_dyn(1,j)
+  END DO
+  DEALLOCATE(z)
+
+  ALLOCATE(xppn(iml-1),xpps(iml-1)) 
+  DO i = 1, iml-1
+    xppn(i) = aire( i,1) * psol_dyn( i,1)
+    xpps(i) = aire( i,jml) * psol_dyn( i,jml)
+  END DO
+  DO i = 1, iml
+    psol_dyn(i,1  ) = SUM(xppn)/apoln
+    psol_dyn(i,jml) = SUM(xpps)/apols
+  END DO
+  DEALLOCATE(xppn,xpps) 
+
+  RETURN
+
+END SUBROUTINE start_init_dyn
+!
+!-------------------------------------------------------------------------------
+
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE start_inter_3d(varname, iml, jml, lml, lon_in, lat_in, jml2, &
+     lon_in2, lat_in2, pls_in, var3d, ibar)
+
+  use pchsp_95_m, only: pchsp_95
+  use pchfe_95_m, only: pchfe_95
+
+! Arguments:
+  CHARACTER(LEN=*),             INTENT(IN)    :: varname
+  INTEGER,                      INTENT(IN)    :: iml, jml, lml
+  REAL, DIMENSION(iml),         INTENT(IN)    :: lon_in
+  REAL, DIMENSION(jml),         INTENT(IN)    :: lat_in
+  INTEGER,                      INTENT(IN)    :: jml2
+  REAL, DIMENSION(iml),         INTENT(IN)    :: lon_in2
+  REAL, DIMENSION(jml2),        INTENT(IN)    :: lat_in2
+  REAL, DIMENSION(iml, jml, lml), INTENT(IN)    :: pls_in
+  REAL, DIMENSION(iml, jml, lml), INTENT(OUT)   :: var3d
+  LOGICAL,                      INTENT(IN)    :: ibar
+!----------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+  LOGICAL:: check=.TRUE., skip
+  REAL                  chmin, chmax
+  INTEGER ii, ij, il, ierr
+  integer n_extrap ! number of extrapolated points
+  REAL, DIMENSION(iml, jml, llm_dyn):: var_tmp3d
+  REAL,    DIMENSION(:),     ALLOCATABLE :: lon_rad, lat_rad, lon_ini, lat_ini
+  REAL, DIMENSION(llm_dyn):: lev_dyn, ax, ay, yder
+
+!---------------------------------------------------------------------------
+  IF(check) WRITE(lunout, *)'Going into flinget to extract the 3D  field.'
+  IF(check) WRITE(lunout, *) fid_dyn, varname, iml_dyn, jml_dyn, llm_dyn, &
+       ttm_dyn
+  IF(check) WRITE(lunout, *) 'Allocating space for interpolation', iml, jml, &
+       llm_dyn
+
+  IF(.NOT.ALLOCATED(var_ana3d)) ALLOCATE(var_ana3d(iml_dyn, jml_dyn, llm_dyn))
+  CALL flinget(fid_dyn, varname, iml_dyn, jml_dyn, llm_dyn, ttm_dyn, 1, 1, &
+       var_ana3d)
+
+!--- IF ANGLES ARE IN DEGREES, THEY ARE CONVERTED INTO RADIANS
+  ALLOCATE(lon_ini(iml_dyn), lat_ini(jml_dyn))
+  lon_ini(:)=lon_dyn(:, 1); IF(MAXVAL(lon_dyn)>pi) lon_ini=lon_ini*deg2rad
+  lat_ini(:)=lat_dyn(1, :); IF(MAXVAL(lat_dyn)>pi) lat_ini=lat_ini*deg2rad
+
+!--- FIELDS ARE PROCESSED TO BE ON STANDARD ANGULAR DOMAINS
+  ALLOCATE(lon_rad(iml_dyn), lat_rad(jml_dyn))
+  CALL conf_dat3d (varname, iml_dyn, jml_dyn, llm_dyn, lon_ini, lat_ini,      &
+                   levdyn_ini, lon_rad, lat_rad, lev_dyn, var_ana3d, ibar)
+  DEALLOCATE(lon_ini, lat_ini)
+
+!--- COMPUTING THE REQUIRED FIELDS USING ROUTINE grid_noro
+  DO il=1, llm_dyn
+    CALL interp_startvar(varname, ibar, il==1, iml_dyn, jml_dyn, lon_rad, &
+         lat_rad, var_ana3d(:, :, il), iml, jml, jml2, lon_in, lat_in, &
+         lon_in2, lat_in2, var_tmp3d(:, :, il))
+  END DO
+  DEALLOCATE(lon_rad, lat_rad)
+
+!--- VERTICAL INTERPOLATION IS PERFORMED FROM TOP OF ATMOSPHERE TO GROUND
+  ax = lev_dyn(llm_dyn:1:-1) 
+  skip = .false.
+  n_extrap = 0
+  DO ij=1, jml
+    DO ii=1, iml-1
+      ay = var_tmp3d(ii, ij, llm_dyn:1:-1)
+      yder = pchsp_95(ax, ay, ibeg=2, iend=2, vc_beg=0., vc_end=0.)
+      CALL pchfe_95(ax, ay, yder, skip, pls_in(ii, ij, lml:1:-1), &
+           var3d(ii, ij, lml:1:-1), ierr)
+      if (ierr < 0) stop 1
+      n_extrap = n_extrap + ierr
+    END DO
+  END DO
+  if (n_extrap /= 0) then
+     print *, "start_inter_3d pchfe_95: n_extrap = ", n_extrap
+  end if
+  var3d(iml, :, :) = var3d(1, :, :) 
+
+  DO il=1, lml
+    CALL minmax(iml*jml, var3d(1, 1, il), chmin, chmax)
+    WRITE(lunout, *)' '//TRIM(varname)//'  min max l ', il, chmin, chmax
+  END DO
+
+END SUBROUTINE start_inter_3d
+!
+!-------------------------------------------------------------------------------
+
+
+!-------------------------------------------------------------------------------
+!
+SUBROUTINE interp_startvar(vname, ibar, ibeg, ii, jj,    lon,  lat,  vari,     &
+                                 i1, j1, j2, lon1, lat1, lon2, lat2, varo)
+!
+!-------------------------------------------------------------------------------
+
+  USE inter_barxy_m, only: inter_barxy
+  USE grid_atob_m, only: grille_m
+
+! Arguments:
+  CHARACTER(LEN=*),       INTENT(IN)  :: vname
+  LOGICAL,                INTENT(IN)  :: ibar, ibeg
+  INTEGER,                INTENT(IN)  :: ii, jj
+  REAL, DIMENSION(ii),    INTENT(IN)  :: lon
+  REAL, DIMENSION(jj),    INTENT(IN)  :: lat
+  REAL, DIMENSION(ii,jj), INTENT(IN)  :: vari
+  INTEGER,                INTENT(IN)  :: i1, j1, j2
+  REAL, DIMENSION(i1),    INTENT(IN)  :: lon1
+  REAL, DIMENSION(j1),    INTENT(IN)  :: lat1
+  REAL, DIMENSION(i1),    INTENT(IN)  :: lon2
+  REAL, DIMENSION(j2),    INTENT(IN)  :: lat2
+  REAL, DIMENSION(i1,j1), INTENT(OUT) :: varo
+!-------------------------------------------------------------------------------
+! Local variables:
+#include "iniprint.h"
+  REAL, DIMENSION(i1-1,j1) :: vtmp
+!-------------------------------------------------------------------------------
+  IF(ibar) THEN
+    IF(ibeg) THEN
+      WRITE(lunout,*)                                                          &
+               '---------------------------------------------------------------'
+      WRITE(lunout,*)                                                          &
+ '$$$ Utilisation de l interpolation barycentrique  pour  '//TRIM(vname)//' $$$'
+      WRITE(lunout,*)                                                          &
+               '---------------------------------------------------------------'
+    END IF
+    CALL inter_barxy(lon, lat(:jj-1), vari, lon2(:i1-1), lat2(:j2), vtmp)
+  ELSE
+    CALL grille_m   (lon, lat, vari, lon1, lat1, vtmp)
+  END IF
+  CALL gr_int_dyn(vtmp, varo, i1-1, j1)
+
+END SUBROUTINE interp_startvar
+!
+!-------------------------------------------------------------------------------
+
+END MODULE startvar
+!
+!*******************************************************************************
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/wind_scal.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/wind_scal.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/wind_scal.F	(revision 1644)
@@ -0,0 +1,54 @@
+      SUBROUTINE wind_scal(pbaru,pbarv,us,vs)
+c=======================================================================
+c
+c
+c   Subject:
+c   ------
+c   On ramene les flux de masse /vents  aux points scalaires.
+c
+c=======================================================================
+      IMPLICIT NONE
+c-----------------------------------------------------------------------
+c   Declararations:
+c   ---------------
+
+#include "dimensions.h"
+#include "paramet.h"
+
+c   Arguments:
+c   ----------
+
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
+      REAL us(ip1jmp1,llm), vs (ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      INTEGER ij,l
+
+c-----------------------------------------------------------------------
+
+c   transport zonal:
+c   ----------------
+      DO l=1,llm
+	 DO ij=2,ip1jmp1
+            us(ij,l)=.5*(pbaru(ij,l)+pbaru(ij-1,l))
+	 ENDDO
+      ENDDO
+      CALL SCOPY(jjp1*llm,us(iip1,1),iip1,us(1,1),iip1)
+
+
+c   Transport meridien:
+c   -------------------
+      DO l=1,llm
+         DO ij=iip2,ip1jm
+	    vs(ij,l)=.5*(pbarv(ij,l)+pbarv(ij-iip1,l))
+	 ENDDO
+	 DO ij=1,iip1
+	    vs(ij,l)=0.
+	    vs(ip1jm+ij,l)=0.
+	 ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/write_archive.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/write_archive.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/write_archive.F	(revision 1644)
@@ -0,0 +1,198 @@
+c=======================================================================
+      subroutine write_archive(nid,nom,titre,unite,dim,px)
+c=======================================================================
+c
+c
+c   Date:    01/1997
+c   ----
+c
+c   Objet:   Ecriture de champs sur grille scalaire (iip1*jjp1)
+c   -----    dans un fichier DRS nomme "start_archive"
+c
+c    Il faut au prealable avoir cree un entete avec un "call ini_archive".
+c    Ces variables peuvent etre 3d (ex: temperature), 2d (ex: temperature
+c    de surface), ou 0d (pour un scalaire qui ne depend que du temps)
+c    (ex: la longitude solaire)
+c
+c
+c   Arguments: 
+c   ----------
+c
+c     Inputs:
+c     ------
+c
+c		  nid      Unite logique du fichier "start_archive"
+c         nom      nom du champ a ecrire dans le fichier "start_archive"
+c         titre    titre de la variable dans le fichier DRS "start_archive"
+c         unite    unite de la variable ....
+c         dim      dimension de la variable a ecrire
+c         px       tableau contenant la variable a ecrire
+c
+c
+c=======================================================================
+
+      USE control_mod
+      USE comvert_mod, ONLY: ap,bp,presnivs,pa,preff,nivsigs,nivsig,
+     .                       aps,bps,scaleheight,pseudoalt,
+     .                       disvert_type,pressure_exner
+
+      implicit none
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "description.h"
+#include "netcdf.inc"
+
+c-----------------------------------------------------------------------
+c	Declarations   
+c-----------------------------------------------------------------------
+
+c Arguments:
+
+      INTEGER nid,ntime,dim 
+      REAL px(iip1,jjp1,llm) 
+
+      CHARACTER*(*) nom, titre, unite
+
+      integer ierr
+
+
+c local
+      integer, dimension(4) :: edges,corner,id
+      integer :: varid,i,j,l
+
+      ntime = 1
+      
+c-----------------------------------------------------------------------
+c      Ecriture du champs dans le fichier            (3 cas)      
+c-----------------------------------------------------------------------
+
+!Cas Variable 3D
+!---------------
+        if (dim.eq.3) then
+
+!         Ecriture du champs
+
+! nom de la variable
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! choix du nom des coordonnees
+              ierr= NF_INQ_DIMID(nid,"rlonv",id(1))
+              ierr= NF_INQ_DIMID(nid,"rlatu",id(2))
+              ierr= NF_INQ_DIMID(nid,"sigs",id(3))
+              ierr= NF_INQ_DIMID(nid,"Time",id(4))
+
+! Creation de la variable si elle n'existait pas
+
+              write (*,*) "====================="
+              write (*,*) "creation de ",nom
+              call def_var(nid,nom,titre,unite,4,id,varid,ierr)
+
+           endif
+
+           corner(1)=1
+           corner(2)=1
+           corner(3)=1
+           corner(4)=ntime
+
+           edges(1)=iip1
+           edges(2)=jjp1
+           edges(3)=llm
+           edges(4)=1
+#ifdef NC_DOUBLE
+           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,px)
+#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in write_archive"
+              write(*,*) "***** with ",nom," ",nf_STRERROR(ierr)
+              call abort
+           endif
+
+!Cas Variable 2D
+!---------------
+
+        else if (dim.eq.2) then
+
+!         Ecriture du champs
+
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+!  choix du nom des coordonnees
+              ierr= NF_INQ_DIMID(nid,"rlonv",id(1))
+              ierr= NF_INQ_DIMID(nid,"rlatu",id(2))
+              ierr= NF_INQ_DIMID(nid,"Time",id(3))
+
+! Creation de la variable si elle n'existait pas
+
+              write (*,*) "====================="
+              write (*,*) "creation de ",nom
+
+              call def_var(nid,nom,titre,unite,3,id,varid,ierr)
+
+           endif
+
+           corner(1)=1
+           corner(2)=1
+           corner(3)=ntime
+           edges(1)=iip1
+           edges(2)=jjp1
+           edges(3)=1
+
+
+#ifdef NC_DOUBLE
+           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px)
+#else         
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif     
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in write_archive"
+              write(*,*) "***** with ",nom,nf_STRERROR(ierr)
+              call abort
+           endif
+
+
+!Cas Variable 0D (scalaire dependant du temps)
+!---------------------------------------------
+
+        else if (dim.eq.0) then
+
+!         Ecriture du champs
+
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+!  choix du nom des coordonnees
+              ierr= NF_INQ_DIMID(nid,"temps",id(1))
+
+! Creation de la variable si elle n'existait pas
+
+              write (*,*) "====================="
+              write (*,*) "creation de ",nom
+
+              call def_var(nid,nom,titre,unite,1,id,varid,ierr)
+
+           endif
+
+           corner(1)=ntime
+           edges(1)=1
+
+#ifdef NC_DOUBLE
+           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px)
+#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in write_archive"
+              write(*,*) "***** with ",nom,nf_STRERROR(ierr)
+              call abort
+           endif
+
+        endif
+
+      return
+      end
+
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/writerestart.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/writerestart.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/writerestart.F	(revision 1644)
@@ -0,0 +1,494 @@
+      SUBROUTINE writerestart(fichnom,tab_cntrl,
+     .                  phis,vcov,ucov,teta,masse,q,ps)
+
+      USE IOIPSL
+      USE infotrac
+      USE comconst_mod
+      USE comvert_mod, ONLY: ap,bp,presnivs,pa,preff,nivsigs,nivsig,
+     .                       aps,bps,scaleheight,pseudoalt,
+     .                       disvert_type,pressure_exner
+
+      IMPLICIT NONE
+
+c=======================================================================
+c Ecriture du fichier de redemarrage sous format NetCDF (pour newstart)
+c=======================================================================
+c   Declarations:
+c   -------------
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "netcdf.inc"
+#include "description.h"
+
+c   Arguments:
+c   ----------
+      CHARACTER*(*) fichnom
+      INTEGER length
+      PARAMETER (length = 100)
+      REAL tab_cntrl(length) ! tableau des parametres du run
+      REAL phis(ip1jmp1)
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) 
+      REAL teta(ip1jmp1,llm),q(ip1jmp1,llm,nqtot) 
+      REAL ps(ip1jmp1),masse(ip1jmp1,llm)                   
+
+c   Local:
+c   ------
+      INTEGER iq,l
+      INTEGER ierr
+      character*20 modname
+      character*80 abort_message
+
+c   Variables locales pour NetCDF:
+c
+      INTEGER dims2(2), dims3(3), dims4(4)
+      INTEGER idim_index
+      INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv
+      INTEGER idim_s, idim_sig
+      INTEGER idim_tim
+      INTEGER nid,nvarid
+
+      character*30 unites
+
+
+c-----------------------------------------------------------------------
+c Creation du fichier:
+c-----------------------------------------------------------------------
+c
+      modname='write_restart_ini'
+
+      ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
+      IF (ierr.NE.NF_NOERR) THEN
+         WRITE(6,*)" Pb d ouverture du fichier "//fichnom
+         WRITE(6,*)' ierr = ', ierr
+         CALL ABORT
+      ENDIF
+c
+c Preciser quelques attributs globaux:
+c
+      ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 27,
+     .                       "Fichier demarrage dynamique")
+c
+c Definir les dimensions du fichiers:
+c
+      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
+      ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
+      ierr = NF_DEF_DIM (nid, "rlatu", jjp1, idim_rlatu)
+      ierr = NF_DEF_DIM (nid, "rlonv", iip1, idim_rlonv)
+      ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv)
+      ierr = NF_DEF_DIM (nid, "sigs", llm, idim_s)
+      ierr = NF_DEF_DIM (nid, "sig", llmp1, idim_sig)
+      ierr = NF_DEF_DIM (nid, "temps", NF_UNLIMITED, idim_tim)
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+c
+c Definir et enregistrer certains champs invariants:
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"controle",NF_DOUBLE,1,idim_index,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"controle",NF_FLOAT,1,idim_index,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Parametres de controle")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"nivsigs",NF_DOUBLE,1,idim_s,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"nivsigs",NF_FLOAT,1,idim_s,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 28,
+     .                       "Numero naturel des couches s")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsigs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsigs)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"nivsig",NF_DOUBLE,1,idim_sig,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"nivsig",NF_FLOAT,1,idim_sig,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 32,
+     .                       "Numero naturel des couches sigma")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsig)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsig)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_sig,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_sig,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26,
+     .                       "Coefficient A pour hybride")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_sig,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_sig,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 26,
+     .                       "Coefficient B pour hybride")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bp)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_s,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_s,nvarid)
+#endif
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,presnivs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,presnivs)
+#endif
+c
+c Coefficients de passage cov. <-> contra. <--> naturel
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonu
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cu",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cu",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatv
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cv",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cv",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
+#endif
+c
+c Aire de chaque maille:
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"aire",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"aire",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Aires de chaque maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
+#endif
+c
+c Geopentiel au sol:
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
+     .                       "Geopotentiel au sol")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,phis)
+#endif
+c
+c Definir les variables pour pouvoir les enregistrer plus tard:
+c
+      ierr = NF_REDEF (nid) ! entrer dans le mode de definition
+c
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"temps",NF_DOUBLE,1,idim_tim,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"temps",NF_FLOAT,1,idim_tim,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
+     .                       "Temps de simulation")
+      write(unites,200) 1990,1,1
+200   format('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "units", 30,
+     .                         unites)
+
+c
+      dims4(1) = idim_rlonu
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ucov",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ucov",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
+     .                       "Vitesse U")
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatv
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"vcov",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"vcov",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
+     .                       "Vitesse V")
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"teta",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"teta",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 11,
+     .                       "Temperature")
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+      DO iq=1,nqtot
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,tname(iq),NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,tname(iq),NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12,ttext(iq))
+      ENDDO
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"masse",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"masse",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12,
+     .                       "C est quoi ?")
+c
+      dims3(1) = idim_rlonv
+      dims3(2) = idim_rlatu
+      dims3(3) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ps",NF_DOUBLE,3,dims3,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ps",NF_FLOAT,3,dims3,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 15,
+     .                       "Pression au sol")
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+
+c-----------------------------------------------------------------------
+c Ecriture des variables:
+c-----------------------------------------------------------------------
+c
+      modname='write_restart'
+
+      ierr = NF_INQ_VARID(nid, "temps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         print *, NF_STRERROR(ierr)
+         abort_message='Variable temps n est pas definie'
+         CALL abort_gcm(modname,abort_message,ierr)
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR1_DOUBLE (nid,nvarid,1,0.)
+#else
+      ierr = NF_PUT_VAR1_REAL (nid,nvarid,1,0.)
+#endif
+
+      ierr = NF_INQ_VARID(nid, "ucov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable ucov n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ucov)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ucov)
+#endif
+
+      ierr = NF_INQ_VARID(nid, "vcov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable vcov n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,vcov)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,vcov)
+#endif
+
+      ierr = NF_INQ_VARID(nid, "teta", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable teta n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,teta)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,teta)
+#endif
+
+       do iq=1,nqtot   
+        ierr = NF_INQ_VARID(nid, tname(iq), nvarid)
+        IF (ierr .NE. NF_NOERR) THEN
+           PRINT*, "Variable  tname(iq) n est pas definie"
+           CALL abort
+        ENDIF
+#ifdef NC_DOUBLE
+          ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q(1,1,iq))
+#else
+          ierr = NF_PUT_VAR_REAL (nid,nvarid,q(1,1,iq))
+#endif
+      ENDDO
+c
+      ierr = NF_INQ_VARID(nid, "masse", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable masse n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,masse)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,masse)
+#endif
+c
+      ierr = NF_INQ_VARID(nid, "ps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable ps n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ps)
+#endif
+
+      ierr = NF_CLOSE(nid) ! fermer le fichier
+
+c      PRINT*,'iim,jjm,llm,iday_end',iim,jjm,llm,iday_end
+c      PRINT*,'rad,omeg,g,cpp,kappa',
+c     ,        rad,omeg,g,cpp,kappa
+
+      RETURN
+      END
+
Index: /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/writerestartphy.F
===================================================================
--- /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/writerestartphy.F	(revision 1644)
+++ /trunk/LMDZ.COMMON/libf/dynphy_lonlat/phytitan.old/writerestartphy.F	(revision 1644)
@@ -0,0 +1,343 @@
+      SUBROUTINE writerestartphy(fichnom,tab_cntrl,klon,klev,
+     .           rlat,rlon, tsol,tsoil,
+     .           albedo, 
+     .           solsw, sollw,fder,
+     .           radsol,
+     .    zmea, zstd, zsig, zgam, zthe, zpic, zval,
+     .           t_ancien)
+
+
+c======================================================================
+c Ecriture de l'etat de redemarrage pour la physique (pour newstart)
+c======================================================================
+      IMPLICIT none
+#include "dimensions.h"
+#include "netcdf.inc"
+#include "dimsoil.h"
+c======================================================================
+      CHARACTER*13 fichnom
+      INTEGER length,klon,klev
+      PARAMETER (length=100)
+      REAL tab_cntrl(length)
+      REAL rlat(klon), rlon(klon)
+      REAL tsol(klon)
+      REAL tsoil(klon,nsoilmx)
+      REAL albedo(klon)
+      real solsw(klon)
+      real sollw(klon)
+      real fder(klon)
+      REAL radsol(klon)
+      REAL zmea(klon), zstd(klon)
+      REAL zsig(klon), zgam(klon), zthe(klon)
+      REAL zpic(klon), zval(klon)
+      REAL t_ancien(klon,klev)
+c
+      INTEGER nid, nvarid, idim1, idim2, idim3
+      INTEGER ierr
+c
+      INTEGER isoil
+      CHARACTER*2 str2
+c
+c-----------------------------------------------------------------------
+c Creation du fichier:
+c-----------------------------------------------------------------------
+c
+c     print*,'fichnom',fichnom
+      ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
+      IF (ierr.NE.NF_NOERR) THEN
+        write(6,*)' Pb d''ouverture du fichier '//fichnom
+        write(6,*)' ierr = ', ierr
+        CALL ABORT
+      ENDIF
+c
+      ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 28,
+     .                       "Fichier redemarrage physique")
+c
+      ierr = NF_DEF_DIM (nid, "index", length, idim1)
+      ierr = NF_DEF_DIM (nid, "points_physiques", klon, idim2)
+      ierr = NF_DEF_DIM (nid, "horizon_vertical", klon*klev, idim3)
+c
+
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, idim1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, idim1,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 22,
+     .                        "Parametres de controle")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "longitude", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "longitude", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 32,
+     .                        "Longitudes de la grille physique")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlon)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlon)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "latitude", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 31,
+     .                        "Latitudes de la grille physique")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlat)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlat)
+#endif
+c
+c-----------------------------------------------------------------------
+c Ecriture des variables:
+c-----------------------------------------------------------------------
+c
+        ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+        ierr = NF_DEF_VAR (nid, "TS", NF_DOUBLE, 1, idim2,nvarid)
+#else
+        ierr = NF_DEF_VAR (nid, "TS", NF_FLOAT, 1, idim2,nvarid)
+#endif
+        ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 22,
+     .                        "Temperature de surface")
+        ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+        ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsol)
+#else
+        ierr = NF_PUT_VAR_REAL (nid,nvarid,tsol)
+#endif
+c
+      DO isoil=1, nsoilmx
+        IF (isoil.LE.99) THEN
+        WRITE(str2,'(i2.2)') isoil
+        ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+        ierr = NF_DEF_VAR (nid, "Tsoil"//str2,NF_DOUBLE,1,idim2,nvarid)
+#else
+        ierr = NF_DEF_VAR (nid, "Tsoil"//str2,NF_FLOAT,1,idim2,nvarid)
+#endif
+        ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 24,
+     .                        "Temperature du sol No."//str2)
+        ierr = NF_ENDDEF(nid)
+        ELSE
+        PRINT*, "Trop de couches"
+        CALL abort
+        ENDIF
+#ifdef NC_DOUBLE
+        ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tsoil(1,isoil))
+#else
+        ierr = NF_PUT_VAR_REAL (nid,nvarid,tsoil(1,isoil))
+#endif
+      ENDDO
+c
+        ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+        ierr = NF_DEF_VAR (nid,"ALBE",NF_DOUBLE,1,idim2,nvarid)
+#else
+        ierr = NF_DEF_VAR (nid,"ALBE",NF_FLOAT,1,idim2,nvarid)
+#endif
+        ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
+     .                        "albedo de surface")
+        ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,albedo)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,albedo)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "solsw", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "solsw", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 32,
+     .                        "Rayonnement solaire a la surface")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,solsw)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,solsw)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "sollw", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "sollw", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 27,
+     .                        "Rayonnement IF a la surface")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,sollw)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,sollw)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "fder", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "fder", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 14,
+     .                        "Derive de flux")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,fder)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,fder)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "RADS", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "RADS", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "Rayonnement net a la surface")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,radsol)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,radsol)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "ZMEA", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "ZMEA", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "zmea Orographie sous-maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zmea)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,zmea)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "ZSTD", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "ZSTD", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "zstd Orographie sous-maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zstd)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,zstd)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "ZSIG", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "ZSIG", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "zsig Orographie sous-maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zsig)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,zsig)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "ZGAM", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "ZGAM", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "zgam Orographie sous-maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zgam)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,zgam)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "ZTHE", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "ZTHE", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "zthe Orographie sous-maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zthe)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,zthe)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "ZPIC", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "ZPIC", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "zpic Orographie sous-maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zpic)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,zpic)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "ZVAL", NF_DOUBLE, 1, idim2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "ZVAL", NF_FLOAT, 1, idim2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 28,
+     .                        "zval Orographie sous-maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,zval)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,zval)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "TANCIEN", NF_DOUBLE, 1, idim3,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "TANCIEN", NF_FLOAT, 1, idim3,nvarid)
+#endif
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,t_ancien)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,t_ancien)
+#endif
+c
+      ierr = NF_CLOSE(nid)
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/DOC/Fig/grid.fig
===================================================================
--- /trunk/LMDZ.TITAN/DOC/Fig/grid.fig	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/Fig/grid.fig	(revision 1644)
@@ -0,0 +1,588 @@
+#FIG 2.1
+80 2
+6 134 449 369 674
+1 4 0 1 0 0 0 11 0.00000 1 0.000 359 459 5 5 354 454 364 464
+1 4 0 1 0 0 0 11 0.00000 1 0.000 159 459 5 5 154 454 164 464
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 459 5 5 254 454 264 464
+1 4 0 1 0 0 0 11 0.00000 1 0.000 359 659 5 5 354 654 364 664
+1 4 0 1 0 0 0 11 0.00000 1 0.000 359 559 5 5 354 554 364 564
+1 4 0 1 0 0 0 11 0.00000 1 0.000 159 659 5 5 154 654 164 664
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 659 5 5 254 654 264 664
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 559 5 5 254 554 264 564
+1 4 0 1 0 0 0 11 0.00000 1 0.000 159 559 5 5 154 554 164 564
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 179 459 239 459 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 204 454 204 464 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 279 459 339 459 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 304 454 304 464 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 359 579 359 639 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 354 609 364 609 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 359 479 359 539 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 354 509 364 509 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 179 659 239 659 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 204 654 204 664 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 159 579 159 639 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 154 609 164 609 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 279 659 339 659 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 304 654 304 664 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 254 609 264 609 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 259 479 259 539 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 254 509 264 509 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 159 479 159 539 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 154 509 164 509 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 259 579 259 639 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 279 559 339 559 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 304 554 304 564 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 179 559 239 559 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 204 554 204 564 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 369 469 369 449 349 449 349 469 369 469 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 169 469 169 449 149 449 149 469 169 469 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 169 569 169 549 149 549 149 569 169 569 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 269 569 269 549 249 549 249 569 269 569 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 269 469 269 449 249 449 249 469 269 469 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 369 569 369 549 349 549 349 569 369 569 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 169 669 169 649 149 649 149 669 169 669 9999 9999
+4 0 0 20 0 0 0 0.00000 4 16 6 344 609 v
+4 0 0 20 0 0 0 0.00000 4 16 6 344 509 v
+4 0 0 20 0 0 0 0.00000 4 16 6 144 609 v
+4 0 0 20 0 0 0 0.00000 4 16 6 244 609 v
+4 0 0 20 0 0 0 0.00000 4 16 6 244 509 v
+4 0 0 20 0 0 0 0.00000 4 16 6 144 509 v
+4 0 0 20 0 -1 0 0.00000 4 18 14 334 549 16
+4 0 0 20 0 -1 0 0.00000 4 18 14 234 549 15
+4 0 0 20 0 -1 0 0.00000 4 18 14 134 549 14
+4 0 0 20 0 0 0 0.00000 4 16 6 204 474 u
+4 0 0 20 0 0 0 0.00000 4 16 6 204 574 u
+4 0 0 20 0 0 0 0.00000 4 16 6 304 474 u
+4 0 0 20 0 0 0 0.00000 4 16 6 304 574 u
+4 0 0 20 0 0 0 0.00000 4 16 6 204 674 u
+4 0 0 20 0 0 0 0.00000 4 16 6 304 674 u
+4 0 0 20 0 -1 0 0.00000 4 18 14 139 649 20
+-6
+6 579 84 774 129
+1 4 0 1 0 0 0 11 0.00000 1 0.000 619 109 5 5 614 104 624 114
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 629 119 629 99 609 99 609 119 629 119 9999 9999
+2 1 0 1 -1 100 0 2 0.000 -1 0 0
+	 579 84 649 84 649 129 579 129 9999 9999
+4 0 0 20 0 -1 0 0.00000 4 18 84 689 109 grille physique
+-6
+6 739 714 824 819
+2 1 0 2 -1 100 0 6 0.000 -1 0 1
+	0 0 2.000 8.000 16.000
+	 759 719 759 759 9999 9999
+2 1 0 2 -1 100 0 6 0.000 -1 0 1
+	0 0 2.000 8.000 16.000
+	 804 719 804 799 9999 9999
+4 1 0 20 0 0 0 0.00000 4 18 33 759 779 rlonv
+4 1 0 20 0 0 0 0.00000 4 18 33 804 819 rlonu
+-6
+6 484 804 579 884
+6 484 804 579 884
+4 0 0 20 0 0 0 0.00000 4 18 95 484 824 rlonu (1,IM+1)
+4 0 0 20 0 0 0 0.00000 4 18 95 484 844 rlonv (1,IM+1)
+4 0 0 20 0 0 0 0.00000 4 18 70 484 884 rlatv(1,JM)
+4 0 0 20 0 0 0 0.00000 4 18 91 484 864 rlatu (1,JM+1)
+-6
+-6
+1 4 0 1 0 0 0 11 0.00000 1 0.000 620 58 5 5 615 53 625 63
+1 4 0 1 0 0 0 11 0.00000 1 0.000 459 459 5 5 454 454 464 464
+1 4 0 1 0 0 0 11 0.00000 1 0.000 459 359 5 5 454 354 464 364
+1 4 0 1 0 0 0 11 0.00000 1 0.000 359 359 5 5 354 354 364 364
+1 4 0 1 0 0 0 11 0.00000 1 0.000 459 259 5 5 454 254 464 264
+1 4 0 1 0 0 0 11 0.00000 1 0.000 359 259 5 5 354 254 364 264
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 359 5 5 254 354 264 364
+1 4 0 1 0 0 0 11 0.00000 1 0.000 159 359 5 5 154 354 164 364
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 259 5 5 254 254 264 264
+1 4 0 1 0 0 0 11 0.00000 1 0.000 159 259 5 5 154 254 164 264
+1 4 0 1 0 0 0 11 0.00000 1 0.000 459 659 5 5 454 654 464 664
+1 4 0 1 0 0 0 11 0.00000 1 0.000 459 559 5 5 454 554 464 564
+1 4 0 1 0 0 0 11 0.00000 1 0.000 559 459 5 5 554 454 564 464
+1 4 0 1 0 0 0 11 0.00000 1 0.000 559 359 5 5 554 354 564 364
+1 4 0 1 0 0 0 11 0.00000 1 0.000 559 259 5 5 554 254 564 264
+1 4 0 1 0 0 0 11 0.00000 1 0.000 559 659 5 5 554 654 564 664
+1 4 0 1 0 0 0 11 0.00000 1 0.000 559 559 5 5 554 554 564 564
+1 4 0 1 0 0 0 11 0.00000 1 0.000 759 459 5 5 754 454 764 464
+1 4 0 1 0 0 0 11 0.00000 1 0.000 759 359 5 5 754 354 764 364
+1 4 0 1 0 0 0 11 0.00000 1 0.000 759 259 5 5 754 254 764 264
+1 4 0 1 0 0 0 11 0.00000 1 0.000 759 659 5 5 754 654 764 664
+1 4 0 1 0 0 0 11 0.00000 1 0.000 759 559 5 5 754 554 764 564
+1 4 0 1 0 0 0 11 0.00000 1 0.000 659 459 5 5 654 454 664 464
+1 4 0 1 0 0 0 11 0.00000 1 0.000 659 359 5 5 654 354 664 364
+1 4 0 1 0 0 0 11 0.00000 1 0.000 659 259 5 5 654 254 664 264
+1 4 0 1 0 0 0 11 0.00000 1 0.000 659 659 5 5 654 654 664 664
+1 4 0 1 0 0 0 11 0.00000 1 0.000 659 559 5 5 654 554 664 564
+1 4 0 1 -1 0 0 6 0.00000 1 0.000 41 194 17 17 34 179 49 209
+1 4 0 1 -1 0 0 6 0.00000 1 0.000 89 174 18 18 79 159 99 189
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 859 5 5 254 854 264 864
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 759 5 5 254 754 264 764
+1 4 0 1 0 0 0 11 0.00000 1 0.000 359 859 5 5 354 854 364 864
+1 4 0 1 0 0 0 11 0.00000 1 0.000 259 959 5 5 254 954 264 964
+1 4 0 1 0 0 0 11 0.00000 1 0.000 159 859 5 5 154 854 164 864
+2 1 0 1 -1 0 0 0 0.000 -1 0 0
+	 49 169 89 209 9999 9999
+2 1 0 1 -1 0 0 6 0.000 -1 0 0
+	 89 209 869 209 9999 9999
+2 1 0 1 -1 0 0 6 0.000 -1 0 0
+	 89 209 89 699 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 379 459 439 459 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 404 454 404 464 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 359 379 359 439 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 354 409 364 409 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 479 459 539 459 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 504 454 504 464 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 454 409 464 409 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 459 279 459 339 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 454 309 464 309 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 359 279 359 339 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 354 309 364 309 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 459 379 459 439 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 479 359 539 359 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 504 354 504 364 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 379 359 439 359 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 404 354 404 364 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 479 259 539 259 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 504 254 504 264 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 379 259 439 259 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 404 254 404 264 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 159 379 159 439 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 154 409 164 409 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 254 409 264 409 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 259 279 259 339 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 254 309 264 309 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 159 279 159 339 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 154 309 164 309 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 259 379 259 439 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 279 359 339 359 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 304 354 304 364 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 179 359 239 359 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 204 354 204 364 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 279 259 339 259 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 304 254 304 264 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 179 259 239 259 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 204 254 204 264 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 379 659 439 659 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 404 654 404 664 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 479 659 539 659 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 504 654 504 664 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 454 609 464 609 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 459 479 459 539 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 454 509 464 509 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 459 579 459 639 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 479 559 539 559 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 504 554 504 564 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 379 559 439 559 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 404 554 404 564 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 579 459 639 459 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 604 454 604 464 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 559 379 559 439 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 554 409 564 409 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 559 279 559 339 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 554 309 564 309 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 579 359 639 359 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 604 354 604 364 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 579 259 639 259 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 604 254 604 264 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 579 659 639 659 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 604 654 604 664 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 559 579 559 639 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 554 609 564 609 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 559 479 559 539 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 554 509 564 509 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 579 559 639 559 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 604 554 604 564 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 779 459 839 459 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 804 454 804 464 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 754 409 764 409 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 759 279 759 339 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 754 309 764 309 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 759 379 759 439 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 779 359 839 359 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 804 354 804 364 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 779 259 839 259 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 804 254 804 264 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 779 659 839 659 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 804 654 804 664 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 754 609 764 609 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 759 479 759 539 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 754 509 764 509 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 759 579 759 639 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 779 559 839 559 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 804 554 804 564 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 679 459 739 459 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 704 454 704 464 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 654 409 664 409 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 659 279 659 339 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 654 309 664 309 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 659 379 659 439 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 679 359 739 359 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 704 354 704 364 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 679 259 739 259 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 704 254 704 264 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 679 659 739 659 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 704 654 704 664 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 654 609 664 609 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 659 479 659 539 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 654 509 664 509 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 659 579 659 639 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 679 559 739 559 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 704 554 704 564 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 169 269 169 249 149 249 149 269 169 269 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 169 369 169 349 149 349 149 369 169 369 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 269 369 269 349 249 349 249 369 269 369 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 369 369 369 349 349 349 349 369 369 369 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 469 369 469 349 449 349 449 369 469 369 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 569 369 569 349 549 349 549 369 569 369 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 669 369 669 349 649 349 649 369 669 369 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 469 469 469 449 449 449 449 469 469 469 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 569 469 569 449 549 449 549 469 569 469 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 669 469 669 449 649 449 649 469 669 469 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 469 569 469 549 449 549 449 569 469 569 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 569 569 569 549 549 549 549 569 569 569 9999 9999
+2 2 0 1 -1 0 0 0 0.000 0 0 0
+	 669 569 669 549 649 549 649 569 669 569 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 254 909 264 909 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 259 779 259 839 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 254 809 264 809 9999 9999
+2 1 0 1 -1 0 0 0 0.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 259 879 259 939 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 279 859 339 859 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 304 854 304 864 9999 9999
+2 1 0 1 0 0 0 6 0.000 -1 1 0
+	0 0 1.000 4.000 8.000
+	 179 859 239 859 9999 9999
+2 1 0 1 0 0 0 21 0.000 -1 0 0
+	 204 854 204 864 9999 9999
+2 1 0 1 -1 100 0 2 0.000 -1 0 0
+	 119 334 689 334 689 379 119 379 9999 9999
+2 1 0 1 -1 100 0 2 0.000 -1 0 0
+	 119 234 189 234 189 279 119 279 9999 9999
+2 1 0 1 -1 100 0 2 0.000 -1 0 0
+	 119 434 689 434 689 479 119 479 9999 9999
+2 1 0 1 -1 100 0 2 0.000 -1 0 0
+	 119 534 689 534 689 579 119 579 9999 9999
+2 1 0 1 -1 100 0 2 0.000 -1 0 0
+	 119 634 189 634 189 679 119 679 9999 9999
+2 2 0 1 -1 100 0 5 0.000 0 0 0
+	 804 709 804 609 704 609 704 709 804 709 9999 9999
+2 1 0 2 -1 100 0 6 0.000 -1 0 1
+	0 0 2.000 8.000 16.000
+	 859 659 899 659 9999 9999
+2 1 0 2 -1 100 0 6 0.000 -1 0 1
+	0 0 2.000 8.000 16.000
+	 819 609 899 609 9999 9999
+2 1 1 1 -1 100 0 5 4.000 -1 0 1
+	0 0 1.000 4.000 8.000
+	 679 699 604 759 9999 9999
+2 4 0 1 -1 10 0 6 0.000 7 0 0
+	 469 104 204 104 204 64 469 64 469 104 9999 9999
+4 0 0 20 0 -1 0 0.00000 4 18 7 154 199 1
+4 0 0 20 0 -1 0 0.00000 4 18 7 254 199 2
+4 0 0 20 0 -1 0 0.00000 4 18 7 354 199 3
+4 0 0 20 0 -1 0 0.00000 4 18 7 454 199 4
+4 0 0 20 0 -1 0 0.00000 4 18 7 554 199 5
+4 0 0 20 0 -1 0 0.00000 4 18 7 654 199 6
+4 0 0 20 0 -1 0 0.00000 4 18 7 754 199 7
+4 0 0 20 0 -1 0 0.00000 4 18 17 649 174 IM
+4 0 0 20 0 -1 0 0.00000 4 18 32 744 174 IM+1
+4 0 0 20 0 -1 0 0.00000 4 18 162 224 89 Exemple:    IM = 6   JM = 4
+4 0 2 22 0 -1 0 0.00000 4 25 7 39 199 j
+4 0 2 22 0 -1 0 0.00000 4 25 6 84 179 i
+4 0 0 20 0 -1 0 0.00000 4 18 17 9 544 JM
+4 0 0 20 0 -1 0 0.00000 4 18 32 9 644 JM+1
+4 0 0 20 0 -1 0 0.00000 4 18 7 64 344 2
+4 0 0 20 0 -1 0 0.00000 4 18 7 64 444 3
+4 0 0 20 0 -1 0 0.00000 4 18 7 64 244 1
+4 0 0 20 0 -1 0 0.00000 4 18 7 64 544 4
+4 0 0 20 0 -1 0 0.00000 4 18 7 64 644 5
+4 0 0 20 0 0 0 0.00000 4 16 6 344 409 v
+4 0 0 20 0 0 0 0.00000 4 16 6 444 409 v
+4 0 0 20 0 0 0 0.00000 4 16 6 444 309 v
+4 0 0 20 0 0 0 0.00000 4 16 6 344 309 v
+4 0 0 20 0 0 0 0.00000 4 16 6 144 409 v
+4 0 0 20 0 0 0 0.00000 4 16 6 244 409 v
+4 0 0 20 0 0 0 0.00000 4 16 6 244 309 v
+4 0 0 20 0 0 0 0.00000 4 16 6 144 309 v
+4 0 0 20 0 0 0 0.00000 4 16 6 444 609 v
+4 0 0 20 0 0 0 0.00000 4 16 6 444 509 v
+4 0 0 20 0 0 0 0.00000 4 16 6 544 409 v
+4 0 0 20 0 0 0 0.00000 4 16 6 544 309 v
+4 0 0 20 0 0 0 0.00000 4 16 6 544 609 v
+4 0 0 20 0 0 0 0.00000 4 16 6 544 509 v
+4 0 0 20 0 0 0 0.00000 4 16 6 744 409 v
+4 0 0 20 0 0 0 0.00000 4 16 6 744 309 v
+4 0 0 20 0 0 0 0.00000 4 16 6 744 609 v
+4 0 0 20 0 0 0 0.00000 4 16 6 744 509 v
+4 0 0 20 0 0 0 0.00000 4 16 6 644 409 v
+4 0 0 20 0 0 0 0.00000 4 16 6 644 309 v
+4 0 0 20 0 0 0 0.00000 4 16 6 644 609 v
+4 0 0 20 0 0 0 0.00000 4 16 6 644 509 v
+4 0 0 20 0 -1 0 0.00000 4 18 14 334 449 10
+4 0 0 20 0 -1 0 0.00000 4 18 7 139 349 2
+4 0 0 20 0 -1 0 0.00000 4 18 7 139 249 1
+4 0 0 20 0 -1 0 0.00000 4 18 7 239 349 3
+4 0 0 20 0 -1 0 0.00000 4 18 7 339 349 4
+4 0 0 20 0 -1 0 0.00000 4 18 7 439 349 5
+4 0 0 20 0 -1 0 0.00000 4 18 7 539 349 6
+4 0 0 20 0 -1 0 0.00000 4 18 7 639 349 7
+4 0 0 20 0 -1 0 0.00000 4 18 7 139 449 8
+4 0 0 20 0 -1 0 0.00000 4 18 7 239 449 9
+4 0 0 20 0 -1 0 0.00000 4 18 14 434 449 11
+4 0 0 20 0 -1 0 0.00000 4 18 14 534 449 12
+4 0 0 20 0 -1 0 0.00000 4 18 14 634 449 13
+4 0 0 20 0 0 0 0.00000 4 16 6 204 274 u
+4 0 0 20 0 0 0 0.00000 4 16 6 304 274 u
+4 0 0 20 0 0 0 0.00000 4 16 6 404 274 u
+4 0 0 20 0 0 0 0.00000 4 16 6 504 274 u
+4 0 0 20 0 0 0 0.00000 4 16 6 204 374 u
+4 0 0 20 0 0 0 0.00000 4 16 6 304 374 u
+4 0 0 20 0 0 0 0.00000 4 16 6 404 374 u
+4 0 0 20 0 0 0 0.00000 4 16 6 504 374 u
+4 0 0 20 0 0 0 0.00000 4 16 6 604 374 u
+4 0 0 20 0 0 0 0.00000 4 16 6 404 474 u
+4 0 0 20 0 0 0 0.00000 4 16 6 504 474 u
+4 0 0 20 0 0 0 0.00000 4 16 6 604 474 u
+4 0 0 20 0 0 0 0.00000 4 16 6 604 574 u
+4 0 0 20 0 0 0 0.00000 4 16 6 504 574 u
+4 0 0 20 0 0 0 0.00000 4 16 6 404 574 u
+4 0 0 20 0 0 0 0.00000 4 16 6 604 274 u
+4 0 0 20 0 0 0 0.00000 4 16 6 404 674 u
+4 0 0 20 0 0 0 0.00000 4 16 6 504 674 u
+4 0 0 20 0 0 0 0.00000 4 16 6 604 674 u
+4 0 0 20 0 -1 0 0.00000 4 18 14 434 549 17
+4 0 0 20 0 -1 0 0.00000 4 18 14 534 549 18
+4 0 0 20 0 -1 0 0.00000 4 18 14 634 549 19
+4 0 0 20 0 0 0 0.00000 4 16 6 804 274 u
+4 0 0 20 0 0 0 0.00000 4 16 6 704 274 u
+4 0 0 20 0 0 0 0.00000 4 16 6 704 374 u
+4 0 0 20 0 0 0 0.00000 4 16 6 804 374 u
+4 0 0 20 0 0 0 0.00000 4 16 6 704 474 u
+4 0 0 20 0 0 0 0.00000 4 16 6 804 474 u
+4 0 0 20 0 0 0 0.00000 4 16 6 704 574 u
+4 0 0 20 0 0 0 0.00000 4 16 6 804 574 u
+4 0 0 20 0 0 0 0.00000 4 16 6 709 674 u
+4 0 0 20 0 0 0 0.00000 4 16 6 804 674 u
+4 0 0 20 0 0 0 0.00000 4 18 47 184 884 u(i-1,j)
+4 0 0 20 0 0 0 0.00000 4 18 47 269 814 v(i,j-1)
+4 0 2 20 0 -1 0 0.00000 4 22 39 209 844 T(i,j)
+4 0 2 20 0 0 0 0.00000 4 20 32 299 884 u(i,j)
+4 0 2 20 0 0 0 0.00000 4 20 31 269 909 v(i,j)
+4 1 0 20 0 0 0 0.00000 4 18 28 929 659 rlatu
+4 1 0 20 0 0 0 0.00000 4 18 28 929 609 rlatv
+4 0 0 20 0 0 0 0.00000 4 18 132 474 779 "boite" grille scalaire
+4 0 0 20 0 -1 0 0.00000 4 22 267 639 59 grille "scalaire" de la dynamique
Index: /trunk/LMDZ.TITAN/DOC/Fig/inout.fig
===================================================================
--- /trunk/LMDZ.TITAN/DOC/Fig/inout.fig	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/Fig/inout.fig	(revision 1644)
@@ -0,0 +1,109 @@
+#FIG 3.2
+Landscape
+Center
+Inches
+Letter  
+100.00
+Single
+-2
+1200 2
+6 4950 2250 6000 2625
+6 4950 2250 6000 2625
+2 4 0 1 -1 -1 20 0 3 0.000 0 0 5 0 0 5
+	 6000 2600 4950 2600 4950 2262 6000 2262 6000 2600
+-6
+-6
+6 9600 9450 10650 10125
+4 1 -1 0 0 0 14 0.0000 4 150 600 10140 9660 run.def\001
+4 1 -1 0 0 0 14 0.0000 4 195 1020 10140 9885 callphys.def\001
+-6
+1 1 0 2 -1 -1 20 0 1 0.000 1 0.0000 7800 2415 1125 225 7800 2415 8925 2640
+1 1 0 2 -1 -1 20 0 1 0.000 1 0.0000 7800 5790 1125 225 7800 5790 8925 6015
+1 1 1 2 -1 -1 20 0 1 6.000 1 0.0000 7800 9900 1125 225 7800 9900 8925 10125
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 7800 6000 7800 7200
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 9375 4470 6270 4470 6270 3705 9375 3705 9375 4470
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 7800 4470 7800 5550
+2 1 0 2 -1 -1 0 0 -1 0.000 0 0 -1 0 0 4
+	 7350 6000 7350 6300 5550 6300 5550 8520
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 0 1 2
+	0 0 2.00 135.00 255.00
+	 5100 7620 5550 7620
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 0 1 2
+	0 0 2.00 135.00 255.00
+	 5100 8520 5550 8520
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 6000 2415 6675 2415
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 9600 2415 8925 2415
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 7800 2640 7800 3675
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 10725 2865 9600 2865 9600 2055 10725 2055 10725 2865
+2 1 1 2 -1 -1 0 0 5 6.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 7800 8025 7800 9690
+2 1 1 2 -1 -1 0 0 5 6.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 7800 10125 7800 10845
+2 1 1 2 -1 -1 0 0 -1 6.000 0 0 -1 0 0 4
+	 7350 10125 7350 10500 6300 10500 6375 10500
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 9390 7995 6285 7995 6285 7230 9390 7230 9390 7995
+2 1 1 2 -1 -1 0 0 5 4.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 9600 9915 8925 9915
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 9600 5790 8925 5790
+2 1 0 2 -1 -1 0 0 5 0.000 0 0 -1 1 0 2
+	0 0 2.00 135.00 255.00
+	 7800 1470 7800 2190
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 5100 8625 3975 8625 3975 8250 5100 8250 5100 8625
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 7620 4200 7620 3870 6675 3870 6675 4200 7620 4200
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 8970 4200 8970 3870 8025 3870 8025 4200 8970 4200
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 8550 1425 8550 1050 7050 1050 7050 1425 8550 1425
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 9075 7725 9075 7425 7950 7425 7950 7725 9075 7725
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 7650 7725 7650 7425 6675 7425 6675 7725 7650 7725
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 7 0 0 5
+	 5100 7725 3975 7725 3975 7350 5100 7350 5100 7725
+2 4 0 1 -1 -1 0 0 -1 0.000 0 0 6 0 0 5
+	 10725 6150 9600 6150 9600 5385 10725 5385 10725 6150
+2 4 1 1 -1 -1 0 0 -1 4.000 0 0 7 0 0 5
+	 10725 10320 9600 10320 9600 9375 10725 9375 10725 10320
+2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5
+	 11925 3225 11925 465 2850 465 2850 3225 11925 3225
+4 1 -1 0 0 0 14 0.0000 4 195 720 4560 7575 diagfi.nc\001
+4 1 -1 0 0 0 14 0.0000 4 150 600 10140 2280 run.def\001
+4 1 -1 0 0 0 14 0.0000 4 195 1020 10140 2505 callphys.def\001
+4 1 -1 0 0 0 14 0.0000 4 195 750 10140 2730 z2sig.def\001
+4 1 -1 0 0 3 20 0.0000 4 330 4125 5025 975 Creation of the initial state\001
+4 1 -1 0 0 2 22 0.0000 4 255 915 7800 9975 GCM\001
+4 1 -1 0 0 3 20 0.0000 4 255 1965 3300 9975 Simulation 2\001
+4 1 -1 0 0 3 20 0.0000 4 255 1965 3300 5775 Simulation 1\001
+4 1 -1 0 0 2 22 0.0000 4 255 915 7800 5880 GCM\001
+4 1 -1 0 0 0 14 0.0000 4 150 600 10140 5610 run.def\001
+4 1 -1 0 0 0 14 0.0000 4 195 1020 10140 5835 callphys.def\001
+4 1 -1 0 0 2 22 0.0000 4 255 1440 7800 2505 Newstart\001
+4 1 -1 0 0 0 14 0.0000 4 135 645 7125 4125 start.nc\001
+4 1 -1 0 0 0 14 0.0000 4 150 900 5475 2475 surface.nc\001
+4 1 -1 0 0 0 14 0.0000 4 195 1395 7800 1275 start_archive.nc\001
+4 1 -1 0 0 0 14 0.0000 4 135 825 7125 7650 restart.nc\001
+4 1 -1 0 0 0 14 0.0000 4 150 930 8475 7650 restartfi.nc\001
+4 1 -1 0 0 0 14 0.0000 4 150 750 8475 4125 startfi.nc\001
+4 1 -1 0 0 0 14 0.0000 4 135 660 4560 8475 stats.nc\001
+4 0 0 50 -1 0 14 0.0000 4 195 750 9750 6075 z2sig.def\001
+4 0 0 50 -1 0 14 0.0000 4 195 750 9750 10125 z2sig.def\001
Index: /trunk/LMDZ.TITAN/DOC/Fig/netcdf.fig
===================================================================
--- /trunk/LMDZ.TITAN/DOC/Fig/netcdf.fig	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/Fig/netcdf.fig	(revision 1644)
@@ -0,0 +1,17 @@
+#FIG 3.2
+Landscape
+Center
+Inches
+Letter  
+100.00
+Single
+-2
+1200 2
+2 5 0 1 0 -1 50 -1 -1 0.000 0 0 -1 0 0 5
+	0 netcdf.eps
+	 1425 2700 9392 2700 9392 15250 1425 15250 1425 2700
+2 2 0 1 0 7 50 -1 20 0.000 0 0 -1 0 0 5
+	 5850 4500 7575 4500 7575 5775 5850 5775 5850 4500
+4 0 0 50 -1 0 12 0.0000 4 180 690 6000 4800 longitude\001
+4 0 0 50 -1 0 12 0.0000 4 135 570 6000 5025 latitude\001
+4 0 0 50 -1 0 12 0.0000 4 90 330 6000 5250 aera\001
Index: /trunk/LMDZ.TITAN/DOC/compilation.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/compilation.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/compilation.tex	(revision 1644)
@@ -0,0 +1,158 @@
+\chapter{Program organization and compilation script}
+\label{sc:info}
+\index{Programming organization and compilation}
+
+\label{loc:contenu}
+
+All the elements of the LMD model are in the {\bf LMDZ.GENERIC} directory
+(and subdirectories).
+As explained in Section~\ref{loc:contact1}, this directory
+should be associated with
+ environment variable {\bf LMDGCM}:\\
+If using Csh:
+\begin{verbatim}
+setenv  LMDGCM /where/you/put/the/model/LMDZ.GENERIC
+\end{verbatim}
+If using Bash:
+\begin{verbatim}
+export  LMDGCM=/where/you/put/the/model/LMDZ.GENERIC
+\end{verbatim}
+
+\noindent Here is a brief description of the
+{\bf LMDZ.GENERIC} directory contents:
+\begin{verbatim}
+  libf/  All the model FORTRAN Sources (.F or .F90)
+         and  include files (.h) organised in sub-directories
+        (physics (phystd), dynamics (dyn3d), filters (filtrez)...)
+
+  deftank/   A collection of examples of parameter files required
+                to run the GCM (run.def, callphys.def, ...)
+
+  makegcm  Script that should be used to compile the GCM as well
+            as related utilities (newstart, start2archive, testphys1d)
+
+  create_make_gcm   Executable used to create the makefile.
+                    This command is run automatically by
+                    "makegcm" (see below).
+
+\end{verbatim}
+
+
+\section{Organization of the model source files}
+\index{Organization of the model source files}
+
+The model source files are stored in various sub directories
+in directory {\bf libf}.
+These sub-directories correspond to the different parts of the model:
+
+\begin{description}
+\item{\bf grid:} mainly made up of "dimensions.h" file,
+which contains the parameters that define the model grid,
+i.e. the number of points in longitude (IIM), latitude (JJM) and altitude
+(LLM), as well as the number of tracers (NQMX).
+
+\item{\bf dyn3d:} contains the dynamical subroutines.
+
+\item{\bf bibio:} contains some generic subroutines not specifically
+related to physics or dynamics but used by either or both.
+
+\item{\bf phymars:} contains the physics routines.
+
+\item{\bf filtrez:} contains the longitudinal filter sources applied in the
+upper latitudes,
+where the Courant-Friedrich-Levy stability criterion is violated.
+
+\end{description}
+
+\section{Programming}
+
+The model is written in {\bf Fortran-77} and {\bf Fortran-90}.
+\begin{itemize}
+\item The program sources are written in {\bf ``file.F"}
+or {\bf ``file.F90''} files.
+The extension .F is the standard extension for fixed-form Fortran and
+the extension .F90 is for free-form Fortran.
+These files must be preprocessed (by a{\bf C preprocessor}
+such as (cpp)) before compilation (this behaviour is, for most
+compilers, implicitly obtained but using a capital F in the extention
+of the file names).
+
+\item Constants are placed in COMMON declarations,
+located in the common ``include'' files {\bf "file.h"}
+
+%\item [also module files now too...]
+\item In general, variables are passed from subroutine to subroutine
+as arguments (and never as COMMON blocks).
+
+\item In some parts of the code, for ``historical'' reasons,
+the following rule is sometimes used: in the subroutine,
+the variables (ex: \verb+name+) passed as an argument by the calling program
+are given the prefix \verb+p+ (ex: \verb+pname+)
+ while the local variables are given the prefix \verb+z+ (ex: \verb+zname+).
+As a result, several variables change their prefix (and thus their name)
+when passing from a calling subroutine to a called subroutine. We're trying to eliminate this as the code is developed.
+\end{itemize}
+
+\section{Model organization}
+Figure~\ref{fg:organi_phys} describes the main subroutines called by physiq.F. OBSOLETE - FOR MARS ONLY!!!
+\index{Model organization}
+\begin{figure}
+\begin{flushleft}
+\includegraphics[scale=0.70,angle=-90]{Fig/physique.eps}
+\caption{Organigram of subroutine function physiq.F90}
+\label{fg:organi_phys}
+\end{flushleft}
+\end{figure}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  Compilation du modele
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{Compiling the model}
+\index{Compiling the model}
+
+\label{sc:compil1}
+Technically, the model is compiled using the Unix utility {\tt make}.
+The file {\tt makefile}, which describes the code dependencies
+and requirements,
+is created automatically by the script
+\begin{verbatim}
+create_make_gcm
+\end{verbatim}
+This utility script recreates the {\tt makefile} file when necessary,
+for example, when a source file has been added or removed since the last
+compilation.
+
+{\bf None of this is visible to the user.
+To compile the model just run the command}
+\begin{verbatim}
+makegcm
+\end{verbatim}
+with adequate options (e.g. {\tt makegcm -d 62x48x32 -p mars gcm}), as
+discussed below and described in section~\ref{sc:run1}.
+
+
+The {\tt makegcm} command compiles the model ({\bf gcm}) and related utilities
+({\bf newstart}, {\bf start2archive}, {\bf testphys1d}).
+A detailed description of how to use it and of the various parameters that
+can be supplied
+is given in the help manual below
+(which will also be given by the \verb+makegcm -h+ command).\\
+Note that before compiling the GCM with {\tt makegcm} you should have set
+the environment variable {\bf LIBOGCM} to a path where intermediate
+objects and libraries will be generated.\\
+If using Csh:
+\begin{verbatim}
+setenv  LIBOGCM /where/you/want/objects/to/go/libo
+\end{verbatim}
+If using Bash:
+\begin{verbatim}
+export  LIBOGCM=/where/you/want/objects/to/go/libo
+\end{verbatim}
+\paragraph{Help manual for the makegcm script}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% makegcm.help:  lu dans makegcm
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\input{input/makegcm_help.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Index: /trunk/LMDZ.TITAN/DOC/def.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/def.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/def.tex	(revision 1644)
@@ -0,0 +1,37 @@
+\newcommand{\der}[2]{\frac{\partial #1 }{\partial #2} }
+
+%termes lations
+\def\ie{{\em i.~e.}}
+\def\etal{{\em et~al.}}
+\def\apriori{{\em a~priori}}
+\def\apost{{\em a~posteriori}}
+\def\afort{{\em a~fortiori}}
+\def\etc{{\em etc.}}
+\def\insitu{{\em in--situ}}
+\def\adoc{{\em ad~hoc}}
+
+\def\sc#1{Section~\ref{sc:#1}}
+\def\an#1{Annexe~\ref{an:#1}}
+\def\ch#1{Chapitre~\ref{ch:#1}}
+\def\fg#1{Fig.~\ref{fg:#1}}
+\def\fgs#1{Figs.~\ref{fg:#1}}
+\def\eq#1{Eq.~\ref{eq:#1}}
+\def\eqs#1{Eqs.~\ref{eq:#1}}
+\def\tb#1{Table~\ref{tb:#1}}
+\newcommand{\av}[2]{{\overline{#1}}^{ #2 }}
+\newcommand{\avg}[1]{\left< #1 \right>}
+\def\cd{C_D}
+% definitions de Macros pour tout l'article
+\def\co{$CO_2$}
+\def\eq#1{Eq.~\ref{eq:#1}}
+\def\fig#1{Fig.~\ref{fg:#1}}
+\newcommand{\dep}[1]{\left( #1 \right) }
+\newcommand{\depb}[1]{\left[ #1 \right] }
+\newcommand{\depc}[1]{\left\{ #1 \right\} }
+\def\coband{$CO_2\ 15\mu$m~band}
+\def\ps{p_S}
+\def\etal{{\em~et al. }}
+\def\insitu{{\em in--situ }}
+\def\t{\theta}
+\def\dnw{^{\downarrow}}
+
Index: /trunk/LMDZ.TITAN/DOC/dynamics.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/dynamics.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/dynamics.tex	(revision 1644)
@@ -0,0 +1,319 @@
+\chapter{3D Dynamical Code}
+\label{sc:dynamic}
+\section{Discretisation of the dynamical equations}
+\index{The hydrodynamic code}
+
+% definitions pour les formules mathematiques
+%\newcommand{\dep}[1]{\left( #1 \right) }
+%\newcommand{\depb}[1]{\left[ #1 \right] }
+%\newcommand{\depc}[1]{\left\{ #1 \right\} }
+\newcommand{\deriv}[1]{\frac{\partial }{\partial #1} }
+\def\abs#1{\left| #1 \right|}
+\renewcommand{\-}[1]{$^{-#1}$}
+
+% definitions pour la dynamique
+\newcommand{\dt}[1]{\frac{\partial #1}{\partial t}}
+\newcommand{\dsig}[1]{\deriv{\sigma} \dep{#1} }
+\newcommand{\diverg}[1]{\vec{\nabla}.\dep{#1 \vec{V}} }
+%\newcommand{\der}[2]{\frac{\partial #1 }{\partial #2} }
+\def\ps{p_s}
+\def\t{\theta}
+\def\w{\dot{\sigma}}
+\def\cp{C_p}
+\def\rcp{\kappa}
+
+%
+%   ATTENTION  ne plait pas a latex2html (I don't know why)
+%       de toutes facons inutile
+%\def\p0{p_0}
+%\def\s{ {\dep{\frac{p}{\p0}}}^{\rcp} }
+%
+
+\newcommand{\adv}[1]{\diverg{\ps #1} + \dsig{\ps #1 \dot{\sigma}} }
+
+\def\sc#1{Section~\ref{sc:#1}}
+\def\an#1{Annexe~\ref{an:#1}}
+\def\ch#1{Chapitre~\ref{ch:#1}}
+\def\fig#1{Fig.~\ref{fg:#1}}
+\def\figs#1{Figs.~\ref{fg:#1}}
+\def\eq#1{Eq.~\ref{eq:#1}}
+\def\eqs#1{Eqs.~\ref{eq:#1}}
+\def\tb#1{Table~\ref{tb:#1}}
+%\newcommand{\av}[2]{{\overline{#1}}^{ #2 }}
+%\newcommand{\avg}[1]{\left< #1 \right>}
+\def\cd{C_D}
+\def\dx{\delta_X}
+\def\dy{\delta_Y}
+\def\dz{\delta_Z}
+
+\def\filtre{{\cal F}}
+\def\uabs{\tilde{u}_{a}}
+\def\err{\epsilon}
+\def\dsig{\dz \sigma}
+\def\psk{{\ps}^\kappa}
+\def\ucov{\tilde{u}}
+\def\vcov{\tilde{v}}
+\def\ucont{\tilde{\ucov}}
+\def\vcont{\tilde{\vcov}}
+\def\cu{c_u}
+\def\cv{c_v}
+\def\h{\theta}
+\def\pext{\tilde{p}_s}
+\def\fext{f}
+\def\K{\frac{1}{2}
+\left( \av{\ucov \ucont}{X} + \av{\vcov \vcont}{Y} \right)}
+\def\Z{\frac{\filtre\dep{\dx \vcov - \dy \ucov} + \fext}{\av{\pext}{X,Y}}}
+\def\Zm{\frac{- \dy \ucov + \fext}{\av{\pext}{Y}}}
+
+\newcommand{\glob}[1]{ \left< #1 \right> }
+
+{\it Extrait de la note de Robert Sadourny, Phu Le Van et Fr\'ed\'eric
+Hourdin, Laboratoire de M\protect\'et\protect{\'e}orologie Dynamique}.\\
+
+[to be translated when I get the time...]
+
+Le mod\`ele climatique du LMD est b\^ati, comme tous les
+mod\`eles de circulation g\'en\'erale atmosph\'erique,
+sur la r\'esolution num\'erique des {\'equations primitives
+de la m\'et\'eorologie} d\'ecrites dans de nombreux
+ouvrages~\cite{Holt:79}.
+L'analyse pr\'esent\'ee ici a \'et\'e men\'ee sur la nouvelle
+version de la dynamique du LMD \'ecrite par Phu Le Van~\cite{LeVa:89}
+sur une formulation de Robert Sadourny.
+Cette formulation diff\`ere de l'ancienne essentiellement
+par deux points:
+dans la nouvelle formulation, la r\'epartition des points en
+longitude et en latitude peut \^etre chang\'ee arbitrairement.
+L'autre modification porte sur la r\'epartition des points
+aux p\^oles\footnote{Aux p\^oles sont calcul\'es:
+le vent m\'eridien dans l'ancienne formulation et les variables
+scalaires dans la nouvelle.}.
+
+La coordonn\'ee  verticale du mod\`ele est la pression normalis\'ee
+par sa valeur \`a la surface: $\sigma=p/\ps$.
+On utilise en fait $\sigma$ aux niveaux inter-couches
+et $s=\sigma^\kappa$ au milieu des couches.
+On note $X$ et $Y$ les coordonn\'ees horizontales:
+
+\begin{figure}
+\begin{center}
+\includegraphics[width=13cm]{Fig/glob.eps}
+\includegraphics[width=10cm]{Fig/med.eps}
+\caption{Grille obtenue avec 96 points en longitude et 73 en latitude et
+un zoom d'un facteur 3 centr\'e sur la m\'edit\'erann\'ee (grille utilis\'ee au laboratoire par Ali Harzallah)\label{fg:zoom}}.
+\end{center}
+\end{figure}
+
+$X$ (resp. $Y$) est une fonction biunivoque de la longitude $\lambda$
+(resp. de la latitude $\phi$). Ces deux fonctions peuvent \^etre choisies
+de fa\c{c}on arbitraire dans le mod\`ele LMDZ ce qui permet d'effectuer un
+zoom sur une r\'egion du globe particuli\`ere. Une grille de ce type est montr\'ee
+sur la Figure~\ref{fg:zoom}.
+Les variables scalaires
+(temp\'erature potentielle $\h = c_p T/\psk$, g\'eopotentiel $\Phi$
+et pression de surface $\ps$) sont \'evalu\'ees aux points
+correspondant \`a des couples de valeurs enti\`eres $(X,Y)=(i,j)$.
+Les variables dynamiques sont d\'ecal\'ees par rapport aux variables
+scalaires en utilisant une grille $C$ dans la d\'efinition de
+Arakawa~\cite{Arak:77}: le vent zonal est calcul\'e
+aux points $(X,Y)=(i+1/2,j)$ et  le vent
+m\'eridien aux points $(X,Y)=(i,j+1/2)$.
+La disposition des variables sur la grille est illustr\'ee sur la
+Figure~\ref{fg:grille}.
+
+\begin{figure}
+\centerline{\framebox{\includegraphics[width=0.6\textwidth]{Fig/grille.eps}}}
+\caption{Disposition des variables dans la grille du LMD}
+\label{fg:grille}
+\end{figure}
+
+
+On utilise en fait les composantes covariantes
+($\ucov$ et $\vcov$) et contravariantes ($\ucont$ et $\vcont$)
+du vent d\'efinies par
+\begin{equation}
+\begin{array}{llllllllll}
+\ucov = \cu u & \mbox{et} & \ucont = u / \cu & \mbox{avec} &
+\cu = a \cos{\phi} \left( d\lambda/dX \right)  \\
+\vcov = \cv v & \mbox{et} & \vcont = v / \cv & \mbox{avec} &
+\cv = a \left( d\phi / dY \right)
+\end{array}
+\end{equation}
+%
+o\`u $u$ et $v$ sont les composantes physiques du vecteur vent
+horizontal.
+On introduit \'egalement:
+%
+\paragraph{la pression extensive:}
+$\pext$ (pression au sol multipli\'ee
+par l'aire de la maille).
+%
+\paragraph{les trois composantes du flux de masse:}
+\begin{equation}
+U=\av{\pext}{X} \ucont ,\  V= \av{\pext}{Y} \vcont \  \mbox{et} \
+W= \pext \dot{\sigma}
+\ \mbox{avec}\ \dot{\sigma}=\frac{d\sigma}{dt}
+\end{equation}
+%
+\paragraph{le facteur de Coriolis multipli\'e par l'aire de la maille:}
+$\fext=2\Omega \sin{\phi} \cu \cv$\\
+o\`u $\Omega$ est la vitesse de rotation de la plan\`ete.
+%
+\paragraph{la vorticit\'e potentielle absolue:}
+\begin{equation}
+Z=\Z
+\end{equation}
+%
+\paragraph{l'\'energie cin\'etique}
+\begin{equation}
+K=\K
+\end{equation}\\
+%
+La notation $\delta X$ signifie simplement qu'on
+effectue la diff\'erence entre deux points cons\'ecutifs
+suivant la direction $X$.
+La notation $\av{a}{X}$ signifie qu'on prend la moyenne arithm\'etique
+de la quantit\'e $a$ suivant la direction $X$. $\filtre$ est un filtre longitudinale appliqu\'e dans les r\'egions polaires.
+Les \'equations discr\'etis\'ees sont \'ecrites sous la forme
+suivante:
+\paragraph{\'equations du mouvement:}
+\begin{equation} \label{eq:u1}
+\dt{\ucov} -
+\av{Z}{Y} \av{V}{X,Y}
++ \dx \filtre\dep{\Phi + K}
++s \av{\h}{X} \dx \filtre\dep{\psk}
+- \frac{\av{\uabs}{Y,Y} \dz \av{W}{X} }
+{\av{\pext}{X} \dsig }
++ \frac{\dz \left( \av{W}{X} \av{\uabs}{Z} \right) }
+{\av{\pext}{X} \dsig}
+=S_{\ucov}
+\end{equation}
+o\'u $\uabs$ est la composante zonale covariante
+du vecteur vent absolu:
+$\uabs=\ucov+\cu a \Omega \cos{\phi}$ et
+\begin{equation} \label{eq:v1}
+\dt{\vcov} + \av{Z}{X} \av{U}{X,Y} + \dy \filtre\dep{\Phi + K}
++s \av{\h}{Y} \dy \filtre\dep{\psk}
+- \frac{\av{\vcov}{X,X} \dz \av{W}{Y} }
+{\av{\pext}{Y} \dsig}
++ \frac{\dz \left( \av{W}{Y} \av{\vcov}{Z} \right) }
+{\av{\pext}{X} \dsig}
+=S_{\vcov}
+\end{equation}
+%
+\paragraph{\'equation thermodynamique:}
+%
+\begin{equation}
+\label{eq:thermo}
+\dt{\dep{\pext \h}}
++\filtre\depb{\dx \dep{\av{\h}{X}U} +\dy \dep{\av{\h}{Y}V} }
++\frac{\dz \dep{\av{\h}{Z} W}}{\dz \sigma}=S_\h
+\end{equation}
+%
+\paragraph{\'equation hydrostatique:}
+\begin{equation}
+\dz \Phi=-\ps^\rcp  \av{\h}{z} \dz s
+\end{equation}
+%
+\paragraph{\'equations de continuit\'e:}
+%
+\begin{equation}
+\label{eq:cont1}
+\dt{\ps}  = \filtre\depb{\sum_z{\dz \sigma \dep{\dx U+ \dy V}}}
+\end{equation}
+\begin{equation}
+\label{eq:cont2}
+\dz W   = -\dz \sigma \depb{\filtre\dep{\dx U+ \dy V} + \dt{\ps}}
+\end{equation}
+%
+On a not\'e $S$ les termes sources dans les diff\'erentes \'equations.
+Dans ces termes sources, on distingue 1) d'une part les param\'etrisations physiques mentionn\'ees plus haut et qui font intervenir pour une maille donn\'ee du mod\`ele, tous les points situ\'es sur une m\^eme verticale mais ceux-l\`a seulement; 2) les op\'erateurs de dissipation horizontale, cens\'es rendre compte des \'echanges entre \'echelles explicitement repr\'esent\'ees dans le mod\`ele et \'echelles sous-mailles. Ces op\'erateurs ont la structure de Laplaciens agissant sur des plans horizontaux c'est \`a dire qu'il font intervenir un voisin de chaque c\^ot\'e dans les deux directions horizontales. Cet op\'erateur est g\'en\'eralement it\'er\'e pour le rendre plus s\'electif en \'echelle (plus on it\`ere un laplacien et plus son effet sur les petites \'echelles devient important relativement).
+
+\section{High latitude filters}
+
+{\it Extract adapted from Forget et al. [1999]}\\
+
+At high latitude a filter is applied near
+the singularity in the grid at the pole
+in order to satisfy the Courant-Friedrichs-Lewy numerical
+stability criterion without going to an excessively
+small timestep. In the original version of the dynamical code
+a classical Fourier filter was used,  but
+we found that because the Martian polar
+atmosphere appears to be much more dynamically unstable than the Earth's
+polar atmosphere, a more efficient formulation (based on the
+grouping of adjacent gridpoints together)  was necessary
+to avoid numerical instability. \\
+
+{\it In practice the following technique is used in the subroutine called {\em groupeun.F} :
+\begin{itemize}
+\item The points are grouped in packets of $2^{\mbox{ngroup}}$
+      at the poles(e.g. {\bf ngroup}=3 $\rightarrow$ packets of 8),
+ then $2^{\mbox{ngroup-1}}$,
+      $2^{\mbox{ngroup-2}}$, etc. in the lower latitudes moving away from the pole
+
+   \item The higher {\bf ngroup} is, the more efficient the smoothing is, and the more stable the model.
+
+\item   BUT, {\bf iim} must be divisible by $2^{\mbox{ngroup}}$ !!!
+
+
+\end{itemize}
+
+}
+
+
+\section{Dissipation}
+
+{\it Extract adapted from Forget et al. [1999]}\\
+
+In the LMD grid point model,
+nonlinear interactions between explicitly resolved scales
+and subgrid-scale processes are
+parameterized by applying a scale-selective horizontal
+dissipation operator
+based on an $n$ time iterated Laplacian $\Delta^{n}$.
+For the grid point model, for instance, this can be written
+${\partial q}/{\partial t} = ([-1]^{n}/ {\tau_{\mbox{\scriptsize
+diss}}})
+(\delta x)^{2n} \Delta^{n} q$
+where $\delta x$ is the smallest horizontal distance represented in the
+model and $\tau_{\mbox{\scriptsize diss}}$ is the dissipation timescale
+for a st
+ructure of scale
+$\delta x$.
+These operators are necessary to ensure the grid point model
+numerical stability.
+In practice, the operator is
+separately applied to (1)~potential temperature, (2)~the divergence of
+the flow,
+and (3)~its vorticity.
+We respectively use  $n=2$, $n=1$, and $n=2$ in the grid point model.\\
+
+{\it Note: In practice,
+values of $n$ and $\tau_{\mbox{\scriptsize diss}}$
+are adjustable and prescribed at the beginning of each run, in run definition file ``run.def'' (cf.~\ref{vb:run.def}) }
+
+\section{Sponge layer}
+
+{\it Extract adapted from Forget et al. [1999]}\\
+
+In the upper levels a sponge layer is also used in both models
+in an attempt to reduce
+spurious reflections of vertically propagating waves from the model top.
+Unlike the traditional Rayleigh friction formulation,
+this operates as a linear drag
+ solely on the eddy components of the vorticity and divergence
+fields and is not scale-selective.  The timescales on which it operates
+are
+typically half a day, 1 day,  and 2 days
+ at the three uppermost levels, respectively. \\
+
+{\it Note: the sponge layer ``timescale'' values and their extensions in altitude
+are adjustable and prescribed at the beginning of each run, in run definition file ``run.def'' (cf.~\ref{vb:run.def}) }
+
+
+
+
+
+
+
Index: /trunk/LMDZ.TITAN/DOC/input/callphys.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/callphys.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/callphys.tex	(revision 1644)
@@ -0,0 +1,129 @@
+{\footnotesize
+\begin{verbatim}
+
+## Orbit / general options
+## ~~~~~~~~~~~~~~~~~~~~~~~
+# Run with or without tracer transport ?
+tracer    = .true.
+# Diurnal cycle ?  if diurnal=false, diurnally averaged solar heating
+diurnal   = .true.
+# Seasonal cycle ? if season=false, Ls stays constant, to value set in "start"
+season    = .true.
+# Tidally resonant orbit ? must have diurnal=false, correct rotation rate in newstart
+tlocked   = .false.
+# Tidal resonance ratio ? ratio T_orbit to T_rotation
+nres      = 10
+# Write some more output on the screen ?
+lwrite    = .false.
+# Save statistics in file "stats.nc" ?
+callstats = .true.
+# Test energy conservation of model physics ?
+enertest  = .true.
+
+## Radiative transfer options
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# call radiative transfer?
+callrad    = .true.
+# the rad. transfer is computed every "iradia" physical timestep
+iradia     = 4
+# call multilayer correlated-k radiative transfer ?
+corrk      = .true.
+# folder in which correlated-k data is stored ?
+corrkdir   = CO2_H2Ovar
+# call visible gaseous absorption in radiative transfer ?
+callgasvis = .true.
+# Include Rayleigh scattering in the visible ?
+rayleigh   = .true.
+# Characteristic planetary equilibrium (black body) temperature
+# This is used only in the aerosol radiative transfer setup. (see aerave.F)
+tplanet    = 215.
+# Output spectral OLR in 1D/3D?
+specOLR    = .false.
+# Output global radiative balance in file 'rad_bal.out' - slow for 1D!!
+meanOLR    = .true.
+# Variable gas species: Radiatively active ?
+varactive  = .true.
+# Variable gas species: Fixed vertical distribution ?
+varfixed   = .false.
+# Variable gas species: Saturation percentage value at ground ?
+satval     = 0.0
+
+## Star type
+## ~~~~~~~~~
+startype = 1
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# The choices are:
+#
+#	startype = 1		Sol        (G2V-class main sequence)
+#	startype = 2		Ad Leo     (M-class, synthetic)
+#   startype = 3        GJ644
+#   startype = 4        HD128167
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Stellar flux at 1 AU. Examples:
+# 1366.0 W m-2		Sol today
+# 1024.5 W m-2		Sol today x 0.75 = weak early Sun
+# 18.462 W m-2		The feeble Gl581
+# 19.960 W m-2		Gl581 with e=0.38 orbital average
+Fat1AU = 1024.5
+
+## Tracer and aerosol options
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Gravitational sedimentation of tracers (KEEP FALSE FOR NOW) ?
+sedimentation = .false.
+
+## Other physics options
+## ~~~~~~~~~~~~~~~~~~~~~
+# call turbulent vertical diffusion ?
+calldifv = .true.
+# call convective adjustment ?
+calladj  = .true.
+# call thermal conduction in the soil ?
+callsoil = .true.
+
+#########################################
+## extra specific options for Early Mars
+#########################################
+
+## Tracer and aerosol options
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Fixed aerosol distributions?
+aerofixed     = .false.
+# Varying H2O cloud fraction?
+CLFvarying    = .false.
+# H2O cloud fraction?
+CLFfixval     = 0.5
+# number mixing ratio of CO2 ice particles
+Nmix_co2      = 100000.
+# number mixing ratio of water ice particles
+Nmix_h2o      = 100000.
+
+## Water options
+## ~~~~~~~~~~~~~
+# Model water cycle
+water         = .true.
+# Model water cloud formation
+watercond     = .true.
+# Model water precipitation (including coagulation etc.)
+waterrain     = .true.
+# WATER: Precipitation threshold (simple scheme only) ?
+rainthreshold = 0.0011
+# Include hydrology ?
+hydrology     = .true.
+# H2O snow (and ice) albedo ?
+albedosnow    = 0.5
+# Maximum sea ice thickness ?
+maxicethick   = 0.05
+# Freezing point of seawater (degrees C) ?
+Tsaldiff      = 0.0
+
+## CO2 options
+## ~~~~~~~~~~~
+# gas is non-ideal CO2 ?
+nonideal      = .false.
+# call CO2 condensation ?
+co2cond       = .true.
+# Set initial temperature profile to 1 K above CO2 condensation everywhere?
+nearco2cond   = .false.
+
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/callphys.tex.bak
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/callphys.tex.bak	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/callphys.tex.bak	(revision 1644)
@@ -0,0 +1,115 @@
+{\footnotesize
+\begin{verbatim}
+
+##General options
+##~~~~~~~~~~~~~~~
+#Run with or without tracer transport ?
+tracer=.false.
+
+#Diurnal cycle ?  if diurnal=False, diurnal averaged solar heating
+diurnal=.true.
+
+#Seasonal cycle ? if season=False, Ls stays constant, to value set in "start"
+season = .true.   
+
+#write some more output on the screen ?
+lwrite = .false.    
+
+#Save statistics in file "stats.nc" ?
+stats =.true.
+
+#Save EOF profiles in file "profiles" for Climate Database?
+calleofdump = .false.
+
+## Dust scenario. Used if the dust is prescribed (i.e. if tracer=F or active=F)
+## ~~~~~~~~~~~~~
+#  =1 Dust opt.deph read in startfi; =2 Viking scenario; =3 MGS scenario,
+#  =4 Mars Year 24 from TES assimilation (same as =24 for now)
+#  =24 Mars Year 24 from TES assimilation (ie: MCD reference case)
+#  =25 Mars Year 25 from TES assimilation (ie: a year with a global dust storm)
+#  =26 Mars Year 26 from TES assimilation
+iaervar = 24 
+# Dust vertical distribution: 
+# (=0: old distrib. (Pollack90), =1: top set by "topdustref",
+#  =2: Viking scenario; =3 MGS scenario)
+iddist  = 3
+# Dust top altitude (km). (Matters only if iddist=1)
+topdustref = 55.
+
+## Physical Parameterizations :
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# call radiative transfer ?
+callrad   = .true.
+# call NLTE radiative schemes ?   matters only if callrad=T
+callnlte = .true.
+# call CO2 NIR absorption ?   matters only if callrad=T
+callnirco2 = .true.
+# call turbulent vertical diffusion ?
+calldifv  = .true.
+# call convective adjustment ?
+calladj  = .true.
+# call CO2 condensation ?
+callcond =.true.
+# call thermal conduction in the soil ?
+callsoil = .true.
+# call Lott's gravity wave/subgrid topography scheme ?
+calllott  = .true.
+
+## Radiative transfer options :
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# the rad.transfer is computed every "iradia" physical timestep
+iradia    = 1
+# Output of the exchange coefficient mattrix ? for diagnostic only
+callg2d  = .false.
+# Rayleigh scattering : (should be .false. for now)
+rayleigh  = .false.
+
+## Tracer (dust water, ice and/or chemical species) options (used if tracer=T):
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# DUST: Transported dust ? (if >0, use 'dustbin' dust bins)
+dustbin    = 0
+# DUST: Radiatively active dust ? (matters if dustbin>0)
+active  = .false.
+# DUST: use mass and number mixing ratios to predict dust size ?
+# (must also have dustbin=1)
+doubleq   = .false.
+# DUST: lifted by GCM surface winds ?
+lifting = .false.
+# DUST: lifted by dust devils ?
+callddevil = .false.
+# DUST: Scavenging by CO2 snowfall ?
+scavenging = .false.
+# DUST/WATERICE: Gravitationnal sedimentation ?
+sedimentation = .false.
+# WATERICE: Radiatively active transported atmospheric water ice ?
+activice   = .false.
+# WATER: Compute water cycle
+water = .false.
+# WATER: current permanent caps at both poles. True IS RECOMMENDED
+#        (with .true., North cap is a source of water and South pole
+#         is a cold trap)
+caps  = .true.
+# PHOTOCHEMISTRY: include chemical species 
+photochem  = .false.
+
+## Thermospheric options (relevant if tracer=T) :
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# call thermosphere ?
+callthermos = .false.
+# WATER: included without cycle (only if water=.false.)
+thermoswater = .false.
+# call thermal conduction ? (only if callthermos=.true.)
+callconduct = .false.
+# call EUV heating ? (only if callthermos=.true.)
+calleuv=.false.
+# call molecular viscosity ? (only if callthermos=.true.)
+callmolvis = .false.
+# call molecular diffusion ? (only if callthermos=.true.)
+callmoldiff = .false.
+# call thermospheric photochemistry ? (only if callthermos=.true.)
+thermochem = .false.
+# date for solar flux calculation: (1985 < date < 2002)
+## (Solar min=1996.4 ave=1993.4 max=1990.6)
+solarcondate = 1993.4
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/ctl
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/ctl	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/ctl	(revision 1644)
@@ -0,0 +1,33 @@
+dset statsa2m4.dat
+title Run    0.000, day     0 to     0
+undef -9.99E33
+options yrev
+xdef    64 linear -180.0000   5.6250
+ydef    49 linear  -88.1633   3.6735
+zdef    25 levels
+ 0.9996389 0.9983609 0.9960319 0.9918210 0.9842223
+ 0.9706507 0.9467649 0.9058902 0.8391817 0.7385885
+ 0.6042400 0.4522929 0.3100970 0.1979461 0.1201197
+ 0.0704957 0.0404525 0.0228180 0.0126525 0.0068702
+ 0.0036093 0.0018078 0.0008212 0.0003282 0.0000653
+tdef    12 linear          0z1jan0001  2hr
+vars         18
+co2ice         0 99  mean CO2 ice cover (kg/m2)
+sdco2ice       0 99  stdv CO2 ice cover (kg/m2)
+emis           0 99  mean emissivity
+sdemis         0 99  stdv emissivity
+tsurf          0 99  mean surface temperature (K)
+sdtsurf        0 99  stdv surface temperature (K)
+ps             0 99  mean surface pressure (Pa)
+sdps           0 99  stdv surface pressure (Pa)
+t             25 99  mean temperature (K)
+sdt           25 99  stdv temperature (K)
+u             25 99  mean zonal velocity (m/s)
+sdu           25 99  stdv zonal velocity (m/s)
+v             25 99  mean meridional velocity (m/s)
+sdv           25 99  stdv meridional velocity (m/s)
+rho           25 99  mean density (kg/m3)
+sdrho         25 99  stdv density (kg/m3)
+q2            25 99  mean b/layer eddy ke (m2/s2)
+sdq2          25 99  stdv b/layer eddy ke (m2/s2)
+endvars
Index: /trunk/LMDZ.TITAN/DOC/input/ctl.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/ctl.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/ctl.tex	(revision 1644)
@@ -0,0 +1,37 @@
+\begin{verbatim}
+_______________________________________________________
+dset statsa2m4.dat
+title Run    0.000, day     0 to     0
+undef -9.99E33
+options yrev
+xdef    64 linear -180.0000   5.6250
+ydef    49 linear  -88.1633   3.6735
+zdef    25 levels
+ 0.9996389 0.9983609 0.9960319 0.9918210 0.9842223
+ 0.9706507 0.9467649 0.9058902 0.8391817 0.7385885
+ 0.6042400 0.4522929 0.3100970 0.1979461 0.1201197
+ 0.0704957 0.0404525 0.0228180 0.0126525 0.0068702
+ 0.0036093 0.0018078 0.0008212 0.0003282 0.0000653
+tdef    12 linear          0z1jan0001  2hr
+vars         18
+co2ice         0 99  mean CO2 ice cover (kg/m2)
+sdco2ice       0 99  stdv CO2 ice cover (kg/m2)
+emis           0 99  mean emissivity
+sdemis         0 99  stdv emissivity
+tsurf          0 99  mean surface temperature (K)
+sdtsurf        0 99  stdv surface temperature (K)
+ps             0 99  mean surface pressure (Pa)
+sdps           0 99  stdv surface pressure (Pa)
+t             25 99  mean temperature (K)
+sdt           25 99  stdv temperature (K)
+u             25 99  mean zonal velocity (m/s)
+sdu           25 99  stdv zonal velocity (m/s)
+v             25 99  mean meridional velocity (m/s)
+sdv           25 99  stdv meridional velocity (m/s)
+rho           25 99  mean density (kg/m3)
+sdrho         25 99  stdv density (kg/m3)
+q2            25 99  mean b/layer eddy ke (m2/s2)
+sdq2          25 99  stdv b/layer eddy ke (m2/s2)
+endvars
+-------------------------------------------------------
+\end{verbatim}
Index: /trunk/LMDZ.TITAN/DOC/input/diag_list
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/diag_list	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/diag_list	(revision 1644)
@@ -0,0 +1,90 @@
+netcdf diagfi1 {
+dimensions:
+	Time = UNLIMITED ; // (366 currently)
+	index = 100 ;
+	rlonu = 65 ;
+	latitude = 49 ;
+	longitude = 65 ;
+	rlatv = 48 ;
+	interlayer = 26 ;
+	altitude = 25 ;
+variables:
+	float Time(Time) ;
+		Time:long_name = "Time" ;
+		Time:units = "days since 0000-00-0 00:00:00" ;
+	float controle(index) ;
+		controle:title = "Parametres de controle" ;
+	float rlonu(rlonu) ;
+		rlonu:title = "Longitudes aux points u" ;
+	float latitude(latitude) ;
+		latitude:units = "degrees_north" ;
+		latitude:long_name = "North latitude" ;
+	float longitude(longitude) ;
+		longitude:long_name = "East longitude" ;
+		longitude:units = "degrees_east" ;
+	float altitude(altitude) ;
+		altitude:long_name = "pseudo-alt" ;
+		altitude:units = "km" ;
+		altitude:positive = "up" ;
+	float rlatv(rlatv) ;
+		rlatv:title = "Latitudes aux points v" ;
+	float aps(altitude) ;
+		aps:title = "hybrid pressure at midlayers" ;
+		aps:units = "h" ;
+	float bps(altitude) ;
+		bps:title = "hybrid sigma at midlayers" ;
+		bps:units = "h" ;
+	float ap(interlayer) ;
+		ap:title = "hybrid pressure at interlayers" ;
+		ap:units = "h" ;
+	float bp(interlayer) ;
+		bp:title = "hybrid sigma at interlayers" ;
+		bp:units = "h" ;
+	float cu(latitude, rlonu) ;
+		cu:title = "Coefficients de passage cov <--> nature" ;
+	float cv(rlatv, longitude) ;
+		cv:title = "Coefficients de passage cov <--> nature" ;
+	float aire(latitude, longitude) ;
+		aire:title = "Aires des mailles" ;
+	float phisinit(latitude, longitude) ;
+		phisinit:title = "Geopotentiel au sol init" ;
+	float mtot(Time, latitude, longitude) ;
+		mtot:title = "total mass of water vapor" ;
+		mtot:units = "kg/m2" ;
+	float icetot(Time, latitude, longitude) ;
+		icetot:title = "total mass of water ice" ;
+		icetot:units = "kg/m2" ;
+	float rice(Time, altitude, latitude, longitude) ;
+		rice:title = "ice radius" ;
+		rice:units = "meter" ;
+	float rave(Time, latitude, longitude) ;
+		rave:title = "Mean ice radius" ;
+		rave:units = "meter" ;
+	float co2ice(Time, latitude, longitude) ;
+		co2ice:title = "co2 ice thickness" ;
+		co2ice:units = "kg.m-2" ;
+	float tsurf(Time, latitude, longitude) ;
+		tsurf:title = "Surface temperature" ;
+		tsurf:units = "K" ;
+	float ps(Time, latitude, longitude) ;
+		ps:title = "surface pressure" ;
+		ps:units = "K" ;
+	float temp(Time, altitude, latitude, longitude) ;
+		temp:title = "temperature" ;
+		temp:units = "K" ;
+	float tau(Time, latitude, longitude) ;
+		tau:title = "tau" ;
+		tau:units = "t" ;
+	float q02(Time, altitude, latitude, longitude) ;
+		q02:title = "mix. ratio" ;
+		q02:units = "kg/kg" ;
+	float qsurf02(Time, latitude, longitude) ;
+		qsurf02:title = "qsurf" ;
+		qsurf02:units = "kg.m-2" ;
+	float q01(Time, altitude, latitude, longitude) ;
+		q01:title = "mix. ratio" ;
+		q01:units = "kg/kg" ;
+	float qsurf01(Time, latitude, longitude) ;
+		qsurf01:title = "qsurf" ;
+		qsurf01:units = "kg.m-2" ;
+}
Index: /trunk/LMDZ.TITAN/DOC/input/diag_list.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/diag_list.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/diag_list.tex	(revision 1644)
@@ -0,0 +1,84 @@
+{\footnotesize
+\begin{verbatim}
+netcdf diagfi {
+dimensions:
+        Time = UNLIMITED ; // (12 currently)
+        index = 100 ;
+        rlonu = 65 ;
+        latitude = 49 ;
+        longitude = 65 ;
+        rlatv = 48 ;
+        interlayer = 26 ;
+        altitude = 25 ;
+        subsurface_layers = 18 ;
+variables:
+        float Time(Time) ;
+                Time:long_name = "Time" ;
+                Time:units = "days since 0000-00-0 00:00:00" ;
+        float controle(index) ;
+                controle:title = "Control parameters" ;
+        float rlonu(rlonu) ;
+                rlonu:title = "Longitudes at u nodes" ;
+        float latitude(latitude) ;
+                latitude:units = "degrees_north" ;
+                latitude:long_name = "North latitude" ;
+        float longitude(longitude) ;
+                longitude:long_name = "East longitude" ;
+                longitude:units = "degrees_east" ;
+        float altitude(altitude) ;
+                altitude:long_name = "pseudo-alt" ;
+                altitude:units = "km" ;
+                altitude:positive = "up" ;
+        float rlatv(rlatv) ;
+                rlatv:title = "Latitudes at v nodes" ;
+        float aps(altitude) ;
+                aps:title = "hybrid pressure at midlayers" ;
+                aps:units = "Pa" ;
+        float bps(altitude) ;
+                bps:title = "hybrid sigma at midlayers" ;
+                bps:units = "" ;
+        float ap(interlayer) ;
+                ap:title = "hybrid pressure at interlayers" ;
+                ap:units = "Pa" ;
+        float bp(interlayer) ;
+                bp:title = "hybrid sigma at interlayers" ;
+                bp:units = "" ;
+        float soildepth(subsurface_layers) ;
+                soildepth:long_name = "Soil mid-layer depth" ;
+                soildepth:units = "m" ;
+                soildepth:positive = "down" ;
+        float cu(latitude, rlonu) ;
+                cu:title = "Conversion coefficients cov <--> natural" ;
+        float cv(rlatv, longitude) ;
+                cv:title = "Conversion coefficients cov <--> natural" ;
+        float aire(latitude, longitude) ;
+                aire:title = "Mesh area" ;
+        float phisinit(latitude, longitude) ;
+                phisinit:title = "Geopotential at the surface" ;
+        float emis(Time, latitude, longitude) ;
+                emis:title = "Surface emissivity" ;
+                emis:units = "w.m-1" ;
+        float tsurf(Time, latitude, longitude) ;
+                tsurf:title = "Surface temperature" ;
+                tsurf:units = "K" ;
+        float ps(Time, latitude, longitude) ;
+                ps:title = "surface pressure" ;
+                ps:units = "Pa" ;
+        float co2ice(Time, latitude, longitude) ;
+                co2ice:title = "co2 ice thickness" ;
+                co2ice:units = "kg.m-2" ;
+        float mtot(Time, latitude, longitude) ;
+                mtot:title = "total mass of water vapor" ;
+                mtot:units = "kg/m2" ;
+        float icetot(Time, latitude, longitude) ;
+                icetot:title = "total mass of water ice" ;
+                icetot:units = "kg/m2" ;
+        float tauTES(Time, latitude, longitude) ;
+                tauTES:title = "tau abs 825 cm-1" ;
+                tauTES:units = "" ;
+        float h2o_ice_s(Time, latitude, longitude) ;
+                h2o_ice_s:title = "surface h2o_ice" ;
+                h2o_ice_s:units = "kg.m-2" ;
+}
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/dyn_cntl
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/dyn_cntl	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/dyn_cntl	(revision 1644)
@@ -0,0 +1,21 @@
+tab_cntrl(1) = float(iim)       ! nombre de points en longitude
+tab_cntrl(2) = float(jjm)       ! nombre de points en latitude
+tab_cntrl(3) = float(llm)       ! nombre de couches
+tab_cntrl(4) = float(idayref)   ! jour 0
+tab_cntrl(5) = rad     ! rayon de mars(m) ~3397200
+tab_cntrl(6) = omeg    ! vitesse de rotation (rad.s-1)
+tab_cntrl(7) = g       ! gravite (m.s-2) ~3.72
+tab_cntrl(8) = mugaz   ! Masse molaire de l'atm (g.mol-1) ~43.49
+tab_cntrl(9) = kappa   ! = r/cp  ~0.256793 (=rcp dans physique)
+tab_cntrl(10) = daysec ! duree du sol (s)  ~88775
+tab_cntrl(11) = dtvr   ! pas de temps de la dynamique (s)
+ 
+tab_cntrl(12) = etot0  ! energie totale    !
+tab_cntrl(13) = ptot0  ! pression totalei   !    variables
+tab_cntrl(14) = ztot0  ! enstrophie totale   !  de controle
+tab_cntrl(15) = stot0  ! enthalpie totale   !    globales
+tab_cntrl(16) = ang0   ! moment cinetique  !
+tab_cntrl(17) = clon   ! longitude en degres du centre du zoom   
+tab_cntrl(18) = clat   ! latitude en degres du centre du zoom
+tab_cntrl(19) = alphax ! facteur de grossissement du zoom,selon longitude
+tab_cntrl(20) = alphay ! facteur de grossissement du zoom ,selon latitude
Index: /trunk/LMDZ.TITAN/DOC/input/dyn_cntl.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/dyn_cntl.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/dyn_cntl.tex	(revision 1644)
@@ -0,0 +1,32 @@
+{\footnotesize
+\begin{verbatim}
+       tab_cntrl(1)  = FLOAT(iim) ! number of nodes along longitude
+       tab_cntrl(2)  = FLOAT(jjm) ! number of nodes along latitude
+       tab_cntrl(3)  = FLOAT(llm) ! number of atmospheric layers
+       tab_cntrl(4)  = FLOAT(idayref) ! initial day 
+       tab_cntrl(5)  = rad   ! radius of the planet
+       tab_cntrl(6)  = omeg  ! rotation of the planet (rad/s)
+       tab_cntrl(7)  = g     ! gravity (m/s2) ~3.72 for Mars
+       tab_cntrl(8)  = cpp 
+       tab_cntrl(9) = kappa   ! = r/cp
+       tab_cntrl(10) = daysec ! lenght of a sol (s) ~88775
+       tab_cntrl(11) = dtvr   ! dynamical time step (s)
+       tab_cntrl(12) = etot0  ! total energy
+       tab_cntrl(13) = ptot0  ! total pressure
+       tab_cntrl(14) = ztot0  ! total enstrophy
+       tab_cntrl(15) = stot0  ! total enthalpy
+       tab_cntrl(16) = ang0   ! total angular momentum
+       tab_cntrl(17) = pa     
+       tab_cntrl(18) = preff  ! reference pressure (Pa)
+       tab_cntrl(19)  = clon  ! longitude of center of zoom
+       tab_cntrl(20)  = clat  ! latitude of center of zoom
+       tab_cntrl(21)  = grossismx ! zooming factor, along longitude
+       tab_cntrl(22)  = grossismy ! zooming factor, along latitude
+
+       tab_cntrl(24) = dzoomx ! extention (in longitude) of zoom
+       tab_cntrl(25) = dzoomy ! extention (in latitude) of zoom
+
+       tab_cntrl(27) = taux ! stiffness factor of zoom in longitude
+       tab_cntrl(28) = tauy ! stiffness factor of zoom in latitude
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/dyn_head
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/dyn_head	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/dyn_head	(revision 1644)
@@ -0,0 +1,11 @@
+aire: Aires des mailles
+cv: Coefficients de passage cov <--> naturel
+cu: Coefficients de passage cov <--> naturel
+sig_s: sigmas aux niveaux s
+s: Niveaux s
+sig: Niveaux sigmas
+rlatv: Latitudes aux points v
+rlonv: Longitudes aux points v
+rlatu: Latitudes aux points u
+rlonu: Longitudes aux points u
+controle: Tableau des parametres du run
Index: /trunk/LMDZ.TITAN/DOC/input/dyn_head.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/dyn_head.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/dyn_head.tex	(revision 1644)
@@ -0,0 +1,15 @@
+\begin{verbatim}
+_______________________________________________________
+aire: Aires des mailles
+cv: Coefficients de passage cov <--> naturel
+cu: Coefficients de passage cov <--> naturel
+sig_s: sigmas aux niveaux s
+s: Niveaux s
+sig: Niveaux sigmas
+rlatv: Latitudes aux points v
+rlonv: Longitudes aux points v
+rlatu: Latitudes aux points u
+rlonu: Longitudes aux points u
+controle: Tableau des parametres du run
+-------------------------------------------------------
+\end{verbatim}
Index: /trunk/LMDZ.TITAN/DOC/input/dyn_list
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/dyn_list	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/dyn_list	(revision 1644)
@@ -0,0 +1,19 @@
+phis: geopotentiel au sol
+pext: pression extensive
+q01: traceur
+h: temperature potentielle
+vcov: vents v covariants
+ucov: vents u covariants
+temps: temps simule
+phisinit: Geopotentiel au sol init
+aire: Aires des mailles
+cv: Coefficients de passage cov <--> naturel
+cu: Coefficients de passage cov <--> naturel
+sig_s: sigmas aux niveaux s
+s: Niveaux s
+sig: Niveaux sigmas
+rlatv: Latitudes aux points v
+rlonv: Longitudes aux points v
+rlatu: Latitudes aux points u
+rlonu: Longitudes aux points u
+controle: Tableau des parametres du run
Index: /trunk/LMDZ.TITAN/DOC/input/dyn_list.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/dyn_list.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/dyn_list.tex	(revision 1644)
@@ -0,0 +1,73 @@
+{\footnotesize
+\begin{verbatim}
+netcdf start {
+dimensions:
+        index = 100 ;
+        rlonu = 33 ;
+        latitude = 25 ;
+        longitude = 33 ;
+        rlatv = 24 ;
+        altitude = 18 ;
+        interlayer = 19 ;
+        Time = UNLIMITED ; // (1 currently)
+variables:
+        float controle(index) ;
+                controle:title = "Parametres de controle" ;
+        float rlonu(rlonu) ;
+                rlonu:title = "Longitudes des points U" ;
+        float rlatu(latitude) ;
+                rlatu:title = "Latitudes des points U" ;
+        float rlonv(longitude) ;
+                rlonv:title = "Longitudes des points V" ;
+        float rlatv(rlatv) ;
+                rlatv:title = "Latitudes des points V" ;
+        float ap(interlayer) ;
+                ap:title = "Coef A: hybrid pressure levels" ;
+        float bp(interlayer) ;
+                bp:title = "Coef B: hybrid sigma levels" ;
+        float aps(altitude) ;
+                aps:title = "Coef AS: hybrid pressure at midlayers" ;
+        float bps(altitude) ;
+                bps:title = "Coef BS: hybrid sigma at midlayers" ;
+        float presnivs(altitude) ;
+        float latitude(latitude) ;
+                latitude:units = "degrees_north" ;
+                latitude:long_name = "North latitude" ;
+        float longitude(longitude) ;
+                longitude:long_name = "East longitude" ;
+                longitude:units = "degrees_east" ;
+        float altitude(altitude) ;
+                altitude:long_name = "pseudo-alt" ;
+                altitude:units = "km" ;
+                altitude:positive = "up" ;
+        float cu(latitude, rlonu) ;
+                cu:title = "Coefficient de passage pour U" ;
+        float cv(rlatv, longitude) ;
+                cv:title = "Coefficient de passage pour V" ;
+        float aire(latitude, longitude) ;
+                aire:title = "Aires de chaque maille" ;
+        float phisinit(latitude, longitude) ;
+                phisinit:title = "Geopotentiel au sol" ;
+        float Time(Time) ;
+                Time:title = "Temps de simulation" ;
+                Time:units = "days since    1-01-01 00:00:00" ;
+        float ucov(Time, altitude, latitude, rlonu) ;
+                ucov:title = "Vitesse U" ;
+        float vcov(Time, altitude, rlatv, longitude) ;
+                vcov:title = "Vitesse V" ;
+        float teta(Time, altitude, latitude, longitude) ;
+                teta:title = "Temperature" ;
+        float h2o_ice(Time, altitude, latitude, longitude) ;
+                h2o_ice:title = "Traceur h2o_ice" ;
+        float h2o_vap(Time, altitude, latitude, longitude) ;
+                h2o_vap:title = "Traceur h2o_vap" ;
+        float masse(Time, altitude, latitude, longitude) ;
+                masse:title = "C est quoi ?" ;
+        float ps(Time, latitude, longitude) ;
+                ps:title = "Pression au sol" ;
+
+// global attributes:
+                :title = "Dynamic start file" ;
+}
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/esasig.def
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/esasig.def	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/esasig.def	(revision 1644)
@@ -0,0 +1,4 @@
+10  atmospheric scale height (km) (used as a reference only)
+80  maximum altitude (km)
+.01 thikness of the first layer (km)
+2.  number of layer for "sponge layer" at the top
Index: /trunk/LMDZ.TITAN/DOC/input/esasig.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/esasig.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/esasig.tex	(revision 1644)
@@ -0,0 +1,8 @@
+\begin{verbatim}
+_______________________________________________________
+10  atmospheric scale height (km) (used as a reference only)
+80  maximum altitude (km)
+.01 thikness of the first layer (km)
+2.  number of layer for "sponge layer" at the top
+-------------------------------------------------------
+\end{verbatim}
Index: /trunk/LMDZ.TITAN/DOC/input/ex.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/ex.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/ex.tex	(revision 1644)
@@ -0,0 +1,13 @@
+\documentstyle[a4,10pt]{article}
+\begin{document}
+\pagestyle{empty}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{verbatim}
+
+
+\end{verbatim}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\end{document}
+
Index: /trunk/LMDZ.TITAN/DOC/input/fi_cntl
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/fi_cntl	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/fi_cntl	(revision 1644)
@@ -0,0 +1,46 @@
+c Info sur la grille physique
+      tab_cntrl(1) = float(ngridmx)  ! nombre de points de la grille physique
+      tab_cntrl(2) = float(nlayermx) ! nombre de couches
+      tab_cntrl(3) = float(idayref)  ! jour 0
+ 
+c Info sur la Planete Mars pour la dynamique et la physique
+      tab_cntrl(5) = rad      ! rayon de mars(m) ~3397200
+      tab_cntrl(6) = omeg     ! vitesse de rotation (rad.s-1)
+      tab_cntrl(7) = g        ! gravite (m.s-2) ~3.72
+      tab_cntrl(8) = mugaz    ! Masse molaire de l'atm (g.mol-1) ~43.49
+      tab_cntrl(9) = rcp      !  = r/cp  ~0.256793 (=kappa dans dynamique)
+      tab_cntrl(10) = daysec  ! duree du sol (s)  ~88775
+ 
+      tab_cntrl(11) = dtphys  ! pas de temps de la physique 
+      tab_cntrl(12) = 0.
+      tab_cntrl(13) = 0.
+ 
+c Info sur la Planete Mars pour la physique uniquement
+      tab_cntrl(14) = year_day  ! duree de l'annee (sols) ~668.6
+      tab_cntrl(15) = periheli  ! dist.min. soleil-mars (Mkm) ~206.66
+      tab_cntrl(16) = aphelie   ! dist.max. soleil-mars (Mkm) ~249.22
+      tab_cntrl(17) = peri_day  ! date du perihelie (sols depuis printemps)
+      tab_cntrl(18) = obliquit  ! Obliquite de la planete (deg) ~23.98
+ 
+c Couche limite et Turbulence
+      tab_cntrl(19) = z0        ! surface roughness (m) ~0.01
+      tab_cntrl(20) = lmixmin   ! longueur de melange ~100
+      tab_cntrl(21) = emin_turb ! energie minimale ~1.e-8
+ 
+c propriete optiques des calottes et emissivite du sol
+      tab_cntrl(22) = albedice(1)  ! Albedo calotte nord ~0.5
+      tab_cntrl(23) = albedice(2)  ! Albedo calotte sud ~0.5
+      tab_cntrl(24) = emisice(1)   ! Emissivite calotte nord ~0.95
+      tab_cntrl(25) = emisice(2)   ! Emissivite calotte sud ~0.95
+      tab_cntrl(26) = emissiv      ! Emissivite du sol martien ~.95
+      tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north)
+      tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south)
+      tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north)
+      tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south)
+ 
+c Proprietes des poussiere aerosol
+      tab_cntrl(27) = tauvis      ! profondeur optique visible moyenne
+ 
+      tab_cntrl(28) = 0.
+      tab_cntrl(29) = 0.
+      tab_cntrl(30) = 0.
Index: /trunk/LMDZ.TITAN/DOC/input/fi_cntl.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/fi_cntl.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/fi_cntl.tex	(revision 1644)
@@ -0,0 +1,54 @@
+{\footnotesize
+\begin{verbatim}
+c Informations on the physics grid
+      tab_cntrl(1) = float(ngridmx)  ! number of nodes on physics grid
+      tab_cntrl(2) = float(nlayermx) ! number of atmospheric layers
+      tab_cntrl(3) = day_ini + int(time)         ! initial day 
+      tab_cntrl(4) = time -int(time)            ! initiale time of day
+
+c Informations about Mars, used by dynamics and physics
+      tab_cntrl(5) = rad      ! radius of Mars (m) ~3397200
+      tab_cntrl(6) = omeg     ! rotation rate (rad.s-1)
+      tab_cntrl(7) = g        ! gravity (m.s-2) ~3.72
+      tab_cntrl(8) = mugaz    ! Molar mass of the atmosphere (g.mol-1) ~43.49
+      tab_cntrl(9) = rcp      !  = r/cp  ~0.256793 (=kappa dans dynamique)
+      tab_cntrl(10) = daysec  ! length of a sol (s)  ~88775
+
+      tab_cntrl(11) = phystep  ! time step in the physics
+      tab_cntrl(12) = 0.
+      tab_cntrl(13) = 0.
+
+c Informations about Mars, only for physics
+      tab_cntrl(14) = year_day  ! length of year (sols) ~668.6
+      tab_cntrl(15) = periheli  ! min. Sun-Mars distance (Mkm) ~206.66
+      tab_cntrl(16) = aphelie   ! max. SUn-Mars distance (Mkm) ~249.22
+      tab_cntrl(17) = peri_day  ! date of perihelion (sols since N. spring)
+      tab_cntrl(18) = obliquit  ! Obliquity of the planet (deg) ~23.98
+
+c Boundary layer and turbulence
+      tab_cntrl(19) = z0        ! surface roughness (m) ~0.01
+      tab_cntrl(20) = lmixmin   ! mixing length ~100
+      tab_cntrl(21) = emin_turb ! minimal energy ~1.e-8
+
+c Optical properties of polar caps and ground emissivity
+      tab_cntrl(22) = albedice(1)  ! Albedo of northern cap ~0.5
+      tab_cntrl(23) = albedice(2)  ! Albedo of southern cap ~0.5
+      tab_cntrl(24) = emisice(1)   ! Emissivity of northern cap ~0.95
+      tab_cntrl(25) = emisice(2)   ! Emissivity of southern cap ~0.95
+      tab_cntrl(26) = emissiv      ! Emissivity of martian soil ~.95
+      tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north)
+      tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south)
+      tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north)
+      tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south)
+
+c dust aerosol properties
+      tab_cntrl(27) = tauvis      ! mean visible optical depth
+
+      tab_cntrl(28) = 0. 
+      tab_cntrl(29) = 0.
+      tab_cntrl(30) = 0.
+
+! Soil properties:
+      tab_cntrl(35) = volcapa ! soil volumetric heat capacity
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/fi_head
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/fi_head	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/fi_head	(revision 1644)
@@ -0,0 +1,8 @@
+area: Aires des mailles
+lati: Latitudes
+long: Longitudes
+surf_coor: Indice vertical sol
+vert2_coor: Indice vertical (bords)
+vert_coor: Indice vertical
+hor_coor: Indice horizontal
+controle: Tableau des parametres du run
Index: /trunk/LMDZ.TITAN/DOC/input/fi_head.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/fi_head.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/fi_head.tex	(revision 1644)
@@ -0,0 +1,14 @@
+{\footnotesize
+\begin{verbatim}
+_______________________________________________________
+area: Aires des mailles
+lati: Latitudes
+long: Longitudes
+surf_coor: Indice vertical sol
+vert2_coor: Indice vertical (bords)
+vert_coor: Indice vertical
+hor_coor: Indice horizontal
+controle: Tableau des parametres du run
+-------------------------------------------------------
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/fi_list
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/fi_list	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/fi_list	(revision 1644)
@@ -0,0 +1,22 @@
+q2: pbl wind variance
+emis: surface emissivity
+tsoil: Soil temperature
+tsurf: Surface temperature
+co2ice: CO2 ice cover
+temps: temps simule
+zthe: Relief: parametre theta
+zgam: Relief: parametre gamma
+zsig: Relief: parametre sigma
+zstd: ecartype du relief
+zmea: Relief moyen
+inertiedat: Inertie thermique du sol
+albedodat: Albedo du sol nu
+phisfi: Geopotentiel au sol init
+area: Aires des mailles
+lati: Latitudes
+long: Longitudes
+surf_coor: Indice vertical sol
+vert2_coor: Indice vertical (bords)
+vert_coor: Indice vertical
+hor_coor: Indice horizontal
+controle: Tableau des parametres du run
Index: /trunk/LMDZ.TITAN/DOC/input/fi_list.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/fi_list.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/fi_list.tex	(revision 1644)
@@ -0,0 +1,54 @@
+{\footnotesize
+\begin{verbatim}
+netcdf startfi {
+dimensions:
+        index = 100 ;
+        physical_points = 738 ;
+        subsurface_layers = 18 ;
+        nlayer_plus_1 = 19 ;
+        number_of_advected_fields = 3 ;
+variables:
+        float controle(index) ;
+                controle:title = "Control parameters" ;
+        float soildepth(subsurface_layers) ;
+                soildepth:title = "Soil mid-layer depth" ;
+        float longitude(physical_points) ;
+                longitude:title = "Longitudes of physics grid" ;
+        float latitude(physical_points) ;
+                latitude:title = "Latitudes of physics grid" ;
+        float area(physical_points) ;
+                area:title = "Mesh area" ;
+        float phisfi(physical_points) ;
+                phisfi:title = "Geopotential at the surface" ;
+        float albedodat(physical_points) ;
+                albedodat:title = "Albedo of bare ground" ;
+        float ZMEA(physical_points) ;
+                ZMEA:title = "Relief: mean relief" ;
+        float ZSTD(physical_points) ;
+                ZSTD:title = "Relief: standard deviation" ;
+        float ZSIG(physical_points) ;
+                ZSIG:title = "Relief: sigma parameter" ;
+        float ZGAM(physical_points) ;
+                ZGAM:title = "Relief: gamma parameter" ;
+        float ZTHE(physical_points) ;
+                ZTHE:title = "Relief: theta parameter" ;
+        float co2ice(physical_points) ;
+                co2_ice:title = "CO2 ice cover" ;
+        float inertiedat(subsurface_layers, physical_points) ;
+                inertiedat:title = "Soil thermal inertia" ;
+        float tsurf(physical_points) ;
+                tsurf:title = "Surface temperature" ;
+        float tsoil(subsurface_layers, physical_points) ;
+                tsoil:title = "Soil temperature" ;
+        float emis(physical_points) ;
+                emis:title = "Surface emissivity" ;
+        float q2(nlayer_plus_1, physical_points) ;
+                q2:title = "pbl wind variance" ;
+        float h2o_ice(physical_points) ;
+                h2o_ice:title = "tracer on surface" ;
+
+// global attributes:
+                :title = "Physics start file" ;
+}
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex	(revision 1644)
@@ -0,0 +1,129 @@
+{\footnotesize
+\begin{verbatim}
+## Orbit / general options
+## ~~~~~~~~~~~~~~~~~~~~~~~
+# Run with or without tracer transport ?
+tracer    = .true.
+# Diurnal cycle ?  if diurnal=false, diurnally averaged solar heating
+diurnal   = .true.
+# Seasonal cycle ? if season=false, Ls stays constant, to value set in "start"
+season    = .true.
+# Tidally resonant orbit ? must have diurnal=false, correct rotation rate in newstart
+tlocked   = .false.
+# Tidal resonance ratio ? ratio T_orbit to T_rotation
+nres      = 10
+# Write some more output on the screen ?
+lwrite    = .false.
+# Save statistics in file "stats.nc" ?
+callstats = .true.
+# Test energy conservation of model physics ?
+enertest  = .true.
+
+## Radiative transfer options
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# call radiative transfer?
+callrad    = .true.
+# the rad. transfer is computed every "iradia" physical timestep
+iradia     = 4
+# call multilayer correlated-k radiative transfer ?
+corrk      = .true.
+# folder in which correlated-k data is stored ?
+corrkdir   = CO2_H2Ovar
+# call visible gaseous absorption in radiative transfer ?
+callgasvis = .true.
+# Include Rayleigh scattering in the visible ?
+rayleigh   = .true.
+# Characteristic planetary equilibrium (black body) temperature
+# This is used only in the aerosol radiative transfer setup. (see aerave.F)
+tplanet    = 215.
+# Output spectral OLR in 1D/3D?
+specOLR    = .false.
+# Output global radiative balance in file 'rad_bal.out' - slow for 1D!!
+meanOLR    = .true.
+# Variable gas species: Radiatively active ?
+varactive  = .true.
+# Variable gas species: Fixed vertical distribution ?
+varfixed   = .false.
+# Variable gas species: Saturation percentage value at ground ?
+satval     = 0.0
+
+## Star type
+## ~~~~~~~~~
+startype = 1
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# The choices are:
+#
+#	    startype = 1		Sol        (G2V-class main sequence)
+#    	startype = 2		Ad Leo     (M-class, synthetic)
+#       startype = 3        GJ644
+#       startype = 4        HD128167
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Stellar flux at 1 AU. Examples:
+# 1366.0 W m-2		Sol today
+# 1024.5 W m-2		Sol today x 0.75 = weak early Sun
+# 18.462 W m-2		The feeble Gl581
+# 19.960 W m-2		Gl581 with e=0.38 orbital average
+Fat1AU = 1024.5
+
+## Tracer and aerosol options
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Gravitational sedimentation of tracers (just H2O ice for now) ?
+sedimentation = .false.
+
+## Other physics options
+## ~~~~~~~~~~~~~~~~~~~~~
+# call turbulent vertical diffusion ?
+calldifv = .true.
+# call convective adjustment ?
+calladj  = .true.
+# call thermal conduction in the soil ?
+callsoil = .true.
+
+#########################################################################
+## extra non-standard definitions for Early Mars
+#########################################################################
+
+## Tracer and aerosol options
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Fixed aerosol distributions?
+aerofixed     = .false.
+# Varying H2O cloud fraction?
+CLFvarying    = .false.
+# H2O cloud fraction?
+CLFfixval     = 1.0
+# number mixing ratio of CO2 ice particles
+Nmix_co2      = 100000.
+# number mixing ratio of water ice particles
+Nmix_h2o      = 100000.
+
+## Water options
+## ~~~~~~~~~~~~~
+# Model water cycle
+water         = .true.
+# Model water cloud formation
+watercond     = .true.
+# Model water precipitation (including coagulation etc.)
+waterrain     = .true.
+# WATER: Precipitation threshold (simple scheme only) ?
+rainthreshold = 0.0011
+# Include hydrology ?
+hydrology     = .true.
+# H2O snow (and ice) albedo ?
+albedosnow    = 0.5
+# Maximum sea ice thickness ?
+maxicethick   = 0.05
+# Freezing point of seawater (degrees C) ?
+Tsaldiff      = 0.0
+# Evolve surface water sources ?
+sourceevol    = .true.
+
+## CO2 options
+## ~~~~~~~~~~~
+# gas is non-ideal CO2 ?
+nonideal      = .false.
+# call CO2 condensation ?
+co2cond       = .true.
+# Set initial temperature profile to 1 K above CO2 condensation everywhere?
+nearco2cond   = .false.
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex.bak
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex.bak	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex.bak	(revision 1644)
@@ -0,0 +1,29 @@
+{\footnotesize
+\begin{verbatim}                                                                               
+## Tracer (dust water, ice and/or chemical species) options (used if tracer=T):
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# DUST: Transported dust ? (if >0, use 'dustbin' dust bins)
+dustbin    = 0
+# DUST: Radiatively active dust ? (matters if dustbin>0)
+active  = .false.
+# DUST: use mass and number mixing ratios to predict dust size ?
+# (must also have dustbin=1)
+doubleq   = .false.
+# DUST: lifted by GCM surface winds ?
+lifting = .false.
+# DUST: lifted by dust devils ?
+callddevil = .false.
+# DUST: Scavenging by CO2 snowfall ?
+scavenging = .false.
+# DUST/WATERICE: Gravitationnal sedimentation ?
+sedimentation = .true.
+# WATERICE: Radiatively active transported atmospheric water ice ?
+activice   = .false.
+# WATER: Compute water cycle
+water = .true.
+# WATER: current permanent caps at both poles. True IS RECOMMENDED
+#        (with .true., North cap is a source of water and South pole
+#         is a cold trap)
+caps  = .true.
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex.sav
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex.sav	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/h2o_list.tex.sav	(revision 1644)
@@ -0,0 +1,34 @@
+{\footnotesize
+\begin{verbatim}
+
+
+## Tracer (dust water, ice and/or chemical species) options (used if tracer=T):
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# DUST: Transported dust ? (if >0, use 'dustbin' dust bins)
+dustbin    = 0
+# DUST: Radiatively active dust ? (matters if dustbin>0)
+active  = .false.
+# DUST: use mass and number mixing ratios to predict dust size ?
+# (must also have dustbin=1)
+doubleq   = .false.
+# DUST: lifted by GCM surface winds ?
+lifting = .false.
+# DUST: lifted by dust devils ?
+callddevil = .false.
+# DUST: Scavenging by CO2 snowfall ?
+scavenging = .false.
+# DUST/WATERICE: Gravitationnal sedimentation ?
+sedimentation = .true.
+# WATERICE: Radiatively active transported atmospheric water ice ?
+activice   = .false.
+# WATER: Compute water cycle
+water = .true.
+# WATER: current permanent caps at both poles. True IS RECOMMENDED
+#        (with .true., North cap is a source of water and South pole
+#         is a cold trap)
+caps  = .true.
+
+
+
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/hist_list
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/hist_list	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/hist_list	(revision 1644)
@@ -0,0 +1,19 @@
+ps: pression extensive moyennee 
+q1:  
+T: temperature moyennees 
+v: vents v naturels moyennes 
+u: vents u naturels moyennees 
+dttot: periode moyennee 
+temps: temps simule 
+phisinit: Geopotentiel au sol init 
+aire: Aires des mailles 
+cv: Coefficients de passage cov <--> naturel 
+cu: Coefficients de passage cov <--> naturel 
+sig_s: sigmas aux niveaux s 
+s: Niveaux s 
+sig: Niveaux sigmas 
+rlatv: Latitudes aux points v 
+rlonv: Longitudes aux points v 
+rlatu: Latitudes aux points u 
+rlonu: Longitudes aux points u 
+controle: Tableau des parametres du run 
Index: /trunk/LMDZ.TITAN/DOC/input/hist_list.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/hist_list.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/hist_list.tex	(revision 1644)
@@ -0,0 +1,22 @@
+\begin{verbatim}
+_______________________________________________________
+ps: pression de surface moyennee 
+q1: quantite de traceur 
+T: temperature moyennees 
+v: vents v naturels moyennes 
+u: vents u naturels moyennees 
+dttot: periode moyennee 
+temps: temps simule 
+phisinit: Geopotentiel au sol init 
+aire: Aires des mailles 
+cv: Coefficients de passage cov <--> naturel 
+cu: Coefficients de passage cov <--> naturel 
+ap: Facteur de coordonnees hybrides
+bp: Facteur de coordonnees hybrides ou niveau sigma
+rlatv: Latitudes aux points v 
+rlonv: Longitudes aux points v 
+rlatu: Latitudes aux points u 
+rlonu: Longitudes aux points u 
+controle: Tableau des parametres du run 
+-------------------------------------------------------
+\end{verbatim}
Index: /trunk/LMDZ.TITAN/DOC/input/makegcm
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/makegcm	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/makegcm	(revision 1644)
@@ -0,0 +1,464 @@
+#!/bin/csh
+
+# penser a mettre le -autopar pour le -O (optimisation) pour PARALLEL 2
+setenv PARALLEL 2
+
+# path a changer contenant les sources et les objets du modele
+if ( ! $?LMDGCM ) then
+   echo You must initialize the variable LMDGCM in your environnement
+   echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc
+   exit
+endif
+if ( ! $?LIBOGCM ) then
+   set LIBOGCM=$LMDGCM/libo
+endif
+if ( ! $?DRSDIR ) then
+   echo You must initialize the variable DRSDIR in your environnement
+   echo for instance: "setenv DRSDIR /usr/myself/drs" in .cshrc
+   exit
+endif
+set model=$LMDGCM
+set libo=$LIBOGCM
+
+########################################################################
+#  Les differentes platformes reconnues
+########################################################################
+set HP=0
+set IBM=0
+set SUN=0
+set CRAY=0
+if ( `uname` == HP-UX ) then
+   set machine=HP
+   set HP=1
+else if (`uname` == SunOS ) then
+   set machine=SUN
+   set SUN=1
+else if ( `uname` == AIX ) then
+   set machine=IBM
+   set IBM=1
+else if ( `hostname` == atlas || `hostname` == axis ) then
+   set machine=CRAY
+   set CRAY=1
+else
+   echo Vous travaillez sur une machine non prevue par le reglement
+   exit
+endif
+
+if $CRAY then
+set libo=$WORKDIR/libo
+endif
+if ( ! -d $libo )  then
+   mkdir $libo
+endif
+set drs=$DRSDIR
+
+########################################################################
+# options par defaut pour la commande make
+########################################################################
+
+echo model $model
+set dim="32x24x25"
+set physique=mars
+set phys="PHYS=mars"
+set include='-I$(LIBF)/grid -I$(LIBF)/dyn3d -I$(LIBF)/bibio -I. '
+set ntrac = 0
+set filtre=filtrez
+set grille=reg
+
+set cray=""
+set dyn=
+set opt_link=""
+set adjnt=""
+set opt_dep=""
+
+########################################################################
+#  Optimisations par defaut suivant les machines
+########################################################################
+
+set libf=$model/libf
+set localdir="LOCAL_DIR=`pwd`"
+cd $model
+if $HP then
+   set optim=" +U77 -O -K +E1 "
+else if $SUN then
+   set optim=" -fast -autopar"
+#  set optim=" -Ztha -fast -autopar"
+#  set optim=" -C -g -Xlist"
+#   set optim=" -fast"
+else if $IBM then
+   set optim=" -O3 -qtune=pwr2 -qarch=pwr2"
+else
+   set optim=""
+endif
+
+if ( ! $CRAY ) then
+set nomlib=$machine
+endif
+
+
+########################################################################
+# lecture des options de mymake
+########################################################################
+
+top:
+if ($#argv > 0) then
+    switch ($1:q)
+
+    case -h:
+
+########################################################################
+# Manuel en ligne
+########################################################################
+more <<eod
+
+
+makegcm [Options] prog
+
+
+
+
+Par default, la commande makegcm:
+---------------------------------
+
+1. compile une serie de sous programmes se trouvant dans des sous-repertoires
+de $LMDGCM/libf
+2. Ensuite, makegcm compile le programme prog.f se trouvant par default sur
+$LMDGCM/libf/dyn3d et effectue le lien avec l'ensemble des librairies.
+
+La commande makegcm est faite pour permettre de gerer en parallele des
+versions differentes du modele, compilees avec des options de compilation
+et des dimensions differentes sans avoir a chaque fois a recompiler tout le
+modele.
+
+Les librairies FORTRAN sont stoquees sur le directory $LIBOGCM.
+
+
+OPTIONS:
+--------
+
+Les options suivantes peuvent etre definies soit par defaut en editant le
+"script" makegcm, soit en interactif:
+
+-d imxjmxlm  ou im, jm, et lm sont resp. le nombre de longitudes, latitudes
+             et couches verticales. 
+
+-t ntrac   selectionne le nombre de traceur advectes par la dynamique.
+           Dans les versions courantes du modele terrestre on a par exemple
+           ntrac=2 pour l'eau vapeur et liquide
+
+             L'effet des options -d et -t est d'ecraser le fichier 
+             $LMDGCM/libf/grid/dimensions.h
+             qui contient sous forme de 4 PARAMETER FORTRAN les 3 dimensions
+             de la grille horizontale im, jm, lm plus le nombre de traceurs
+             advectes passivement par la dynamique ntrac, par un nouveu fichier
+             $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac
+             Si ce fichier n'existe pas encore, il est cree par le script
+             $LMDGCM/libf/grid/dimension/makdim
+
+-p PHYS    pour selectionner le jeu de parametrisations physiques avec
+           lequel on veut compiler le modele.
+           Le modele sera alors compile en prenant les sources des
+           parametrisations physiques dans le repertoire:
+            $LMDGCM/libf/phyPHYS
+
+-g grille  selectionne le type de grille qu'on veut utiliser.
+           L'effet de cette option est d'ecraser le fichier
+           $LMDGCM/libf/grid/fxyprim.h avec le fichier
+           $LMDGCM/libf/grid/fxy_grille.h
+           La grille peut prendre les valeurs:
+           1. reg pour la grille reguliere
+           2. sin pour avoir des points equidistants en sinus de la latitude
+           3. new pour pouvoir zoomer sur une partie du globe
+
+-O "optimisation fortran" ou les optimisations fortran sont les options de la
+            commande f77
+
+-include path
+           Dans le cas ou on a dans des sous programmes des fichiers 
+           #include (cpp) qui se trouve sur des repertoires non references
+           par defaut
+
+-adjnt     Pour compiler la l'adjoint du code dynamique
+
+-filtre  filtre
+           Pour choisir le filtre en longitude dans les regions polaires.
+           "filtre" correspond au nom d'un repertoire se trouvant sur
+           $LMDGCM/libf. Le filtre standard du modele est "filtrez" qui peut
+           etre utilise aussi bien pour une grille reguliere que pour une 
+           grille zoomee en longitude.
+
+-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
+          Pour rajouter un lien avec les librairies FORTRAN
+          libfile1.a, libfile2.a ... se trouvant respectivement sur les
+          repertoires dir1, dir2 ...
+          Si dirn est un repertoire dont le chemin est automatique (comme
+          par exemple /usr/lib ...) il n'est pas besoin de specifier -Ldirn.
+
+Auteur: Frederic Hourdin  (hourdin@lmd.jussieu.fr)
+eod
+exit
+
+########################################################################
+# Lecture des differentes options
+########################################################################
+
+    case -d:
+        set dim=$2 ; shift ; shift ; goto top
+                        
+    case -O:
+        set optim="$2" ; shift ; shift ; goto top
+
+     case -p
+        set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top
+
+     case -g
+        set grille="$2" ; shift ; shift ; goto top
+
+     case -t
+        set ntrac=$2 ; shift ; shift ; goto top
+
+     case -include
+        set include="$include -I$2" ; shift ; shift ; goto top
+
+     case -adjnt
+        set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d "
+        set optim="$optim -Dadj" ; shift ; goto top
+
+     case -filtre
+        set filtre=$2 ; shift ; shift ; goto top
+
+     case -link
+        set opt_link="$2" ; shift ; shift ; goto top
+
+     default
+        set code="$1" ; shift ; goto top
+
+   endsw
+endif
+
+########################################################################
+# cas special sans physique
+########################################################################
+if ( "$physique" == 'nophys' ) then
+   set phys="L_PHY= LIBPHY="
+   echo PHYSIQUE $phys
+endif
+
+########################################################################
+# choix du nombre de traceur par defaut si il n'a pas ete choisi,
+# suivant la physique
+########################################################################
+if ( $ntrac == 0  ) then
+    if ( "$physique" == 'nophys' ) then
+        set ntrac=1
+    else if ( "$physique" == 'lmd' ) then
+        set ntrac=2
+    else if ( "$physique" == 'lmd_test_li' ) then
+        set ntrac=2
+    else if ( "$physique" == 'ec' ) then
+        set ntrac=1
+    else
+        set ntrac = 1
+    endif
+endif
+
+########################################################################
+#subtilites sur le nom de la librairie
+########################################################################
+\rm tmp ; touch tmp
+foreach i ( $optim )
+   echo $i >> tmp
+end
+set suf=
+foreach i ( `sort tmp | uniq ` )
+   set suf=$suf$i
+end
+if ( ! $IBM ) then
+   set nomlib="$nomlib$suf"
+endif
+if $IBM then
+   set dim=`echo $dim | sed -en 's/[^0-9]/ /g'`
+   set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'`
+else
+   set dim=`echo $dim | sed -e 's/[^0-9]/ /gp'`
+   set dim_=`echo $dim | sed -e 's/[^0-9]/_/gp'`
+endif
+set nomlib=${nomlib}_${physique}_${dim_}_t${ntrac}_$grille
+
+########################################################################
+# path pour les #include
+########################################################################
+if $HP then
+set include="$include -I$drs/HP"
+else if $SUN then
+set include="$include -I$drs/SUN"
+else if  $IBM then
+set include="$include -I$drs/IBM"
+else
+set include="$include -I$drs"
+endif
+echo $include
+
+########################################################################
+# on cree ou remplace le fichier des dimensions/nombre de traceur
+########################################################################
+cd $libf/grid/dimension
+makdim $ntrac $dim
+set dimc=`echo $dim | wc -w`
+cat $libf/grid/dimensions.h
+
+
+set libo=$libo/$nomlib
+if ( ! -d $libo )  then
+   mkdir $libo
+   cd $model
+endif
+
+
+########################################################################
+# Differentes dynamiques
+########################################################################
+
+set dimension=`echo $dim | wc -w`
+echo dimension $dimension
+if ( $dimension == 1 ) then
+echo pas de dynamique
+set dyn="L_DYN= DYN= L_FILTRE= DIRMAIN=phy$physique "
+endif
+endif
+cd $model
+if ( $dimension == 3 ) then
+cd libf/grid
+\rm fxyprim.h
+cp -p fxy_${grille}.h fxyprim.h
+endif
+
+######################################################################
+# fonctions CRAY
+######################################################################
+
+if ! $CRAY then
+   set dircray=$model/cray/libf  # repertoire par defaut
+   if $HP then
+      if ( ` echo $optim | grep autodblpad ` != "" ) then
+         set opt_cray="-O +autodblpad"
+         set lib_cray=CrayHPr8
+      else
+         set dircray=$model/cray/libfhp  # versions optimisees pour HP
+         set opt_cray=-O
+         set lib_cray=CrayHP
+      endif
+   endif
+   if $SUN then
+      if ( ` echo $optim | grep r8 | wc -w ` != "0" ) then
+         set opt_cray=-r8
+         set lib_cray=CraySUNr8
+      else
+         set opt_cray=-O3
+         set lib_cray=CraySUN
+      endif
+   endif
+   if $IBM then
+      set opt_cray="-O3 -qtune=pwr2 -qarch=pwr2"
+      set lib_cray=CrayIBM
+   endif
+
+   cd $dircray
+   if ( ! -f makefile ) then
+      newmake
+   endif
+   make OPTIM="$opt_cray" NOM_LIB=$lib_cray
+   set cray="-L$dircray -l$lib_cray"
+
+endif
+
+######################################################################
+# execution de la commande make UNIX
+######################################################################
+
+if ( `expr $dimc \> 2` == 1 ) then
+   set filtre="FILTRE=$filtre"
+else
+   set filtre="FILTRE= L_FILTRE= "
+endif
+echo MACRO FILTRE $filtre
+
+echo $dimc
+
+########################################################################
+#  Avant de lancer le make, on recree le makefile si necessaire
+########################################################################
+# c'est a dire dans 3 cas:
+# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
+#    derniere creation du makefile
+# 2. si le fichier contenant cette liste "liste_des_sources"
+#    n'existe pas.
+# 3. Si le makefile n'existe pas.
+########################################################################
+
+cd $model
+( find libf -name '*.[Fh]' -print ; grep include libf/*/*F ) >! tmp
+
+if (    `diff tmp liste_des_sources | wc -w` \
+     || ! -f makefile \
+     || ! -f liste_des_sources ) then
+        echo les fichiers suivants ont ete crees ou detruits
+        diff liste_des_sources tmp
+        \cp tmp liste_des_sources
+        echo On recree le makefile
+        ./create_make_gcm >! tmp
+        \mv tmp makefile
+        echo Nouveau makefile cree.
+endif
+
+########################################################################
+#  Execution de la comande make
+########################################################################
+
+echo PHYSIQUE $phys
+echo dynamique $dyn $dimension
+echo OPTIM="$optim" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code
+echo PATH pour les fichiers INCLUDE $include
+
+if $HP then
+   set f77='fort77 +OP'
+   set opt_link="$opt_link -lm"
+else
+   set f77=f77
+endif
+
+cd $model
+if ( $SUN || $IBM || $HP ) then
+
+make \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+OPTIM="$optim" \
+INCLUDE="$include" \
+L_CRAY="$cray" \
+$filtre \
+L_DRS="-L$drs/$machine -ldrs" \
+LIBO=$libo \
+$dyn \
+$phys \
+DIM=$dimc \
+L_ADJNT="$adjnt" \
+$localdir  \
+F77="$f77" \
+PROG=$code
+
+else if $CRAY then
+
+make \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+INCLUDE="$include" \
+L_DRS="-L$drs -ldrs" \
+$filtre \
+LIBO=$libo \
+$dyn \
+$phys \
+DIM=$dimc \
+L_ADJNT="$adjnt" \
+$localdir \
+PROG=$code
+
+endif
Index: /trunk/LMDZ.TITAN/DOC/input/makegcm_help
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/makegcm_help	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/makegcm_help	(revision 1644)
@@ -0,0 +1,78 @@
+Par default, la commande makegcm:
+---------------------------------
+
+1. compile une serie de sous programmes se trouvant dans des sous-repertoires
+de $LMDGCM/libf
+2. Ensuite, makegcm compile le programme prog.f se trouvant par default sur
+$LMDGCM/libf/dyn3d et effectue le lien avec l'ensemble des librairies.
+
+La commande makegcm est faite pour permettre de gerer en parallele des
+versions differentes du modele, compilees avec des options de compilation
+et des dimensions differentes sans avoir a chaque fois a recompiler tout le
+modele.
+
+Les librairies FORTRAN sont stoquees sur le directory $LIBOGCM.
+
+
+OPTIONS:
+--------
+
+Les options suivantes peuvent etre definies soit par defaut en editant le
+"script" makegcm, soit en interactif:
+
+-d imxjmxlm  ou im, jm, et lm sont resp. le nombre de longitudes, latitudes
+             et couches verticales. 
+
+-t ntrac   selectionne le nombre de traceur advectes par la dynamique.
+           Dans les versions courantes du modele terrestre on a par exemple
+           ntrac=2 pour l'eau vapeur et liquide
+
+             L'effet des options -d et -t est d'ecraser le fichier 
+             $LMDGCM/libf/grid/dimensions.h
+             qui contient sous forme de 4 PARAMETER FORTRAN les 3 dimensions
+             de la grille horizontale im, jm, lm plus le nombre de traceurs
+             advectes passivement par la dynamique ntrac, par un nouveu fichier
+             $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac
+             Si ce fichier n'existe pas encore, il est cree par le script
+             $LMDGCM/libf/grid/dimension/makdim
+
+-p PHYS    pour selectionner le jeu de parametrisations physiques avec
+           lequel on veut compiler le modele.
+           Le modele sera alors compile en prenant les sources des
+           parametrisations physiques dans le repertoire:
+            $LMDGCM/libf/phyPHYS
+
+-g grille  selectionne le type de grille qu'on veut utiliser.
+           L'effet de cette option est d'ecraser le fichier
+           $LMDGCM/libf/grid/fxyprim.h avec le fichier
+           $LMDGCM/libf/grid/fxy_grille.h
+           La grille peut prendre les valeurs:
+           1. reg pour la grille reguliere
+           2. sin pour avoir des points equidistants en sinus de la latitude
+           3. new pour pouvoir zoomer sur une partie du globe
+
+-O "optimisation fortran" ou les optimisations fortran sont les options de la
+            commande f77
+
+-include path
+           Dans le cas ou on a dans des sous programmes des fichiers 
+           #include (cpp) qui se trouve sur des repertoires non references
+           par defaut
+
+-adjnt     Pour compiler la l'adjoint du code dynamique
+
+-filtre  filtre
+           Pour choisir le filtre en longitude dans les regions polaires.
+           "filtre" correspond au nom d'un repertoire se trouvant sur
+           $LMDGCM/libf. Le filtre standard du modele est "filtrez" qui peut
+           etre utilise aussi bien pour une grille reguliere que pour une 
+           grille zoomee en longitude.
+
+-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
+          Pour rajouter un lien avec les librairies FORTRAN
+          libfile1.a, libfile2.a ... se trouvant respectivement sur les
+          repertoires dir1, dir2 ...
+          Si dirn est un repertoire dont le chemin est automatique (comme
+          par exemple /usr/lib ...) il n'est pas besoin de specifier -Ldirn.
+
+Auteur: Frederic Hourdin  (hourdin@lmd.jussieu.fr)
Index: /trunk/LMDZ.TITAN/DOC/input/makegcm_help.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/makegcm_help.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/makegcm_help.tex	(revision 1644)
@@ -0,0 +1,91 @@
+{\footnotesize
+\begin{verbatim}
+makegcm [Options] prog
+
+
+The makegcm script:
+-------------------
+
+1. compiles a series of subroutines located in the $LMDGCM/libf
+ sub-directories.
+ The objects are then stored in the libraries in $LIBOGCM.
+
+2. then, makegcm compiles program prog.f located by default in
+$LMDGCM/libf/dyn3d and makes the link with the libraries.
+
+Environment Variables '$LMDGCM' and '$LIBOGCM'
+ must be set as environment variables or directly
+ in the makegcm file.
+
+The makegcm command is used to control the different versions of the model
+ in parallel, compiled using the compilation options 
+ and the various dimensions, without having to recompile the whole model.
+
+The FORTRAN libraries are stored in directory $LIBOGCM.
+
+
+OPTIONS:
+--------
+
+The following options can either be defined by default by editing the
+makegcm "script", or in interactive mode:
+
+-d imxjmxlm  where im, jm, and lm are the number of longitudes,
+             latitudes and vertical layers respectively.
+
+-t ntrac   Selects the number of tracers present in the model
+
+             Options -d and -t overwrite file 
+             $LMDGCM/libf/grid/dimensions.h
+             which contains the 3 dimensions of the
+             horizontal grid 
+             im, jm, lm plus the number of tracers passively advected
+             by the dynamics ntrac,
+             in 4 PARAMETER FORTRAN format 
+             with a new file:
+             $LMDGCM/libf/grid/dimension/dimensions.im.jm.lm.tntrac
+             If the file does not exist already
+             it is created by the script
+             $LMDGCM/libf/grid/dimension/makdim
+
+-p PHYS    Selects the set of physical parameterizations
+           you want to compile the model with.
+           The model is then compiled using the physical
+           parameterization sources in directory:
+            $LMDGCM/libf/phyPHYS
+
+-g grille  Selects the grid type.
+           This option overwrites file
+           $LMDGCM/libf/grid/fxyprim.h
+           with file
+           $LMDGCM/libf/grid/fxy_grille.h
+           the grid can take the following values:
+           1. reg - the regular grid
+           2. sin - to obtain equidistant points in terms of sin(latitude)
+           3. new - to zoom into a part of the globe
+
+-O "compilation options" set of fortran compilation options to use
+
+-include path
+           Used if the subroutines contain #include files (ccp) that 
+           are located in directories that are not referenced by default.
+
+-adjnt     Compiles the adjoint model to the dynamical code.
+
+-filtre  filter
+           To select the longitudinal filter in the polar regions.
+           "filter" corresponds to the name of a directory located in
+           $LMDGCM/libf. The standard filter for the model is "filtrez"
+           which can be used for a regular grid and for a  
+           grid with longitudinal zoom.
+
+-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
+           Adds a link to FORTRAN libraries
+           libfile1.a, libfile2.a ... 
+           located in directories dir1, dir2 ...respectively
+           If dirn is a directory with an automatic path 
+           (/usr/lib ... for example) 
+           there is no need to specify  -Ldirn.
+
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/photochem_list.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/photochem_list.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/photochem_list.tex	(revision 1644)
@@ -0,0 +1,32 @@
+{\footnotesize
+
+\begin{verbatim}                                                                               
+## Tracer (dust water, ice and/or chemical species) options (used if tracer=T):
+## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# DUST: Transported dust ? (if >0, use 'dustbin' dust bins)
+dustbin    = 0
+# DUST: Radiatively active dust ? (matters if dustbin>0)
+active  = .false.
+# DUST: use mass and number mixing ratios to predict dust size ?
+# (must also have dustbin=1)
+doubleq   = .false.
+# DUST: lifted by GCM surface winds ?
+lifting = .false.
+# DUST: lifted by dust devils ?
+callddevil = .false.
+# DUST: Scavenging by CO2 snowfall ?
+scavenging = .false.
+# DUST/WATERICE: Gravitationnal sedimentation ?
+sedimentation = .true.
+# WATERICE: Radiatively active transported atmospheric water ice ?
+activice   = .false.
+# WATER: Compute water cycle
+water = .true.
+# WATER: current permanent caps at both poles. True IS RECOMMENDED
+#        (with .true., North cap is a source of water and South pole
+#         is a cold trap)
+caps  = .true.
+# PHOTOCHEMISTRY: include chemical species 
+photochem  = .true.
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/questions_inistate.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/questions_inistate.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/questions_inistate.tex	(revision 1644)
@@ -0,0 +1,54 @@
+{\footnotesize
+\begin{verbatim}
+ First set of questions:
+ Change values in tab_cntrl ? :
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ (Current values given above)
+
+ (3)          day_ini : Initial day (=0 at Ls=0)
+ (19)              z0 :  surface roughness (m)
+ (21)       emin_turb :  minimal energy (PBL)
+ (20)         lmixmin : mixing length (PBL)
+ (26)         emissiv : ground emissivity
+ (24 et 25)   emisice : CO2 ice max emissivity
+ (22 et 23)  albedice : CO2 ice cap albedos
+ (31 et 32) iceradius : mean scat radius of CO2 snow
+ (33 et 34) dtemisice : time scale for snow metamorphism
+ (27)        tauvis : mean dust vis. reference opacity
+ (35)      volcapa : soil volumetric heat capacity
+ (18)     obliquit : planet obliquity (deg)
+ (17)     peri_day : periastron date (sols since Ls=0)
+ (15)     periastr : min. star-planet dist (Mkm)
+ (16)     apoastr  : max. star-planet (Mkm)
+ (14)     year_day : length of year (in sols)
+ (5) rad : radius of the planet (m)
+ (6) omeg : planet rotation rate (rad/s)
+ (7) g : gravity (m/s2)
+ (8) mugaz : molecular mass of the atmosphere (g/mol)
+ (9) rcp : r/Cp
+ (10) daysec : length of a sol (s)
+
+ Second set of questions :
+ flat : no topography ("aquaplanet")
+ bilball : uniform albedo and thermal inertia
+ coldspole : cold subsurface and high albedo at S.pole
+ qname : change tracer name
+ q=0 : ALL tracer =zero
+ q=x : give a specific uniform value to one tracer
+ ini_q : tracers initialisation for chemistry, water and ice
+ ini_q-H2O : tracers initialisation for chemistry and ice
+ ini_q-iceH2O : tracers initialisation for chemistry only
+ noglacier : Remove tropical H2O ice if |lat|<45
+ watercapn : H20 ice on permanent N polar cap
+ watercaps : H20 ice on permanent S polar cap
+ oborealis : H2O ice across Vastitas Borealis
+ iceball   : Thick ice layer all over surface
+ wetstart  : start with a wet atmosphere
+ isotherm  : Isothermal Temperatures, wind set to zero
+ radequi   : Earth-like rad. eq. temperature profile and winds set to zero
+ co2ice=0 : remove CO2 polar cap
+ ptot : change total pressure
+ emis : change surface emissivity
+ therm_ini_s : Set soil thermal inertia to reference suface values
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/questions_inistate.tex.bak
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/questions_inistate.tex.bak	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/questions_inistate.tex.bak	(revision 1644)
@@ -0,0 +1,55 @@
+{\footnotesize
+\begin{verbatim}
+ First set of questions:
+ Change values in tab_cntrl ? :
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ (Current values given above)
+
+ (3)          day_ini : Initial day (=0 at Ls=0)
+ (19)              z0 :  surface roughness (m)
+ (21)       emin_turb :  minimal energy (PBL)
+ (20)         lmixmin : mixing length (PBL)
+ (26)         emissiv : ground emissivity
+ (24 et 25)   emisice : CO2 ice max emissivity
+ (22 et 23)  albedice : CO2 ice cap albedos
+ (31 et 32) iceradius : mean scat radius of CO2 snow
+ (33 et 34) dtemisice : time scale for snow metamorphism
+ (27)        tauvis : mean dust vis. reference opacity
+ (35)      volcapa : soil volumetric heat capacity
+ (18)     obliquit : planet obliquity (deg)
+ (17)     peri_day : periastron date (sols since Ls=0)
+ (15)     periastr : min. star-planet dist (Mkm)
+ (16)     apoastr  : max. star-planet (Mkm)
+ (14)     year_day : length of year (in sols)
+ (5) rad : radius of the planet (m)
+ (6) omeg : planet rotation rate (rad/s)
+ (7) g : gravity (m/s2)
+ (8) mugaz : molecular mass of the atmosphere (g/mol)
+ (9) rcp : r/Cp
+ (10) daysec : length of a sol (s)
+
+ Second set of questions :
+ flat : no topography ("aquaplanet")
+ bilball : uniform albedo and thermal inertia
+ coldspole : cold subsurface and high albedo at S.pole
+ qname : change tracer name
+ q=0 : ALL tracer =zero
+ q=x : give a specific uniform value to one tracer
+ ini_q : tracers initialisation for chemistry, water and ice
+ ini_q-H2O : tracers initialisation for chemistry and ice
+ ini_q-iceH2O : tracers initialisation for chemistry only
+ noglacier : Remove tropical H2O ice if |lat|<45
+ watercapn : H20 ice on permanent N polar cap
+ watercaps : H20 ice on permanent S polar cap
+ oborealis : H2O ice across Vastitas Borealis
+ iceball   : Thick ice layer all over surface
+ wetstart  : start with a wet atmosphere
+ isotherm  : Isothermal Temperatures, wind set to zero
+ radequi   : Earth-like radiative equilibrium temperatu profile (lat-alt) and winds set to zero
+ coldstart : Start X K above the CO2 frost point and set wind to zero (assumes 100% CO2)
+ co2ice=0 : remove CO2 polar cap
+ ptot : change total pressure
+ emis : change surface emissivity
+ therm_ini_s : Set soil thermal inertia to reference suface values
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/run.def
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/run.def	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/run.def	(revision 1644)
@@ -0,0 +1,104 @@
+Parametres de controle du run:                                          
+------------------------------                                          
+
+- Nombre de jours d'integration                                         
+    nday
+  47
+
+- nombre de pas par jour (multiple de iperiod)                          
+day_step
+  960.
+
+- periode pour le pas Matsuno (en pas)                                  
+ iperiod
+  5
+
+- periode de sortie des variables de controle (en pas)                 
+ iconser
+  120
+
+- periode d'ecriture du fichier histoire (en jour)                      
+   iecri
+  10
+
+- periode de stockage fichier histmoy (en jour)                         
+ periodav
+  1
+
+- periode de la dissipation (en pas)                                    
+ idissip
+  5
+
+- choix de l'operateur de dissipation (star ou  non star )
+  lstardis
+  F
+
+- nombre d'iterations de l'operateur de dissipation   gradiv
+  nitergdiv
+  1
+ 
+- nombre d'iterations de l'operateur de dissipation  nxgradrot
+  nitergrot
+  2
+ 
+- nombre d'iterations de l'operateur de dissipation  divgrad
+  niterh
+  2
+ 
+- temps de dissipation des plus petites long.d ondes pour u,v (gradiv)
+  tetagdiv
+  5500.
+ 
+- temps de dissipation des plus petites long.d ondes pour u,v (nxgradrot)
+  tetagrot
+  3600.
+ 
+- temps de dissipation des plus petites long.d ondes pour   h
+  tetatemp
+  3600.
+ 
+- coefficient pour gamdissip
+ coefdis
+  0.
+ 
+- periode de la physique (en pas)                                       
+  iphysiq
+  20
+
+- choix du shema d'integration temporelle (Matsuno ou Matsuno-leapfrog) 
+ purmats
+  F
+
+- choix d'une grille reguliere                                          
+  grireg
+  T
+
+- avec ou sans physique                                                 
+  physic
+  T
+
+- frequence (en  pas !! ) de l'ecriture du fichier diagfi
+  ecritphy
+  960.
+
+- longitude en degres du centre du zoom
+  clon
+  0.
+
+- latitude en degres du centre du zoom
+  clat
+  0.
+
+- facteur de grossissement du zoom,selon longitude
+  alphax
+  0.
+
+- facteur de grossissement du zoom ,selon latitude
+  alphay
+  0.
+
+-  Fonction  f(y)  hyperbolique ( si .true. )  ou   sinusoidale
+ fxyhypb
+ F
+
+.
Index: /trunk/LMDZ.TITAN/DOC/input/run.def.1d.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/run.def.1d.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/run.def.1d.tex	(revision 1644)
@@ -0,0 +1,84 @@
+{\footnotesize
+\begin{verbatim}
+#-----------------------------------------------------------------------
+# Run parameters for the rcm1d.e model
+#-----------------------------------------------------------------------
+
+#### Time integration parameters
+#
+# Initial date (in martian sols ; =0 at Ls=0)
+day0=0
+# Initial local time (in hours, between 0 and 24)
+time=0
+# Number of time steps per sol
+day_step=48
+# Number of sols to run
+ndt =400
+
+#### Physical parameters
+#
+# Surface pressure (Pa)
+psurf=7000.
+# Gravity (ms^-2)
+g=3.72
+# Molar mass of atmosphere (g)
+mugaz=43.49
+# Specific heat capacity of atmosphere?
+cpp=744.5
+# latitude (in degrees)
+latitude=0.0
+# orbital distance at perihelion (AU)
+periastr=1.558
+# orbital distance at aphelion (AU)
+apoastr=1.558
+# obliquity (degrees)
+obliquit=0.0
+# Solar zenith angle (degrees)
+szangle=60.0
+
+# Albedo of bare ground
+albedo=0.2
+# Emissivity of bare ground
+emis=1.0
+# Soil thermal inertia (SI)
+inertia=400
+# zonal eastward component of the geostrophic wind (m/s)
+u=10.
+# meridional northward component of the geostrophic wind (m/s)
+v=0.
+# Initial CO2 ice on the surface (kg.m-2)
+co2ice=0
+# hybrid vertical coordinate ? (.true. for hybrid and .false. for sigma levels)
+hybrid=.false.
+# autocompute vertical discretisation? (useful for exoplanet runs)
+autozlevs=.false.
+% pressure ceiling
+pceil=40.0
+
+###### Initial atmospheric temperature profile
+#
+# Type of initial temperature profile
+#         ichoice=1   Constant Temperature:  T=tref
+#         ichoice=2   Savidjari profile (as Seiff but with dT/dz=cte)
+#         ichoice=3   Lindner (polar profile)
+#         ichoice=4   inversion
+#         ichoice=5   Seiff  (standard profile, based on Viking entry)
+#         ichoice=6   constant T  +  gaussian perturbation (levels)
+#         ichoice=7   constant T  + gaussian perturbation (km)
+#         ichoice=8   Read in an ascii file "profile"
+ichoice=5
+# Reference temperature tref (K)
+tref=200
+# Add a perturbation to profile if isin=1
+isin=0
+# peak of gaussian perturbation (for ichoice=6 or 7)
+pic=26.522
+# width of the gaussian perturbation (for ichoice=6 or 7)
+largeur=10
+# height of the gaussian perturbation (for ichoice=6 or 7)
+hauteur=30.
+
+# some definitions for the physics, in file 'callphys.def'
+INCLUDEDEF=callphys.def
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/run.def.1d.tex.bak
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/run.def.1d.tex.bak	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/run.def.1d.tex.bak	(revision 1644)
@@ -0,0 +1,68 @@
+{\footnotesize
+\begin{verbatim}
+#
+#----------------------------------------------------------------------- 
+# Run parameters for the 1D 'testphys1d.e' model                                          
+#-----------------------------------------------------------------------                                         
+
+#### Time integration parameters
+#
+# Initial date (in martian sols ; =0 at Ls=0)
+day0=0
+# Initial local time (in hours, between 0 and 24)
+time=0
+# Number of time steps per sol
+day_step=48
+# Number of sols to run 
+ndt = 100
+
+#### Physical parameters
+#
+# Surface pressure (Pa)
+psurf= 610
+# Reference dust opacity at 700 Pa, in the visible (true tau~tauref*psurf/700)
+tauvis=0.2
+# latitude (in degrees)
+latitude= 0.
+# Albedo of bare ground
+albedo=0.2
+# Soil thermal inertia (SI)
+inertia=400
+# zonal eastward component of the geostrophic wind (m/s)
+u=10.
+# meridional northward component of the geostrophic wind (m/s)
+v=0.
+# Initial CO2 ice on the surface (kg.m-2)
+co2ice=0
+# hybrid vertical coordinate ? (.true. for hybrid and .false. for sigma levels)
+hybrid=.true.
+
+
+###### Initial atmospheric temperature profile
+#
+# Type of initial temperature profile
+#         ichoice=1   Constant Temperature:  T=tref
+#         ichoice=2   Savidjari profile (as Seiff but with dT/dz=cte)
+#         ichoice=3   Lindner (polar profile)
+#         ichoice=4   inversion
+#         ichoice=5   Seiff  (standard profile, based on Viking entry)
+#         ichoice=6   constant T  +  gaussian perturbation (levels)
+#         ichoice=7   constant T  + gaussian perturbation (km)
+#         ichoice=8   Read in an ascii file "profile" 
+ichoice=5
+# Reference temperature tref (K)
+tref=200
+# Add a perturbation to profile if isin=1
+isin=0
+# peak of gaussian perturbation (for ichoice=6 or 7)
+pic=26.522
+# width of the gaussian perturbation (for ichoice=6 or 7)
+largeur=10
+# height of the gaussian perturbation (for ichoice=6 or 7)
+hauteur=30.
+
+
+# some definitions for the physics, in file 'callphys.def'
+INCLUDEDEF=callphys.def
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/run.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/run.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/run.tex	(revision 1644)
@@ -0,0 +1,118 @@
+{\footnotesize
+\begin{verbatim}
+
+#------------------------------
+# Parametres de controle du run
+#------------------------------
+
+# Nombre de jours d'integration
+     nday=669
+
+# nombre de pas par jour (multiple de iperiod) ( ici pour  dt = 1 min )
+ day_step = 960
+
+# periode pour le pas Matsuno (en pas)
+  iperiod=5
+
+# periode de sortie des variables de controle (en pas)
+  iconser=120
+
+# periode d'ecriture du fichier histoire (en jour)
+    iecri=100
+
+# periode de stockage fichier histmoy (en jour)
+ periodav=60.
+
+# periode de la dissipation (en pas)
+  idissip=5
+
+# choix de l'operateur de dissipation (star ou  non star )
+ lstardis=.true.
+
+# avec ou sans coordonnee hybrides
+ hybrid=.true.
+
+# nombre d'iterations de l'operateur de dissipation   gradiv
+nitergdiv=1
+
+# nombre d'iterations de l'operateur de dissipation  nxgradrot
+nitergrot=2
+
+# nombre d'iterations de l'operateur de dissipation  divgrad
+   niterh=2
+
+# temps de dissipation des plus petites long.d ondes pour u,v (gradiv)
+ tetagdiv=10000.
+
+# temps de dissipation des plus petites long.d ondes pour u,v(nxgradrot)
+ tetagrot=10000.
+
+# temps de dissipation des plus petites long.d ondes pour  h ( divgrad)
+ tetatemp=10000.
+
+# coefficient pour gamdissip
+  coefdis=0.
+
+# choix du shema d'integration temporelle (Matsuno ou Matsuno-leapfrog)
+  purmats=.false.
+
+# avec ou sans physique
+   physic=.true.
+
+# periode de la physique (en pas)
+  iphysiq=20
+
+# choix d'une grille reguliere
+  grireg=.true.
+
+# frequence (en pas) de l'ecriture du fichier diagfi
+ ecritphy=1920
+
+# longitude en degres du centre du zoom
+   clon=63.
+
+# latitude en degres du centre du zoom
+   clat=0.
+
+# facteur de grossissement du zoom,selon longitude
+  grossismx=1.
+
+# facteur de grossissement du zoom ,selon latitude
+ grossismy=1.
+
+#  Fonction  f(y)  hyperbolique  si = .true.  , sinon  sinusoidale
+  fxyhypb=.false.
+
+# extension en longitude  de la zone du zoom  ( fraction de la zone totale)
+   dzoomx= 0.
+
+# extension en latitude de la zone  du zoom  ( fraction de la zone totale)
+   dzoomy=0.
+
+#  raideur du zoom en  X
+    taux=2.
+
+#  raideur du zoom en  Y
+    tauy=2.
+
+#  Fonction  f(y) avec y = Sin(latit.) si = .TRUE. ,  Sinon  y = latit.
+  ysinus= .false.
+
+# Avec sponge layer
+  callsponge  = .true.
+
+# Sponge:  mode0(u=v=0), mode1(u=umoy,v=0), mode2(u=umoy,v=vmoy)
+  mode_sponge= 2
+
+# Sponge:  hauteur de sponge (km)
+  hsponge= 90
+
+# Sponge:  tetasponge (secondes)
+  tetasponge = 50000
+
+# some definitions for the physics, in file 'callphys.def'
+INCLUDEDEF=callphys.def
+
+
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/run.tex.bak
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/run.tex.bak	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/run.tex.bak	(revision 1644)
@@ -0,0 +1,118 @@
+{\footnotesize
+\begin{verbatim}
+
+#-----------------------------
+#Parametres de controle du run
+#-----------------------------
+
+# Nombre de jours d'integration
+     nday=669
+
+# nombre de pas par jour (multiple de iperiod) ( ici pour  dt = 1 min )
+ day_step = 960
+
+# periode pour le pas Matsuno (en pas)
+  iperiod=5
+
+# periode de sortie des variables de controle (en pas)
+  iconser=120
+
+# periode d'ecriture du fichier histoire (en jour)
+    iecri=100
+
+# periode de stockage fichier histmoy (en jour)
+ periodav=60.
+
+# periode de la dissipation (en pas)
+  idissip=5
+
+# choix de l'operateur de dissipation (star ou  non star )
+ lstardis=.true.
+
+# avec ou sans coordonnee hybrides
+ hybrid=.true.
+
+# nombre d'iterations de l'operateur de dissipation   gradiv
+nitergdiv=1
+
+# nombre d'iterations de l'operateur de dissipation  nxgradrot
+nitergrot=2
+
+# nombre d'iterations de l'operateur de dissipation  divgrad
+   niterh=2
+
+# temps de dissipation des plus petites long.d ondes pour u,v (gradiv)
+ tetagdiv=10000.
+
+# temps de dissipation des plus petites long.d ondes pour u,v(nxgradrot)
+ tetagrot=10000.
+
+# temps de dissipation des plus petites long.d ondes pour  h ( divgrad)
+ tetatemp=10000.
+
+# coefficient pour gamdissip
+  coefdis=0.
+
+# choix du shema d'integration temporelle (Matsuno ou Matsuno-leapfrog)
+  purmats=.false.
+
+# avec ou sans physique
+   physic=.true.
+
+# periode de la physique (en pas)
+  iphysiq=20
+
+# choix d'une grille reguliere
+  grireg=.true.
+
+# frequence (en pas) de l'ecriture du fichier diagfi
+ ecritphy=1920
+
+# longitude en degres du centre du zoom
+   clon=63.
+
+# latitude en degres du centre du zoom
+   clat=0.
+
+# facteur de grossissement du zoom,selon longitude
+  grossismx=1.
+
+# facteur de grossissement du zoom ,selon latitude
+ grossismy=1.
+
+#  Fonction  f(y)  hyperbolique  si = .true.  , sinon  sinusoidale
+  fxyhypb=.false.
+
+# extension en longitude  de la zone du zoom  ( fraction de la zone totale)
+   dzoomx= 0.
+
+# extension en latitude de la zone  du zoom  ( fraction de la zone totale)
+   dzoomy=0.
+
+#  raideur du zoom en  X
+    taux=2.
+
+#  raideur du zoom en  Y
+    tauy=2.
+
+#  Fonction  f(y) avec y = Sin(latit.) si = .TRUE. ,  Sinon  y = latit.
+  ysinus= .false.
+
+# Avec sponge layer
+  callsponge  = .true.
+
+# Sponge:  mode0(u=v=0), mode1(u=umoy,v=0), mode2(u=umoy,v=vmoy)
+  mode_sponge= 2
+
+# Sponge:  hauteur de sponge (km)
+  hsponge= 90
+
+# Sponge:  tetasponge (secondes)
+  tetasponge = 50000
+
+# some definitions for the physics, in file 'callphys.def'
+INCLUDEDEF=callphys.def
+
+
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/stats_list.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/stats_list.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/stats_list.tex	(revision 1644)
@@ -0,0 +1,158 @@
+{\footnotesize
+\begin{verbatim}
+netcdf stats {
+dimensions:
+        latitude = 49 ;
+        longitude = 65 ;
+        altitude = 25 ;
+        llmp1 = 26 ;
+        Time = UNLIMITED ; // (12 currently)
+variables:
+        float Time(Time) ;
+                Time:title = "Time" ;
+                Time:units = "days since 0000-00-0 00:00:00" ;
+        float latitude(latitude) ;
+                latitude:title = "latitude" ;
+                latitude:units = "degrees_north" ;
+        float longitude(longitude) ;
+                longitude:title = "East longitude" ;
+                longitude:units = "degrees_east" ;
+        float altitude(altitude) ;
+                altitude:long_name = "altitude" ;
+                altitude:units = "km" ;
+                altitude:positive = "up" ;
+        float aps(altitude) ;
+                aps:title = "hybrid pressure at midlayers" ;
+                aps:units = "" ;
+        float bps(altitude) ;
+                bps:title = "hybrid sigma at midlayers" ;
+                bps:units = "" ;
+        float ps(Time, latitude, longitude) ;
+                ps:title = "Surface pressure" ;
+                ps:units = "Pa" ;
+        float ps_sd(Time, latitude, longitude) ;
+                ps_sd:title = "Surface pressure total standard deviation over th
+e season" ;
+                ps_sd:units = "Pa" ;
+        float tsurf(Time, latitude, longitude) ;
+                tsurf:title = "Surface temperature" ;
+                tsurf:units = "K" ;
+        float tsurf_sd(Time, latitude, longitude) ;
+                tsurf_sd:title = "Surface temperature total standard deviation o
+ver the season" ;
+                tsurf_sd:units = "K" ;
+        float co2ice(Time, latitude, longitude) ;
+                co2ice:title = "CO2 ice cover" ;
+                co2ice:units = "kg.m-2" ;
+        float co2ice_sd(Time, latitude, longitude) ;
+                co2ice_sd:title = "CO2 ice cover total standard deviation over t
+he season" ;
+                co2ice_sd:units = "kg.m-2" ;
+        float fluxsurf_lw(Time, latitude, longitude) ;
+                fluxsurf_lw:title = "Thermal IR radiative flux to surface" ;
+                fluxsurf_lw:units = "W.m-2" ;
+        float fluxsurf_lw_sd(Time, latitude, longitude) ;
+                fluxsurf_lw_sd:title = "Thermal IR radiative flux to surface tot
+al standard deviation over the season" ;
+                fluxsurf_lw_sd:units = "W.m-2" ;
+        float fluxsurf_sw(Time, latitude, longitude) ;
+                fluxsurf_sw:title = "Solar radiative flux to surface" ;
+                fluxsurf_sw:units = "W.m-2" ;
+        float fluxsurf_sw_sd(Time, latitude, longitude) ;
+                fluxsurf_sw_sd:title = "Solar radiative flux to surface total st
+andard deviation over the season" ;
+                fluxsurf_sw_sd:units = "W.m-2" ;
+        float fluxtop_lw(Time, latitude, longitude) ;
+                fluxtop_lw:title = "Thermal IR radiative flux to space" ;
+                fluxtop_lw:units = "W.m-2" ;
+        float fluxtop_lw_sd(Time, latitude, longitude) ;
+                fluxtop_lw_sd:title = "Thermal IR radiative flux to space total 
+standard deviation over the season" ;
+                fluxtop_lw_sd:units = "W.m-2" ;
+        float fluxtop_sw(Time, latitude, longitude) ;
+                fluxtop_sw:title = "Solar radiative flux to space" ;
+                fluxtop_sw:units = "W.m-2" ;
+        float fluxtop_sw_sd(Time, latitude, longitude) ;
+                fluxtop_sw_sd:title = "Solar radiative flux to space total stand
+ard deviation over the season" ;
+                fluxtop_sw_sd:units = "W.m-2" ;
+        float dod(Time, latitude, longitude) ;
+                dod:title = "Dust optical depth" ;
+                dod:units = "" ;
+        float dod_sd(Time, latitude, longitude) ;
+                dod_sd:title = "Dust optical depth total standard deviation over
+ the season" ;
+                dod_sd:units = "" ;
+        float temp(Time, altitude, latitude, longitude) ;
+                temp:title = "Atmospheric temperature" ;
+                temp:units = "K" ;
+        float temp_sd(Time, altitude, latitude, longitude) ;
+                temp_sd:title = "Atmospheric temperature total standard deviatio
+n over the season" ;
+                temp_sd:units = "K" ;
+        float u(Time, altitude, latitude, longitude) ;
+                u:title = "Zonal (East-West) wind" ;
+                u:units = "m.s-1" ;
+        float u_sd(Time, altitude, latitude, longitude) ;
+                u_sd:title = "Zonal (East-West) wind total standard deviation ov
+er the season" ;
+                u_sd:units = "m.s-1" ;
+        float v(Time, altitude, latitude, longitude) ;
+                v:title = "Meridional (North-South) wind" ;
+                v:units = "m.s-1" ;
+        float v_sd(Time, altitude, latitude, longitude) ;
+                v_sd:title = "Meridional (North-South) wind total standard devia
+tion over the season" ;
+                v_sd:units = "m.s-1" ;
+        float w(Time, altitude, latitude, longitude) ;
+                w:title = "Vertical (down-up) wind" ;
+                w:units = "m.s-1" ;
+        float w_sd(Time, altitude, latitude, longitude) ;
+                w_sd:title = "Vertical (down-up) wind total standard deviation o
+ver the season" ;
+                w_sd:units = "m.s-1" ;
+        float rho(Time, altitude, latitude, longitude) ;
+                rho:title = "Atmospheric density" ;
+                rho:units = "none" ;
+        float rho_sd(Time, altitude, latitude, longitude) ;
+                rho_sd:title = "Atmospheric density total standard deviation ove
+r the season" ;
+                rho_sd:units = "none" ;
+        float q2(Time, altitude, latitude, longitude) ;
+                q2:title = "Boundary layer eddy kinetic energy" ;
+                q2:units = "m2.s-2" ;
+        float q2_sd(Time, altitude, latitude, longitude) ;
+                q2_sd:title = "Boundary layer eddy kinetic energy total standard
+ deviation over the season" ;
+                q2_sd:units = "m2.s-2" ;
+        float vmr_h2ovapor(Time, altitude, latitude, longitude) ;
+                vmr_h2ovapor:title = "H2O vapor volume mixing ratio" ;
+                vmr_h2ovapor:units = "mol/mol" ;
+        float vmr_h2ovapor_sd(Time, altitude, latitude, longitude) ;
+                vmr_h2ovapor_sd:title = "H2O vapor volume mixing ratio total sta
+ndard deviation over the season" ;
+                vmr_h2ovapor_sd:units = "mol/mol" ;
+        float vmr_h2oice(Time, altitude, latitude, longitude) ;
+                vmr_h2oice:title = "H2O ice volume mixing ratio" ;
+                vmr_h2oice:units = "mol/mol" ;
+        float vmr_h2oice_sd(Time, altitude, latitude, longitude) ;
+                vmr_h2oice_sd:title = "H2O ice volume mixing ratio total standar
+d deviation over the season" ;
+                vmr_h2oice_sd:units = "mol/mol" ;
+        float mtot(Time, latitude, longitude) ;
+                mtot:title = "total mass of water vapor" ;
+                mtot:units = "kg/m2" ;
+        float mtot_sd(Time, latitude, longitude) ;
+                mtot_sd:title = "total mass of water vapor total standard deviat
+ion over the season" ;
+                mtot_sd:units = "kg/m2" ;
+        float icetot(Time, latitude, longitude) ;
+                icetot:title = "total mass of water ice" ;
+                icetot:units = "kg/m2" ;
+        float icetot_sd(Time, latitude, longitude) ;
+                icetot_sd:title = "total mass of water ice total standard deviat
+ion over the season" ;
+                icetot_sd:units = "kg/m2" ;
+}
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/testphys1d.def.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/testphys1d.def.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/testphys1d.def.tex	(revision 1644)
@@ -0,0 +1,38 @@
+{\footnotesize
+\begin{verbatim}
+0      ! Initial day (martian sol; = 0 at Ls=0) 
+0      ! initial local time  (between 0 and 24) 
+48     ! number of time-step per day.
+1      ! Run duration (sols) 
+700.   ! psurf: Surface pressure (Pa) 
+0.2    ! tauref: reference dust opacity at 700 Pa (true tau~tauref*psurf/700)
+30.    ! latitude  (degrees) 
+0.2    ! ground albedo  (under the ice)
+400    ! ground thermal inertia  (SI)
+10.    ! composante vers l'est du vent geostrophique (u) 
+0.     ! composante vers le nord du vent geostrophique (v)
+0.     ! initial CO2 ice mass (kg.m-2)
+T      ! Hybrid vertical coordinate ? T=Hybrid , F=sigma
+
+Initial temperature profile
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+5       ! ichoice :  Kind of initial profile (see below)
+200     ! tref : reference temperature (K) (used if ichoice=1)
+0       ! isin (if isin=1, add a perturbation to profile)
+26.5220 ! pic  pic perturbation gauss pour ichoice = 6 ou 7
+10      ! largeur de la perturbation gauss pour ichoice = 6 ou 7
+30.     ! hauteur de la perturbation gauss pour ichoice = 6 ou 7 
+
+c=======================================================================
+c   differents profils d'atmospheres. T=f(z)
+c         ichoice=1   Temperature constante T=tref
+c         ichoice=2   profil Savidjari (comme Seiff mais avec dT/dz=cte)
+c         ichoice=3   Lindner (profil polaire)
+c         ichoice=4   inversion
+c         ichoice=5   Seiff  (profile standard base sur les entrees Viking)
+c         ichoice=6    T constante + perturbation gauss (level)
+c         ichoice=7    T constante + perturbation gauss (km)
+c         ichoice=8   Read in an ascii file "profile" 
+
+\end{verbatim}
+}
Index: /trunk/LMDZ.TITAN/DOC/input/z2sig.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/z2sig.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/z2sig.tex	(revision 1644)
@@ -0,0 +1,21 @@
+\begin{verbatim}
+10.00000     H: atmospheric scale height (km) (used as a reference only)
+0.0040       Typical pseudo-altitude (m) for 1st layer (z=H*log(sigma))
+0.018       ,, ,,  ,, ,, ,, ,,  ,, ,, ,,  2nd layer, etc...
+0.0400
+0.1000
+0.228200
+0.460400
+0.907000
+1.73630
+3.19040
+5.54010
+8.97780
+13.5138
+18.9666
+25.0626
+31.5527
+38.4369
+45.4369
+52.4369
+\end{verbatim}
Index: /trunk/LMDZ.TITAN/DOC/input/z2sig.tex.bak
===================================================================
--- /trunk/LMDZ.TITAN/DOC/input/z2sig.tex.bak	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/input/z2sig.tex.bak	(revision 1644)
@@ -0,0 +1,70 @@
+\begin{verbatim}
+10.00000     H: atmospheric scale height (km) (used as a reference only)
+0.0040       Typical pseudo-altitude (m) for 1st layer (z=H*log(sigma))
+0.018       ,, ,,  ,, ,, ,, ,,  ,, ,, ,,  2nd layer, etc...
+0.0400
+0.1000
+0.228200
+0.460400
+0.907000
+1.73630
+3.19040
+5.54010
+8.97780
+13.5138
+18.9666
+25.0626
+31.5527
+38.4369
+45.4369
+52.4369
+59.4369
+66.4369
+73.4369
+80.4369
+87.4369
+94.4369
+101.4369
+108.437
+115.437
+122.437
+129.437
+136.437
+143.437
+150.437
+157.437
+164.437
+171.437
+178.437
+185.437
+192.437
+199.437
+206.437
+213.437
+220.437
+227.437
+234.437
+241.437
+248.437
+255.437
+262.437
+269.437
+276.437
+283.437
+290.437
+297.437
+304.437
+311.437
+318.437
+325.437
+332.437
+339.437
+346.437
+353.437
+360.437
+367.437
+374.437
+381.437
+388.437
+395.437
+\end{verbatim}
Index: /trunk/LMDZ.TITAN/DOC/intro.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/intro.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/intro.tex	(revision 1644)
@@ -0,0 +1,25 @@
+\chapter{Introduction}
+
+\selectlanguage{english}
+This document is a user manual for the Generic Climate Model
+developed by the Laboratoire de M\'et\'eorologie
+Dynamique of the CNRS in Paris.
+It corresponds to the version of the model available since January 2011,
+that includes the new dynamic code lmdz3.3
+and input and output data in NetCDF format.
+The physical part includes generalized correlated-k radiative transfer,
+generalized tracer transport, and a water cycle that includes water vapour and ice transport,
+radiative and thermodynamic effects, and simple hydrology.
+
+Chapter~\ref{sc:apercu} of this document, to be read before any of the others,
+describes the main features of the model.
+The model is divided into two relatively independent parts:
+(1) The hydrodynamic code, which integrates the fluid mechanical \emph{primitive equations} in time
+over the globe, and (2) the physical parameterizations, which include the radiative transfer, tracer transport / evolution,
+and surface-atmosphere interaction. It is followed by a list of references for anyone requiring a detailed
+description of the physics and the numerical formulation of the parameterizations (Chapter~\ref{sc:phystd}).
+
+For your {\bf first contact with the model}, Chapter~\ref{loc:contact1} guides the user through a practice simulation
+(choosing the initial states and parameters and  visualizing the output files). The document then describes the code used for the model, including a user computer manual for compiling and running it (Chapter~\ref{sc:info}).
+
+Chapter~\ref{sc:io} describes the input/output data of the model. The input files are the files needed to initialize the model (state of the atmosphere at instant $t0$ as well as a dataset of boundary conditions). The output files are ``historical files", archives of the atmospheric flow history as simulated by the model, the ``diagfi files", the ``stats files'', the daily averages, and so on. Common ways of editing or visualizing these files (editor ``ncdump" and the graphics software ``grads") are also explained.  Chapter~\ref{sc:water} explains how to run a simulation that includes the water cycle. Finally, Chapter~\ref{sc:rcm1d} will help you to use a 1-dimensional version of the model, which may be a simpler tool for some analysis work.
Index: /trunk/LMDZ.TITAN/DOC/io.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/io.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/io.tex	(revision 1644)
@@ -0,0 +1,486 @@
+\chapter{Input/Output}
+\label{sc:io}
+
+\section{NetCDF format}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%
+GCM input/output data are written in {\bf NetCDF} format
+(Network Common Data Form). NetCDF is an interface used to store and access
+geophysical data, and a library that provides an implementation of this
+interface. The NetCDF library also defines a machine-independent format for
+representing scientific data.
+Together, the interface, library and format support the creation, access and
+sharing of scientific data. NetCDF was developed at the Unidata Program Center
+in Boulder, Colorado. The freely available source can be obtained from
+{the Unidata website}{http://www.unidata.ucar.edu/software/netcdf}.
+
+A data set in NetCDF format is a single file, as it is self-descriptive.
+
+\subsection{NetCDF file editor: ncdump}
+
+The editor is included in the NetCDF library.
+By default it generates an ASCII representation as standard output
+from the NetCDF file specified at the input.
+
+\paragraph{Main commands for  ncdump}
+
+\begin{center}
+{\it ncdump diagfi.nc}
+\end{center}
+
+\noindent
+dump contents of NetCDF file {\tt diagfi.nc} to standard output
+(i.e. the screen).
+
+\begin{center}
+{\it ncdump -c diagfi.nc}
+\end{center}
+
+\noindent
+Displays the {\bf coordinate} variable values (variables which are also
+dimensions), as well as the declarations, variables and attribute values.
+The values of the non-coordinate variable data are not displayed at
+the output.
+
+\begin{center}
+{\it ncdump -h diagfi.nc}
+\end{center}
+
+\noindent
+Shows only the informative header of the file, which is the declaration
+of the dimensions, variables and attributes, but not the values of these
+variables. The output is identical to that in option {\bf -c} except for
+the fact that the coordinated variable values are not included.
+
+\begin{center}
+{\it ncdump -v var1,...,varn diagfi.nc}
+\end{center}
+
+\noindent
+The output includes the specific variable values,
+as well as all the dimensions, variables and attributes.
+More that one variable can be specified in the list following this option.
+The list must be a simple argument for the command, and must not contain any
+spaces. If no variable is specified, the command displays all the values of
+the variables in the file by default.
+
+
+\subsection{Graphic visualization of the NetCDF files using GrAds}
+
+GrAdS (The Grid Analysis and Display System) is a graphic software developed
+by Brian Doty at the "Center for Ocean-Land-Atmosphere (COLA)".
+
+One of its functions is to enable data stored in NetCDF format to be
+visualized directly. In figure~\ref{fg:grads} for example, we can see the
+GrADS visualization of the temperature data at a given moment.
+%
+\begin{figure}
+\centering
+\includegraphics[width=0.5\textwidth,angle=270]{Fig/grads.eps}
+\caption{Example of temperature data (in this case for present-day Mars) at a given time using
+GrADS visualization\label{fg:grads}}
+\end{figure}
+%
+However, unlike NetCDF, GrADS only recognizes files where all the variables are stored on the same horizontal grid.
+These variables can be in 1, 2, 3 or 4 dimensions (X,Y,Z and t).\\
+
+GrADS can also be obtained on the {WWW}{http://grads.iges.org/grads/}.
+
+\section{Input and parameter files}
+
+%{\bf \it Examples of initialization files can be found in directory
+%\begin{verbatim}$PATH1/LMDZ.MARS/deftank \end{verbatim}}
+\label{loc:entrees}
+
+The (3D version of the) GCM requires
+the input of two initialization files (in NetCDF format):\\
+-{\bf start.nc}
+contains the initial states of the dynamical variables.\\
+-{\bf startfi.nc}
+contains the initial states of the physical variables.\\
+Note that collections of initial states can be retreived at:\\
+\verb+http://www.lmd.jussieu.fr/~forget/datagcm/Starts+ \\
+Extracting {\tt start.nc} and {\tt startfi.nc} from these archived
+requires using program {\tt newstart}, as described in
+section~\ref{sc:newstart}.\\
+
+\noindent
+To run, the GCM also requires the  four following
+parameter files (ascii text files):\\
+-{\bf run.def} the parameters of the dynamical part of the program,
+and the temporal integration of the model.\\
+-{\bf callphys.def} the parameters for calling the physical part.\\
+-{\bf traceur.def} the names of the tracer to use.\\
+-{\bf z2sig.def}
+ the vertical distribution of the atmospheric layers.\\
+Examples of these parameter files can be found in the
+\verb+LMDZ.MARS/deftank+ directory.
+
+\subsection{run.def}
+\label{vb:run.def}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% run.def: les param sont lus dans dyn3d/defrun.F
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+A typical {\tt run.def} file is given as an example below.
+The choice of variables to be set is simple (e.g.
+ {\tt nday} number of modeled days to run),
+while the others do not need to be changed for normal use.\\
+The format of the {\tt run.def} file is quite straightforward
+(and flexible): values given to parameters must be given as:
+\begin{verbatim}
+  parameter = value
+\end{verbatim}
+Any blank line or line beginning with symbol {\bf \#} is
+a comment, and instruction lines may be written in any order.
+Moreover, not specifying a parameter/value set (e.g. deleting it
+or commenting it out) means you want the GCM to use a default built-in value.
+Additionally, one may use a specific keyword {\bf INCLUDEDEF} to specify
+another (text) file in which to also read values of parameters; e.g.:
+\begin{verbatim}
+INCLUDEDEF=callphys.def
+\end{verbatim}
+
+
+\noindent Here are some details about some of the parameters which may be
+set in {\tt run.def}:
+\begin{itemize}
+\item {\bf day\_step}, the number of dynamical steps per day to use for
+the time integration. This needs to be large enough for the model
+to remain stable (this is related to the CFL stability criterion
+which essentially depends on the horizontal resolution of the model).
+On Mars, in theory, the GCM can run with
+{\tt day\_step}=480 using the 64$\times$48 grid, but model stability
+improves when this number is higher: {\tt day\_step}=960 is recommended
+ when using the 64$\times$48 grid. According to the CFL criterion,
+{\tt day\_step} should vary in proportion with the resolution: for example
+{\tt day\_step}=480 using the 32$\times$24 horizontal resolution.
+Note that {\tt day\_step} must also be divisible by {\tt iperiod}. For other planets... [FINISH]
+
+\item {\bf tetagdiv, tetagrot, tetatemp} control the dissipation intensity.
+It is better to limit the dissipation intensity
+(tetagdiv, tetagrot, tetatemp should not be too low).
+However the model diverges if tetagdiv, tetagrot, tetatemp are too high,
+especially if there is a lot of dust in the atmosphere. \\
+Example used with nitergdiv=1 and  nitergrot=niterh=2 : \\
+- using the 32$\times$24 grid tetagdiv=6000~s ; tetagrot=tetatemp=30000~s \\
+- using the 64$\times$48 grid: tetagdiv=3000~s ; tetagrot=tetatemp=9000~s
+
+\item {\bf idissip} is the time step used for the dissipation:
+dissipation is computed and added every {\tt idissip} dynamical
+time step. If {\tt idissip} is
+too short, the model waste time in these calculations. But if idissip is too
+long, the  dissipation will not be parametrized correctly and the  model will
+be more likely to diverge.
+A check must be made, so that:
+{\tt idissip}~$<$~{\tt tetagdiv}$\times${\tt daystep}/86400
+(same rule for {\tt tetagrot} and {\tt tetatemp}).
+This is tested automatically during the run.
+
+\item {\bf iphysiq} is the time step used for the physics:
+physical tendencies are computed every {\tt iphysiq} dynamical time step.
+In practice, we
+usually set the physical time step to be of the order of half an hour.
+We thus generally set {\tt iphysiq}= {\tt day\_step}/48
+
+\end{itemize}
+
+\noindent
+{\it Example of run.def file: }
+\input{input/run.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\subsection{callphys.def}
+\label{sc:callphys.def}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% callphys.def: les param sont lus dans phymars/inifis.F
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+The {\tt callphys.def} file (along the same format
+as the {\tt run.def} file) contains parameter/value sets
+for the physics.\\
+
+
+\noindent
+{\it Example of callphys.def file: }
+\input{input/callphys.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\subsection{traceur.def}
+\label{sc:traceur.def}
+Tracers in input ({\tt start.nc} and {\tt startfi.nc}) and output
+files ({\tt restart.nc} and {\tt restartfi.nc}) are stored using
+individual tracer names (e.g. {\tt co2} for CO2 gas, {\tt h2o\_vap}
+for water vapour, {\tt h2o\_ice} for water ice, ...).\\
+The first line of the {\tt traceur.def} file (an ASCII file) must
+contain the number of tracers to load and use (this number should
+be the same as given to the {\tt -t} option of the {\tt makegcm}
+script when the GCM was compiled), followed by the tracer names
+(one per line). Note that if the corresponding tracers are not
+found in input files {\tt start.nc} and {\tt startfi.nc}, then the
+tracer is initialized to zero.\\
+
+
+\noindent {\it Example of a traceur.def file:
+(with water vapour and ice tracers)}
+{\footnotesize
+\begin{verbatim}
+2
+h2o_ice
+h2o_vap
+\end{verbatim}
+}
+
+\subsection{z2sig.def}
+The {\tt z2sig.def} file contains the pseudo-altitudes
+(in km) at which the user wants to set the vertical levels.\\
+Note that levels should be unevenly spread, with a higher resolution
+near the surface in order to capture the rapid variations of variables
+there. It is recommended to use the altitude levels as set in the
+{\tt z2sig.def} file provided in the {\tt deftank} directory.\\
+
+\noindent
+{\it Example of  z2sig.def file}
+\input{input/z2sig.tex}
+
+\subsection{Initialization files: start and startfi}
+
+%
+\begin{figure}[h]
+\centering
+\framebox[0.8\textwidth][c]{\includegraphics[width=0.7\textwidth]{Fig/netcdf.eps}}
+\caption{Organization of NetCDF files \label{fg:netcdf}}
+\end{figure}
+%
+Files {\tt start.nc} and {\tt startfi.nc}, like all the NetCDF files of
+the GCM,
+are constructed on the same model (see NetCDF file composition,
+figure~\ref{fg:netcdf}). They contain:\\
+- a header with a ``control'' variable followed by a series of variables
+defining the (physical and dynamical) grids \\
+- a series of non temporal variables that give information about surface
+conditions on the planet.\\
+- a ``time'' variable giving the values of the different instants at which
+the temporal variables are stored
+(a single time value (t=0) for start,
+as it describes the dynamical initial states,
+and no time values for startfi, as it describes only a physical state).\\
+
+To visualize the contents of a {\tt start.nc} file using the
+{\tt ncdump} command:\\
+
+\noindent
+{\it ncdump -h start.nc}\\
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% List START
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\input{input/dyn_list.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\noindent
+List of contents of a {\tt startfi.nc} file:\\
+
+\noindent
+{\it ncdump -h startfi.nc}\\
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% List startfi
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\input{input/fi_list.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%    Description des start et startfi
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\paragraph{Physical and dynamical headers}
+
+There are two types of headers: one for the physical headers,
+and one for the dynamical headers.
+The headers always begin with a ``control' variable
+(described below), that is allocated differently in the physical and
+dynamical parts.
+The other variables in the header concern the (physical and dynamical) grids.
+They are the following:\\
+
+\noindent
+the horizontal coordinates\\
+- {\bf rlonu}, {\bf rlatu}, {\bf rlonv}, {\bf rlatv} for the dynamical part,\\
+- {\bf lati}, {\bf long} for the physical part,\\
+
+\noindent
+the coefficients for passing from the physical grid to the dynamical grid\\
+- {\bf cu},{\bf cv} only in the dynamical header\\
+
+\noindent
+and finally, the grid box areas\\
+- {\bf aire} for the dynamical part,\\
+- {\bf area} for the physical part.\\
+
+\paragraph{Surface conditions}
+
+The surface conditions are mostly given in the physical NetCDF files by
+variables:\\
+- {\bf phisfi} for the initial state of surface geopotential,\\
+- {\bf albedodat} for the bare ground albedo,\\
+- {\bf inertiedat} for the surface thermal inertia,\\
+- {\bf zmea}, {\bf zstd}, {\bf zsig}, {\bf zgam} and {\bf zthe} for
+  the subgrid scale topography.\\
+
+\noindent
+For the dynamics:\\
+- {\bf physinit} for the initial state of surface geopotential\\
+
+\noindent
+Remark: variables {\bf phisfi} and {\bf physinit} contain the same information
+(surface geopotential), but {\bf phisfi} gives the geopotential values on the
+physical grid, while {\bf physinit} give the values on the dynamical grid.\\
+
+\paragraph{Physical and dynamical state variables}
+To save disk space, the initialization files store the variables used by
+the model, rather than the ``natural'' variables.\\
+
+\noindent
+For the dynamics:
+\begin{description}
+\item - {\bf ucov} and {\bf vcov} the covariant winds\\
+These variables are linked to the ``natural'' winds by\\
+\verb+ucov = cu * u+ and \verb+vcov = cv * v+
+\item - {\bf teta} the potential temperature,\\
+  or more precisely, the potential enthalpy linked to temperature {\bf T} by
+  $\theta = T\dep{\frac{P}{Pref}}^{-K}$
+\item - the tracers,
+\item - {\bf ps} surface pressure.
+\item - {\bf masse} the atmosphere mass in each grid box.
+\end{description}
+
+\noindent
+``Vectorial'' variables {\bf ucov} and {\bf vcov} are stored on
+``staggered'' grids u and v respectively (in the dynamics)
+(see section \ref{fg:grid}).\\
+Scalar variables {\bf h}, {\bf q} (tracers), {\bf ps}, {\bf masse} are stored
+on the ``scalar'' grid of the dynamical part.\\
+
+\noindent
+For the physics:
+\begin{description}
+\item - {\bf co2ice} surface dry ice,
+\item - {\bf tsurf} surface temperature,
+\item - {\bf tsoil} temperatures at different layers under the surface,
+\item - {\bf emis} surface emissivity,
+\item - {\bf q2} wind variance,\\
+or more precisely, the square root of the turbulent kinetic energy.
+\item - the surface ``tracer'' budget
+ (kg.m$^{-2}$),\\
+\end{description}
+
+\noindent
+All these variables are stored on the ``physical'' grid
+(see section \ref{fg:grid}).\\
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\paragraph{The ``control'' array}
+
+\indent
+Both physical and dynamical headers of the GCM NetCDF files start with
+a {\bf controle} variable. This variable is an array of 100 reals (the vector
+called {\tt tab\_cntrl} in the program), which contains the program control
+parameters.
+Parameters differ between the physical and dynamical sections, and examples
+of both are listed below. The contents of table {\tt tab\_cntrl} can also
+be checked with the command {\tt ncdump -ff -v controle}.\\
+
+\noindent
+{\bf The "control" array in the header of a dynamical NetCDF file:
+start}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% tab_cntrl (dynamique) dans dyn3d/inimomo.F
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\input{input/dyn_cntl.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\noindent
+{\bf The "controle" array in the header of a physical NetCDF file:
+startfi.nc}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% tab_cntrl (physique) dans phymars/iniwritefi.F
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\input{input/fi_cntl.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newpage
+\section{Output files}
+
+\subsection{NetCDF restart files - restart.nc and restartfi.nc}
+These files are of the exact same format as {\tt start.nc} and
+{\tt startfi.nc}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Description des fichiers de Sortie
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\subsection{ NetCDF file - diagfi.nc}
+NetCDF file {\tt diagfi.nc} stores the instantaneous physical variables
+throughout the simulation at regular intervals
+(set by the value of parameter {\tt ecritphy} in
+parameter file {\tt run.def}; note that {\tt ecritphy} should be a
+multiple of {\tt iphysiq} as well as a divisor of {\tt day\_step}).
+
+\noindent
+{\bf Any variable from any sub-routine of the physics can be stored
+by calling subroutine}
+\verb+ writediagfi+
+
+
+\noindent
+Illustrative example of the contents of a {\tt diagfi.nc}
+file (using ncdump):\\
+\noindent
+{\it ncdump -h diagfi.nc}\\
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% List DIAGFI
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% temporaire!!!
+\input{input/diag_list.tex}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\noindent
+The structure of the file is thus as follows:
+\begin{description}
+\item- the dimensions
+\item- variable ``time'' containing the time of the timestep stored in the
+ file (in Martian days since the beginning of the run)
+\item- variable ``control'' containing many parameters, as described above.
+\item- from `` rhonu'' to 'phisinit'': a list of data describing the
+ geometrical coordinates of the data file, plus the surface topography
+\item- finally, all the 2D or 3D data stored in the run.
+\end{description}
+
+
+\subsection{Stats files}
+
+As an option ({\tt stats} must be set to {\tt .true.} in {\tt callphys.def}),
+the model can accumulate any
+variable from any subroutine of the physics by calling
+subroutine \verb+ wstat+
+\\ \\
+\noindent
+This save is performed at regular intervals 12 times a day.
+An average of the daily evolutions over the whole run is calculated
+(for example, for a 10 day run, the averages of the variable values at
+0hTU, 2hTU, 4hTU,...24hTU are calculated), along with RMS standard
+deviations of the variables. This ouput is given in
+file {\tt stats.nc}.\\
+
+
+\noindent
+Illustrative example of the contents of a {\tt stats.nc} file (using ncdump):\\
+\noindent
+{\it ncdump -h stats.nc}\\
+\input{input/stats_list.tex}
+
+\noindent
+The structure of the file is simillar to the {\tt diagfi.nc} file,
+except that, as stated before, the average of variables are given for
+12 times of the day and that RMS standard deviation are also provided.
+
Index: /trunk/LMDZ.TITAN/DOC/kspectrum.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/kspectrum.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/kspectrum.tex	(revision 1644)
@@ -0,0 +1,101 @@
+\chapter{Changing the radiative transfer properties}
+
+\label{sc:kspectrum}
+
+One of the key advantages of the LMD generic model is the ability
+to work with arbitrary gas and aerosol mixtures in the radiative transfer.
+In this chapter we describe how to produce new correlated-k absorption coefficients
+and implement them in the GCM.
+
+\section{Producing the high-resolution data}
+We use the open-source software {\tt kspectrum} to produce line-by-line (LBL) absorption coefficients. {\tt Kspectrum}
+is freely available online at
+
+\begin{verbatim}
+http://code.google.com/p/kspectrum/
+\end{verbatim}
+
+See its user manual for general information on installation and basic usage.
+
+To produce LBL data on a grid of pressure and temperature suitable for the GCM, the program \verb+make_composition.F90+ is used (available in the {\tt utilities} folder of the main GCM directory). This may be compiled with the script {\tt compile} in the same folder. Once this has been done, the two scripts \verb+prekspectrum+ and \verb+postkspectrum+ are used to feed {\tt kspectrum} the correct inputs and convert the LBL data to correlated-k coefficients afterward. These scripts require three environment variables to be defined: {\tt DWORK\_DIR}, {\tt KSPEC\_DIR} and {\tt BANDS\_DIR}.
+
+In the following example, we create a database with a mixed CO$_2$ / H$_2$O atmosphere where CO$_2$ is the dominant gas. First, the three environment variables are set as
+
+\begin{verbatim}
+DWORK_DIR=/san/home/rdword/corrk_data/CO2_H2Ovar
+KSPEC_DIR=/san/home/rdword/kspectrum/kspec_1
+BANDS_DIR=32x36
+\end{verbatim}
+
+We then create a directory that includes files \verb+Q.dat+, \verb+p.dat+ and \verb+T.dat+ to define the number of gaseous species and pressure and temperature gridpoints. For each file the first number gives the number of points / species.   See the folder \verb+corrk_example+ in \verb+utilities+ for the example we will describe here.
+
+Typing {\tt prekspectrum} results in the following prompt:
+
+\begin{verbatim}
+Name of atmosphere / planet:
+\end{verbatim}
+
+The planet name is for reference only and does not affect the results. After this, the values of the temperature, pressure and variable gas (H2O) grids are displayed, and you are asked for the CO2 mixing ratio:
+
+\begin{verbatim}
+ Correlated-k temperature grid:
+ 1.  100.0 K
+ 2.  150.0 K
+ 3.  200.0 K
+ 4.  250.0 K
+ 5.  300.0 K
+ 6.  350.0 K
+ 7.  400.0 K
+
+ Correlated-k pressure grid (mBar):
+ 1. 1 x 10 ^-3 mBar
+ 2. 1 x 10 ^-2 mBar
+ 3. 1 x 10 ^-1 mBar
+ 4. 1 x 10 ^ 0 mBar
+ 5. 1 x 10 ^ 1 mBar
+ 6. 1 x 10 ^ 2 mBar
+ 7. 1 x 10 ^ 3 mBar
+ 8. 1 x 10 ^ 4 mBar
+ 9. 1 x 10 ^ 5 mBar
+
+ nmolec=           2
+ Temperature layers:             7
+ Pressure layers:                9
+ Mixing ratio layers:            7
+ Total:                        441
+
+ Please enter vmr of CO2
+\end{verbatim}
+
+We chose {\tt 1.0} as there are no other gases (the mixing ratio is automatically changed to take into account the variable gas). After {\tt prekspectrum} exits, we can view the resulting \verb+composition.in+ file stored in the \verb+data/+ directory of \verb+kspectrum+:
+
+\begin{verbatim}
+Atmospheric composition input data file for planet: Zarmina
+Number of atmospheric levels: 441
+Number of molecules:   2
+
+       z (km)     /    P (atm)     /  T (K)   /  x[CO2]    /  x[H2O]
+  0.000000000E+00  0.986923267E-06  0.100E+03  0.99999E+00  0.10000E-06
+  0.000000000E+00  0.986923267E-06  0.150E+03  0.99999E+00  0.10000E-06
+  0.000000000E+00  0.986923267E-06  0.200E+03  0.99999E+00  0.10000E-06
+  ...
+\end{verbatim}
+
+Typing \verb+run_kspectrum+ in the \verb+kspectrum+ directory then submits the process as a batch job. Beware: calculating LBL coefficients for multiple gases and several hundred $p$, $T$ values can take several weeks at current processing speeds!
+
+\section{Performing the correlated-k conversion}
+
+Once the LBL data is calculated, it's time to convert it to correlated-k format. We do this using a program \verb+generate_kmatrix.F90+ which is also stored in the \verb+utilities+ folder and is called by \verb+postkspectrum+. In addition to the data generated by \verb+kspectrum+ and the original \verb+.dat+ files, it requires definition of the spectral bands to be used in the GCM. In this example we use a folder \verb+32x36+, containing files \verb+narrowbands_VI.in+ and \verb+narrowbands_IR.in+. These files define the number and widths all all bands in the visible and infrared, respectively. They can of course be modified depending on blackbody temperatures and the tradeoff required between model speed and accuracy - the 
+ examples given provide accurate results for planets around Sun-like or M-class stars with surface temperatures in the 200-350 K range. {\tt postkspectrum} moves the LBL database to the {\tt DWORK\_DIR} directory along with the script {\tt run\_kmatrix}. When {\tt run\_kmatrix} is submitted in batch mode, it calls \verb+generate_kmatrix.exe+ automatically for both the visible and the infrared. 
+Correlated-k conversion is much quicker than the LBL calculation - for this database on current (2011) systems it should take only a few hours.
+
+\section{Implementing the absorption data in the GCM}
+
+To use our new correlated-k coefficients, we symbolically link the correlated-k folder to the {\tt datagcm} directory defined in the GCM file \verb+phystd/datafile.h+ (it's best to avoid copying the data directly due to space considerations). All that is left is to change {\tt corrkdir} in \verb+callphys.def+ to the correct name (\verb+CO2_H2Ovar+ in this example). Provided that we compile the GCM with the correct number of bands, e.g.
+
+\begin{verbatim}
+makegcm -d 32x32x20 -t 1 -b 32x36 -p std gcm
+\end{verbatim}
+
+it will run automatically with the new radiative transfer. The GCM checks the radiative transfer data on initialization vs. the values given in 
+\verb+gases.def+, to verify that thermodynamic values (e.g. $\mu_{gas}$, $c_p$) match the correlated-k data in the model. 
Index: /trunk/LMDZ.TITAN/DOC/main.aux
===================================================================
--- /trunk/LMDZ.TITAN/DOC/main.aux	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/main.aux	(revision 1644)
@@ -0,0 +1,189 @@
+\relax 
+\catcode`:\active
+\catcode`;\active
+\catcode`!\active
+\catcode`?\active
+\bibstyle{abbrv}
+\select@language{english}
+\@writefile{toc}{\select@language{english}}
+\@writefile{lof}{\select@language{english}}
+\@writefile{lot}{\select@language{english}}
+\select@language{english}
+\@writefile{toc}{\select@language{english}}
+\@writefile{lof}{\select@language{english}}
+\@writefile{lot}{\select@language{english}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {1}Introduction}{3}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\select@language{english}
+\@writefile{toc}{\select@language{english}}
+\@writefile{lof}{\select@language{english}}
+\@writefile{lot}{\select@language{english}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {2}Main features of the model}{4}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:apercu}{{2}{4}}
+\@writefile{toc}{\contentsline {section}{\numberline {2.1}Basic principles}{4}}
+\@writefile{toc}{\contentsline {section}{\numberline {2.2}Dynamical-Physical separation}{4}}
+\@writefile{lof}{\contentsline {figure}{\numberline {2.1}{\ignorespaces Physical/dynamical interface}}{5}}
+\newlabel{fg:fidyn}{{2.1}{5}}
+\@writefile{toc}{\contentsline {section}{\numberline {2.3}Grid boxes:}{5}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.1}Horizontal grids}{5}}
+\@writefile{lof}{\contentsline {figure}{\numberline {2.2}{\ignorespaces Dynamical and physical grids for a 6 $\times $ 7 horizontal resolution. In the dynamics (but not in the physics) winds u and v are on specific staggered grids. Other dynamical variables are on the dynamical ``scalar'' grid. The physics uses the same ``scalar'' grid for all the variables, except that nodes are indexed in a single vector containing NGRID=2+(JM-1)$\times $IM points when counting from the north pole. N.B.: In the Fortran program, the following variables are used: {\tt  iim=IM , iip1=IM+1, jjm=JM , jjp1=JM+1}.}}{6}}
+\newlabel{fg:grid}{{2.2}{6}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.2}Vertical grids}{7}}
+\@writefile{lof}{\contentsline {figure}{\numberline {2.3}{\ignorespaces hybrides}}{7}}
+\newlabel{fg:hybrid}{{2.3}{7}}
+\@writefile{lof}{\contentsline {figure}{\numberline {2.4}{\ignorespaces Vertical grid description of the {\tt  llm (or nlayer)} atmospheric layers in the programming code ({\tt  llm} is the variable used in the dynamical part, and {\tt  nlayer} is used in the physical part). Variables {\tt  ap, bp} and {\tt  aps, bps} indicate the hybrid levels at the interlayer levels and at middle of the layers respectively. Pressure at the interlayer is $Plev(l)=ap(l)+bp(l) \times Ps$ and pressure in the middle of the layer is defined by $Play(l)=aps(l)+bps(l) \times Ps$, (where $Ps$ is surface pressure). Sigma coordinates are merely a specific case of hybrid coordinates such that $aps=0$ and $bps=P/Ps$. Note that for the hybrid coordinates, $bps=0$ above $\sim 50$~km, leading to purely pressure levels. The user can choose whether to run the model using hybrid coordinates or not by setting variable {\tt  hybrid} in run.def to True or False.}}{8}}
+\newlabel{fg:sigma}{{2.4}{8}}
+\@writefile{toc}{\contentsline {section}{\numberline {2.4}Variables used in the model}{9}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {2.4.1}Dynamical variables}{9}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {2.4.2}Physical variables}{9}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {2.4.3}Tracers}{10}}
+\citation{Holt:79}
+\citation{LeVa:89}
+\citation{Arak:77}
+\@writefile{toc}{\contentsline {chapter}{\numberline {3}3D Dynamical Code}{11}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:dynamic}{{3}{11}}
+\@writefile{toc}{\contentsline {section}{\numberline {3.1}Discretisation of the dynamical equations}{11}}
+\@writefile{toc}{\contentsline {paragraph}{la pression extensive:}{11}}
+\@writefile{lof}{\contentsline {figure}{\numberline {3.1}{\ignorespaces Grille obtenue avec 96 points en longitude et 73 en latitude et un zoom d'un facteur 3 centr\'e sur la m\'edit\'erann\'ee (grille utilis\'ee au laboratoire par Ali Harzallah)}}{12}}
+\newlabel{fg:zoom}{{3.1}{12}}
+\@writefile{lof}{\contentsline {figure}{\numberline {3.2}{\ignorespaces Disposition des variables dans la grille du LMD}}{13}}
+\newlabel{fg:grille}{{3.2}{13}}
+\@writefile{toc}{\contentsline {paragraph}{les trois composantes du flux de masse:}{13}}
+\@writefile{toc}{\contentsline {paragraph}{le facteur de Coriolis multipli\'e par l'aire de la maille:}{13}}
+\@writefile{toc}{\contentsline {paragraph}{la vorticit\'e potentielle absolue:}{13}}
+\@writefile{toc}{\contentsline {paragraph}{l'\'energie cin\'etique}{13}}
+\@writefile{toc}{\contentsline {paragraph}{\'equations du mouvement:}{13}}
+\newlabel{eq:u1}{{3.5}{13}}
+\newlabel{eq:v1}{{3.6}{13}}
+\@writefile{toc}{\contentsline {paragraph}{\'equation thermodynamique:}{14}}
+\newlabel{eq:thermo}{{3.7}{14}}
+\@writefile{toc}{\contentsline {paragraph}{\'equation hydrostatique:}{14}}
+\@writefile{toc}{\contentsline {paragraph}{\'equations de continuit\'e:}{14}}
+\newlabel{eq:cont1}{{3.9}{14}}
+\newlabel{eq:cont2}{{3.10}{14}}
+\@writefile{toc}{\contentsline {section}{\numberline {3.2}High latitude filters}{14}}
+\@writefile{toc}{\contentsline {section}{\numberline {3.3}Dissipation}{14}}
+\@writefile{toc}{\contentsline {section}{\numberline {3.4}Sponge layer}{15}}
+\citation{Forg:99}
+\citation{Forg:99}
+\citation{Lewi:99}
+\@writefile{toc}{\contentsline {chapter}{\numberline {4}Physical parameterizations of the generic model: some references}{16}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:phystd}{{4}{16}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.1}General}{16}}
+\@writefile{toc}{\contentsline {paragraph}{General references:}{16}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.2}Radiative transfer}{16}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {4.2.1}\bf  Absorption/emission and diffusion by dust:}{16}}
+\citation{Toon:89}
+\citation{Forg:98grl}
+\citation{Fouq:80}
+\citation{Ocke:97}
+\citation{Clan:91}
+\citation{Hour:93}
+\citation{Forg:98}
+\citation{Hour:99}
+\citation{Mont:04jgr}
+\@writefile{toc}{\contentsline {section}{\numberline {4.3}Subgrid atmospheric dynamical processes}{17}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {4.3.1}Turbulent diffusion in the upper layer}{17}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {4.3.2}Convection}{17}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.4}Surface thermal conduction}{17}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.5}CO$_2$ Condensation}{17}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.6}Tracer transport and sources}{17}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {5}Running the model: a practice simulation}{19}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{loc:contact1}{{5}{19}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.1}Installing the model from SVN}{19}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.2}Installing the model without SVN}{21}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.3}Compiling the model}{21}}
+\newlabel{sc:run1}{{5.3}{21}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.4}Input files (initial states and def files)}{22}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.5}Running the model}{22}}
+\@writefile{lof}{\contentsline {figure}{\numberline {5.1}{\ignorespaces Input/output data}}{23}}
+\newlabel{fig:inout}{{5.1}{23}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.6}Visualizing the output files}{24}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {5.6.1}Using GrAds to visualize outputs}{24}}
+\newlabel{loc:visu}{{5.6.1}{24}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.7}Resuming a simulation}{25}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.8}Chain simulations}{25}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.9}Creating and modifying initial states}{25}}
+\newlabel{sc:newstart}{{5.9}{25}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {5.9.1}Using program ``newstart''}{25}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {5.9.2}Creating the initial start\_archive.nc file }{27}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {5.9.3}Changing the horizontal or vertical grid resolution}{27}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {6}Program organization and compilation script}{28}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:info}{{6}{28}}
+\newlabel{loc:contenu}{{6}{28}}
+\@writefile{toc}{\contentsline {section}{\numberline {6.1}Organization of the model source files}{28}}
+\@writefile{toc}{\contentsline {section}{\numberline {6.2}Programming}{29}}
+\@writefile{toc}{\contentsline {section}{\numberline {6.3}Model organization}{29}}
+\@writefile{toc}{\contentsline {section}{\numberline {6.4}Compiling the model}{29}}
+\newlabel{sc:compil1}{{6.4}{29}}
+\@writefile{lof}{\contentsline {figure}{\numberline {6.1}{\ignorespaces Organigram of subroutine function physiq.F90}}{30}}
+\newlabel{fg:organi_phys}{{6.1}{30}}
+\@writefile{toc}{\contentsline {paragraph}{Help manual for the makegcm script}{31}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {7}Input/Output}{33}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:io}{{7}{33}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.1}NetCDF format}{33}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.1.1}NetCDF file editor: ncdump}{33}}
+\@writefile{toc}{\contentsline {paragraph}{Main commands for ncdump}{33}}
+\@writefile{lof}{\contentsline {figure}{\numberline {7.1}{\ignorespaces Example of temperature data (in this case for present-day Mars) at a given time using GrADS visualization}}{34}}
+\newlabel{fg:grads}{{7.1}{34}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.1.2}Graphic visualization of the NetCDF files using GrAds}{34}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.2}Input and parameter files}{34}}
+\newlabel{loc:entrees}{{7.2}{34}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.2.1}run.def}{35}}
+\newlabel{vb:run.def}{{7.2.1}{35}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.2.2}callphys.def}{37}}
+\newlabel{sc:callphys.def}{{7.2.2}{37}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.2.3}traceur.def}{39}}
+\newlabel{sc:traceur.def}{{7.2.3}{39}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.2.4}z2sig.def}{39}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.2.5}Initialization files: start and startfi}{40}}
+\@writefile{lof}{\contentsline {figure}{\numberline {7.2}{\ignorespaces Organization of NetCDF files }}{41}}
+\newlabel{fg:netcdf}{{7.2}{41}}
+\@writefile{toc}{\contentsline {paragraph}{Physical and dynamical headers}{43}}
+\@writefile{toc}{\contentsline {paragraph}{Surface conditions}{43}}
+\@writefile{toc}{\contentsline {paragraph}{Physical and dynamical state variables}{43}}
+\@writefile{toc}{\contentsline {paragraph}{The ``control'' array}{44}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.3}Output files}{46}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.3.1}NetCDF restart files - restart.nc and restartfi.nc}{46}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.3.2} NetCDF file - diagfi.nc}{46}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {7.3.3}Stats files}{47}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {8}Water Cycle Simulation}{51}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:water}{{8}{51}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {9}1D version of the generic model}{54}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:rcm1d}{{9}{54}}
+\@writefile{toc}{\contentsline {section}{\numberline {9.1}Compilation}{54}}
+\@writefile{toc}{\contentsline {section}{\numberline {9.2}1-D runs and input files}{54}}
+\@writefile{toc}{\contentsline {section}{\numberline {9.3}Output data}{56}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {10}Zoomed simulations}{57}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:zoom}{{10}{57}}
+\@writefile{toc}{\contentsline {section}{\numberline {10.1}To define the zoomed area}{57}}
+\@writefile{toc}{\contentsline {section}{\numberline {10.2}Making a zoomed initial state}{57}}
+\@writefile{toc}{\contentsline {section}{\numberline {10.3}Running a zoomed simulation and stability issue}{58}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {11}Changing the radiative transfer properties}{59}}
+\@writefile{lof}{\addvspace {10\p@ }}
+\@writefile{lot}{\addvspace {10\p@ }}
+\newlabel{sc:kspectrum}{{11}{59}}
+\@writefile{toc}{\contentsline {section}{\numberline {11.1}Producing the high-resolution data}{59}}
+\@writefile{toc}{\contentsline {section}{\numberline {11.2}Performing the correlated-k conversion}{60}}
+\bibdata{newfred.bib}
+\@writefile{toc}{\contentsline {section}{\numberline {11.3}Implementing the absorption data in the GCM}{61}}
+\bibstyle{plain}
Index: /trunk/LMDZ.TITAN/DOC/main.bbl
===================================================================
--- /trunk/LMDZ.TITAN/DOC/main.bbl	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/main.bbl	(revision 1644)
@@ -0,0 +1,3 @@
+\begin{thebibliography}{}
+
+\end{thebibliography}
Index: /trunk/LMDZ.TITAN/DOC/main.ilg
===================================================================
--- /trunk/LMDZ.TITAN/DOC/main.ilg	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/main.ilg	(revision 1644)
@@ -0,0 +1,6 @@
+This is C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\makeindex.EXE, version 2.15 [MiKTeX 2.9] (kpathsea + Thai support).
+Scanning input file main.idx....done (5 entries accepted, 0 rejected).
+Sorting entries....done (11 comparisons).
+Generating output file main.ind....done (21 lines written, 0 warnings).
+Output written in main.ind.
+Transcript written in main.ilg.
Index: /trunk/LMDZ.TITAN/DOC/main.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/main.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/main.tex	(revision 1644)
@@ -0,0 +1,56 @@
+\documentclass{report}
+\usepackage{epsf}
+\usepackage{times}
+\usepackage{epsfig}
+\usepackage[round]{natbib}
+
+%\usepackage{makeidx}
+\usepackage{a4}
+\usepackage{graphicx}
+\usepackage[french,english]{babel}
+\scrollmode
+
+%\makeindex
+
+\newcommand{\indexentry}[2]{\item #1 #2}
+% numero de la derniere section numerotee
+\setcounter{secnumdepth}{3}
+% numero de la derniere section a apparaitre dans la table des matieres
+\setcounter{tocdepth}{3}
+
+% For title page
+\title{User Manual for the LMD Generic Climate Model}
+\author{E. Millour, F. Forget, J. Leconte, R. Wordsworth.}
+\date{\today}
+
+
+\begin{document}
+\bibliographystyle{abbrv}
+
+\input{def}
+
+\selectlanguage{english}
+
+\maketitle
+\tableofcontents
+
+\input{intro}
+\input{principe}
+\input{dynamics}
+\input{phystd}
+\input{run.tex}
+\input{compilation}
+\input{io.tex}
+\input{water.tex}
+\input{rcm1d.tex}
+\input{zoom.tex}
+\input{kspectrum.tex}
+
+\appendix
+
+%\printindex
+
+\bibliography{newfred.bib}
+\bibliographystyle{plain}
+
+\end{document}
Index: /trunk/LMDZ.TITAN/DOC/newfred.bib
===================================================================
--- /trunk/LMDZ.TITAN/DOC/newfred.bib	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/newfred.bib	(revision 1644)
@@ -0,0 +1,15640 @@
+
+@string{aa = "Astron.~Astrophys."}
+@string{aap = "Astron.~Astrophys."}
+@string{ae = "Atmosph.~Environ."}
+
+@string{ang = "Ann.~Geophys."}
+
+@string{ao = "Appl.~Opt."}
+
+@string{apj="Astrophys.~Jour."}
+
+@string{araa="Ann.~Rev.~Astron.~Astrophys."}
+
+@string{aereps="Ann.~Rev.~Earth~Planet~Sci."}
+
+@string{asr="Adv.~Space~Res."}
+
+@string{baas="Bull.~Am.~Astron.~Soc."}
+
+@string{bams="Bull.~Am.~Meteorol.~Soc."}
+
+@string{bpa2 = "Beitr.~Phys.~Atmosph." }
+
+@string{bpa="Contrib.~Atmos.~Phys."}
+
+@string{cap="Contrib.~Atmos.~Phys."}
+
+@string{cc  = "Climatic~Change"}
+
+@string{jc = "J.~Climate"}
+
+@string{gfd="Geophys.~Fluid~Dyn."}
+
+@string{grl="Geophys.~Res.~Lett."}
+
+@string{iaop= "Izvestiya,~Atmos.~Ocean.~Phys."}
+
+@string{jam = "J.~Appl.~Met."}
+
+@string{jas = "J.~Atmos.~Sci."}
+
+@string{jcp = "J.~Computational~Phys."}
+
+@string{jgr = "J.~Geophys.~Res."}
+
+@string{jmsj = "J.~Meteor.~Soc.~Jap."}
+
+@string{josa = "J.~Opt.~Soc.~Am."}
+
+@string{jpo = "J.~Phys.~Oceanogr."}
+
+@string{jqsrt = "J.~Spectrosc.~Radiat.~Transfer"}
+
+@string{jqsrt="J.~Quant.~Spectrosc.~Radiat.~Transfer"}
+
+@string{lnp="Lect. Notes Phys."}
+
+@string{lps="Lunar Planet Sci."}
+
+@string{mwr = "Mon. Wea. Rev." }
+
+@string{pss="Planet.~Space~Sci."}
+
+@string{ptrsl="Philos. Trans. R. Soc. London"}
+
+@string{qjr = "Q.~J.~R.~Meteorol.~Soc."}
+
+@string{rg="Rev.~Geophys."}
+
+@string{sci="Science"}
+
+@string{qjrms="Q.~J.~R.~Meteorol.~Soc."}
+
+@string{rg="Rev.~Geophys."}
+
+@string{blm="Boundary-layer Meteorol."}
+
+@article{Zent:93,
+   author = {Zent, A. P. and Haberle, R. M. and Houben, H. C. and Jakosky, B. M.},
+   journal = jgr,
+   pages = {3319-3337},
+   publisher = {Masson},
+   title = {A coupled subsurface-boundary layer model of water on {Mars}},
+   volume = {98},
+   year = {1997}
+}
+
+@misc{Forg:01,
+   author = {Forget, F. and Wanherdrick, Y. and Lewis, S. R.},
+   howpublished = {{ESA technical report, available on 
+{\tt http://www-mars.lmd.jussieu.fr/mars/esadoc/lmd/esadoc.html} }},
+   title = {Validation of the {Mars General Circulation model and Mars Climate Database with new spacecraftobservations}},
+   year = {2001}
+}
+
+@article{Bake:01,
+   author = {Baker, V. R.},
+   journal = {Nature},
+   pages = {228-236},
+   title = {Water and the martian landscape},
+   year = {2001}
+}
+
+@misc{Forg:01egs,
+   author = {Forget et al.},
+   howpublished = {Oral presentation at the EGS assembly, Nice},
+   title = {Simulation of the upper martian atmosphere up to 120 km with a General Circulation Model},
+   year = {2001}
+}
+
+@misc{Cant:01sub,
+   author = {Cantor, B. and James, P.B. and Caplinger , M. and Wolff, M. J.},
+   howpublished = {Submitted to JGR},
+   title = {Martian dust storms: 1999 Mars Orbiter Camera Observations},
+   year = {2001}
+}
+
+@article{Hins:01,
+   author = {Hinson, D},
+   journal = jgr,
+   pages = {1463-1480},
+   title = {Radio Occultation measurements of forced atmospheric waves on {Mars}},
+   volume = {106},
+   year = {2001}
+}
+
+@article{Schu:98,
+   author = {Schulz, M. and Balkanski, Y. J.  and Guelle, W. and Dulac, F.},
+   journal = jgr,
+   pages = {10,579-10,592},
+   title = {Role of aerosol size distribution and source location in a three-dimensional simulation of {Saharan} dust episode tested against staellite-derived optical thickness},
+   volume = {103},
+   year = {1998}
+}
+
+@article{Wils:00,
+   author = {Wilson, R.~J. and Richardson, M.~I.},
+   journal = {Icarus},
+   pages = {555-579},
+   title = {Infrared measurements of atmospheric temperatures revisited},
+   volume = {145},
+   year = {2000}
+}
+
+@article{Scho:97,
+   author = {Schofield, J. T. and Crisp, D. and Barnes, J. R. and Haberle, R. M. and Magalha{\~a}es, J. A. and Murphy, J. R. and Seiff, A. and Larsen, S. and Wilson, G.},
+   journal = {Science},
+   pages = {1752-1757},
+   title = {The {Mars Pathfinder Atmospheric Structure Investigation/Meteorology (ASI/MET)} experiment},
+   volume = {278},
+   year = {1997}
+}
+
+@article{Josh:00,
+   author = {Joshi, M. and Haberle, R. M. and Hollingsworth, J. and Hinson, D.},
+   journal = jgr,
+   pages = {17,601-17615},
+   title = {A comparison of {MGS} phase 1 aerobraking radio occultation data and the {NASA Ames Mars GCM}.},
+   volume = {105},
+   year = {2000}
+}
+
+@article{Clan:00,
+   author = {Clancy, R. T. and Sandor, B. J. and Woff, M. J. and Christensen, P. R. and Smith, M. D. and Pearl, J. C. and Conrath, B. J. and Wilson, R. J.},
+   journal = jgr,
+   pages = {9553-9571},
+   title = {An intercomparison of ground-based millimeter, {MGS TES}, and {Viking} atmospheric temperature measurements: Seasonal and interannual variability of temperatures and dust loading in the global {Mars} atmosphere},
+   type = {atmosphere},
+   volume = {105},
+   year = {2000}
+}
+
+@article{Forb:00,
+   author = {Forbes, J. M. and Hagan, M. E.},
+   journal = grl,
+   pages = {3563-3566},
+   title = {Diurnal {Kelvin} wave in the atmosphere of {Mars}: Toward and understanding of {``Stationary''} density structures observed by the {MGS} accelerometer.},
+   volume = {27},
+   year = {2000}
+}
+
+@article{Conr:00,
+   author = {Conrath, B. J. and Pearl, J. C. and Smith, M. D. and Maguire, W. C. and Christensen, P. R. and Dason, S. and Kaelberer, M. S.},
+   journal = jgr,
+   pages = {9509-9519},
+   title = {{Mars Global Surveyor Thermal Emission Spectrometer (Tes)} observations : atmospheric temperature during aerobraking and science phasing.},
+   volume = {105},
+   year = {2000}
+}
+
+@ARTICLE{Smit:01tes,
+   author = {{Smith}, M.~D. and {Pearl}, J.~C. and {Conrath}, B.~J. and {Christensen}, P.~R.},
+    title = {Thermal Emission Spectrometer results: Mars atmospheric thermal structure and aerosol distribution},
+  journal = jgr,
+     year = 2001,
+   volume = 106,
+    pages = {23929-23945},
+      doi = {10.1029/2000JE001321},
+}
+
+@article{Hins:99,
+   author = {Hinson, D. P. and Flasar, M. and Simpson, R. A. and Twicken, J. D. and Tyler, G. L.},
+   journal = jgr,
+   pages = {26,997-27,012},
+   title = {Initial results from radio occultation measurements with Mars Global Surveyor},
+   volume = {104},
+   year = {1999}
+}
+
+@article{Keat:98,
+   author = {Keating, G. M. and Bougher S. W. and 29-coauthors.},
+   journal = {Science},
+   pages = {1672-1676},
+   title = {The structure of the upper atmosphere of Mars: {In} situ accelerometer measurements from {Mars Global Surveyor}},
+   volume = {279},
+   year = {1998}
+}
+
+@article{Mell:00,
+   author = {Mellon, M. T. and Jakosky, B. M. and Kieffer, H. H. and Christensen, P. R.},
+   journal = {Icarus},
+   pages = {437-455},
+   title = {High resolution Thermal inertia mapping from the {Mars Global Surveyor Thermal Emission Spectrometer}},
+   volume = {148},
+   year = {2000}
+}
+
+@article{Will:93,
+   author = {Williams , A. G. and Hacker , J. M.},
+   journal = blm,
+   pages = {55-74},
+   title = {Interactions between coherent eddies in the lower convective boundary layer},
+   volume = {64},
+   year = {1993}
+}
+
+@article{Will:92,
+   author = {Williams , A. G. and Hacker , J. M.},
+   journal = blm,
+   pages = {213--245},
+   title = {The composite shape and structure of coherent eddies in the convective boundary layer},
+   volume = {61},
+   year = {1992}
+}
+
+@misc{Will:9
+}
+
+@article{Ayot:96,
+   author = {Ayotte , K. W. and Sullivan , P. P. and Andrén , A. and Doney , S. C. and Holtslag , A. A. and Large , W. G. and McWilliams , J. C. and Moeng , C.-N. and Otte , M. J. and Tribbia , J. J. and Wyngaard , J. C.},
+   address = {, J. C.},
+   journal = blm,
+   pages = {131--175},
+   title = {An evaluation of neutral and convective planetary boundary-layer parameterizations relative to large eddy simulations},
+   volume = {79},
+   year = {1996}
+}
+
+@misc{Lebo:00,
+   author = {Lebonnois , S. and Toublanc , D. and Hourdin , F. and Rannou , P.},
+   howpublished = {submitted to Icarus},
+   title = {Seasonal variations of {Titan}'s atmospheric composition},
+   year = {2000}
+}
+
+@misc{Bona:00,
+   author = {Bonazzola , M. and Picon , L. and Laurent , H. and Hourdin , F. and S\`ese , G. and Pawlowska , H. and Sadourny , R.},
+   howpublished = {Submitted to J. of Geophys. Res.},
+   title = {Direct estimate of vertical profiles of horizontal wiund difvergences from {Meteosat}-5 data over the indian ocean},
+   year = {2000}
+}
+
+@misc{Hour:00THERM,
+   author = {Hourdin , F. and Couvreux , F. and Menut , L.},
+   howpublished = {submitted to J. of Atmosph. Sci.},
+   title = {Parameterisation of the dry convective boundary layer based on a mass flux representation of thermals},
+   year = {2000}
+}
+
+@misc{Crue:00,
+   author = {Cruette, D. and Marillier , A. and Dufresne , J.-L. and Granpeix , J.-Y. and Nacass , P. and Bellec , H.},
+   howpublished = {J. Atmosph. and Oceanic Tech., in press},
+   journal = {J. Atmosph. and Oceanic Tech.},
+   title = {Fast temperature and trues  airspeed measurements with the airborne ultrasonic anemometer-thermometer (AUSAT)},
+   year = {2000}
+}
+
+@misc{VanD:00,
+   author = {Van Dop , Han},
+   howpublished = {oral presentation at the General Assembly of the European Geophiscial Society, Nice},
+   title = {Progress in coutergradient theory},
+   year = {2000}
+}
+
+@article{Raym:86,
+   author = {Raymond , D. J. and Blyth , A. M.},
+   journal = jas,
+   pages = {2708--2718},
+   title = {A stochastic model for non precipitating cumulus clouds},
+   volume = {43},
+   year = {1986}
+}
+
+@phdthesis{Will:91,
+   author = {Williams , A. G.},
+   school = {Flinders University of South Australia},
+   title = {Internal structure and interactions of coherent eddies in the lower Convective Boundary Layer},
+   year = {1991}
+}
+
+@article{Eber:89,
+   author = {Ebert , E. E. and Schumann , U. and Stull , R. B.},
+   journal = jas,
+   pages = {2178-2207},
+   title = {Non local turbulent mixing in the Convective Boundary Layer evaluated from {Large-Eddy Simulation}},
+   volume = {46},
+   year = {1989}
+}
+
+@book{Pran:34,
+   author = {Prandtl , L. and Tietjens , O. G.},
+   address = {New-York},
+   publisher = {Dover Publications, Inc.},
+   series = {Engineering Societies Monographs},
+   title = {Applied hydro- and aeromechanics},
+   year = {1934}
+}
+
+@article{Alap:97,
+   author = {Alapaty , K. A. and Pleim , J. E. and Raman , S. and Niyogi , D. S. and Byun , D. W.},
+   journal = jam,
+   pages = {214--233},
+   title = {Simulation of Atmospheric Boundary Layer Processes Using Local and Nonlocal-Closure schemes},
+   year = {1997}
+}
+
+@article{Arak:74,
+   author = {Arakawa , R. A. and Schubert , W. H.},
+   journal = jas,
+   pages = {674--701},
+   title = {Interaction of a cumulus cloud ensemble with the large scale environment. Part {I}},
+   volume = {31},
+   year = {1974}
+}
+
+@article{Eman:91,
+   author = {Emanuel , Kerry A.},
+   journal = jas,
+   pages = {2313--2335},
+   title = {A scheme for representing cumulus convection in large-scale models},
+   volume = {48},
+   year = {1991}
+}
+
+@article{Plei:92,
+   author = {Pleim , Jonathan. E. and Chang , Julius. S.},
+   journal = ae,
+   pages = {965--981},
+   title = {A non-local closure model for vertical mixing in the convective boundary layer},
+   volume = {26A},
+   year = {1992}
+}
+
+@article{Holt:93,
+   author = {Holtslag , A. A. M. and Boville , B. A.},
+   journal = jc,
+   pages = {1825--1842},
+   title = {Local Versus Non-Local Boundary-Layer Diffusion in a Global Climate Model},
+   volume = {6},
+   year = {1993}
+}
+
+@article{Troe:86,
+   author = {Troen , I. and Mahrt , L.},
+   journal = blm,
+   pages = {129--148},
+   title = {A simple model of the atmospheric boundary layer: Sensitivity to surface evaporation},
+   volume = {37},
+   year = {1986}
+}
+
+@book{Well:97,
+   author = {Wells , Neil},
+   edition = {2nd},
+   publisher = {John Wiley and Sons},
+   title = {The atmosphere and ocean : A physical Introduction},
+   year = {1997}
+}
+
+@book{Salb:96,
+   author = {Salby , Murry L.},
+   publisher = {Academic Press},
+   title = {DFundamentals of Atmospheric Physics},
+   year = {1996}
+}
+
+@article{Hour:99METEO,
+   author = {Hourdin , F. H. and Idelkadi , Abderrahmane and Bonazola , M. and Fairhead , L. and Filiberti , M.-A. and Issartel , J.-P.},
+   journal = {La m\'et\'eorologie, 8eme serie},
+   title = {Exercice de simulation de dispersion atmosph\'erique pour l'accident de Tokaimura},
+   year = {1999}
+}
+
+@misc{Hour:00b,
+   author = {Hourdin, C. and Dufresnes, J-L. and Fournier, R. and Hourdin, F.},
+   howpublished = {Article in preparation},
+   title = {Net exchange reformulation of radiative transfer in the {CO$_2$} 15$\mu$m band on Mars},
+   year = {2000}
+}
+
+@misc{Mell:99,
+   author = {Mellon, M. T. and Jakosky, B.M. and Kieffer H. H. and Christensen P. R.},
+   howpublished = {In the {\it Fifth International conference on Mars}. Abstract 6131. LPI contribution No. 972 Lunar and Planetary Institute, Houston (CD-ROM).},
+   title = {High resolution mapping of thermal inertia from {Mars Global SUrveyor Thermal Emission Spectrometer}},
+   year = {1999}
+}
+
+@article{Smit:99,
+   author = {Smith , D. E. and Zuber , M. T.  and {17 coauthors}},
+   journal = {Science},
+   pages = {1495-1503},
+   title = {The global topography of {Mars} and implication for surface evolution},
+   volume = {284},
+   year = {1999}
+}
+
+@article{Houb:97,
+   author = {Houben, H. and Haberle, R. M. and Young, R. E. and Zent, A. P.},
+   journal = jgr,
+   pages = {9069-9083},
+   title = {Modeling the {Martian} seasonal water cycle},
+   volume = {102},
+   year = {1997}
+}
+
+@article{Zent:97,
+   author = {Zent, A. P. and Quinn, R. C.},
+   journal = jgr,
+   pages = {9085-9095},
+   title = {Measurements of {H$_2$O} adsorption under {Mars} like conditions: {Effect} of adsorbent heterogeneity},
+   volume = {102},
+   year = {1997}
+}
+
+@article{Clif:83,
+   author = {Clifford, S. M. and Hillel, D.},
+   journal = jgr,
+   pages = {2456-2474},
+   title = {The stability of ground ice in the equatorial region of {Mars}},
+   volume = {88},
+   year = {1983}
+}
+
+@proceedings{VanD:98,
+   editor = {Van Dop , H. and Nodop , K.},
+   pages = {4089--4378},
+   series = {Atmos. Enrionn. special issue, pp. 4089--4378},
+   title = {{ETEX}, A european tracer experiment},
+   volume = {32},
+   year = {1998}
+}
+
+@book{Fris:95,
+   author = {Frisch, U.},
+   publisher = {Cambridge University Press},
+   title = {Turbulence: the legacy of A. N. Kolmogorov},
+   year = {1995}
+}
+
+@article{Odak:97,
+   author = {Odaka, M. and Nakajima, K. and Takehiro, S. and Ishiwatari, M. and Hayashi, Y.},
+   journal = {EPS},
+   title = {A numerical study of the martian atmospheric convection with a two dimensional anelastic model},
+   year = {1997}
+}
+
+@article{Stan:98,
+   author = {Stansberry, J. A.},
+   journal = {American astronomical society},
+   pages = {4905},
+   title = {Atmospheric control of {Triton's} frost distribution},
+   volume = {30},
+   year = {1998}
+}
+
+@mastersthesis{Alla:79,
+   author = {Allard, E.},
+   school = {Ecole nationale de la m\'et\'eorologie},
+   title = {Une m\'ethode de reconnaissance des ascendances convectives individuelles},
+   type = {Rapport de stage},
+   year = {1979}
+}
+
+@article{Renn:98,
+   author = {Renno, N. O. and Burkett, M. L. and Larkin, M. P.},
+   journal = jas,
+   pages = {3244--3252},
+   title = {A simple thermodynamical theory for dust devils},
+   volume = {55},
+   year = {1998}
+}
+
+@article{Abde:97,
+   author = {Abdella, K. and McFarlane, N.},
+   journal = jas,
+   pages = {1850--1867},
+   title = {A new second-order turbulence closure scheme for the planetary boundary layers},
+   volume = {54},
+   year = {1997}
+}
+
+@article{Stul:84,
+   author = {Stull , Roland B.},
+   journal = jas,
+   pages = {3351--3367},
+   title = {Transilient Turbulence Theory. {Part I}: The concept of Eddy-Mixing  across finite distances},
+   volume = {41},
+   year = {1984}
+}
+
+@book{Nume:86,
+   publisher = {William H.},
+   title = {Numerical Recipies: the art of scientific computing},
+   year = {1986}
+}
+
+@book{Galp:93,
+   author = {Galperin, B. and Orszag, S. A.},
+   publisher = {Cambridge University Press},
+   title = {Large eddy simulation of complex engineering and geophysical flows},
+   year = {1993}
+}
+
+@article{Moen:88,
+   author = {Moeng, C. and Wyngaard, J. C.},
+   journal = jas,
+   number = {23},
+   pages = {3573--3587},
+   title = {Spectral analysis of large-eddy simulations of the convective bounadary layer},
+   volume = {45},
+   year = {1988}
+}
+
+@article{Andr:78,
+   author = {Andr\'e, J. C. and De Moor, G. and Lacarr\`ere, P. and Therry, G. and du Vachat, R.},
+   journal = jas,
+   pages = {1861--1883},
+   title = {Modeling the 24-hour evolution of the mean and turbulent structures of the planetary boundary layer},
+   volume = {35},
+   year = {1978}
+}
+
+@article{Ogur:61,
+   author = {Ogura, Y. and Phillips, N. A.},
+   journal = jas,
+   pages = {173--179},
+   title = {Scale analysis of deep and shallow convection in the atmosphere},
+   volume = {19},
+   year = {1962}
+}
+
+@article{Lipp:90,
+   author = {Lipps, F. B.},
+   journal = jas,
+   number = {14},
+   pages = {1794--1798},
+   title = {On the anelastic approximation for deep convection},
+   volume = {47},
+   year = {1990}
+}
+
+@article{Dutt:68,
+   author = {Dutton, J. A. and Fichtl, G. H.},
+   journal = jas,
+   pages = {241--254},
+   title = {Approximate equations of motion for gases and liquids},
+   volume = {26},
+   year = {1968}
+}
+
+@article{Goug:68,
+   author = {Gough, D. O.},
+   journal = jas,
+   pages = {448--456},
+   title = {The anelastic approximation for thermal convection},
+   volume = {26},
+   year = {1968}
+}
+
+@article{Lipp:82,
+   author = {Lipps, F. B. and Hemler, R. S.},
+   journal = jas,
+   pages = {2192--2210},
+   title = {A scale analysis of deep moist convection and some related numerical calculations},
+   volume = {39},
+   year = {1982}
+}
+
+@article{Scin:92,
+   author = {Scinocca, J. F. and Shepherd, T. G.},
+   journal = jas,
+   number = {1},
+   pages = {5--27},
+   title = {Nonlinear wave-activity conservation laws and hamiltonian structure for the two-dimensional anelastic equations},
+   volume = {49},
+   year = {1992}
+}
+
+@article{Maso:88,
+   author = {Mason, P. J.},
+   journal = jas,
+   number = {11},
+   pages = {1492--1516},
+   title = {Large-eddy simulation of the convective atmospheric boundary layer},
+   volume = {46},
+   year = {1988}
+}
+
+@article{Wilh:72,
+   author = {Wilhelmson, R. and Ogura, Y.},
+   journal = jas,
+   pages = {1295--1307},
+   title = {The pressure perturbation and the numerical modelling of a cloud},
+   volume = {29},
+   year = {1972}
+}
+
+@article{Dear:72,
+   author = {Deardorff, J. W.},
+   journal = jgr,
+   number = {30},
+   pages = {5900--5904},
+   title = {Theoretical expression for the countergradient vertical heat flux},
+   volume = {77},
+   year = {1972}
+}
+
+@book{Land:89,
+   author = {Landau, L. and Lifchitz, E.},
+   publisher = {Editions {Mir} {Moscou}},
+   title = {M\'ecanique des fluides},
+   volume = {6},
+   year = {1989}
+}
+
+@book{Stul:88,
+  title={{An introduction to boundary layer meteorology}},
+  author={Stull, R.B.},
+  year={1988},
+  publisher={Kluwer Academic Publishers, Dordrecht}
+}
+
+@article{Sode:90,
+   author = {Soderblom, L. A. and Kieffer, S. W. and Becker, T. L. and Brown, R. H. and Cook, A. F. and Hansen, C. J. and Johnson, T. V. and Kirk, R. L. and Shoemaker, E. M.},
+   journal = {Science},
+   pages = {410-415},
+   title = {Triton's geyser-like plumes : Discovery and basic characterization},
+   volume = {250},
+   year = {1990}
+}
+
+@article{Atki:96,
+   author = {Atkinson, B. W. and Zhang, J. W.},
+   journal = {Reviews of Geophysics},
+   pages = {403--431},
+   title = {Mesoscale shallow convection in the atmosphere},
+   volume = {34},
+   year = {1996}
+}
+
+@book{Lesi:90,
+   author = {Lesieur, M.},
+   publisher = {Kluwer Academic Publishers},
+   title = {Turbulence in fluids},
+   year = {1990}
+}
+
+@article{Moen:84,
+   author = {Moeng, C.},
+   journal = jas,
+   number = {13},
+   pages = {2052--2062},
+   title = {A large-eddy-simulation model for the study of planetary boundary-layer turbulence},
+   volume = {41},
+   year = {1984}
+}
+
+@article{Shut:94,
+   author = {Shutts, G. J. and Gray, E. B.},
+   journal = qjr,
+   pages = {1145--1178},
+   title = {A numerical modelling study of the geostrophic adjustement process following deep convection},
+   volume = {120},
+   year = {1994}
+}
+
+@article{Lill:62,
+   author = {Lilly, D. K.},
+   journal = {Tellus},
+   number = {2},
+   pages = {148--172},
+   title = {On the numerical simulation of buoyant convection},
+   volume = {14},
+   year = {1962}
+}
+
+@article{Herb:91,
+   author = {Herbert, F. and Sandel, B. R.},
+   journal = jgr,
+   pages = {19241-19252},
+   title = {{CH}$_4$ and haze in {Triton's} lower atmosphere},
+   volume = {96},
+   year = {1991}
+}
+
+@article{Mark:99,
+   author = {Markiewicz, W. J. and Sablotny, R. M. and Keller, H. U. and Thomas, N. and Titov, D. and Smith, P. H.},
+   journal = jgr,
+   pages = {9009-9017},
+   title = {Optical properties of the {Martian} aerosols as derived from
+ Imager for {Mars Pathfinder} midday sky brightness data},
+   volume = {104},
+   year = {1999}
+}
+
+@article{Stan:92,
+   author = {Stansberry, J. A. and Yelle, R. V. and Lunine, J. L. and McEwen, A. S.},
+   journal = {Icarus},
+   pages = {242-260},
+   title = {Triton's surface-atmosphere energy balance},
+   volume = {99},
+   year = {1992}
+}
+
+@book{Weas:67,
+   editor = {Weast, R. C.},
+   publisher = {{CRC,Cleaveland}},
+   title = {Handbook of {Chemistry and Physics}},
+   year = {1967}
+}
+
+@article{Clan:98,
+   author = {Clancy, R. T. and Sandor, B. J.},
+   journal = grl,
+   pages = {489-492},
+   title = {CO{$_2$} ice clouds in the upper atmosphere of {Mars}},
+   volume = {25},
+   year = {1998}
+}
+
+@article{Chri:98,
+   author = {Christensen, P. R. and Anderson, D. L. and Chase, S. C. and Clancy, R. T. and Clark, R.N. and Conrath, B. J. and Kieffer, H. H. and Kuzmin, R. O. and Malin, M. C. and Pearl, J. C. and Roush, T. L. and Smith, M. D.},
+   address = { Smith, M. D.},
+   journal = {Science},
+   pages = {1692-1698},
+   title = {Results from the {Mars Global Surveyor Thermal Emission Spectrometer}},
+   volume = {279},
+   year = {1998}
+}
+
+@misc{Pier:97,
+   author = {Pierrehumbert, R. T. and Erlick, C.},
+   howpublished = {J. Atmos. Sci, in press},
+   title = {On the scattering-greenhouse effect of {CO$_2$} ice clouds},
+   year = {1977}
+}
+
+@article{Hourd:98b,
+   author = {Hourdin , Frédéric and Issartel , Jean-Pierre},
+   journal = {In preparation},
+   title = {Reciprocity of transport of atmospheric tracers and CTBT monitoring of nuclear tests.},
+   year = {1998}
+}
+
+@article{Dele:94,
+   author = {Deleersnijder, E. and Luyten},
+   journal = {Applied Mathematical Modelling},
+   pages = {281-287},
+   volume = {18},
+   year = {1994}
+}
+
+@article{Forg:98dps,
+   author = {Forget, F. and Hourdin, F. and Hourdin, C. and Talagrand, O.},
+   journal = baas,
+   pages = {1023},
+   title = {Simulation of dust lifting and transport with the {LMD} {Mars} general circulation model},
+   volume = {30},
+   year = {1998}
+}
+
+@inproceedings{Forg:98erca,
+   author = {Forget, F.},
+   booktitle = {European Research Course on Atmosphere {III}},
+   editor = {C. Boutron},
+   note = {(in press)},
+   publisher = {Les Edition de physique},
+   title = {Climate and habitability of terrestrial planets around other stars},
+   year = {1998}
+}
+
+@article{Elli:98,
+   author = {Elliot, J. L. and Hammel, H. B. and Wasserman, L. H. and Franz, O. G. and McDonald, S. W. and Person, M. J. and Olkin, C. B. and Dunham, E. W. and Spencer, J. R. and Stansberry, J. A. and Buie, M. W.},
+   journal = {Nature},
+   pages = {765-767},
+   title = {Global Warming on Triton},
+   volume = {393},
+   year = {1998}
+}
+
+@article{Mayo:95,
+   author = {Mayor, M. and Queloz, D.},
+   journal = {Nature},
+   pages = {355-359},
+   title = {A {Jupiter-mass} companion to a solar-type star},
+   volume = {378},
+   year = {1995}
+}
+
+@article{Butl:96,
+   author = {Butler, P. and Marcy, G.},
+   journal = {Ap.J. Letters},
+   pages = {L153-L156},
+   title = {A Planet orbiting 47 {Uma}},
+   volume = {464},
+   year = {1996}
+}
+
+@phdthesis{Gurw:96,
+   author = {Gurwell, M. A.},
+   school = {California institute of technology},
+   title = {Planetary atmospheres: probing structure through millimeterwave observations of carbon monoxide.},
+   year = {1996}
+}
+
+@misc{Jego:98,
+   author = {Jegou, F.},
+   howpublished = {Rapport de stage de DEA, Universit{\'e} Paris 6},
+   title = { {Effets des mar\`ees atmosph\'eriques sur la circulation
+ de la moyenne atmosph\`ere martienne}},
+   year = {1998}
+}
+
+@article{From:68,
+   author = {From , J. E.},
+   journal = jcp,
+   pages = {176-189},
+   title = {A method for reducing dispersion in convective difference schemes},
+   volume = {3},
+   year = {1968}
+}
+
+@article{Hosk:81,
+   author = {Hoskins, B.J. and Karoly, D. J.},
+   journal = jas,
+   pages = {1179-1196},
+   title = {The steady linear response of a spherical atmosphere to thermal and orographic forcing},
+   volume = {38},
+   year = {1981}
+}
+
+@article{MacV:83,
+   author = {MacVean, M. K.},
+   howpublished = qjrms,
+   journal = qjrms,
+   pages = {771-783},
+   title = {The effect of horizontal diffusion on baroclinic development in a spectral model},
+   volume = {38},
+   year = {1983}
+}
+
+@article{Cole:84,
+   author = {Colella , P. and Woodward , P. R.},
+   journal = jcp,
+   pages = {174--201},
+   title = {The Piecewise parabolic method ({PPM}) for gaz-dynamical simulations},
+   volume = {54},
+   year = {1984}
+}
+
+@misc{Gree:94b,
+   author = {Greeley, R. and Blumberg, D. G. and Williams, S. H.},
+   howpublished = {Abstract of the workshop on Reponse of Eolian Processes to Global changes, Desert research Institute},
+   title = {Field measurements  of active windblown sand},
+   year = {1994}
+}
+
+@article{Shao:93,
+   author = {Shao, Y. and Raupach, M. R.  and Findlater , P. A.},
+   journal = jgr,
+   pages = {12719-12726},
+   title = {Effect of saltation bombardment  on the entrainment  of dust by wind},
+   volume = {98},
+   year = {1993}
+}
+
+@article{Mart:95lisa,
+   author = {Marticorena, N. and Bergametti, G.},
+   journal = jgr,
+   pages = {16,415-16,430},
+   title = {Modeling the atmospheric dust cycle: design of a soil-derived emission scheme},
+   volume = {102},
+   year = {1995}
+}
+
+@inproceedings{Muhl:93,
+   author = {Muhleman, D. O. and Clancy, R. T.},
+   booktitle = {Atmospheric remote sensing by microwave radiometry},
+   chapter = {9},
+   editor = {Janssen, M. A.},
+   pages = {497-533},
+   title = {Retrieval of atmospheric parameters in planetary atmospheres from microwave spectroscopy},
+   year = {1993}
+}
+
+@article{Lell:91b,
+   author = {Lellouch, E.  and Paubert, G. and Encrenaz, T.},
+   howpublished = pss,
+   journal = pss,
+   pages = {219-224},
+   title = {Mapping of {CO} millimeter-wave lines in {Mars}'atmosphere: the spatial variability of carbon monoxide on Mars.},
+   volume = {39},
+   year = {1991}
+}
+
+@article{Elli:97,
+   author = {Elliot, J. L. and Stansberry , J. A. and Olkin, C. B. and Agner , M. A. and Davies , M. E.},
+   journal = {Science},
+   pages = {436-439},
+   title = {Triton's distorted atmosphere},
+   volume = {278},
+   year = {1997}
+}
+
+@article{Olki:97,
+   author = {Olkin, C. B.  \protect{et al.}},
+   journal = {Icarus},
+   pages = {178-201},
+   title = {The thermal structure of triton's atmosphere:  {Results from the 1993 and 1995 occultations}},
+   volume = {129},
+   year = {1997}
+}
+
+@article{Bill:98,
+   author = {Billebaud, F. and Rosenqvist , J. and Lellouch , E. and Maillard , J.-P. and Encrenaz , T. and Hourdin , F.},
+   journal = {Planetary and Space Sciences, accepted for publication},
+   title = {Observations of $CO$ in the atmosphere of {Mars} in the (2-0) vibrational band at 2.35 microns},
+   year = {1998}
+}
+
+@article{Bill:98b,
+   author = {Billebaud , F. and Rosenqvist , J. and Hourdin F.},
+   journal = aa,
+   title = {Observations of CO in the atmosphere of Mars in the (2-0) vibrational band at 2.35 microns},
+   year = {1998}
+}
+
+@misc{Defr:00,
+   author = { Defraigne , P. and de Viron , O. and Dehant , V. and Van Hoolst , T. and Hourdin , F.},
+   howpublished = {JGR},
+   title = {Mars atmospheric rotation induced by atmospheric CO2 and winds},
+   year = {2000}
+}
+
+@misc{Hech:97,
+   author = {Hechler, M.},
+   howpublished = {M.A.S. working paper n$^o$398b},
+   title = {{Mars Express} mission analysis: proposed orbits},
+   year = {1997}
+}
+
+@article{Owen:79,
+   author = {Owen, T. and Cess, R. D.  and Ramanathan , V.},
+   journal = {Nature},
+   pages = {640-642},
+   title = {Early {Earth: An enhanced carbon dioxide greenhouse to compensate for reduced solar luminocity}},
+   volume = {277},
+   year = {1979}
+}
+
+@article{Toub:95,
+   author = {Toublanc , D. and Parisot , J. P. and Brillet , J. and Gautier , D. and Raulin , F. and McKay , C. P.},
+   journal = {Icarus},
+   pages = {2-26},
+   title = {Photochemical modelling of {Titan's} atmosphere},
+   volume = {113},
+   year = {1995}
+}
+
+@article{Forg:98grl,
+   author = {Forget, F.},
+   journal = grl,
+   pages = {1105-1109},
+   title = {Improved optical properties of the {Martian} atmospheric dust for radiative transfer calculations in the infrared},
+   volume = {25},
+   year = {1998}
+}
+
+@article{Forg:97,
+   author = {Forget,  F. and Pierrehumbert, R. T.},
+   journal = {Science},
+   pages = {1273-1276},
+   title = {Warming early {Mars} with carbon dioxide clouds that scatter infrared radiation},
+   volume = {278},
+   year = {1997}
+}
+
+@article{Carr:95,
+   author = {Carr, M. H.},
+   journal = jgr,
+   pages = {7479-7505},
+   title = {The {Martian} drainage system and the origin of valley networks and fretted channels},
+   volume = {100},
+   year = {1995}
+}
+
+@article{Ghil:97,
+   author = {Ghil , M. and Ide , K. and Benett , A. and Courtier , P. and Kimoto , M. and Nagata , M. and Saiki , M. and Sato , M.},
+   journal = jmsj,
+   pages = {111--196},
+   title = {Data assimilation in Meteorology and Oceanography : Theory and Practice},
+   volume = {75},
+   year = {1997}
+}
+
+@article{Carr:97,
+   author = {Carr, M. H. and Chuang, F. C.},
+   journal = jgr,
+   pages = {9145-9152},
+   title = {Martian drainage densities},
+   volume = {102},
+   year = {1997}
+}
+
+@article{Tala:97,
+   author = {Talagrand , O.},
+   journal = jmsj,
+   pages = {191-209},
+   title = {Assimilation of Observations : An introduction},
+   volume = {75},
+   year = {1997}
+}
+
+@misc{Stan:95,
+   author = {Stansberry, J. A.  and Haberle, R. M. and McKay, C. P.},
+   howpublished = {Paper presented at the 27th Annual Meeting of the Division for Planetary Science of the AAS, Hawaii, October 9, 1995},
+   year = {1995}
+}
+
+@article{Step:90,
+   author = {Stephens , G. L. and Tsay, S-C  and Stackhouse , P. W. and Flatau , P. J.},
+   journal = jas,
+   pages = {1742-1753},
+   title = {The relevance of the Microphysical and radiative properties of cirrus clouds to climate and climatic feedback},
+   volume = {47},
+   year = {1990}
+}
+
+@article{Wood:96,
+   author = {Wood, S. E. and Richardson, M. I. and Paige , D. A.},
+   journal = baas,
+   pages = {1065},
+   title = {A microphysical model of {CO$_2$} snow on {Mars}},
+   volume = {28},
+   year = {1996}
+}
+
+@article{Jens:94,
+   author = {Jensen, E. J. and Kinne, S. and Toon, O. B.},
+   journal = grl,
+   pages = {2023-2026},
+   title = {Tropical cirrus cloud radiative forcing: Sensitivity studies},
+   volume = {21},
+   year = {1994}
+}
+
+@article{Samu:67,
+   author = {Samuelson, R. E.},
+   journal = {Astrophys. J.},
+   pages = {782-798},
+   title = {Greenhouse effect in semi-infinite atmospheres: {Application} to {Venus}},
+   volume = {147},
+   year = {1967}
+}
+
+@article{Saga:97,
+   author = {Sagan, C.  and Chyba, C.},
+   journal = {Science},
+   pages = {1217-1221},
+   title = {The early faint young sun paradox: organic shielding of ultraviolet-labile greenhouse gases},
+   volume = {276},
+   year = {1997}
+}
+
+@article{Kast:97,
+   author = {Kasting, J. F.},
+   journal = {Science},
+   pages = {1213-1215},
+   title = {Warming early earth and mars},
+   volume = {276},
+   year = {1997}
+}
+
+@article{Cald:92,
+   author = {Cadeira, K. and Kasting, J. F},
+   journal = {Nature},
+   pages = {226-228},
+   title = {Susceptibility of the early Earth to irreversible glaciation caused by carbon dioxide clouds},
+   volume = {359},
+   year = {1992}
+}
+
+@article{Doug:93,
+   author = {Douglass , A. and Rood , R. and Waters , J. and Froidevaux , L. and Read , W. and Elson , L. and Geller , M. and Chi , Y. and Cerniglia , M. and Steenrod , S.},
+   journal = grl,
+   pages = {1271-1274},
+   title = {A {3D} simulation of the early winter distribution of reactive chlorine in the north polar vortex},
+   volume = {20},
+   year = {1993}
+}
+
+@article{Murp:95,
+   author = {Murphy, J.R. and Pollack, J. B.  and Haberle, R. M. and Leovy , C. B.  and Toon, O. B.  and Schaeffer, J.},
+   journal = jgr,
+   pages = {26357-26376},
+   title = {Three-dimensional numerical simulation of {Martian} global dust storms},
+   volume = {100},
+   year = {1995}
+}
+
+@article{Alle:91,
+   author = {Allen , Dale J. and Douglass , Anne R. and Rood , Richard B. and Guthrie , Paul D.},
+   journal = mwr,
+   pages = {2456--2464},
+   title = {Application of a monotonic upstream-biased transport scheme to three dimensional constituent transport calculations},
+   volume = {119},
+   year = {1991}
+}
+
+@article{Will:89,
+   author = {Williamson , David and Rasch , Philip J.},
+   journal = mwr,
+   pages = {102--127},
+   title = {Two Dimensional Semi-Lagrangian Transport with shape-preserving interpolation},
+   volume = {117},
+   year = {1989}
+}
+
+@article{Lin:96,
+   author = {Lin , Shian-Jiann and Rood, R. B.},
+   journal = mwr,
+   pages = {2046--2070},
+   title = {Multi-Dimensional Flux Form Semi-Lagrangian Transport Schemes},
+   volume = {124},
+   year = {1996}
+}
+
+@article{Godu:59,
+   author = {Godunov , S. K.},
+   journal = {Math. Sb.},
+   pages = {271-290},
+   title = {Finite-Difference Methods for the numerical computations of equations of gas dynamics},
+   volume = {7},
+   year = {1959}
+}
+
+@article{Rood:87,
+   author = {Rood , Richard B.},
+   journal = rg,
+   pages = {71-100},
+   title = {Numerical advection algorithms and their role in atmospheric transport and chemistry models},
+   volume = {25},
+   year = {1987}
+}
+
+@article{Wils:97,
+   author = {Wilson, R. J.},
+   journal = grl,
+   pages = {123-126},
+   title = {A general circulation model of the {Martian} polar warming},
+   volume = {24},
+   year = {1997}
+}
+
+@article{Spra:96,
+   author = {Sprague, A. L. and Hunten, D. M. and Hill, R. E. and Risk, B. and Wells, W. K.},
+   journal = jgr,
+   pages = {23,229-23,241},
+   title = {Martian water vapor, 1988-1995},
+   volume = {101},
+   year = {`1996}
+}
+
+@inproceedings{Poll:93msatt,
+   author = {Pollack, J. B. and Forget F. and Haberle , R.M. and Schaeffer , J. and Lee , H.},
+   address = {Lunar and Planetary Institute, Houston},
+   booktitle = {Mars: past, present and future.{Results from the MSATT program}},
+   journal = {LPI},
+   pages = {43},
+   series = {{LPI} Technical report},
+   title = {Controls on the {CO_2} seasonal cycle},
+   volume = {43P},
+   year = {1993}
+}
+
+@article{Edou:96,
+   author = {Edouard , S. and Legras , B. and Lef\`evre , F. and Eymard , R.},
+   journal = {Nature},
+   title = {The effect of small-scale inhomogeneities on ozone depletion in the {Artic}},
+   volume = {384},
+   year = {1996}
+}
+
+@article{Edou:96a,
+   author = {Edouard , S. and Legras , B. and Zeitlin , V.},
+   journal = jgr,
+   number = {D11},
+   pages = {16771-16779},
+   title = {The effect of dynamical mixing in a simple model of the ozone hole},
+   volume = {101},
+   year = {1996}
+}
+
+@article{Kast:93,
+   author = {Kasting,  J.F. and Whitmire , D. P. and Reynolds, R. T.},
+   journal = {Icarus},
+   pages = {108-128},
+   title = {Habitable zones around main sequence stars},
+   volume = {101},
+   year = {1993}
+}
+
+@book{Doyl:96,
+   address = {Menlo Park, California},
+   editor = {Doyle, L. R.},
+   publisher = {Travis House Pulications},
+   title = {Circumstellar Habitable Zone},
+   year = {1996}
+}
+
+@article{Josh:97,
+   author = {Joshi, M. M. and Haberle, R. M. and Reynolds, R. T.},
+   journal = {Icarus},
+   pages = {450-465},
+   title = {Simulations of the atmospheres of synchronously rotating terrestrial planets orbiting {M} dwarfs: conditions for atmospheric collapse and the implications for habitability},
+   volume = {129},
+   year = {1997}
+}
+
+@article{Will:97a,
+   author = {Williams, D. M. and Kasting, J. F.},
+   journal = {Icarus},
+   pages = {254-267},
+   title = {Habitable planets with high obliquities},
+   volume = {129},
+   year = {1997}
+}
+
+@article{Will:97b,
+   author = {Williams, D. M. and Kasting, J. F. and Wade, R. A.},
+   journal = {Nature},
+   pages = {234-236},
+   title = {Habitable moons around extrasolar planets},
+   volume = {385},
+   year = {1997}
+}
+
+@article{Gera:88,
+   author = {Gerard, J. C. and Francois, L. M.},
+   journal = {Annales Geophysicae},
+   pages = {101-112},
+   title = {A sensitivity study of the effects of solar luminosity changes on the Earth's global temperature},
+   volume = {6},
+   year = {1988}
+}
+
+@article{Brac:93,
+   author = {Brack, A.},
+   journal = {Orig. of Life},
+   pages = {23},
+   volume = {3-10},
+   title = {Liquid water and the origin of life},
+   year = {1993}
+}
+
+@inproceedings{Saga:96,
+   author = {Sagan, C.},
+   booktitle = {Circumstellar Habitable Zones},
+   chapter = {1},
+   editor = {Doyle, L. R.},
+   pages = {3-14},
+   title = {Circumstellar habitable zones: an introduction},
+   year = {1996}
+}
+
+@inproceedings{Whit:96,
+   author = {Whitmire, D. P. and Reynolds, R. T.},
+   booktitle = {Circumstellar Habitable Zones},
+   editor = {Doyle, L. R.},
+   pages = {117-142},
+   title = {Circumstellar habitable zones: Astronomical considerations},
+   year = {1996}
+}
+
+@article{Dona:82,
+   author = {Donahue, T. M. and Hoffman, J. H. and Hodges, R. R. and Watson, A. J.},
+   journal = {Science},
+   pages = {630-633},
+   title = {Venus was wet: a measurement of the ratio of deuterium to hydrogen},
+   volume = {216},
+   year = {1982}
+}
+
+@article{Grin:93,
+   author = {Grinspoon, D. H.},
+   journal = {Nature},
+   pages = {428-431},
+   title = {Implications of the high {D/H} ratio for the sources of water in Venus' atmosphere},
+   volume = {363},
+   year = {1993}
+}
+
+@article{Elli:96,
+   author = {Elliot , J. L. and Stansberry, J. A. and Olkin, C. B.},
+   journal = baas,
+   pages = {1079},
+   title = {Triton's distorted atmosphere},
+   volume = {28},
+   year = {1996}
+}
+
+@article{Stan:96,
+   author = {Stansberry , J. A. and Elliot, J. L. and Olkin, C. B.},
+   journal = baas,
+   pages = {1079},
+   title = {Strong zonal winds in {Triton's (and Pluto's?)} middle atmosphere},
+   volume = {28},
+   year = {1996}
+}
+
+@inproceedings{Harr:84,
+   author = {Harris, A. W.},
+   booktitle = {{Uranus and Neptune}},
+   editor = {Bergstralh, J. T.},
+   organization = {NASA CP-2330},
+   pages = {357-376},
+   title = {Physical properties of {Neptune and Triton} inferred from the orbit of {Triton}},
+   year = {1984}
+}
+
+@inproceedings{Yell:95,
+   author = {Yelle, R. V. and Lunine, J. I. and Pollack, J. B. and Brown, R. H.},
+   booktitle = {Neptune and {Triton}},
+   editor = {Cruikshank, D. P.},
+   pages = {1031-1105},
+   publisher = {The university of {Arizona} press},
+   title = {Lower atmospheric structure and surface-atmosphere interactions on {Triton}},
+   year = {1995}
+}
+
+@inproceedings{Gurr:92,
+   author = {Gurrola, E. M. and Marouf, E. A. and Eshleman, V. R. and Tyler, G. L. and Rosen, P. A.},
+   booktitle = {Neptune and {Triton}, Abstract book},
+   pages = {28},
+   publisher = {The university of {Arizona} press},
+   title = {Analysis of {Voyager} radio occultation observations of {Triton}},
+   year = {1992}
+}
+
+@article{Caba:92,
+   author = {Cabane , M. and Chassefi\`ere , E. and Israel , G.},
+   journal = {Icarus},
+   pages = {176-189},
+   title = {Formation and growth of photochemical aerosols in {Titan's} atmosphere},
+   volume = {96},
+   year = {1992}
+}
+
+@article{Caba:93,
+   author = {Cabane , M. and Rannou , P. and Chassefi\`ere , E. and Israel , G.},
+   journal = pss,
+   pages = {257-267},
+   title = {Fractal aggregates in {Titan's} atmosphere},
+   volume = {41},
+   year = {1993}
+}
+
+@article{Caba:94,
+   author = {Cabane , M. and Chassefi\`ere , E.},
+   journal = pss,
+   pages = {47-65},
+   title = {Laboratory simulations of {Titan's} atmosphere},
+   volume = {43},
+   year = {1994}
+}
+
+@article{Bote:95,
+   author = {Botet, R. and Rannou , P. and Cabane , M.},
+   journal = {J. Physics A},
+   pages = {297-316},
+   title = {Sensitivity of some optical properties of fractals to the cut-off functions},
+   volume = {28},
+   year = {1995}
+}
+
+@article{Bote:97,
+   author = {Botet , R. and Rannou , P. and Cabane , M.},
+   journal = {Applied Optics, in press},
+   title = {Mean field scattering aproximation of {Mie} scattering by fractal aggregates of identical spheres},
+   year = {1997}
+}
+
+@article{Leva:97,
+   author = {Levasseur-Regourd , A.-C. and Cabane , M. and  Worms , J. C. and Haudebourg, V.},
+   journal = {Advances in Space Research, in press},
+   title = {Physical properties of dust in the Solar System: relevance of a computational approach and of measurements under microgravity conditions},
+   year = {1997}
+}
+
+@article{Rann:93,
+   author = {Rannou , P. and Cabane , M. and Chassefi\`ere , E.},
+   journal = grl,
+   pages = {967-970},
+   title = {Growth of aerosols in {Titan's} atmosphere and related time scales : a stochastic approach},
+   volume = {20},
+   year = {1993}
+}
+
+@article{Rann:97,
+   author = {Rannou , P. and Cabane , M. and Botet , R.  and Chassefi\`ere , E.},
+   journal = jgr,
+   pages = {10997-11013},
+   title = {A new interpretation of scattered light at {Titan's} limb},
+   volume = {102},
+   year = {1997}
+}
+
+@article{Rann:97b,
+   author = {Rannou , P. and McKay , C. P. and Botet , R. and Cabane , M.},
+   journal = {to be submitted to Applied Optics},
+   title = {A Semi-empirical model of absorption and scattering by isotropic fractal aggregates of spheres},
+   year = {1997}
+}
+
+@article{Rann:95,
+   author = {Rannou , P. and Cabane , M. and Chassefi\`ere , E. and Botet , R. and McKay , C. P. and Courtin , R.},
+   journal = {Icarus},
+   pages = {355-372},
+   title = {Titan's geometric albedo : Role of the fractal structure of the aerosols},
+   volume = {96},
+   year = {1995}
+}
+
+@article{Forg:96egs,
+   author = {Forget , F. and Hourdin, F. and Talagrand, O.},
+   journal = {Ann. Geophys.},
+   pages = {C797},
+   title = {Simulation of the {Martian} atmospheric polar warming with the {LMD} general circulation model},
+   volume = {14},
+   year = {1996}
+}
+
+@article{Forg:96dps,
+   author = {Forget, F.  and Hourdin, F. and Fournier, R. and Talagrand, O.},
+   journal = baas,
+   note = {Oral presentation for the 28th DPS meeting, Tucson, Arizona},
+   pages = {1066},
+   title = {Simulation of the {Martian} polar climate withe the {LMD} General Circulation model: {CO$_2$ snow} falls and upper atmosphere polar warming},
+   volume = {28},
+   year = {1996}
+}
+
+@misc{Ono:96,
+   author = {Ono , A.M. and Paige , D. A.},
+   journal = baas,
+   pages = {1060},
+   title = {
+ IRTM observations of {Martian} South Polar Frosts
+},
+   volume = {28},
+   year = {1996}
+}
+
+@misc{Forg:96gcm,
+   author = {Forget, F.},
+   howpublished = {Présentation invitée au ``Mars GCM intercomparison workshop''},
+   note = {Oxford, juillet 1996},
+   title = {Intercomparison of {GCM} simulations at winter solstice with dust storm conditions},
+   year = {1996}
+}
+
+@mastersthesis{Meno:95,
+   author = {Menou , Kristen},
+   school = {DEA d'astrophysique et t\'echniques spatiales,  {PARIS-7}},
+   title = {D\'eveloppement d'un code de transfert radiatif de l'atmosph\`ere de V\'enus},
+   year = {1995}
+}
+
+@mastersthesis{DeVa:96,
+   author = {De Vaulgrenant , Guyonne},
+   school = {DEA d'océanographie,  m\'et\'eorologie et environnement  {(PARIS-VI)}},
+   title = {Pr\'eparation de l'assimilation des observations des futures missions martiennes},
+   year = {1996}
+}
+
+@article{Cher:96,
+   author = {Cherkaoui, M. and Dufresne, J.L. and Fournier, R. and Grandpeix, J.Y. and Lahellec, A.},
+   journal = {ASME Journal of Heat Transfer},
+   pages = {401--407},
+   title = {Monte-Carlo Simulation of Radiation in Gases with a Narrow-Band Model and a Net-Exchange Formulation},
+   volume = {118},
+   year = {1996}
+}
+
+@article{Lope:95,
+   author = {Lopez-Puertas, M. and Lopez-Valverde , M.A.},
+   journal = {Icarus},
+   pages = {113-129},
+   title = {Radiative energy balance of {CO$_2$} non-{LTE} infrared emissions in the {Martian} atmosphere},
+   volume = {114},
+   year = {1995}
+}
+
+@article{Thom:79cap,
+   author = {Thomas, P. and Veverka, J. and Campos-Marquetti , R.},
+   journal = jgr,
+   pages = {4621-4633},
+   title = {Frost streaks in the south polar cap of {Mars}},
+   volume = {84},
+   year = {1979}
+}
+
+@article{Jous:90,
+   author = {Joussaume , S.},
+   journal = jgr,
+   pages = {1909-1941},
+   title = {Three-dimensional simulations od the atmospheric cycle of desert dust particles using a general circulation model},
+   volume = {95},
+   year = {1990}
+}
+
+@inproceedings{Slin:83,
+   author = {Slinn, W. G. N.},
+   booktitle = {Air -sea exchange of gases and particles},
+   editor = {Liss, P.S. and Slinn, W. G. N.},
+   pages = {299-405},
+   publisher = {D. Reidel Publishing Company},
+   title = {Air to sea transfer of particles},
+   year = {1983}
+}
+
+@article{Haya:95,
+   author = {Hayashi, J. N. and Jakosky, B. M. and Haberle , R. M.},
+   journal = jgr,
+   pages = {5277-5284},
+   title = {Atmospheric effects on the mapping of {Martian} thermal inertia and thermally derived albedo},
+   volume = {100},
+   year = {1995}
+}
+
+@book{DeVa:54,
+   author = {De Vaucouleurs , G.},
+   publisher = {Faber and Faber, London},
+   title = {Physics of the planet {Mars}},
+   year = {1954}
+}
+
+@misc{Airl:76,
+   author = {Air-liquide},
+   note = {Elsevier publication},
+   title = {Encyclopédie des gaz},
+   year = {1976}
+}
+
+@article{Kast:91,
+   author = {Kasting, J. F.},
+   journal = {Icarus},
+   pages = {1-13},
+   title = {{CO$_2$} condensation and the early climate of {Mars}},
+   volume = {94},
+   year = {1991}
+}
+
+@inproceedings{Kast:91book,
+   author = {Kasting, J. F. and Grinspoon, M. S.},
+   booktitle = {The sun in time},
+   editor = {Sonett, C.P. and Grinspoon, M.S. and Matthews, M.S.},
+   pages = {447-462},
+   title = {The faint young sun problem},
+   year = {1991}
+}
+
+@article{Kast:88,
+   author = {Kasting, J. F.},
+   journal = {Icarus},
+   pages = {472-494},
+   title = {Runaway and moist greenhouse atmosphere and the evolution of {Earth} and {Venus}},
+   volume = {74},
+   year = {1988}
+}
+
+@article{Jako:97,
+   author = {Jakosky, B. M. and Jones , J. H.},
+   journal = {Review of Geophysics},
+   pages = {1 -16},
+   title = {The history of {Martian} volatiles},
+   volume = {35},
+   year = {1997}
+}
+
+@article{Sell:69,
+   author = {Sellers, W.D.},
+   journal = jam,
+   pages = {392-400},
+   title = {A climate model based on the energy balance of the {Earth}-atmosphere system},
+   volume = {8},
+   year = {1969}
+}
+
+@article{Gera:92,
+   author = {Gerard, J.-C. and Hauglustaine , D. A. and Francois, L. M.},
+   journal = {Paleogeogr., Paleoclimatol., Paleoecol.},
+   pages = {133-150},
+   title = {The faint young sun climatic paradox: a simulation with an interactive seasonal climate-sea ice model},
+   volume = {97},
+   year = {1992}
+}
+
+@article{Long:97,
+   author = {Longdoz, B. and Francois, L. M.},
+   journal = {Global and Planetary change},
+   pages = {97-112},
+   title = {The faint young sun paradox: influence of the continental configuration and of the seasonal cycle on the climatic stability},
+   volume = {14},
+   year = {1997}
+}
+
+@article{Walk:81,
+   author = {Walker, J. C. G. and Hays, P. B. and Kasting, J. F.},
+   howpublished = jgr,
+   journal = jgr,
+   pages = {9776-9782},
+   title = {A negative feedback mechanism for the long term stabilization of the Earth's surface temperature.},
+   volume = {86},
+   year = {1981}
+}
+
+@inproceedings{Fran:93,
+   author = {Francois, L. M. and Walker, J. C. G. and Opdyke, B. N.},
+   booktitle = {Evolution of the Earth and Planets},
+   editor = {Takahashi, E. and Jeanloz, R.  and  Dubie, D.},
+   pages = {143-159},
+   publisher = {IUGG},
+   title = {The history of global weathering and the chemical evolution of the ocean-atmosphere system},
+   volume = {14},
+   year = {1993}
+}
+
+@article{Hoff:98,
+   author = {Hoffman, P. F. and Kaufman, A. J. and Halverson, G. P. and Schrag, D. P.},
+   journal = {Science},
+   pages = {1342-1346},
+   title = {A neoproterozoic snowball {Earth}},
+   volume = {281},
+   year = {1998}
+}
+
+@article{Chyb:97,
+   author = {Chyba, C. F.},
+   journal = {Nature},
+   pages = {201},
+   title = {Life on other moons},
+   volume = {385},
+   year = {1997}
+}
+
+@article{Carr:98,
+   author = {Carr, M. H. and {21 co-authors}},
+   journal = {Nature},
+   pages = {363-365},
+   title = {Evidence for aubsurface ocean on {Europa}},
+   volume = {391},
+   year = {1998}
+}
+
+@article{Scho:93,
+   author = {Schopf, J. W.},
+   journal = {Science},
+   pages = {640-646},
+   title = {Microfossils of the early archean apex chert: new evidence of the antiquity of life},
+   volume = {260},
+   year = {1993}
+}
+
+@article{Mojz:96,
+   author = {Mojzsis, S. J. and Arrhenius, G. and McKeegan, K, D. and Harrison, T. M. and Nutman, A. P. and Friend, C. R. L.},
+   journal = {Nature},
+   pages = {55-59},
+   title = {Evidence for life on Earth before 3,800 million years ago},
+   volume = {384},
+   year = {1996}
+}
+
+@article{Goug:81,
+   author = {Gough, D. O.},
+   journal = {Solar Phys.},
+   pages = {21-34},
+   title = {Solar interior structure and luminosity variations},
+   volume = {74},
+   year = {1981}
+}
+
+@article{Whit:95,
+   author = {Whitmire, D. P. and Doyle, L. R. and Reynolds, R. T. and Matese, J.J.},
+   journal = jgr,
+   pages = {5457-5464},
+   title = {A slightly more massive young sun as an explanation for warm temperature on early {Mars}},
+   volume = {100},
+   year = {1995}
+}
+
+@article{Habe:94,
+   author = {Haberle, R.M.  and Tyler, D.  and McKay, C.P. and Davis, W. L.},
+   journal = {Icarus},
+   pages = {102-120},
+   title = {A model for the evolution of {CO$_2$ on Mars}},
+   volume = {109},
+   year = {1994}
+}
+
+@article{Kass:95,
+   author = {Kass, D. M. and Yung , Y. L.},
+   journal = {Science},
+   pages = {697-699},
+   title = {Loss of atmoshere from {Mars} due to solar wind-induced sputtering},
+   volume = {268},
+   year = {1995}
+}
+
+@article{Luhm:92,
+   author = {Luhman, J. G. and Johnson, R. E. and Zhang, H. G.},
+   howpublished = grl,
+   journal = grl,
+   pages = {2151-2154},
+   title = {Evolutionary impact of sputerring of the {Martian} atmosphere by {O$^+$} pickup ions},
+   volume = {19},
+   year = {1992}
+}
+
+@misc{John:96,
+   author = {Johnson, R.E. and Schnellenberger, D. and Liu, M.},
+   howpublished = {Abstract  for the ``Workshop on evolution of {Martian} volatiles'', LPI, Houston},
+   title = {Sputtering of the atmosphere of {Mars}},
+   year = {1996}
+}
+
+@article{Poll:87,
+   author = {Pollack, J. B. and Kasting, J. F. and Richardson, S. M. and Poliakoff , K.},
+   journal = {Icarus},
+   pages = {203-224},
+   title = {The case for a wet, warm climate on early {Mars}},
+   volume = {71},
+   year = {1987}
+}
+
+@article{Kast:86,
+   author = {Kasting  J. H. and  Ackerman ,  T. P.},
+   journal = {Science},
+   pages = {1383-1385},
+   title = {Climatic consequences of very high carbon dioxide levels in the earth's early atmosphere},
+   volume = {234},
+   year = {1986}
+}
+
+@article{Chap:77,
+   author = {Chapman, C. R. and Jones, K. L.},
+   journal = aereps,
+   pages = {515-540},
+   title = {Cratering and obliteration history of {Mars}},
+   volume = {5},
+   year = {1977}
+}
+
+@article{Tito:95,
+   author = {Titov , D.V.  and Rosenqvist , J.  and Moroz, V. I.  and Grigoriev , A. V. and Arnold, G.},
+   journal = asr,
+   pages = {23-33},
+   title = {Evidences of the regolith-atmosphere water exchange on {Mars} from the {ISM  (Phobos2)} infrared spectrometer observations},
+   volume = {16-6},
+   year = {1995}
+}
+
+@article{Yell:91,
+   author = {Yelle , R. V. and Lunine , J. I. and Hunten , D. M.},
+   journal = {Icarus},
+   pages = {347-358},
+   title = {Energy balance and plume dynamics in {Triton's} lower atmosphere},
+   volume = {89},
+   year = {1991}
+}
+
+@article{Ryan:79,
+   author = {Ryan , J. A.  and Henry, R. M.},
+   journal = jgr,
+   pages = {2821-2829},
+   title = {Mars atmospheric phenomena during major dust storms as measured at surface},
+   volume = {84},
+   year = {1979}
+}
+
+@article{Thom:85,
+   author = {Thomas,  P.C. and Gierasch , P. J.},
+   journal = {Science},
+   pages = {175-177},
+   title = {Dust devils on {Mars}},
+   volume = {230},
+   year = {1985}
+}
+
+@article{Josh:95b,
+   author = {Joshi , M. M. and Lawrence , B. N. and Lewis , S. R.},
+   journal = jgr,
+   pages = {21235-21245},
+   title = {Gravity wave dragin {3D} atmospheric models of  {Mars}},
+   volume = {100},
+   year = {1995}
+}
+
+@article{Forg:96spitz,
+   author = {Forget, F.  and Donzé , F. and Lahaye, G.},
+   journal = {La montagne \& Alpinisme},
+   pages = {38-41},
+   title = {Spitzberg:  {le rêve polaire}},
+   volume = {183},
+   year = {1996}
+}
+
+@article{Holl:96nat,
+author = {Hollingsworth , J. L. and Haberle, R. M. and Barnes, J.R. and Bridger, a. f. c. and Pollack, J. B. and Lee, H. and Schaeffer, J.},
+journal = {Nature},
+pages = {413-416},
+title = {Orographic control of storm zones on Mars},
+volume = {380},
+year = {1996}
+}
+
+@article{Holl:96,
+author = {Hollingsworth, J. L. and Barnes, J. R.},
+journal = jas,
+pages = {428-448},
+title = {Forced stationary waves in {Mars}' winter atmosphere},
+volume = {53},
+year = {1996}
+}
+
+@article{Conr:81,
+author = {Conrath  ,  B. J.},
+journal = {Icarus},
+pages = {246-255},
+title = {Planetary-scale wave structure in the {Martian} atmosphere},
+volume = {48},
+year = {1981}
+}
+
+@article{Banf:96,
+author = {Banfield, D.  and Toigo, A. D.  and Ingersoll , A. P.},
+journal = {Icarus},
+pages = {130-143},
+title = {Martian weather correlation length scales},
+volume = {119},
+year = {1996}
+}
+
+@article{Barn:96,
+author = {Barnes, J. R. and Haberle, R. M. and Pollack , J. B. and Lee, H. and Schaeffer , J.},
+journal = jgr,
+pages = {12753-12776},
+title = {{Mars} atmospheric dynamics as simulated by the  {NASA Ames} general circulation model, 3, winter quasi-stationary eddies},
+volume = {101},
+year = {1996}
+}
+
+@article{Lell:91,
+author = {Lellouch, E and Rosenqvist, J. and Goldstein , J. J.  and Bougher S. W.  and Paubert , G.},
+journal = {Astrophys. J.},
+pages = {383},
+title = {First absolute wind measurements in the middle atmosphere of {Mars}},
+volume = {401-406},
+year = {1991}
+}
+
+@article{Wils:96,
+author = {Wilson, R. W. and Hamilton, K.},
+journal = jas,
+pages = {1290-1326},
+title = {Comprehensive model simulation of thermal tides in the {Martian} atmosphere},
+volume = {53},
+year = {1996}
+}
+
+@article{Sant:95,
+author = {Santee, M.  L. and Crisp , D.},
+journal = jgr,
+pages = {5465-5484},
+title = {Diagnostic calculations of then circulation in the {Martian} atmosphere},
+volume = {100},
+year = {1995}
+}
+
+@article{Gree:93,
+author = {Greeley , R. and Skypeck , A. and Pollack , J. B.},
+journal = jgr,
+pages = {3183-3196},
+title = {Martian aeolian features and deposits: comparisons with general circulation model results},
+volume = {98},
+year = {1993}
+}
+
+@article{Thom:84,
+author = {Thomas , P. J. and Veverka ,  J.  and  Gineris , D. and Wong , L.},
+journal = {Icarus},
+pages = {161-179},
+title = {{``Dust streaks on Mars}},
+volume = {60},
+year = {1984}
+}
+
+@article{Coll:97,
+author = {Collins, M. and Lewis, S.R. and Read , P. L.},
+howpublished = {Submitted to {\it Advances in Space Research} for the 32th COSPAR  Scientific Assembly, Birmingham, UK},
+journal = asr,
+pages = {1395-1409},
+title = {Gravity wave drag in a global circulation model of the {Martian} atmosphere: parametrisation and validation},
+volume = {44},
+year = {1997}
+}
+
+@article{Demi:86,
+author = {Deming, D.  and  Mumma  , M. J. and Espenal, F.  and Kostiuk , T. and Zipoy , D.},
+journal = {Icarus},
+pages = {366-379},
+title = {Polar warming in the middle atmosphere of {Mars}},
+volume = {66},
+year = {1986}
+}
+
+@article{Giff:64,
+author = {Gifford JR. , F.  A.},
+journal = {Icarus},
+pages = {130-135},
+title = {The  {Martian} canals according to a purely aeolian hypothesis},
+volume = {3},
+year = {1964}
+}
+
+@article{Chas:78,
+author = {Chase , S.C. and Engel, J. L. and Eyerly , H. W. and Kieffer, H. H.  and Palluconi , F. D. and Schofield, D.},
+journal = {App. Optics},
+pages = {1243-1251},
+title = {Viking infrared thermal mappers},
+volume = {17},
+year = {1978}
+}
+
+@article{Hans:69,
+author = {Hansen , J. E.},
+journal = jas,
+pages = {478-487},
+title = {Exact and approximate solutions for multiple scaterring by cloudy and hazy planetary atmosphere},
+volume = {26},
+year = {1969}
+}
+
+@article{Gree:71,
+author = {Greenberg, J. M.  and Wang , R. T.  and Bangs, L.},
+journal = {Nature Phys. Sci},
+pages = {110-112},
+title = {Extinction by rough particles and the use of {Mie} theory},
+volume = {230},
+year = {1971}
+}
+
+@article{Deir:64,
+author = {Deirmendjian, D.},
+journal = {Applied Optics},
+key = {:},
+pages = {187-196},
+title = {Scattering and polarization properties of water clouds and hazes in the visible and infrared},
+volume = {3},
+year = {1964}
+}
+
+@book{Deir:69,
+author = {Deirmendjian , D.},
+publisher = {Elsevier},
+title = {Electromagnetic scaterring of spherical polydispersions},
+year = {1969}
+}
+
+@article{Bohr:91,
+author = {Bohren,  C. F. and Singham , S. B.},
+journal = jgr,
+pages = {5269-5277},
+title = {Backscattering by nonspherical particles: a review of methods and suggested new approaches},
+volume = {96},
+year = {1991}
+}
+
+@article{Chyl:76,
+author = {Ch\'{y}lek , P. G. and Grams , G. W.  and Pinnick , R. G.\},
+journal = {Science},
+pages = {480-482},
+title = {Light scaterring by irregular randomly oriented particles},
+volume = {193},
+year = {1976}
+}
+
+@book{Prup:78,
+author = {Pruppacher, H. R. and Klett , J. D.},
+publisher = {D. Reidel},
+title = {Microphysics of clouds and precipitation},
+year = {1978}
+}
+
+@article{Poll:80,
+author = {Pollack  , J. B. and Cuzzi , J. N.},
+journal = jas,
+pages = {868-881},
+title = {Scaterring by nonspherical particles of size comparable to wavelength: a new semi-empirical theory and its application to trpospheric aerosol},
+volume = {37},
+year = {1980}
+}
+
+@article{Helf:88,
+author = {Helfand , H. M. and Labraga , J. C.},
+journal = jas,
+pages = {113-132},
+title = {Design of a nonsingular level 2.5 second-order closure for the prediction of atmospheric turbulence},
+volume = {45},
+year = {1988}
+}
+
+@article{Blac:62,
+author = {Blackadar , A. K.},
+journal = jgr,
+pages = {3095-3102},
+title = {The vertical distribution of wind and turbulent exchange in neutral atmosphere},
+volume = {67},
+year = {1962}
+}
+
+@article{Galp:88,
+author = {Galperin , B. A. and Kantha , L. H. and Hassid , S. and Rosati  , A.},
+journal = jas,
+pages = {55-62},
+title = {A quasi-equilibrium turbulent energy model for geophysical flows},
+volume = {45},
+year = {1988}
+}
+
+@article{Rous:91,
+author = {Roush, T. and Pollack , J. B. and Orenberg , J.},
+journal = {Icarus},
+pages = {191-208},
+title = {Derivation of midinfrared ({5-25~$\mu$m}) optical constants of some silicates and palagonite},
+volume = {94},
+year = {1991}
+}
+
+@article{Rous:92,
+author = {Roush, T. L. and Roush , E. A. and Singer , R. B.  and Lucey , P. G.},
+journal = {Icarus},
+pages = {42-50},
+title = {Estimate of absolute flux and radiance factor of localized regions on {Mars} in the  2-4{$\mu$m} wavelength region},
+volume = {99},
+year = {1992}
+}
+
+@article{Habe:90,
+author = {Haberle, R.M. and Jakosky , B.M.},
+journal = jgr,
+pages = {1423-1437},
+title = {Sublimation and transport of water from the north residual polar cap on Mars},
+volume = {95},
+year = {1990}
+}
+
+@article{Ocke:97,
+author = {Ockert-Bell, M. E.  and Bell III, J. F.  and McKay , C.P.
+and Pollack , J.B. and Forget , F.},
+journal = jgr,
+pages = {9039-9050},
+title = {Absorption and scattering properties of the {Martian} dust in the solar wavelengths},
+volume = {102},
+year = {1997}
+}
+
+@techreport{Read:96,
+author = {Read, P.L. and  Collins , M. and Lewis , S.R. and Taylor , W. and Talagrand , O. and Forget , F. and Hourdin , F.},
+institution = {E.S.A.},
+title = {The {Martian} environment},
+year = {1996}
+}
+
+@article{Read:97,
+author = {Read, P. L. and Collins, M. and Forget, F. and Fournier, R. and Hourdin, F.  and Lewis, S. R. and Talagrand, O. and Taylor, W. and Thomas, N. P. J.},
+journal = asr,
+pages = {1267-1270},
+title = {A {GCM} climate database for Mars: for mission planning and for scientific studies.},
+volume = {19},
+year = {1997}
+}
+
+@inproceedings{Forg:97blois,
+author = { Forget, F. and Hourdin, F. and Hourdin, C. and Fournier, R. and Talagrand, O. and Collins, M.  and Lewis, S. R. and Read, P. L.   and  Huot., J-P.},
+booktitle = {Planetary system, the long view},
+note = {IXth Blois meeting},
+publisher = {Diderot Editeurs},
+title = {A {Martian} climate database},
+year = {1997}
+}
+
+@article{Forg:99,
+author = { Forget, F. and Hourdin, F. and Fournier, R. and Hourdin, C. and Talagrand, O. and Collins, M.  and Lewis, S. R. and Read, P. L.  and  Huot., J-P.},
+journal = jgr,
+pages = {24,155-24,176},
+title = {Improved general circulation models of the {Martian}
+atmosphere from the surface to above 80~km},
+volume = {104},
+year = {1999}
+}
+
+@article{Lewi:99,
+author = {Lewis, S. R. and Collins, M.  and Read, P. L. and Forget, F. and Hourdin, F. and Fournier, R. and Hourdin, C. and Talagrand, O. and  Huot., J-P.},
+journal = jgr,
+pages = {24,177-24,194},
+title = {A Climate Database for {Mars}},
+volume = {104},
+year = {1999}
+}
+
+@unpublished{Lewi:99jgr,
+author = {Lewis, S. R. and Collins, M.  and Read, P. L. and Forget, F. and Hourdin, F. and Fournier, R. and Hourdin, C. and Talagrand, O. and  Huot., J-P.},
+note = {\protect{\it J. Geophys. Res.}, this issue},
+title = {A Climate Database for {Mars}},
+year = {1999}
+}
+
+@article{Smit:96,
+author = {Smith , D. E. and Zuber  , M. T.},
+journal = {Science},
+pages = {184-188},
+title = {The shape of {Mars} and the topographic signature of the hemispheric dichotomy},
+volume = {271},
+year = {1996}
+}
+
+@article{Wu:78,
+author = {Wu , S. S. C.},
+journal = {Icarus},
+pages = {417-440},
+title = {Mars synthetic topographic mapping},
+volume = {33},
+year = {1978}
+}
+
+@article{Pime:74,
+author = {Pimentel, G.C.  and  Forney, P.B. and Herr, K.C.},
+journal = jgr,
+pages = {1623-1634},
+title = {Evidence about hydrate and solid water in the {Martian} surface from the 1969 {Mariner} infrared spectrometer},
+volume = {79},
+year = {1974}
+}
+
+@article{Rizk:95,
+author = {Rizk, B. and Haberle , R. M. and Hunten , D.M. and Pollack , J. B.},
+journal = {Icarus},
+pages = {39-50},
+title = {Meridional transport and water reservoir in southern {Mars} during 1988-1989},
+volume = {118},
+year = {1995}
+}
+
+@article{Chri:86,
+author = {Christensen , P. R.},
+journal = {Icarus},
+pages = {217-238},
+title = {The spatial distribution of rocks on {Mars}},
+volume = {68},
+year = {1986}
+}
+
+@article{Chri:82,
+author = {Christensen, P. R.},
+journal = JGR,
+pages = {9985-9998},
+title = {Martian dust mantling and surface composition: interpretation of the thermophysical  properties},
+volume = {87},
+year = {1982}
+}
+
+@article{Lott:97,
+author = {Lott, F. and Miller, M.},
+journal = qjrms,
+pages = {101-128},
+title = {A new sub-grid scale orographic drag parametrization: its formulation and testing.},
+volume = {123},
+year = {1997}
+}
+
+@article{Palm:86,
+author = {Palmer, T. N. and Shutts, G. J. and Swinbank, R.},
+journal = qjrms,
+pages = {1001-1039},
+title = {Alleviation of a systematic westerly bias in general
+circulation and numerical weather prediction models through an orographic gravity wave drag parametrisation},
+volume = {112},
+year = {1986}
+}
+
+@article{Palm:82,
+author = {Palmer, T. N.},
+journal = jas,
+pages = {992-997},
+title = {Properties of the {Eliassen-Palm} flux for planetary scale motions},
+volume = {39},
+year = {1982}
+}
+
+@article{Edmo,
+author = {Edmon, H. J.  and Hoskins, B. J. and McIntyre , M. E.},
+journal = jas,
+pages = {2600-2616},
+title = {Eliassen-Palm cross sections for the troposphere},
+year = {1980}
+}
+
+@book{Andr:87,
+author = {Andrews, D. G. and Holton, J. R. and Leovy, C. B.},
+publisher = {Academic Press},
+title = {Middle Atmosphere Dynamics},
+year = {1987}
+}
+
+@article{Jako:83b,
+author = {Jakosky, B.M.},
+journal = {Icarus},
+pages = {1-18},
+title = {The role of sesaonal reservoirs in the {Mars} water cycle. {I.} {Seasonal} exchange of water with the regolith.},
+volume = {55},
+year = {1983}
+}
+
+@book{Pano:84,
+author = {Panofsky , Hans A. and Dutton , John A.},
+address = {New York},
+publisher = {John Wiley and Sons},
+title = {Atmospheric turbulence},
+year = {1984}
+}
+
+@article{Jako:85,
+author = {Jakosky, B. M.},
+journal = {Space Sci. Rev.},
+pages = {131-200},
+title = {The seasonal cycle of water on {Mars}},
+volume = {41},
+year = {1985}
+}
+
+@article{Kras:91,
+author = {Krasnopolsky , V. A. and Korablev, O. I. and Moroz , A. A. and Krysko , A. A. and Blamont , J. E. and Chassefiere , E.},
+journal = {Icarus},
+pages = {32-44},
+title = {Infrared solar occultation sounding of the {Martian} atmosphere by the {Phobos} spacecraft.},
+volume = {94},
+year = {1991}
+}
+
+@article{Ryan:82,
+author = {Ryan , J. A. and Sharman, R. D. and Lucich , R. D.},
+journal = jgr,
+pages = {7279-7284},
+title = {Mars water vapor, near surface.},
+volume = {87},
+year = {1982}
+}
+
+@article{Kahn:90,
+author = {Kahn, R.},
+journal = jgr,
+pages = {14,677-14,693},
+title = {Ice haze, snow, and the {Mars} water cycle.},
+volume = {95},
+year = {1990}
+}
+
+@article{Kahn:95,
+author = {Kahn, R.},
+journal = jgr,
+pages = {5265-5275},
+title = {Temperature measurements of a {Martian} local dust storm},
+volume = {100},
+year = {1995}
+}
+
+@article{Ryan:83,
+author = {Ryan, J. A. and Lucich , R. D.},
+journal = jgr,
+pages = {11005-11011},
+title = {Possible dust devils vortices on {Mars}},
+volume = {1983},
+year = {1983}
+}
+
+@article{Mich:93,
+author = {Michelangeli, D. V. and Toon , O. B. and Haberle , R. M. and Pollack , J. B.},
+journal = {Icarus},
+pages = {261-285},
+title = {Numerical simulations of the formation and evolution of water ice clouds in the {Martian} atmosphere.},
+volume = {100},
+year = {1993}
+}
+
+@article{Curr:73,
+author = {Curran , R. J. and Conrath , B. J. and Hanel , R. A. and Kunde , V. G. and Pearl , J. C.},
+journal = {Science},
+pages = {381-383},
+title = {Mars: {Mariner~9} spectroscopic evidence for {H$_2$O} ice clouds.},
+volume = {182},
+year = {1973}
+}
+
+@article{Whit:79,
+author = {White , B. R.},
+journal = jgr,
+pages = {4643-4651},
+title = {Soil transport by winds on {Mars}},
+volume = {84},
+year = {1979}
+}
+
+@article{Gree:80,
+author = {Greeley , R. and Leach R. and White , B.  and Iversen , J. and Pollack , J.},
+journal = grl,
+pages = {121-124},
+title = {Threshold windspeeds for sands on {Mars}: wind tunnel simulations},
+volume = {7},
+year = {1980}
+}
+
+@inproceedings{Whit:89,
+author = {White , B. R. and Greeley , R.},
+booktitle = {MECA Workshop on dust on {Mars} {III}},
+editor = {Lee , S.},
+institution = {L.P.I.},
+number = {89-01},
+organization = {L.P.I  Tech. Rept.},
+pages = {60-61},
+title = {Martian dust threshold measurements: simulation under heated surface conditions},
+year = {1989}
+}
+
+@inproceedings{Gree:94,
+author = {Greeley, R. and Lacchia , M. and White , B. and Leach, R. and Trilling , D. and Pollack , J.},
+booktitle = {{XXV Lunar Planet. Sci. Conf.}},
+pages = {467-468},
+title = {Dust on {Mars}: new values for wind threshold},
+year = {1994}
+}
+
+@book{Wash:48,
+author = {Washburn, E.W.},
+publisher = {New York: McGraw Hill},
+title = {International critical tables of numerical data,physics, chemistry, and technology, volume~3},
+year = {1948}
+}
+
+@article{Arvi:83,
+author = {Arvidson , R.E.  and Guiness , E. A. and Moore , H.J. and Tillman , J. and Wall , S.D.},
+journal = {Science},
+pages = {463-468},
+title = {Three {Mars} years: {Viking Lander 1} imaging observations},
+volume = {222},
+year = {1983}
+}
+
+@article{West:87,
+author = {Westphal, D.L.  and Toon , O. B. and Carlson , T. N.},
+journal = jgr,
+pages = {3027-3049},
+title = {A two-dimensional numerical investigation of the dynamics and mycrophysics of saharian dust storms.},
+volume = {92},
+year = {1987}
+}
+
+@article{Fana:82,
+author = {Fanale , F. P. and Salvail , J.R. and Banerdt , W. B. and Saunders, R. S.},
+journal = {Icarus},
+pages = {381-407},
+title = {Mars: the regolith-atmosphere -cap system and climate change},
+volume = {50},
+year = {1982}
+}
+
+@article{Must:94,
+author = {Mustard , J. F. and Bell III , J. F.},
+journal = grl,
+pages = {353-356},
+title = {New composite reflectance spectra of {Mars} from 0.4 to 3.14~{$\mu$m}.},
+volume = {21},
+year = {1994}
+}
+
+@article{Must:93,
+author = {Mustard , J. F. and Erard , S.  and Bibring , J.P. and Head , J.W.  and Hurtrez ,  S. and Langevin , Y.  and Pieters , C. M.  and Sotin , C. J.},
+journal = jgr,
+pages = {3387-3400},
+title = {The surface of {Syrtis Major}: {Composition} of the volcanic substrate and mixing with altered dust and soil},
+volume = {98},
+year = {1993}
+}
+
+@article{Bibr:89,
+author = {Bibring, J. P. and Combes , M. and Langevin, Y. and Cara , C. and Drossart, P. and Encrenaz, T. and Erard, S. and Forni, O. and Gondet, B. and Ksanfomality, L.V. and Lellouch, E. and Masson, P.},
+journal = {Nature},
+pages = {591-592},
+title = {Results from the {ISM} experiments},
+volume = {341},
+year = {1989}
+}
+
+@article{Ocke:94,
+author = {Ockert-Bell, M.E. and Pollack , J. B. and Bell, J.F.},
+journal = baas,
+pages = {1130},
+title = {Wavelength dependance of the radiative properties of {Martian} atmospheric dust},
+volume = {26},
+year = {1994}
+}
+
+@article{Pang:77,
+author = {Pang, K. and Ajello, J.M.},
+journal = {Icarus},
+pages = {63-74},
+title = {Complex refractive index of {Martian} dust: wavelength dependence and composition},
+volume = {30},
+year = {1977}
+}
+
+@article{Pang:76,
+author = {Pang, K. and Ajello , J. M. and Hord, C.W. and Egan, W. G.},
+journal = {Icarus},
+pages = {55-67},
+title = {Complex refractive index of {Martian} dust: {Mariner 9 ultraviolet observations}.},
+volume = {27},
+year = {1976}
+}
+
+@article{Chyl:78,
+author = {Ch\'{y}lek, P. and Grams, G. W.},
+journal = {Icarus},
+pages = {198-203},
+title = {Scaterring by nonspherical particles and optical properties of {Martian} dust.},
+volume = {36},
+year = {1978}
+}
+
+@article{Ande:78,
+author = {Anderson , E. and Leovy , C.},
+journal = jas,
+pages = {723-734},
+title = {Mariner 9 television limb observations of dust and ice hazes on {Mars}},
+volume = {35},
+year = {1978}
+}
+
+@article{Clan:90,
+author = {Clancy , R. T. and Muhleman , D. O. and Berge , G. L.},
+journal = jgr,
+pages = {14543-14554},
+title = {Global changes in the {0-70 km} thermal structure of the {Mars} atmosphere derived from 1975 to 1989 microwave {CO} spectra},
+volume = {95},
+year = {1990}
+}
+
+@article{Jaqu:86,
+author = {Jaquin , F. and Gierasch , P. and Kahn , R.},
+journal = {Icarus},
+pages = {442-461},
+title = {The vertical structure of limb hazes in the {Martian} atmosphere},
+volume = {68},
+year = {1986}
+}
+
+@inproceedings{Hour:95intermarsnet,
+author = {Hourdin , Fr\'ed\'eric and Talagrand , Olivier and Forget , Fran\c{c}ois and Fournier , Richard},
+booktitle = {International workshop on {INTERMARSNET}},
+note = {invited presentation},
+organization = {ESA /NASA and EGS},
+title = {Numerical simulation of the circulation of the {Martian} atmosphere in {Europe}},
+year = {1995}
+}
+
+@inproceedings{Forg:95intermarsnet,
+author = {Forget , Fran\c{c}ois and Hansen , G. B. and Pollack , J.  B.},
+booktitle = {International workshop on {INTERMARSNET}},
+note = {oral presentation},
+organization = {ESA /NASA and EGS},
+title = {Condensation of the {Martian} {CO$_2$} polar caps},
+year = {1995}
+}
+
+@inproceedings{Hour:93msatt,
+author = {Hourdin , Fr\'ed\'eric and Forget , F. and Talagrand , O.},
+address = {Lunar and Planetary Institute,  Houston},
+booktitle = {Workshop on atmospheric transport on {Mars} (MSATT meeting)},
+institution = {LPI},
+number = {93-05},
+pages = {16-17},
+series = {{LPI} Technical Report},
+title = {The annual pressure cycle on {Mars} : Results from the {LMD} {Martian} Atmospheric General Circulation Model},
+type = {Technical Report},
+year = {1993}
+}
+
+@article{Hou:84,
+author = {Hou, A. Y.},
+journal = jas,
+pages = {3437-3455},
+title = {Axisymetric circulations forced by heat and momentum sources : a simple model applicable to the  {Venus atmosphere}},
+volume = {41},
+year = {1984}
+}
+
+@inproceedings{Forg:93msatt,
+author = {Forget , F. and Pollack , J. B.},
+address = {Lunar and Planetary Institute,  Houston},
+booktitle = {Workshop on atmospheric transport on {Mars} (MSATT meeting)},
+institution = {LPI},
+number = {93-05},
+pages = {16-17},
+series = {{LPI} Technical Report},
+title = {Impact of the {CO$_2$} and {H$_2$O} Clouds of the {Martian} polar hood on the polar energy balance},
+type = {Technical Report},
+year = {1993}
+}
+
+@incollection{Forg:97book,
+author = {Forget , F.},
+booktitle = {Solar system ices},
+editor = {Schmitt , B.  and De Bergh,  C.  and Festou , M.},
+pages = {477-507},
+publisher = {Kluwer Academic},
+title = {Mars {CO$_2$} ice polar caps},
+year = {1997}
+}
+
+@misc{Forg:95cnes,
+author = {Forget, F.},
+howpublished = {Rapport Technique BA/AM/3448, CNES},
+institution = {CNES},
+number = {BA/AM/3448},
+title = {Projet Aerostat Martien~: Etude et modelisation de l'environnement atmospherique: {Conclusion pour le projet MARS 96}, bases pour des projets futurs},
+year = {1995}
+}
+
+@misc{Forg:95ice,
+author = {Forget, F.},
+howpublished = {Invited presentation at the ``Solar system ices'' symposium in Toulouse (France)},
+title = {Mars {CO$_2$} ice seasonal polar caps},
+year = {1995}
+}
+
+@article{Habe:91,
+author = {Haberle , R. M. and Jakosky , B. M.},
+journal = {Icarus},
+pages = {187-204},
+title = {Atmospheric effects on the remote determination of thermal inertia of {Mars}},
+volume = {90},
+year = {1991}
+}
+
+@article{Coll:96,
+author = {Collins, M. and Lewis, S. R. and Read, P. L. and Hourdin, F.},
+journal = {Icarus},
+pages = {344-357},
+title = {Baroclinic wave transitions in the {Martian} atmosphere},
+volume = {120},
+year = {1996}
+}
+
+@misc{Dalt:89,
+author = {Dalton , B. et al.},
+howpublished = {in ``The Case for Mars III''},
+title = {.},
+year = {1989}
+}
+
+@techreport{Four:96ddd,
+author = {Fournier , R. and Forget , F. and Collins , M. and Hourdin , F.},
+institution = {ESA},
+number = {ESA contract  (Ref.~11369/95/NL/JG(SC))},
+title = {Detailed Design Document for the {Martian} Atmospheric General Circulation Model},
+year = {1996}
+}
+
+@techreport{Four:96gcmtesting,
+author = {Fournier , R. and Forget , F. and Collins , M. and Hourdin , F.},
+institution = {ESA},
+number = {ESA contract  (Ref.~11369/95/NL/JG(SC))},
+title = {Technical note on GCM testing},
+year = {1996}
+}
+
+@techreport{Maur:91,
+author = {Mauroy ,   P.},
+institution = {CNES},
+month = {janvier},
+number = {BA/AM/949},
+title = {Evaluation pr\'eliminaire de la vitesse du vent au voisinage du sol et d\'eplacement du guiderope.},
+year = {1991}
+}
+
+@techreport{Maur:92,
+author = {Mauroy , P.},
+address = {mars},
+institution = {CNES},
+number = {BA/AM/1513},
+title = {Consequences probables du changement de date de la missionsur les performances de l'aerostat},
+year = {1992}
+}
+
+@book{Arya:88,
+author = {Arya , S. P.},
+publisher = {Academic Press},
+title = {Intoduction to micrometeorology},
+year = {1988}
+}
+
+@article{Lumm:84,
+author = {Lumme , Kari and James , Philip B.},
+journal = {Icarus},
+pages = {363-376},
+title = {Some photometric properties of the {Martian} south polar cap region during the 1971 apparition.},
+volume = {58},
+year = {1984}
+}
+
+@article{Lars:72,
+author = {Larson , H. P. and Fink, U.},
+journal = {Astrophys. Jour.},
+pages = {L91-L95},
+title = {Identification of carbon dioxide frost on the {Martian} polar caps},
+volume = {171},
+year = {1972}
+}
+
+@article{Doll:65,
+author = {Dollfus,  Audouin},
+journal = {Ann. Astrophys},
+pages = {722-747},
+title = {Etude de la plan\`{e}te {Mars} de 1954 \`{a} 1958},
+volume = {28},
+year = {1965}
+}
+
+@article{Lumm:76,
+author = {Lumme , K},
+journal = {Icarus},
+pages = {69},
+title = {On the surface brightness and geometric albedo of some {Martian} areas.},
+volume = {29},
+year = {1976}
+}
+
+@misc{Ono:95,
+author = {Ono , A.M. and Paige , D. A.},
+howpublished = {Abstract for the "Solar System Ices" international symposium, Toulouse, France},
+title = {Martian polar frosts},
+year = {1995}
+}
+
+@misc{Butl:95,
+author = {Butler, B.J. and Muhleman , D.O. and Slade , M.J.},
+howpublished = {Abstract for the "Solar System Ices" international symposium, Toulouse, France},
+title = {The difference in the residual ice caps on {Mars} as deduced from {VLA/Goldstone} radar images},
+year = {1995}
+}
+
+@article{Cape:70,
+author = {Capen , C. F. and Capen , V. W.},
+journal = {Icarus},
+pages = {100-108},
+title = {Martian north polar cap, 1962-1968},
+volume = {13},
+year = {1970}
+}
+
+@article{Iwis:82,
+author = {Iwisaki , K. and Saito , Y. and Akabane , T.},
+journal = jgr,
+pages = {10265-10269},
+title = {Martian north polar cap : 1979-1980},
+volume = {87},
+year = {1982}
+}
+
+@article{Jame:83,
+author = {James , P. B.},
+journal = baas,
+pages = {846-847},
+title = {Condensation phase of the {Martian} south polar cap},
+volume = {15},
+year = {1983}
+}
+
+@article{Hart:83,
+author = {Hartman , Dennis L.},
+journal = jas,
+pages = {817-835},
+title = {Barotropic instability of the polar night jet stream},
+volume = {40},
+year = {1983}
+}
+
+@article{Park:83,
+author = {Parker , D. C.  and Capen , C. F. and Beish , J. D.},
+journal = {Sky \& Telescope},
+pages = {218-220},
+title = {Exploring the {Martian} artic.},
+volume = {65},
+year = {1983}
+}
+
+@article{Pire:95,
+author = {Pires , C. and Vautard , R. and Talagrand , O.},
+journal = {Tellus},
+pages = {96-121},
+title = {On extending the limits of variational assimilation in nonlinear chaotic systems},
+volume = {48A},
+year = {1995}
+}
+
+@article{Elus:93,
+author = {Eluszkiewicz , Janusz},
+journal = {Icarus},
+pages = {43-48},
+title = {On the microphysical state of the {Martian} seasonal caps},
+volume = {103},
+year = {1993}
+}
+
+@book{LaCh:69,
+author = {LaChapelle , E. R.},
+publisher = {University of Washington Press, Seattle, 1969.},
+title = {Field Guide to Snow Crystals},
+year = {1969}
+}
+
+@article{Bohr:83,
+author = {Bohren, C. F.},
+journal = {J. Opt. Soc. Am.},
+pages = {1646-1652},
+title = {Colors of snow, frozen waterfalls, and icebergs},
+volume = {73},
+year = {1983}
+}
+
+@article{Calv:94,
+author = {Calvin , Wendy M. and Martin , Terry Z.},
+journal = jgr,
+number = {E10cd},
+pages = {21,143-21,152},
+title = {Spatial variability in the seasonal south polar cap of {Mars}},
+volume = {99},
+year = {1994}
+}
+
+@article{Calv:90,
+author = {Calvin , Wendy M.},
+journal = jgr,
+pages = {14,743-14,750},
+title = {Additions and corrections to the absorption coefficient of {CO$_2$} ice : applications to the {Martian} south polar cap},
+volume = {95},
+year = {1990}
+}
+
+@article{Hans:74,
+author = {Hansen ,  James E. and Travis ,  Larry D.},
+journal = {Space Sci. Rev.},
+pages = {527-610},
+title = {Light scaterring in planetary atmosphere},
+volume = {16},
+year = {1974}
+}
+
+@misc{Pa
+}
+
+@misc{Hans:95,
+author = {Hansen  ,  Garry  B.},
+howpublished = {In preparation for J.G.R.},
+title = {Spectral absorption coefficient of {CO$_2$} ice 2. {Thermal}  infrared},
+year = {1995}
+}
+
+@article{Hans:71,
+author = {Hansen, J. E.},
+journal = jas,
+pages = {1400-1426},
+title = {Multiple scatering of polarized light in planetary atmosphere. {Part II. Sunlight} reflected by terrestrial water clouds.},
+volume = {28},
+year = {1971}
+}
+
+@article{Mish:94,
+author = {Mishchenko, M. I.},
+journal = {J. Quant. Spectrosc. Radiat. Transfer},
+pages = {95-110},
+title = {Asymmetry parameters of the phase function for densely packed scattering grains},
+volume = {52},
+year = {1994}
+}
+
+@article{Lind:81,
+author = {Lindzen , R. S.},
+journal = jgr,
+pages = {9707--9714},
+title = {Turbulence and stress owing to gravity wave and tidal breakdown},
+volume = {86},
+year = {1981}
+}
+
+@article{McFa:87,
+author = {McFarlane , N. A.},
+journal = jas,
+pages = {1775--1800},
+title = {The effect of orographically excited gravity wave drag on the general circulation of the lower stratosphere and troposphere},
+volume = {44},
+year = {1987}
+}
+
+@article{Herr:70,
+author = {Herr, K. C. and Pimentel, G. C.},
+journal = {Science},
+pages = {47-49},
+title = {Evidence for solid carbon dioxide in the upper atmosphere of {Mars}},
+volume = {167},
+year = {1970}
+}
+
+@article{Gier:68,
+author = {Gierasch, P. J. and Goody, R. M.},
+journal = {Planet. Space Sci.},
+pages = {615-646},
+title = {A study of the thermal and dynamical structure of the {Martian}  lower atmosphere},
+volume = {16},
+year = {1968}
+}
+
+@article{Herr:69,
+author = {Herr , K. C. and Pimentel , G. C.},
+journal = {Science},
+pages = {496-499},
+title = {Infrared absorptions near three microns recorded over the polar caps of {Mars}},
+volume = {166},
+year = {1969}
+}
+
+@article{Hans:92,
+author = {Hansen , G.  B.},
+journal = baas,
+pages = {978},
+title = {The spectral absorption of {CO$_2$} ice from 0.18 to 4.8 microns},
+volume = {24},
+year = {1992}
+}
+
+@article{Hans:92triton,
+author = {Hansen, C. J. and Paige , D. A.},
+journal = {Icarus},
+pages = {273-288},
+title = {A thermal model for the seasonal nitrogen cycle on {Triton}},
+volume = {99},
+year = {1992}
+}
+
+@article{Brow:94,
+author = {Brown, R. H. and Kirk, R. L.},
+journal = jgr,
+pages = {1965-1981},
+title = {Coupling of volatile transport and internal heat flow on {Triton}},
+volume = {99},
+year = {1994}
+}
+
+@inproceedings{Brow:79,
+author = {Brown, G. N. and Ziegler, W. T.},
+booktitle = {Advances in cryogenic engineering},
+editor = {Timmerhaus. K. and Snyder, H. A.},
+pages = {662-670},
+publisher = {New-York, {Plenum press}},
+title = {Vapor pressure and heats of sublimation of liquids and solids of interest in cryogenics below 1-atm pressure},
+volume = {25},
+year = {1979}
+}
+
+@article{Kief:70a,
+author = {Kieffer , H. H.},
+journal = jgr,
+pages = {510-514},
+title = {Interpretation of the {Martian} polar cap spectra},
+volume = {75},
+year = {1970}
+}
+
+@article{Kief:70b,
+author = {Kieffer, H. H.},
+journal = jgr,
+pages = {501-509},
+title = {Spectral reflectance of {CO$_2$-H$_2$O} frosts},
+volume = {75},
+year = {1970}
+}
+
+@article{Clar:82,
+author = {Clark , R. N. and McCord , T. B.},
+journal = jgr,
+pages = {367-370},
+title = {Mars residual polar cap : {Earth}-based spectroscopic confirmation of water ice as a major constituent and evidence for hydrated minerals},
+volume = {87},
+year = {1982}
+}
+
+@article{Jako:83,
+author = {Jakosky , B. M.},
+journal = jgr,
+pages = {4329-4330},
+title = {Comments on "{Mars} residual north polar cap : {Earth-based} spectroscopic confirmation of water ice as a major constituent and evidence for hydrated minerals" by {R. N. Clark and T. B.  McCord}.},
+volume = {88},
+year = {1983}
+}
+
+@article{Jako:84,
+author = {Jakosky , B. M. and Barker , E. S.},
+journal = {Icarus},
+pages = {322-334},
+title = {Comparison of ground-based and {Viking Orbiter} measurements of {Martian } water vapor : variability of the seasonal cycle.},
+volume = {57},
+year = {1984}
+}
+
+@article{Jako:90,
+author = {Jakosky , B. M. and Haberle , R. M.},
+journal = jgr,
+pages = {1359-1365},
+title = {Year-to-year instability of the {Mars} south polar cap.},
+volume = {95},
+year = {1990}
+}
+
+@article{Clan:96b,
+author = {Clancy, R.T.  and Grossman , A. W. and Wolff , M. J.  and  James, P. B. and Rudy , D. J. and Billawala , Y. N. and Sandor , B. J.  and Lee , S. W.  and Muhleman , D. O.},
+journal = {Icarus},
+pages = {36-62},
+title = {Water vapor saturation at low altitudes around {Mars}
+aphelion: a key to {Mars} climate},
+volume = {122},
+year = {1996}
+}
+
+@article{Encr:95,
+author = {Encrenaz , T. and Lellouch , E. and Cernicharo , J. and Paubert , G.  and Gulkis , S.},
+journal = {Icarus},
+pages = {110-118},
+title = {A tentative detection of the {183-GHz} water vapor line in the {Martian} atmosphere: {Contraint} upon the {H$_2$O}  abundance and vertical distribution},
+year = {1995}
+}
+
+@article{Clan:96,
+author = {Clancy, R.T.  and  Wolff , M. J.  and  James, P. B.  and Smith , E. and Billawala , Y. N.  and Lee , S. W.  and Callan , M.},
+journal = jgr,
+pages = {12777-12783},
+title = {Mars ozone measurements near the 1995 aphelion: {Hubble} space telescope ultraviolet spectroscopy with the faint object spectrograph},
+volume = {101},
+year = {1996}
+}
+
+@techreport{Alli:93,
+author = {Allison , M and Chandler , M. A. and Del Genio , A. D. and Lacis , A. and Rind , D.  and Rossow , W. B. and Travis , L. D.  and Zhou , W.},
+institution = {LPI},
+number = {93-05},
+title = {The {NASA GISS}   {Mars}  general circulation model : preliminary experiments.},
+type = {Technical Report},
+year = {1993}
+}
+
+@techreport{Wils:93,
+author = {Wilson , R. J.},
+institution = {LPI},
+number = {93-05},
+title = {Three dimensional numerical simulation of thermal tides in the {Martian} atmosphere.},
+type = {Technical Report},
+year = {1993}
+}
+
+@inproceedings{Thom:92,
+author = {Thomas , P. and Squyres , S. and Herkenhoff , K. and Howard , A. and Murray , B.},
+booktitle = {Mars},
+pages = {pp. 767-795},
+publisher = {Univ. of Arizona Press, Tucson},
+title = {Polar deposits of {Mars}},
+year = {1992}
+}
+
+@inproceedings{Fana:92,
+author = {Fanale, F. P. and Postawko, S. E. and Pollack, J. B. and
+Carr, M. H. and Pepin, R. O.},
+booktitle = {Mars},
+pages = {pp. 1135-1179},
+publisher = {Univ. of Arizona Press, Tucson},
+title = {Epochal climate change and volatile history},
+year = {1992}
+}
+
+@article{Theo:93,
+author = {Th{\'e}odore , B and Lellouch , E. and Chassefiere , E. and Hauchecorne , A.},
+journal = {Icarus},
+pages = {512-528},
+title = {Solsticial temperature inversions in the {Martian} middle atmosphere : observational clues and 2-{D} modeling},
+volume = {105},
+year = {1993}
+}
+
+@article{Josh:94nat,
+author = {Joshi , M. M. and Lewis , S. R. and Read , P. L. and Catling , D. C.},
+journal = {Nature},
+month = {February},
+pages = {548-551},
+title = {Western boundary currents in the atmosphere of {Mars}},
+volume = {367},
+year = {1994}
+}
+
+@article{Josh:95,
+author = {Joshi , M. M. and Lewis , S. R. and Read P. L. and Catling , D. C.},
+journal = jgr,
+pages = {5485-5500},
+title = {Western Boundary Courrents in the {Martian}  atmosphere : Numerical simulations and observational evidence},
+volume = {100},
+year = {1995}
+}
+
+@article{Hutz:95,
+author = {Hutzell , William T. and McKay , Christopher P. and Toon , Owen B. and Hourdin , F.},
+journal = {Icarus},
+pages = {112-129},
+title = {Simulations of {Titan's} brightness by a two-dimensional haze model},
+volume = {119},
+year = {1995}
+}
+
+@misc{Cous:su,
+author = {Coustenis, A. and B{\'e}zard , B.},
+note = {Submitted for publication},
+title = {{Titan's} atmosphere from {Voyager} infrared observations: {IV} Latitudinal variations of temperature and composition},
+year = {1995}
+}
+
+@article{Beza:95,
+author = {B\'ezard , Bruno and Coustenis , Athena and McKay , Christopher P.},
+journal = {Icarus},
+pages = {267-276},
+title = {Titan's stratospheric temperature asymmetry: a radiative origin},
+volume = {113},
+year = {1995}
+}
+
+@article{Upad:94,
+author = {Upadhyaya , H. C. and Agrawal , S. and Talagrand , O.},
+journal = {Proc. Indian Nation Sci. Acad.},
+pages = {193,204},
+title = {Variational data assimilation with an adiabatic version of the {LMD} {GCM} using adjoint methods},
+volume = {60},
+year = {1994}
+}
+
+@article{Rabi:93,
+author = {Rabier , F. and Courtier , P. and Pailleux , J. and Talagrand , O. and Vasijevic , D.},
+journal = qjrms,
+pages = {845-880},
+title = {A comparison bewteen four-dimensional variational assimilation and simplified sequential assimilation relying on three-dimensional analysis},
+volume = {119},
+year = {1993}
+}
+
+@unpublished{Tala:96,
+author = {Talagrand , Olivier},
+note = {submitted to J. Meteor. Soc. Japan},
+title = {Assimilation of Observations, an Introduction},
+year = {1996}
+}
+
+@article{Li:96,
+author = {Li , Zhao-Xin},
+journal = {NATO AISI series},
+pages = {127-137},
+title = {Comparison of convection parametrizations in an atmospheric General Circulation model},
+volume = {I 34},
+year = {1996}
+}
+
+@article{Hutz:93,
+author = {Hutzell , William T. and McKay , Christopher P. and Toon , Owen B.},
+journal = {Icarus},
+pages = {162-174},
+title = {Effects of time-varying haze production on {Titan's} geometric albedo},
+volume = {105},
+year = {1993}
+}
+
+@article{Jame:87,
+author = {James , Philip B. and Pierce , Maurice  and Martin , Leonard J.},
+journal = {Icarus},
+pages = {306-312},
+title = {Martian north polar cap and circumpolar clouds: 1975-1980  {Telescopic} observation.},
+volume = {71},
+year = {1987}
+}
+
+@article{Jame:94,
+author = {James , P. B. and Clancy , R. T. and Lee , S. W. and Martin, L. J. and Singer, R. B. and Smith E. and Kahn , R. A. and Zurek , R. W.},
+journal = {Icarus},
+pages = {79-101},
+title = {Monitoring {Mars} with the {Hubble} space telescope~: 1990-1991 observations.},
+volume = {109},
+year = {1994}
+}
+
+@article{Keeg:91,
+author = {Keegan , K. D. and Bachman , J. E. and Paige , D. A.},
+journal = lps,
+pages = {701-702},
+title = {Thermal and albedo mapping of the north polar region of {Mars}},
+volume = {XXII},
+year = {1991}
+}
+
+@article{Paig:91,
+author = {Paige , D. A. and Keegan , K. D.},
+journal = lps,
+pages = {1013-1014},
+title = {Thermal and albedo mapping of the south polar region of {Mars}},
+volume = {XXII},
+year = {1991}
+}
+
+@article{Paig:90jgr,
+author = {Paige , David A. and Herkenhoff , K. E. and Murray , B. C.},
+journal = jgr,
+number = {B2},
+pages = {1319-1335},
+title = {Mariner 9 observations of the south polar cap of {Mars} : evidence for residual {CO$_2$} frost},
+volume = {95},
+year = {1990}
+}
+
+@techreport{Paig:93,
+author = {Paige ,David A.  and Crisp , D. and Santee M. L.  and Richardson , M. I.},
+institution = {L.P.I.},
+title = {IRTM brightness temperature maps of the {Martian} south polar region during the polar night : the cold spots don't move},
+type = {MSATT final meeting report.},
+year = {1993}
+}
+
+@article{Sutt:78,
+author = {Sutton , Jordan L. and Leovy , Conway B. and Tillman , James E.},
+journal = jas,
+pages = {2346-2355},
+title = {Diurnal variations of the {Martian} surface layer meteorological parameters during the first 45 sols at two {Viking} lander sites},
+volume = {35},
+year = {1978}
+}
+
+@article{Till:94,
+author = {Tillman, James E. and Landberg , Lars and Larsen , Soren E.},
+journal = jas,
+month = {june},
+number = {12},
+pages = {1709-1727},
+title = {The boundary layer of {Mars} : fluxes stability, turbulent spectra and growth of the mixed layer},
+volume = {51},
+year = {1994}
+}
+
+@article{Dyer:74,
+author = {Dyer , A. J.},
+journal = blm,
+pages = {363-372},
+title = {A review of the flux profile relationships},
+year = {1974}
+}
+
+@article{Hans:93,
+author = {Hansen , G. B.},
+journal = baas,
+number = {3},
+pages = {1034},
+title = {The spectral absorption of {CO2} ice in the thermal infrared},
+volume = {25},
+year = {1993}
+}
+
+@article{Barn:90,
+author = {Barnes , J. R.},
+journal = jgr,
+pages = {1401-1421},
+title = {Possible  effect of breaking gravity waves on the circulation of the middle atmosphere of {Mars}},
+volume = {95},
+year = {1990}
+}
+
+@article{Warr:84,
+author = {Warren , S. G.},
+journal = {Applied~Optics},
+pages = {1206-1225},
+title = {Optical constant of ice from the ultraviolet to the microwaves},
+volume = {23},
+year = {1984}
+}
+
+@article{Bell:93,
+author = {Bell,  James F. III and Calvin  , W. M. and Pollack ,  J. B.  and Crisp , D.},
+journal = {Lunar~and~Plan.~Sci.},
+pages = {83-84},
+title = {An observational search for {CO2} ice clouds on {Mars}},
+volume = {XXIV},
+year = {1993}
+}
+
+@article{Bell:90,
+author = {Bell III, J. F.  and McCord , T. B. and Owensby , P. D.},
+journal = jgr,
+pages = {14447-14461},
+title = {Observational evidence of crystalline iron oxides on {Mars}},
+volume = {95},
+year = {1990}
+}
+
+@article{Bell:93b,
+author = {Bell, James F. and Crisp , D.},
+journal = {Icarus},
+pages = {2-19},
+title = {Groundbased imaging spectroscopy of {Mars} in the near infrared : preliminary results},
+volume = {104},
+year = {1993}
+}
+
+@article{Forg:96,
+author = {Forget, F. and Pollack,  J.B.},
+journal = jgr,
+pages = {16,865-16,880},
+title = {Thermal infrared observations of the condensing {Martian} polar caps: {CO$_2$} ice temperatures and radiative budget},
+volume = {101},
+year = {1996}
+}
+
+@article{Mart:93,
+author = {Martin , Terry Z. and Richardson , Mark I.},
+journal = jgr,
+pages = {10,941-10,949},
+title = {New Dust Opacity Mapping From \protect{Viking} Infrared Thermal Mapper Data},
+volume = {98},
+year = {1993}
+}
+
+@article{Mart:93leo,
+author = {Martin , Leonard J. and Zurek , Richard W.},
+journal = jgr,
+number = {E2},
+pages = {3221-3246},
+title = {An analysis of the history of dust activity on {Mars}},
+volume = {98},
+year = {1993}
+}
+
+@article{Loui:79,
+author = {Louis , J.-F.},
+journal = blm,
+pages = {187-202},
+title = {A parametric model of vertical eddy fluxes in the atmosphere.},
+volume = {17},
+year = {1979}
+}
+
+@article{Carl:91,
+author = {Carlson, R. W. and Baines, K. H. and Encrenaz, Th. and Taylor, F,. and Drossart, P. and Kamp, L. W.  and Pollack, J. B. ad Lellouch, E. and Collard, A. D. and Calcutt , S. B. and Grinspoon  et al.},
+journal = sci,
+pages = {1541-1548},
+title = {Galileo infrared imaging spectroscopy measurements at \protect{Venus}},
+volume = {253},
+year = {1991}
+}
+
+@techreport{Till:87,
+author = {Tillman, James E. and Guest ,W.},
+institution = {National Space Sciences Data Center},
+title = {a},
+year = {1987}
+}
+
+@article{Bark:86,
+author = {Barkstrom , B. R. and Smith , G. L.},
+journal = rg,
+key = {Barkstrom and Smith,1986},
+pages = {379-390},
+title = {The \protect{E}arth \protect{R}adiation \protect{B}udget \protect{E}xperiment: Science and Implementation},
+volume = {24},
+year = {1986}
+}
+
+@article{Hubb:93,
+author = {Hubbard , W. B. \protect{et al.}},
+journal = aa,
+pages = {541-563},
+title = {The Occultation of 28 {Sgr by Titan}},
+volume = {269},
+year = {1993}
+}
+
+@article{Tala:81,
+author = {Talagrand , Olivier},
+journal = {Tellus},
+pages = {321-339},
+title = {On the mathematics of Data Assimilation},
+volume = {33},
+year = {1981}
+}
+
+@article{Char:69,
+author = {Charney , J. and Halem , M. and Jastrow , R.},
+journal = jas,
+pages = {1160-1163},
+title = {Use of Incomplete Historical Data to Infer the Present State of the Atmosphere},
+volume = {26},
+year = {1969}
+}
+
+@article{LeDi:86,
+author = {Le Dimet , F.-X. and Talagrand , O.},
+journal = {Tellus},
+pages = {97-110},
+title = {Variational algorithms for analysis and assimilation of meteorological observations: theoretical aspects},
+volume = {38A},
+year = {1986}
+}
+
+@article{Thep:91,
+author = {Th\'epaut , J.- N. and Courtier , P.},
+journal = qjrms,
+pages = {1225-1254},
+title = {Four-dimensional variational data assimilation using the adjoint of a multilevel primitive-equation model},
+volume = {117},
+year = {1991}
+}
+
+@article{Muhl:92,
+author = {Muhleman , D. O. and Grossman , A. W. and Slade , M. A. and Butler , B. J.},
+journal = baas,
+pages = {954-955},
+title = {Thes surface of \protect{Titan's} rotation: What is radar telling us?},
+volume = {24},
+year = {1992}
+}
+
+@book{Moor:83,
+author = {Moore , Patrick and Hunt , Garry and Nicolson , Iain and Cattermole , Peter},
+publisher = {Mitchell Beasley Publishers},
+title = {The Atlas of the Solar System},
+year = {1983}
+}
+
+@article{Mutc:76,
+author = {Mutch , Thomas A. and Binder , Alan B. and Huck , Friedrich O. and Levinthal , E. C. and Liebes , S. Jr. and Morris , E. C. and Patterson , W. R. and Pollack J. B. and Sagan , C. and Taylor , G. R.},
+journal = {Science},
+pages = {791-801},
+title = {The surface of \protect{Mars} : The view from the \protect{Viking}~1 Lander},
+volume = {193},
+year = {1976}
+}
+
+@article{Pick:79,
+author = {Pickersgill , Adrian O. and Hunt , Garry E.},
+journal = jgr,
+number = {B14},
+pages = {8317-8331},
+title = {The formation of \protect{Martian} Lee Waves generated by a crater},
+volume = {84},
+year = {1979}
+}
+
+@article{Pick:81,
+author = {Pickersgill , Adrian O. and Hunt , Garry E.},
+journal = jas,
+pages = {40-51},
+title = {An examination of the formation of linear lee waves generated by giant \protect{Martian} volcanoes},
+volume = {38},
+year = {1981}
+}
+
+@article{Fren:81,
+author = {French , R. G. and Gierasch , P. J. and Popp , B. D. and Yerdon , R. J.},
+journal = {Icarus},
+pages = {468-493},
+title = {Global paterns in cloud forms on Mars},
+volume = {45},
+year = {1981}
+}
+
+@article{Svit:90,
+author = {Svitek , Thomas and Murray , Bruce},
+journal = jgr,
+pages = {1495-1510},
+title = {Winter frost at {Viking  Lander} 2 site},
+year = {1990}
+}
+
+@article{Kahn:83,
+author = {Kahn , R.},
+journal = jgr,
+pages = {10189-10209},
+title = {Some observational constraints on the global-scale wind systems of \protect{Mars}},
+volume = {88},
+year = {1983}
+}
+
+@article{Kahn:84,
+author = {Kahn , R.},
+journal = jgr,
+pages = {6671-6688},
+title = {The spatial and seasonal distribution of \protect{Martian} clouds and some meteorological implications},
+volume = {89},
+year = {1984}
+}
+
+@article{Maga:87,
+author = {Magalhaes , J. A.},
+journal = {Icarus},
+pages = {442-468},
+title = {The \protect{Martian} \protect{Hadley} circulation: Comparison of "viscous" predictions to observations},
+volume = {70},
+year = {1987}
+}
+
+@article{Maga:82,
+author = {Magalhaes , J. and Gierasch , P.},
+journal = jgr,
+pages = {9975-9984},
+title = {A model of \protect{Martian} slopes winds:  Implications for eolian transport},
+volume = {87},
+year = {1982}
+}
+
+@article{Kief:79,
+author = {Kieffer , H. H.},
+journal = jgr,
+pages = {8263-8288},
+title = {Mars south polar spring and summer temperatures: a residual CO$_2$ frost},
+volume = {84},
+year = {1979}
+}
+
+@article{Gadi:78,
+author = {Gadian , A. M.},
+journal = {Icarus},
+pages = {454-465},
+title = {The dynamics of and the heat transfer by baroclinic eddies and large-scale stationnary topographically forced long waves in the \protect{Martian} atmosphere},
+volume = {33},
+year = {1978}
+}
+
+@article{Mart:74,
+author = {Martin , L. J.},
+journal = {Icarus},
+pages = {108-115},
+title = {The major \protect{Martian} dust stroms of 1971 and 1973},
+volume = {23},
+year = {1974}
+}
+
+@article{Mell:74,
+author = {Mellor , George L. and Yamada , Tetsuji},
+journal = jas,
+pages = {1791-1806},
+title = {A Hierarchy of Turbulence Closure Models for Planetary Boundary Layers},
+volume = {31},
+year = {1974}
+}
+
+@article{Mell:82,
+author = {Mellor , George L. and Yamada , Tetsuji},
+journal = {Rev. of Geophys.},
+month = {November},
+number = {4},
+pages = {851-875},
+title = {Development of a turbulence closure model for geophysical fluid problems},
+volume = {20},
+year = {1982}
+}
+
+@article{Miya:77,
+author = {Myakoda , K. and Sirutis},
+journal = bpa,
+pages = {445-447},
+title = {Comparative Integrations of Global Models with Various Parametrized Processes of Subgrid-Scale Vertical Transports: Description of the Parametrization},
+volume = {50},
+year = {1977}
+}
+
+@article{Frie:94,
+author = {Friedson , A. J.},
+journal = {Icarus},
+pages = {40-57},
+title = {Gravity waves in {Titan's} atmosphere},
+volume = {109},
+year = {1994}
+}
+
+@article{Jame:82,
+author = {James , P. B. and North , G. R.},
+journal = jgr,
+pages = {10271-10283},
+title = {The seasonal {CO$_2$} cycle on \protect{Mars} : An application of an energy balance climate model},
+volume = {87},
+year = {1982}
+}
+
+@article{Davi:77,
+author = {Davies ,  D. W. and Farmer , C. B.  and LaPorte  , D. D.},
+journal = jgr,
+pages = {3815-3822},
+title = {Behavior of volatile in {Mars}' polar areas~:  a model incorporating new experimental data.},
+volume = {82},
+year = {1977}
+}
+
+@article{Jone:79,
+author = {Jones, K.L. and Arvidson, R. E. and Guiness, E. A. and Braggs, S. L. and Wall , S. D. and Carlston , C. E. and Pidek, D. G.},
+journal = {Science},
+pages = {799-806},
+title = {One {Mars} year : {Viking} lander imaging observations},
+volume = {204},
+year = {1979}
+}
+
+@article{Mitc:89,
+author = {Mitchell , Jhon F. B.},
+journal = rg,
+pages = {115-139},
+title = {The "greenhouse" effect and climate change},
+volume = {27},
+year = {1989}
+}
+
+@article{Wall:81,
+author = {Wall, Stephen D.},
+journal = {Icarus},
+pages = {173-183},
+title = {Analysis of condensates formed at the {Viking} 2 lander site : the first winter},
+volume = {47},
+year = {1981}
+}
+
+@article{Hart:86,
+author = {Hart , Helen M. and Jakosky , Bruce M.},
+journal = {Icarus},
+pages = {134-142},
+title = {Composition and stability of the condensate observed at the {Viking} lander 2 site on {Mars}},
+volume = {66},
+year = {1986}
+}
+
+@article{Mccl:92,
+journal = jgr,
+number = {E5},
+pages = {7735-7757},
+title = {Atmosphere and Climate Studies Using the \protect{Mars} Observer Pressure Modulator Infrared Radiometer},
+volume = {97},
+year = {1992}
+}
+
+@phdthesis{Mayn:97,
+author = {Karine Maynard},
+school = {Universit\'e Paris-6},
+title = {Param\'etrisation de la diffusion lat\'erale dans un mod\`ele de circulation g\'en\'erale de l'atmosph\`ere},
+type = {th\`ese},
+year = {1997}
+}
+
+@phdthesis{Hour:92f,
+author = {Hourdin, Fr\'ed\'eric},
+school = {Universit\'e Paris-7},
+title = {Etude et mod\'elisation num\'erique de la circulation g\'en\'erale des atmosph\`eres plan\'etaires},
+type = {th\`ese},
+year = {1992}
+}
+
+@phdthesis{Forg:96these,
+author = {Forget, Fran\c{c}ois},
+school = {Universit\'e Paris-6},
+title = {Le climat de la plan\`ete Mars~:
+de l'importance des poussi\`eres et des r\'egions polaires.},
+type = {th\`ese},
+year = {1996}
+}
+
+@phdthesis{Bouc:95,
+author = {Boucher, Olivier},
+school = {Universit\'e Paris-6},
+title = {
+Etude de quelques interactions a{\'e}rosol-nuage-rayonnement~: mod{\'e}lisation et simulations avec un mod{\'e}le de circulation g{\'e}n{\'e}rale},
+type = {th{\`e}se},
+year = {1995}
+}
+
+@book{Lore:67,
+author = {Lorenz , Edward N.},
+publisher = {World Meteorological Organization},
+title = {The nature and theory of the general circulation of the atmosphere},
+year = {1967}
+}
+
+@book{Newe:72,
+author = {Newel , Reginald E. and Kidson , John W. and Vincent , Dayton G. and Boer , George J.},
+address = {Cambridge, Massachussetts, USA},
+publisher = {The MIT Press},
+title = {The general circulation of the torpical atmosphere},
+year = {1972}
+}
+
+@book{Herg:62,
+author = {Herg\'e},
+address = {Tournai, Belgique},
+publisher = {Casterman},
+title = {On a march\'e sur la lune},
+year = {1962}
+}
+
+@article{Bouc:95b,
+author = {Boucher, O.},
+journal = jc,
+pages = {1403--1409},
+title = {GCM Estimate of the indirect aerosol forcing using satellite-retrieved cloud effective droplet radii},
+volume = {8},
+year = {1995}
+}
+
+@techreport{Bouc:95c,
+author = {Boucher , O. and Li , Z.-X. and Le Treut , H.},
+institution = {LMD},
+number = {197},
+title = {Introduction du sch\'ema de convection de {T}iedtke dans les
+{MCG}s du {LMD}},
+year = {1995}
+}
+
+@article{Bouc:97,
+author = {Boucher , O. and Pham , M. and Sadourny , R.},
+journal = {Submitted to Annales Geophysic},
+title = {General circulation model simulations of indian summer monsoon with increasing levels of sulphate aerosols},
+year = {1997}
+}
+
+@article{Cres:59,
+author = {Cressman , G. P.},
+journal = mwr,
+pages = {367--374},
+title = {An operational objective analysis system},
+volume = {87},
+year = {1959}
+}
+
+@article{Hour:99,
+author = {Hourdin , F. and Armengaud , A.},
+journal = mwr,
+pages = {822--837},
+title = {Test of a hierarchy of finite-volume schemes for transport of trace species in an atmospheric general circulation model},
+volume = {127},
+year = {1999}
+}
+
+@article{Pudy:98,
+author = {Pudykiewicz , J. A.},
+journal = {Atmos. Environ.},
+pages = {3039--3050},
+title = {Application of adjoint tracer transport equations for evaluating source parameters},
+volume = {32},
+year = {1998}
+}
+
+@article{Hess:96,
+author = {Hess, P. G. and Nanda, S.  and Flocke, S. J.},
+journal = jgr,
+pages = {14,543--14,568},
+title = {Trajectories and related variations in the chemical composition
+of air for the Mauna Loa Observatory during 1991 and 1992},
+volume = {101},
+year = {1996}
+}
+
+@article{Ramo:96,
+author = {Ramonet, M. and Le Roulley , J. C. and Bousquet, P. and Monfray, P.},
+journal = {J. Atmos. Chem.},
+pages = {107--136},
+title = {Radon-222 measurements during the Tropoz II campaign and coparison with a global atmospheric transport model},
+volume = {23},
+year = {1996}
+}
+
+@article{Merr:94,
+author = {Merrill, J. T.},
+journal = jgr,
+pages = {25,8881-25,8889},
+title = {Isentropic airflow probability analysis},
+volume = {99},
+year = {1994}
+}
+
+@techreport{Graz:98,
+author = {Graziani , C. and Klug , W. and Mosca , S.},
+address = {Office for Official Publications of the European Communities},
+institution = {Joint Research Center},
+title = {Real-time long-range dispersion model evaluation of the {ETEX} release},
+volume = {EUR--17754},
+year = {1996}
+}
+
+@article{X,
+author = {X},
+journal = {X},
+pages = {X},
+title = {X},
+volume = {X},
+year = {X}
+}
+
+@article{Hour:00GRL,
+author = {Hourdin , F. and Issartel , J.-P.},
+journal = grl,
+pages = {2245--2248},
+title = {Sub-surface nuclear tests monitoring through the CTBT xenon network},
+year = {2000},
+vol = "27"
+}
+
+@article{Hour:99CRAS,
+author = {Hourdin , F. and Issartel , J.-P. and Cabrit , B. and Idelkadi , A.},
+journal = {CRAS},
+pages = {623--628},
+title = {Reciprocity of Atmospheric Transport of Trace Species},
+volume = {329},
+year = {1999}
+}
+
+@article{Hosk:75,
+author = {Hoskins, B. J. and Simmons, A. J.},
+journal = qjrms,
+pages = {771-783},
+title = {A Multi-layer spectral model and the semi-implicit method},
+volume = {109},
+year = {1975}
+}
+
+@article{Barn:96jas,
+author = {Barnes, J. R. and Haberle, R. M.},
+journal = jas,
+pages = {3143-3156},
+title = {The {Martian} zonal-mean circulation: angular momentum and potential vorticity structure in GCM simulations},
+volume = {53},
+year = {1996}
+}
+
+@article{LeTr:96,
+author = {Le Treut , H. and Forichon , M. and Boucher , O. and Li , Z.-X.},
+journal = {submitted to J. Climate},
+title = {Sulfate aerosol indirect effect and CO$_2$ greenhouse forcing: equilibrium response of the LMD GCM and associated cloud feedbacks},
+year = {1996}
+}
+
+@article{author
+}
+
+@article{author
+}
+
+@article{author
+}
+
+@article{author
+}
+
+@article{Thom:70,
+author = {Thompson , R.},
+journal = jas,
+pages = {1107-1116},
+title = {Venus'  general circulation is a merry-go-round},
+volume = {27},
+year = {1970}
+}
+
+@misc{Elia:91,
+author = {Eliason, E.   and  Batson , R. and Manley , A.},
+title = {Mars {Mosaicked Digital Image Model (MIDM) and Digital Terrain Model (DTM), 1991.}},
+year = {1991}
+}
+
+@inproceedings{Davi:92,
+author = {Davies , Merton E. and Batson , Raymond M. and Sherman , S. C. Wu},
+booktitle = {Mars},
+pages = {321-342},
+publisher = {Univ. of Ariz. Press, Tucson},
+title = {Geodesy and Cartography of {Mars}},
+year = {1992}
+}
+
+@article{Thom:79,
+author = {Thomas , P. and Veverka , J.},
+journal = jgr,
+number = {b14},
+pages = {8131-8146},
+title = {Seasonal and secular variations of wind streaks on \protect{Mars}: A anlysis of \protect{Mariner~9} and \protect{Viking} data},
+volume = {84},
+year = {1979}
+}
+
+@article{Shap:71,
+author = {Shapiro , R.},
+journal = jas,
+pages = {523-591},
+title = {The use of linear filtering as a parametrization of atmospheric diffusion},
+volume = {28},
+year = {1971}
+}
+
+@article{Schn:77a,
+author = {Schneider , Edwin K.},
+journal = jas,
+pages = {280-296},
+title = {Axially symmetric Steady-State Models of the Basic State for Instabillity and Climate Studies. \protect{Part II}. Nonlinear Calculations},
+volume = {34},
+year = {1977}
+}
+
+@article{Samu:83a,
+author = {Samuelson , R. E. and Maguire , W. C. and  Hanel , R. A. and Kunde , V. G.and Jennigs D. E. and Yung , Y. L. and Aikin , A. C.},
+journal = jgr,
+pages = {8709-8715},
+title = {CO$_2$ on \protect{Titan}},
+volume = {88},
+year = {1983}
+}
+
+@article{Samu:83,
+author = {Samuelson , R. E.},
+journal = {Icarus},
+pages = {364-387},
+title = {Radiative equilibrium model of \protect{Titan's} atomsphere},
+volume = {53DedDeD},
+year = {1983}
+}
+
+@book{Brig:82,
+author = {Briggs , G. A. and Taylor , F. W.},
+publisher = {Cambridge University Press},
+title = {Photographic Atlas of the Planets},
+year = {1982}
+}
+
+@proceedings{esa:91,
+address = {Paris, France},
+editor = {ESA},
+publisher = {ESA Publications Division},
+title = {Symposium on \protect{Titan}},
+volume = {SP-338},
+year = {1992}
+}
+
+@inproceedings{Cous:91,
+author = {Coustenis , Athena},
+booktitle = {Symposium on Titan},
+crossref = {esa:91},
+pages = {53-58},
+title = {Titan's atmosphere: latitudinal variations in temperature and composition}
+}
+
+@article{Cous:95,
+author = {Coustenis , A. and B\'ezard , B.},
+journal = {Icarus},
+pages = {126-140},
+title = {Titan's atmosphere from {Voyager} Infrared observations : {IV} Latitudinal variations of temperature and composition},
+volume = {115},
+year = {1995}
+}
+
+@article{Kaln:73,
+author = {K\'alnay de Rivas , Eugenia},
+journal = jas,
+pages = {763-779},
+title = {Numerical models of the circulation of the atmosphere of \protect{Venus}},
+volume = {30},
+year = {1973}
+}
+
+@article{Suar:92,
+author = {Suarez , Max J. and Duffy , Dean G.},
+journal = jas,
+pages = {1541-1554},
+title = {Terrestrial Superrotation: A bifurcation of the general circulation},
+year = {1992}
+}
+
+@article{Newm:92,
+author = {Newman, Matthew and Leovy , Conway},
+journal = sci,
+pages = {647-650},
+title = {Maintenance of the Rotational Winds in \protectP{Venus'} Middle Atmosphere by thermal tides},
+volume = {257},
+year = {1992}
+}
+
+@article{Ross:79,
+author = {Rossow , William B.},
+journal = jas,
+pages = {377-389},
+title = {Large--scale Motion in the \protect{Venus} Stratosphere},
+volume = {36},
+year = {1979}
+}
+
+@article{Ross:80,
+author = {Rossow , W. B. and Del Genio , A. D. and Limaye , S. S. and Travis , L. D. and Stone , P. H.},
+journal = jgr,
+pages = {8107-8128},
+title = {Cloud morphology and motions from \protect{Pioneer} \protect{Venus} images},
+volume = {85},
+year = {1980}
+}
+
+@article{Ross:78,
+author = {Rossow , William B.},
+journal = {Icarus},
+pages = {1,50},
+title = {Cloud microphysics: {A}nalysis of the clouds of {Earth, Venus, Mars, and Jupiter}},
+volume = {36},
+year = {1978}
+}
+
+@article{Del:93,
+author = {Del Genio , Anthony D. and Zhou , Wei and Eichler , Timothy P.},
+journal = {Icarus},
+pages = {1-17},
+title = {Equatorial superrotation in a slowly rotating \protect{GCM}: implications for \protect{Titan} and \protect{Venus}},
+volume = {101},
+year = {1993}
+}
+
+@article{Fels:74,
+author = {Fels , S. B. and Lindzen , R. S.},
+journal = gfd,
+pages = {149-191},
+title = {The interaction of thermally excited gravity waves with the mean zonal flows},
+volume = {6},
+year = {1974}
+}
+
+@article{Schu:70,
+author = {Schubert , Gerald and Young , Richard E.},
+journal = jas,
+pages = {523-528},
+title = {The 4-Day \protect{Venus} Circulation Driven by Periodis Thermal Forcing},
+volume = {27},
+year = {1970}
+}
+
+@article{Fels:77,
+author = {Fels , Stephen B.},
+journal = jas,
+pages = {499-514},
+title = {Momentum and Energy Exchanges due to Orographically scaterred Gravity Waves},
+volume = {34},
+year = {1977}
+}
+
+@article{Malk:70,
+author = {Malkus , Willem V. R.},
+journal = jas,
+pages = {529-535},
+title = {Hadley--Halley Circulation on \protect{Venus}},
+volume = {27},
+year = {1970}
+}
+
+@article{Zure:88,
+author = {Zurek , Richard W. and Haberle , Robert M.},
+journal = jas,
+pages = {2469-2485},
+title = {Zonally Symmetric Response to Atmospheric Tidal Forcing in the Dusty {Martian} Atmosphere},
+volume = {45},
+year = {1988}
+}
+
+@inproceedings{Chri:92,
+author = {Christensen , P. R. and Moore , H. J.},
+address = {Tucson, AR},
+booktitle = {Mars},
+chapter = {26},
+pages = {686-729},
+publisher = {University of Arizona Press, Tucson},
+title = {The {Martian} surface layer},
+year = {1992}
+}
+
+@inproceedings{Zure:92,
+author = {Zurek , R. W. and Barnes , J. R. and Haberle , R. M. and Pollack , J. B. and Tillman , J. E. and Leovy ,  C. B.},
+booktitle = {Mars},
+chapter = {26},
+pages = {835-933},
+publisher = {Univ. of Ariz. Press, Tucson},
+title = {Dynamics of the atmosphere of \protect{Mars}},
+year = {1992}
+}
+
+@article{Boug:88,
+author = {Bougher , S. W. and Dickinson , R. E.},
+journal = jgr,
+pages = {7325-7337},
+title = {Mars mesosphere and thermosphere. I. Global ,mean heat budget and thermal structure},
+volume = {94},
+year = {1988}
+}
+
+@article{Schu:69,
+author = {Scubert , G. and Whitehead , J.},
+journal = sci,
+pages = {71-72},
+title = {Moving flame experiment with liquid mercury: Possible implication for Venus atmosphere},
+year = {1969}
+}
+
+@misc{Schu:97,
+author = {Schubnel, A.},
+howpublished = {Rapport de stage au LMD},
+title = {Modélisation numérique de la structure thermique de l'atmosphere de Triton},
+year = {1997}
+}
+
+@article{Lind:88,
+author = {Lindzen , Richard S. and Hou , Arthur},
+journal = jas,
+pages = {2416-2427},
+title = {Hadley circulation for zonally averaged heating centered off the equator},
+volume = {45},
+year = {1988}
+}
+
+@article{Lind:70,
+author = {Lindzen , Richard S.},
+journal = jas,
+pages = {536-549},
+title = {The Application and Aplicability of Terrestrial Atmospheric Tidal Theory to \protect{Venus} and \protect{Mars}},
+volume = {27},
+year = {1970}
+}
+
+@article{Ross:83,
+author = {Rossow , William B.},
+journal = jas,
+pages = {273-302},
+title = {A General Circulation Model of a {Venus}--like Atmosphere},
+volume = {40},
+year = {1983}
+}
+
+@article{Hunt:76,
+author = {Hunt , B. G.},
+journal = mwr,
+pages = {333-350},
+title = {Experiments with a Stratospheric General Circulation Model: Part \protect{IV}. Inclusion of the Hydrological Cycle},
+volume = {104},
+year = {1976}
+}
+
+@article{Hunt:79b,
+author = {Hunt , G. E. and James , P. B.},
+journal = {Nature},
+pages = {531-532},
+title = {Martian extratropical cyclones},
+volume = {278},
+year = {1979}
+}
+
+@article{Del:82,
+author = {Del Genio , A. D. and Rossow , W. B.},
+journal = {Icarus},
+pages = {391-415},
+title = {Temporal variability of ultraviolet cloud features in the Venus startosphere},
+volume = {51},
+year = {1982}
+}
+
+@article{Char:47,
+author = {Charney , J. G.},
+journal = {J. Meteor.},
+pages = {135-162},
+title = {The dynamics of long waves in a baroclinic westerly current},
+volume = {35},
+year = {1947}
+}
+
+@article{Eady:49,
+author = {Eady , E. T.},
+journal = {Tellus},
+pages = {35-52},
+title = {Long waves and cyclones},
+volume = {1},
+year = {1950}
+}
+
+@inproceedings{Fjor:51,
+author = {Fjortoft , R.},
+address = {Boston},
+booktitle = {Compendium of meteorology},
+editor = {T. F. Malone},
+journal = {Compendium of meteorology},
+pages = {454-463},
+publisher = {Amer. Meteor. Soc.},
+title = {Stability properties of large-scale distubances},
+year = {1951}
+}
+
+@article{Kuo:52,
+author = {Kuo , H.-L.},
+journal = {J. Meteor.},
+pages = {260-278},
+title = {Three-dimensional disturbances in a baroclinic zonal current},
+volume = {9},
+year = {1952}
+}
+
+@article{Kuo:49,
+author = {Kuo , H. L.},
+journal = {J. Meteor.},
+pages = {105-122},
+title = {Dynamic instability of two-dimensional nondivergent flow in a barotropic atmosphere},
+volume = {6},
+year = {1949}
+}
+
+@article{Hide:69,
+author = {Hide , R.},
+journal = jas,
+pages = {841-853},
+title = {Dynamics of the atmospheres of the major planets with an appendix on the viscous boundary layer at the rigid boundary surface of an electrically conducting rotating fluid in the presence of a magnetic field},
+type = { field},
+volume = {26},
+year = {1969}
+}
+
+@unpublished{Sado:90,
+author = {Sadourny , Robert},
+note = {Cours du DEA de m\'et\'eorologie de PARIS~6},
+title = {La circulation g\'en\'erale de l'atmosph\`ere: Th\'ories et observations},
+year = {1990}
+}
+
+@article{Hide:75,
+author = {Hide , R. and Mason , P. J.},
+journal = {Adv. in Physics},
+pages = {47-100},
+title = {Slopping convection in a rotating fluid},
+volume = {24},
+year = {1975}
+}
+
+@book{Pedl:82,
+author = {Pedlosky , Joseph},
+address = {New York},
+publisher = {Springer-Verlag},
+title = {Geophysical Fluid Dynamics},
+year = {1982}
+}
+
+@article{Lell:89,
+author = {Lellouch , E. and Coustenis , A.  and Gautier , D. and Raulin , F. and Dubouloz , N. and Fr\`ere , C.},
+journal = {Icarus},
+pages = {328-349},
+title = {Titan's atmosphere and hypothesized ocean: A reanalysis of  {Voyager~1} radio-occultation and {IRIS 7.7 $\mu$m} data.},
+volume = {79},
+year = {1989}
+}
+
+@misc{Lell:94,
+author = {Lellouch, E. and Rosenqvist , J. and Goldstein, J. J. and Boucher , S. W. and Paubert , G.},
+howpublished = {Acte du Colloque National de planétologie de l'INSU},
+note = {Section 13.5},
+title = {Dynamique des {atmosphère moyennes de Vénus et de Mars par spectroscopie  millimétrique}},
+year = {1994}
+}
+
+@misc{Benc:94,
+author = {Benchkoura, A. and Schmitt, B. and Klinger, J.},
+howpublished = {Acte du Colloque National de planétologie de l'INSU},
+note = {Section 13.5},
+title = {Mod\'elisation num\'erique du transport de volatils et de la
+differenciation chimique \`a la surface du satellite {Triton}},
+year = {1994}
+}
+
+@article{Boye:66,
+author = {Boyer , C. and Gu\'erin , P.},
+journal = {C. R. Hebd. S\'eances Acad. Sci.},
+pages = {253-255},
+title = {Mise en \'evidence directe, par la photographie d'une rotation r\'etrograde de V\'enus en 4 jours},
+volume = {263},
+year = {1966}
+}
+
+@inproceedings{Raul:92,
+author = {Raulin , F. and Fr\`ere , C. and Do , L. and Khlifi , M. and Paillous , P. and de Vanssay , E.},
+booktitle = {Symposium on Titan},
+crossref = {esa:91},
+title = {Organic chemistry on \protect{Titan} versus Terrestrial prebiotic chemistry: Exobiological implications}
+}
+
+@inproceedings{Gaut:92,
+author = {Gautier, Daniel},
+booktitle = {Symposium on Titan},
+crossref = {esa:91},
+pages = {43-51},
+publisher = {ESA},
+title = {The composition of the atmosphere of {Titan}},
+volume = {SP 338},
+year = {1992}
+}
+
+@inbook{Shap:68,
+author = {Shapiro , I. I.},
+address = {New York: Mc Graw-Hill},
+pages = {143-185},
+publisher = {eds. J. V. Evans and T. Hagfors},
+title = {Spin and orbital motions of the planets},
+year = {1968}
+}
+
+@article{Hadl:35,
+author = {Hadley , G.},
+journal = ptrsl,
+pages = {58-62},
+title = {Concerning the cause of the general trade-winds},
+volume = {39},
+year = {1735}
+}
+
+@article{Hall:86,
+author = {Halley , E.},
+journal = ptrsl,
+pages = {153-168},
+title = {An historical account of the trade winds, and monsoons, observable in the seas between and near the tropiks, with an attempt to assign the physical cause of the said winds},
+volume = {16},
+year = {1686}
+}
+
+@article{Evan:76,
+author = {Evans , David S.},
+journal = {Science},
+note = {Book rewview},
+pages = {754},
+title = {A Fancier of \protect{Mars}},
+volume = {193},
+year = {1976}
+}
+
+@book{Louc:88,
+author = {Louchet , Andr\'e},
+address = {120 Bd St Michel, 75280 Paris CEDEX 06},
+publisher = {Masson},
+title = {La plan\`ete Mars: description g\'eographique},
+year = {1988}
+}
+
+@book{Pica:53,
+author = {Picart , Luc},
+address = {103 Bd. Saint--Michel, Paris},
+publisher = {Librairie Armand Colin},
+title = {Astronomie g\'en\'erale},
+year = {1953}
+}
+
+@article{Blam:91,
+author = {Blamont , J. E. and Chassefi\`ere , E. and Goutail , J. P. and Mege , B. and Munes-Pinharanda and Souchon , G and Krasnopolsky , V. A. and Krysko , A. A. and Moroz , V. I..},
+journal = pss,
+pages = {175-187},
+title = {Vertical profiles of dust and ozone in the {Martian} atmosphere deduced from solar occultation measurements},
+volume = {39},
+year = {1991}
+}
+
+@article{Blam:89,
+author = {Blamont , J. E. and Chassefi\`ere , E. and Goutail , J. P. and Mege , B. and Munes-Pinharanda and Souchon , G and Krasnopolsky , V. A. and Krysko , A. A. and Moroz , V. I..},
+journal = {Nature},
+pages = {600-603},
+title = {Vertical profiles of dust and ozone in the {Martian} atmosphere deduced from solar occultation measurements},
+volume = {341},
+year = {1989}
+}
+
+@article{Comb:91,
+author = {Combes , M. and Cara , C. and Drossart , P. and Encrenaz , T. and Lellouch , E. and Rosenqvist , J. and Bibring , J.-P. and Erard , S. and Gondet , B. and Langevin , Y. and Soufflot , A. {\em et al.}},
+journal = pss,
+pages = {189-197},
+title = {Martian atmosphere studies from the \protect{ISM} experiment},
+volume = {39},
+year = {1991}
+}
+
+@article{Moro:91,
+author = {Moroz , V. I. and Petrova , E. V. and Ksanfomality , L. V. and Ganpantzerova , O. F. and Goroshkova , N. V. and Zharkov , A. V. and Nikitin , G. E. and Esposito , L. and Bibring , J.-P. {\em et al.}},
+journal = pss,
+pages = {199-207},
+title = {Characteristics of aerosol phenomena in {Martian} atmosphere from \protect{KRFM} eperiment data},
+volume = {39},
+year = {1991}
+}
+
+@article{Jose:76,
+author = {Joseph , J. H. and Wiscombe , W. J. and Weiman , J. A.},
+journal = jas,
+pages = {2452-2459},
+title = {The Delta-Eddington Approximation for radiative flux transfer},
+volume = {33},
+year = {1976}
+}
+
+@article{Zdun:80,
+author = {Zdunkowski , W. G. and Welch , R. M. and Korb , G.},
+journal = bpa,
+pages = {147-166},
+title = {An investigation of the structure of typical two-stream methods for the calculation of solar fluxes and heating rates in clouds},
+volume = {53},
+year = {1980}
+}
+
+@article{Gele:79,
+author = {Geleyn , J. F. and Hollingswortha , A.},
+journal = bpa,
+pages = {1-16},
+title = {An economical method for the computation of the interaction between scattering and line absorption of radiation},
+volume = {52},
+year = {1979}
+}
+
+@article{Emde:12,
+author = {Emden , R.},
+journal = {Sitzungsber. Bayer. Akad. Wiss. Math.-Phys. Kl.},
+pages = {55},
+title = {\"Uber Strahlungsgleichgewicht und atmospher\"ische Strahlung.},
+volume = {1},
+year = {1912}
+}
+
+@book{Palt:76,
+author = {Paltridge , G. W. and Platt , C. M. R.},
+address = {335 Jan Van Galenstraat/ P. O. Box 211, Amsterdam, The Netherlands},
+publisher = {Elsevier scientific publishing company},
+title = {Radiative processes in meteorology and climatology},
+year = {1976}
+}
+
+@article{Pall:81,
+author = {Palluconi , F. D. and Kieffer , H. H.},
+journal = {Icarus},
+pages = {415-426},
+title = {Thermal inertia mapping of {Mars} from {$60^{\mbox{o}}$S to $60^{\mbox{o}}$N}},
+volume = {45},
+year = {1981}
+}
+
+@article{Ples:81,
+author = {Pleskot , L. K. and Miner ,  E. D.},
+journal = {Icarus},
+pages = {179-201},
+title = {Time variability of {Martian} bolometric albedo},
+volume = {45},
+year = {1981}
+}
+
+@unpublished{Forg:91,
+author = {Forget , Fran\c{c}ois},
+note = {Rapport du stage de DEA "Oc\'eanologie, m\'et\'eorologie et environnement" de Paris VI},
+title = {Simulation nu\'erique de l'atmosph\`ere Martienne},
+year = {1991}
+}
+
+@article{Forg:95,
+author = {Forget , F. and Pollack , J. B. and Hansen , G. B.},
+journal = jgr,
+pages = {21,119-21,234},
+title = {Low brightness temperatures of {Martian} polar caps: {CO$_2$} clouds or low surface emissivity?},
+volume = {100},
+year = {1995}
+}
+
+@inproceedings{Hour:96estecb,
+author = { Hourdin , F. and Forget , Fran\c{c}ois and Fournier , Richard and Talagrand , O. and Read , P. L. and Collins , M. and Lewis , S. R. and Thomas , P. J.},
+booktitle = {Environement Modelling for Space-based Applications},
+editor = {A. Hilgers and T.-D. Guyenne},
+pages = {315-320},
+series = {ESA},
+title = {Numerical Modelling of the General Circulation of the {Martian} Atmosphere},
+volume = {SP-392},
+year = {1996}
+}
+
+@inproceedings{Hour:96estec,
+author = { Hourdin , F. and Talagrand , O. and Menou , K. and Fournier , R. and Dufresnes , J.-L. and Gautier , D. and Courtin , R.  and B\'ezard , B. and McKay , C. P.},
+booktitle = {Environement Modelling for Space-based Applications},
+editor = {A. Hilgers and T.-D. Guyenne},
+pages = {329-333},
+series = {ESA},
+title = { Numerical Modelling of the Circulation of Superrotating Atmospheres: {Venus and Titan}},
+volume = {SP-392},
+year = {1996}
+}
+
+@inproceedings{Four:96estec,
+author = { Fournier , R. and Deleersnijder , E. and Hourdin , F. and Lahellec , A. and Forget , F. and Talagrand , O.},
+booktitle = {Environement Modelling for Space-based Applications},
+editor = {A. Hilgers and T.-D. Guyenne},
+pages = {321},
+series = {ESA},
+title = { A  Boundary-Layer Parametrisation for {Martian General Circulation Models}},
+volume = {SP-392},
+year = {1996}
+}
+
+@misc{Coll:96estec,
+author = { Read , P. L. and Collins , M. and Lewis , S. R. and Thomas , P. J. and Talagrand , O. and Forget , F. and Fournier , R. and Hourdin , F.},
+howpublished = { Oral presentation at the Symopsium on Environment Modelling for space-based applications, ESTEC/ESA},
+title = { A Climate Database for the {Martian} Atmosphere},
+year = {1996}
+}
+
+@article{Coll:95a,
+author = {Collins , M. and James , I. N.},
+journal = jgr,
+number = {E7},
+pages = {14421-14432},
+title = {Regular and irregular baroclinic waves in a simplified global circulation model of the {Martian} atmosphere},
+volume = {100},
+year = {1995}
+}
+
+@misc{Forg:95dps,
+author = {Forget, F.  and Hansen , G.B. and Pollack , J.B.},
+howpublished = {Oral presentation at the 27th annual DPS meeting
+(Kona). Abstracts book, p44},
+title = {Low brightness temperatures of {Martian} polar caps},
+year = {1995}
+}
+
+@misc{Habe:95dps,
+author = {Haberle, R. M. and Schaeffer , J.},
+howpublished = {Oral presentation at the 27th annual DPS meeting
+(Kona). Abstracts book, p12},
+title = {Obliquity experiment with a Mars general circulation model},
+year = {1995}
+}
+
+@misc{Wood:95,
+author = {Wood, S. E. and Richardson, M. I. and Paige, D. A.},
+howpublished = {Oral presentation at the 27th annual DPS meeting (Kona). Abstracts book, p44},
+title = {Microphysical and radiative processes in {CO$_2$} snow on {Mars}},
+year = {1995}
+}
+
+@misc{Tala:95dps,
+author = {Talagrand , O. and Forget , F. and Hourdin , F. and Read , P. and Collins, M. and Lewis , S.},
+howpublished = {Oral presentation at the 27th annual DPS meeting (Kona). Abstracts book, p13},
+title = {A plan for developing  a {Martian} climate database},
+year = {1995}
+}
+
+@misc{Hour:95dps,
+author = {Hourdin , Fr\'ed\'eric and Talagrand , O.  and Courtin , R.  and Gautier , D. and McKay , C. P.},
+howpublished = {Oral presentation at the 27th annual DPS meeting (Kona). Abstracts book, p51},
+title = {Atmospheric superrotation on {Titan}},
+year = {1995}
+}
+
+@article{Forg:93dps,
+author = {Forget , F. and Pollack , J. B.},
+journal = baas,
+note = {Oral presentation at the 25th annual DPS meeting (Boulder)},
+pages = {1070},
+title = {Impact of the {CO$_2$} and {H$_2$O} clouds of the {Martian } polar hood on the polar energy balance},
+volume = {25},
+year = {1993}
+}
+
+@unpublished{Hour:89,
+author = {Hourdin , Fr\'ed\'eric},
+note = {stage de DEA "Astrophysique et T\'echniques spatiales" Universit\'e Paris 7},
+title = {Adaptation du Mod\`ele de Circulation G\'en\'eral du \protect{LMD} aux conditions \protect{Martiennes}},
+year = {1989}
+}
+
+@book{Good:89,
+author = {Goody , R. M. and Yung , Y. L.},
+address = {200 Madison Avenue, New York, New York 10016},
+edition = {second},
+publisher = {Oxford University Press.},
+title = {Atmospheric Radiation, Theoretical Basis},
+year = {1989}
+}
+
+@article{Brig:77,
+author = {Briggs , Geoffrey and Klaasen , Kenneth and Thorpe , Thomas and Wellman , John},
+journal = jgr,
+pages = {4121-4149},
+title = {Martian dynamical phenomenon during {June-November} 1976: \protect{Viking} orbiter imaging results},
+volume = {82},
+year = {1977}
+}
+
+@article{Brig:74,
+author = {Briggs , G. A. and Leovy , C. B.},
+journal = bams,
+pages = {278-296},
+title = {Mariner 9 observations of the \protect{Mars} north polar hood},
+volume = {55},
+year = {1974}
+}
+
+@article{Brig:74b,
+author = {Briggs, G. A},
+journal = {Icarus},
+pages = {167-191},
+title = {The nature of the residual {Martian} polar caps},
+volume = {23},
+year = {1974}
+}
+
+@article{Klio:73,
+author = {Kliore , A. J. and Fjeldbo , G. and Seidel, B. L. and Woiceshyn , P. M.},
+journal = jgr,
+pages = {4331-4350},
+title = {S band occultation measurements of the atmosphere and topography of \protect{Mars} with \protect{Mariner} 9: {Extended} mission coverage of polar intermediate latitudes},
+volume = {78},
+year = {1973}
+}
+
+@article{Klio:72,
+author = {Kliore , A. J. and  Cain , D. L. and  Fjeldbo , G. and  Seidel , B. L.  and
+Sykes , M. J.},
+journal = {Icarus},
+pages = {484-516},
+title = {The  atmosphere of {Mars from Mariner 9} radio occultation
+measurements},
+volume = {17},
+year = {1972}
+}
+
+@article{Vere:77,
+author = {Vereka , J. and Thomas , P. and Greeley , R.},
+journal = jgr,
+pages = {4167-4187},
+title = {A study of variables fitures on \protect{Mars} during the \protect{Viking} primary mission},
+volume = {82},
+year = {1977}
+}
+
+@article{Conr:73,
+author = {Conrath , B. and Curran , R. and Hanel , R. and Kunde , V. and Maguire , W. and Pearl , J. and Pirraglia , J. and Welker , J. and Burke , T.},
+journal = jgr,
+pages = {4267-4278},
+title = {Atmospheric and surface properties of \protect{Mars} obtained by infrared spectroscopy on \protect{Mariner} 9},
+volume = {78},
+year = {1973}
+}
+
+@article{Chri:84,
+author = {Christensen , P. R. and  Zurek , R. W.},
+journal = jgr,
+pages = {4587-4596},
+title = { Martian  north polar hazes and surface ice: {Results} from the \protect{Viking} survey/completion mission},
+volume = {89},
+year = {1984}
+}
+
+@article{Conr:75,
+author = {Conrath , B. J.},
+journal = {Icarus},
+pages = {36-46},
+title = {Thermal structure of the \protect{Martian} atmosphere during the dissipation of dust storm of 1971},
+volume = {24},
+year = {1975}
+}
+
+@techreport{Chri:94,
+author = {Christensen , P. R. and Edgett  , K. S.},
+institution = {LPI},
+number = {94-04},
+title = {Physical properties ({Particle size, rock abundance}) from thermal infrared remote observations : implication for {Mars} landing site},
+year = {1994}
+}
+
+@article{Ditt:79,
+author = {Ditteon, R. and Kieffer, H. H.},
+journal = jgr,
+pages = {8294-8300},
+title = {Optical properties of solid {CO$_2$}: {Application} to {Mars}},
+volume = {84},
+year = {1979}
+}
+
+@article{Chri:75,
+author = {Christensen, E. J.},
+journal = jgr,
+pages = {2909-2913},
+title = {Martian topography derived from occultation, radar, spectral, and optical measurements},
+volume = {80},
+year = {1975}
+}
+
+@unpublished{Paig:92a,
+author = {Paige  , David A.  and  Bachman , Jennifer E.  and Keegan K. D.},
+note = {Submitted to the Jour. Geophys. Res},
+title = {Thermal and albedo mapping of the polar regions of {Mars} using {Viking} thermal mapper observations : 1. {North} polar region},
+year = {1992}
+}
+
+@inproceedings{Simp:92,
+author = {Simpson , Richard A. and Harmon , John K. and Zisk , Stanley H. and Thompson , T. W.  and Muhleman , Duane O.},
+booktitle = {Mars},
+pages = {pp.~652-685},
+publisher = {University of Arizona Press, Tucson},
+title = {Radar determination of {Mars} surface properties},
+year = {1992}
+}
+
+@article{Fjel:77,
+author = {Fjeldbo , Gunnar and Sweetnam , Donald and Brenkle , Joseph and Christensen , Edward and Farless , Jitendra and Seidel , Boris and Michael , William and Wallio , Andrew and Grossi , Marioand},
+journal = jgr,
+pages = {4317-4324},
+title = {Viking radio occultation measurements of the {Martian} atmosphere and topography: primary coverage},
+volume = {82},
+year = {1977}
+}
+
+@article{Farm:77,
+author = {Farmer , C. B. and Davies , D. W. and Holland , A. L. and La Porte , D. D. and Doms , P. E.},
+journal = jgr,
+pages = {4225-4248},
+title = {Mars: water vapor observations from the \protect{Viking} orbiters},
+volume = {82},
+year = {1977}
+}
+
+@article{Farm:79,
+author = {Farmer , C. B. and Doms , P. E.},
+journal = jgr,
+number = {B6},
+pages = {2881-2888},
+title = {Global seasonal variation of water vapor on \protect{Mars} and the  implications for permafrost},
+volume = {84},
+year = {1979}
+}
+
+@article{Kief:77,
+author = {Kieffer , Hugh H. and Martin , T. Z. and Peterfreund , R. and Jakosky , Bruce M. and Miner , Ellis D. and Palluconi , Frank Don},
+journal = jgr,
+pages = {4249-4291},
+title = {Thermal and albedo mapping during the \protect{Viking} primary mission},
+volume = {82},
+year = {1977}
+}
+
+@article{Kief:76b,
+author = {Kieffer , H. H. and  Christensen , P. R. and  Martin , T. Z. and
+Miner, E. D. and Palluconi , F. D.},
+journal = {Science},
+pages = {1346-1351},
+title = {Infrared  thermal mapping of the {Martian} surface and atmosphere: {Viking} observation of diurnal and geometric observation},
+volume = {194},
+year = {1976}
+}
+
+@article{Kerz:77,
+author = {Kerzhanovich , V. V.},
+title = "{Mars 6 - Improved analysis of the descent module measurements}",
+journal = {Icarus},
+pages = {1-25},
+doi = {10.1016/0019-1035(77)90117-8},
+volume = {30},
+year = {1977}
+}
+
+@article{Owen:77,
+author = {Owen , Tobias and Biemann , K. and Rushneck , D. R. and Biller , J. E. and Howarth , D. W. and Lafleur , A. L.},
+journal = jgr,
+pages = {4635-4639},
+title = {The composition of the atmosphere at the surface of \protect{Mars}},
+volume = {82},
+year = {1977}
+}
+
+@article{Squy:94,
+author = {Squyres, S.W. and Kasting , J.F.},
+journal = {Science},
+pages = {744-749},
+title = {Early {Mars} , how warm and how wet?},
+volume = {265},
+year = {1994}
+}
+
+@article{Davi:79,
+author = {Davies , D. W.},
+journal = jgr,
+number = {B14},
+pages = {8335-8340},
+title = {The relative humidity of \protect{Mars} atmosphere},
+volume = {84},
+year = {1979}
+}
+
+@article{Davi:79a,
+author = {Davies , Donald W.},
+journal = jgr,
+number = {B6},
+pages = {2875-2879},
+title = {The vertical distribution of \protect{Mars} water vapor},
+volume = {84},
+year = {1979}
+}
+
+@article{Owen:72,
+author = {Owen , T. and Sagan , C.},
+journal = {Icarus},
+pages = {557-568},
+title = {Minor constituents in planetary atmospheres: {Ultraviolet} spectroscopy from the {Orbiting Astronomical Observatory}},
+volume = {16},
+year = {1972}
+}
+
+@article{Davi:79c,
+author = {Davies , Donald W.},
+journal = jgr,
+pages = {8289-8293},
+title = {Effect of dust on the heating of {Mars's} surface and atmosphere},
+volume = {84},
+year = {1979}
+}
+
+@article{Poll:85,
+author = {Pollack , James B. and McKay C. P.},
+journal = sci,
+pages = {245-262},
+title = {The impact of polar stratospheric clouds on the heating rates of the winter polar stratosphere},
+volume = {42},
+year = {1985}
+}
+
+@article{Poll:77,
+author = {Pollack , James B. and Colburn , David and Kahn , Ralph and Hunter , June and Warren , Van Camp and Carlston , C. E. and Wolf , M. R.},
+journal = jgr,
+pages = {4479-4496},
+title = {Properties of aerosols in the {Martian} atmosphere, as infered from \protect{Viking} lander imaging data},
+volume = {82},
+year = {1977}
+}
+
+@inproceedings{Seif:83,
+author = {Seiff , A.},
+booktitle = {Venus},
+crossref = {Hunt:83},
+pages = {215-279},
+title = {Thermal structure of the atmosphere of \protect{Venus}},
+year = {1983}
+}
+
+@article{Seif:77,
+author = {Seiff , Alvin and Kirk , Donn B.},
+journal = jgr,
+pages = {4364-4378},
+title = {Structure of the atmosphere of \protect{Mars} in summer mid-latitudes},
+volume = {82},
+year = {1977}
+}
+
+@inproceedings{Ekon:83,
+author = {Ekonomov , A. P. and Golovin , Yu. M. and Moroz , M. I. and Moshkin , B. Ye},
+booktitle = {Venus},
+crossref = {Hunt:83},
+pages = {632-649},
+title = {Solar scattered raiation measurements by \protect{Venus} probes},
+year = {1983}
+}
+
+@inproceedings{Schu:83,
+author = {Schubert , Gerald},
+booktitle = {Venus},
+crossref = {Hunt:83},
+pages = {681-765},
+title = {General ciruclation and the dynamical state of the \protect{Venus} atmosphere},
+year = {1983}
+}
+
+@inproceedings{Kerz:83,
+author = {Kerzhanovich , V. V. and Marov , M. Ya. Marov},
+booktitle = {Venus},
+crossref = {Hunt::83},
+pages = {766-778},
+title = {The atmospheric dyanmics of \protect{Venus} according to \protect{Doppler} measurements by the \protect{Venera} entry probes},
+year = {1983}
+}
+
+@inproceedings{Toma:83,
+author = {Tomasko , Martin G.},
+booktitle = {Venus},
+crossref = {Hunt:83},
+pages = {604-631},
+title = {The thermal balance of the lower atmosphere of \protect{Venus}},
+year = {1983}
+}
+
+@article{Cour:28,
+author = {Courant , R. and Friedrichs , K. O. and Lewy , H.},
+title = {On the Partial Difference Equations of Mathematical Physics},
+journal = {Math. Ann.},
+pages = {32},
+volume = {100},
+year = {1928}
+}
+
+@book{Oort:83,
+author = {Oort , Abraham H.},
+publisher = {NOAA},
+series = {NOAA profesional paper},
+title = {Global  Atmospheric Circulations Statics,  1958-1973},
+volume = {14},
+year = {1983}
+}
+
+@article{Huss:86,
+author = {Husson , N. and Ch\'edin , A. and Scott , N. A. and Bailly , D. and Graner , G. and Lacome , N. and Levy , A. and Rossetti , C. and Tarrago , G. and Camy-Peyret , C. and Flaud , J. M. etc.},
+journal = ang,
+pages = {185-190},
+title = {The \protect{GEISA} spectroscopic line parameters data bank in 1984},
+volume = {4},
+year = {1986},
+anotate = "  and Bauer , A. , and Colmont , J. M. and Monnanteuil , N. and Hilico , J. C. and Pierre , G. and Loete , M. and Champion , J. P. and Rothman , L. S. and Brown , L.R. and Orton , G. and Varanasi , P. and Rinsland , C. P. and Smith , M. A. H. and Goldman , A."
+}
+
+@article{Fouq:74,
+author = {Fouquart , Yves},
+journal = jqsrt,
+pages = {497-508},
+title = {Utilisation des approximants de Pad\'e pour l'\'etude des largeurs \'equivalentes des raies form\'ees en atmosph\`ere diffusante},
+volume = {14},
+year = {1974}
+}
+
+@article{Tala:88,
+author = {Talagrand , O.},
+journal = {La Recherche},
+pages = {1010-1021},
+title = {La dynamique des atmosph\`eres plan\'etaires},
+volume = {19},
+year = {1988}
+}
+
+@article{Tala:86,
+author = {Talagrand , O.},
+journal = {Bull. de la Soc. Fran\c{c}aise de Phys.},
+pages = {3-8},
+title = {La circulation des atmosph\`eres plan\'etaires},
+volume = {61},
+year = {1986}
+}
+
+@inproceedings{Tala:92,
+author = {Talagrand , O. and Hourdin , F. and Forget , F.},
+booktitle = {Atmospheres, Hydrospheres and Space Sciences},
+organization = {European Geophysical Scociety},
+pages = {Suppl:III,C--494},
+title = {Numerical simulation of the circulation of the \protect{Martian} atmosphere},
+volume = {10},
+year = {1992}
+}
+
+@inproceedings{Hour:92c,
+author = {Hourdin , F. and Talagrand , O. and Le Van , Phu and Courtin , R. and Gautier , D. and McKay , C. P.},
+booktitle = {Atmospheres, Hydrospheres and Space Sciences},
+organization = {European Geophysical Scociety},
+pages = {Suppl:III,C--496},
+title = {Study of atmospheric superrotation: Numerical simulations},
+volume = {10},
+year = {1992}
+}
+
+@article{Will:82,
+author = {Williams , Gareth P. and Holloway ,  J. Leith Jr},
+journal = {Nature},
+pages = {295-299},
+title = {The range and unity of planetary circulations},
+volume = {297},
+year = {1982}
+}
+
+@article{Inge:90,
+author = {Ingersoll , Andrew P.},
+journal = {Science},
+pages = {308-315},
+title = {Atmospheric dynamics of the outer planets},
+volume = {248},
+year = {1990}
+}
+
+@article{Inge:90triton,
+author = {Ingersoll, A. P.},
+journal = {Nature},
+pages = {315-316},
+title = {Dynamic of {Triton}'s atmosphere},
+volume = {344},
+year = {1990}
+}
+
+@article{Traf:84,
+author = {Trafton, L.},
+journal = {Icarus},
+pages = {312-324},
+title = {Large seasonal variations in {Triton's} atmosphere},
+volume = {58},
+year = {1984}
+}
+
+@article{Inge:85,
+author = {Ingersoll, A. P. and Summers, M. E. and Schlipf, S. G.},
+journal = {Icarus},
+pages = {375-390},
+title = {Supersonic meteorology of {Io} - sublimation - driven flow of {SO}$_2$},
+volume = {64},
+year = {1985}
+}
+
+@article{Inge:93,
+author = {Ingersoll,  A. P. and Lyons , J. R.},
+journal = jgr,
+pages = {10951-10961},
+title = {Mars dust storms: interranual variability and chaos},
+volume = {98},
+year = {1993}
+}
+
+@article{Traf:83,
+author = {Trafton, L. and Stern, S. A.},
+journal = {Astophysical Journal},
+pages = {872-881},
+title = {On the global distribution of {Pluto}'s atmosphere},
+volume = {267},
+year = {1983}
+}
+
+@article{Land:90,
+author = {Landberg , Lars and Tillman , James E. and Larsen , Soren E.},
+journal = {manuscript},
+title = {Turbulence spectra from the boundary layer of \protect{Mars}},
+year = {1990}
+}
+
+@incollection{Kasa:77,
+author = {Kasahara , Akira},
+booktitle = {Methods in computational physics},
+editor = {Julius Chang},
+journal = {Methods in Computational Physics},
+pages = {1-66},
+publisher = {Academic press, inc.},
+title = {Computational aspects of numerical models for weather prediction and climate simulation},
+volume = {17},
+year = {1977}
+}
+
+@techreport{LeVa:89,
+author = {Le Van , Phu},
+address = {24 rue Lhomond/75 231 Paris CEDEX 05},
+institution = {Laboratoire de M\'et\'eorologie Dynamique du CNRS},
+month = {Note interne},
+number = {147},
+title = {Description de directives pour l'utilisation de la nouvelle dynamique du \protect{Mod\`ele} de \protect{Circulation} \protect{G\'en\'erale}},
+year = {1989}
+}
+
+@phdthesis{Cass:89,
+author = {Cass\'e , Vincent},
+school = {Universit\'e Paris VI},
+title = {Elaboration d'un mod\`ele coupl\'e oc\'ean tropical--atmosph\`ere globale},
+type = {Th\`ese},
+year = {1989}
+}
+
+@article{Zure:93,
+author = {Zurek , Richard W. and Martin , Leonard J.},
+journal = jgr,
+number = {E2},
+pages = {3247-3259},
+title = {Interannual variability of planet-encircling dust storms on {Mars}},
+volume = {98},
+year = {1993}
+}
+
+@article{Lell:93,
+author = {Lellouch, E. and Goldstein, J. J. and Bougher , S. and Theodore, B. and Rosenqvist , J.},
+journal = baas,
+pages = {1060},
+title = {{Mars'} middle atmosphere circulation near equinox from microwave observations},
+volume = {25},
+year = {1993}
+}
+
+@article{Zure:82,
+author = {Zurek, R. W.},
+journal = {Icarus},
+pages = {288-310},
+title = {Martian great dust storm, an update},
+volume = {50},
+year = {1982}
+}
+
+@article{Paig:85,
+author = {Paige , D. A. and Ingersoll , A. P.},
+journal = {Science},
+pages = {1160-1168},
+title = {Annual heat balance of \protect{Martian} polar caps: \protect{Viking} observations},
+volume = {228},
+year = {1985}
+}
+
+@phdthesis{Holl:92,
+author = {Hollingsworth ,  J. L.},
+school = {Oreg. State Univ., Corvallis},
+title = {Modeling the forced planetary waves in the {Mars} atmosphere},
+year = {1992}
+}
+
+@phdthesis{Paig:85phd,
+author = {Paige , David A.},
+school = {Calif. Inst. of Technol., Pasadena},
+title = {{\em The annual heat balance of the {Martian} polar caps from {Viking} observations}},
+year = {1985}
+}
+
+@article{Paig:90,
+author = {Paige,  David A. and Crisp, David and Santee , M. L.},
+journal = baas,
+pages = {1075},
+title = {It  snows on {Mars}},
+volume = {22},
+year = {1990}
+}
+
+@misc{w
+}
+
+@article{Paig:92,
+author = {Paige , David A. and Wood , Stephen E.},
+journal = {Icarus},
+pages = {15-27},
+title = {Modeling the \protect{Martian} Seasonal {$CO_2$} Cycle: 2. Interannual variability},
+volume = {99},
+year = {1992}
+}
+
+@article{Poll:93,
+author = {Pollack , J. B. and Haberle , R. M. and Murphy , J. R. and Shaeffer , J. and Lee , H.},
+journal = jgr,
+pages = {3149-3181},
+title = {Simulation of the general circulation of the \protect{Martian} atmosphere \protect{2}, {Seasonnal} pressure variations},
+volume = {98},
+year = {1993}
+}
+
+@article{Paig:94s,
+author = {Paige , David A. and  Keegan , K. D.},
+journal = jgr,
+pages = {25993-26013},
+title = {Thermal and Albedo Mapping of the Polar Regions of {Mars}, 2, {South} Polar Region},
+volume = {99},
+year = {1994}
+}
+
+@article{Poll:93venus,
+author = {Pollack , J. B. and Dalton , J. B. and Grinspoon , D. and
+Wattson , D. R. B. and  Freedman , R. and Crisp , D.},
+journal = {Icarus},
+pages = {1-42},
+title = {Near-infrared light from
+{Venus} nightside: {A} spectroscopic analysis},
+volume = {103},
+year = {1993}
+}
+
+@article{Poll:95,
+author = {Pollack , J. B. and Ockert-Bell , M. E. and Shepard , M. K.},
+journal = jgr,
+pages = {5235-5250},
+title = {Viking {Lander} image analysis of {Martian} atmospheric dust},
+volume = {100},
+year = {1995}
+}
+
+@article{Habe:93,
+author = {Haberle , R. M. and Pollack , J. B. and Barnes , J. R. and Zurek , R. W. and Leovy , C. B. and Murphy , J. R. and Lee , H. and Schaeffer , J.},
+journal = jgr,
+number = {E2},
+pages = {3093-3124},
+title = {Mars Atmospheric Dynamics as Simulated by the \protect{NASA/Ames} General Circulation model, 1, The zonal-Mean Circulation},
+volume = {98},
+year = {1993}
+}
+
+@article{Habe:93pbl,
+author = {Haberle , R.M. and Houben , H. C. and Hertenstein, R. and Herdtle,,T.},
+journal = jas,
+month = {june},
+pages = {1544-1559},
+title = {A boundary layer model for {Mars}: {Comparison} with {Viking Lander} and entry data},
+volume = {50},
+year = {1993}
+}
+
+@phdthesis{Siil:94,
+author = {Siili , Tero},
+school = {Helsinki University of Technology},
+title = {Numerical studies of some surface-induced mesoscale phenomena in the {Martian} atmosphere},
+year = {1994}
+}
+
+@article{Hane:72,
+author = {Hanel, R. and Conrath, R. and Hovis, W. and Kunde, V. and Lowman, P. and Maguire, W. and
+Pearl, J. and  Pirraglia, J. and  Prabhakara, C. and  Schlachman, B. and Levin, G.},
+journal = {Icarus},
+pages = {423-442},
+title = {Investigation of the {Martian} environment by infrared spectroscopy on {Mariner} 9},
+volume = {17},
+year = {1972}
+}
+
+@article{Poll:82,
+author = {Pollack , James B.},
+journal = asr,
+pages = {43-56},
+title = {Properties and effects of \protect{Martian} atmospheric dust},
+volume = {2},
+year = {1982}
+}
+
+@article{Warr:90,
+author = {Warren , S. G. and Wiscombe , W. J. and Firestone , J. F.},
+journal = jgr,
+pages = {717-741},
+title = {Spectral albedo and emissivity of {CO}$_2$ in \protect{Martian} polar caps: model results},
+volume = {95},
+year = {1990}
+}
+
+@article{Wood:92,
+author = {Wood , S. E. and Paige , D. A.},
+journal = {Icarus},
+pages = {1-14},
+title = {Modeling the {Martian} seasonal  {CO$_2$} Cycle:  {Fitting} the \protect{Viking} lander pressure curves},
+volume = {99},
+year = {1992}
+}
+
+@article{Wood:84,
+author = {Woodward , P. R. and Colella , Phillip},
+journal = jcp,
+pages = {115-173},
+title = {The numerical simulation of Two-dimensional fluid flow with strong shocks},
+volume = {54},
+year = {1984}
+}
+
+@article{Wood:81,
+author = {Woodward , P. R. and Colella , P.},
+journal = lnp,
+pages = {434--441},
+title = {High resolution difference schemes for compressible gaz dynamics},
+volume = {141},
+year = {1981}
+}
+
+@article{Carp:90,
+author = {Carpenter , R. L. and Droegemeier , K. K. and Woodward , P. R. and Hane , C. E.},
+journal = mwr,
+pages = {586--612},
+title = {Application of the Piecewise Parabolic Method ({PPM}) to meteorological modeling},
+volume = {118},
+year = {1990}
+}
+
+@article{Leig:66,
+author = {Leighton , R. R. and Murray , B. C.},
+journal = sci,
+pages = {136-144},
+title = {Behavior of carbon dioxide and other volatiles on \protect{Mars}},
+volume = {153},
+year = {1966}
+}
+
+@article{Paig:94n,
+author = {Paige , D. A. and Bachman , J. E.  and Keegan , K. D.},
+journal = jgr,
+pages = {25959-25991},
+title = {Thermal and albedo mapping of the polar regions of {Mars} using {Viking} thermal mapper observations, 1, {North} polar region},
+volume = {99},
+year = {1994}
+}
+
+@techreport{Warr:86,
+author = {Warrilow , D. A. and Sangster , A. B. and Slingo , A.},
+address = {Meteorological Office, London Road, Bracknell, Berkshire RG12 2SZ},
+institution = {UKMO},
+number = {DCTN 38},
+title = {Modeling of land surface processes and their influence on \protect{European} climate},
+year = {1986}
+}
+
+@article{Warr:86co2,
+author = {Warren, S. G.},
+journal = {Appl. Opt.},
+pages = {2650-2674},
+title = {Optical constants of carbon dioxide ice},
+volume = {25},
+year = {1986}
+}
+
+@article{Barn:81,
+author = {Barnes , Jeffrey R.},
+journal = jas,
+number = {2},
+pages = {225-234},
+title = {Midlatitude disturbances in the \protect{Martian} atmosphere: A second \protect{Mars} year},
+volume = {38},
+year = {1981}
+}
+
+@misc{pola
+}
+
+@article{Barn:80,
+author = {Barnes , J. R.},
+journal = jas,
+pages = {2002-2015},
+title = {Time spectral analysis of the midlatitude disturbances in the \protect{Martian} atmosphere},
+volume = {37},
+year = {1980}
+}
+
+@article{Barn:87,
+author = {Barnes , Jeffey R. and Hollingsworth , Jeffrey L.},
+journal = {Icarus},
+pages = {313-334},
+title = {Dynamical modeling of a planetary wave mechanism for a \protect{Martian} polar warming},
+volume = {71},
+year = {1987}
+}
+
+@article{Poll:81,
+author = {Pollack , James B. and Leovy , Coneway B. and Greiman , Paul W. and Mintz , Yale},
+journal = jas,
+pages = {3-29},
+title = {A \protect{Martian} \protect{General} \protect{Circulation} \protect{Model} Experiment with Large Topography},
+volume = {38},
+year = {1981}
+}
+
+@inproceedings{Bill:92,
+author = {Billebaud , F. and Rosenqvist , J. and Maillard , J. P. and Lellouch , E. and Encrenaz , T. and Hourdin , F.},
+booktitle = {EGS},
+title = {Search for spatial variations in the \protect{CO} abundance on \protect{Mars} at $2.3\mu$m},
+year = {1998}
+}
+
+@inproceedings{Mart:91,
+author = {Martin , T. Z.},
+address = {Headington Hill Hall, Oxford OX2 0BW, England},
+booktitle = {The environmental model of \protect{Mars}},
+editor = {Szeg\"o K.},
+pages = {89-100},
+publisher = {Pergamon press plc},
+series = {COSPAR Colloquia series},
+title = {Thermal environnement of \protect{Mars}.},
+volume = {2},
+year = {1991}
+}
+
+@article{Mart:79,
+author = {Martin , Terry Z. and Peterfreund , Alan R. and Miner , Ellis D. and Kieffer , Hugh H. and Hunt , Garry E.},
+journal = jgr,
+pages = {2381-2842},
+title = {Thermal infrared properties of the \protect{Martian} atmosphere, 1, {Global} behavior at 7, 9, 11 and 20 \protect{$\mu$m}},
+volume = {84},
+year = {1979}
+}
+
+@article{Mart:79a,
+author = {Martin , Terry Z. and Kieffer , Hugh H.},
+journal = jgr,
+number = {B6},
+pages = {2843-2852},
+title = {Thermal infrared properties of the \protect{Martian} atmosphere, 2, The \protect{$15-\mu$m}  band measurements},
+volume = {84},
+year = {1979}
+}
+
+@article{Pete:79,
+author = {Peterfreund , Alan R. and Kieffer , Hugh H.},
+journal = jgr,
+number = {B6},
+pages = {2853-2863},
+title = {Thermal infrared properties of the \protect{Martian} atmosphere: 3. local dust clouds},
+volume = {84},
+year = {1979}
+}
+
+@article{Hunt:79a,
+author = {Hunt , Garry E.},
+journal = jgr,
+number = {B6},
+pages = {2865-2879},
+title = {Thermal IR properties of the \protect{Martian} atmosphere: 4. Predictions of the resence of Dust and ice clouds from \protect{Viking} \protect{IRTM} spectral measurements},
+volume = {84},
+year = {1979}
+}
+
+@article{Mart:86,
+author = {Martin , Terry Z.},
+journal = {Icarus},
+pages = {2-21},
+title = {Thermal infrared opacity of the \protect{Mars} atmosphere},
+volume = {66},
+year = {1986}
+}
+
+@techreport{Polc:91q,
+author = {Polcher , J. and Harzallah , A. and Bony , S.a and Chalita , S. N. and Cohen-Solal , E. and Forichon , M. and Hourdin , F. and LeTreut , H. and  Le Van , P. and Li , Z. X. and Rogel , P.},
+address = {ENS/24 rue Lhomond/75 005 Paris},
+institution = {LMD / CNRS},
+number = {170},
+title = {Le cycle 5 du \protect{Mod\`ele} de \protect{Circulation} \protect{G\'en\'erale} du \protect{LMD}},
+type = {Note interne},
+year = {1991}
+}
+
+@misc{pol,
+author = { }
+}
+
+@book{Chan:60,
+author = {Chandrasekhar , S.},
+address = {180 Varick Street,  New York},
+publisher = {Dover publications},
+title = {Radiative transfer},
+year = {1960}
+}
+
+@techreport{Polc:91a,
+author = {Polcher , Jan and Hourdin , Fr\'ed\'eric},
+institution = {LMD},
+number = {162},
+title = {Une gestion orient\'ee \protect{UNIX} du mod\`ele de circulation g\'en\'erale du \protect{LMD}},
+type = {note interne},
+year = {1991}
+}
+
+@techreport{Hour:91c,
+author = {Hourdin , Fr\'ed\'eric and Polcher , Jan and Li , Zhao  Xin},
+institution = {LMD},
+number = {161},
+title = {Vers une meilleur utilisation du logiciel \protect{UNIRAS}. Pr\'esentation de la biblioth\`eque commune de programmes graphiques lmdgraph et de la norme lmdstd d'\'ecriture des fichiers},
+type = {note interne},
+year = {1991}
+}
+
+@article{Hour:92,
+author = {Hourdin , Fr\'ed\'eric},
+journal = jgr,
+number = {E11},
+pages = {18,319-18,335},
+title = {A new representation of the \protect{CO$_2$ 15~$\mu$m} band for a \protect{Martian} General Circulation Model},
+volume = {97},
+year = {1992}
+}
+
+@article{Leov:82,
+author = {Leovy, C. B.},
+journal = {Adv. Space Res.},
+pages = {19-44},
+title = {Martian meteorological variability},
+volume = {2},
+year = {1982}
+}
+
+@article{Leov:85,
+author = {Leovy, Conway},
+journal = {Adv. Geophys},
+pages = {327-346},
+title = {The general circulation of {Mars} : {Model} and observations.},
+volume = {28a},
+year = {1985}
+}
+
+@article{Curt:52,
+author = {Curtis , A. R.},
+journal = qjr,
+pages = {638},
+title = {Contribution to a discussion of a statistical model for water vapor absorption', by \protect{R. M. Goody}},
+volume = {78},
+year = {1952}
+}
+
+@article{Mart:81,
+author = {Martin, T.  Z.},
+journal = {Icarus},
+pages = {427-446},
+title = {Mean thermal and albedo behavior of the {Mars} surface and atmosphere over a {Martian} year},
+volume = {45},
+year = {1981}
+}
+
+@article{Gods:53,
+author = {Godson , W. L.},
+journal = qjr,
+pages = {367},
+title = {The evaluation of infra-red radiative fluxes due to atmospheric vater vapor},
+volume = {79},
+year = {1953}
+}
+
+@article{Hour:93,
+author = {Hourdin , F. and Le Van , Phu and Forget , F. and Talagrand , O.},
+journal = jas,
+pages = {3625-3640},
+title = {Meteorological variability and the annual surface pressure cycle on \protect{Mars}},
+volume = {50},
+year = {1993}
+}
+
+@inproceedings{Forg:94lpi,
+author = {Forget , F. and Hourdin , F. and Talagrand , O.},
+booktitle = {{Mars Pathfinder Landing}},
+series = {LPI Technical Report},
+title = {Mars pathfinder meteorological observations on the basis of results of an atmospheric general circulation model},
+volume = {94-04},
+year = {1994}
+}
+
+@article{Forg:94egs,
+author = {Forget , F. and Pollack, J.B.},
+journal = {Annales Geophysicae},
+note = {Oral presentation at the 19th annual European Geophysical Society meeting},
+pages = {613},
+title = {Climatology and impact of the {Martian CO$_2$ and H$_2$O polar clouds from thermal infrared data}},
+volume = {12},
+year = {1994}
+}
+
+@article{Tala:94egs,
+author = {Talagrand , O. and Hourdin , F. and Forget , F.},
+journal = {Annales Geophysicae},
+note = {Oral presentation at the 19th annual European Geophysical
+Society meeting},
+pages = {613},
+title = {The {Viking} pressure measurements and the {LMD Martian
+atmospheric GCM}},
+volume = {12},
+year = {1994}
+}
+
+@article{Hour:94egs,
+author = {Hourdin , F and   Talagrand , O. and Courtin , R.  and  Gautier , D. and  McKay , C.P.},
+journal = {Annales Geophysicae},
+note = {Oral presentation at the 19th annual European Geophysical
+Society mee
+ting},
+pages = {613},
+title = {A strong atmospheric superrotation on {Titan}: numerical results},
+volume = {12},
+year = {1994}
+}
+
+@article{Hans:94,
+author = {Hansen , Garry B.},
+journal = baas,
+pages = {1114},
+title = {Low brightness temperatures of {Martian} polar deposits: {New} insight from recent measurement  of  {CO$_2$} ice.},
+volume = {26},
+year = {1994}
+}
+
+@article{Hans:90,
+author = {Hansen, C. A. and {McEwen}, A. S. and Ingersoll, A. P. and Terrile, R. J.},
+journal = {Science},
+pages = {421-424},
+title = {Surface and airborne evidence for plumes and winds on {Triton}},
+volume = {250},
+year = {1990}
+}
+
+@unpublished{Hour:94,
+author = {Hourdin, Fr\'ed\'eric and Talagrand, Olivier},
+note = {submitted to J.~Atmosph.~Sci.},
+title = {Superrotation of Planetary Atmospheres: a Numerical Study},
+year = {1994}
+}
+
+@article{Hour:95b,
+author = {Hourdin , Fr\'ed\'eric and Talagrand , Olivier and Sadourny , Robert and Courtin R\'egis and Gautier , Daniel and McKay , Christopher P.},
+journal = {Icarus},
+pages = {358-374},
+title = {General Circulation of the Atmosphere of {Titan}},
+volume = {117},
+year = {1995}
+}
+
+@article{Cour:94,
+author = {Courtier , P. and Thepaut , J.-N. and Hollingsworth , A.},
+journal = qjrms,
+pages = {1367-1387},
+title = {A strategy for implementation of 4D-Var, using an incremental approach},
+volume = {120},
+year = {1994}
+}
+
+@phdthesis{Forg:these,
+author = {Forget , Fran\c{c}ois},
+school = {Université Paris 6},
+title = {Le climat de la plan{è}te {Mars}~:  de l'importance des poussi{ères} et  des régions polaires},
+year = {1994}
+}
+
+@phdthesis{Murp:91,
+author = {Murphy , J. R.},
+address = {Seattle},
+school = {Univ. of Washington},
+title = {A dimensional hierarchy of numerical simulations of {Martian} global dust storms},
+year = {1991}
+}
+
+
+@article{Barn:93,
+author = {Barnes , J. R. and Pollack , J. B. and Haberle , R. M. and Zurek , R. W. and Leovy , C. B. and Lee , H and Schaeffer , J.},
+journal = jgr,
+number = {E2},
+pages = {3125-3148},
+title = {Mars atmospheric dynamics as simulated by the \protect{NASA/Ames} General Circulation Model, \protect{2}, {Transient} baroclinic eddies},
+volume = {98},
+year = {1993}
+}
+
+@article{Bert:69,
+author = {Bertie},
+journal = {J.~Chem.~Phys},
+pages = {4501},
+volume = {50},
+year = {1969}
+}
+
+@misc{Brig
+}
+
+@article{Leca:91,
+author = {Lecacheux , J. and Drossart , P. and Buil , C. and Laques , P. and Thouvenot , E. and Gu\'erin , P.},
+journal = pss,
+pages = {273-279},
+title = {\protect{CCD} images of \protect{Mars} with the $1m$ reflector atop \protect{Pic-du-Midi}},
+volume = {39},
+year = {1991}
+}
+
+@techreport{Hour:92e,
+author = {Hourdin , F.},
+institution = {Lab. de M\'et\'eorol Dyn., Cent. Nat. de la Rech.
+Sci., Paris},
+number = {175},
+title = {Conservation du moment angulaire dans le mod\`ele de circulation g\'en\'erale du \protect{LMD}},
+type = {Note Interne},
+year = {1992}
+}
+
+@article{Basd:78,
+author = {Basdevant , Claude and Lessieur , M. and Sadourny , R.},
+journal = jas,
+pages = {1028-1042},
+title = {Subgrid scale modeling of enstrophy transfer in two-dimensional turbulence},
+volume = {35},
+year = {1978}
+}
+
+@article{Hess:79,
+author = {Hess , Seymour L. and Henry , Robert H. and Tillman , James E.},
+journal = jgr,
+number = {B6},
+pages = {2923-2927},
+title = {The seasonal variation of atmospheric pressure on \protect{Mars} as affected by the south polar cap},
+volume = {84},
+year = {1979}
+}
+
+@article{Hess:79b,
+author = {Hess ,  Seymour L.},
+journal = jgr,
+pages = {2969-2973},
+title = {Static stability and thermal wind in an atmosphere of
+variable composition: {Application} to {Mars}},
+volume = {84},
+year = {1979}
+}
+
+@article{Hudg:93,
+author = {Hudgins , D. M. and  Sanford , S. A. and Allamandola , L. J. and Tielens , A. G. G. M.},
+journal = {J.~Astrophys.~Jour.~Suppl.~Ser.},
+pages = {713-870},
+title = {Mid and far-infrared spectroscopy of ices: {Optical} constants and
+integrated absorbances},
+volume = {86},
+year = {1993}
+}
+
+@article{Hunt:80,
+author = {Hunt, G. E.},
+journal = grl,
+pages = {481-484},
+title = {On the infrared radiative properties of {CO2} ice
+clouds: {Applications} to {Mars}.},
+volume = {7},
+year = {1980}
+}
+
+@article{Hess:80,
+author = {Hess , S. L. and Ryan , J. A. and Tillman , J. E. and Henry , R. M. and Leovy , C. B.},
+journal = grl,
+pages = {197-200},
+title = {The annual cycle of pressure on \protect{Mars} measured by \protect{Viking} landers 1 and 2},
+volume = {7},
+year = {1980}
+}
+
+@article{Jako:87,
+author = {Jakosky ,  Bruce M. and Martin , Terry Z.},
+journal = {Icarus},
+pages = {528-534},
+title = {Mars: {North}-polar atmospheric warming during dust storms},
+volume = {72},
+year = {1987}
+}
+
+@article{Hess:77,
+author = {Hess , S. L. and Henry , R. M. and Leovy , C. B. and Ryan , J. A. and Tillman , J. E.},
+journal = jgr,
+pages = {4559-4574},
+title = {Meteorological results from the surface of \protect{Mars}: \protect{Viking} 1 and 2},
+volume = {82},
+year = {1977}
+}
+
+@article{Jako:95,
+author = {Jakosky , B. M. and Henderson , B. G. and Mellon ,   M. T.},
+journal = jgr,
+pages = {1579-1584},
+title = {Chaotic obliquity and the nature of the {Martian} climate},
+volume = {100},
+year = {1995}
+}
+
+@article{Jako:95b,
+author = {Jakosky , B. M.},
+journal = {Icarus},
+pages = {352-357},
+title = {Out on a limb: {Martian} atmospheric dust opacity during the past hundred years},
+volume = {117},
+year = {1995}
+}
+
+@article{Habe:95,
+author = {Haberle , Robert M.},
+journal = {Nature},
+pages = {595-596},
+title = {Buried dry ice on Mars},
+volume = {374},
+year = {1995}
+}
+
+@article{Dros:91,
+author = {Drossart , P. and Rosenqvist , J. and Erard , S. and Langevin , Y. and Bibring , J. P. and Combes , M.},
+journal = ang,
+pages = {754-760},
+title = {Martian aerosol properties from the \protect{{\em Phobos}/ISM} experiment},
+volume = {9},
+year = {1991}
+}
+
+@article{Jaco:82,
+author = {Jacobsen , I. and Heise , E.},
+journal = bpa,
+pages = {128-141},
+title = {A new economical method for the computation of the surface temperature in numerical models.},
+volume = {55},
+year = {1982}
+}
+
+@article{Jame:79,
+author = {James , Philip B. and Briggs , Geoffrey and Barnes , Jeffrey and Spruck , Andrea},
+journal = jgr,
+number = {B6},
+pages = {2889-2922},
+title = {Seasonal recession of \protect{Mars'} south polar cap as seen by \protect{V}iking},
+volume = {84},
+year = {1979}
+}
+
+@article{Jame:79nor,
+author = {James, Philip B.},
+journal = jgr,
+pages = {8332-8334},
+title = {Recession of {Martian} north polar cap : 1977-1978 {Viking} Observations},
+volume = {84},
+year = {1979}
+}
+
+@article{Jame:82nor,
+author = {James, Philip B.},
+journal = {Icarus},
+pages = {565-569},
+title = {Recession of {Martian} north polar cap : 1979-1980 {Viking} Observations},
+volume = {52},
+year = {1982}
+}
+
+@article{Tied:89,
+author = {M. Tiedtke},
+journal = {Mon. Wea. Rev.},
+pages = {1179-1800},
+title = {A comprehensive mass flux scheme for cumulus parameterization in large-scale models},
+volume = {117},
+year = {1989}
+}
+
+@article{Till:88,
+author = {Tillman , James E.},
+journal = jgr,
+number = {D8},
+pages = {9433-9451},
+title = {Mars global atmospheric oscillations: Annually synchronized transient normal-mode oscillations and the triggering of global dust storms},
+volume = {93},
+year = {1988}
+}
+
+@article{Till:93,
+author = {Tillman  , James E. and Johnson , Neal C. and Guttorp , Peter and Percival , Donald B.},
+journal = jgr,
+number = {E6},
+pages = {10,963-10,971},
+title = {The \protect{Martian} annual atmospheric pressure cycle: years without great dust storms},
+volume = {98},
+year = {1993}
+}
+
+@article{Till:79,
+author = {Tillman , James E. and Henry , Robert M. and Hess , Seymour L.},
+journal = jgr,
+number = {B6},
+pages = {2947-2955},
+title = {Frontal systems during passage of the \protect{Martian} north polar hood over the \protect{Viking} lander 2 site prior to the first 1977 dust storm},
+volume = {84},
+year = {1979}
+}
+
+@article{Leov:79a,
+author = {Leovy , Conway B. and Zurek , Richard W.},
+journal = jgr,
+number = {B6},
+pages = {2956-2968},
+title = {Thermal tides and \protect{Martian} dust storms: direct evidence for coupling},
+volume = {84},
+year = {1979}
+}
+
+@article{Leov:73,
+author = {Leovy , C. B. and Briggs , G. A. and Smith , B. A.},
+journal = jgr,
+pages = {4252-4266},
+title = {Mars atmosphere during the \protect{Mariner} 9 extended mission: Television results},
+volume = {78},
+year = {1973}
+}
+
+@article{Leov:73a,
+author = {Leovy , C. B. and Pollack , J. B.},
+journal = {Icarus},
+pages = {195-201},
+title = {A first look at atmospheric dynamics and temperature variations on {Titan}},
+volume = {19},
+year = {1973}
+}
+
+@article{Kahn:82,
+author = {Kahn , R. and Gierasch , P.},
+journal = jgr,
+pages = {867-880},
+title = {Long clouds observations on \protect{Mars} and implications for boundary layer characteristics over slopes},
+volume = {87},
+year = {1982}
+}
+
+@article{Ryan:85,
+author = {Ryan , J,. A.},
+journal = jgr,
+number = {A7},
+pages = {6319-6325},
+title = {Mars atmospheric circulation: aspects from \protect{V}iking \protect{L}anders},
+volume = {90},
+year = {1985}
+}
+
+@article{Jako:79,
+author = {Jakosky , Bruce M.},
+journal = jgr,
+number = {B14},
+pages = {8252-8282},
+title = {The effect of nonideal surfaces on the derived thermal properties of \protect{M}ars},
+volume = {84},
+year = {1979}
+}
+
+@article{Jako:82,
+author = {Jakosky , B. M. and Farmer , C. B.},
+journal = jgr,
+number = {B4},
+pages = {2999-3019},
+title = {The seasonal and global behavior of Water Vapor in the \protect{Mars} atmosphere: complete global results of the \protect{Viking} atmospheric vater detector experiment},
+volume = {87},
+year = {1982}
+}
+
+@article{Habe:82,
+author = {Haberle , Robert M. and Leovy , Conway B. and Pollack , J. B.},
+journal = {Icarus},
+pages = {322-367},
+title = {Some effects of global dust storms on the atmospheric circulation of \protect{M}ars},
+volume = {50},
+year = {1982}
+}
+
+@phdthesis{Jous:89,
+author = {Joussaume , Sylvie},
+address = {Paris},
+school = {Universit\'e Pierre et Marie Curie},
+title = {Simulations du climat du dernier max. glaciaire \`a l'aide d'un \protect{MCG} de l'atm. incluant  une mod\'el. du cycle des isotopes de l'eau et des poussi\`eres d'orig. desert.},
+type = {Th\`ese de \protect{D}octorat d'\protect{E}tat \`es \protect{S}ciences \protect{P}hysiques},
+year = {1984}
+}
+
+@article{Youn:77,
+author = {Young , R. E. and Pollack , J. B.},
+journal = jas,
+pages = {1315-1351},
+title = {A three-dimensional model of dynamical processes in the {Venus} atmosphere},
+volume = {34},
+year = {1990}
+}
+
+@article{West:88,
+author = {Westphal , Douglas L. and Toon , Owen B. and Carlson
+, Toby N.},
+journal = jas,
+pages = {2145-2175},
+title = {A case of mobilization and transport of \protect{S}aharan dust},
+volume = {45},
+year = {1988}
+}
+
+@article{Murp:90,
+author = {Murphy , James R. and Haberle , Robert M. and Pollack , James B.},
+journal = jgr,
+number = {B9},
+pages = {14,629-14,647},
+title = {Numerical simulations of the decay of \protect{M}artian dust storms},
+volume = {95},
+year = {1990}
+}
+
+@article{Murp:93,
+author = {Murphy, J.R. and Haberle , R. M. and Toon, O.B.  and  Pollack, J.B.},
+journal = jgr,
+pages = {3197-3220},
+title = {Martian global dust storms: zonally symetric numerical simulations including size dependent  particle transport.},
+volume = {98},
+year = {1993}
+}
+
+@article{Toon:89,
+author = {Toon , O. B. and McKay , C. P. and Ackerman , T. P. and Santhanam , K.},
+journal = jgr,
+pages = {16,287-16,301},
+title = {Rapid calculation of radiative heating rates and photodissociation rates in inhomogeneous multiple scattering atmospheres},
+volume = {94},
+year = {1989}
+}
+
+@article{Toon:77,
+author = {Toon, O. B. and Pollack , J. B. and Sagan , C.},
+journal = {Icarus},
+pages = {663-696},
+title = {Physical properties of the particles composing the  {Martian} dust storm of 1971-1972},
+volume = {30},
+year = {1977}
+}
+
+@article{Wisc:80,
+author = {Wiscombe , W. J. and Warren, S. G.},
+journal = jas,
+pages = {2712-2733},
+title = {A model for the spectral albedo of snow, {I}, {Pure snow}},
+volume = {37},
+year = {1980}
+}
+
+@article{McKa:91,
+author = {McKay , Chris P. and Pollack , James B. and Courtin , R\'egis},
+journal = sci,
+pages = {1118-1121},
+title = {The greenhouse and anti-greenhouse effects on \protect{T}itan},
+volume = {253},
+year = {1991}
+}
+
+@article{Toon:91,
+author = {Toon , O. B. and McKay , C. P. and Griffith , C. A. and Turco , R. P.},
+journal = {Icarus},
+note = {submitted},
+title = {Titan's arerosols},
+year = {1991}
+}
+
+@article{Goli:70,
+author = {Golitsyn , G. S.},
+journal = {Icarus},
+pages = {1-24},
+title = {A similarity Approach to the General Circulation of planetary atmospheres},
+volume = {13},
+year = {1970}
+}
+
+@article{Goli:84,
+author = {Golitsyn , G. S.},
+journal = {Icarus},
+pages = {289-306},
+title = {Some problems of \protect{Venus'} atmospheric dynamics},
+volume = {60},
+year = {1984}
+}
+
+@article{Goli:77,
+author = {Golitsyn , G. S.},
+journal = iaop,
+pages = {780-791},
+title = {Similarity theory in \protect{Soviet} works on geophysical dynamics},
+volume = {13},
+year = {1977}
+}
+
+@article{Goli:75,
+author = {Golitsyn , G. S.},
+journal = {Icarus},
+pages = {70-75},
+title = {Another look at atmospheric dynamics on {Titan} and some of its general consequences},
+volume = {24},
+year = {1975}
+}
+
+@article{Hour:90dps,
+author = {Hourdin , Fr\'ed\'eric and Le~Van , P. and Talagrand , O. and Courtin , R. and Gautier , D. and McKay , C. P.},
+journal = {BAAS},
+note = {Oral presentation at the 22nd annual DPS meeting
+(Charlottesville, Virginia)},
+pages = {1086},
+title = {The Circulation of the Atmosphere of \protect{Titan} : Development of a General Circulation Model},
+volume = {22},
+year = {1990}
+}
+
+@article{Hour:91dps,
+author = {Hourdin , Fr\'ed\'eric and Le~Van , P. and Talagrand , O. and Courtin , R. and Gautier , D. and McKay , C. P.},
+journal = {BAAS},
+note = {Oral presentation at the 23rd annual DPS meeting (Palo Alto, California)},
+pages = {1187},
+title = {Numerical simulation of the circulation of \protect{T}itan's atmosphere: Study of a possible \protect{V}enus-like superrotation},
+volume = {23},
+year = {1991}
+}
+
+@article{Hour:92dps,
+author = {Hourdin , F. and Talagrand , O.},
+journal = {BAAS},
+note = {Oral presentation at the 24th annual DPS meeting (M\"unich, Germany)},
+pages = {1004},
+title = {Study of atmospheric superrotation: Numerical simulations},
+volume = {24},
+year = {1992}
+}
+
+@article{Hour:94cospar,
+author = {Hourdin , Fr\'ed\'eric and Talagrand , O.},
+journal = {Cospar 94 proceeding},
+note = {Invited presentation at the 30th {COSPAR} Scientific Assembly, Hamburg, Germany},
+pages = {133},
+title = {The {Martian} General Circulation},
+volume = {26},
+year = {1994}
+}
+
+@article{Hour:94dps,
+author = {Hourdin , F. and Talagrand , O.  and Courtin , R. and Gautier , D. and McKay , C. P.},
+journal = {BAAS},
+note = {Oral presentation at the 26th annual DPS meeting (Washington)},
+pages = {1184},
+title = {The Gerneral Circulation of the Atmosphere of {Titan}},
+volume = {26},
+year = {1994}
+}
+
+@article{Tala:94dps,
+author = {Talagrand , Olivier and Forget , Fran\c{c}ois and Hourdin , Fr\'ed\'eric},
+journal = {BAAS},
+note = {Oral presentation at the 26th annual DPS meeting (Washington)},
+pages = {1125},
+title = {Martian seasonal transient pressure variations : {GCM}
+simulations and {Viking} observations},
+volume = {26},
+year = {1994}
+}
+
+@article{Forg:94dps,
+author = {Forget , Fran\c{c}ois and Hourdin , Fr\'ed\'eric and Talagrand , Olivier  and Pollack , James B.},
+journal = {BAAS},
+note = {Oral presentation at the 26th annual DPS meeting (Washington)},
+pages = {1125},
+title = {Observations and simulation of the {Martian} Polar Climate : Impact of the {CO$_2$} Clouds},
+volume = {26},
+year = {1994}
+}
+
+@article{Forg:98,
+author = {Forget, F. and Hourdin, F. and Talagrand, O.},
+journal = {Icarus},
+pages = {302-316},
+title = {{CO$_2$} snow fall on {Mars}: Simulation with a general circulation model},
+volume = {131},
+year = {1998}
+}
+
+@article{Hour:93dps,
+author = {Hourdin , Fr\'ed\'eric and Le~Van , P. and Talagrand , O.  and Courtin , R. and Gautier , D. and McKay , C. P.},
+journal = {BAAS},
+note = {Oral presentation at the 25th annual DPS meeting (Boulder)},
+pages = {1105},
+title = {Superrotation: the case of {Titan}},
+volume = {25},
+year = {1993}
+}
+
+@article{Hour:95,
+author = {Hourdin , F. and Forget , F. and Talagrand , O.},
+journal = jgr,
+pages = {5501-5523},
+title = {The sensitivity of the {Martian} surface pressure to various parameters: {A} comparison between numerical simulations and {Viking} observations},
+volume = {100},
+year = {1995}
+}
+
+@article{Duqu:91,
+author = {Duquennoy, A. and Mayor, M.},
+journal = {Astron. Astrophys.},
+pages = {485-524},
+title = {Multiplicity among solar-type stars in the solar neighborhood. {II. Distribution of the orbital elements in an unbiased sample.}},
+volume = {248},
+year = {1991}
+}
+
+@article{Whit:97,
+author = {Whitmire, D. and Matese, J. and Criswell, L. and Mikkola, S.},
+journal = {Icarus},
+pages = {196},
+title = {Habitable planet formation in binary star systems},
+volume = {132},
+year = {1997}
+}
+
+@article{Weth:96,
+author = {Wetherill, G. W.},
+journal = {Icarus},
+pages = {219-238},
+title = {The formation and habitability of extra-solar planets},
+volume = {119},
+year = {1996}
+}
+
+@misc{Forg:95esa,
+author = {Forget , F. and Hansen , G.B. and Pollack , J.B.},
+howpublished = {Oral presentation at the International Workshop on Intermarsnet, Capri, Italy.},
+title = {Condensation of the {Martian CO$_2$} polar caps},
+year = {1995}
+}
+
+@article{Habe:96,
+author = {Haberle, R. M. and Catling, D. C.},
+journal = pss,
+pages = {1361-1383},
+title = {A micro-meteorological mission for global network science on {Mars}: rationale and measurement requirements},
+volume = {44},
+year = {1996}
+}
+
+@article{Lewi:96,
+author = {Lewis, S. R. and Read, P. L. and Collins , M.},
+journal = pss,
+pages = {1395-1409},
+title = {Martian atmospheric data assimilation with a simplified general circulation model: orbiter and Lander networks},
+volume = {44},
+year = {1996}
+}
+
+@article{Jako:96dps,
+author = {Jakosky, B. M.  and  Zent, A. P. and Zurek, R.W.},
+journal = baas,
+pages = {1064},
+title = {The {Mars} water cycle: determining the role of regolith-atmosphere exchange},
+volume = {28},
+year = {1996}
+}
+
+@misc{Maro:95,
+author = {Marov, M.  and Walberg, G. and Jits, R.},
+howpublished = {Mars mission Research Center, NCSU},
+title = {Microlander network for meteorological {Mars} monitoring},
+year = {1996}
+}
+
+@article{Merr:96,
+author = {Merrihew, S. C.  and Haberle, R. M. and Lemke, L. G.},
+journal = pss,
+pages = {1385-1393},
+title = {A micro-meteorological mission for global network science on {Mars}: a conceptual design},
+year = {1996}
+}
+
+@article{IMEW:94,
+author = {The  {International Mars Exploration Working Group}},
+howpublished = pss,
+journal = pss,
+pages = {581-595},
+title = {International strategy for the exploration of {Mars}},
+volume = {43},
+year = {1994}
+}
+
+@article{Tala:93dps,
+author = {Talagrand , O. and Hourdin , F. and Forget , F.},
+journal = {BAAS},
+note = {Oral presentation at the 25th annual DPS meeting (Boulder)},
+pages = {1071},
+title = {Numerical simulation of the General Circulation of the
+{Martian} Atmosphere and the Viking Pressure Data},
+volume = {25},
+year = {1993}
+}
+
+@misc{}
+}
+
+@article{Tala:90dps,
+author = {Talagrand , Olivier and Hourdin , Fr\'ed\'eric},
+journal = {BAAS},
+note = {Oral presentation at the 22nd annual DPS meeting
+(Charlottesville, Virginia)},
+pages = {1074},
+title = {A general Circulation Model of the {Martian} Atmosphere},
+volume = {22},
+year = {1990}
+}
+
+@article{Tala:91dps,
+author = {Talagrand , O. and Hourdin , F. and Forget , F.},
+journal = baas,
+note = {Oral presentation at the 23rd annual DPS meeting (Palo Alto, California)},
+pages = {1217},
+title = {The \protect{LMD} \protect{M}artian General Circulation Model: Results about the Annual Pressure Cycle},
+volume = {23},
+year = {1991}
+}
+
+@article{Tala:92dps,
+author = {Talagrand , O. and Hourdin , F. and Forget , F.},
+journal = {BAAS},
+note = {Oral presentation at the 24th annual DPS meeting (M\"unich, Germany)},
+pages = {922},
+title = {Study of atmospheric superrotation: Numerical simulations},
+volume = {24},
+year = {1992}
+}
+
+@inproceedings{Tala:93assim,
+author = {Talagrand , Olivier},
+address = {Berlin},
+booktitle = {Energy and Weather Cycles in the Climate System},
+editor = {A. Raschke and D. Jacob},
+organization = {NATO Advanced Study Institute},
+pages = {187-213},
+publisher = {Springer-Verlag},
+series = {NATO ASI Series},
+title = {Data Assimilations Problems},
+year = {1993}
+}
+
+@article{Rabi:92,
+author = {Rabier , F. and Courtier , P. and Talagrand , O.},
+journal = bpa,
+pages = {177-192},
+title = {An application of adjoint models to sensitivity analysis},
+volume = {65},
+year = {1992}
+}
+
+@inproceedings{Tala:91assim,
+author = {Talagrand , Olivier},
+address = {Philadelphie},
+booktitle = {Automatic differentitation of algorithms: Theory, implementation, and application},
+editor = {A. Griewank and G. F. Corliss},
+pages = {169-180},
+publisher = {Society for Industrial and Applied Mathematics},
+title = {The use of adjoint equations in numerical modeling of the atmospheric circulation},
+year = {1991}
+}
+
+@phdthesis{Tour:84,
+author = {Tourte , Jean-Louis},
+address = {Paris},
+school = {Universit\'e \protect{P}ierre et \protect{M}arie \protect{C}urie},
+title = {Mod\'elisation num\'erique de la circulation de l'atmosph\`ere de \protect{V}\'enus},
+type = {Th\`ese de docteur -ing\'enieur},
+year = {1984}
+}
+
+@inproceedings{Tanr:84,
+author = {Tanr\'e , D. and Geylen , J.-F. and Slingo , J.},
+address = {Hampton},
+booktitle = {Aerosols and their climatic effects},
+editor = {H..E. Gerber and A. Deepack},
+pages = {133-177},
+publisher = {A. Deepack Publishing},
+title = {First results of the introduction of aerosol-radiation interaction in the \protect{ECMWF} low resolution global model},
+year = {1984}
+}
+
+@article{Del:87,
+author = {Del Genio , Anthony and Suozzo , Robert J.},
+journal = jas,
+pages = {973-986},
+title = {A comparative study of rapidly rotating dynamical regimes in a terrestrial general circulation model},
+volume = {44},
+year = {1987}
+}
+
+@article{Del:83,
+author = {Del Genio , A. D. and Meccage , J. K. and Suozzo , R. and Opstbaum , R. and Rind , D. and Rossow , W. B. and Russell , G. and Travis , L. D.},
+journal = baas,
+pages = {821},
+title = {Variable rotation rate experiments with the \protect{GISS}   General Circulation Model},
+volume = {15},
+year = {1983}
+}
+
+@book{Elsa:42,
+author = {Elsasser , W. M.},
+address = {Cambridge, Mass.},
+pages = {43},
+publisher = {Harvard University Press},
+series = {Harvard Meteorol. Stud.},
+title = {Heat Transfer by Infrared Radiation in the Atmosphere},
+volume = {6},
+year = {1942}
+}
+
+@book{Good:64,
+author = {Goody , R. M.},
+address = {New York},
+publisher = {Oxford University Press},
+title = {Atmospheric Radiation, \protect{vol. I}, Theoretical Basis},
+year = {1964}
+}
+
+@article{Fouq:80,
+author = {Fouquart , Y and Bonnel , B.},
+journal = bpa,
+pages = {35-62},
+title = {Computations of solar heating of the \protect{E}arth's atmosphere: A new parametrization},
+volume = {53},
+year = {1980}
+}
+
+@book{Abra:65,
+address = {New York},
+editor = {Abramowitz , M. and Stegun , I. A.},
+publisher = {Dover},
+title = {Handbook of Mathematical Functions},
+year = {1965}
+}
+
+@article{Gier:67,
+author = {Gierasch , Peter and Goody , Richard},
+journal = pss,
+pages = {1465-1477},
+title = {An approximate calculation of radiative heating and radiative equilibrium in the {Martian} atmosphere},
+volume = {15},
+year = {1967}
+}
+
+@article{Kuhn:79,
+author = {Kuhn ,  W. R. and Atreya , S. K. and Postawko , S. E.},
+journal = jgr,
+number = {B14},
+pages = {8341-8342},
+title = {The influence of ozone on \protect{M}artian atmospheric temperature},
+volume = {84},
+year = {1979}
+}
+
+@phdthesis{Lind:85,
+author = {Lindner , Leo Bernhard},
+school = {Fac. of the Grad. Sch. of the Univ. of Colo., Boulder},
+title = {The aeronomy and radiative transfer of the \protect{M}artian atmosphere},
+year = {1985}
+}
+
+@article{Lind:90,
+author = {Lindner , B. L.},
+journal = jgr,
+pages = {1367-1379},
+title = {The {Martian} polar cap: {Radiative} effects of ozone, clouds, and airborne dust},
+volume = {95},
+year = {1990}
+}
+
+@book{Lind:90book,
+author = {Lindzen , R. S.},
+publisher = {Cmabridge University Press},
+title = {Dynamics in atmospheric physicsq},
+year = {1990}
+}
+
+@book{Jame:94book,
+author = {James, I. N.},
+publisher = {Cambridge University Press},
+title = {Introduction to circulating atmospheres},
+year = {1994}
+}
+
+@article{Lind:93,
+author = {Lindner , B. L.},
+journal = jgr,
+pages = {3339-3344},
+title = {The hemispherical asymmetry in the {Martian} polar caps.},
+volume = {98},
+year = {1993}
+}
+
+@article{Lind:83,
+author = {Lindal , G. F. and Wood , G. E. and Hotz , H. B. and Sweetnam , D. N. and Eshleman , V. R. and Tyler , G. L.},
+journal = {Icarus},
+pages = {348--363},
+title = {The atmosphere of {Titan}: an analysis of the {Voyager~1} radio occultation measurements},
+volume = {53},
+year = {1983}
+}
+
+@article{Lind:79a,
+author = {Lindal , G. F. and Hotz , H. B. and Sweetnam , D. N. and Shippony , Z. and Brenkle , J. P. and Hartsell , G. V. and Spear , R. T. and Micheal , W. H.},
+journal = jgr,
+pages = {8443-8456},
+title = {Viking radio occultation measurements of the atmosphere and topography on \protect{M}ars},
+volume = {84},
+year = {1979}
+}
+
+@book{Liou:80,
+author = {Liou , Kuo-Nan},
+address = {San Diego, Calif.},
+editor = {Academic press},
+publisher = {Academic},
+title = {An Introduction to Atmospheric Radiation},
+year = {1980}
+}
+
+@phdthesis{Li:90,
+author = {Li , Zhao Xin},
+school = {Universit\'e Paris 7},
+title = {Etude de l'int\'eratcion nuage-rayonnement dans le contexte deu changement climatique d\^u \`a l'augmentation dez gaz \`a effet de serre dans l'atmosph\`ere},
+type = {Th\`ese},
+year = {1990}
+}
+
+@article{Leov:69,
+author = {Leovy , Conway and Mintz , Yale},
+journal = jas,
+pages = {1167-1190},
+title = {Numerical simulation of the atmospheric circulation and climate of \protect{M}ars},
+volume = {26},
+year = {1969}
+}
+
+@article{Leov:79,
+author = {Leovy , Conway B.},
+journal = araa,
+pages = {387-413},
+title = {Martian meteorology},
+volume = {17},
+year = {1979}
+}
+
+@article{Poll:79,
+author = {Pollack , James B. and Colburn , David S. and Flasar , F. Michael and Kahn , Ralph and Carlston , C. E. and Pidek , D.},
+journal = jgr,
+number = {B6},
+pages = {2929-2945},
+title = {Properties and effects of dust particles suspended in the \protect{M}artian atmosphere},
+volume = {84},
+year = {1979}
+}
+
+@inproceedings{Mart:92,
+author = {Martin , L. J. and James, P. B. and Dollfus , A. and Iwasaki, K. and Beish , J. D.},
+booktitle = {Mars},
+journal = {Icarus},
+publisher = {University of Arizona Press, Tucson},
+title = {Telescopic observations: visual, photographic, polarimetric},
+year = {1992}
+}
+
+@article{Clan:93lpi,
+author = {Clancy  , R. T. and Lee , S. W. and Gladstone , G. R.},
+institution = {LPI},
+number = {93-05},
+title = {Particle sizes and composition of {Mars} atmospheric dust based upon {Viking}  and {Mariner 9} observations.},
+year = {1993}
+}
+
+@article{Clan:93,
+author = {Clancy,  T.  and Grossman , A.  and Muhleman , D.},
+journal = baas,
+pages = {1060},
+title = {A cold , dry, cloudy, dust-free {Mars} atmosphere in the 1990's},
+volume = {25},
+year = {1993}
+}
+
+@article{Clan:94,
+author = {Clancy, R. T. and Lellouch , E. and Billawala , Y. N. and Sandor , B. J. and Rudy, D. J.},
+journal = baas,
+pages = {1130},
+title = {Microwave observations of a 1994 {Mars} global dust storm},
+volume = {26},
+year = {1994}
+}
+
+@article{Clan:95,
+author = {Clancy, R. T. and Lee , S. W.  and Gladstone , G. R. and McMillan , W. W.  and Rousch , T.},
+journal = jgr,
+pages = {5251-5263},
+title = {A new model for {Mars} atmospheric dust based upon analysis of ultraviolet through infrared observations from  {Mariner 9, Viking, and Phobos}},
+volume = {100},
+year = {1995}
+}
+
+@article{Clan:91,
+author = {Clancy , R. T. and Lee , S. W.},
+journal = {Icarus},
+pages = {135-158},
+title = {A new look at dust and clouds in the {Mars} atmosphere: {Analysis} of emission-phase function sequences from global {Viking IRTM} observations},
+volume = {93},
+year = {1991}
+}
+
+@article{Chas:95,
+author = {Chassefiere, E. and Drossart , P. and Korablev , O.},
+journal = jgr,
+pages = {5525-5539},
+title = {Post-{Phobos} model for the altitude and size distribution of dust in the low {Martian} atmosphere},
+volume = {100},
+year = {1995}
+}
+
+@article{Chas:92,
+author = {Chassefiere, E. and Blamont , J. E.  and Krasnopolsky , V. A.  and Korablev , O. I. and Atreya , S. K.  and West , R. A.},
+journal = {Icarus},
+pages = {46-69},
+title = {Vertical structure and size distributions of {Martian} aerosols from solar occultation measurements},
+volume = {97},
+year = {1992}
+}
+
+@article{Chas:91,
+author = {Chassefi\`{e}re, E.},
+journal = grl,
+pages = {1055-1058},
+title = {Photochemical regulation of {CO on Mars}},
+volume = {18},
+year = {1991}
+}
+
+@article{Chas:92b,
+author = {Chassefi\`ere , E. and Blamont , J. E.},
+journal = grl,
+pages = {945},
+title = {Vertical transport of water ice at low latitudes in the {Martian} atmosphere},
+volume = {19},
+year = {1992}
+}
+
+@article{Zent:95,
+author = {Zent , A. P.  and Quinn , R. C.},
+journal = jgr,
+pages = {5341-5349},
+title = {Simultaneous adsorption of {CO$_{2}$ and H$_{2}$O under  Mars}-like conditions and application to the evolution of the {Martian} climate.},
+volume = {100},
+year = {1995}
+}
+
+@article{Houb:94,
+author = {Houben , H. and Haberle , R. M. and Young , R.E. and Zent , A.},
+journal = baas,
+pages = {1112},
+title = {The regolith-dominated {Martian} water cycle.},
+volume = {26},
+year = {1994}
+}
+
+@article{Kora:93,
+author = {Korablev , O. I. and Krasnopolsky , V. A. and Rodin , A. V.  and Chassefiere , E.},
+journal = {Icarus},
+pages = {76-87},
+title = {Vertical structure of the {Martian} dust measured by the solar infrared occultations from the {Phobos} spacecraft.},
+volume = {102},
+year = {1993}
+}
+
+@article{Colb:89,
+author = {Colburn , D. S.  and Pollack , J. B.  and  Haberle , R. M.},
+journal = {Icarus},
+pages = {159-189},
+title = {Diurnal variations in optical depth at {Mars}},
+volume = {79},
+year = {1989}
+}
+
+@article{Poll:90,
+author = {Pollack , James B. and Haberle , Robert M. and Schaeffer , J. and Lee , H.},
+journal = jgr,
+pages = {1447-1473},
+title = {Simulations of the general circulation of the \protect{M}artian atmosphere, \protect{1}, \protect{Polar} processes},
+volume = {95},
+year = {1990}
+}
+
+@article{Poll:90triton,
+author = {Pollack, J.B. and Schwartz, J. M. and Rages, K.},
+journal = {Science},
+number = {25},
+pages = {440-443},
+title = {Scatterers in {Triton's} atmosphere : implications for the seasonal volatile cycle.},
+year = {1990}
+}
+
+@techreport{Ched:84,
+author = {Chedin , A. and Husson , N. and Scott , N. A. and Cohen-Hallaleh , I. and Berroir , A.},
+address = {Ecole Polytech., Palaiseau, France},
+institution = {Laboratoire de M\'et\'eorologie Dynamique du CNRS},
+number = {127},
+title = {The \protect{"GEISA"} data bank 1984 version},
+year = {1984}
+}
+
+@article{Hunt:73,
+author = {Hunt , B. G.},
+journal = {Tellus},
+pages = {337-354},
+title = {Zonally symmetric global general circulation models with and without hydrologic cycle},
+volume = {XXV},
+year = {1973}
+}
+
+@article{Mayr:91,
+author = {Mayr , H. G.  and Chan , K. L. and Harris , I. and Schatten , K.},
+journal = apj,
+pages = {361-366},
+title = {What maintains the zonal circulation in planetary atmospheres?},
+volume = {367},
+year = {1991}
+}
+
+@article{Savi:91,
+author = {Savij\"arvi , H.},
+journal = bpa,
+pages = {103-112},
+title = {Radiative Fluxes on a dust free \protect{M}ars},
+volume = {2},
+year = {1991}
+}
+
+@article{Savi:91pbl,
+author = {Savij{\"a}rvi , Hannu},
+journal = mwr,
+pages = {833-840},
+title = {The {United} {States|} Great plains diurnal {ABL} variation and the nocturnal low-level jet},
+volume = {119},
+year = {1991}
+}
+
+@article{Savi:93,
+author = {Savij\"arvi , H. and Siili , T.},
+journal = jas,
+pages = {77-88},
+title = {The \protect{M}artian slope wind and the nocturnal \protect{PBL} jet},
+volume = {50},
+year = {1993}
+}
+
+@article{Savi:XXa,
+author = {Savij\"arvi , Hannu},
+journal = {not published},
+title = {A model study of the \protect{PBL} structure on Mars and Earth},
+year = {19XX}
+}
+
+@article{Savi:95,
+author = {Savij{\"a}rvi , Hannu},
+journal = {Icarus},
+pages = {120-127},
+title = {Mars boundary layer modeling : diurnal moisture cycle and soil properties at the {Viking} Lander~1 site},
+volume = {117},
+year = {1995}
+}
+
+@article{Seif:82,
+author = {Seiff , A.},
+journal = asr,
+pages = {3-17},
+title = {Post-\protect{V}iking models for the stucture of the summer atmosphere of \protect{M}ars},
+volume = {2},
+year = {1982}
+}
+
+@article{Seif:76,
+author = {Seiff , Alvin and Kirk , Donn B.},
+journal = {Science},
+pages = {1300-1303},
+title = {Structure of the \protect{Mars'} atmosphere up to 100 kilometers from the entry measurements of \protect{Viking} 2},
+volume = {194},
+year = {1976}
+}
+
+@article{Shor:76,
+author = {Shorthill , Richard W. and Moore , Henry J. and Hutton , Robert E.  and Scott , Ronald F. and Spitzer , Cary R.},
+journal = {Science},
+pages = {1309-1318},
+title = {The environment of \protect{Viking} 2 lander},
+volume = {194},
+year = {1976}
+}
+
+@article{Kief:76,
+author = {Kieffer , Hugh H. and Chase , S. C.  and Miner,  E. D.  and Palluconi , Frank Don.  and M\"unch , Guidoa and Neugebauer , Gerry and Martin, Terry Z.},
+journal = {Science},
+pages = {780-786},
+title = {Infrared Thermal mapping of the {Martian} surface and atmosphere: First results},
+volume = {193},
+year = {1976}
+}
+
+@article{Kief:76c,
+author = {Kieffer , H. H. and Chase , S. C.  and Martin , T. Z.  and Miner , E. D.  and Palluconi , F. D.},
+journal = {Science},
+pages = {1341-1343},
+title = {Martian north pole summer temperatures : dirty water ice},
+volume = {194},
+year = {76}
+}
+
+@article{Hers:84,
+author = {Herschel , W.},
+journal = {Philos. Trans.},
+pages = {233-273},
+title = {On the remarkable appearance of the polar regions of the planet {Mars}, the inclination of its axis, the position of its poles, and its spheroidical figure; {With} a few hints relative to its diameter},
+volume = {24},
+year = {1784}
+}
+
+@article{Mana:61,
+author = {Manabe , Syukuro  and M\"oller , Fritz},
+journal = mwr,
+pages = {503-532},
+title = {On the radiative  equilibrium and heat balance of the atmosphere},
+volume = {89},
+year = {1961}
+}
+
+@article{Mana:64,
+author = {Manabe , Syukuro and Strickler , Robert F.},
+journal = jas,
+pages = {361-385},
+title = {Thermal Equilibrium of the atmosphere with a convective adjustment},
+volume = {21},
+year = {1964}
+}
+
+@article{Hosk:91,
+author = {Hoskins , Brian J.},
+journal = {Tellus},
+pages = {27-35},
+title = {Toward a PV-$\theta$ view of the general circulation},
+volume = {43AB},
+year = {1991}
+}
+
+@article{Cris:86,
+author = {Crisp , David and Fels , Stephen B. and Schwarzkopf , M. D.},
+journal = jgr,
+number = {D11},
+pages = {11,851-11,866},
+title = {Approximate methods for finding \protect{CO$_2$}  \protect{$15\mu$m} band transmission in planetary atmospheres},
+volume = {91},
+year = {1986}
+}
+
+@article{Buri:80,
+author = {Buriez , J. C. and Fouquart , Y.},
+journal = jqsrt,
+pages = {407-419},
+title = {Generalization of the \protect{C}urtis-\protect{G}odson approximation to inhomogeneous scattering atmopsheres},
+volume = {24},
+year = {1980}
+}
+
+@article{Mead:80,
+author = {Meador , W. E. and Weaver , W. R.},
+journal = jas,
+pages = {630-643},
+title = {Two-stream approximations to radiative transfer in planetary atmospheres: a unified description of existing methods and new improvement},
+volume = {37},
+year = {1980}
+}
+
+@article{Kuhn:69,
+author = {Kuhn , William and London , Julius},
+journal = jas,
+pages = {189-204},
+title = {Infrared radiative cooling in the middle atmosphere (30-110 km)},
+volume = {26},
+year = {1969}
+}
+
+@proceedings{Berg:84,
+editor = {Berger, A. L. and Nicolis C.},
+publisher = {Elsevier Science Publishers, Amsterdam},
+title = {New perspectives in climate modeling},
+year = {1984}
+}
+
+@article{Fels:81,
+author = {Fels , Stephen B. and Schwarzkopf , M. D.},
+journal = jgr,
+number = {C2},
+pages = {1205-1232},
+title = {An Efficient, Accurate Algorithm for Calculating \protect{CO$_2$} $15 \mu$m Band Cooling Rates},
+volume = {86},
+year = {1981}
+}
+
+@article{Flas:81,
+author = {Flasar , F. M. and Samuelson , R. E. and Conrath , B. J.},
+journal = {Nature},
+pages = {693-698},
+title = {Titan's atmosphere: temperature and dynamics},
+volume = {292},
+year = {1981}
+}
+
+@article{Lask:93,
+author = {Laskar , J and Robutel , P.},
+journal = {Nature},
+pages = {608-612},
+title = {The chaotic obliquity of the planets},
+volume = {361},
+year = {1993}
+}
+
+@article{Flas:90,
+author = {Flasar , F. M. and Conrath , B. J.},
+journal = {Icarus},
+pages = {346-354},
+title = {Titan's stratospheric temperatures: a case for dynamical inertia?},
+volume = {85},
+year = {1990}
+}
+
+@article{Gier:75,
+author = {Gierasch , P. J.},
+journal = jas,
+pages = {1038-1044},
+title = {Meridional circulation and the maintenance of the \protect{Venus} atmospheric rotation},
+volume = {32},
+year = {1975}
+}
+
+@book{Holt:79,
+author = {Holton , James R.},
+edition = {second},
+editor = {Anton L. Hales},
+publisher = {Academic Press},
+series = {Internal geophysics series},
+title = {An introduction to dynamic meteorology},
+volume = {23},
+year = {1979},
+adress = "New York \ San Francisco \ London"
+}
+
+@book{Holt:92,
+author = {Holton , James R.},
+edition = {third},
+publisher = {Academic Press},
+series = {Internal geophysics series},
+title = {An introduction to dynamic meteorology},
+volume = {48},
+year = {1992},
+adress = "New York \ San Francisco \ London"
+}
+
+@book{Holt:04,
+	author = {Holton , J.~R.},
+	edition = {fourth},
+	publisher = {Elsevier Academic Press},
+	series = {International geophysics series},
+	title = {An introduction to dynamic meteorology},
+	volume = {48},
+	year = {2004},
+	adress = "New York \ San Francisco \ London"
+}
+
+@book{Peix:92,
+author = {Peixoto , Jos\'e P.  and Oort , Abraham H.},
+address = {New York},
+publisher = {American Institute of Physics},
+title = {Physics of Climate},
+year = {1992}
+}
+
+@unpublished{Morc:89,
+author = {Morcrette , Jean-Jacques},
+title = {The \protect{ECMWF} model radiation scheme: Description and Validation},
+year = {1989}
+}
+
+@article{Hou:90,
+author = {Hou , Arthur Y. and Fels , Stephen B. and Goody , Richard M.},
+journal = jas,
+pages = {1894-1901},
+title = {Zonal Superrotation above \protect{Venus}'Cloud Base Induced by the Semidiurnal Tide and the Mean Meridional Circulation},
+volume = {47},
+year = {1990}
+}
+
+@article{Malk:67,
+author = {Malkmus , W.},
+journal = josa,
+pages = {323-329},
+title = {Random \protect{L}orentz band model with exponential-tailed $S^{-1}$ line-intensity distiribution function},
+volume = {57},
+year = {1967}
+}
+
+@article{Zhu:88,
+author = {Zhu , Xun},
+journal = jqsrt,
+pages = {421-427},
+title = {An improved voigt line approximation for the calculation of equivalent width and transmission},
+volume = {39},
+year = {1988}
+}
+
+@article{Zhu:89,
+author = {Zhu , Xun},
+journal = jas,
+pages = {511-520},
+title = {Radiative cooling calculated by random models with \protect{$S^{-1-\beta}$} tailed distribution},
+volume = {46},
+year = {1989}
+}
+
+@article{Fels:79,
+author = {Fels , Stephen B.},
+journal = ao,
+pages = {2634-2637},
+title = {Simple strategies for inclusion of \protect{V}oigt effect in infrared cooling rate calculations},
+volume = {18},
+year = {1979}
+}
+
+@inproceedings{Tala:90b,
+author = {Talagrand , Olivier and Hourdin , Fr\'ed\'eric},
+booktitle = {International symposium on assimilation of observations in meteorology and oceanography},
+organization = {World Meteorological Organization},
+pages = {578-580},
+title = {A plan for assimilation of observations of the \protect{Martian} atmosphere},
+year = {1990}
+}
+
+@article{Cour:90,
+author = {Courtier , P. and Talagrand , O.},
+journal = {Tellus},
+pages = {531-549},
+title = {Variational assimilation of meteorological observations with the direct and adjoint shallow-water equations},
+volume = {42A},
+year = {1990}
+}
+
+@article{Cour:95,
+author = {Courtin , R\'egis and Gautier , Daniel  and McKay , Christopher P.},
+journal = {Icarus},
+pages = {144-162},
+title = {Titan's thermal emission spectrum: {Reanalysis} of the {Voyager} Infrared measurements},
+volume = {14},
+year = {1995}
+}
+
+@article{Cour:87,
+author = {Courtier , P. and Talagrand , O.},
+journal = qjrms,
+pages = {1329-1347},
+title = {Variational assimilation of meteorological observations with the adjoint vorticity equation. \protect{II}: Numerical results},
+volume = {113},
+year = {1987}
+}
+
+@article{Tala:90,
+author = {Talagrand , O. and Courtier , P.},
+journal = {Tellus},
+pages = {531-549},
+title = {Variational assimilation of meteorological observations with the direct and adjoint shallow-water equations},
+volume = {42A},
+year = {1990}
+}
+
+@article{Tala:87,
+author = {Talagrand , O. and Courtier , P.},
+journal = qjrms,
+pages = {1331-1328},
+title = {Variational assimilation of meteorological observations with the adjoint vorticity equation. \protect{I}: Theory},
+volume = {113},
+year = {1987}
+}
+
+@article{Good:52,
+author = {Goody , R. M.},
+journal = qjr,
+pages = {165-169},
+title = {A statistical model for water vapour absorption},
+volume = {78},
+year = {1952}
+}
+
+@article{Hour:90a,
+author = {Fr\'ed\'eric Hourdin and Talagrand , Olivier},
+journal = ang,
+note = {Poster presentation at the XV General Assembly of the EGS},
+pages = {328},
+title = {A general Circulation Model of the {Martian} Atmosphere},
+volume = {Special Issue},
+year = {1990}
+}
+
+@article{Jako:93,
+author = {Jakosky, B. M.   and Henderson , B. G.  and Mellon M. T.},
+journal = {Icarus},
+pages = {286-297},
+title = {The {Mars} water cycle at other epochs~: recent history of the polar caps and layered terrain.},
+volume = {102},
+year = {1993}
+}
+
+@article{Ward:74,
+author = {Ward  ,  W. R. and Murray , B. C. and Malin , M. C.},
+journal = jgr,
+pages = {3387-3395},
+title = {Climatic variations on {Mars}. 2. {Evolution} of carbon dioxide atmosphere and polar caps},
+volume = {79},
+year = {1974}
+}
+
+@article{Tala:91,
+author = {Talagrand , Olivier and Hourdin , Fr\'ed\'eric and Le Van , Phu},
+journal = ang,
+note = {Oral presentation at the XVI General Assembly of the EGS},
+pages = {C422},
+title = {Development of the \protect{LMD} General Circulation Model of the {Martian} atmosphere: a progress report},
+volume = {9 supp.},
+year = {1991}
+}
+
+@article{Hou:92,
+author = {Hou , Arthur Y. and Lindzen , Richard S.},
+journal = jas,
+pages = {1233-1241},
+title = {The influence of concentrated heating on the \protect{Hadley} circulation},
+volume = {49},
+year = {1992}
+}
+
+@article{Hour:91,
+author = {Hourdin , Fr\'ed\'eric and Talagrand , Olivier},
+journal = ang,
+note = {Oral presentation at the XVI General Assembly of the EGS},
+pages = {C409},
+title = {Hadley Circulation and Superrotation in Planetary Atmospheres},
+volume = {9 supp.},
+year = {1991}
+}
+
+@inproceedings{Hour:92b,
+author = {Hourdin , F. and Le Van , P. and Talagrand , O. and Courtin , R. and Gautier , D. and McKay , C.},
+booktitle = {Symposium on \protect{Titan}},
+organization = {ESA},
+pages = {101-106},
+publisher = {ESA},
+title = {Numerical simulation of the circulation of the atmosphere of \protect{Titan}},
+volume = {SP-338},
+year = {1992}
+}
+
+@inproceedings{Jame:92,
+author = {James , Ian N.},
+booktitle = {Symposium on \protect{Titan}},
+crossref = {esa:91},
+editor = {ESA},
+organization = {ESA},
+pages = {107-111},
+title = {Simple dynamical models of \protect{Titan's}
+atmospheric circulation},
+volume = {SP-338},
+year = {1992}
+}
+
+@inproceedings{Kief:92b,
+author = {Kieffer , H. H. and Zent , A. P.},
+booktitle = {Mars},
+editor = {Kieffer , Jakosky , Snyder  and Matthews},
+pages = {pp. 1180-1218},
+publisher = {University of Arizona Press, Tucson},
+title = {Quasi-periodic climate change on {Mars}},
+year = {1992}
+}
+
+@inproceedings{Snyd:92,
+author = {Snyder, C. W. and Moroz, V. I.},
+booktitle = {Mars},
+editor = {Kieffer , Jakosky , Snyder  and Matthews},
+pages = {pp. 71-119},
+publisher = {University of Arizona Press, Tucson},
+title = {Spacecraft exploration of {Mars}},
+year = {1992}
+}
+
+@inproceedings{Kief:92c,
+author = {Kieffer , H. H. and Jakosky, B. M. and Snyder , C.W.},
+booktitle = {Mars},
+editor = {Kieffer ,  Jakosky , Snyder  and Matthews},
+pages = {pp. 1-33},
+publisher = {University of Arizona Press, Tucson},
+title = {The planet {Mars: From} antiquity to the present},
+year = {1992}
+}
+
+@inproceedings{Jame:92mars,
+author = {James , Philip B. and Kieffer , Hugh H. and Paige , David A.},
+booktitle = {Mars},
+pages = {pp.~934-968},
+publisher = {University of Arizona Press, Tucson},
+title = {The seasonal cycle of carbon dioxide on {Mars}},
+volume = {  },
+year = {1992}
+}
+
+@inproceedings{Kahn:92,
+author = {Kahn, R. A. and Martin , T. Z. and Zurek , R. W.},
+booktitle = {Mars},
+pages = {pp.~1017-1053},
+publisher = {University of Arizona Press, Tucson},
+title = {The {Martian} dust cycle},
+volume = {  },
+year = {1992}
+}
+
+@inproceedings{Gree:92,
+author = {Greeley , R. and Lancaster , N. and Lee , S. and Thomas, P.},
+booktitle = {Mars},
+pages = {pp.~730-766},
+publisher = {University of Arizona Press, Tucson},
+title = {Martian aeolian processes, sediments and features},
+volume = {  },
+year = {1992}
+}
+
+@inproceedings{Jako:92,
+author = {Jakosky , Bruce M. and Haberle  ,  Robert M},
+booktitle = {Mars},
+pages = {pp.~969},
+publisher = {University of Arizona Press, Tucson},
+title = {The seasonal behavior of water on {Mars}},
+year = {1992}
+}
+
+@inproceedings{Owen:92,
+author = {Owen ,Tobias},
+booktitle = {Mars},
+pages = {pp.~818-834},
+publisher = {University of Arizona Press, Tucson},
+title = {The composition and early history of the atmosphere of {Mars}},
+year = {1992}
+}
+
+@article{Hapk:81,
+author = {Hapke, B.},
+journal = jgr,
+pages = {3039-3054},
+title = {Bidirectional reflectance spectroscopy 1. {Theory}},
+volume = {86},
+year = {1981}
+}
+
+@article{Hapk:86,
+author = {Hapke , B.},
+journal = {Icarus},
+pages = {264-280},
+title = {Bidirectional reflectance spectroscopy  4. {The extinction coefficient and the opposition effect}},
+volume = {67},
+year = {1986}
+}
+
+@inproceedings{Jame:92b,
+author = {James , P. B. and Kieffer , H. H. and Paige , D. A.},
+address = {Tucson},
+booktitle = {Mars},
+chapter = {27},
+pages = {pp.~934-968},
+publisher = {University of Arizona Press, Tucson},
+title = {The seasonal cycle of carbon dioxide on \protect{Mars}},
+year = {1992}
+}
+
+@book{Kief:92,
+author = {Kieffer, H. H. and Jakosky , B. M.  and Snyder , C. W.  and Matthews, M .S},
+address = {Tucson},
+booktitle = {Mars},
+chapter = {23},
+publisher = {University of Arizona Press, Tucson},
+title = {Mars},
+year = {1992}
+}
+
+@article{Hunt:79,
+author = {Hunt , B. G.},
+journal = jas,
+pages = {1392-1408},
+title = {The Influence of the Earth's Rotation Rate on the General Circulation of the Atmosphere},
+volume = {36},
+year = {1979}
+}
+
+@article{Toon:,
+author = {Rapid}
+}
+
+@article{Hunt:81,
+author = {Hunt, B. G.},
+journal = jas,
+pages = {2172-2186},
+title = {The maintenance of the zonal mean state of the upper atmosphere as represented in a three-dimensional \protect{General} \protect{Circulation} \protect{Model} Extending to $100km$.},
+volume = {38},
+year = {1981}
+}
+
+@article{McKa:89,
+author = {McKay , C. P. and Pollack , J. B. and Courtin , R.},
+journal = {Icarus},
+pages = {23-53},
+title = {The Thermal Structure of \protect{Titan's} Atmosphere},
+volume = {80},
+year = {1989}
+}
+
+@article{Schn:77,
+author = {Schneider , Edwin K. and Lindzen , Richard S.},
+journal = jas,
+pages = {263-296},
+title = {Axially symmetric steady-state models of the basic state for instability and climate studies. \protect{Part I}. Linearized calculations.},
+volume = {34},
+year = {1977}
+}
+
+@article{Held:80,
+author = {Held , Isaac M. and Hou , Arthur Y.},
+journal = jas,
+pages = {515-533},
+title = {Nonlinear axially symmetric circulations in a nearly inviscid atmosphere},
+volume = {37},
+year = {1980}
+}
+
+@article{Held:78,
+author = {Held , Isaac M.},
+journal = jas,
+pages = {572-576},
+title = {The vertical scale of an unstable baroclinic wave and its importance for Eddy heat flux parametrizations},
+volume = {35},
+year = {1977}
+}
+
+@article{McKa:90,
+author = {McKay , Christopher},
+journal = {La recherche},
+pages = {1216-1224},
+title = {La vie sur \protect{Mars}},
+volume = {21},
+year = {1990}
+}
+
+@article{McKa:89mars,
+author = {McKay, C.P. and Stoker, C. R.},
+journal = {Review of Geophysics},
+pages = {189-214},
+title = {The early environment and its evolution on {Mars}: implication for life},
+volume = {27},
+year = {1989}
+}
+
+@article{McKa:96,
+author = {McKay, D. S. and Gibson Jr. , E. K. and Thomas-Keprta, K.L. and Vali, H. and Romanek, C.S. and Clemett, S. J. and Chillier, X.D.F. and Maechling, C.R. and Zare, R.N.},
+journal = {Science},
+pages = {924-929},
+title = {Search for past life on {Mars}: possible relic biogenic activity in {Martian} meteorite {ALH84001}},
+volume = {273},
+year = {1996}
+}
+
+@article{Morc:86,
+author = {Morcrette , Jean Jacques and Smith , Laura and Fouquart , Yves},
+journal = bpa,
+number = {4},
+pages = {455-469},
+title = {Pressure and Temperature Dependence of the Absorption in Longwave Radiation Parametrizations},
+volume = {59},
+year = {1986}
+}
+
+@phdthesis{Morc:84,
+author = {Morcrette , Jean Jacques},
+school = {Univ. des Sci. et Tech. de Lille, France},
+title = {Sur la param\'etrisation du rayonnement dans les mod\`eles de la circulation g\'en\'erale atmosph\'erique},
+type = {th\`ese de \protect{D}octorat d'\protect{E}tat},
+year = {1984}
+}
+
+@article{Sado:75,
+author = {Sadourny , Robert},
+journal = jas,
+pages = {680-689},
+title = {The Dynamics of Finite-Difference Models of the Shallow-Water Equations},
+volume = {32},
+year = {1975}
+}
+
+@article{Sado:75a,
+author = {Sadourny , Robert},
+journal = jas,
+pages = {2103-2110},
+title = {Compressible Model Flows on the Sphere},
+volume = {32},
+year = {1975}
+}
+
+@article{Rodg:66,
+author = {Rodgers , C. D. and Walshaw , C. D.},
+journal = qjr,
+pages = {67-92},
+title = {The computation of infra-red cooling rate in planetary atmospheres},
+volume = {92},
+year = {1966}
+}
+
+@article{Rodg:74,
+author = {Rodgers , C. D. and Williams , A. P.},
+journal = jqsrt,
+pages = {319-323},
+title = {Integrated absorption of a spectral line with the \protect{V}oigt profile},
+volume = {14},
+year = {1974}
+}
+
+@incollection{Sado:84,
+author = {Sadourny,R. and Laval,K.},
+address = {Amsterdam},
+booktitle = {New perspectives in Climate Modeling},
+editor = {A.~Berger and C.~Nicolis},
+key = {Sadourny, Laval, 1984},
+pages = {173-197},
+series = {Elsevier},
+title = {January and {July} performance of the \protect{LMD} General Circulation Model},
+year = {1984}
+}
+
+@inproceedings{Sado:80,
+author = {Sadourny , Robert},
+address = {Reading},
+booktitle = {Dynamical meteorology and numerical weather prediction},
+editor = {ECMWF},
+title = {Conservation laws, quasi-two-dimensional turbulence and numerical modeling of large scale flows},
+volume = {2},
+year = {1980}
+}
+
+@article{Sica:90,
+author = {Sicardy , Bruno and Brahic , A. and Ferrari , C. and Gautier , D. and Lecacheux , J. and Lellouch , E. and Roques , F. and Arlot , J. E. and Colas , F. and Thuillot , W. and S\`evre , F. and Vidal , J. and Blanco , C. and Cristaldi , S. and Buil , C. and Klotz , A. and Thouvenot , E.},
+address = {. and Blanco , C. and Cristaldi , S. and Buil , C. and Klotz , A. and Thouvenot , E.},
+journal = {Nature},
+pages = {350},
+title = {Probing \protect{Titan's} atmosphere by stellar occultation},
+volume = {343},
+year = {1990}
+}
+
+@article{Sant:93,
+author = {Santee , Michelle and Crisp , David},
+journal = jgr,
+pages = {3261-3279},
+title = {Thermal structure and Dust Loading of the \protect{Martian} atmosphere during late southern summer: \protect{Mariner} 9 revisited},
+volume = {98},
+year = {1993}
+}
+
+@article{Step:84,
+author = {Stephens , Graeme L.},
+journal = mwr,
+pages = {826-867},
+title = {The Parametrization of Radiation for Numerical Weather Prediction and Climate Models},
+volume = {112},
+year = {1984}
+}
+
+@article{Tiwa:78,
+author = {Tiwari , Surendra N.},
+journal = {Adv. Geophys.},
+pages = {1-85},
+title = {Models For Infrared Atmospheric Radiation},
+volume = {20},
+year = {1978}
+}
+
+@article{Tjem:88,
+author = {Tjemkes , S. A. and Duynkerke , P. G.},
+journal = bpa,
+pages = {105-113},
+title = {A New Look at the \protect{G}oody Band Model},
+volume = {61},
+year = {1988}
+}
+
+@book{Hunt:83,
+address = {Tucson, AZ, USA},
+editor = {Hunten , D. M. and Colin , L. and Donahue , T. M. and Moroz , V. I.},
+publisher = {Univ. of Arizona Press},
+series = {Space Science},
+title = {Venus},
+year = {1983}
+}
+
+@article{Rama:89,
+author = {Ramanathan, V. and R. D. Cess and E. F. Harrison
+and P. Minnis and B. R. Barkstrom and E. Ahmad and D.
+Hartmann},
+journal = {Science},
+pages = {57-62},
+title = {Cloud-radiative forcing and climate: results
+from the {E}arth {R}adiation {B}udget {E}xperiment},
+volume = {243},
+year = {1989}
+}
+
+@article{Russ:81,
+author = {Russell , G. L. and Lerner , J. A.},
+journal = jam,
+pages = {1483-1498},
+title = {A new finite-differencing scheme for the tracer transport equation},
+volume = {20},
+year = {1981}
+}
+
+@article{Blam:93,
+author = {Blamont, J. E. and Chassefi\`ere , E.},
+journal = {Icarus},
+pages = {324-336},
+title = {First detection of Ozone in the middle atmosphere of Mars from solar occultaion measurements},
+volume = {104},
+year = {1993}
+}
+
+@article{Chas:94,
+author = {Chassefi\`ere , E. and Rosenqvist , J. and Th\'eodore , B.},
+journal = pss,
+pages = {825-830},
+volume = {42},
+year = {1994}
+}
+
+@article{VanL:77,
+author = {Van Leer , Bram},
+journal = jcp,
+pages = {276-299},
+title = {Towards the ultimate conservative difference scheme : {IV.} A new approach to numerical convection},
+volume = {23},
+year = {1977}
+}
+
+@article{VanL:79,
+author = {Van Leer , B.},
+journal = jcp,
+pages = {101-136},
+title = {Towards the ultimate conservative difference scheme. {V.} A second-order sequel to {Godunov's} method},
+volume = {32},
+year = {1979}
+}
+
+@article{Bori:73,
+author = {Boris , J. P. and Book , D. L.}
+}
+
+@article{vanL:85,
+author = {\protect{van} Leer, B.},
+journal = {Lect.~Notes Appl. Math.},
+pages = {327-336},
+title = {Upwind-difference methods for aerodynamic problems governed by the \protect{E}uler equations},
+volume = {22},
+year = {1985}
+}
+
+@book{Vand:57,
+author = {Van de Hulst , H. C.},
+note = {Republished, 1981},
+publisher = {Dover Publication, inc.},
+title = {Light scaterring by small particles},
+year = {1957}
+}
+
+@article{Prat:86,
+author = {Prather , M. J.},
+journal = jgr,
+pages = {6671-6681},
+title = {Numerical advection by conservation of second order moments},
+volume = {91},
+year = {1986}
+}
+
+@article{Mill:89,
+author = {Miller, M. J. and Palmer, P. M. and Swinbank, R.},
+journal = {Meteorol. Atmos. Phys.},
+pages = {84-109},
+title = {Parametrisation and influence of sub-grid scale orography in general circulation and numerical weather prediction models.},
+volume = {40},
+year = {1989}
+}
+
+@techreport{Bain:90,
+author = {Baines, P. G. and Palmer, T. N.},
+institution = {Eur. Cent. for Medium-Range Weather Forecasts,
+Reading, England},
+number = {169},
+title = {Rationale for a new physically-based parametrisation of sub-grid scale orographic effects.},
+year = {1990}
+}
+
+@article{Wu:81,
+author = {Wu, S. S. C.},
+journal = {Annales de Geophysique},
+pages = {147-160},
+title = {A method of defining topographic datums of planetary bodies},
+volume = {1},
+year = {1981}
+}
+
+@article{Phil:84,
+author = {Phillips, S. P.},
+journal = jas,
+pages = {1073-1084},
+title = {Analytical surface pressure and drag for linear hydrostatic flow over three-dimensional elliptical mountains},
+volume = {41},
+year = {1984}
+}
+
+@article{Conr:89,
+author = {{Conrath}, B. and {Flasar}, F. M. and {Hanel}, R. and {Kunde}, V. and
+{Maguire}, W. and {Pearl}, J. and {Pirraglia}, J. and {Samuelson}, R. and 
+{Gierasch}, P. and {Weir}, A. and {Bezard}
+}
+}
+
+@article{Lehn:99,
+author = { Lehning , M. and Richner , H. and Kok , G. L. and Neininger , B.},
+journal = ae,
+pages = {1353-1363},
+title = {Vertical exchange and regional budgets of air pollutants over densely populated areas},
+volume = {32},
+year = {1999}
+}
+
+@article{Menu:99a,
+author = { Menut , L. and Flamant , C. and Pelon , J. and Flamant , P. H.},
+journal = ao,
+pages = {945-954},
+title = {Urban boundary layer height determination from lidar measurements over the {Paris} area},
+volume = {38},
+year = {1999}
+}
+
+@article{Menu:99b,
+author = { Menut , L. and Flamant , C. and Pelon , J.},
+journal = blm,
+pages = {269-286},
+title = {Evidence of synoptic scale influence on the atmospheric boundary layer dynamics and turbulent processes over the Paris area},
+volume = {93},
+year = {1999}
+}
+
+@misc{Menu:00,
+author = {Menut , L. and Vautard , R. and Flamant , C. and Abonnel , C. and Beekman , M. and Chazette , P. Flamant , P. H. and Gombert , D.  and Guedalia D. and Kley , D. and Lefebvre , M. B. and Lossec , B. and Martin , D. and Megie , G. and Perros , P. and Sicard , M. and Toupance , G.},
+address = {d Martin , D. and Megie , G. and Perros , P. and Sicard , M. and Toupance , G.},
+note = {Annales Geophysicae (submitted)},
+title = {Atmospheric pollution over the Paris area: The {ESQUIF} project},
+year = {2000}
+}
+
+@article{Piel:98,
+author = {Pielke , R. A. and Uliasz , M.},
+journal = ae,
+pages = {1455-1466},
+title = {Use of meteorological models as input to
+regional and mesoscale air quality models - Limitations and strengths},
+volume = {32},
+year = {1998}
+}
+
+@article{Plei:94,
+author = {Pleim , J. E. and Xiu , A.},
+journal = jam,
+pages = {16-32},
+title = {Development and Testing of a Surface Flux and Planetary Boundary Layer Model for Application in Mesoscale Models},
+volume = {34},
+year = {1994}
+}
+
+@article{GK1,
+author = {Krinner, G. and Genthon, C.},
+journal = {Ann. Glaciol.},
+pages = {73--78},
+title = {The {A}ntarctic surface mass balance in a stretched-grid {GCM}},
+volume = {25},
+year = {1997}
+}
+
+@article{GK2,
+author = {Krinner, G. and Genthon, C. and Li, Z.-X. and Le Van, P.},
+journal = jgr,
+pages = {13731--13745},
+title = {Studies of the {A}ntarctic climate with a stretched-grid general
+circulation model},
+volume = {102},
+year = {1997}
+}
+
+@article{GK3,
+author = {Genthon, C. and Krinner, G. and D\'equ\'e, M.},
+journal = {Ann. Glaciol.},
+pages = {488--494},
+title = {Intra-annual variability of {A}ntarctic precipitation
+from weather forecasts and high resolution climate models},
+volume = {27},
+year = {1998}
+}
+
+@article{GK4,
+author = {Krinner, G. and Genthon, C. and Jouzel, J.},
+journal = grl,
+pages = {2825--2828},
+title = {{GCM} analysis of local influences on ice core $\delta$ signals},
+volume = {24},
+year = {1997}
+}
+
+@phdthesis{GK5,
+author = {Krinner, G.},
+note = {partially in French},
+pages = {209 pp.},
+school = {Universit\'e Grenoble 1},
+title = {Simulations du climat des calottes de glace},
+type = {Th\`ese de doctorat},
+year = {1997}
+}
+
+@article{GK6,
+author = {Krinner, G. and Genthon, C.},
+journal = {Clim. Dyn.},
+pages = {741--758},
+title = {{GCM} simulations of the {L}ast {G}lacial {M}aximum surface
+climate of {G}reenland and {A}ntarctica},
+volume = {14},
+year = {1998}
+}
+
+@article{GK7,
+author = {Krinner, G. and Raynaud , D. and Doutriaux , C. and Dang , H.},
+journal = jgr,
+pages = {2059--2070},
+title = {Simulations of the {L}ast {G}lacial {M}aximum ice sheet
+surface climate: {I}mplications for the interpretation of
+ice core air content},
+volume = {105},
+year = {2000}
+}
+
+@article{GK8,
+author = {Krinner, G. and Genthon, C.},
+journal = grl,
+pages = {2227--2230},
+title = {Altitude dependence of the surface climate over the ice
+sheets},
+volume = {26},
+year = {1999}
+}
+
+@article{LeTr:91,
+author = {Le Treut, H. and Li, Z. X.},
+journal = {Climate Dynamics},
+pages = {175-187},
+title = {Sensitivity of an atmospheric general circulation model to prescribed \protect{SST} changes: Feedback effects associated with the simulation of cloud optical properties.},
+volume = {5},
+year = {1991}
+}
+
+@article{Harzallah:1994,
+author = {A. Harzallah and R. Sadourny},
+journal = {J.Clim.},
+pages = {474-495},
+title = {Internal versus {SST}-forced atmospheric variability as simulated by atmospheric general circulation model},
+volume = {8},
+year = {1994}
+}
+
+@article{Toig:00,
+author = {{Toigo}, A.~D. and {Richardson}, M.~I.},
+journal = jgr,
+pages = {4109--4121},
+title = {{Seasonal variation of aerosols in the Martian atmosphere}},
+volume = {105},
+year = {2000}
+}
+
+@article{Kief:00,
+author = {{Kieffer}, H.~H. and {Titus}, T.~N. and {Mullins}, K.~F.
+and 
+{Christensen}, P.~R.},
+journal = jgr,
+pages = {9653--9700},
+title = {{Mars south polar spring and summer behavior observed by
+TES: Seasonal cap evolution controlled by frost grain size}},
+volume = {105},
+year = {2000}
+}
+
+@article{Thom:00,
+author = {{Thomas}, P.~C. and {Malin}, M.~C. and {Edgett}, K.~S. and
+{Carr}, M.~H. and 
+{Hartmann}, W.~K. and {Ingersoll}, A.~P. and {James}, P. B.},
+journal = {Nature},
+pages = {161--164},
+title = {{North-south geological differences between the residual
+polar caps on Mars}},
+volume = {404},
+year = {2000}
+}
+
+@article{Pett:00,
+author = {{Pettengill}, G.~H. and {Ford}, P.~G.},
+journal = grl,
+pages = {609--613},
+title = {{Winter Clouds over the North Martian Polar Cap}},
+volume = {27},
+year = {2000}
+}
+
+@article{Cola:00,
+author = {{Colaprete}, A. and {Toon}, O.~B.},
+journal = {Icarus},
+pages = {524--532},
+title = {{The radiative effects of martian water ice clouds on the
+local atmospheric temperature profile}},
+volume = {145},
+year = {2000}
+}
+
+@article{Toum:93,
+author = {{Touma}, J. and {Wisdom}, J.},
+journal = {Science},
+pages = {1294--1297},
+title = {{The chaotic obliquity of Mars}},
+volume = {259},
+year = {1993}
+}
+
+
+@article{Jego:00,
+author = {{Jegou}, F. and {Chassefiere}, E. and {Forget}, F. and
+{Hourdin}, F. and {Lellouch}, E. and {Encrenaz}, T. and {Moreno}, R.},
+title = "{Ground-Based Millimeter Observations of the Middle
+Atmosphere of Mars: Why Are the Retrograde Winds So Strong?}",
+booktitle = {AAS/Division of Planetary Sciences Meeting},
+year = 2000,
+volume = 32,
+pages = {5116+}
+}
+
+@ARTICLE{Misc:03,
+author = {{Mischna}, M.~A. and {Richardson}, M.~I. and {Wilson},
+R.~J. and 
+{McCleese}, D.~J.},
+title = "{On the orbital forcing of Martian water and CO$_{2}$ cycles:
+A general circulation model study with simplified volatile schemes}",
+journal = {Journal of Geophysical Research (Planets)},
+year = 2003,
+pages = {16-1},
+}
+
+
+@ARTICLE{Bert:00,
+author = {{Bertaux}, J.-L. and {Fonteyn}, D. and {Korablev}, O. and
+{Chassefi{\` e}re}, E. and 
+{Dimarellis}, E. and {Dubois}, J.~P. and {Hauchecorne}, A. and 
+{Cabane}, M. and {Rannou}, P. and {Levasseur-Regourd}, A.~C. and 
+{Cernogora}, G. and {Quemerais}, E. and {Hermans}, C. and
+{Kockarts}, G. and 
+{Lippens}, C. and {Maziere}, M.~D. and {Moreau}, D. and {Muller}, C.
+and 
+{Neefs}, B. and {Simon}, P.~C. and {Forget}, F. and {Hourdin}, F.
+and 
+{Talagrand}, O. and {Moroz}, V.~I. and {Rodin}, A. and {Sandel}, B.
+and 
+{Stern}, A.},
+title = "{The study of the martian atmosphere from top to bottom
+with SPICAM light on mars express}",
+journal = pss,
+year = 2000,
+volume = 48,
+pages = {1303-1320},
+}
+
+@INPROCEEDINGS{Chic:03,
+author = {{Chicarro}, A.~F. and {The Science Team}},
+title = "{The Mars Express Mission and Its Beagle-2 Lander}",
+booktitle = {Sixth International Conference on Mars},
+year = 2003,
+month = jul,
+pages = {3049},
+}
+
+@ARTICLE{Form:02,
+author = {{Formisano}, V. and {Grassi}, D. and {Ignatiev}, N. and
+{Zasova}, L. and 
+{Maturilli}, A.},
+title = "{PFS for Mars Express: A new approach to study Martian
+atmosphere}",
+journal = {Advances in Space Research},
+year = 2002,
+volume = 29,
+pages = {131-142},
+}
+
+@ARTICLE{Habe:03,
+author = {{Haberle}, R.~M. and {Murphy}, J.~R. and {Schaeffer}, J.},
+title = "{Orbital change experiments with a Mars general circulation
+model}",
+journal = {Icarus},
+year = 2003,
+volume = 161,
+pages = {66-89},
+}
+
+@ARTICLE{Habe:98,
+author = {{Haberle}, R.~M.},
+title = "{Early Mars climate models}",
+journal = jgr,
+year = 1998,
+volume = 103,
+pages = {28467},
+}
+
+@ARTICLE{Habe:99,
+    author = {{Haberle}, R.~M. and {Joshi}, M.~M. and {Murphy}, J.~R.
+and 
+	{Barnes}, J.~R. and {Schofield}, J.~T. and {Wilson}, G. and 
+	{Lopez-Valverde}, M. and {Hollingsworth}, J.~L. and {Bridger},
+A.~F.~C. and 
+	{Schaeffer}, J.},
+    title = "{General circulation model simulations of the Mars
+Pathfinder atmospheric structure investigation/meteorology data}",
+    journal = jgr,
+    year = 1999,
+    volume = 104,
+    pages = {8957-8974},
+}
+
+
+
+@ARTICLE{Brid:98,
+    author = {{Bridger}, A.~F.~C. and {Murphy}, J.~R.},
+    title = "{Mars' surface pressure tides and their behavior during
+global dust storms}",
+    journal = jgr,
+    year = 1998,
+    volume = 103,
+    pages = {8587-8602},
+}
+
+
+@ARTICLE{Cola:99,
+    author = {{Colaprete}, A. and {Toon}, O.~B. and {Magalh{\~ a}es},
+J.~A.
+	},
+    title = "{Cloud formation under Mars Pathfinder conditions}",
+    journal = jgr,
+    year = 1999,
+    volume = 104,
+    pages = {9043-9054},
+}
+
+@ARTICLE{Cola:03a,
+    author = {{Colaprete}, A. and {Toon}, O.~B.},
+    title = "{Carbon dioxide clouds in an early dense Martian
+atmosphere}",
+    journal = {Jour. Geophys. Res. (Planets)},
+    year = 2003,
+    pages = {6-1},
+}
+
+@ARTICLE{Cola:03b,
+    author = {{Colaprete}, A. and {Haberle}, R.~M. and {Toon}, O.~B.},
+    title = "{Formation of convective carbon dioxide clouds near the
+south pole of Mars}",
+    journal = {Jour. Geophy. Res. (Planets)},
+    year = 2003,
+    pages = {17-1},
+}
+
+@ARTICLE{Mont:02,
+    author = {{Montmessin}, F. and {Rannou}, P. and {Cabane}, M.},
+    title = "{New insights into Martian dust distribution and water-ice
+cloud microphysics}",
+    journal = {Jour. Geophys. Res. (Planets)},
+    year = 2002,
+    pages = {4-1},
+}
+
+
+
+@ARTICLE{Boyn:02,
+    author = {{Boynton}, W.~V. and {Feldman}, W.~C. and {Squyres}, S.~W.
+and 
+	{Prettyman}, T.~H. and {Br{\" u}ckner}, J. and {Evans}, L.~G. and 
+	{Reedy}, R.~C. and {Starr}, R. and {Arnold}, J.~R. and {Drake},
+D.~M. and 
+	{Englert}, P.~A.~J. and {Metzger}, A.~E. and {Mitrofanov}, I. and 
+	{Trombka}, J.~I. and {d'Uston}, C. and {W{\" a}nke}, H. and 
+	{Gasnault}, O. and {Hamara}, D.~K. and {Janes}, D.~M. and
+{Marcialis}, R.~L. and 
+	{Maurice}, S. and {Mikheeva}, I. and {Taylor}, G.~J. and {Tokar}, R.
+and 
+	{Shinohara}, C.},
+    title = "{Distribution of Hydrogen in the Near Surface of Mars:
+Evidence for Subsurface Ice Deposits}",
+    journal = {Science},
+    year = 2002,
+    volume = 297,
+    pages = {81-85},
+}
+
+@INPROCEEDINGS{Habe:00lpi,
+    author = {{Haberle}, R.~M. and {McKay}, C.~P. and {Schaeffer}, J.
+and 
+	{Joshi}, M. and {Cabrol}, N.~A. and {Grin}, E.~A.},
+    title = "{Meteorological Control on the Formation of Martian
+Paleolakes}",
+    booktitle = {Lunar and Planetary Institute Conference Abstracts},
+    year = 2000,
+    pages = {1509},
+}
+
+@INPROCEEDINGS{Bott:03,
+    author = {{Bottger}, H.~M. and {Lewis}, S. R. and {Read}, P. L.
+and {Forget}, F. },
+    title = "{{GCM simulations of the Martian water cycle} }",
+    booktitle = {Mars atmosphere modelling and observations workshop abstracts, {http://www-mars.lmd.jussieu.fr/granada2003} },
+    year = 2003,
+}
+
+
+@INPROCEEDINGS{Mont:03,
+    author = {{Montmessin}, F. and {Forget}, F. and {Haberle}, R.~M. and
+{Rannou}, P. and {Cabane}, M.},
+    title = "{Water-Ice Clouds in the LMDs Martian General Circulation
+Model}",
+    booktitle = {Sixth International Conference on Mars},
+    year = 2003,
+    pages = {3117},
+}
+
+@ARTICLE{Bibr:04,
+   author = {{Bibring}, J. and {Langevin}, Y. and {Poulet}, F. and {Gendrin}, A. and 
+	{Gondet}, B. and {Berth{\' e}}, M. and {Soufflot}, A. and {Drossart}, P. and 
+	{Combes}, M. and {Bellucci}, G. and {Moroz}, V. and {Mangold}, N. and 
+	{Schmitt}, B. and {OMEGA team}, the},
+    title = "{Perennial water ice identified in the south polar cap of Mars}",
+  journal = {Nature},
+     year = {2004},
+   volume = 428,
+    pages = {627-630},
+}
+
+@book{Sobo:75,
+author = {Sobolev , V. V.},
+publisher = {Pergamon Press},
+title = {Light scaterring in planetary atmospheres},
+year = {1975},
+}
+
+
+
+@ARTICLE{Gend:03,
+   author = {{Gendrin}, A. and {Erard}, S. and {Drossart}, P. and {Melchiorri}, R.
+	},
+    title = "{Observation of pressure variations in the Martian atmosphere}",
+  journal = grl,
+     year = 2003,
+   volume = 30,
+    pages = {A14},
+} 
+
+@article{Mass:90,
+	author = {{Mass}, C.~F. and {Ferber}, G.~K.},
+	title = "{Surface pressure perturbations produced by an isolated mesoscale
+		topographic barrier. Part I: general characteristics and dynamics}",
+	journal = mwr,
+	year = 1990,
+	volume = 118,
+	pages={2579-2595},	
+}
+
+	
+@ARTICLE{Suns:93,
+   author = {{Sunshine}, J.~M. and {Pieters}, C.~M.},
+    title = "{Estimating modal abundances from the spectra of natural and laboratory pyroxene mixtures using the modified Gaussian model}",
+  journal = jgr,
+     year = 1993,
+   volume = 98,
+    pages = {9075-9087},
+}
+
+
+@ARTICLE{Suns:98,
+   author = {{Sunshine}, J.~M. and {Pieters}, C.~M.},
+    title = "{Determining the composition of olivine from reflectance spectroscopy}",
+  journal = jgr,
+     year = 1998,
+   volume = 103,
+    pages = {13675-13688},
+ }
+
+@phdthesis{Rose:these,
+author = {Rosenqvist, Jan},
+school = {Universit\'e Paris 7},
+title = {Mars : \'etude de son atmosph\`ere par le spectro-imageur ISM},
+year = {1991}
+}
+
+
+@book{Forg:03book,
+author = {{Forget}, F. and {Costard}, F. and {Lognonn\'e}, P.},
+publisher = {Belin. Pour la science},
+title = {La plan\`ete Mars, histoire d'un autre monde},
+year = {2003}
+}
+
+@book{Forg:06book,
+author = {{Forget}, F. and {Costard}, F. and {Lognonn\'e}, P.},
+publisher = {Belin. Pour la science},
+title = {La plan\`ete Mars, histoire d'un autre monde (seconde édition
+augmentée)},
+year = {2006}
+}
+
+@ARTICLE{Titu:01,
+   author = {{Titus}, T.~N. and {Kieffer}, H.~H. and {Mullins}, K.~F. and 
+	{Christensen}, P.~R.},
+    title = "{TES premapping data: Slab ice and snow flurries in the
+Martian north polar night}",
+  journal = jgr,
+     year = 2001,
+   volume = 106,
+    pages = {23181-23196}
+}
+
+
+
+@ARTICLE{Metz:99,
+   author = {{Metzger}, S.~M. and {Carr}, J.~R. and {Johnson}, J.~R. and 
+	{Parker}, T.~J. and {Lemmon}, M.~T.},
+    title = "{Dust devil vortices seen by the Mars Pathfinder camera}",
+  journal = grl,
+     year = 1999,
+   volume = 26,
+    pages = {2781-2784},
+}
+
+
+@ARTICLE{Smit:02,
+   author = {{Smith}, M.~D. and {Conrath}, B.~J. and {Pearl}, J.~C. and
+{Christensen}, P.~R.
+	},
+    title = "{NOTE: Thermal Emission Spectrometer Observations of Martian
+Planet-Encircling Dust Storm 2001A}",
+  journal = {Icarus},
+     year = 2002,
+   volume = 157,
+    pages = {259-263},
+}
+
+@ARTICLE{Newm:02b,
+   author = {{Newman}, C.~E. and {Lewis}, S.~R. and {Read}, P.~L. and
+{Forget}, F.
+	},
+    title = "{Modeling the Martian dust cycle 2. Multiannual radiatively
+active dust transport simulations}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+    pages = {7-1},
+}
+
+@ARTICLE{Newm:02a,
+   author = {{Newman}, C.~E. and {Lewis}, S.~R. and {Read}, P.~L. and
+{Forget}, F.
+	},
+    title = "{Modeling the Martian dust cycle, 1. Representations of dust
+transport processes}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+    pages = {6-1},
+}
+
+@ARTICLE{Smit:04,
+   author = {{Smith}, M.~D.},
+    title = "{Interannual variability in TES atmospheric observations of
+Mars during 1999-2003}",
+  journal = {Icarus},
+     year = 2004,
+   volume = 167,
+    pages = {148-165},
+}
+
+@ARTICLE{Encr:04,
+   author = {{Encrenaz}, T. and {B{\' e}zard}, B. and {Greathouse},
+T.~K. and 
+	{Richter}, M.~J. and {Lacy}, J.~H. and {Atreya}, S.~K. and {Wong},
+A.~S. and 
+	{Lebonnois}, S. and {Lef{\` e}vre}, F. and {Forget}, F.},
+    title = "{Hydrogen peroxide on Mars: evidence for spatial and
+seasonal variations}",
+  journal = {Icarus},
+     year = 2004,
+   volume = 170,
+    pages = {424-429},
+}
+
+@ARTICLE{Capd:04,
+   author = {{Capderou}, M. and {Forget}, F.},
+    title = "{Optimal orbits for Mars atmosphere remote sensing}",
+  journal = pss,
+     year = 2004,
+   volume = 52,
+    pages = {789-798},
+}
+
+@ARTICLE{Ange:04,
+   author = {{Angelats i Coll}, M. and {Forget}, F. and {L{\'
+o}pez-Valverde}, M.~A. and 
+	{Read}, P.~L. and {Lewis}, S.~R.},
+    title = "{Upper atmosphere of Mars up to 120 km: Mars Global
+Surveyor accelerometer data analysis with the LMD general circulation
+model}",
+  journal = jgr,
+     year = 2004,
+    pages = {1011},
+}
+
+@ARTICLE{Forg:05reve,
+   author = {Forget, F. and {Angelats i Coll}, M.
+and Hourdin, F. and Wanherdrick, Y. and 
+{L{\'o}pez-Valverde}, M.~A. and 
+	{Read}, P.~L. and {Lewis}, S.~R.},
+    title = "{Upper atmosphere of Mars up to 120 km: 
+numerical simulation with a general circulation model
+}",
+  journal = jgr,
+     year = 2004,
+    volume = {In preparation...},
+}
+
+
+
+@ARTICLE{Lefe:04,
+   author = {Lef\`evre, S. and Lebonnois, S. and Montmessin, F.  and Forget,
+F.  },
+    title = "{Three-dimensional modeling of ozone on Mars }",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2004,
+   volume = 109,
+    pages = {E07004},
+}
+
+@ARTICLE{Vand:02,
+   author = {{Van den Acker}, E. and {Van Hoolst}, T. and {de Viron}, O.
+and 
+	{Defraigne}, P. and {Forget}, F. and {Hourdin}, F. and {Dehant}, V.
+	},
+    title = "{Influence of the seasonal winds and the CO$_{2}$ mass
+exchange between atmosphere and polar caps on Mars' rotation}",
+  journal = {Journal of Geophysical Research },
+     year = 2002,
+   volume = 107,
+    pages = {E7,9-1},
+}
+
+@ARTICLE{Levr:04,
+   author = {Levrard, B. and Forget, F. and Montmessin, F. and Laskar,
+J.
+    },
+    title = "{Formation of recent martian high-latitude ice-rich
+deposits by sublimation of unstable equatorial ice at low obliquity
+}",
+  journal = {Nature},
+     year = 2004,
+    volume = {In press},
+}
+
+
+@ARTICLE{Mont:05,
+   author = {
+Montmessin, F. and Fouchet, T. and  Forget, F. },
+    title = "{
+Modeling the annual cycle of HDO in the {Martian atmosphere}
+}",
+  journal = {Journal of Geophysical Research },
+     year = 2004,
+    volume = {Submitted},
+}
+
+@ARTICLE{Tobi:03,
+   author = {{Tobie}, G. and {Forget}, F. and {Lott}, F.},
+    title = "{Numerical simulation of the winter polar wave clouds observed by
+Mars Global Surveyor Mars Orbiter Laser Altimeter}",
+  journal = {Icarus},
+     year = 2003,
+   volume = 164,
+    pages = {33-49}
+}
+
+@INBOOK{Squy:92,
+    author = {{Squyres}, S.~W. and {Clifford}, S.~M. and {Kuz'min}, R.~O. and 
+	{Zimbelman}, J.~R. and {Costard}, F.~M.},
+    title = "{Ice in the Martian regolith}",
+publisher = {University of Arizona Press, Tucson},
+year = 1992,
+    pages = {523-554}
+}
+@ARTICLE{Lask:04,
+   author = {{Laskar}, J. and {Correia}, A.~C.~M. and {Gastineau}, M. and 
+	{Joutel}, F. and {Levrard}, B. and {Robutel}, P.},
+    title = "{Long term evolution and chaotic diffusion of the insolation
+quantities of Mars}",
+  journal = {Icarus},
+     year = 2004,
+   volume = 170,
+    pages = {343-364}
+}
+
+@INBOOK{Bake:92,
+    author = {{Baker}, V.~R. and {Carr}, M.~H. and {Gulick}, V.~C. and
+{Williams}, C.~R. and 
+	{Marley}, M.~S.},
+    title = "{Channels and valley networks}",
+publisher = {University of Arizona Press, Tucson},
+year = 1992,
+    pages = {493-522}
+}
+
+@BOOK{Carr:96,
+    author = {{Carr}, M.~H.},
+    title = "{Water on Mars}",
+publisher = {New York: Oxford University Press, |c1996},
+year = 1996
+}
+
+@ARTICLE{Crad:93,
+   author = {{Craddock}, R.~A. and {Maxwell}, T.~A.},
+    title = "{Geomorphic evolution of the Martian highlands through ancient
+fluvial processes}",
+  journal = jgr,
+     year = 1993,
+   volume = 98,
+    pages = {3453-3468},
+}
+
+@ARTICLE{Lask:02,
+   author = {{Laskar}, J. and {Levrard}, B. and {Mustard}, J.~F.},
+    title = "{Orbital forcing of the martian polar layered deposits}",
+  journal = {Nature},
+     year = 2002,
+   volume = 419,
+    pages = {375-377},
+}
+
+@ARTICLE{Clif:00,
+   author = {{Clifford}, S.~M. and {Crisp}, D. and {Fisher}, D.~A. and
+{Herkenhoff}, K.~E. and 
+	{Smrekar}, S.~E. and {Thomas}, P.~C. and {Wynn-Williams}, D.~D. and 
+	{Zurek}, R.~W. and {Barnes}, J.~R. and {Bills}, B.~G. and {Blake}, E.~W.
+and 
+	{Calvin}, W.~M. and {Cameron}, J.~M. and {Carr}, M.~H. and {Christensen},
+P.~R. and 
+	{Clark}, B.~C. and {Clow}, G.~D. and {Cutts}, J.~A. and {Dahl-Jensen}, D.
+and 
+	{Durham}, W.~B. and {Fanale}, F.~P. and {Farmer}, J.~D. and 
+	{Forget}, F. and {Gotto-Azuma}, K. and {Grard}, R. and {Haberle}, R.~M. and
+
+	{Harrison}, W. and {Harvey}, R. and {Howard}, A.~D. and {Ingersoll}, A.~P.
+and 
+	{James}, P.~B. and {Kargel}, J.~S. and {Kieffer}, H.~H. and 
+	{Larsen}, J. and {Lepper}, K. and {Malin}, M.~C. and {McCleese}, D.~J. and
+	{Murray}, B. and {Nye}, J.~F. and {Paige}, D.~A. and {Platt}, S.~R. and 
+	{Plaut}, J.~J. and {Reeh}, N. and {Rice}, J.~W. and {Smith}, D.~E. and 
+	{Stoker}, C.~R. and {Tanaka}, K.~L. and {Mosley-Thompson}, E. and 
+	{Thorsteinsson}, T. and {Wood}, S.~E. and {Zent}, A. and {Zuber}, M.~T. and
+	{Zwally}, H.~J.},
+    title = "{The State and Future of Mars Polar Science and Exploration}",
+  journal = {Icarus},
+     year = 2000,
+   volume = 144,
+    pages = {210-242}
+}
+
+@ARTICLE{Smit:01mola,
+   author = {{Smith}, D.~E. and {Zuber}, M.~T. and {Frey}, H.~V. and {Garvin},
+J.~B. and 
+	{Head}, J.~W. and {Muhleman}, D.~O. and {Pettengill}, G.~H. and 
+	{Phillips}, R.~J. and {Solomon}, S.~C. and {Zwally}, H.~J. and 
+	{Banerdt}, W.~B. and {Duxbury}, T.~C. and {Golombek}, M.~P. and 
+	{Lemoine}, F.~G. and {Neumann}, G.~A. and {Rowlands}, D.~D. and 
+	{Aharonson}, O. and {Ford}, P.~G. and {Ivanov}, A.~B. and {Johnson}, C.~L.
+and 
+	{McGovern}, P.~J. and {Abshire}, J.~B. and {Afzal}, R.~S. and 
+	{Sun}, X.},
+    title = "{Mars Orbiter Laser Altimeter: Experiment summary after the first
+year of global mapping of Mars}",
+  journal = jgr,
+     year = 2001,
+volume=106,
+    pages = {23689-23722},
+}
+
+@ARTICLE{Mitr:02,
+   author = {{Mitrofanov}, I. and {Anfimov}, D. and {Kozyrev}, A. and {Litvak},
+M. and 
+	{Sanin}, A. and {Tret'yakov}, V. and {Krylov}, A. and {Shvetsov}, V. and 
+	{Boynton}, W. and {Shinohara}, C. and {Hamara}, D. and {Saunders}, R.~S.
+	},
+    title = "{Maps of Subsurface Hydrogen from the High Energy Neutron
+Detector, Mars Odyssey}",
+  journal = {Science},
+     year = 2002,
+   volume = 297,
+    pages = {78-81},
+}
+
+@ARTICLE{Feld:02,
+   author = {{Feldman}, W.~C. and {Boynton}, W.~V. and {Tokar}, R.~L. and 
+	{Prettyman}, T.~H. and {Gasnault}, O. and {Squyres}, S.~W. and 
+	{Elphic}, R.~C. and {Lawrence}, D.~J. and {Lawson}, S.~L. and 
+	{Maurice}, S. and {McKinney}, G.~W. and {Moore}, K.~R. and {Reedy}, R.~C.
+	},
+    title = "{Global Distribution of Neutrons from Mars: Results from Mars
+Odyssey}",
+  journal = {Science},
+     year = 2002,
+   volume = 297,
+    pages = {75-78},
+}
+
+@ARTICLE{Head:03,
+   author = {{Head}, J.~W. and {Mustard}, J.~F. and {Kreslavsky}, M.~A. and 
+	{Milliken}, R.~E. and {Marchant}, D.~R.},
+    title = "{Recent ice ages on Mars}",
+  journal = {Nature},
+     year = 2003,
+   volume = 426,
+    pages = {797-802},
+}
+
+@ARTICLE{Habe:01,
+   author = {{Haberle}, R.~M. and {McKay}, C.~P. and {Schaeffer}, J. and 
+	{Cabrol}, N.~A. and {Grin}, E.~A. and {Zent}, A.~P. and {Quinn}, R.
+	},
+    title = "{On the possibility of liquid water on present-day Mars}",
+  journal = jgr,
+     year = 2001,
+    pages = {23317-23326},
+}
+
+@ARTICLE{Hech:02,
+   author = {{Hecht}, M.~H.},
+    title = "{Metastability of Liquid Water on Mars}",
+  journal = {Icarus},
+     year = 2002,
+   volume = 156,
+    pages = {373-386},
+}
+
+@ARTICLE{Head:03nat,
+   author = {{Head}, J.~W. and {Mustard}, J.~F. and {Kreslavsky}, M.~A. and 
+	{Milliken}, R.~E. and {Marchant}, D.~R.},
+    title = "{Recent ice ages on Mars}",
+  journal = {Nature},
+     year = 2003,
+   volume = 426,
+    pages = {797-802},
+}
+
+@ARTICLE{Mali:00gul,
+   author = {{Malin}, M.~C. and {Edgett}, K.~S.},
+    title = "{Evidence for Recent Groundwater Seepage and Surface Runoff on
+Mars}",
+  journal = {Science},
+     year = 2000,
+   volume = 288,
+    pages = {2330-2335},
+}
+
+
+@ARTICLE{Mali:00lay,
+author = {{Malin}, M.~C. and {Edgett}, K.~S.},
+    title = "{Sedimentary Rocks of Early Mars}",
+  journal = {Science},
+     year = 2000,
+   volume = 290,
+    pages = {1927-1937},
+
+}
+
+@ARTICLE{Mali:03,
+author = {{Malin}, M.~C. and {Edgett}, K.~S.},
+    title = "{Evidence for Persistent Flow and Aqueous Sedimentation on Early
+Mars}",
+  journal = {Science},
+     year = 2003,
+   volume = 302,
+    pages = {1931-1934},
+}
+
+@ARTICLE{Cost:02,
+   author = {{Costard}, F. and {Forget}, F. and {Mangold}, N. and {Peulvast},
+J.~P.
+	},
+    title = "{Formation of Recent Martian Debris Flows by Melting of
+Near-Surface Ground Ice at High Obliquity}",
+  journal = {Science},
+     year = 2002,
+   volume = 295,
+    pages = {110-113},
+}
+
+@ARTICLE{Mang:03dune,
+   author = {{Mangold}, N. and {Costard}, F. and {Forget}, F.},
+    title = "{Debris flows over sand dunes on Mars: Evidence for liquid
+water}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {8-1},
+}
+
+@ARTICLE{Mang:04,
+   author = {{Mangold}, N. and {Quantin}, C. and {Ansan}, V. and {Delacourt},
+C. and 
+	{Allemand}, P.},
+    title = "{Evidence for Precipitation on Mars from Dendritic Valleys in the
+Valles Marineris Area}",
+  journal = {Science},
+     year = 2004,
+   volume = 305,
+    pages = {78-81},
+}
+
+@ARTICLE{Crad:02,
+   author = {{Craddock}, R.~A. and {Howard}, A.~D.},
+    title = "{The case for rainfall on a warm, wet early Mars}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+    pages = {21-1},
+}
+
+@ARTICLE{Chri:01,
+   author = {{Christensen}, P.~R. and {Bandfield}, J.~L. and {Hamilton}, V.~E.
+and 
+	{Ruff}, S.~W. and {Kieffer}, H.~H. and {Titus}, T.~N. and {Malin}, M.~C.
+and 
+	{Morris}, R.~V. and {Lane}, M.~D. and {Clark}, R.~L. and {Jakosky}, B.~M.
+and 
+	{Mellon}, M.~T. and {Pearl}, J.~C. and {Conrath}, B.~J. and 
+	{Smith}, M.~D. and {Clancy}, R.~T. and {Kuzmin}, R.~O. and {Roush}, T. and
+	{Mehall}, G.~L. and {Gorelick}, N. and {Bender}, K. and {Murray}, K. and 
+	{Dason}, S. and {Greene}, E. and {Silverman}, S. and {Greenfield}, M.
+	},
+    title = "{Mars Global Surveyor Thermal Emission Spectrometer experiment:
+Investigation description and surface science results}",
+  journal = jgr,
+     year = 2001,
+   volume = 111,
+    pages = {23823-23872},
+}
+
+@ARTICLE{Segu:02,
+   author = {{Segura}, T.~L. and {Toon}, O.~B. and {Colaprete}, A. and
+{Zahnle}, K.
+	},
+    title = "{Environmental Effects of Large Impacts on Mars}",
+  journal = {Science},
+     year = 2002,
+   volume = 298,
+    pages = {1977-1980},
+}
+
+
+@ARTICLE{Mont:04jgr,
+   author = {{Montmessin}, F. and {Forget}, F. and {Rannou}, P. and
+{Cabane}, M. and 
+	{Haberle}, R.~M.},
+    title = "{Origin and role of water ice clouds in the Martian water
+cycle as inferred from a general circulation model}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2004,
+   volume = 109,
+   number = "E18",
+    pages = {10004},
+}
+
+@ARTICLE{Shea:05,
+   author = {{Shean}, D.~E. and {Head}, J.~W. and {Marchant}, D.~R.},
+    title = "{Origin and evolution of a cold-based tropical mountain
+glacier on Mars: The Pavonis Mons fan-shaped deposit}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {5001},
+}
+
+@ARTICLE{Haub:05,
+   author = {{Hauber}, E. and {van Gasselt}, S. and {Ivanov}, B. and
+{Werner}, S. and 
+	{Head}, J.~W. and {Neukum}, G. and {Jaumann}, R. and {Greeley}, R.
+and 
+	{Mitchell}, K.~L. and {Muller}, P. and {Co-Investigator Team}, T.~H.
+	},
+    title = "{Discovery of a flank caldera and very young glacial
+activity at Hecates Tholus, Mars}",
+  journal = {Nature},
+     year = 2005,
+   volume = 434,
+    pages = {356-361},
+}
+
+
+@ARTICLE{Head:05,
+   author = {{Head}, J.~W. and {Neukum}, G. and {Jaumann}, R. and
+{Hiesinger}, H. and 
+	{Hauber}, E. and {Carr}, M. and {Masson}, P. and {Foing}, B. and 
+	{Hoffmann}, H. and {Kreslavsky}, M. and {Werner}, S. and {Milkovich},
+S. and 
+	{van Gasselt}, S. and {Co-Investigator Team}, T.~H.},
+    title = "{Tropical to mid-latitude snow and ice accumulation, flow
+and glaciation on Mars}",
+  journal = {Nature},
+     year = 2005,
+   volume = 434,
+    pages = {346-351},
+}
+
+
+
+@ARTICLE{Squy:79,
+   author = {{Squyres}, S.~W.},
+    title = "{The distribution of lobate debris aprons and similar flows
+on Mars}",
+  journal = jgr,
+     year = 1979,
+   volume = 84,
+    pages = {8087-8096},
+}
+
+@ARTICLE{Lucc:84,
+   author = {{Lucchitta}, B.~K.},
+    title = "{Ice and debris in the fretted terrain, Mars}",
+  journal = {Journal of Geophysical Research Supplement},
+     year = 1984,
+   volume = 89,
+    pages = {409},
+}
+
+@ARTICLE{Lucc:81,
+   author = {{Lucchitta}, B.~K.},
+    title = "{Mars and earth - Comparison of cold-climate features}",
+  journal = {Icarus},
+     year = 1981,
+   volume = 45,
+    pages = {264-303},
+}
+
+@ARTICLE{Mill:03,
+   author = {{Milliken}, R.~E. and {Mustard}, J.~F. and {Goldsby},
+D.~L.},
+    title = "{Viscous flow features on the surface of Mars: Observations
+from high-resolution Mars Orbiter Camera (MOC) images}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+   number = "E6",
+    pages = {11-1},
+}
+
+@ARTICLE{Marq:04,
+   author = {{M{\' a}rquez}, {\' A}. and {Fern{\' a}ndez}, C. and
+{Anguita}, F. and 
+	{Farelo}, A. and {Anguita}, J. and {de La Casa}, M.},
+    title = "{New evidence for a volcanically, tectonically, and
+climatically active Mars}",
+  journal = {Icarus},
+     year = 2004,
+   volume = 172,
+    pages = {573-581},
+}
+
+@ARTICLE{Arfs:05,
+   author = {{Arfstrom}, J. and {Hartmann}, W.~K.},
+    title = "{Martian flow features, moraine-like ridges, and gullies:
+Terrestrial analogs and interrelationships}",
+  journal = {Icarus},
+     year = 2005,
+   volume = 174,
+    pages = {321-335},
+}
+
+@ARTICLE{Hart:03,
+   author = {{Hartmann}, W.~K. and {Thorsteinsson}, T. and {Sigurdsson},
+F.
+	},
+    title = "{Martian hillside gullies and icelandic analogs}",
+  journal = {Icarus},
+     year = 2003,
+   volume = 162,
+    pages = {259-277},
+}
+
+@ARTICLE{Chri:03,
+   author = {{Christensen}, P.~R.},
+    title = "{Formation of recent martian gullies through melting of
+extensive water-rich snow deposits}",
+  journal = {Nature},
+     year = 2003,
+   volume = 422,
+    pages = {45-48},
+}
+
+@ARTICLE{Mang:03aprons,
+   author = {{Mangold}, N.},
+    title = "{Geomorphic analysis of lobate debris aprons on Mars at Mars
+Orbiter Camera scale: Evidence for ice sublimation initiated by
+fractures}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+   number = "E4",
+    pages = {2-1},
+}
+
+@ARTICLE{Jako:85nat,
+   author = {{Jakosky}, B.~M. and {Carr}, M.~H.},
+    title = "{Possible precipitation of ice at low latitudes of Mars
+during periods of high obliquity}",
+  journal = {Nature},
+     year = 1985,
+   volume = 315,
+    pages = {559-561},
+}
+
+@ARTICLE{Head:03geo,
+   author = {Head, J. W. and Marchant, D. R.}, 
+    title = "{
+Cold-based mountain glaciers on Mars: western Arsia Mons.
+}",
+  journal = {Geology},
+     year = 2003,
+   volume = 31,
+    pages = {641-644},
+}
+
+@ARTICLE{Mont:04,
+   author = {{Montmessin}, F. and {Forget}, F. and {Rannou}, P. and
+{Cabane}, M. and 
+	{Haberle}, R.~M.},
+    title = "{Origin and role of water ice clouds in the Martian water
+cycle as inferred from a general circulation model}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2004,
+   volume = 109,
+   number = "E18",
+    pages = {10004},
+}
+
+@ARTICLE{Rich:02,
+   author = {{Richardson}, M.~I. and {Wilson}, R.~J.},
+    title = "{Investigation of the nature and stability of the Martian
+seasonal water cycle with a general circulation model}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+   number = "E5",
+    pages = {7-1},
+}
+
+
+@ARTICLE{Clan:03,
+   author = {{Clancy}, R.~T. and {Wolff}, M.~J. and {Christensen},
+P.~R.},
+    title = "{Mars aerosol studies with the MGS TES emission phase
+function observations: Optical depths, particle sizes, and ice cloud
+types versus latitude and solar longitude}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+   number = {E9},
+    pages = {2-1},
+}
+
+@ARTICLE{Newm:05,
+   author = {{Newman}, C.~E. and {Lewis}, S.~R. and {Read}, P.~L.},
+    title = "{The atmospheric circulation and dust activity in different
+orbital epochs on Mars}",
+  journal = {Icarus},
+     year = 2005,
+   volume = 174,
+    pages = {135-160},
+}
+
+@ARTICLE{Misc:05,
+   author = {{Mischna}, M.~A. and {Richardson}, M.~I.},
+    title = "{A reanalysis of water abundances in the Martian atmosphere
+at high obliquity}",
+  journal = grl,
+     year = 2005,
+   volume = 32,
+    pages = {3201},
+}
+
+
+@INPROCEEDINGS{Mont:04lpi,
+   author = {{Montmessin}, F. and {Haberle}, R.~M. and {Forget}, F.},
+    title = "{Making Water Ice Permanent at the South Pole 25000 Years
+Ago}",
+booktitle = {Lunar and Planetary Institute Conference Abstracts},
+     year = 2004,
+    pages = {1312},
+}
+
+@INPROCEEDINGS{Chap:05,
+   author = {{Chapman}, M.~G. and {Soderblom}, L.~A. and {Cushing}, G.},
+    title = "{Evidence of Very Young Glacial Processes in Central Candor
+Chasma, Mars}",
+booktitle = {36th Annual Lunar and Planetary Science Conference},
+     year = 2005,
+    pages = {1850},
+}
+
+@INPROCEEDINGS{Fast:05,
+   author = {{Fastook}, J.~L. and {Head}, J.~W. and {Marchant}, D.~R. and
+	{Shean}, D.~E.},
+    title = "{Ice Sheet Modeling: Mass Balance Relationships for
+Map-Plane Ice Sheet Reconstruction: Application to Tharsis Montes
+Glaciation}",
+booktitle = {36th Annual Lunar and Planetary Science Conference},
+     year = 2005,
+    pages = {1212},
+}
+
+rt
+
+@ARTICLE{Neuk:04,
+   author = {{Neukum}, G. and {Jaumann}, R. and {Hoffmann}, H. and {Hauber}, E. and 
+	{Head}, J.~W. and {Basilevsky}, A.~T. and {Ivanov}, B.~A. and 
+	{Werner}, S.~C. and {van Gasselt}, S. and {Murray}, J.~B. and 
+	{McCord}, T. and {HRSC Co-Investigator Team}, T.},
+    title = "{Recent and episodic volcanic and glacial activity on Mars revealed by the High Resolution Stereo Camera}",
+  journal = {Nature},
+     year = 2004,
+   volume = 432,
+    pages = {971-979},
+      doi = {10.1038/nature03231},
+}
+
+@ARTICLE{Pier:03,
+   author = {{Pierce}, T.~L. and {Crown}, D.~A.},
+    title = "{Morphologic and topographic analyses of debris aprons in
+the eastern Hellas region, Mars}",
+  journal = {Icarus},
+     year = 2003,
+   volume = 163,
+    pages = {46-65},
+}
+
+@INPROCEEDINGS{Milk:03,
+   author = {{Milkovich}, S.~M. and {Head}, J.~W.},
+    title = "{Olympus Mons Fan Shaped Deposit Morphology: Evidence for
+Debris Glaciers}",
+booktitle = {Sixth International Conference on Mars},
+     year = 2003,
+    pages = {3149},
+}
+
+@ARTICLE{Rafk:01,
+   author = {{Rafkin}, S.~C.~R. and {Haberle}, R.~M. and {Michaels}, T.~I.
+	},
+    title = "{The Mars Regional Atmospheric Modeling System: Model Description and
+Selected Simulations}",
+  journal = {Icarus},
+     year = 2001,
+   volume = 151,
+    pages = {228-256},
+}
+
+
+@ARTICLE{Tyle:02,
+   author = {{Tyler}, D. and {Barnes}, J.~R. and {Haberle}, R.~M.},
+    title = "{Simulation of surface meteorology at the Pathfinder and VL1 sites using
+a Mars mesoscale model}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+   number = {E4},
+    pages = {5018},
+}
+
+@ARTICLE{Toig:02,
+   author = {{Toigo}, A.~D. and {Richardson}, M.~I.},
+    title = "{A mesoscale model for the Martian atmosphere}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+   number = {E12},
+    pages = {5049},
+      doi = {10.1029/2000JE001489},
+}
+
+@ARTICLE{Stam:88,
+ author = {{Stamnes}, K. and {Tsay}, S.-C. and {Jayaweera}, K.  and
+		 {Wiscombe}, W.},
+title = "{Numerically stable algorithm for
+				   discrete-ordinate-method radiative transfer in
+					   multiple scattering and emitting layered media}",
+journal = {Applied Optics},
+year = 1988,
+volume = 27,
+pages = {2502-2509},
+}
+
+@ARTICLE{Evan:98,
+  author = {{Evans}, K.~F.},
+  title = "{The Spherical Harmonics Discrete Ordinate
+		   Method for Three-Dimensional Atmospheric
+		   Radiative Transfer.}",
+  journal = {Journal of Atmospheric Sciences},
+  year = 1998,
+  volume = 55,
+  pages = {429-446},
+}
+
+@ARTICLE{Melc:06,
+   author = {{Melchiorri}, R. and {Drossart}, P. and {Fouchet}, T. and {B{\'e}zard}, B. and 
+	{Forget}, F. and {Gendrin}, A. and {Bibring}, J.~P. and {Manaud}, N. and 
+	{OMEGA Team}},
+    title = "{A simulation of the OMEGA/Mars Express observations: Analysis of the atmospheric
+contribution}",
+  journal = pss,
+     year = 2006,
+   volume = 54,
+    pages = {774-783},
+      doi = {10.1016/j.pss.2006.04.014},
+}
+
+@ARTICLE{Bibr:05,
+   author = {{Bibring}, J.-P. and {Langevin}, Y. and {Gendrin}, A. and {Gondet}, B. and 
+	{Poulet}, F. and {Berth{\'e}}, M. and {Soufflot}, A. and {Arvidson}, R. and 
+	{Mangold}, N. and {Mustard}, J. and {Drossart}, P.},
+    title = "{Mars Surface Diversity as Revealed by the OMEGA/Mars Express Observations}",
+  journal = {Science},
+     year = 2005,
+   volume = 307,
+    pages = {1576-1581},
+      doi = {10.1126/science.1108806},
+}
+
+@ARTICLE{Erar:94,
+   author = {{Erard}, S. and {Mustard}, J. and {Murchie}, S. and {Bibring}, J.-P. and 
+	{Cerroni}, P. and {Caradini}, A.},
+    title = "{Martian aerosols: Near-infrared spectral properties and effects on the observation of the
+surface}",
+  journal = {Icarus},
+     year = 1994,
+   volume = 111,
+    pages = {317-337},
+      doi = {10.1006/icar.1994.1148},
+}
+
+@ARTICLE{Tito:00,
+   author = {{Titov}, D.~V. and {Fedorova}, A.~A. and {Haus}, R.},
+    title = "{A new method of remote sounding of the Martian aerosols by means of spectroscopy in the
+2.7 {$\mu$}m CO$_{2}$ band}",
+  journal = pss,
+     year = 2000,
+   volume = 48,
+    pages = {67-74},
+}
+
+@ARTICLE{Hins:04,
+   author = {{Hinson}, D.~P. and {Smith}, M.~D. and {Conrath}, B.~J.},
+    title = "{Comparison of atmospheric temperatures obtained through infrared sounding and
+radio occultation by Mars Global Surveyor}",
+  journal = jgr,
+     year = 2004,
+   volume = 109,
+   number = {E18},
+    pages = {12002},
+      doi = {10.1029/2004JE002344},
+}
+
+@ARTICLE{Gras:05,
+   author = {{Grassi}, D. and {Fiorenza}, C. and {Zasova}, L.~V. and
+{Ignatiev}, N.~I. and 
+	{Maturilli}, A. and {Formisano}, V. and {Giuranna}, M.},
+    title = "{The Martian atmosphere above great volcanoes: Early
+planetary Fourier spectrometer observations}",
+  journal = pss,
+     year = 2005,
+   volume = 53,
+    pages = {1053-1064},
+      doi = {10.1016/j.pss.2005.02.008},
+}
+
+@ARTICLE{Gras:07,
+   author = {{Grassi}, D. and {Formisano}, V. and {Forget}, F.
+and {Fiorenza}, C. and {Ignatiev}, N.~I. and {Maturilli}, A. and 
+{Zasova}, L.~V.},
+    title = "{The martian atmosphere in the region of Hellas basin as
+	observed by the planetary Fourier spectrometer (PFS-MEX)}",
+  journal = pss,
+     year = 2007,
+	 volume = 55,
+	 pages = {1346-1357},
+		       doi = {10.1016/j.pss.2006.12.006},
+}
+
+@INPROCEEDINGS{Paet:06gra,
+   author = {{P{\"a}tzold}, M. and {Tellmann}, S. and {H{\"a}usler}, B.
+and 
+	{Hinson}, D. and {Tyler}, G.~L.},
+    title = "{Radio-sounding of the neutral martian atmosphere with Mars
+Express: overview of the observations}",
+booktitle = {Mars Atmosphere Modelling and Observations},
+     year = 2006,
+    pages = {132},
+   editor = {Forget et al.},
+}
+
+
+
+@INPROCEEDINGS{Keat:03,
+   author = {{Keating}, G.~M. and {Theriot}, Jr., M. and {Tolson}, R. and
+	{Bougher}, S. and {Forget}, F. and {Forbes}, J.},
+    title = "{Global Measurements of the Mars Upper Atmosphere: In Situ
+Accelerometer Measurements from Mars Odyssey 2001 and Mars Global
+Surveyor}",
+booktitle = {Lunar and Planetary Institute Conference Abstracts},
+     year = 2003,
+   editor = {{Mackwell}, S. and {Stansbery}, E.},
+    pages = {1142},
+}
+
+@ARTICLE{Forb:02,
+   author = {{Forbes}, J.~M. and {Bridger}, A.~F.~C. and {Bougher}, S.~W.
+and 
+	{Hagan}, M.~E. and {Hollingsworth}, J.~L. and {Keating}, G.~M. and 
+	{Murphy}, J.},
+    title = "{Nonmigrating tides in the thermosphere of Mars}",
+  journal = jgr,
+     year = 2002,
+   volume = 107,
+    pages = {23-1},
+      doi = {10.1029/2001JE001582},
+}
+
+
+ 
+@INPROCEEDINGS{Forg:06mcd,
+   author = {{Forget}, F. and {Millour}, E. and {Lebonnois}, S. and {Montabone}, L. and
+   	{Dassas}, K. and {Lewis}, S.~R. and {Read}, P.~L. and {L{\'o}pez-Valverde}, M.~A. and
+	{Gonz{\'a}lez-Galindo}, F. and {Montmessin}, F. and {Lef{\`e}vre}, F. and
+	{Desjean}, M.-C. and {Huot}, J.-P.},
+   title = "{The new Mars climate database}",
+   booktitle = {Mars Atmosphere Modelling and Observations},
+   year = 2006,
+   editor = {{Forget et al.}},
+    pages = {625},
+   adsurl = {http://adsabs.harvard.edu/abs/2006mamo.conf..625G},
+}
+
+
+
+@ARTICLE{Must:05,
+   author = {{Mustard}, J.~F. and {Poulet}, F. and {Gendrin}, A. and {Bibring}, J.-P. and
+  	{Langevin}, Y. and {Gondet}, B. and {Mangold}, N. and {Bellucci}, G. and
+	{Altieri}, F.},
+   title = "{Olivine and Pyroxene Diversity in the Crust of Mars}",
+   journal = sci,
+   year = 2005,
+   volume = 307,
+   pages = {1594-1597},
+   doi = {10.1126/science.1109098},
+}
+
+@ARTICLE{Bell:06,
+   author = {{Bellucci}, G. and {Altieri}, F. and {Bibring}, J.~P. and {Bonello}, G. and
+   	{Langevin}, Y. and {Gondet}, B. and {Poulet}, F.},
+   title = "{OMEGA/Mars Express: Visual channel performances and data reduction techniques}",
+   journal = pss,
+   year = 2006,
+   volume = 54,
+   pages = {675-684},
+   doi = {10.1016/j.pss.2006.03.006},
+}
+
+@INPROCEEDINGS{Gond:06,
+   author = {{Gondet}, B. and {Bibring}, J.-P. and {Langevin}, Y. and {Poulet}, F. and
+   	{Montmessin}, F. and {Forget}, F.},
+   title = "{One martian year observation of H2O ice clouds By OMEGA/Mars Express}",
+   booktitle = {Mars Atmosphere Modelling and Observations},
+   year = 2006,
+   pages = {251},
+   editor = {{Forget et al.}},
+   adsurl = {http://adsabs.harvard.edu/abs/2006mamo.conf..625G},
+}
+
+@ARTICLE{Lang:05,
+   author = {{Langevin}, Y. and {Poulet}, F. and {Bibring}, J.-P. and {Schmitt}, B. and
+   	{Dout{\'e}}, S. and {Gondet}, B.},
+   title = "{Summer Evolution of the North Polar Cap of Mars as Observed by OMEGA/Mars Express}",
+   journal = sci,
+   year = 2005,
+   volume = 307,
+   pages = {1581-1584},
+   doi = {10.1126/science.1109438},
+}
+
+
+@ARTICLE{Bibr:06,
+   author = {{Bibring}, J.-P. and {Langevin}, Y. and {Mustard}, J.~F. and
+   	{Poulet}, F. and {Arvidson}, R. and {Gendrin}, A. and {Gondet}, B. and
+        {Mangold}, N. and {Pinet}, P. and {Forget}, F.},
+   title = "{Global Mineralogical and Aqueous Mars History Derived from OMEGA/Mars Express Data}",
+   journal = sci,
+   year = 2006,
+   volume = 312,
+   pages = {400-404},
+   doi = {10.1126/science.1122659},
+}
+
+@INBOOK{Bibr:04doc,
+   author = {{Bibring}, J.-P. and {Soufflot}, A. and {Berth{\'e}}, M. and 
+   	{Langevin}, Y. and {Gondet}, B. and {Drossart}, P. and {Bouy{\'e}}, M. and 
+	{Combes}, M. and {Puget}, P. and {Semery}, A. and {Bellucci}, G. and 
+	{Formisano}, V. and {Moroz}, V. and {Kottsov}, V. and {Bonello}, G. and 
+	{Erard}, S. and {Forni}, O. and {Gendrin}, A. and {Manaud}, N. and 
+	{Poulet}, F. and {Poulleau}, G. and {Encrenaz}, T. and {Fouchet}, T. and 
+	{Melchiori}, R. and {Altieri}, F. and {Ignatiev}, N. and {Titov}, D. and 
+	{Zasova}, L. and {Coradini}, A. and {Capacionni}, F. and {Cerroni}, P. and 
+	{Fonti}, S. and {Mangold}, N. and {Pinet}, P. and {Schmitt}, B. and 
+	{Sotin}, C. and {Hauber}, E. and {Hoffmann}, H. and {Jaumann}, R. and 
+	{Keller}, U. and {Arvidson}, R. and {Mustard}, J. and {Forget}, F.},
+   title = "{OMEGA: Observatoire pour la Min{\'e}ralogie, l'Eau, les Glaces et l'Activit{\'e}}",
+   publisher = {ESA SP-1240: Mars Express: the Scientific Payload},
+   year = 2004,
+   pages = {37-49},
+}
+
+@misc{Lang:05doc,
+	author = {Langevin, Y.},
+	title = {\protect{OMEGA} software documentation version 3},
+	year = {2005}
+}
+
+@ARTICLE{Wang:02,
+   author = {{Wang}, H. and {Ingersoll}, A.~P.},
+   title = "{Martian clouds observed by Mars Global Surveyor Mars Orbiter Camera}",
+   journal = jgr,
+   year = 2002,
+   volume = 107,
+   pages = {5078-+},
+   doi = {10.1029/2001JE001815},
+}
+
+
+@book{Read:04,
+    author = {{Read}, P.~L. and {Lewis}, S.~R.},
+    publisher = {Springer/Praxis Publishing},
+    title = {The Martian climate revisited: Atmosphere and Environment of a desert planet},
+    year = {2004},
+    adress = "Berlin \ Heidelberg \ New York"
+}
+
+@ARTICLE{Crea:06,
+   author = {{Creasey}, J.~E. and {Forbes}, J.~M. and {Hinson}, D.~P.},
+   title = "{Global and seasonal distribution of gravity wave activity in Mars' lower atmosphere derived from MGS radio occultation data}",
+   journal = grl,
+   year = 2006,
+   volume = 33,
+   pages = {1803},
+  doi = {10.1029/2005GL024037},
+}
+
+@ARTICLE{Vinc:00,
+   author = {{Vincent}, R.~A. and {Alexander}, M.~J.},
+   title = "{Gravity waves in the tropical lower stratosphere: An observational study of seasonal and interannual variability}",
+   journal = jgr,
+   year = 2000,
+   volume = 105,
+   number = 14,
+   pages = {17971-17982},
+   doi = {10.1029/2000JD900196},
+}
+
+@ARTICLE{Plou:03,
+   author = {{Plougonven}, R. and {Teitelbaum}, H. and {Zeitlin}, V.},
+   title = "{Inertia gravity wave generation by the tropospheric midlatitude jet as given by the Fronts and Atlantic 
+	   Storm-Track Experiment radio soundings}",
+   journal = jgr,
+   year = 2003,
+   volume = 108,
+   number = 21,
+   pages = {4686-4704},
+   doi = {10.1029/2003JD003535},
+}
+
+
+@INPROCEEDINGS{Tyle:06,
+   author = {{Tyler}, Jr., D. and {Barnes}, J.~R. and {Skyllingstad}, E.},
+   title = "{A New Large Eddy Simulation Model to Study the Convective Planetary Boundary Layer On Mars}",
+   booktitle = {Mars Atmosphere Modelling and Observations},
+   year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean}, M.~C. and 
+      	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis}, S.~R. and 
+	{Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+   pages = {124},
+}
+
+@ARTICLE{Koff:98,
+   author = {{Koffi}, E. and {B{\'e}nech}, B. and {Stein}, J. and {Terliuc}, B.
+	},
+    title = "{Dynamic Characteristics of Regional Flows around the Pyr{\'e}n{\'e}es in View of the PYREX Experiment. Part II: Solution of a Linear Model Compared to Field Measurements.}",
+  journal = jam,
+    year = 1998,
+    volume = 37,
+    pages = {53-71},
+}
+
+@ARTICLE{Youn:02,
+   author = {{Young}, G.~S. and {Kristovich}, D.~A.~R. and {Hjelmfelt}, M.~R. and
+           {Foster}, R.~C.},
+   title = "{Rolls, Streets, Waves, and More: A Review of Quasi-Two-Dimensional Structures in the Atmospheric Boundary Layer.}",
+   journal = bams,
+   year = 2002,
+   volume = 83,
+   pages = {997-1001},
+}
+
+@ARTICLE{Smit:80,
+   author = {{Smith}, R.~B.},
+    title = "{Linear theory of stratified hydrostatic flow past an isolated mountain}",
+  journal = {Tellus},
+     year = 1980,
+   volume = 32,
+    pages = {348},
+}
+
+@misc{Skam:05,
+	author = {{Skamarock}, W.~C. and  {Klemp}, J.~B. and  {Dudhia}, J. and 
+		{Gill}, D.~O. and {Barker}, D.~M. and {Wang}, W. and {Powers}, J.~G.},
+  	title = "{A description of the Advanced Research \protect{WRF}, version 2.}",
+    	journal = {National Center for Atmospheric Research Technical Note},
+	year = 2005,
+        pages = {468+STR},
+}
+
+@book{Goss:75,
+	author = {{Gossard}, E.~E. and {Hooke}, W.~H.},
+        edition = {first},
+        publisher = {Elsevier Scientific Publishing},
+        series = {Developments in Atmospheric Science},
+	title = "{Waves in the atmosphere: Atmospheric infrasound 
+		and gravity waves - Their generation and propagation}",
+	volume = {2},
+	year = {1975},
+	adress = "Amsterdam - Oxford - New York"
+}
+
+@ARTICLE{Boug:97,
+   author = {{Bougeault}, P. and {Benech}, B. and {Bessemoulin}, P. 
+	   and {Carissimo}, B. and {Jansa Clar}, A. and {Pelon}, J. 
+		   and {Petitdidier}, M. and {Richard}, E.},
+   title = "{PYREX: A Summary of Findings.}",
+   journal = bams,
+   year = 1997,
+   volume = 78,
+   pages = {637-637},
+}
+
+@ARTICLE{Dubu:01,
+   author = {{Dubuisson}, P. and {Borde}, R. 
+	   and {Schmechtig}, C. and {Santer}, R.},
+   title = "{Surface pressure estimates from satellite data in 
+	   the oxygen A-band: Applications to the MOS sensor over land}",
+   journal = jgr,
+   year = 2001,
+   volume = 106,
+   pages = {27277-27286},
+   doi = {10.1029/2001JD000401},
+}
+
+@ARTICLE{Mitc:87,
+   author = {{Mitchell}, R.~M. and {O'Brien}, D.~M.},
+   title = "{Error Estimates for Passive Satellite Measurement 
+	   of Surface Pressure Using Absorption in the A Band of Oxygen.}",
+   journal = jas,
+   year = 1987,
+   volume = 44,
+   pages = {1981-1990},
+}
+
+@ARTICLE{Mont:06luca,
+   author = {{Montabone}, L. and {Lewis}, S.~R. and {Read}, P.~L. and {Hinson}, D.~P.},
+   title = "{Validation of martian meteorological data assimilation for MGS/TES using radio occultation measurements}",
+   journal = {Icarus},
+   year = 2006,
+   volume = 185,
+   pages = {113-132},
+   doi = {10.1016/j.icarus.2006.07.012},
+}
+
+@ARTICLE{Bibr:91,
+   author = {{Bibring}, J.-P. and {Erard}, S. and {Gondet}, B. and
+{Langevin}, Y. and 
+	{Soufflot}, A. and {Combes}, M. and {Cara}, C. and {Drossart},
+P. and 
+	{Encrenaz}, T. and {Lellouch}, E. and {Rosenqvist}, J. and
+{Moroz}, V.~I. and 
+	{Dyachkov}, A.~V. and {Grygoriev}, A.~V. and {Havinson}, N.~G.
+and 
+	{Khatuntsev}, I.~V. and {Kiselev}, A.~V. and {Ksanfomality},
+L.~V. and 
+	{Nikolsky}, Y.~V. and {Masson}, P. and {Forni}, O. and {Sotin},
+C.
+	},
+    title = "{Topography of the Martian tropical regions with
+ISM}",
+  journal = pss,
+     year = 1991,
+   volume = 39,
+    pages = {225-236},
+      doi = {10.1016/0032-0633(91)90146-2},
+}
+
+@INPROCEEDINGS{Smit:06granada,
+   author = {{Smith}, M.~D.},
+    title = "{TES atmospheric temperature, aerosol optical depth, and
+water vapor observations 1999-2004}",
+booktitle = {Mars Atmosphere Modelling and Observations},
+     year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean},
+M.~C. and 
+	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis},
+S.~R. and 
+	{Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+    pages = {211},
+}
+
+@ARTICLE{Zaso:05,
+   author = {{Zasova}, L. and {Formisano}, V. and {Moroz}, V. and
+{Grassi}, D. and 
+	{Ignatiev}, N. and {Giuranna}, M. and {Hansen}, G. and {Blecka}, M.
+and 
+	{Ekonomov}, A. and {Lellouch}, E. and {Fonti}, S. and {Grigoriev}, A.
+and 
+	{Hirsch}, H. and {Khatuntsev}, I. and {Mattana}, A. and {Maturilli},
+A. and 
+	{Moshkin}, B. and {Patsaev}, D. and {Piccioni}, G. and {Rataj}, M.
+and 
+	{Saggin}, B.},
+    title = "{Water clouds and dust aerosols observations with PFS MEX at
+Mars}",
+  journal = pss,
+     year = 2005,
+   volume = 53,
+    pages = {1065-1077},
+      doi = {10.1016/j.pss.2004.12.010},
+}
+
+@ARTICLE{Lebo:06,
+   author = {{Lebonnois}, S. and {Qu{\'e}merais}, E. and {Montmessin},
+F. and 
+	{Lef{\`e}vre}, F. and {Perrier}, S. and {Bertaux}, J.-L. and 
+	{Forget}, F.},
+    title = "{Vertical distribution of ozone on Mars as measured by
+SPICAM/Mars Express using stellar occultations}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+    pages = {9},
+      doi = {10.1029/2005JE002643},
+}
+
+@ARTICLE{Lang:06,
+   author = {{Langevin}, Y. and {Dout{\'e}}, S. and {Vincendon}, M. and
+{Poulet}, F. and 
+	{Bibring}, J.-P. and {Gondet}, B. and {Schmitt}, B. and {Forget}, F.
+	},
+    title = "{No signature of clear {CO$_{2}$} ice from the `cryptic'
+regions in Mars' south seasonal polar cap}",
+  journal = {Nature},
+     year = 2006,
+   volume = 442,
+    pages = {790-792},
+      doi = {10.1038/nature05012},
+}
+
+@ARTICLE{Mont:06franck,
+   author = {{Montmessin}, F. and {Bertaux}, J.-L. and {Qu{\'e}merais}, E. and 
+	{Korablev}, O. and {Rannou}, P. and {Forget}, F. and {Perrier}, S.  and 
+	{Fussen}, D. and {Lebonnois}, S. and {R{\'e}b{\'e}rac}, A. and 
+	{Dimarellis}, E.},
+    title = "{Subvisible {CO$_2$} ice clouds detected in the mesosphere of
+Mars}",
+  journal = {Icarus},
+     year = 2006,
+   volume = 183,
+    pages = {403-410},
+      doi = {10.1016/j.icarus.2006.03.015},
+}
+
+@ARTICLE{Bara:06,
+   author = {{Baratoux}, D. and {Mangold}, N. and {Forget}, F. and
+{Cord}, A. and 
+	{Pinet}, P. and {Daydou}, Y. and {Jehl}, A. and {Masson}, P. and 
+	{Neukum}, G. and {The HRSC Co-Investigator Team}},
+    title = "{The role of the wind-transported dust in slope streaks
+activity: Evidence from the HRSC data}",
+  journal = {Icarus},
+     year = 2006,
+   volume = 183,
+    pages = {30-45},
+      doi = {10.1016/j.icarus.2006.01.023},
+}
+
+@ARTICLE{Forg:06,
+   author = {{Forget}, F. and {Haberle}, R.~M. and {Montmessin}, F. and
+{Levrard}, B. and 
+	{Head}, J.~W.},
+    title = "{Formation of Glaciers on Mars by Atmospheric Precipitation
+at High Obliquity}",
+  journal = {Science},
+     year = 2006,
+   volume = 311,
+    pages = {368-371},
+      doi = {10.1126/science.1120335},
+}
+
+@ARTICLE{Encr:05ica,
+   author = {{Encrenaz}, T. and {B{\'e}zard}, B. and {Owen}, T. and
+{Lebonnois}, S. and 
+	{Lef{\`e}vre}, F. and {Greathouse}, T. and {Richter}, M. and 
+	{Lacy}, J. and {Atreya}, S. and {Wong}, A.~S. and {Forget}, F.  },
+    title = "{Infrared imaging spectroscopy of Mars: H$_{2}$O mapping and
+determination of {CO$_2$} isotopic ratios}",
+  journal = {Icarus},
+     year = 2005,
+   volume = 179,
+    pages = {43-54},
+      doi = {10.1016/j.icarus.2005.06.022},
+}
+
+@ARTICLE{Encr:05aaa,
+   author = {{Encrenaz}, T. and {Melchiorri}, R. and {Fouchet}, T. and
+{Drossart}, P. and 
+	{Lellouch}, E. and {Gondet}, B. and {Bibring}, J.-P. and {Langevin},
+Y. and 
+	{Titov}, D. and {Ignatiev}, N. and {Forget}, F.},
+    title = "{A mapping of martian water sublimation during early
+northern summer using OMEGA/Mars Express}",
+  journal = {Astronomy and Astrophysics},
+     year = 2005,
+   volume = 441,
+    pages = {L9-L12},
+      doi = {10.1051/0004-6361:200500171},
+}
+
+
+@ARTICLE{Suns:90,
+   author = {{Sunshine}, J.~M. and {Pieters}, C.~M. and {Pratt}, S.~F.},
+    title = "{Deconvolution of mineral absorption bands - An improved
+approach}",
+  journal = jgr,
+     year = 1990,
+   volume = 95,
+    pages = {6955-6966},
+}
+
+@INPROCEEDINGS{Kann:05,
+   author = {{Kanner}, L.~C. and {Mustard}, J.~F. and {Bibring}, J.-P.
+and 
+	{Gendrin}, A. and {Langevin}, Y. and {Gondet}, B. and {Pelkey}, S.~M.
+and 
+	{The Omega Science Team}},
+    title = "{Analysis of Martian Pyroxene Compositions in Syrtis Major:
+Full MGM Application to OMEGA}",
+booktitle = {36th Annual Lunar and Planetary Science Conference},
+     year = 2005,
+    pages = {1730},
+}
+
+@ARTICLE{Forg:07omeg,
+   author = {{Forget}, F. and {Spiga}, A. and {Dolla}, B. and {Vinatier}, S. and 
+	{Melchiorri}, R. and {Drossart}, P. and {Gendrin}, A. and {Bibring}, J.-P. and 
+	{Langevin}, Y. and {Gondet}, B.},
+    title = "{Remote sensing of surface pressure on Mars with the Mars Express/OMEGA spectrometer: 1. Retrieval method}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002871},
+}
+
+@ARTICLE{Spig:07omeg,
+   author = {{Spiga}, A. and {Forget}, F. and {Dolla}, B. and {Vinatier}, S. and 
+	{Melchiorri}, R. and {Drossart}, P. and {Gendrin}, A. and {Bibring}, J.-P. and 
+	{Langevin}, Y. and {Gondet}, B.},
+    title = "{Remote sensing of surface pressure on Mars with the Mars Express/OMEGA spectrometer: 2. Meteorological maps}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002870},
+}
+
+@misc{Forg:07dust,
+   author = {Forget, F. and Dolla, B. and Vinatier, S. and Spiga, A.},
+   howpublished = {submitted to Geophys. Res. Lett.},
+   title = {A very simple algorithm to compute light scattering in optically
+	   thin planetary atmosphere. Application to remote sensing on \protect{M}ars},
+   year = {2010}
+}
+
+
+@ARTICLE{Renn:04,
+   author = {{Renno}, N.~O. and {Abreu}, V.~J. and {Koch}, J. and {Smith}, P.~H. and 
+   	{Hartogensis}, O.~K. and {De Bruin}, H.~A.~R. and {Burose}, D. and 
+	{Delory}, G.~T. and {Farrell}, W.~M. and {Watts}, C.~J. and 
+	{Garatuza}, J. and {Parker}, M. and {Carswell}, A.},
+   title = "{MATADOR 2002: A pilot field experiment on convective plumes and dust devils}",
+   journal = jgr,
+   year = 2004,
+   volume = 109,
+   number = {E18},
+   pages = {7001},
+   doi = {10.1029/2003JE002219},
+}
+
+@misc{Koch:06,
+   author = {{Koch}, J. and {Renno}, N.~O.},
+   howpublished = {submitted to JAS},
+   title = {Interactions between Boundary Layer Convection, Mineral Dust and Solar Radiation},
+   year = {2006}
+}
+
+@misc{Joug:06,
+   author = {{Jouglet}, D. and {Poulet}, F. and {Milliken}, R.~E. and {Mustard}, J.~F.
+	  and {Bibring}, J.-P. and {Langevin}, Y. and {Gondet}, B.
+	  and the \protect{OMEGA} team},
+   howpublished = {submitted to JGR},
+   title = {Hydration state of the Martian surface as seen by \protect{Mars Express OMEGA}. \protect{I} - Analysis
+	   of 3~$\mu$m hydration feature},
+   year = {2006}
+}
+
+@INPROCEEDINGS{Zaso:06,
+   author = {{Zasova}, L.~V. and {Altieri}, F. and {Grassi}, D. and {Bellucci}, G. and 
+   	{Formisano}, V. and {Ignatiev}, N. and {Bibring}, J.-P. and 
+	{Drossart}, P. and {Encrenaz}, T. and {Fouchet}, T. and {The Omega Team}
+	},
+   title = "{Ozone in martian atmosphere from the 1.27 {$\mu$}m O2 Emission: OMEGA/Mars Express measurements}",
+   booktitle = {Mars Atmosphere Modelling and Observations},
+   year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean}, M.~C. and 
+      	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis}, S.~R. and 
+	{Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+   pages = {521},
+}
+
+
+
+@INPROCEEDINGS{Gras:06,
+   author = {{Grassi}, D. and {Wolkenberg}, P. and {Fiorenza}, C. and
+{Formisano}, V. and 
+	{Ignatiev}, N.~I. and {Zasova}, L.~V.},
+    title = "{Studies of the local circulation in the martian atmosphere
+from PFS data}",
+booktitle = {Mars Atmosphere Modelling and Observations},
+     year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean},
+M.~C. and 
+	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis},
+S.~R. and 
+	{Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+    pages = {131},
+}
+
+
+@ARTICLE{Huss:92,
+   author = {{Husson}, N. and {Bonnet}, B. and {Scott}, N.~A. and
+{Chedin}, A.
+	},
+    title = "{Management and Study of Spectroscopic Information-The
+GEISA program}",
+  journal = {Journal of Quantitative Spectroscopy and Radiative
+Transfer},
+     year = 1992,
+   volume = 48,
+    pages = {509-518},
+}
+
+
+@INPROCEEDINGS{Cham:06,
+   author = {{Chamberlain}, S. and {Bailey}, J. and {Walter}, M. and {Simpson}, A. and 
+   	{Crisp}, D.},
+   title = "{Topographic and atmospheric pressure mapping using near infrared imaging and spectral observations of Mars}",
+   booktitle = {Mars Atmosphere Modelling and Observations},
+   year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean}, M.~C. and 
+      	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis}, S.~R. and 
+        {Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+   pages = {146},
+}
+						     
+@ARTICLE{Habe:04,
+   author = {{Haberle}, R.~M. and {Mattingly}, B. and {Titus}, T.~N.},
+    title = "{Reconciling different observations of the $CO_{2}$ ice mass
+loading of the Martian north polar cap}",
+  journal = grl,
+     year = 2004,
+   volume = 31,
+    pages = {5702},
+      doi = {10.1029/2004GL019445},
+}
+
+@ARTICLE{Rafk:03,
+   author = {{Rafkin}, S.~C.~R. and {Michaels}, T.~I.},
+    title = "{Meteorological predictions for 2003 Mars Exploration Rover high-priority landing sites}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+   number = {E12},
+    pages = {8091},
+      doi = {10.1029/2002JE002027},
+}
+
+@ARTICLE{Toig:03,
+   author = {{Toigo}, A.~D. and {Richardson}, M.~I.},
+   title = "{Meteorology of proposed Mars Exploration Rover landing sites}",
+   journal = jgr,
+   year = 2003,
+   volume = 108,
+   number = {E12},
+   pages = {8092-+},
+   doi = {10.1029/2003JE002064},
+}
+
+@ARTICLE{Gray:66,
+   author = {{Gray}, L.~D.},
+   title = "{Transmission of the Atmosphere of Mars in the Region of 2~$\mu$}",
+   journal = {Icarus},
+   year = 1966,
+   volume = 5,
+   pages = {390},
+}
+
+@ARTICLE{Rafk:02,
+   author = {{Rafkin}, S.~C.~R. and {Sta.~Maria}, M.~R.~V. and {Michaels}, T.~I.},
+   title = "{Simulation of the atmospheric thermal circulation of a martian volcano using a mesoscale numerical model}",
+   journal = {Nature},
+   year = 2002,
+   volume = 419,
+   pages = {697-699},
+}
+
+@ARTICLE{Buch:06,
+   author = {{Buchwitz}, M. and {de Beek}, R. and {No{\"e}l}, S. and {Burrows}, J.~P. and 
+   	{Bovensmann}, H. and {Schneising}, O. and {Khlystova}, I. and 
+	{Bruns}, M. and {Bremer}, H. and {Bergamaschi}, P. and {K{\"o}rner}, S. and 
+	{Heimann}, M.},
+    title = "{Atmospheric carbon gases retrieved from SCIAMACHY by WFM-DOAS: version 0.5 CO and CH4 and impact of calibration improvements on CO2 retrieval}",
+    journal = {Atmospheric Chemistry \& Physics},
+    year = 2006,
+    volume = 6,
+   pages = {2727-2751},
+}
+
+@ARTICLE{Bosc:06,
+   author = {{B{\"o}sch}, H. and {Toon}, G.~C. and {Sen}, B. and {Washenfelder}, R.~A. and 
+   	{Wennberg}, P.~O. and {Buchwitz}, M. and {de Beek}, R. and {Burrows}, J.~P. and 
+	{Crisp}, D. and {Christi}, M. and {Connor}, B.~J. and {Natraj}, V. and 
+	{Yung}, Y.~L.},
+   title = "{Space-based near-infrared CO2 measurements: Testing the Orbiting Carbon Observatory retrieval algorithm and validation concept using SCIAMACHY observations over Park Falls, Wisconsin}",
+   journal = {Journal of Geophysical Research (Atmospheres)},
+   year = 2006,
+   volume = 111,
+   number = {D10},
+   pages = {23302},
+   doi = {10.1029/2006JD007080},
+}
+
+@ARTICLE{Four:06,
+   author = {{Fournier}, N. and {Stammes}, P. and {de Graaf}, M. and {van der A}, R. and 
+   	{Piters}, A. and {Grzegorski}, M. and {Kokhanovsky}, A.},
+   title = "{Improving cloud information over deserts from SCIAMACHY Oxygen A-band measurements}",
+   journal = {Atmospheric Chemistry \& Physics},
+   year = 2006,
+   volume = 6,
+   pages = {163-172},
+}
+
+@ARTICLE{Mich:06,
+   author = {{Michaels}, T.~I. and {Colaprete}, A. and {Rafkin}, S.~C.~R.},
+   title = "{Significant vertical water transport by mountain-induced circulations on Mars}",
+   journal = grl,
+   year = 2006,
+   volume = 33,
+   pages = {L16201},
+   doi = {10.1029/2006GL026562},
+}
+
+@ARTICLE{Janj:01,
+  author = {{Janjic}, Z.~I. and {Gerrity Jr}, J.~P. and {Nickovic},S.},
+  title = "{An alternative approach to nonhydrostatic modeling}",
+  journal = mwr,
+  year = 2001,
+  volume = 129,
+  pages = {1129-1178},
+}
+
+@ARTICLE{Lapr:92,
+  author = {{Laprise}, R},
+  title = "{The Euler Equations of Motion with Hydrostatic Pressure as an Independent Variable}",
+  journal = mwr,
+  year = 1992,
+  volume = 120,
+ pages = {197-207},
+}
+
+@ARTICLE{Stul:76,
+  author = {{Stull}, R.~B.},
+  title = "{Internal Gravity Waves Generated by Penetrative Convection}",
+  journal = jas,
+  year = 1976,
+  volume = 33,
+  pages = {1279-1286},
+}
+
+@ARTICLE{Mich:04,
+   author = {{Michaels}, T.~I. and {Rafkin}, S.~C.~R.},
+   title = "{Large eddy simulation of atmospheric convection on Mars}",
+   journal = qjrms,
+   year = 2004,
+   volume = 128,
+}
+
+@ARTICLE{Wang:03,
+   author = {{Wang}, H. and {Richardson}, M.~I. and {Wilson}, R.~J. and {Ingersoll}, A.~P. and 
+   	{Toigo}, A.~D. and {Zurek}, R.~W.},
+   title = "{Cyclones, tides, and the origin of a cross-equatorial dust storm on Mars}",
+   journal = grl,
+   year = 2003,
+   volume = 30,
+   pages = {1488},
+   doi = {10.1029/2002GL016828},
+}
+
+@ARTICLE{Bart:86,
+   author = {{Barton}, I.~J. and {Scott}, J.~C.},
+    title = "{Remote measurement of surface pressure using absorption in
+the oxygen A-band}",
+  journal = {Applied Optics},
+     year = 1986,
+   volume = 25,
+    pages = {3502-3507},
+}
+
+@ARTICLE{Jacq:03,
+   author = {{Jacquinet-Husson}, N. and {Scott}, N.~A. and {Chedin}, A.
+and 
+	{Garceran}, K. and {Armante}, R. and {Chursin}, A.~A. and {Barbe},
+A. and 
+	{Birk}, M. and {Brown}, L.~R. and {Camy-Peyret}, C. and {Claveau},
+C. and 
+	{Clerbaux}, C. and {Coheur}, P.~F. and {Dana}, V. and {Daumont}, L.
+and 
+	{Debacker-Barilly}, M.~R. and {Flaud}, J.~M. and {Goldman}, A. and 
+	{Hamdouni}, A. and {Hess}, M. and {Jacquemart}, D. and {Kopke}, P.
+and 
+	{Mandin}, J.~Y. and {Massie}, S. and {Mikhailenko}, S. and
+{Nemtchinov}, V. and 
+	{Nikitin}, A. and {Newnham}, D. and {Perrin}, A. and {Perevalov},
+V.~I. and 
+	{Regalia-Jarlot}, L. and {Rublev}, A. and {Schreier}, F. and 
+	{Schult}, I. and {Smith}, K.~M. and {Tashkun}, S.~A. and {Teffo},
+J.~L. and 
+	{Toth}, R.~A. and {Tyuterev}, V.~G. and {Vander Auwera}, J. and 
+	{Varanasi}, P. and {Wagner}, G.},
+    title = "{The 2003 edition of the GEISA/IASI spectroscopic
+database}",
+  journal = {Journal of Quantitative Spectroscopy and Radiative
+Transfer},
+     year = 2005,
+   volume = 95,
+    pages = {429-467},
+}
+
+@ARTICLE{Houw:05,
+   author = {{Houweling}, S. and {Hartmann}, W. and {Aben}, I. and
+{Schrijver}, H. and 
+	{Skidmore}, J. and {Roelofs}, G.-J. and {Breon}, F.-M.},
+    title = "{Evidence of systematic errors in SCIAMACHY-observed CO$_{2}$
+due to aerosols}",
+  journal = {Atmospheric Chemistry \& Physics},
+     year = 2005,
+   volume = 5,
+    pages = {3003-3013},
+}
+
+@ARTICLE{Mont:06jgr,
+   author = {{Montmessin}, F. and {Qu{\'e}merais}, E. and {Bertaux},
+J.~L. and 
+	{Korablev}, O. and {Rannou}, P. and {Lebonnois}, S.},
+    title = "{Stellar occultations at UV wavelengths by the SPICAM
+instrument: Retrieval and analysis of Martian haze profiles}",
+  journal = jgr,
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {9},
+      doi = {10.1029/2005JE002662},
+}
+
+@ARTICLE{Fedo:06,
+   author = {{Fedorova}, A. and {Korablev}, O. and {Perrier}, S. and {Bertaux}, J.-L. and 
+	   	{Lef{\`e}vre}, F. and {Rodin}, A.},
+   title = "{Observation of O$_{2}$ 1.27~$\mu$m dayglow by SPICAM IR: Seasonal distribution for the first Martian year of Mars Express}",
+   journal = jgr,
+   year = 2006,
+   volume = 111,
+   number = {E10},
+   pages = {9},
+   doi = {10.1029/2006JE002694},
+}
+
+@BOOK{Pres:92,
+   author = {{Press}, W.~H. and {Teukolsky}, S.~A. and {Vetterling},
+W.~T. and 
+	{Flannery}, B.~P.},
+    title = "{Numerical recipes in FORTRAN. The art of scientific
+computing}",
+publisher = {Cambridge University Press},
+     year = 1992,
+}
+
+
+@ARTICLE{Kann:07,
+   author = {{Kanner}, L.~C. and {Mustard}, J.~F. and {Gendrin}, A.},
+    title = "{Assessing the limits of the Modified Gaussian Model for
+remote spectroscopic studies of pyroxenes on Mars}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 187,
+    pages = {442-456},
+      doi = {10.1016/j.icarus.2006.10.025},
+}
+
+ 
+
+@ARTICLE{Jacq:05,
+   author = {{Jacquinet-Husson}, N. and {Scott}, N.~A. and {Chedin}, A.
+and 
+	{Garceran}, K. and {Armante}, R. and {Chursin}, A.~A. and {Barbe}, A.
+and 
+	{Birk}, M. and {Brown}, L.~R. and {Camy-Peyret}, C. and {Claveau}, C.
+and 
+	{Clerbaux}, C. and {Coheur}, P.~F. and {Dana}, V. and {Daumont}, L.
+and 
+	{Debacker-Barilly}, M.~R. and {Flaud}, J.~M. and {Goldman}, A. and 
+	{Hamdouni}, A. and {Hess}, M. and {Jacquemart}, D. and {Kopke}, P.
+and 
+	{Mandin}, J.~Y. and {Massie}, S. and {Mikhailenko}, S. and
+{Nemtchinov}, V. and 
+	{Nikitin}, A. and {Newnham}, D. and {Perrin}, A. and {Perevalov},
+V.~I. and 
+	{Regalia-Jarlot}, L. and {Rublev}, A. and {Schreier}, F. and 
+	{Schult}, I. and {Smith}, K.~M. and {Tashkun}, S.~A. and {Teffo},
+J.~L. and 
+	{Toth}, R.~A. and {Tyuterev}, V.~G. and {Vander Auwera}, J. and 
+	{Varanasi}, P. and {Wagner}, G.},
+    title = "{The 2003 edition of the GEISA/IASI spectroscopic
+database}",
+  journal = {Journal of Quantitative Spectroscopy and Radiative
+Transfer},
+     year = 2005,
+   volume = 95,
+    pages = {429-467},
+}
+
+@ARTICLE{Rega:06,
+   author = {{R{\'e}galia-Jarlot}, L. and {Z{\'e}ninari}, V. and
+{Parvitte}, B. and 
+	{Grossel}, A. and {Thomas}, X. and {von der Heyden}, P. and 
+	{Durry}, G.},
+    title = "{A complete study of the line intensities of four bands of
+CO2 around 1.6 and 2.0 {$\mu$}m: A comparison between Fourier transform
+and diode laser measurements}",
+  journal = {Journal of Quantitative Spectroscopy and Radiative
+Transfer},
+     year = 2006,
+   volume = 101,
+    pages = {325-338},
+}
+
+@ARTICLE{Stam:00,
+   author = {{Stam}, D.~M. and {De Haan}, J.~F. and {Hovenier}, J.~W.
+and 
+	{Aben}, I.},
+    title = "{Detecting radiances in the {O$_{2}$} A band using
+polarization-sensitive satellite instruments with application to the
+Global Ozone Monitoring Experiment}",
+  journal = jgr,
+     year = 2000,
+   volume = 105,
+    pages = {22379-22392},
+      doi = {10.1029/2000JD900313},
+}
+
+@ARTICLE{Stam:99,
+   author = {{Stam}, D.~M. and {De Haan}, J.~F. and {Hovenier}, J.~W.
+and 
+	{Stammes}, P.},
+    title = "{Degree of linear polarization of light emerging from the
+cloudless atmosphere in the oxygen A band}",
+  journal = jgr,
+     year = 1999,
+   volume = 104,
+    pages = {16843-16858},
+      doi = {10.1029/1999JD900159},
+}
+
+@ARTICLE{Wolf:06,
+   author = {{Wolff}, M.~J. and {Smith}, M.~D. and {Clancy}, R.~T. and
+{Spanovich}, N. and 
+	{Whitney}, B.~A. and {Lemmon}, M.~T. and {Bandfield}, J.~L. and 
+	{Banfield}, D. and {Ghosh}, A. and {Landis}, G. and {Christensen},
+P.~R. and 
+	{Bell}, J.~F. and {Squyres}, S.~W.},
+    title = "{Constraints on dust aerosols from the Mars Exploration
+Rovers using MGS overflights and Mini-TES}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {12},
+      doi = {10.1029/2006JE002786},
+}
+
+@ARTICLE{Shku:05,
+   author = {{Shkuratov}, Y. and {Kreslavsky}, M. and {Kaydash}, V. and
+{Videen}, G. and 
+	{Bell}, J. and {Wolff}, M. and {Hubbard}, M. and {Noll}, K. and 
+	{Lubenow}, A.},
+    title = "{Hubble Space Telescope imaging polarimetry of Mars during
+the 2003 opposition}",
+  journal = {Icarus},
+     year = 2005,
+   volume = 176,
+    pages = {1-11},
+      doi = {10.1016/j.icarus.2005.01.009},
+}
+
+@ARTICLE{Bone:05,
+   author = {{Bonello}, G. and {Pierre Bibring}, J. and {Soufflot}, A.
+and 
+	{Langevin}, Y. and {Gondet}, B. and {Berth{\'e}}, M. and
+{Carabetian}, C.
+	},
+    title = "{The ground calibration setup of OMEGA and VIRTIS
+experiments: description and performances}",
+  journal = pss,
+     year = 2005,
+   volume = 53,
+    pages = {711-728},
+      doi = {10.1016/j.pss.2005.02.002},
+}
+
+@ARTICLE{Spra:04,
+   author = {{Sprague}, A.~L. and {Boynton}, W.~V. and {Kerry}, K.~E.
+and 
+	{Janes}, D.~M. and {Hunten}, D.~M. and {Kim}, K.~J. and {Reedy},
+R.~C. and 
+	{Metzger}, A.~E.},
+    title = "{Mars' South Polar Ar Enhancement: A Tracer for South Polar
+Seasonal Meridional Mixing}",
+  journal = {Science},
+     year = 2004,
+   volume = 306,
+    pages = {1364-1367},
+      doi = {10.1126/science.1098496},
+}
+
+@ARTICLE{Toth:06,
+   author = {{Toth}, R.~A. and {Brown}, L.~R. and {Miller}, C.~E. and
+{Devi}, V.~M. and 
+	{Benner}, D.~C.},
+    title = "{Line strengths of $^{12}C^{16}O_{2}$: 4550-7000
+cm$^{-1}$}",
+  journal = {Journal of Molecular Spectroscopy},
+     year = 2006,
+   volume = 239,
+    pages = {221-242},
+      doi = {10.1016/j.jms.2006.08.001},
+}
+
+@ARTICLE{Coli:96,
+   author = {{Colina}, L. and {Bohlin}, R.~C. and {Castelli}, F.},
+    title = "{The 0.12-2.5 micron Absolute Flux Distribution of the Sun for
+Comparison With Solar Analog Stars}",
+  journal = {Astronomical Journal },
+     year = 1996,
+   volume = 112,
+    pages = {307},
+      doi = {10.1086/118016},
+}
+
+
+@ARTICLE{Dufr:05,
+   author = {{Dufresne}, J.-L. and {Fournier}, R. and {Hourdin}, C. and
+{Hourdin}, F. },
+title = "{Net Exchange Reformulation of Radiative Transfer in the
+{CO$_{2}$} 15-{$\mu$}m Band on Mars.}",
+journal = {Journal of Atmospheric Sciences},
+year = 2005,
+volume = 62,
+pages = {3303-3319},
+}
+
+@ARTICLE{Wils:07,
+   author = {{Wilson}, R.~J. and {Neumann}, G.~A. and {Smith}, M.~D.},
+    title = "{Diurnal variation and radiative influence of Martian water
+ice clouds}",
+  journal = grl,
+     year = 2007,
+   volume = 34,
+    pages = {2710},
+      doi = {10.1029/2006GL027976},
+}
+
+@ARTICLE{Basu:04,
+   author = {{Basu}, S. and {Richardson}, M.~I. and {Wilson}, R.~J.},
+    title = "{Simulation of the Martian dust cycle with the GFDL Mars
+GCM}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2004,
+   volume = 109,
+   number = {E18},
+    pages = {11006},
+      doi = {10.1029/2004JE002243},
+}
+
+@INPROCEEDINGS{Rich:06,
+   author = {{Richardson}, M.~I. and {Newman}, C.~E. and {Toigo},
+A.~D.},
+    title = "{PlanetWRF - A Flexible, Multi-scale Model For Planetary
+Atmospheres}",
+booktitle = {AAS/Division for Planetary Sciences Meeting Abstracts},
+     year = 2006,
+   volume = 38,
+    pages = {70.04},
+}
+
+@ARTICLE{Hart:05,
+   author = {{Hartogh}, P. and {Medvedev}, A.~S. and {Kuroda}, T. and
+{Saito}, R. and 
+	{Villanueva}, G. and {Feofilov}, A.~G. and {Kutepov}, A.~A. and 
+	{Berger}, U.},
+    title = "{Description and climatology of a new general circulation
+model of the Martian atmosphere}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {11008},
+      doi = {10.1029/2005JE002498},
+}
+
+@ARTICLE{Moud:05,
+   author = {{Moudden}, Y. and {McConnell}, J.~C.},
+    title = "{A new model for multiscale modeling of the Martian
+atmosphere, GM3}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {4001},
+      doi = {10.1029/2004JE002354},
+}
+
+@ARTICLE{Fent:07,
+   author = {{Fenton}, L.~K. and {Geissler}, P.~E. and {Haberle},
+R.~M.},
+    title = "{Global warming and climate forcing by recent albedo
+changes on Mars}",
+  journal = {Nature},
+     year = 2007,
+   volume = 446,
+    pages = {646-649},
+      doi = {10.1038/nature05718},
+}
+
+@ARTICLE{Kahr:06,
+   author = {{Kahre}, M.~A. and {Murphy}, J.~R. and {Haberle}, R.~M.},
+    title = "{Modeling the Martian dust cycle and surface dust
+reservoirs with the NASA Ames general circulation model}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {6008},
+      doi = {10.1029/2005JE002588},
+}
+
+
+@ARTICLE{Taka:03,
+   author = {{Takahashi}, Y.~O. and {Fujiwara}, H. and {Fukunishi}, H.
+and 
+	{Odaka}, M. and {Hayashi}, Y.-Y. and {Watanabe}, S.},
+    title = "{Topographically induced north-south asymmetry of the
+meridional circulation in the Martian atmosphere}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {5-1},
+      doi = {10.1029/2001JE001638},
+}
+
+@ARTICLE{Taka:06,
+   author = {{Takahashi}, Y.~O. and {Fujiwara}, H. and {Fukunishi}, H.},
+   title = "{Vertical and latitudinal structure of the migrating diurnal
+tide in the Martian atmosphere: Numerical investigations}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {1003},
+      doi = {10.1029/2005JE002543},
+}
+
+@INPROCEEDINGS{Forg:06argon,
+   author = {{Forget}, F. and {Montabone}, L. and {Lebonnois}, S.},
+    title = "{Modelling the non-condensable gas enrichment in the polar
+night}",
+booktitle = {Mars Atmosphere Modelling and Observations},
+     year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean},
+M.~C. and 
+	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis},
+S.~R. and 
+	{Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+    pages = {422},
+}
+
+@ARTICLE{Encr:06,
+   author = {{Encrenaz}, T. and {Fouchet}, T. and {Melchiorri}, R. and
+{Drossart}, P. and 
+	{Gondet}, B. and {Langevin}, Y. and {Bibring}, J.-P. and {Forget},
+F. and 
+	{B{\'e}zard}, B.},
+    title = "{Seasonal variations of the martian CO over Hellas as
+observed by OMEGA/Mars Express}",
+  journal = {Astronomy and Astrophysics},
+     year = 2006,
+   volume = 459,
+    pages = {265-270},
+      doi = {10.1051/0004-6361:20065586},
+}
+
+@ARTICLE{Basu:06,
+  author = {{Basu}, S. and {Wilson}, J. and {Richardson}, M. and
+   {Ingersoll}, A.
+   },
+   title = "{Simulation of spontaneous and variable global
+   dust storms with the GFDL Mars GCM}",
+   journal = {Journal of Geophysical Research (Planets)},
+   year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {9004},
+   doi = {10.1029/2005JE002660}, 
+   }
+
+
+@ARTICLE{Perr:06,
+   author = {{Perrier}, S. and {Bertaux}, J.~L. and {Lef{\`e}vre}, F. and 
+	{Lebonnois}, S. and {Korablev}, O. and {Fedorova}, A. and 
+{Montmessin}, F.
+	},
+    title = "{Global distribution of total ozone on Mars from SPICAM/MEX UV 
+measurements}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {9},
+      doi = {10.1029/2006JE002681},
+}
+
+@ARTICLE{Squy:04,
+author = {{Squyres}, S.~W. and {Grotzinger}, J.~P. and
+   {Arvidson}, R.~E. and 
+   {Bell}, J.~F. and {Calvin}, W. and {Christensen},
+P.~R. and 
+{Clark}, B.~C. and {Crisp}, J.~A. and
+{Farrand}, W.~H. and {Herkenhoff}, K.~E. and 
+{Johnson}, J.~R. and {Klingelh{\"o}fer}, G. and
+{Knoll}, A.~H. and 
+{McLennan}, S.~M. and {McSween}, H.~Y. and
+{Morris}, R.~V. and 
+{Rice}, J.~W. and {Rieder}, R. and
+{Soderblom}, L.~A.},
+    title = "{In Situ Evidence for an
+Ancient Aqueous Environment
+at Meridiani Planum, Mars}",
+journal = {Science},
+      year = 2004,
+      volume = 306,
+      pages = {1709-1714},
+        doi = {10.1126/science.1104559},
+}
+
+
+@ARTICLE{Ansa:06,
+   author = {{Ansan}, V. and {Mangold}, N.},
+       title = "{New observations of Warrego Valles, Mars:
+   Evidence for precipitation and surface runoff}",
+     journal = pss,
+      year = 2006,
+     volume = 54,
+     pages = {219-242},
+       doi = {10.1016/j.pss.2005.12.009},
+}
+
+
+@INPROCEEDINGS{Forg:03,
+   author = {{Forget}, F. and {Haberle}, R.~M. and {Montmessin},
+   F. and {Cha}, S. and 
+   {Marcq}, E. and {Schaeffer}, J. and
+   {Wanherdrick}, Y.},
+       title = "{3D Simulations of the Early Mars
+   Climate with a General Circulation
+   Model}",
+   booktitle = {Third International Conference on
+   Mars Polar Science and Exploration},
+        year = 2003,
+   editor = {{Clifford}, S. and {Doran}, P.  and {Fisher}, D. and {Herd}, C.  },
+       pages = {8070},
+}
+
+@misc{Forg:04,
+   author = {Forget, F. and Bertaux, J.L. },
+   howpublished = {ESA technical report 09-2004},
+   title = {The Martian atmosphere at the time of the Beagle 2 landing: the density was not anomalously low},
+   year = 2004,
+}
+
+@misc{Forg:02mambo,
+   author = {Forget, F. {and the MAMBO team}  },
+   howpublished = {Proposition CNES, 12O pages},
+   title = {MAMBO: Mars atmosphere Microwave Brightness Observer (A
+proposal for the scientific payload onboard the CNES 2007 Premier
+Obiter)
+   },
+   year = 2002,
+}
+
+
+@INPROCEEDINGS{Gonz:06,
+   author = {{Gonz{\'a}lez-Galindo}, F. and {Bougher}, S. and
+{L{\'o}pez-Valverde}, M.~A. and 
+	{Forget}, F. and {Bell}, J.},
+    title = "{Thermal structure of the martian thermosphere: LMD-IAA GCM
+and MTGCM intercomparisons}",
+booktitle = {Mars Atmosphere Modelling and Observations},
+     year = 2006,
+   editor = {{Forget et al.}},
+    pages = {625},
+   adsurl = {http://adsabs.harvard.edu/abs/2006mamo.conf..625G},
+}
+
+@ARTICLE{Boug:90,
+   author = {{Bougher}, S.~W. and {Roble}, R.~G. and {Ridley}, E.~C. and
+	{Dickinson}, R.~E.},
+    title = "{The Mars thermosphere. II - General circulation with
+coupled dynamics and composition}",
+  journal = jgr,
+     year = 1990,
+   volume = 95,
+    pages = {14811-14827},
+}
+
+@ARTICLE{Gonz:05,
+   author = {{Gonz{\'a}lez-Galindo}, F. and {L{\'o}pez-Valverde}, M.~A.
+and {Angelats i Coll}, M. and {Forget}, F.},
+    title = "{Extension of a Martian general circulation model to
+thermospheric altitudes: UV heating and photochemical models}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {9008},
+      doi = {10.1029/2004JE002312},
+}
+
+@INPROCEEDINGS{Forg:05methane,
+   author = {{Forget}, F. and {Haberle}, R.~M. and {Montmessin}, F.},
+    title = "{Spatial Variation of Methane and Other Trace Gases Detected
+on Mars: Interpretation with a General Circulation Model}",
+booktitle = {36th Annual Lunar and Planetary Science Conference},
+     year = 2005,
+   series = {Lunar and Planetary Institute Conference Abstracts},
+   volume = 36,
+   editor = {{Mackwell}, S. and {Stansbery}, E.},
+    pages = {1597},
+}
+
+@INPROCEEDINGS{Forg:05cap,
+   author = {{Forget}, F. and {Levrard}, B. and {Montmessin}, F. and
+{Schmitt}, B. and 
+	{Dout{\'e}}, S. and {Langevin}, Y. and {Bibring}, J.-P.},
+    title = "{Mars Water Ice and Carbon Dioxide Seasonal Polar Caps: GCM
+Modeling and Comparison with Mars Express Omega Observations}",
+booktitle = {36th Annual Lunar and Planetary Science Conference},
+     year = 2005,
+   series = {Lunar and Planetary Institute Conference Abstracts},
+   volume = 36,
+   editor = {{Mackwell}, S. and {Stansbery}, E.},
+    pages = {1605},
+}
+
+@ARTICLE{Form:04,
+   author = {{Formisano}, V. and {Atreya}, S. and {Encrenaz}, T. and
+{Ignatiev}, N. and 
+	{Giuranna}, M.},
+    title = "{Detection of Methane in the Atmosphere of Mars}",
+  journal = {Science},
+     year = 2004,
+   volume = 306,
+    pages = {1758-1761},
+      doi = {10.1126/science.1101732},
+}
+
+@ARTICLE{Kras:04,
+   author = {{Krasnopolsky}, V.~A. and {Maillard}, J.~P. and {Owen},
+T.~C.
+	},
+    title = "{Detection of methane in the martian atmosphere: evidence
+for life?}",
+  journal = {Icarus},
+     year = 2004,
+   volume = 172,
+    pages = {537-547},
+      doi = {10.1016/j.icarus.2004.07.004},
+}
+
+@INPROCEEDINGS{Made:07,
+   author = {{Madeleine}, J.-B. and {Forget}, F. and {Head}, J.~W. and
+{Levrard}, B. and {Montmessin}, F.},
+    title = "{Mars: A Proposed Climatic Scenario for Northern
+Mid-Latitude Glaciation}",
+booktitle = {Lunar and Planetary Institute Conference Abstracts},
+     year = 2007,
+   volume = 38,
+    pages = {1778},
+}
+
+@ARTICLE{Elli:07,
+   author = {{Elliot}, J.~L. and {Person}, M.~J. and {Gulbis}, A.~A.~S.
+and 
+	{Souza}, S.~P. and {Adams}, E.~R. and {Babcock}, B.~A. and
+{Gangestad}, J.~W. and 
+	{Jaskot}, A.~E. and {Kramer}, E.~A. and {Pasachoff}, J.~M. and 
+	{Pike}, R.~E. and {Zuluaga}, C.~A. and {Bosh}, A.~S. and {Dieters},
+S.~W. and 
+	{Francis}, P.~J. and {Giles}, A.~B. and {Greenhill}, J.~G. and 
+	{Lade}, B. and {Lucas}, R. and {Ramm}, D.~J.},
+    title = "{Changes in Pluto's Atmosphere: 1988-2006}",
+  journal = {Astrophys. Jour.},
+     year = 2007,
+   volume = 134,
+    pages = {1-13},
+      doi = {10.1086/517998},
+}
+
+@ARTICLE{Youn:97,
+   author = {{Young}, L.~A. and {Elliot}, J.~L. and {Tokunaga}, A. and
+{de Bergh}, C. and 
+	{Owen}, T.},
+    title = "{Detection of Gaseous Methane on Pluto}",
+  journal = {Icarus},
+     year = 1997,
+   volume = 127,
+    pages = {258},
+      doi = {10.1006/icar.1997.5709},
+}
+
+@ARTICLE{Stro:96,
+   author = {{Young}, L.~A. and {Elliot}, J.~L. and {Tokunaga}, A. and
+{de Bergh}, C. and 
+	{Owen}, T.},
+    title = "{Detection of Gaseous Methane on Pluto}",
+  journal = {Icarus},
+     year = 1997,
+   volume = 127,
+    pages = {258},
+      doi = {10.1006/icar.1997.5709},
+}
+
+@ARTICLE{Elli:03,
+   author = {{Elliot}, J.~L. and {Ates}, A. and {Babcock}, B.~A. and
+{Bosh}, A.~S. and 
+	{Buie}, M.~W. and {Clancy}, K.~B. and {Dunham}, E.~W. and
+{Eikenberry}, S.~S. and 
+	{Hall}, D.~T. and {Kern}, S.~D. and {Leggett}, S.~K. and {Levine},
+S.~E. and 
+	{Moon}, D.-S. and {Olkin}, C.~B. and {Osip}, D.~J. and {Pasachoff},
+J.~M. and 
+	{Penprase}, B.~E. and {Person}, M.~J. and {Qu}, S. and {Rayner},
+J.~T. and 
+	{Roberts}, L.~C. and {Salyk}, C.~V. and {Souza}, S.~P. and {Stone},
+R.~C. and 
+	{Taylor}, B.~W. and {Tholen}, D.~J. and {Thomas-Osip}, J.~E. and 
+	{Ticehurst}, D.~R. and {Wasserman}, L.~H.},
+    title = "{The recent expansion of Pluto's atmosphere}",
+  journal = {Nature},
+     year = 2003,
+   volume = 424,
+    pages = {165-168},
+}
+
+@ARTICLE{Sica:03,
+   author = {{Elliot}, J.~L. and {Ates}, A. and {Babcock}, B.~A. and
+{Bosh}, A.~S. and 
+	{Buie}, M.~W. and {Clancy}, K.~B. and {Dunham}, E.~W. and
+{Eikenberry}, S.~S. and 
+	{Hall}, D.~T. and {Kern}, S.~D. and {Leggett}, S.~K. and {Levine},
+S.~E. and 
+	{Moon}, D.-S. and {Olkin}, C.~B. and {Osip}, D.~J. and {Pasachoff},
+J.~M. and 
+	{Penprase}, B.~E. and {Person}, M.~J. and {Qu}, S. and {Rayner},
+J.~T. and 
+	{Roberts}, L.~C. and {Salyk}, C.~V. and {Souza}, S.~P. and {Stone},
+R.~C. and 
+	{Taylor}, B.~W. and {Tholen}, D.~J. and {Thomas-Osip}, J.~E. and 
+	{Ticehurst}, D.~R. and {Wasserman}, L.~H.},
+    title = "{The recent expansion of Pluto's atmosphere}",
+  journal = {Nature},
+     year = 2003,
+   volume = 424,
+    pages = {165-168},
+}
+
+@ARTICLE{Bull:01,
+   author = {{Bullock}, M.~A. and {Grinspoon}, D.~H.},
+    title = "{The Recent Evolution of Climate on Venus}",
+  journal = {Icarus},
+     year = 2001,
+   volume = 150,
+    pages = {19-37},
+      doi = {10.1006/icar.2000.6570},
+}
+
+@ARTICLE{Bull:96,
+   author = {{Bullock}, M.~A. and {Grinspoon}, D.~H.},
+    title = "{The stability of climate on Venus}",
+  journal = jgr,
+     year = 1996,
+   volume = 101,
+    pages = {7521-7530},
+      doi = {10.1029/95JE03862},
+}
+
+@ARTICLE{Udry:07,
+   author = {{Udry}, S. and {Bonfils}, X. and {Delfosse}, X. and
+{Forveille}, T. and 
+	{Mayor}, M. and {Perrier}, C. and {Bouchy}, F. and {Lovis}, C. and 
+	{Pepe}, F. and {Queloz}, D. and {Bertaux}, J.~-.},
+    title = "{The HARPS search for southern extra-solar planets XI.
+Super-Earths (5 and 8 Earth mass in a 3-planet system}",
+  journal = {Astronomy and Astrophysics, ArXiv e-prints},
+   eprint = {0704.3841},
+     year = 2007,
+   volume = 704,
+}
+
+@ARTICLE{Kalt:05,
+   author = {{Kaltenegger}, L. and {Fridlund}, M.},
+    title = "{The Darwin mission: Search for extra-solar planets}",
+  journal = {Advances in Space Research},
+     year = 2005,
+   volume = 36,
+    pages = {1114-1122},
+      doi = {10.1016/j.asr.2005.05.061},
+}
+
+@ARTICLE{Robe:06,
+   author = {{Robert}, F. and {Chaussidon}, M.},
+    title = "{
+A paleotemperature curve for the Precambrian oceans based on silicon
+isotopes in cherts.
+}",
+  journal = {Nature},
+     year = 2006,
+   volume = 443,
+    pages = {969-973},
+}
+
+
+@ARTICLE{Cola:05,
+   author = {{Colaprete}, A. and {Barnes}, J.~R. and {Haberle}, R.~M.
+and 
+	{Hollingsworth}, J.~L. and {Kieffer}, H.~H. and {Titus}, T.~N.
+	},
+    title = "{Albedo of the south pole on Mars determined by topographic
+forcing of atmosphere dynamics}",
+  journal = {Nature},
+     year = 2005,
+   volume = 435,
+    pages = {184-188},
+      doi = {10.1038/nature03561},
+}
+
+@ARTICLE{Bott:05,
+   author = {{B{\"o}ttger}, H.~M. and {Lewis}, S.~R. and {Read}, P.~L.
+and 
+	{Forget}, F.},
+    title = "{The effects of the martian regolith on GCM water cycle
+simulations}",
+  journal = {Icarus},
+     year = 2005,
+   volume = 177,
+    pages = {174-189},
+      doi = {10.1016/j.icarus.2005.02.024},
+}
+
+@ARTICLE{Bott:04,
+   author = {{B{\"o}ttger}, H.~M. and {Lewis}, S.~R. and {Read}, P.~L.
+and 
+	{Forget}, F.},
+    title = "{The effect of a global dust storm on simulations of the
+Martian water cycle}",
+  journal = grl,
+     year = 2004,
+   volume = 31,
+    pages = {22702},
+      doi = {10.1029/2004GL021137},
+}
+
+
+@ARTICLE{Fouc:07,
+   author = {
+Fouchet,  T. and Lellouch E. and  Ignatiev, N.I. and  {Forget, F.} 
+and  Titov, D.V. and 
+Tschimmel, M. and  Montmessin, F. and  Formisano, V. and  
+Giuranna, M. and  Maturilli A. and Encrenaz, T.
+},
+    title = "{
+Martian water Vapor: Mars Express PFS/LW Observations.
+}",
+  journal = {{\it Icarus}, in press},
+     year = 2007,
+}
+
+@ARTICLE{Levr:07,
+   author = {Levrard, B. and {Forget, F.} and  Montmessin, F. and Laskar,
+J.},
+    title = "{
+Recent formation and evolution of northern Martian polar layered
+deposits as inferred from a Global Climate Model.
+}",
+  journal = {{Jour. Geophys. Res.}, in press},
+     year = 2007,
+}
+
+@ARTICLE{Bert:02,
+   author = {{Bertaux}, J.-L. and {Montmessin}, F.},
+    title = "{Isotopic fractionation through water vapor condensation:
+The Deuteropause, a cold trap for deuterium in the atmosphere of Mars}",
+ journal = jgr,
+     year = 2001,
+   volume = 106,
+    pages = {32879-32884},
+      doi = {10.1029/2000JE001358},
+}
+
+@ARTICLE{Urba:05,
+   author = {{Urban}, J. and {Dassas}, K. and {Forget}, F. and {Ricaud},
+P.
+	},
+    title = "{Retrieval of vertical constituents and temperature
+profiles from passive submillimeter wave limb observations of the
+Martian atmosphere: a feasibility study}",
+  journal = {Applied Optics},
+     year = 2005,
+   volume = 44,
+    pages = {2438-2455},
+}
+
+@ARTICLE{Fouc:00,
+   author = {{Fouchet}, T. and {Lellouch}, E.},
+    title = "{Vapor Pressure Isotope Fractionation Effects in Planetary
+Atmospheres: Application to Deuterium}",
+  journal = {Icarus},
+     year = 2000,
+   volume = 144,
+    pages = {114-123},
+      doi = {10.1006/icar.1999.6264},
+}
+
+
+@ARTICLE{Ange:05,
+   author = {{Angelats i Coll}, M. and {Forget}, F. and {L{\'o}pez-Valverde}, M.~A. and 
+   {Gonz{\'a}lez-Galindo}, F.},
+       title = "{The first Mars thermospheric general circulation model: The Martian atmosphere from the ground to 240 km}",
+         journal = grl,
+      year = 2005,
+     volume = 32,
+         pages = {4201},
+       doi = {10.1029/2004GL021368},
+}
+
+
+
+@ARTICLE{Maga:99,
+   author = {{Magalhaes}, J.~A. and {Schofield}, J.~T. and {Seiff},
+A.
+	},
+    title = "{Results of the Mars Pathfinder atmospheric structure
+investigation}",
+  journal = jgr,
+     year = 1999,
+   volume = 104,
+    pages = {8943-8956},
+      doi = {10.1029/1998JE900041},
+}
+
+@ARTICLE{Arie:87,
+   author = {{Arie}, E. and {Lacome}, N. and {Levy}, A.},
+    title = "{Measurement of $CO_2$ line broadening in the 10.4-micron
+laser transition at low temperatures}",
+  journal = {Applied Optics},
+     year = 1987,
+   volume = 26,
+    pages = {1636-1640},
+}
+
+@ARTICLE{Roth:05,
+   author = {{Rothman}, L.~S. and {Jacquemart}, D. and {Barbe}, A. and
+{Benner}, D.~C. and 
+	{Birk}, M. and {Brown}, L.~R. and {Carleer}, M.~R. and {Chackerian},
+C. and 
+	{Chance}, K. and {Coudert}, L.~H. and {Dana}, V. and {Devi}, V.~M.
+and 
+	{Flaud}, J.~M. and {Gamache}, R.~R. and {Goldman}, A. and
+{Hartmann}, J.~M. and 
+	{Jucks}, K.~W. and {Maki}, A.~G. and {Mandin}, J.~Y. and {Massie},
+S.~T. and 
+	{Orphal}, J. and {Perrin}, A. and {Rinsland}, C.~P. and {Smith},
+M.~A.~H. and 
+	{Tennyson}, J. and {Tolchenov}, R.~N. and {Toth}, R.~A. and 
+	{Vander Auwera}, J. and {Varanasi}, P. and {Wagner}, G.},
+    title = "{The HITRAN 2004 molecular spectroscopic database}",
+  journal = {Journal of Quantitative Spectroscopy and Radiative
+Transfer},
+     year = 2005,
+   volume = 96,
+    pages = {139-204},
+}
+
+@ARTICLE{Obri:97,
+   author = { {O'Brien}, D. M. and  Mitchell, R. M. and  English, S. A. and 
+   Da Costa, G. A. },
+    title = "{
+Airborne Measurements of Air Mass from {O$_2$} A-Band Absorption Spectra
+}",
+  journal = {Jour. of Atmos. and Oceanic Technology},
+     year = 1997,
+   volume = 15,
+    pages = {1272-1286},
+}
+
+@ARTICLE{Cris:04,
+   author = {{Crisp}, D. and {Atlas}, R.~M. and {Breon}, F.-M.
+   and {Brown}, L.~R. and 
+   {Burrows}, J.~P. and {Ciais}, P. and
+   {Connor}, B.~J. and {Doney}, S.~C. and 
+   {Fung}, I.~Y. and {Jacob}, D.~J. and {Miller}, C.~E.
+and {O'Brien}, D. and 
+{Pawson}, S. and {Randerson}, J.~T. and
+{Rayner}, P. and {Salawitch}, R.~J. and 
+{Sander}, S.~P. and {Sen}, B. and {Stephens},
+G.~L. and {Tans}, P.~P. and 
+{Toon}, G.~C. and {Wennberg}, P.~O.
+and {Wofsy}, S.~C. and {Yung}, Y.~L. and 
+{Kuang}, Z. and {Chudasama}, B. and
+{Sprague}, G. and {Weiss}, B. and 
+{Pollock}, R. and {Kenyon}, D. and {Schroll},
+S.},
+    title = "{The Orbiting Carbon Observatory
+(OCO) mission}",
+  journal = {Advances in Space Research},
+       year = 2004,
+      volume = 34,
+      pages = {700-709},
+        doi =
+{10.1016/j.asr.2003.08.062},
+}
+
+@ARTICLE{Boug:06grl,
+   author = {{Bougher}, S.~W. and {Bell}, J.~M. and {Murphy}, J.~R. and
+{Lopez-Valverde}, M.~A. and 
+	{Withers}, P.~G.},
+    title = "{Polar warming in the Mars thermosphere: Seasonal
+variations owing to changing insolation and dust distributions}",
+  journal = grl,
+     year = 2006,
+   volume = 33,
+    pages = {2203-+},
+      doi = {10.1029/2005GL024059},
+}
+
+
+@ARTICLE{Mill:07,
+   author = {{Millour}, E. and Forget, F.  and {Gonz{\'a}lez-Galindo},
+F. and 
+	{Spiga}, A. and {Lewis}, S.~R. and {Montabone}, L. and {Read}, P.~L.
+and 
+	{L{\'o}pez-Valverde}, M.~A. and {Gilli}, G. and {Desjean}, M.-C. and
+
+	{Huot}, J.-P. and {McD/Gcm Development Team}},
+    title = "{The Mars Climate Database (Version 4.2)}",
+  journal = {European Mars Science and Exploration Conference, ESTEC,
+The Netherlands, 12 - 16 November, 2007},
+     year = 2007,
+}
+
+
+@ARTICLE{Boug:07,
+   author = {{Bougher}, S.~W. and {Bell}, J.~M. and {Steers}, B. and
+{Murphy}, J.~R. and 
+	{Keating}, G.~M.},
+    title = "{Winter Polar Warming in the Mars Thermosphere}",
+  journal = {LPI Contributions},
+     year = 2007,
+   volume = 1353,
+    pages = {3027-+},
+}
+
+@INPROCEEDINGS{Keat:07,
+   author = {{Keating}, G.~M. and {Bougher}, S.~W. and {Theriot}, M.~E.
+and 
+	{Tolson}, R.~H. and {Zurek}, R.~W. and {Blanchard}, R.~C. and 
+	{Murphy}, J.~R. and {Bertaux}, J.-L.},
+    title = "{Mars Neutral Upper Atmosphere Temporal and Spatial
+Variations Discovered from the Accelerometer Science Experiment Aboard
+Mars Reconnaissance Orbiter}",
+booktitle = {Lunar and Planetary Institute Conference Abstracts},
+     year = 2007,
+   series = {Lunar and Planetary Institute Conference Abstracts},
+   volume = 38,
+    pages = {2074-+},
+}
+
+@INPROCEEDINGS{Ther:06,
+   author = {{Theriot}, M. and {Keating}, G. and {Blanchard}, R. and
+{Bougher}, S. and 
+	{Zurek}, R. and {Tolson}, R. and {Murphy}, J. and {Forget}, F. and 
+	{Bertaux}, J.},
+    title = "{Interannual Comparison of Temporal and Spatial Structure
+in the Martian Thermosphere from Atmospheric Accelerometer Measurements
+of Mars Reconnaissance Orbiter (MRO) during Aerobraking and Stellar
+Occultation Measurements from the SPICAM Ultraviolet Infrared
+Atmospheric Spectrometer of Mars Express (MEX)}",
+booktitle = {AAS/Division for Planetary Sciences Meeting Abstracts},
+     year = 2006,
+   volume = 38,
+    pages = {73.02},
+}
+
+@ARTICLE{Mont:07clouds,
+   author = {{Montmessin}, F. and {Gondet}, B. and {Bibring}, J.-P. and
+{Langevin}, Y. and 
+	{Drossart}, P. and {Forget}, F. and {Fouchet}, T.},
+    title = "{Hyperspectral imaging of convective {CO$_{2}$} ice clouds in
+the equatorial mesosphere of Mars}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+    pages = {11-+},
+      doi = {10.1029/2007JE002944},
+}
+
+@ARTICLE{Mont:07cap,
+   author = {{Montmessin}, F. and {Haberle}, R.~M. and {Forget}, F. and
+{Langevin}, Y. and 
+	{Clancy}, R.~T. and {Bibring}, J.-P.},
+    title = "{On the origin of perennial water ice at the south pole of
+Mars: A precession-controlled mechanism?}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2007JE002902},
+}
+
+@ARTICLE{Quem:06,
+   author = {{Qu{\'e}merais}, E. and {Bertaux}, J.-L. and {Korablev}, O.
+and 
+	{Dimarellis}, E. and {Cot}, C. and {Sandel}, B.~R. and {Fussen}, D.
+	},
+    title = "{Stellar occultations observed by SPICAM on Mars Express}",
+ journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+    pages = {9-+},
+      doi = {10.1029/2005JE002604},
+   adsurl = {http://adsabs.harvard.edu/abs/2006JGRE..11109S04Q},
+  adsnote = {Provided by the Smithsonian/NASA Astrophysics Data System}
+}
+
+@ARTICLE{Yosh:96,
+   author = {{Yoshino}, K. and {Esmond}, J.~R. and {Sun}, Y. and
+{Parkinson}, W.~H. and 
+	{Ito}, K. and {Matsui}, T.},
+    title = "{Absorption cross section measurements of carbon dioxide in
+the wavelength region 118.7-175.5 nm and the temperature dependence.}",
+  journal = {Journal of Quantitative Spectroscopy and Radiative
+Transfer},
+     year = 1996,
+   volume = 55,
+    pages = {53-60},
+}
+
+
+@book{Tikh:77,
+   author = {Tikhonov, A. N.  and Arsenin, V. Y. },
+   publisher = {V. H. Winston and Sons (distributed by Wiley, New York)},
+   title = {Solutions of ill posed problems},
+   year = {1977}
+}
+
+@techreport{Thol:06,
+author = {Thollot, P. },
+institution = {Service d'Aeronomie},
+title = {Am{\'e}lioration du traitement des occultations stellaires
+SPICAM},
+type = {L3 Project report},
+year = {2006}
+}
+
+@ARTICLE{Kora:01,
+   author = {{Korablev}, O.~I. and {Bertaux}, J.-L. and {Dubois},
+J.-P.},
+    title = "{Occultation of stars in the UV: Study of the atmosphere of
+Mars}",
+  journal = jgr,
+     year = 2001,
+   volume = 106,
+    pages = {7597-7610},
+      doi = {10.1029/2000JE001298},
+}
+
+@ARTICLE{With:06,
+   author = {{Withers}, P. and {Smith}, M.~D.},
+    title = "{Atmospheric entry profiles from the Mars Exploration
+Rovers Spirit and Opportunity}",
+  journal = {Icarus},
+     year = 2006,
+   volume = 185,
+    pages = {133-142},
+      doi = {10.1016/j.icarus.2006.06.013},
+}
+
+@ARTICLE{Smit:06,
+   author = {{Smith}, M.~D. and {Wolff}, M.~J. and {Spanovich}, N. and
+{Ghosh}, A. and 
+	{Banfield}, D. and {Christensen}, P.~R. and {Landis}, G.~A. and 
+	{Squyres}, S.~W.},
+    title = "{One Martian year of atmospheric observations using MER
+Mini-TES}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {12-+},
+      doi = {10.1029/2006JE002770},
+}
+
+@ARTICLE{Wils:02,
+   author = {{Wilson}, R.~J.},
+    title = "{Evidence for nonmigrating thermal tides in the Mars upper
+atmosphere from the Mars Global Surveyor Accelerometer Experiment}",
+  journal = grl,
+     year = 2002,
+   volume = 29,
+    pages = {24-1},
+}
+
+@ARTICLE{Lope:98,
+   author = {{L{\'o}pez-Valverde}, M.~A. and {Edwards}, D.~P. and
+{L{\'o}pez-Puertas}, M. and 
+	{Rold{\'a}n}, C.},
+    title = "{Non-local thermodynamic equilibrium in general circulation
+models of the Martian atmosphere 1. Effects of the local thermodynamic
+equilibrium approximation on thermal cooling and solar heating}",
+  journal = jgr,
+     year = 1998,
+   volume = 103,
+    pages = {16799-16812},
+      doi = {10.1029/98JE01601},
+}
+
+@ARTICLE{Boug:94,
+   author = {{Bougher}, S.~W. and {Hunten}, D.~M. and {Roble}, R.~G.},
+    title = "{CO2 cooling in terrestrial planet thermospheres}",
+  journal = jgr,
+     year = 1994,
+   volume = 99,
+    pages = {14609-+},
+}
+
+@ARTICLE{Boug:99,
+   author = {{Bougher}, S.~W. and {Engel}, S. and {Roble}, R.~G. and
+{Foster}, B.
+	},
+    title = "{Comparative terrestrial planet thermospheres 2. Solar
+cycle variation of global structure and winds at equinox}",
+  journal = jgr,
+     year = 1999,
+   volume = 104,
+    pages = {16591-16611},
+      doi = {10.1029/1998JE001019},
+}
+
+@misc{Lope:01,
+   author = {Lopez-Valverde, M. A. and Lopez-Puertas, M.},
+   howpublished = {{ESA contract 11369 technical report}},
+   title = {
+Amospheric non-LTE effects and their parameterization for Mars
+},
+   year = {2001}
+}
+
+@ARTICLE{Stew:92,
+   author = {{Stewart}, A.~I.~F. and {Alexander}, M.~J. and {Meier},
+R.~R. and 
+	{Paxton}, L.~J. and {Bougher}, S.~W. and {Fesen}, C.~G.},
+    title = "{Atomic oxygen in the Martian thermosphere}",
+  journal = jgr,
+     year = 1992,
+   volume = 97,
+    pages = {91-102},
+}
+
+@ARTICLE{Nair:94,
+   author = {{Nair}, H. and {Allen}, M. and {Anbar}, A.~D. and {Yung},
+Y.~L. and 
+	{Clancy}, R.~T.},
+    title = "{A photochemical model of the martian atmosphere}",
+  journal = {Icarus},
+     year = 1994,
+   volume = 111,
+    pages = {124-150},
+      doi = {10.1006/icar.1994.1137},
+}
+
+@INPROCEEDINGS{Lope:06,
+   author = {{L{\'o}pez-Valverde}, M.~A. and {Gonz{\'a}lez-Galindo}, F.
+and 
+	{Forget}, F.},
+    title = "{1-D and 3-D modelling of the upper atmosphere of Mars}",
+booktitle = {Mars Atmosphere Modelling and Observations},
+     year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean},
+M.~C. and 
+	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis},
+S.~R. and 
+	{Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+    pages = {623-+},
+}
+
+@ARTICLE{Stat:00,
+   author = {{States}, R.~J. and {Gardner}, C.~S.},
+    title = "{Thermal Structure of the Mesopause Region (80-105 km) at
+{40$^\circ$N} Latitude. Part I: Seasonal Variations.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2000,
+   volume = 57,
+    pages = {66-77},
+}
+
+@ARTICLE{Mccl:07,
+   author = {{McCleese}, D.~J. and {Schofield}, J.~T. and {Taylor},
+F.~W. and 
+	{Calcutt}, S.~B. and {Foote}, M.~C. and {Kass}, D.~M. and {Leovy},
+C.~B. and 
+	{Paige}, D.~A. and {Read}, P.~L. and {Zurek}, R.~W.},
+    title = "{Mars Climate Sounder: An investigation of thermal and
+water vapor structure, dust and condensate distributions in the
+atmosphere, and energy balance of the polar regions}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {5-+},
+      doi = {10.1029/2006JE002790},
+}
+
+@ARTICLE{Vonz:96,
+   author = {{von Zahn}, U. and {H{\"o}ffner}, J.},
+    title = "{Mesopause temperature profiling by potassium lidar}",
+  journal = grl,
+     year = 1996,
+   volume = 23,
+    pages = {141-144},
+      doi = {10.1029/95GL03688},
+}
+
+@ARTICLE{Sels:07,
+   author = {{Selsis}, F. and {Kasting}, J.~F. and {Levrard}, B. and
+{Paillet}, J. and 
+	{Ribas}, I. and {Delfosse}, X.},
+    title = "{Habitable planets around the star Gliese 581?}",
+  journal = {Astronomy and Astrophysics},
+     year = 2007,
+   volume = 476,
+    pages = {1373-1387},
+      doi = {10.1051/0004-6361:20078091},
+}
+
+@ARTICLE{Bert:06,
+   author = {{Bertaux}, J.-L. and {Korablev}, O. and {Perrier}, S. and
+{Qu{\'e}merais}, E. and 
+	{Montmessin}, F. and {Leblanc}, F. and {Lebonnois}, S. and {Rannou},
+P. and 
+	{Lef{\`e}vre}, F. and {Forget}, F. and {Fedorova}, A. and
+{Dimarellis}, E. and 
+	{Reberac}, A. and {Fonteyn}, D. and {Chaufray}, J.~Y. and {Guibert},
+S.
+	},
+    title = "{SPICAM on Mars Express: Observing modes and overview of UV
+spectrometer data and scientific results}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {10-+},
+      doi = {10.1029/2006JE002690},
+}
+
+@ARTICLE{Toma:99,
+   author = {{Tomasko}, M.~G. and {Doose}, L.~R. and {Lemmon}, M. and
+{Smith}, P.~H. and 
+	{Wegryn}, E.},
+    title = "{Properties of dust in the Martian atmosphere from the
+Imager on Mars Pathfinder}",
+  journal = jgr,
+     year = 1999,
+   volume = 104,
+    pages = {8987-9008},
+      doi = {10.1029/1998JE900016},
+}
+
+@ARTICLE{Gras:00,
+   author = {{Grassi}, D. and {Formisano}, V.},
+    title = "{IRIS Mariner 9 data revisited:2. Aerosol dust
+composition}",
+  journal = pss,
+     year = 2000,
+   volume = 48,
+    pages = {577-598},
+}
+
+@ARTICLE{Hami:05,
+   author = {{Hamilton}, V.~E. and {McSween}, H.~Y. and {Hapke}, B.},
+    title = "{Mineralogy of Martian atmospheric dust inferred from
+thermal infrared spectra of aerosols}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+    pages = {12006-+},
+      doi = {10.1029/2005JE002501},
+}
+
+@INPROCEEDINGS{Hans:03,
+   author = {{Hansen}, G.~B.},
+    title = "{Infrared Optical Constants of Martian Dust Derived from
+Martian Spectra}",
+booktitle = {Sixth International Conference on Mars},
+     year = 2003,
+   editor = {{Albee}, A.},
+    pages = {3194-+},
+}
+
+@ARTICLE{Wolf:03,
+   author = {{Wolff}, M.~J. and {Clancy}, R.~T.},
+    title = "{Constraints on the size of Martian aerosols from Thermal
+Emission Spectrometer observations}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {5097-+},
+      doi = {10.1029/2003JE002057},
+}
+
+@ARTICLE{Bell:00,
+   author = {{Bell}, J.~F. and {McSween}, H.~Y. and {Crisp}, J.~A. and
+{Morris}, R.~V. and 
+	{Murchie}, S.~L. and {Bridges}, N.~T. and {Johnson}, J.~R. and 
+	{Britt}, D.~T. and {Golombek}, M.~P. and {Moore}, H.~J. and 
+	{Ghosh}, A. and {Bishop}, J.~L. and {Anderson}, R.~C. and
+{Br{\"u}ckner}, J. and 
+	{Economou}, T. and {Greenwood}, J.~P. and {Gunnlaugsson}, H.~P. and 
+	{Hargraves}, R.~M. and {Hviid}, S. and {Knudsen}, J.~M. and 
+	{Madsen}, M.~B. and {Reid}, R. and {Rieder}, R. and {Soderblom}, L.
+	},
+    title = "{Mineralogic and compositional properties of Martian soil
+and dust: Results from Mars Pathfinder}",
+  journal = jgr,
+     year = 2000,
+   volume = 105,
+    pages = {1721-1756},
+      doi = {10.1029/1999JE001060},
+}
+ 
+@ARTICLE{Morr:06b,
+   author = {{Morris}, R.~V. and {Klingelh{\"o}fer}, G. and
+{Schr{\"o}der}, C. and 
+	{Rodionov}, D.~S. and {Yen}, A. and {Ming}, D.~W. and {de Souza},
+P.~A. and 
+	{Wdowiak}, T. and {Fleischer}, I. and {Gellert}, R. and {Bernhardt},
+B. and 
+	{Bonnes}, U. and {Cohen}, B.~A. and {Evlanov}, E.~N. and {Foh}, J.
+and 
+	{G{\"u}tlich}, P. and {Kankeleit}, E. and {McCoy}, T. and
+{Mittlefehldt}, D.~W. and 
+	{Renz}, F. and {Schmidt}, M.~E. and {Zubkov}, B. and {Squyres}, S.~W.
+and 
+	{Arvidson}, R.~E.},
+    title = "{M{\"o}ssbauer mineralogy of rock, soil, and dust at
+Meridiani Planum, Mars: Opportunity's journey across sulfate-rich
+outcrop, basaltic sand and dust, and hematite lag deposits}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+    pages = {12-+},
+      doi = {10.1029/2006JE002791},
+}
+
+@ARTICLE{Morr:06a,
+   author = {{Morris}, R.~V. and {Klingelh{\"o}fer}, G. and
+{Schr{\"o}der}, C. and 
+	{Rodionov}, D.~S. and {Yen}, A. and {Ming}, D.~W. and {de Souza},
+P.~A. and 
+	{Fleischer}, I. and {Wdowiak}, T. and {Gellert}, R. and {Bernhardt},
+B. and 
+	{Evlanov}, E.~N. and {Zubkov}, B. and {Foh}, J. and {Bonnes}, U. and
+	{Kankeleit}, E. and {G{\"u}tlich}, P. and {Renz}, F. and {Squyres},
+S.~W. and 
+	{Arvidson}, R.~E.},
+    title = "{M{\"o}ssbauer mineralogy of rock, soil, and dust at Gusev
+crater, Mars: Spirit's journey through weakly altered olivine basalt on
+the plains and pervasively altered basalt in the Columbia Hills}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+    pages = {2-+},
+      doi = {10.1029/2005JE002584},
+}
+
+@ARTICLE{Goetz:05,
+   author = {{Goetz}, W. and {Bertelsen}, P. and {Binau}, C.~S. and
+{Gunnlaugsson}, H.~P. and 
+	{Hviid}, S.~F. and {Kinch}, K.~M. and {Madsen}, D.~E. and {Madsen},
+M.~B. and 
+	{Olsen}, M. and {Gellert}, R. and {Klingelh{\"o}fer}, G. and 
+	{Ming}, D.~W. and {Morris}, R.~V. and {Rieder}, R. and {Rodionov},
+D.~S. and 
+	{de Souza}, P.~A. and {Schr{\"o}der}, C. and {Squyres}, S.~W. and 
+	{Wdowiak}, T. and {Yen}, A.},
+    title = "{Indication of drier periods on Mars from the chemistry and
+mineralogy of atmospheric dust}",
+  journal = {Nature},
+     year = 2005,
+   volume = 436,
+    pages = {62-65},
+      doi = {10.1038/nature03807},
+}
+
+@ARTICLE{Mart:95,
+   author = {{Martin}, T.~Z.},
+    title = "{Mass of dust in the Martian atmosphere}",
+  journal = jgr,
+     year = 1995,
+   volume = 100,
+    pages = {7509-7512},
+}
+
+@ARTICLE{Neuk:07,
+   author = {{Neukum}, G. and {Behnke}, T. and 
+	   	{Duxbury}, T.~C. and {Eichentopf}, K. and {Flohrer}, J. and 
+		{Gasselt}, S.~V. and {Giese}, B. and {Gwinner}, K. and {Hauber}, E. and 
+		{Hoffmann}, H. and {Hoffmeister}, A. and {K{\"o}hler}, U. and 
+		{Matz}, K.-D. and {McCord}, T.~B. and {Mertens}, V. and {Oberst}, J. and 
+		{Pischel}, R. and {Reiss}, D. and {Ress}, E. and {Roatsch}, T. and 
+		{Saiger}, P. and {Scholten}, F. and {Schwarz}, G. and {Stephan}, K. and 
+		{W{\"a}hlisch}, M.},
+    title = "{The high-resolution stereo camera (HRSC) experiment on Mars Express: Instrument aspects and experiment conduct from interplanetary cruise through the nominal mission}",
+    journal = pss,
+    year = 2007,
+    volume = 55,
+    pages = {928-952},
+    doi = {10.1016/j.pss.2006.12.003},
+}
+
+@ARTICLE{Mcew:07,
+  author = {{McEwen}, A.~S. and {Eliason}, E.~M. and {Bergstrom}, J.~W. and 
+   	{Bridges}, N.~T. and {Hansen}, C.~J. and {Delamere}, W.~A. and 
+	{Grant}, J.~A. and {Gulick}, V.~C. and {Herkenhoff}, K.~E. and 
+	{Keszthelyi}, L. and {Kirk}, R.~L. and {Mellon}, M.~T. and {Squyres}, S.~W. and 
+	{Thomas}, N. and {Weitz}, C.~M.},
+  title = "{Mars Reconnaissance Orbiter's High Resolution Imaging Science Experiment (HiRISE)}",
+  journal = jgr,
+  year = 2007,
+  volume = 112,
+  number = {E11},
+  pages = {5-+},
+  doi = {10.1029/2005JE002605},
+}
+
+@ARTICLE{Murc:07,
+   author = {{Murchie}, S. and {Arvidson}, R. and {Bedini}, P. and {Beisser}, K. and 
+   	{Bibring}, J.-P. and {Bishop}, J. and {Boldt}, J. and {Cavender}, P. and 
+	{Choo}, T. and {Clancy}, R.~T. and {Darlington}, E.~H. and {Des Marais}, D. and 
+	{Espiritu}, R. and {Fort}, D. and {Green}, R. and {Guinness}, E. and 
+	{Hayes}, J. and {Hash}, C. and {Heffernan}, K. and {Hemmler}, J. and 
+	{Heyler}, G. and {Humm}, D. and {Hutcheson}, J. and {Izenberg}, N. and 
+	{Lee}, R. and {Lees}, J. and {Lohr}, D. and {Malaret}, E. and 
+	{Martin}, T. and {McGovern}, J.~A. and {McGuire}, P. and {Morris}, R. and 
+	{Mustard}, J. and {Pelkey}, S. and {Rhodes}, E. and {Robinson}, M. and 
+	{Roush}, T. and {Schaefer}, E. and {Seagrave}, G. and {Seelos}, F. and 
+	{Silverglate}, P. and {Slavney}, S. and {Smith}, M. and {Shyong}, W.-J. and 
+	{Strohbehn}, K. and {Taylor}, H. and {Thompson}, P. and {Tossman}, B. and 
+	{Wirzburger}, M. and {Wolff}, M.},
+   title = "{Compact Reconnaissance Imaging Spectrometer for Mars (CRISM) on Mars Reconnaissance Orbiter (MRO)}",
+   journal = {Journal of Geophysical Research (Planets)},
+   year = 2007,
+   volume = 112,
+   number = {E11},
+   pages = {5-+},
+   doi = {10.1029/2006JE002682},
+}
+
+@book{Kond:65,
+	author = {Kondratyev , K.~Y.},
+	publisher = {Pergamon Press, Oxford},
+	title = {Radiative heat exchange in the atmosphere},
+	year = {1965},
+}
+
+@article{Dozi:90,
+	author = {{Dozier}, J. and {Frew}, J.}, 
+	title = "{Rapid calculation of terrain parameters for radiation modeling from digital elevation data}", 
+	journal = {\protect{IEEE} Transactions on Geoscience and Remote Sensing},
+	year = 1990,
+	volume =  28,
+	number = 5, 
+	pages = {963-969},
+}
+
+@article{Hay:85,
+	author = {Hay, J.~E. and McKay, D.~C.}, 
+	title = "{Estimating Solar Irradiance on Inclined Surfaces: A Review and Assessment of Methodologies}", 
+	journal = {International Journal of Sustainable Energy},
+	year = 1985,
+	volume =  {3-4},
+	pages = {203-240},
+}
+
+@book{Mune:04,
+	author = {Muneer, T.},
+	publisher = {Butterworth-Heinemann},
+	title = {Solar Radiation and Daylight Models},
+	year = {2004}
+}
+
+@book{Capd:88,
+	author = {Capderou, M.},
+	publisher = {Office des publications universitaires, Alger},
+	title = {Atlas solaire de l'Alg\'erie},
+	year = {1988}
+}
+
+@article{Sand:97,
+	author = {Sandmeier, S. and Itten, K.~I.}, 
+	title = "{A physically-based model to correct atmospheric and illumination effects in optical satellite data of rugged terrain}", 
+	journal = {\protect{IEEE} Transactions on Geoscience and Remote Sensing},
+	year = 1997,
+	volume = 35,
+	number = 3, 
+	pages = {708-717},
+	doi={10.1109/36.581991},
+}
+ 
+@INPROCEEDINGS{Hay:78,
+	author = {Hay, J.~E. and Davies, J.~A.},
+        title = "{Calculation of the solar radiation incident on an inclined surface}",
+	booktitle = {Proc. First Canadian Solar Radiation Data Workshop},
+	year = 1978,
+	pages = {59-72},
+	editor = {{Hay, J.~E. and Won, T.~K., Toronto, Ontario, Canada}},
+}
+
+@ARTICLE{Bird:86,
+   author = {{Bird}, R.~E. and {Riordan}, C.},
+   title = "{Simple Solar Spectral Model for Direct and Diffuse Irradiance on Horizontal and Tilted Planes at the Earth's Surface for Cloudless Atmospheres}",
+   journal = {Journal of Applied Meteorology},
+   year = 1986,
+   volume = 25,
+   pages = {87-97},
+}
+
+@article{Pere:90,
+  title={{Modeling daylight availability and irradiance components from direct and global irradiance}},
+  author={Perez, R. and Ineichen, P. and Seals, R. and Michalsky, J. and Stewart, R.},
+  journal={Solar Energy},
+  volume={44},
+  number={5},
+  pages={271--289},
+  year={1990}
+}
+
+@ARTICLE{Li:00,
+   author = {Li, D.~H.~W. and Lam, J.~C.},
+   title = "{Evaluation of slope irradiance and illuminance models against measured Hong Kong data}",
+   journal = {Building and Environment},
+   year = 2000,
+   volume = 35,
+   number=6,
+   pages = {501-509},
+}
+
+@ARTICLE{Kluc:79,
+   author = {Klucher, T.~M.},
+   title = "{Evaluation of models to predict insolation on tilted surfaces}",
+   journal = {Solar Energy},
+   year = 1979,
+   volume = 23,
+   pages = {111-114},
+}
+
+@ARTICLE{Tran:04,
+   author = {Tran, T.~T. and Rannou, P.},
+   title = "{Comparing 3D spherical Monte-Carlo and 2-stream parallel plane simulation of far-field backscattering image of Titan}",
+   journal = {Notes du Pole de Plan\'etologie IPSL},
+   year = 2004,
+}
+
+@ARTICLE{Mull:05,
+   author = {M{\"u}ller, M.~D. and Scherer, D.},
+   title = "{A Grid and Subgrid Scale Radiation Parameterization of Topographic Effects for Mesoscale Weather Forecast Models}",
+   journal = mwr,
+   year = 2005,
+   volume = 133,
+   pages = {1431-1442}
+}
+
+@ARTICLE{Senk:07,
+   author = {{Senkova}, A.~V. and {Rontu}, L. and {Savij{\"a}rvi}, H.},
+    title = "{Parametrization of orographic effects on surface radiation in HIRLAM}",
+  journal = {Tellus Series A},
+     year = 2007,
+   volume = 59,
+    pages = {279-291},
+      doi = {10.1111/j.1600-0870.2007.00235.x},
+}
+
+@ARTICLE{Savi:05,
+   author = {{Savij{\"a}rvi}, H. and {Crisp}, D. and {Harri}, A.-M.},
+    title = "{Effects of CO2 and dust on present-day solar radiation and climate on Mars}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2005,
+   volume = 131,
+    pages = {2907-2922},
+}
+
+@ARTICLE{Beye:03,
+   author = {{Beyer}, R.~A. and {McEwen}, A.~S. and {Kirk}, R.~L.},
+    title = "{Meter-scale slopes of candidate MER landing sites from point photoclinometry}",
+  journal = jgr,
+     year = 2003,
+   volume = 108,
+    pages = {8085-+},
+      doi = {10.1029/2003JE002120},
+}
+
+@ARTICLE{Ahar:06,
+   author = {{Aharonson}, O. and {Schorghofer}, N.},
+    title = "{Subsurface ice on Mars with rough topography}",
+  journal = jgr,
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {11007-+},
+      doi = {10.1029/2005JE002636},
+}
+
+@ARTICLE{Golo:03,
+   author = {{Golombek}, M.~P. and {Grant}, J.~A. and {Parker}, T.~J. and 
+	{Kass}, D.~M. and {Crisp}, J.~A. and {Squyres}, S.~W. and {Haldemann}, A.~F.~C. and 
+	{Adler}, M. and {Lee}, W.~J. and {Bridges}, N.~T. and {Arvidson}, R.~E. and 
+	{Carr}, M.~H. and {Kirk}, R.~L. and {Knocke}, P.~C. and {Roncoli}, R.~B. and 
+	{Weitz}, C.~M. and {Schofield}, J.~T. and {Zurek}, R.~W. and 
+	{Christensen}, P.~R. and {Fergason}, R.~L. and {Anderson}, F.~S. and 
+	{Rice}, J.~W.},
+    title = "{Selection of the Mars Exploration Rover landing sites}",
+  journal = jgr,
+     year = 2003,
+   volume = 108,
+    pages = {8072-+},
+      doi = {10.1029/2003JE002074},
+}
+
+@ARTICLE{Wils:08,
+   author = {{Wilson}, R.~J. and {Lewis}, S.~R. and {Montabone}, L. and
+{Smith}, M.~D.
+	},
+    title = "{Influence of water ice clouds on Martian tropical
+atmospheric temperatures}",
+  journal = grl,
+     year = 2008,
+   volume = 35,
+    pages = {7202-+},
+      doi = {10.1029/2007GL032405},
+}
+
+@ARTICLE{Scho:06,
+   author = {{Schorghofer}, N. and {Edgett}, K.~S.},
+   title = "{Seasonal surface frost at low latitudes on Mars}",
+   journal = {Icarus},
+   year = 2006,
+   volume = 180,
+   pages = {321-334},
+   doi = {10.1016/j.icarus.2005.08.022},
+}
+
+@ARTICLE{Ye:90,
+   author = {{Ye}, Z.~J. and {Segal}, M. and {Pielke}, R.~A.},
+    title = "{A comparative study of daytime thermally induced upslope flow on Mars and earth}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 1990,
+   volume = 47,
+    pages = {612-628},
+}
+
+@INPROCEEDINGS{Siil:06,
+   author = {{Siili}, T. and {J{\"a}rvenoja}, S. and {Kauhanen}, J. and {Savij{\"a}rvi}, H.
+	},
+    title = "{Mars limited area model: status report}",
+booktitle = {Mars Atmosphere Modelling and Observations},
+     year = 2006,
+   editor = {{Forget}, F. and {Lopez-Valverde}, M.~A. and {Desjean}, M.~C. and 
+	{Huot}, J.~P. and {Lefevre}, F. and {Lebonnois}, S. and {Lewis}, S.~R. and 
+	{Millour}, E. and {Read}, P.~L. and {Wilson}, R.~J.},
+    pages = {129-+},
+}
+
+@ARTICLE{Wing:06,
+   author = {{Wing}, D.~R. and {Austin}, G.~L.},
+    title = "{Description of the University of Auckland global Mars mesoscale meteorological model}",
+  journal = {Icarus},
+     year = 2006,
+   volume = 185,
+    pages = {370-382},
+      doi = {10.1016/j.icarus.2006.07.016},
+}
+
+@ARTICLE{Rich:07,
+   author = {{Richardson}, M.~I. and {Toigo}, A.~D. and {Newman}, C.~E.},
+    title = "{PlanetWRF: A general purpose, local to global numerical model for planetary atmospheric and climate dynamics}",
+  journal = jgr,
+     year = 2007,
+   volume = 112,
+   number = {E09001},
+      doi = {10.1029/2005JE002636},
+}
+
+@ARTICLE{Tyle:05,
+   author = {{Tyler}, D. and {Barnes}, J.~R.},
+    title = "{A mesoscale model study of summertime atmospheric circulations in the north polar region of Mars}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {6007-+},
+      doi = {10.1029/2004JE002356},
+}
+
+@ARTICLE{Toig:02dust,
+   author = {{Toigo}, A.~D. and {Richardson}, M.~I. and {Wilson}, R.~J. and 
+	{Wang}, H. and {Ingersoll}, A.~P.},
+    title = "{A first look at dust lifting and dust storms near the south pole of Mars with a mesoscale model}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+    pages = {5050-+},
+      doi = {10.1029/2001JE001592},
+}
+
+@ARTICLE{Kuzm:01,
+   author = {{Kuzmin}, R.~O. and {Greeley}, R. and {Rafkin}, S.~C.~R. and 
+	{Haberle}, R.},
+    title = "{Wind-Related Modification of Some Small Impact Craters on Mars}",
+  journal = {Icarus},
+     year = 2001,
+   volume = 153,
+    pages = {61-70},
+      doi = {10.1006/icar.2001.6654},
+}
+
+@ARTICLE{Fent:05,
+   author = {{Fenton}, L.~K. and {Toigo}, A.~D. and {Richardson}, M.~I.},
+    title = "{Aeolian processes in Proctor Crater on Mars: Mesoscale modeling of dune-forming winds}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {6005-+},
+      doi = {10.1029/2004JE002309},
+}
+
+@ARTICLE{Gree:08,
+   author = {{Greeley}, R. and {Whelley}, P.~L. and {Neakrase}, L.~D.~V. and 
+	{Arvidson}, R.~E. and {Bridges}, N.~T. and {Cabrol}, N.~A. and 
+	{Christensen}, P.~R. and {Di}, K. and {Foley}, D.~J. and {Golombek}, M.~P. and 
+	{Herkenhoff}, K. and {Knudson}, A. and {Kuzmin}, R.~O. and {Li}, R. and 
+	{Michaels}, T. and {Squyres}, S.~W. and {Sullivan}, R. and {Thompson}, S.~D.
+	},
+    title = "{Columbia Hills, Mars: Aeolian features seen from the ground and orbit}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+   number = {E12},
+    pages = {6-+},
+      doi = {10.1029/2007JE002971},
+}
+
+@ARTICLE{Rafk:04,
+   author = {{Rafkin}, S.~C.~R. and {Michaels}, T.~I. and {Haberle}, R.~M.
+	},
+    title = "{Meteorological predictions for the Beagle 2 mission to Mars}",
+  journal = grl,
+     year = 2004,
+   volume = 31,
+    pages = {1703-+},
+      doi = {10.1029/2003GL018966},
+}
+
+@ARTICLE{Kass:03,
+   author = {{Kass}, D.~M. and {Schofield}, J.~T. and {Michaels}, T.~I. and 
+	{Rafkin}, S.~C.~R. and {Richardson}, M.~I. and {Toigo}, A.~D.
+	},
+    title = "{Analysis of atmospheric mesoscale models for entry, descent, and landing}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {8090-+},
+      doi = {10.1029/2003JE002065},
+}
+
+@ARTICLE{Skam:08,
+   author = {{Skamarock}, W.~C. and {Klemp}, J.~B.},
+    title = "{A time-split nonhydrostatic atmospheric model for weather research and forecasting applications}",
+  journal = {Journal of Computational Physics},
+     year = 2008,
+   volume = 227,
+    pages = {3465-3485},
+      doi = {10.1016/j.jcp.2007.01.037},
+}
+
+@ARTICLE{Skam:06,
+   author = {{Skamarock}, W.~C.},
+    title = "{Positive-Definite and Monotonic Limiters for Unrestricted-Time-Step Transport Schemes}",
+  journal = {Monthly Weather Review},
+     year = 2006,
+   volume = 134,
+    pages = {2241-+},
+      doi = {10.1175/MWR3170.1},
+}
+
+@ARTICLE{Arak:66,
+   author = {{Arakawa}, A.},
+    title = "{Computational Design for Long-Term Numerical Integration of the Equations of Fluid Motion: Two-Dimensional Incompressible Flow. Part I}",
+  journal = {Journal of Computational Physics},
+     year = 1966,
+   volume = 1,
+    pages = {119-+},
+}
+
+@ARTICLE{Klem:07,
+   author = {{Klemp}, J.~B. and {Skamarock}, W.~C. and {Dudhia}, J.},
+    title = "{Conservative Split-Explicit Time Integration Methods for the Compressible Nonhydrostatic Equations}",
+  journal = {Monthly Weather Review},
+     year = 2007,
+   volume = 135,
+    pages = {2897-+},
+      doi = {10.1175/MWR3440.1},
+}
+
+@ARTICLE{Wick:02,
+   author = {{Wicker}, L.~J. and {Skamarock}, W.~C.},
+    title = "{Time-Splitting Methods for Elastic Models Using Forward Time Schemes}",
+  journal = {Monthly Weather Review},
+     year = 2002,
+   volume = 130,
+    pages = {2088-+},
+      doi = {10.1175/1520-0493(2002)130},
+}
+
+@ARTICLE{Hund:95,
+   author = {{Hundsdorfer}, W.},
+    title = "{A Positive Finite-Difference Advection Scheme}",
+  journal = {Journal of Computational Physics},
+     year = 1995,
+   volume = 117,
+    pages = {35-46},
+      doi = {10.1006/jcph.1995.1042},
+}
+
+@ARTICLE{Knie:07,
+   author = {{Knievel}, J.~C. and {Bryan}, G.~H. and {Hacker}, J.~P.},
+    title = "{Explicit Numerical Diffusion in the WRF Model}",
+  journal = {Monthly Weather Review},
+     year = 2007,
+   volume = 135,
+    pages = {3808-+},
+      doi = {10.1175/2007MWR2100.1},
+}
+
+@article{Smag:63,
+  author   = {Smagorinsky, J.},
+  journal  = {Mon. Weather Rev.},
+  pages    = {99--164},
+  title    = {General Circulation Experiments with the Primitive Equations. I. The Basic Experiment},
+  volume   = {91},
+  year     = {1963}
+}
+
+@INPROCEEDINGS{Forg:99icm5,
+   author = {{Forget}, F. and {Hourdin}, F. and {Hourdin}, C. and {Talagrand}, O.
+	},
+    title = "{Simulations of the Martian Seasonal Dust Cycle with a General Circulation Model}",
+booktitle = {The Fifth International Conference on Mars},
+     year = 1999,
+    pages = {6206-+},
+}
+
+
+@inproceedings{Forg:07emsec,
+	author = {Forget, F. and Millour, E. and Gonzalez-Galindo, F. and Spiga, A. and Lebonnois, S. and Hourdin, F. and Lewis, S.~R. and Montabone, L. and Read, P.~L. and Lefevre, F. and Montmessin, F.},
+	booktitle = {European Mars Science and Exploration Conference: Mars Express and ExoMars},
+	editor = {ESA},
+	title = {Modelling the present Mars climate system as observed by Mars Express},
+	year = {2007}
+}
+
+@INPROCEEDINGS{Rafk:03adj,
+   author = {{Rafkin}, S.~C.~R.},
+    title = "{The Effect of Convective Adjustment on the Global Circulation of Mars as Simulated by a General Circulation Model}",
+booktitle = {Sixth International Conference on Mars},
+     year = 2003,
+   editor = {{Albee}, A.},
+    pages = {3059-+},
+}
+
+@ARTICLE{Dimi:05,
+   author = {{Dimitrijevic}, M. and {Laprise}, R.},
+    title = "{Validation of the nesting technique in a regional climate model and sensitivity tests to the resolution of the lateral boundary conditions during summer}",
+  journal = {Climate Dynamics},
+     year = 2005,
+   volume = 25,
+    pages = {555-580},
+      doi = {10.1007/s00382-005-0023-6},
+}
+
+@article{Anti:06,
+  title={{Testing the downscaling ability of a one-way nested regional climate model in regions of complex topography}},
+  author={Antic, S. and Laprise, R. and Denis, B. and de El{\'\i}a, R.},
+  journal={Climate Dynamics},
+  volume={26},
+  number={2},
+  pages={305--325},
+  year={2006},
+}
+
+@ARTICLE{Putz:07,
+   author = {{Putzig}, N.~E. and {Mellon}, M.~T.},
+    title = "{Apparent thermal inertia and the surface heterogeneity of Mars}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 191,
+    pages = {68-94},
+      doi = {10.1016/j.icarus.2007.05.013},
+}
+
+@ARTICLE{Vasa:00,
+   author = {{Vasavada}, A.~R. and {Williams}, J.-P. and {Paige}, D.~A. and 
+	{Herkenhoff}, K.~E. and {Bridges}, N.~T. and {Greeley}, R. and 
+	{Murray}, B.~C. and {Bass}, D.~S. and {McBride}, K.~S.},
+    title = "{Surface properties of Mars' polar layered deposits and polar landing sites}",
+  journal = jgr,
+     year = 2000,
+   volume = 105,
+    pages = {6961-6970},
+      doi = {10.1029/1999JE001108},
+}
+
+@ARTICLE{Hebr:07,
+   author = {{H{\'e}brard}, E. and {Coll}, P. and {Montmessin}, F. and {Marticorena}, B. and 
+	{Bergametti}, G.},
+    title = "{Modelling the Aeolian Erosion Thresholds on Mars}",
+  journal = {LPI Contributions},
+     year = 2007,
+   volume = 1353,
+    pages = {3144-+},
+}
+
+@ARTICLE{Nayv:97,
+   author = {{Nayvelt}, L. and {Gierasch}, P.~J. and {Cook}, K.~H.},
+    title = "{Modeling and observations of Martian stationary waves.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 1997,
+   volume = 54,
+    pages = {986-1013},
+}
+
+@misc{Mill:08ddd,
+   author = {Millour, E. and Forget, F. and Lewis, S.~R.},
+   howpublished = {Mars Climate Database v4.3 Detailed Design Document, available on {\tt http://web.lmd.jussieu.fr/forget/dvd/docs}},
+   year = {2008}
+}
+
+@ARTICLE{Lewi:03,
+   author = {{Lewis}, S.~R. and {Read}, P.~L.},
+    title = "{Equatorial jets in the dusty Martian atmosphere}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {5034-+},
+      doi = {10.1029/2002JE001933},
+}
+
+@ARTICLE{Gier:71,
+   author = {{Gierasch}, P. and {Sagan}, C.},
+    title = "{A Preliminary Assessment of Martian Wind Regimes}",
+  journal = {Icarus},
+     year = 1971,
+   volume = 14,
+    pages = {312-+},
+}
+
+@ARTICLE{Ramp:04,
+   author = {{Rampanelli}, G. and {Zardi}, D. and {Rotunno}, R.},
+    title = "{Mechanisms of Up-Valley Winds.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2004,
+   volume = 61,
+    pages = {3097-3111},
+}
+
+@ARTICLE{Zang:02,
+   author = {{Z{\"a}ngl}, G.},
+    title = "{An Improved Method for Computing Horizontal Diffusion in a Sigma-Coordinate Model and Its Application to Simulations over Mountainous Topography}",
+  journal = {Monthly Weather Review},
+     year = 2002,
+   volume = 130,
+    pages = {1423-+},
+      doi = {10.1175/1520-0493(2002)130},
+}
+
+@ARTICLE{Inad:08,
+   author = {{Inada}, A. and {Garcia-Comas}, M. and {Altieri}, F. and {Gwinner}, K. and 
+	{Poulet}, F. and {Bellucci}, G. and {Keller}, H.~U. and {Markiewicz}, W.~J. and 
+	{Richardson}, M.~I. and {Hoekzema}, N. and {Neukum}, G. and 
+	{Bibring}, J.-P.},
+    title = "{Dust haze in Valles Marineris observed by HRSC and OMEGA on board Mars Express}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+   number = {E12},
+    pages = {2004-+},
+      doi = {10.1029/2007JE002893},
+}
+
+@ARTICLE{Odak:98,
+   author = {{Odaka}, M. and {Nakajima}, K. and {Takehiro}, S. and {Ishiwatari}, M. and 
+	{Hayashi}, Y.},
+    title = "{A numerical study of the Martian atmospheric convection with a two-dimensional anelastic model}",
+  journal = {Earth, Planets, and Space},
+     year = 1998,
+   volume = 50,
+    pages = {431-437},
+}
+
+@ARTICLE{Sorb:07,
+   author = {{Sorbjan}, Z.},
+    title = "{Statistics of shallow convection on Mars based on large-eddy simulations. Part 1: shearless conditions}",
+  journal = {Boundary-Layer Meteorology},
+     year = 2007,
+   volume = 123,
+    pages = {121-142},
+      doi = {10.1007/s10546-006-9128-7},
+}
+
+@ARTICLE{Toig:03dd,
+   author = {{Toigo}, A.~D. and {Richardson}, M.~I. and {Ewald}, S.~P. and 
+	{Gierasch}, P.~J.},
+    title = "{Numerical simulation of Martian dust devils}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {5047-+},
+      doi = {10.1029/2002JE002002},
+}
+
+@ARTICLE{Anto:07,
+   author = {{Antonelli}, M. and {Rotunno}, R.},
+    title = "{Large-Eddy Simulation of the Onset of the Sea Breeze}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2007,
+   volume = 64,
+    pages = {4445-+},
+      doi = {10.1175/2007JAS2261.1},
+}
+
+@ARTICLE{Savi:04,
+   author = {{Savij{\"a}rvi}, H. and {M{\"a}{\"a}tt{\"a}nen}, A. and {Kauhanen}, J. and 
+	{Harri}, A.-M.},
+    title = "{Mars Pathfinder: New data and new model simulations}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2004,
+   volume = 130,
+    pages = {669-683},
+}
+
+@ARTICLE{Ferr:03,
+   author = {{Ferri}, F. and {Smith}, P.~H. and {Lemmon}, M. and {Renn{\'o}}, N.~O.
+	},
+    title = "{Dust devils as observed by Mars Pathfinder}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {5133-+},
+      doi = {10.1029/2000JE001421},
+}
+
+@article{Dion:02,
+  title={{Numerical study of a Sahelian synoptic weather system: Initiation and mature stages of convection and its interactions with the large-scale dynamics}},
+  author={Diongue, A. and Lafore, JP and Redelsperger, JL and Roca, R.},
+  journal={Quarterly Journal of the Royal Meteorological Society},
+  volume={128},
+  number={584},
+  pages={1899--1927},
+  year={2002}
+}
+
+@ARTICLE{Peal:73,
+   author = {{Peale}, J.},
+    title = "{Water and the Martian W Cloud}",
+  journal = {Icarus},
+     year = 1973,
+   volume = 18,
+    pages = {497-+},
+}
+
+@ARTICLE{Bens:03,
+   author = {{Benson}, J.~L. and {Bonev}, B.~P. and {James}, P.~B. and {Shan}, K.~J. and 
+	{Cantor}, B.~A. and {Caplinger}, M.~A.},
+    title = "{The seasonal behavior of water ice clouds in the Tharsis and Valles Marineris regions of Mars: Mars Orbiter Camera Observations}",
+  journal = {Icarus},
+     year = 2003,
+   volume = 165,
+    pages = {34-52},
+      doi = {10.1016/S0019-1035(03)00175-1},
+}
+
+@ARTICLE{Mali:08,
+   author = {{Malin}, M.~C. and {Calvin}, W.~M. and {Cantor}, B.~A. and {Clancy}, R.~T. and 
+	{Haberle}, R.~M. and {James}, P.~B. and {Thomas}, P.~C. and 
+	{Wolff}, M.~J. and {Bell}, J.~F. and {Lee}, S.~W.},
+    title = "{Climate, weather, and north polar observations from the Mars Reconnaissance Orbiter Mars Color Imager}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 194,
+    pages = {501-512},
+      doi = {10.1016/j.icarus.2007.10.016},
+}
+
+@INPROCEEDINGS{Made:08mwcm,
+   author = {Madeleine, J.~B. and Forget F. and Spiga A. and Bibring J.~P. and Gondet B. and Jouglet D. and Vincendon M. and Langevin Y. and Poulet F. and Montmessin F. and Schmitt B.},
+    title = "{Mapping water ice cloud microphysics with OMEGA/Mars Express}",
+booktitle = {Mars Water Cycle Workshop},
+     year = 2008,
+   editor = {{Montmessin}, F.},
+}
+
+@INPROCEEDINGS{Wolf:08mwcm,
+   author = {Wolff, M.~J. and Clancy, R.~T. and Smith, M.~D. and the CRISM and MARCI team},
+    title = "{Insights into the Mars Water Cycle Through Retrievals of Aerosols and Ozone:
+The MARCI and CRISM Datasets}",
+booktitle = {Mars Water Cycle Workshop},
+     year = 2008,
+   editor = {{Montmessin}, F.},
+}
+
+@ARTICLE{Raph:03,
+   author = {{Raphael}, M.~N.},
+    title = "{The Santa Ana Winds of California}",
+  journal = {Earth Interactions},
+     year = 2003,
+   volume = 7,
+   number = 8,
+    pages = {080000-+},
+      doi = {10.1175/1087-3562(2003)007},
+}
+
+@ARTICLE{Maat:09,
+   author = {
+{M{\"a}{\"a}tt{\"a}nen}, A. 
+and Fouchet, T. 
+and Forni, O. 
+and Melchiorri, R. 
+and Forget, F. 
+and Savijarvi, H. 
+and Bibring, J.~P. 
+and Langevin, Y. 
+and Gondet, B. 
+and Formisano, V. 
+and Giuranna, M.},
+   title = {A study of the properties of a local dust storm with \protect{Mars Express} \protect{OMEGA} and \protect{PFS} data},
+  journal = {Icarus},
+     year = 2009,
+   volume = 201,
+   number = 2,
+    pages = {504-516},
+}
+
+@misc{Mont:08,
+   author = {Montabone, L. and Martinez-Alvarado, O. and Spiga, A. and Lewis, S. R. and Read, P. L. and Forget, F.},
+   howpublished = {EGU 2008, Abstract Number 10457},
+   title = {Meteorology of the 2001 Martian planet-encircling dust storm in global and mesoscale modelling with data assimilation},
+   year = {2008}
+}
+
+@INPROCEEDINGS{Smit:08mwcm,
+   author = {Smith, M.~D.},
+    title = "{Mars Water Vapor Climatology From MGS/TES}",
+booktitle = {Mars Water Cycle Workshop},
+     year = 2008,
+   editor = {{Montmessin}, F.},
+}
+
+@ARTICLE{Malt:08,
+   author = {{Maltagliati}, L. and {Titov}, D.~V. and {Encrenaz}, T. and 
+	{Melchiorri}, R. and {Forget}, F. and {Garcia-Comas}, M. and 
+	{Keller}, H.~U. and {Langevin}, Y. and {Bibring}, J.-P.},
+    title = "{Observations of atmospheric water vapor above the Tharsis volcanoes on Mars with the OMEGA/MEx imaging spectrometer}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 194,
+    pages = {53-64},
+      doi = {10.1016/j.icarus.2007.09.027},
+}
+
+@ARTICLE{Giur:08,
+   author = {{Giuranna}, M. and {Grassi}, D. and {Formisano}, V. and {Montabone}, L. and {Forget}, F. and {Zasova}, L.},
+    title = "{PFS/MEX observations of the condensing $CO_{2}$ south polar cap of Mars}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 197,
+    pages = {386-402},
+      doi = {10.1016/j.icarus.2008.05.019},
+}
+
+@misc{Sorb:08,
+   author = {Sorbjan, Z. and Wolff, M.~J. and Smith, M.~D.},
+   howpublished = {\textit{submitted to Icarus}},
+   title = {Temperature and turbulent heat flux profiles on Mars based on mini-TES observations},
+   year = {2008}
+}
+
+
+@article{Scor:56,
+  title={{Airflow over an isolated hill}},
+  author={Scorer, RS},
+  journal={Quart. J. Roy. Meteor. Soc},
+  volume={82},
+  pages={75--81},
+  year={1956}
+}
+
+@ARTICLE{Spig:09,
+   author = {{Spiga}, A. and {Forget}, F.},
+    title = "{A new model to simulate the Martian mesoscale and microscale atmospheric circulation: Validation and first results}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2009,
+   volume = 114,
+    pages = {E02009},
+      doi = {10.1029/2008JE003242},
+}
+
+@ARTICLE{Vinc:07,
+   author = {{Vincendon}, M. and {Langevin}, Y. and {Poulet}, F. and
+{Bibring}, J.-P. and 
+	{Gondet}, B.},
+    title = "{Recovery of surface reflectance spectra and evaluation of
+the optical depth of aerosols in the near-IR using a Monte Carlo
+approach: Application to the OMEGA observations of high-latitude regions
+of Mars}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002845},
+}
+
+@ARTICLE{Boug:06venus,
+   author = {{Bougher}, S.~W. and {Rafkin}, S. and {Drossart}, P.},
+    title = "{Dynamics of the Venus upper atmosphere: Outstanding
+problems and new constraints expected from Venus Express}",
+  journal = pss,
+     year = 2006,
+   volume = 54,
+    pages = {1371-1380},
+      doi = {10.1016/j.pss.2006.04.023},
+}
+
+@article{Lore:63,
+  title={{Deterministic Nonperiodic Flow}},
+  author={Lorenz, E.N.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={20},
+  number={2},
+  pages={130--141},
+  year={1963},
+  publisher={American Meteorological Society}
+}
+
+@article{Wyng:04,
+  title={{Toward Numerical Modeling in the “Terra Incognita”}},
+  author={Wyngaard, J.C.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={61},
+  number={14},
+  pages={1816--1826},
+  year={2004},
+  publisher={American Meteorological Society}
+}
+
+@article{Phil:56,
+  title={{The general circulation of the atmosphere: A numerical experiment}},
+  author={Phillips, N.A.},
+  journal={Quart. J. Roy. Meteor. Soc},
+  volume={82},
+  pages={123--164},
+  year={1956}
+}
+
+@article{Lill:67,
+  title={{The representation of small-scale turbulence in numerical simulation experiments}},
+  author={Lilly, DK},
+  journal={Proc. IBM Scientific Computing Symposium on Environmental Sciences},
+  volume={195},
+  year={1967}
+}
+
+@article{Dear:70,
+  title={{Convective Velocity and Temperature Scales for the Unstable Planetary Boundary Layer and for Rayleigh Convection}},
+  author={Deardorff, J.W.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={27},
+  number={8},
+  pages={1211--1213},
+  year={1970},
+  publisher={American Meteorological Society}
+}
+
+
+@book{Fedo:04,
+  title={{Atmospheric turbulence and mesoscale meteorology}},
+  author={Fedorovich, E. and Rotunno, R. and Stevens, B.},
+  year={2004},
+  publisher={Cambridge University Press, Cambridge}
+}
+
+@article{Orla:75,
+  title={{A rational subdivision of scales for atmospheric processes}},
+  author={Orlanski, I.},
+  journal={Bull. Amer. Meteor. Soc},
+  volume={56},
+  number={5},
+  pages={527--534},
+  year={1975}
+}
+
+@article{Hill:68,
+  title={{Grid Telescoping in Numerical Weather Prediction}},
+  author={Hill, GE},
+  journal={Journal of Applied Meteorology},
+  volume={7},
+  number={1},
+  pages={29--38},
+  year={1968},
+  publisher={NOAA Central Library, Department of Commerce}
+}
+
+@article{Harr:72,
+  title={{A Method for Incorporating Nested Finite Grids in the Solution of Systems of Geophysical Equations}},
+  author={Harrison, E.J. and Elsberry, R.L.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={29},
+  number={7},
+  pages={1235--1245},
+  year={1972},
+  publisher={American Meteorological Society}
+}
+
+@article{Yana:61,
+  title={{A Detailed Analysis of Typhoon Formation}},
+  author={Yanai, M.},
+  journal={Meteor. Soc. Japan},
+  volume={39},
+  pages={187--214},
+  year={1961}
+}
+
+@article{Char:64,
+  title={{On the Growth of the Hurricane Depression}},
+  author={Charney, J.G. and Eliassen, A.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={21},
+  number={1},
+  pages={68--75},
+  year={1964},
+  publisher={American Meteorological Society}
+}
+
+@article{Ooya:69,
+  title={{Numerical Simulation of the Life Cycle of Tropical Cyclones}},
+  author={Ooyama, K.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={26},
+  number={1},
+  pages={3--40},
+  year={1969},
+  publisher={American Meteorological Society}
+}
+
+@article{Anth:71,
+  title={{Preliminary results from an asymmetric model of the tropical cyclone}},
+  author={Anthes, R.~A. and Rosenthal, S.~L. and Trout, J.~W.},
+  journal={Monthly Weather Review},
+  volume={99},
+  number={10},
+  pages={744--758},
+  year={1971},
+  publisher={American Meteorological Society}
+}
+
+@article{Ogur:64,
+  title={{Frictionally Controlled, Thermally Driven Circulations in a Circular Vortex with Application to Tropical Cyclones}},
+  author={Ogura, Y.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={21},
+  number={6},
+  pages={610--621},
+  year={1964},
+  publisher={American Meteorological Society}
+}
+
+@article{Math:74,
+  title={{A Multiple-Grid Primitive Equation Model to Simulate the Development of an Asymmetric Hurricane (Isbell, 1964)}},
+  author={Mathur, M.B.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={31},
+  number={2},
+  pages={371--393},
+  year={1974},
+  publisher={American Meteorological Society}
+}
+
+@article{Rede:88,
+  title={{A Three-Dimensional Simulation of a Tropical Squall Line: Convective Organization and Thermodynamic Vertical Transport}},
+  author={Redelsperger, J.L. and Lafore, J.P.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={45},
+  number={8},
+  pages={1334--1356},
+  year={1988},
+  publisher={American Meteorological Society}
+}
+
+@article{Mill:74,
+  title={{A three-dimensional primitive equation model of cumulonimbus convection}},
+  author={Miller, M.~J. and Pearce, R.~P.},
+  journal={Quarterly Journal of the Royal Meteorological Society},
+  volume={100},
+  number={424},
+  pages={133--154},
+  year={1974},
+  publisher={Royal Meteorological Society}
+}
+
+@article{Monc:76,
+  title={{The dynamics and simulation of tropical cumulonimbus and squall lines}},
+  author={Moncrieff, M.~W. and Miller, M.~J.},
+  journal={Quarterly Journal of the Royal Meteorological Society},
+  volume={102},
+  number={432},
+  pages={373--394},
+  year={1976},
+  publisher={Royal Meteorological Society}
+}
+
+
+@article{Lill:73,
+  title={{Observations of a Stationary Mountain Wave and its Associated Momentum Flux and Energy Dissipation}},
+  author={Lilly, DK and Kennedy, PJ},
+  journal={Journal of the Atmospheric Sciences},
+  volume={30},
+  number={6},
+  pages={1135--1152},
+  year={1973},
+  publisher={American Meteorological Society}
+}
+
+@article{Quen:48,
+  title={{The problem of airflow over mountains: A summary of theoretical studies}},
+  author={Queney, P.},
+  journal={Bull. Amer. Meteor. Soc},
+  volume={29},
+  number={1},
+  pages={16--26},
+  year={1948}
+}
+
+@article{Mahr:77,
+  title={{The Effects of Topography on Sea and Land Breezes in a Two-Dimensional Numerical Model}},
+  author={Mahrer, Y. and Pielke, R.A.},
+  journal={Monthly Weather Review},
+  volume={105},
+  number={9},
+  pages={1151--1162},
+  year={1977},
+  publisher={American Meteorological Society}
+}
+
+@article{Klem:78,
+  title={{Numerical Simulation of Hydrostatic Mountain Waves}},
+  author={Klemp, JB and Lilly, DK},
+  journal={Journal of the Atmospheric Sciences},
+  volume={35},
+  number={1},
+  pages={78--107},
+  year={1978},
+  publisher={American Meteorological Society}
+}
+
+@article{Anth:78,
+  title={{Development of Hydrodynamic Models Suitable for Air Pollution and Other Mesometerological Studies}},
+  author={Anthes, R.A. and Warner, T.T.},
+  journal={Monthly Weather Review},
+  volume={106},
+  number={8},
+  pages={1045--1078},
+  year={1978},
+  publisher={American Meteorological Society}
+}
+
+@article{Mesi:88,
+  title={{The Step-Mountain Coordinate: Model Description and Performance for Cases of Alpine Lee Cyclogenesis and for a Case of an Appalachian Redevelopment}},
+  author={Mesinger, F. and Janji{\'c}, Z.I. and Ni{\v{c}}kovi{\'c}, S. and Gavrilov, D. and Deaven, D.G.},
+  journal={Monthly Weather Review},
+  volume={116},
+  number={7},
+  pages={1493--1518},
+  year={1988},
+  publisher={American Meteorological Society}
+}
+
+@article{Piel:92,
+  title={{A Comprehensive Meteorological Modeling System-RAMS}},
+  author={Pielke, RA and Cotton, WR and Walko, RL and Trembaek, CJ and Lyons, WA and Grasso, LD and Nieholls, ME and Moran, MD and Wesley, DA and Lee, TJ and others},
+  journal={Meteorol. Atmos. Phys},
+  volume={49},
+  pages={69--91},
+  year={1992}
+}
+
+@article{Dudh:93,
+  title={{A Nonhydrostatic Version of the Penn State--NCAR Mesoscale Model: Validation Tests and Simulation of an Atlantic Cyclone and Cold Front}},
+  author={Dudhia, J.},
+  journal={Monthly Weather Review},
+  volume={121},
+  number={5},
+  pages={1493--1513},
+  year={1993},
+  publisher={American Meteorological Society}
+}
+
+@article{Clar:84,
+  title={{Severe Downslope Windstorm Calculations in Two and Three Spatial Dimensions Using Anelastic Interactive Grid Nesting: A Possible Mechanism for Gustiness}},
+  author={Clark, T.L. and Farley, R.~D.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={41},
+  number={3},
+  pages={329--350},
+  year={1984},
+  publisher={American Meteorological Society}
+}
+
+@article{Lo:08,
+  title={{Assessment of three dynamical climate downscaling methods using the Weather Research and Forecasting (WRF) model}},
+  author={Lo, J. and Yang, Z. and Pielke, RA},
+  journal={J. Geophys. Res., doi},
+  volume={10},
+  year={2008}
+}
+
+@book{Boug:01,
+  title={{Dynamique de l’atmosphere et de l’ocean}},
+  author={Bougeault, P. and Sadourny, R.},
+  journal={Editions de l’Ecole polytechnique},
+  year={2001},
+  publisher={Editions de l'Ecole Polytechnique}
+}
+
+@article{Elia:49,
+  title={{The quasi-static equations of motion with pressure as independent variable}},
+  author={Eliassen, A.},
+  journal={Geofys. Publ., Oslo},
+  volume={17},
+  year={1949}
+}
+
+@article{Phil:57,
+  title={{A coordinate system having some special advantages for numerical forecasting}},
+  author={Phillips, NA},
+  journal={Journal of the Atmospheric Sciences},
+  volume={14},
+  number={2},
+  pages={184--185},
+  year={1957},
+  publisher={American Meteorological Society}
+}
+
+@article{Arak:77,
+  title={{Computational design of the UCLA general circulation model}},
+  author={Arakawa, A. and Lamb, V.~R.},
+  journal={Methods in Computational Physics},
+  volume={17},
+  pages={174--267},
+  year={1977}
+}
+
+@article{Kasa:74,
+  title={{Various Vertical Coordinate Systems Used for Numerical Weather Prediction}},
+  author={Kasahara, A.},
+  journal={Monthly Weather Review},
+  volume={102},
+  number={7},
+  pages={509--522},
+  year={1974},
+  publisher={American Meteorological Society}
+}
+
+@article{Durr:89,
+  title={{Improving the Anelastic Approximation}},
+  author={Durran, D.R.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={46},
+  number={11},
+  pages={1453--1461},
+  year={1989},
+  publisher={American Meteorological Society}
+}
+
+
+@ARTICLE{Lafo:98,
+   author = {{Lafore}, J.~P. and {Stein}, J. and {Asencio}, N. and {Bougeault}, P. and 
+	{Ducrocq}, V. and {Duron}, J. and {Fischer}, C. and {H{\'e}reil}, P. and 
+	{Mascart}, P. and {Masson}, V. and {Pinty}, J.~P. and {Redelsperger}, J.~L. and 
+	{Richard}, E. and {Vil{\`a}-Guerau de Arellano}, J.},
+    title = "{The Meso-NH Atmospheric Simulation System. Part I: adiabatic formulation and control simulations}",
+  journal = {Annales Geophysicae},
+     year = 1998,
+   volume = 16,
+    pages = {90-109},
+}
+
+@book{Piel:84,
+  title={{Mesoscale Atmospheric Modeling}},
+  author={Pielke, RA},
+  year={1984},
+  publisher={Academic Press}
+}
+
+@article{Skam:92,
+  title={{The Stability of Time-Split Numerical Methods for the Hydrostatic and the Nonhydrostatic Elastic Equations}},
+  author={Skamarock, W.C. and Klemp, J.B.},
+  journal={Monthly Weather Review},
+  volume={120},
+  number={9},
+  pages={2109--2127},
+  year={1992},
+  publisher={American Meteorological Society}
+}
+
+@article{Frit:03,
+  title={{Gravity wave dynamics and effects in the middle atmosphere}},
+  author={Fritts, D.C. and Alexander, M.J.},
+  journal={Rev. Geophys},
+  volume={41},
+  number={1},
+  pages={1003},
+  year={2003},
+}
+
+@article{Moen:07,
+  title={{Examining Two-Way Grid Nesting for Large Eddy Simulation of the PBL Using the WRF Model}},
+  author={Moeng, CH and Dudhia, J. and Klemp, J. and Sullivan, P.},
+  journal={Monthly Weather Review},
+  volume={135},
+  number={6},
+  pages={2295--2311},
+  year={2007},
+  publisher={American Meteorological Society}
+}
+
+@misc{Skam:08weis,
+   author = {Skamarock, W.~C. and Weisman, M.~L.},
+   howpublished = {Submitted to Monthly Weather Review},
+   title = {The Impact of Positive-Definite Moisture Transport on NWP Precipitation Forecasts},
+   year = {2008}
+}
+
+@book{Alla:05,
+  title={{Analyse numérique et optimisation}},
+  author={Allaire, G.},
+  year={2005},
+  publisher={Editions de l'Ecole Polytechnique}
+}
+
+@article{Gall:06,
+  title={{Comparison of Impacts of WRF Dynamic Core, Physics Package, and Initial Conditions on Warm Season Rainfall Forecasts}},
+  author={Gallus Jr, W.A. and Bresch, J.F.},
+  journal={Monthly Weather Review},
+  volume={134},
+  number={9},
+  pages={2632--2641},
+  year={2006},
+  publisher={American Meteorological Society}
+}
+
+@article{Davi:08,
+  title={{Hurricane Vortex Dynamics during Atlantic Extratropical Transition}},
+  author={Davis, C.A. and Jones, S.C. and Riemer, M.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={65},
+  number={3},
+  pages={714--736},
+  year={2008},
+  publisher={American Meteorological Society}
+}
+
+@ARTICLE{Plou:08,
+   author = {{Plougonven}, R. and {Hertzog}, A. and {Teitelbaum}, H.},
+    title = "{Observations and simulations of a large-amplitude mountain wave breaking over the Antarctic Peninsula}",
+  journal = {Journal of Geophysical Research (Atmospheres)},
+     year = 2008,
+   volume = 113,
+   number = D12,
+    pages = {16113-+},
+      doi = {10.1029/2007JD009739},
+}
+
+@article{Hine:08,
+  title={{Development and Testing of Polar Weather Research and Forecasting (WRF) Model. Part I: Greenland Ice Sheet Meteorology}},
+  author={Hines, K.M. and Bromwich, D.H.},
+  journal={Monthly Weather Review},
+  volume={136},
+  number={6},
+  pages={1971--1989},
+  year={2008},
+  publisher={American Meteorological Society}
+}
+
+@misc{Bao:08,
+   author = {Bao, J.~W. and Michelson, S.~A. and Persson, P.~O.~G. and Djalalova, I.~V. and Wilczak J.~M.},
+   howpublished = {Journal of Applied Meteorology and Climatology},
+   title = {Observed and WRF-Simulated Low-Level Winds in a High-Ozone Episode during the Central California Ozone Study, In Press},
+   year = {2008}
+}
+
+@article{Chen:05,
+  title={{Evaluation of Surface Sensible Weather Forecasts by the WRF and the Eta Models over the Western United States}},
+  author={Cheng, W.Y.Y. and Steenburgh, W.J.},
+  journal={Weather and Forecasting},
+  volume={20},
+  number={5},
+  pages={812--821},
+  year={2005},
+  publisher={American Meteorological Society}
+}
+
+@article{Scav:98,
+  title={{A study of the low frequency inertio-gravity waves observed during PYREX}},
+  author={Scavuzzo, CM and Lamfri, MA and Teitelbaum, H. and Lott, F.},
+  journal={J. Geophys. Res},
+  volume={103},
+  pages={1747--1758},
+  year={1998}
+}
+
+@ARTICLE{Alex:00,
+   author = {{Alexander}, M.~J. and {Vincent}, R.~A.},
+    title = "{Gravity waves in the tropical lower stratosphere: A model study of seasonal and interannual variability}",
+  journal = jgr,
+     year = 2000,
+   volume = 105,
+    pages = {17983-17994},
+      doi = {10.1029/2000JD900197},
+}
+
+@article{Osul:95,
+  title={{Generation of Inertia--Gravity Waves in a Simulated Life Cycle of Baroclinic Instability}},
+  author={O'sullivan, D. and Dunkerton, T.J.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={52},
+  number={21},
+  pages={3695--3716},
+  year={1995},
+  publisher={American Meteorological Society}
+}
+
+@article{Pfis:93,
+  title={{Mesoscale Disturbances in the Tropical Stratosphere Excited by Convection: Observations and Effects on the Stratospheric Momentum Budget}},
+  author={Pfister, L. and Scott, S. and Loewenstein, M. and Bowen, S. and Legg, M.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={50},
+  number={8},
+  pages={1058--1075},
+  year={1993},
+  publisher={American Meteorological Society}
+}
+
+@book{Mint:61,
+  title={{Numerical studies of planetary circulation}},
+  author={Mintz, Y.},
+  year={1961},
+  publisher={DTIC Research Report AD0263158}
+}
+
+@article{Savi:99,
+  title={{A model study of the atmospheric boundary layer in the Mars Pathfinder lander conditions}},
+  author={S{\"a}vijarvi, H.},
+  journal={Quarterly Journal of the Royal Meteorological Society},
+  volume={125},
+  number={554},
+  pages={483--493},
+  year={1999},
+  publisher={Royal Meteorological Society}
+}
+
+@article{Pres:97,
+  title={{The effect of bulk density and particle size sorting on the thermal conductivity of particulate materials under Martian atmospheric pressures}},
+  author={Presley, M.A. and Christensen, P.R.},
+  journal={J. Geophys. Res},
+  volume={102},
+  number={E4},
+  pages={9221--9229},
+  year={1997}
+}
+
+@ARTICLE{Good:67,
+   author = {{Goody}, R. and {Belton}, M.~J.~S.},
+    title = "{Radiative relaxation times for Mars. A discussion of martian atmospheric dynamics}",
+  journal = pss,
+     year = 1967,
+   volume = 15,
+    pages = {247-+},
+}
+
+@ARTICLE{Cant:07,
+   author = {{Cantor}, B.~A.},
+    title = "{MOC observations of the 2001 Mars planet-encircling dust storm}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 186,
+    pages = {60-96},
+      doi = {10.1016/j.icarus.2006.08.019},
+}
+
+@ARTICLE{Mont:05luca,
+   author = {{Montabone}, L. and {Lewis}, S.~R. and {Read}, P.~L.},
+    title = "{Interannual variability of Martian dust storms in assimilation of several years of Mars global surveyor observations}",
+  journal = {Advances in Space Research},
+     year = 2005,
+   volume = 36,
+    pages = {2146-2155},
+      doi = {10.1016/j.asr.2005.07.047},
+}
+
+@ARTICLE{Gold:08,
+   author = {{Goldenson}, N. and {Desch}, S. and {Christensen}, P.},
+    title = "{Non-equilibrium between dust and gas temperatures in the Mars atmosphere}",
+  journal = grl,
+     year = 2008,
+   volume = 35,
+    pages = {8813-+},
+      doi = {10.1029/2007GL032907},
+}
+
+@ARTICLE{Banf:00,
+   author = {{Banfield}, D. and {Conrath}, B. and {Pearl}, J.~C. and {Smith}, M.~D. and 
+	{Christensen}, P.},
+    title = "{Thermal tides and stationary waves on Mars as revealed by Mars Global Surveyor thermal emission spectrometer}",
+  journal = jgr,
+     year = 2000,
+   volume = 105,
+    pages = {9521-9538},
+      doi = {10.1029/1999JE001161},
+}
+
+@ARTICLE{Cant:02,
+   author = {{Cantor}, B. and {Malin}, M. and {Edgett}, K.~S.},
+    title = "{Multiyear Mars Orbiter Camera (MOC) observations of repeated Martian weather phenomena during the northern summer season}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+    pages = {5014-+},
+      doi = {10.1029/2001JE001588},
+}
+
+@BOOK{Chap:70,
+   author = {{Chapman}, S. and {Lindzen}, R.},
+    title = "{Atmospheric tides. Thermal and gravitational}",
+publisher = {Dordrecht: Reidel, 1970},
+     year = 1970,
+}
+
+@ARTICLE{Zure:81,
+   author = {{Zurek}, R.~W. and {Leovy}, C.~B.},
+    title = "{Thermal tides in the dusty martian atmosphere - A verification of theory}",
+  journal = {Science},
+     year = 1981,
+   volume = 213,
+    pages = {437-439},
+}
+
+@ARTICLE{Hert:07,
+   author = {{Hertzog}, A. and {Cocquerez}, P. and {Basdevant}, C. and {Boccara}, G. and 
+	{Bordereau}, J. and {Brioit}, B. and {Cardonne}, A. and {Guilbon}, R. and 
+	{Ravissot}, A. and {Schmitt}, {\'E}. and {Valdivia}, J.-N. and 
+	{Venel}, S. and {Vial}, F.},
+    title = "{Strat{\'e}ole/Vorcore Long-duration, Superpressure Balloons to Study the Antarctic Lower Stratosphere during the 2005 Winter}",
+  journal = {Journal of Atmospheric and Oceanic Technology},
+     year = 2007,
+   volume = 24,
+    pages = {2048-+},
+      doi = {10.1175/2007JTECHA948.1},
+}
+
+@article{Teit:91,
+  title={{On tidal variability induced by nonlinear interaction with planetary waves}},
+  author={Teitelbaum, H. and Vial, F.},
+  journal={Journal of Geophysical Research},
+  volume={96},
+  number={A8},
+  pages={14169--14178},
+  year={1991}
+}
+
+@ARTICLE{Span:06,
+   author = {{Spanovich}, N. and {Smith}, M.~D. and {Smith}, P.~H. and {Wolff}, M.~J. and 
+	{Christensen}, P.~R. and {Squyres}, S.~W.},
+    title = "{Surface and near-surface atmospheric temperatures for the Mars Exploration Rover landing sites}",
+  journal = {Icarus},
+     year = 2006,
+   volume = 180,
+    pages = {314-320},
+      doi = {10.1016/j.icarus.2005.09.014},
+}
+
+@article{Aebi:98,
+  title={{Low-Level Potential Vorticity and Cyclogenesis to the Lee of the Alps}},
+  author={Aebischer, U. and Sch{\"a}r, C.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={55},
+  number={2},
+  pages={186--207},
+  year={1998},
+  publisher={American Meteorological Society}
+}
+
+@article{Epif:02,
+  title={{Lee-Vortex Formation in Free-Slip Stratified Flow over Ridges. Part II: Mechanisms of Vorticity and PV Production in Nonlinear Viscous Wakes}},
+  author={Epifanio, CC and Durran, DR},
+  journal={Journal of the Atmospheric Sciences},
+  volume={59},
+  number={7},
+  pages={1166--1181},
+  year={2002},
+  publisher={American Meteorological Society}
+}
+
+@article{Cast:93,
+  title={{Experiments on wave breaking in statified flow over obstacles}},
+  author={Castro, I.~P. and Snyder, W.~H.},
+  journal={Journal of Fluid Mechanics},
+  volume={255},
+  pages={195--211},
+  year={1993},
+  publisher={Cambridge University Press}
+}
+
+@misc{Epif:03,
+  title={{Lee vortices. Encyclopedia of Atmospheric Sciences, JR Holton, J. Pyle, and J. A. Curry, Eds}},
+  author={Epifanio, C.C.},
+  year={2003},
+  publisher={Academic Press}
+}
+
+@article{Scha:97,
+  title={{Vortex Formation and Vortex Shedding in Continuously Stratified Flows past Isolated Topography}},
+  author={Sch{\"a}r, C. and Durran, D.R.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={54},
+  number={4},
+  pages={534--554},
+  year={1997},
+  publisher={American Meteorological Society}
+}
+
+@article{Scha:93,
+  title={{Shallow-Water Flow past Isolated Topography. Part I: Vorticity Production and Wake Formation}},
+  author={Sch{\"a}r, C. and Smith, R.B.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={50},
+  number={10},
+  pages={1373--1400},
+  year={1993},
+  publisher={American Meteorological Society}
+}
+
+@article{Smol:89,
+  title={{Low Froude Number Flow Past Three-Dimensional Obstacles. Part I: Baroclinically Generated Lee Vortices}},
+  author={Smolarkiewicz, P.K. and Rotunno, R.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={46},
+  number={8},
+  pages={1154--1164},
+  year={1989},
+  publisher={American Meteorological Society}
+}
+
+@article{Clar:77,
+  title={{On the Evolution and Stability of Finite-Amplitude Mountain Waves}},
+  author={Clark, T.~L. and Peltier, W.~R.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={34},
+  number={11},
+  pages={1715--1730},
+  year={1977},
+  publisher={American Meteorological Society}
+}
+
+@article{Durr:86,
+  title={{Another Look at Downslope Windstorms. Part I: The Development of Analogs to Supercritical Flow in an Infinitely Deep, Continuously Stratified Fluid}},
+  author={Durran, D.R.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={43},
+  number={21},
+  pages={2527--2543},
+  year={1986},
+  publisher={American Meteorological Society}
+}
+
+@article{Grub:95,
+  title={{The Effect of Bottom Friction on Shallow-Water Flow past an Isolated Obstacle}},
+  author={Grubi{\v{s}}i{\'c}, V. and Smith, R.B. and Sch{\"a}r, C.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={52},
+  number={11},
+  pages={1985--2005},
+  year={1995},
+  publisher={American Meteorological Society}
+}
+
+@article{Kaln:96,
+  title={{The NCEP/NCAR 40-Year Reanalysis Project}},
+  author={Kalnay, E. and Kanamitsu, M. and Kistler, R. and Collins, W. and Deaven, D. and Gandin, L. and Iredell, M. and Saha, S. and White, G. and Woollen, J. and others},
+  journal={Bulletin of the American Meteorological Society},
+  volume={77},
+  number={3},
+  pages={437--471},
+  year={1996},
+  publisher={American Meteorological Society}
+}
+
+
+@ARTICLE{Ched:03,
+   author = {{Ch{\'e}din}, A. and {Serrar}, S. and {Scott}, N.~A. and {Crevoisier}, C. and 
+	{Armante}, R.},
+    title = "{First global measurement of midtropospheric CO2 from NOAA polar satellites: Tropical zone}",
+  journal = {Journal of Geophysical Research (Atmospheres)},
+     year = 2003,
+   volume = 108,
+    pages = {4581-+},
+      doi = {10.1029/2003JD003439},
+}
+
+@ARTICLE{Kapl:64,
+   author = {{Kaplan}, L.~D. and {M{\"u}nch}, G. and {Spinrad}, H.},
+    title = "{An Analysis of the Spectrum of Mars.}",
+  journal = apj,
+     year = 1964,
+   volume = 139,
+    pages = {1-+},
+}
+
+@ARTICLE{Klio:65,
+   author = {{Kliore}, A. and {Cain}, D.~L. and {Levy}, G.~S. and {Eshleman}, V.~R. and 
+	{Fjeldbo}, G. and {Drake}, F.~D.},
+    title = "{Occultation Experiment: Results of the First Direct Measurement of Mars's Atmosphere and Ionosphere}",
+  journal = {Science},
+     year = 1965,
+   volume = 149,
+    pages = {1243-1248},
+}
+
+@article{Belt:66,
+  title={{The Abundance and Temperature of CO$_2$ in the Martian Atmosphere}},
+  author={Belton, M.J.S. and Hunten, D.M.},
+  journal={The Astrophysical Journal},
+  volume={145},
+  pages={454},
+  year={1966}
+}
+
+@ARTICLE{Farr:08,
+   author = {{Farrell}, W.~M. and {Clifford}, S.~M. and {Milkovich}, S.~M. and 
+	{Plaut}, J.~J. and {Leuschen}, C.~J. and {Picardi}, G. and {Gurnett}, D.~A. and 
+	{Watters}, T.~R. and {Safaeinili}, A. and {Ivanov}, A.~B. and 
+	{Phillips}, R.~J. and {Stofan}, E.~R. and {Heggy}, E. and {Cummer}, S.~A. and 
+	{Espley}, J.~R.},
+    title = "{MARSIS subsurface radar investigations of the South Polar reentrant Chasma Australe}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+   number = {E12},
+    pages = {4002-+},
+      doi = {10.1029/2007JE002974},
+}
+
+@ARTICLE{Poul:07,
+   author = {{Poulet}, F. and {Gomez}, C. and {Bibring}, J.-P. and {Langevin}, Y. and 
+	{Gondet}, B. and {Pinet}, P. and {Belluci}, G. and {Mustard}, J.
+	},
+    title = "{Martian surface mineralogy from Observatoire pour la Min{\'e}ralogie, l'Eau, les Glaces et l'Activit{\'e} on board the Mars Express spacecraft (OMEGA/MEx): Global mineral maps}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002840},
+}
+
+
+
+@ARTICLE{Loiz:07,
+   author = {{Loizeau}, D. and {Mangold}, N. and {Poulet}, F. and {Bibring}, J.-P. and 
+	{Gendrin}, A. and {Ansan}, V. and {Gomez}, C. and {Gondet}, B. and 
+	{Langevin}, Y. and {Masson}, P. and {Neukum}, G.},
+    title = "{Phyllosilicates in the Mawrth Vallis region of Mars}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002877},
+}
+
+
+@ARTICLE{Lang:07,
+   author = {{Langevin}, Y. and {Bibring}, J.-P. and {Montmessin}, F. and 
+	{Forget}, F. and {Vincendon}, M. and {Dout{\'e}}, S. and {Poulet}, F. and 
+	{Gondet}, B.},
+    title = "{Observations of the south seasonal cap of Mars during recession in 2004-2006 by the OMEGA visible/near-infrared imaging spectrometer on board Mars Express}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002841},
+}
+
+@ARTICLE{Mang:07,
+   author = {{Mangold}, N. and {Poulet}, F. and {Mustard}, J.~F. and {Bibring}, J.-P. and 
+	{Gondet}, B. and {Langevin}, Y. and {Ansan}, V. and {Masson}, P. and 
+	{Fassett}, C. and {Head}, J.~W. and {Hoffmann}, H. and {Neukum}, G.
+	},
+    title = "{Mineralogy of the Nili Fossae region with OMEGA/Mars Express data: 2. Aqueous alteration of the crust}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002835},
+}
+
+@ARTICLE{Joug:07,
+   author = {{Jouglet}, D. and {Poulet}, F. and {Milliken}, R.~E. and {Mustard}, J.~F. and 
+	{Bibring}, J.-P. and {Langevin}, Y. and {Gondet}, B. and {Gomez}, C.
+	},
+    title = "{Hydration state of the Martian surface as seen by Mars Express OMEGA: 1. Analysis of the 3 {$\mu$}m hydration feature}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {8-+},
+      doi = {10.1029/2006JE002846},
+}
+
+@ARTICLE{Gend:05,
+   author = {{Gendrin}, A. and {Mangold}, N. and {Bibring}, J.-P. and {Langevin}, Y. and 
+	{Gondet}, B. and {Poulet}, F. and {Bonello}, G. and {Quantin}, C. and 
+	{Mustard}, J. and {Arvidson}, R. and {LeMou{\'e}lic}, S.},
+    title = "{Sulfates in Martian Layered Terrains: The OMEGA/Mars Express View}",
+  journal = {Science},
+     year = 2005,
+   volume = 307,
+    pages = {1587-1591},
+      doi = {10.1126/science.1109087},
+}
+
+@ARTICLE{Encr:05,
+   author = {{Encrenaz}, T. and {Melchiorri}, R. and {Fouchet}, T. and {Drossart}, P. and 
+	{Lellouch}, E. and {Gondet}, B. and {Bibring}, J.-P. and {Langevin}, Y. and 
+	{Titov}, D. and {Ignatiev}, N. and {Forget}, F.},
+    title = "{A mapping of martian water sublimation during early northern summer using OMEGA/Mars Express}",
+  journal = aa,
+     year = 2005,
+   volume = 441,
+    pages = {L9-L12},
+      doi = {10.1051/0004-6361:200500171},
+}
+
+@book{Tara:05,
+  title={{Inverse Problem Theory and Methods for Model Parameter Estimation}},
+  author={Tarantola, A.},
+  year={2005},
+  publisher={Society for Industrial Mathematics}
+}
+
+@ARTICLE{Melc:07,
+   author = {{Melchiorri}, R. and {Encrenaz}, T. and {Fouchet}, T. and {Drossart}, P. and 
+	{Lellouch}, E. and {Gondet}, B. and {Bibring}, J.-P. and {Langevin}, Y. and 
+	{Schmitt}, B. and {Titov}, D. and {Ignatiev}, N.},
+    title = "{Water vapor mapping on Mars using OMEGA/Mars Express}",
+  journal = pss,
+     year = 2007,
+   volume = 55,
+    pages = {333-342},
+      doi = {10.1016/j.pss.2006.05.040},
+}
+
+@ARTICLE{Tsch:08,
+   author = {{Tschimmel}, M. and {Ignatiev}, N.~I. and {Titov}, D.~V. and 
+	{Lellouch}, E. and {Fouchet}, T. and {Giuranna}, M. and {Formisano}, V.
+	},
+    title = "{Investigation of water vapor on Mars with PFS/SW of Mars Express}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 195,
+    pages = {557-575},
+      doi = {10.1016/j.icarus.2008.01.018},
+}
+
+@ARTICLE{Fedo:06water,
+   author = {{Fedorova}, A. and {Korablev}, O. and {Bertaux}, J.-L. and {Rodin}, A. and 
+	{Kiselev}, A. and {Perrier}, S.},
+    title = "{Mars water vapor abundance from SPICAM IR spectrometer: Seasonal and geographic distributions}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {9-+},
+      doi = {10.1029/2006JE002695},
+}
+
+@article{Neld:65,
+  title={{A Simplex Method for Function Minimization}},
+  author={Nelder, JA and Mead, R.},
+  journal={The Computer Journal},
+  volume={7},
+  number={4},
+  pages={308},
+  year={1965},
+  publisher={Br Computer Soc}
+}
+
+@article{Mahr:82,
+  title={{Momentum Balance of Gravity Flows}},
+  author={Mahrt, L.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={39},
+  number={12},
+  pages={2701--2711},
+  year={1982},
+  publisher={American Meteorological Society}
+}
+
+
+@ARTICLE{Savi:08,
+   author = {{Savij{\"a}rvi}, H. and {Kauhanen}, J.},
+    title = "{Surface and boundary-layer modelling for the Mars Exploration Rover sites}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2008,
+   volume = 134,
+    pages = {635-641},
+      doi = {10.1002/qj.232},
+}
+
+@article{Blac:57,
+  title={{Boundary layer wind maxima and their significance for the growth of nocturnal inversions}},
+  author={Blackadar, A.K.},
+  journal={Bull. Amer. Meteor. Soc},
+  volume={38},
+  number={5},
+  pages={283--290},
+  year={1957}
+}
+
+@article{Thor:77,
+  title={{The nocturnal jet}},
+  author={Thorpe, A.J. and Guymer, T.H.},
+  journal={Quarterly Journal of the Royal Meteorological Society},
+  volume={103},
+  number={438},
+  pages={633--653},
+  year={1977},
+  publisher={Royal Meteorological Society}
+}
+
+
+@article{Smit:92,
+  title={{Surface Forcing of the Infrared Cooling Profile over the Tibetan Plateau. Part I: Influence of Relative Longwave Radiative Heating at High Altitude}},
+  author={Smith, E.A. and Shi, L.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={49},
+  number={10},
+  pages={805--822},
+  year={1992},
+  publisher={American Meteorological Society}
+}
+
+@ARTICLE{Balm:06,
+   author = {{Balme}, M. and {Greeley}, R.},
+    title = "{Dust devils on Earth and Mars}",
+  journal = {Reviews of Geophysics},
+     year = 2006,
+   volume = 44,
+    pages = {3003-+},
+      doi = {10.1029/2005RG000188},
+}
+
+@ARTICLE{Mali:01,
+   author = {{Malin}, M.~C. and {Edgett}, K.~S.},
+    title = "{Mars Global Surveyor Mars Orbiter Camera: Interplanetary cruise through primary mission}",
+  journal = jgr,
+     year = 2001,
+   volume = 106,
+    pages = {23429-23570},
+      doi = {10.1029/2000JE001455},
+}
+
+@ARTICLE{Stan:06,
+   author = {{Stanzel}, C. and {P{\"a}tzold}, M. and {Greeley}, R. and {Hauber}, E. and 
+	{Neukum}, G.},
+    title = "{Dust devils on Mars observed by the High Resolution Stereo Camera}",
+  journal = grl,
+     year = 2006,
+   volume = 33,
+    pages = {11202-+},
+      doi = {10.1029/2006GL025816},
+}
+
+@article{Sinc:73,
+  title={{The Lower Structure of Dust Devils}},
+  author={Sinclair, P.C.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={30},
+  number={8},
+  pages={1599--1619},
+  year={1973},
+  publisher={American Meteorological Society}
+}
+
+@ARTICLE{Fish:05,
+   author = {{Fisher}, J.~A. and {Richardson}, M.~I. and {Newman}, C.~E. and 
+	{Szwast}, M.~A. and {Graf}, C. and {Basu}, S. and {Ewald}, S.~P. and 
+	{Toigo}, A.~D. and {Wilson}, R.~J.},
+    title = "{A survey of Martian dust devil activity using Mars Global Surveyor Mars Orbiter Camera images}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {3004-+},
+      doi = {10.1029/2003JE002165},
+}
+
+@ARTICLE{Geis:05,
+   author = {{Geissler}, P.~E.},
+    title = "{Three decades of Martian surface changes}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = {E9},
+    pages = {2001-+},
+      doi = {10.1029/2004JE002345},
+}
+
+@ARTICLE{Ring:03,
+   author = {{Ringrose}, T.~J. and {Towner}, M.~C. and {Zarnecki}, J.~C.},
+    title = "{Convective vortices on Mars: a reanalysis of Viking Lander 2 meteorological data, sols 1-60}",
+  journal = {Icarus},
+     year = 2003,
+   volume = 163,
+    pages = {78-87},
+      doi = {10.1016/S0019-1035(03)00073-3},
+}
+
+@ARTICLE{Murp:02,
+   author = {{Murphy}, J.~R. and {Nelli}, S.},
+    title = "{Mars Pathfinder convective vortices: Frequency of occurrence}",
+  journal = grl,
+     year = 2002,
+   volume = 29,
+   number = 23,
+    pages = {230000-1},
+}
+
+@ARTICLE{Farr:04,
+   author = {{Farrell}, W.~M. and {Smith}, P.~H. and {Delory}, G.~T. and 
+	{Hillard}, G.~B. and {Marshall}, J.~R. and {Catling}, D. and 
+	{Hecht}, M. and {Tratt}, D.~M. and {Renno}, N. and {Desch}, M.~D. and 
+	{Cummer}, S.~A. and {Houser}, J.~G. and {Johnson}, B.},
+    title = "{Electric and magnetic signatures of dust devils from the 2000-2001 MATADOR desert tests}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2004,
+   volume = 109,
+   number = {E18},
+    pages = {3004-+},
+      doi = {10.1029/2003JE002088},
+}
+
+@ARTICLE{Renn:03,
+   author = {{Renno}, N.~O. and {Wong}, A.-S. and {Atreya}, S.~K. and {de Pater}, I. and 
+	{Roos-Serote}, M.},
+    title = "{Electrical discharges and broadband radio emission by Martian dust devils and dust storms}",
+  journal = grl,
+     year = 2003,
+   volume = 30,
+   number = 22,
+    pages = {220000-1},
+}
+
+@ARTICLE{Gree:06,
+   author = {{Greeley}, R. and {Whelley}, P.~L. and {Arvidson}, R.~E. and 
+	{Cabrol}, N.~A. and {Foley}, D.~J. and {Franklin}, B.~J. and 
+	{Geissler}, P.~G. and {Golombek}, M.~P. and {Kuzmin}, R.~O. and 
+	{Landis}, G.~A. and {Lemmon}, M.~T. and {Neakrase}, L.~D.~V. and 
+	{Squyres}, S.~W. and {Thompson}, S.~D.},
+    title = "{Active dust devils in Gusev crater, Mars: Observations from the Mars Exploration Rover Spirit}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {12-+},
+      doi = {10.1029/2006JE002743},
+}
+
+@ARTICLE{Cant:01,
+   author = {{Cantor}, B.~A. and {James}, P.~B. and {Caplinger}, M. and {Wolff}, M.~J.
+	},
+    title = "{Martian dust storms: 1999 Mars Orbiter Camera observations}",
+  journal = jgr,
+     year = 2001,
+   volume = 106,
+    pages = {23653-23688},
+      doi = {10.1029/2000JE001310},
+}
+
+@ARTICLE{Kana:00,
+   author = {{Kanak}, K.~M. and {Lilly}, D.~K. and {Snow}, J.~T.},
+    title = "{The formation of vertical Vortices in the convective boundary layer}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2000,
+   volume = 126,
+    pages = {2789-2810},
+      doi = {10.1256/smsqj.56909},
+}
+
+@ARTICLE{Renn:00,
+   author = {{Renno}, N.~O. and {Nash}, A.~A. and {Lunine}, J. and {Murphy}, J.},
+    title = "{Martian and terrestrial dust devils: Test of a scaling theory using Pathfinder data}",
+  journal = jgr,
+     year = 2000,
+   volume = 105,
+    pages = {1859-1866},
+      doi = {10.1029/1999JE001037},
+}
+
+@ARTICLE{Thor:03,
+   author = {{Thorpe}, A.~J. and {Volkert}, H. and {Ziemianski}, M.~J.},
+    title = "{The Bjerknes' Circulation Theorem: A Historical Perspective.}",
+  journal = {Bulletin of the American Meteorological Society, vol.~84, Issue 4, pp.471-480},
+     year = 2003,
+   volume = 84,
+    pages = {471-480},
+}
+
+@article{Flea:50,
+  title={{A theory of air drainage}},
+  author={Fleagle, R.G.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={7},
+  number={3},
+  pages={227--232},
+  year={1950},
+  publisher={American Meteorological Society}
+}
+
+@article{Mani:79,
+  title={{A Model of Katabatic Winds}},
+  author={Manins, PC and Sawford, BL},
+  journal={Journal of the Atmospheric Sciences},
+  volume={36},
+  number={4},
+  pages={619--630},
+  year={1979},
+  publisher={American Meteorological Society}
+}
+
+@ARTICLE{Brom:01,
+   author = {{Bromwich}, D.~H. and {Cassano}, J.~J. and {Klein}, T. and {Heinemann}, G. and 
+	{Hines}, K.~M. and {Steffen}, K. and {Box}, J.~E.},
+    title = "{Mesoscale Modeling of Katabatic Winds over Greenland with the Polar MM5}",
+  journal = {Monthly Weather Review},
+     year = 2001,
+   volume = 129,
+    pages = {2290--2309},
+      doi = {10.1175/1520-0493(2001)129},
+}
+
+@article{Ball:56,
+  title={{The Theory of Strong Katabatic Winds}},
+  author={Ball, FK},
+  journal={Australian Journal of Physics},
+  volume={9},
+  pages={373},
+  year={1956}
+}
+
+@article{Pran:42,
+  title={{Fuehrer durch die Stromunglehre. Braunschweig}},
+  author={Prandtl, L.},
+  journal={Viewing und Sohn},
+  volume={382},
+  year={1942}
+}
+
+@article{Defa:49,
+  title={{Zur Theorie der Hangwinde, nebst Bemerkungen zur Theorie der Berg-und Talwinde}},
+  author={Defant, F.},
+  journal={Archiv f{\"u}r Meteorologie, Geophysik und Bioklimatologie Serie A,},
+  volume={1},
+  number={3-4},
+  pages={421--450},
+  year={1949}
+}
+
+@article{Ye:87,
+  title={{Effects of Atmospheric Thermal Stability and Slope Steepness on the Development of Daytime Thermally Induced Upslope Flow}},
+  author={Ye, ZJ and Segal, M. and Pielke, RA},
+  journal={Journal of the Atmospheric Sciences},
+  volume={44},
+  number={22},
+  pages={3341--3354},
+  year={1987},
+  publisher={American Meteorological Society}
+}
+
+@ARTICLE{Parm:04,
+   author = {{Parmhed}, O. and {Oerlemans}, J. and {Grisogono}, B.},
+    title = "{Describing surface fluxes in katabatic flow on Breidamerkurj{\"o}kull, Iceland}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2004,
+   volume = 130,
+    pages = {1137-1151},
+}
+
+@ARTICLE{Pari:84,
+   author = {{Parish}, T.~R.},
+    title = "{A Numerical Study of Strong Katabatic Winds over Antarctica}",
+  journal = {Monthly Weather Review},
+     year = 1984,
+   volume = 112,
+    pages = {545-+},
+      doi = {10.1175/1520-0493(1984)112},
+}
+
+@ARTICLE{Stip:07,
+   author = {{Stiperski}, I. and {Kav{\v c}i{\v c}}, I. and {Grisogono}, B. and 
+	{Durran}, D.~R.},
+    title = "{Including Coriolis effects in the Prandtl model for katabatic flow}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2007,
+   volume = 133,
+    pages = {101-106},
+      doi = {10.1002/qj.19},
+}
+
+@ARTICLE{Siil:99,
+   author = {{Siili}, T. and {Haberle}, R.~M. and {Murphy}, J.~R. and {Savijarvi}, H.
+	},
+    title = "{Modelling of the combined late-winter ice cap edge and slope winds in Mars Hellas and Argyre regions}",
+  journal = pss,
+     year = 1999,
+   volume = 47,
+    pages = {951-970},
+}
+
+@ARTICLE{Frit:06,
+   author = {{Fritts}, D.~C. and {Wang}, L. and {Tolson}, R.~H.},
+    title = "{Mean and gravity wave structures and variability in the Mars upper atmosphere inferred from Mars Global Surveyor and Mars Odyssey aerobraking densities}",
+  journal = {Journal of Geophysical Research (Space Physics)},
+     year = 2006,
+   volume = 111,
+   number = {A10},
+    pages = {12304-+},
+      doi = {10.1029/2006JA011897},
+}
+
+@article{Quen:47,
+  title={{Theory of perturbations in stratified currents with applications to airflow over mountain barriers}},
+  author={Queney, P.},
+  journal={Misc. Rep},
+  volume={23},
+  year={1947}
+}
+
+@article{Pirr:76,
+  title={{Martian atmospheric Lee waves}},
+  author={Pirraglia, J.A.},
+  journal={Icarus},
+  volume={27},
+  number={4},
+  pages={517--530},
+  year={1976},
+  publisher={Elsevier}
+}
+
+@article{Bene:98,
+  title={{Dynamic Characteristics of Regional Flows around the Pyr{\'e}n{\'e}es in View of the PYREX Experiment. Part I: Analysis of the Pressure and Wind Fields and Experimental Assessment of the Applicability of the Linear Theory}},
+  author={B{\'e}nech, B. and Koffi, E. and Druilhet, A. and Durand, P. and Bessemoulin, P. and Campins, J. and Jansa, A. and Terliuc, B.},
+  journal={Journal of Applied Meteorology},
+  volume={37},
+  number={1},
+  pages={32--52},
+  year={1998},
+  publisher={NOAA Central Library, Department of Commerce}
+}
+
+@article{Smol:88,
+  title={{On the Dynamics of Hawaiian Cloud Bands: Island Forcing}},
+  author={Smolarkiewicz, P.K. and Rasmussen, R.M. and Clark, T.L.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={45},
+  number={13},
+  pages={1872--1905},
+  year={1988},
+  publisher={American Meteorological Society}
+}
+
+@article{Lott:98,
+  title={{Linear mountain drag and averaged pseudo-momentum flux profiles in the presence of trapped lee waves}},
+  author={Lott, F.},
+  journal={Tellus A},
+  volume={50},
+  number={1},
+  pages={12--25},
+  year={1998},
+  publisher={Blackwell Synergy}
+}
+
+@ARTICLE{Poul:00,
+   author = {{Poulos}, G.~S. and {Bossert}, J.~E. and {McKee}, T.~B. and 
+	{Pielke}, R.~A.},
+    title = "{The Interaction of Katabatic Flow and Mountain Waves. Part I: Observations and Idealized Simulations.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2000,
+   volume = 57,
+    pages = {1919-1936},
+}
+
+@article{Busi:71,
+  title={{Flux-Profile Relationships in the Atmospheric Surface Layer}},
+  author={Businger, JA and Wyngaard, JC and Izumi, Y. and Bradley, EF},
+  journal={Journal of the Atmospheric Sciences},
+  volume={28},
+  number={2},
+  pages={181--189},
+  year={1971},
+  publisher={American Meteorological Society}
+}
+
+@ARTICLE{Glen:03,
+   author = {{Glenar}, D.~A. and {Samuelson}, R.~E. and {Pearl}, J.~C. and 
+	{Bjoraker}, G.~L. and {Blaney}, D.},
+    title = "{Spectral imaging of martian water ice clouds and their diurnal behavior during the 1999 aphelion season}",
+  journal = {Icarus},
+     year = 2003,
+   volume = 161,
+    pages = {297-318},
+      doi = {10.1016/S0019-1035(02)00046-5},
+}
+
+@article{Maso:89,
+  title={{Large-Eddy Simulation of the Convective Atmospheric Boundary Layer}},
+  author={Mason, PJ},
+  journal={Journal of the Atmospheric Sciences},
+  volume={46},
+  number={11},
+  pages={1492--1516},
+  year={1989},
+  publisher={American Meteorological Society}
+}
+
+@article{Will:79,
+  title={{Laboratory observations of turbulent penetrative-convection planforms}},
+  author={Willis, GE and Deardorff, JW},
+  journal={Journal of Geophysical Research},
+  volume={84},
+  number={C1},
+  pages={295--302},
+  year={1979}
+}
+
+@ARTICLE{Newm:02,
+   author = {{Newman}, C.~E. and {Lewis}, S.~R. and {Read}, P.~L. and {Forget}, F.
+	},
+    title = "{Modeling the Martian dust cycle 2. Multiannual radiatively active dust transport simulations}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2002,
+   volume = 107,
+    pages = {5124-+},
+      doi = {10.1029/2002JE001920},
+}
+
+@ARTICLE{Gree:03,
+   author = {{Greeley}, R. and {Kuzmin}, R.~O. and {Rafkin}, S.~C.~R. and 
+	{Michaels}, T.~I. and {Haberle}, R.},
+    title = "{Wind-related features in Gusev crater, Mars}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+   number = {E12},
+    pages = {8077},
+      doi = {10.1029/2002JE002006},
+}
+
+@article{Smit:93grubi,
+  title={{Aerial Observations of Hawaii's Wake}},
+  author={Smith, R.B. and Grubi{\v{s}}i{\'c}, V.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={50},
+  number={22},
+  pages={3728--3750},
+  year={1993},
+  publisher={American Meteorological Society}
+}
+
+
+@article{Rotu:99,
+  title={{Vorticity and Potential Vorticity in Mountain Wakes}},
+  author={Rotunno, R. and Grubi{\v{s}}i{\'c}, V. and Smolarkiewicz, PK},
+  journal={Journal of the Atmospheric Sciences},
+  volume={56},
+  number={16},
+  pages={2796--2810},
+  year={1999},
+  publisher={American Meteorological Society}
+}
+
+@article{Spig:08grl,
+  title={{Fast and accurate estimation of solar irradiance on Martian slopes}},
+  author={Spiga, A. and Forget, F.},
+  journal=grl,
+  volume={35},
+  pages={L15201},
+  year={2008},
+}
+
+@article{Smit:08,
+  title={Spacecraft Observations of the Martian Atmosphere},
+  author={Smith, M.~D.},
+  journal={Annu. Rev. Earth Planet. Sci},
+  year={2008},
+  volume={36},
+  pages={191--219}
+}
+
+@ARTICLE{Poll:76,
+   author = {{Pollack}, J.~B. and {Leovy}, C.~B. and {Mintz}, Y.~H. and {van Camp}, W.},
+    title = "{Winds on Mars during the Viking season - Predictions based on a general circulation model with topography}",
+  journal = grl,
+     year = 1976,
+   volume = 3,
+    pages = {479-482},
+}
+
+@ARTICLE{Balm:03,
+   author = {{Balme}, M.~R. and {Whelley}, P.~L. and {Greeley}, R.},
+    title = "{Mars: Dust devil track survey in Argyre Planitia and Hellas Basin}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {5086-+},
+      doi = {10.1029/2003JE002096},
+}
+
+@misc{Pari:03,
+  title={{Katabatic winds. Encyclopedia of Atmospheric Sciences, JR Holton, J. Pyle, and J. A. Curry, Eds}},
+  author={Parish, T.~R.},
+  year={2003},
+  publisher={Academic Press}
+}
+
+@misc{Durr:03enc,
+  title={{Lee waves and mountain waves. Encyclopedia of Atmospheric Sciences, JR Holton, J. Pyle, and J. A. Curry, Eds}},
+  author={Durran, D.},
+  year={2003},
+  publisher={Academic Press}
+}
+
+@ARTICLE{Forg:06blague,
+   author = {{Forget}, F. and {Schmitt}, B.},
+    title = "{Katabatic winds in Greenland: the no-wind case.}",
+  journal = {Journal of Advanced Kite-Surfing},
+     year = 2006,
+   volume = 66,
+    pages = {99-+},
+}
+
+
+@ARTICLE{Vinc:08,
+   author = {{Vincendon}, M. and {Langevin}, Y. and {Poulet}, F. and {Bibring}, J.-P. and 
+	{Gondet}, B. and {Jouglet}, D. and {OMEGA Team}},
+    title = "{Dust aerosols above the south polar cap of Mars as seen by OMEGA}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 196,
+    pages = {488-505},
+      doi = {10.1016/j.icarus.2007.11.034},
+}
+
+@INPROCEEDINGS{Joug:08,
+   author = {{Jouglet}, D. and {Poulet}, F. and {Langevin}, Y. and {Bibring}, J.-P. and {Gondet}, B. and {Vincendon}, M.},
+    title = "{Hydration of the Martian Southern Hemiphere Using the OMEGA Dataset}",
+booktitle = {Lunar and Planetary Institute Conference Abstracts},
+     year = 2008,
+   series = {Lunar and Planetary Institute Conference Abstracts},
+   volume = 39,
+    pages = {1752-+},
+}
+
+@article{Rein:08,
+  title={{Estimating Topographic Blocking Using a Froude Number When the Static Stability Is Nonuniform}},
+  author={Reinecke, P.A. and Durran, D.R.},
+  journal={Journal of the Atmospheric Sciences},
+  volume={65},
+  number={3},
+  pages={1035--1048},
+  year={2008},
+  publisher={American Meteorological Society}
+}
+
+@article{Harr:08,
+  title={{Lee vortices in evolving large-scale flows}},
+  author={Harris, L.M.},
+  journal={13th Conference on Mountain Meteorology},
+  year={2008}
+}
+
+
+@ARTICLE{Bell:06jim,
+   author = {{Bell}, J.~F. and {Savransky}, D. and {Wolff}, M.~J.},
+    title = "{Chromaticity of the Martian sky as observed by the Mars Exploration Rover Pancam instruments}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {12-+},
+      doi = {10.1029/2006JE002687},
+}
+
+@article{Smit:31,
+  title={{The CIE colorimetric standards and their use}},
+  author={Smith, T. and Guild, J.},
+  journal={Transactions of the Optical Society},
+  volume={33},
+  pages={73--134},
+  year={1931},
+  publisher={Institute of Physics Publishing}
+}
+
+@misc{Stok:96,
+  author={Stokes, M. and Anderson, M. and Chandrasekar, S. and Motta, R.},
+  title={A standard default color space for the Internet sRGB},
+  year={1996},
+  howpublished = {Microsoft and Hewlett-Packard Joint Report, Version 1.10. (Available at {\tt http://www.w3.org/Graphics/Color/sRGB})}
+}
+
+@ARTICLE{Cola:08,
+   author = {{Colaprete}, A. and {Barnes}, J.~R. and {Haberle}, R.~M. and 
+	{Montmessin}, F.},
+   title = "{CO$_{2}$ clouds, CAPE and convection on Mars: Observations and general circulation modeling}",
+   journal = pss,
+   year = 2008,
+   volume = 56,
+   pages = {150-180},
+   doi = {10.1016/j.pss.2007.08.010},
+}
+
+@article{Dyud:08,
+  title={{Dynamics of Saturn's South Polar Vortex}},
+  author={Dyudina, U.A. and Ingersoll, A.P. and Ewald, S.P. and Vasavada, A.R. and West, R.A. and Del Genio, A.D. and Barbara, J.M. and Porco, C.C. and Achterberg, R.K. and Flasar, F.M. and others},
+  journal={Science},
+  volume={319},
+  number={5871},
+  pages={1801},
+  year={2008},
+  publisher={AAAS}
+}
+
+@article{Reut:07,
+  title={{Jupiter Cloud Composition, Stratification, Convection, and Wave Motion: A View from New Horizons}},
+  author={Reuter, DC and Simon-Miller, AA and Lunsford, A. and Baines, KH and Cheng, AF and Jennings, DE and Olkin, CB and Spencer, JR and Stern, SA and Weaver, HA and others},
+  journal={Science},
+  volume={318},
+  number={5848},
+  pages={223},
+  year={2007},
+  publisher={AAAS}
+}
+
+@article{Bart:07,
+  title={{TRAMS: A new dynamic cloud model for Titan's methane clouds}},
+  author={Barth, E.L. and Rafkin, S.C.R.},
+  journal=grl,
+  volume={34},
+  pages={L03203},
+  year={2007}
+}
+
+@article{Sanc:08,
+  title={{Variable winds on Venus mapped in three dimensions}},
+  author={S{\'a}nchez-Lavega, A. and Hueso, R. and Piccioni, G. and Drossart, P. and Peralta, J. and P{\'e}rez-Hoyos, S. and Wilson, CF and Taylor, FW and Baines, KH and Luz, D. and others},
+  journal={Geophysical Research Letters},
+  volume={35},
+  number={13},
+  year={2008}
+}
+
+@article{Hayw:07,
+  title={{Mars Global Digital Dune Database and initial science results}},
+  author={Hayward, R.K. and Mullins, K.F. and Fenton, L.K. and Hare, T.M. and Titus, T.N. and Bourke, M.C. and Colaprete, A. and Christensen, P.R.},
+  journal={Journal of Geophysical Research},
+  volume={112},
+  number={E11},
+  year={2007}
+}
+
+@article{Bant:04,
+  title={{Nocturnal Low-Level Jet in a Mountain Basin Complex. Part I: Evolution and Effects on Local Flows}},
+  author={Banta, R.M. and Darby, L.S. and Fast, J.D. and Pinto, J.O. and Whiteman, C.D. and Shaw, W.J. and Orr, B.W.},
+  journal={Journal of Applied Meteorology},
+  volume={43},
+  number={10},
+  pages={1348--1365},
+  year={2004},
+  publisher={NOAA Central Library, Department of Commerce}
+}
+
+@misc{Egge:03,
+  title={{Valley winds. Encyclopedia of Atmospheric Sciences, JR Holton, J. Pyle, and J. A. Curry, Eds}},
+  author={Egger, J.},
+  year={2003},
+  publisher={Academic Press}
+}
+
+@INPROCEEDINGS{Spig:03,
+   author = {{Haberle}, R.~M. and {Montmessin}, F. and {Forget}, F. and {Spiga}, A. and 
+	{Colaprete}, A.},
+   title = "{Obliquity Driven Climate Change in Mars' Recent Past}",
+booktitle = {Third International Conference on Mars Polar Science and Exploration},
+   year = 2003,
+   editor = {{Clifford}, S. and {Doran}, P. and {Fisher}, D. and {Herd}, C.
+	},
+    pages = {8060-+},
+}
+
+@ARTICLE{Lian:08,
+   author = {{Lian}, Y. and {Showman}, A.~P.},
+   title = "{Deep jets on gas-giant planets}",
+   journal = {Icarus},
+   year = 2008,
+   volume = 194,
+   pages = {597-615},
+   doi = {10.1016/j.icarus.2007.10.014},
+}
+
+@ARTICLE{Heim:05,
+   author = {{Heimpel}, M. and {Aurnou}, J. and {Wicht}, J.},
+   title = "{Simulation of equatorial and high-latitude jets on Jupiter in a deep convection model}",
+   journal = {Nature},
+   year = 2005,
+   volume = 438,
+    pages = {193-196},
+}
+
+@ARTICLE{Fouc:08,
+   author = {{Fouchet}, T. and {Guerlet}, S. and {Strobel}, D.~F. and {Simon-Miller}, A.~A. and 
+	{B{\'e}zard}, B. and {Flasar}, F.~M.},
+   title = "{An equatorial oscillation in Saturn's middle atmosphere}",
+   journal = {Nature},
+   year = 2008,
+   volume = 453,
+   pages = {200-202},
+   doi = {10.1038/nature06912},
+}
+
+@ARTICLE{Spig:08gw,
+   author = {{Spiga}, A. and {Teitelbaum}, H. and {Zeitlin}, V.},
+   title = "{Identification of the sources of inertia-gravity waves in the Andes Cordillera region}",
+   journal = {Annales Geophysicae},
+   year = 2008,
+   volume = 26,
+   pages = {2551-2568},
+}
+
+@ARTICLE{Lewi:07,
+   author = {{Lewis}, S.~R. and {Read}, P.~L. and {Conrath}, B.~J. and {Pearl}, J.~C. and 
+	{Smith}, M.~D.},
+    title = "{Assimilation of thermal emission spectrometer atmospheric data during the Mars Global Surveyor aerobraking period}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 192,
+    pages = {327-347},
+      doi = {10.1016/j.icarus.2007.08.009},
+}
+
+@ARTICLE{Flas:05,
+   author = {{Flasar}, F.~M. and {Achterberg}, R.~K. and {Conrath}, B.~J. and 
+	{Pearl}, J.~C. and {Bjoraker}, G.~L. and {Jennings}, D.~E. and 
+	{Romani}, P.~N. and {Simon-Miller}, A.~A. and {Kunde}, V.~G. and 
+	{Nixon}, C.~A. and {B{\'e}zard}, B. and {Orton}, G.~S. and {Spilker}, L.~J. and 
+	{Spencer}, J.~R. and {Irwin}, P.~G.~J. and {Teanby}, N.~A. and 
+	{Owen}, T.~C. and {Brasunas}, J. and {Segura}, M.~E. and {Carlson}, R.~C. and 
+	{Mamoutkine}, A. and {Gierasch}, P.~J. and {Schinder}, P.~J. and 
+	{Showalter}, M.~R. and {Ferrari}, C. and {Barucci}, A. and {Courtin}, R. and 
+	{Coustenis}, A. and {Fouchet}, T. and {Gautier}, D. and {Lellouch}, E. and 
+	{Marten}, A. and {Prang{\'e}}, R. and {Strobel}, D.~F. and {Calcutt}, S.~B. and 
+	{Read}, P.~L. and {Taylor}, F.~W. and {Bowles}, N. and {Samuelson}, R.~E. and 
+	{Abbas}, M.~M. and {Raulin}, F. and {Ade}, P. and {Edgington}, S. and 
+	{Pilorz}, S. and {Wallis}, B. and {Wishnow}, E.~H.},
+    title = "{Temperatures, Winds, and Composition in the Saturnian System}",
+  journal = {Science},
+     year = 2005,
+   volume = 307,
+    pages = {1247-1251},
+      doi = {10.1126/science.1105806},
+}
+
+@ARTICLE{Porc:05,
+   author = {{Porco}, C.~C. and {Baker}, E. and {Barbara}, J. and {Beurle}, K. and 
+	{Brahic}, A. and {Burns}, J.~A. and {Charnoz}, S. and {Cooper}, N. and 
+	{Dawson}, D.~D. and {Del Genio}, A.~D. and {Denk}, T. and {Dones}, L. and 
+	{Dyudina}, U. and {Evans}, M.~W. and {Giese}, B. and {Grazier}, K. and 
+	{Helfenstein}, P. and {Ingersoll}, A.~P. and {Jacobson}, R.~A. and 
+	{Johnson}, T.~V. and {McEwen}, A. and {Murray}, C.~D. and {Neukum}, G. and 
+	{Owen}, W.~M. and {Perry}, J. and {Roatsch}, T. and {Spitale}, J. and 
+	{Squyres}, S. and {Thomas}, P. and {Tiscareno}, M. and {Turtle}, E. and 
+	{Vasavada}, A.~R. and {Veverka}, J. and {Wagner}, R. and {West}, R.
+	},
+    title = "{Cassini Imaging Science: Initial Results on Saturn's Atmosphere}",
+  journal = {Science},
+     year = 2005,
+   volume = 307,
+    pages = {1243-1247},
+      doi = {10.1126/science.1107691},
+}
+
+@ARTICLE{Porc:03,
+   author = {{Porco}, C.~C. and {West}, R.~A. and {McEwen}, A. and {Del Genio}, A.~D. and 
+	{Ingersoll}, A.~P. and {Thomas}, P. and {Squyres}, S. and {Dones}, L. and 
+	{Murray}, C.~D. and {Johnson}, T.~V. and {Burns}, J.~A. and 
+	{Brahic}, A. and {Neukum}, G. and {Veverka}, J. and {Barbara}, J.~M. and 
+	{Denk}, T. and {Evans}, M. and {Ferrier}, J.~J. and {Geissler}, P. and 
+	{Helfenstein}, P. and {Roatsch}, T. and {Throop}, H. and {Tiscareno}, M. and 
+	{Vasavada}, A.~R.},
+    title = "{Cassini Imaging of Jupiter's Atmosphere, Satellites, and Rings}",
+  journal = {Science},
+     year = 2003,
+   volume = 299,
+    pages = {1541-1547},
+      doi = {10.1126/science.1079462},
+}
+
+@ARTICLE{Flas:04,
+   author = {{Flasar}, F.~M. and {Kunde}, V.~G. and {Achterberg}, R.~K. and 
+	{Conrath}, B.~J. and {Simon-Miller}, A.~A. and {Nixon}, C.~A. and 
+	{Gierasch}, P.~J. and {Romani}, P.~N. and {B{\'e}zard}, B. and 
+	{Irwin}, P. and {Bjoraker}, G.~L. and {Brasunas}, J.~C. and 
+	{Jennings}, D.~E. and {Pearl}, J.~C. and {Smith}, M.~D. and 
+	{Orton}, G.~S. and {Spilker}, L.~J. and {Carlson}, R. and {Calcutt}, S.~B. and 
+	{Read}, P.~L. and {Taylor}, F.~W. and {Parrish}, P. and {Barucci}, A. and 
+	{Courtin}, R. and {Coustenis}, A. and {Gautier}, D. and {Lellouch}, E. and 
+	{Marten}, A. and {Prang{\'e}}, R. and {Biraud}, Y. and {Fouchet}, T. and 
+	{Ferrari}, C. and {Owen}, T.~C. and {Abbas}, M.~M. and {Samuelson}, R.~E. and 
+	{Raulin}, F. and {Ade}, P. and {C{\'e}sarsky}, C.~J. and {Grossman}, K.~U. and 
+	{Coradini}, A.},
+    title = "{An intense stratospheric jet on Jupiter}",
+  journal = {Nature},
+     year = 2004,
+   volume = 427,
+    pages = {132-135},
+}
+
+@ARTICLE{Li:08,
+   author = {{Li}, L. and {Gierasch}, P.~J. and {Achterberg}, R.~K. and 
+	{Conrath}, B.~J. and {Flasar}, F.~M. and {Vasavada}, A.~R. and 
+	{Ingersoll}, A.~P. and {Banfield}, D. and {Simon-Miller}, A.~A. and 
+	{Fletcher}, L.~N.},
+    title = "{Strong jet and a new thermal wave in Saturn's equatorial stratosphere}",
+  journal = grl,
+     year = 2008,
+   volume = 35,
+    pages = {23208-+},
+      doi = {10.1029/2008GL035515},
+}
+
+@ARTICLE{Leov:91,
+   author = {{Leovy}, C.~B. and {Friedson}, A.~J. and {Orton}, G.~S.},
+    title = "{The quasiquadrennial oscillation of Jupiter's equatorial stratosphere}",
+  journal = {Nature},
+     year = 1991,
+   volume = 354,
+    pages = {380-382},
+      doi = {10.1038/354380a0},
+}
+
+@ARTICLE{Howe:07,
+   author = {{Howett}, C.~J.~A. and {Irwin}, P.~G.~J. and {Teanby}, N.~A. and 
+	{Simon-Miller}, A. and {Calcutt}, S.~B. and {Fletcher}, L.~N. and 
+	{de Kok}, R.},
+    title = "{Meridional variations in stratospheric acetylene and ethane in the southern hemisphere of the saturnian atmosphere as determined from Cassini/CIRS measurements}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 190,
+    pages = {556-572},
+      doi = {10.1016/j.icarus.2007.03.009},
+}
+
+@ARTICLE{Sanc:08,
+   author = {{S{\'a}nchez-Lavega}, A. and {Orton}, G.~S. and {Hueso}, R. and 
+	{Garc{\'{\i}}a-Melendo}, E. and {P{\'e}rez-Hoyos}, S. and {Simon-Miller}, A. and 
+	{Rojas}, J.~F. and {G{\'o}mez}, J.~M. and {Yanamandra-Fisher}, P. and 
+	{Fletcher}, L. and {Joels}, J. and {Kemerer}, J. and {Hora}, J. and 
+	{Karkoschka}, E. and {de Pater}, I. and {Wong}, M.~H. and {Marcus}, P.~S. and 
+	{Pinilla-Alonso}, N. and {Carvalho}, F. and {Go}, C. and {Parker}, D. and 
+	{Salway}, M. and {Valimberti}, M. and {Wesley}, A. and {Pujic}, Z.
+	},
+    title = "{Depth of a strong jovian jet from a planetary-scale disturbance driven by storms}",
+  journal = {Nature},
+     year = 2008,
+   volume = 451,
+    pages = {437-440},
+      doi = {10.1038/nature06533},
+}
+
+@ARTICLE{Dyud:07,
+   author = {{Dyudina}, U.~A. and {Ingersoll}, A.~P. and {Ewald}, S.~P. and 
+	{Porco}, C.~C. and {Fischer}, G. and {Kurth}, W. and {Desch}, M. and 
+	{Del Genio}, A. and {Barbara}, J. and {Ferrier}, J.},
+    title = "{Lightning storms on Saturn observed by Cassini ISS and RPWS during 2004 2006}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 190,
+    pages = {545-555},
+      doi = {10.1016/j.icarus.2007.03.035},
+}
+
+@ARTICLE{Show:08,
+   author = {{Showman}, A.~P. and {Cooper}, C.~S. and {Fortney}, J.~J. and 
+	{Marley}, M.~S.},
+    title = "{Atmospheric Circulation of Hot Jupiters: Three-dimensional Circulation Models of HD 209458b and HD 189733b with Simplified Forcing}",
+  journal = apj,
+archivePrefix = "arXiv",
+   eprint = {0802.0327},
+     year = 2008,
+   volume = 682,
+    pages = {559-576},
+      doi = {10.1086/589325},
+}
+
+@ARTICLE{Pera:08,
+   author = {{Peralta}, J. and {Hueso}, R. and {S{\'a}nchez-Lavega}, A. and 
+	{Piccioni}, G. and {Lanciano}, O. and {Drossart}, P.},
+    title = "{Characterization of mesoscale gravity waves in the upper and lower clouds of Venus from VEX-VIRTIS images}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+    pages = {0-+},
+      doi = {10.1029/2008JE003185},
+}
+
+@ARTICLE{Rafk:09,
+   author = {{Rafkin}, S.~C.~R.},
+    title = "{A positive radiative-dynamic feedback mechanism for the maintenance and growth of Martian dust storms}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2009,
+   volume = 114,
+   number = {E13},
+    pages = {1009-+},
+      doi = {10.1029/2008JE003217},
+}
+
+
+@ARTICLE{Hins:08,
+   author = {{Hinson}, D.~P. and {P{\"a}tzold}, M. and {Tellmann}, S. and 
+	{H{\"a}usler}, B. and {Tyler}, G.~L.},
+    title = "{The depth of the convective boundary layer on Mars}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 198,
+    pages = {57-66},
+      doi = {10.1016/j.icarus.2008.07.003},
+}
+
+@ARTICLE{Li:00qqo,
+   author = {{Li}, X. and {Read}, P.~L.},
+    title = "{A mechanistic model of the quasi-quadrennial oscillation in Jupiter's stratosphere}",
+  journal = pss,
+     year = 2000,
+   volume = 48,
+    pages = {637-669},
+}
+
+@ARTICLE{Hues:01,
+   author = {{Hueso}, R. and {S{\'a}nchez-Lavega}, A.},
+    title = "{A Three-Dimensional Model of Moist Convection for the Giant Planets: The Jupiter Case}",
+  journal = {Icarus},
+     year = 2001,
+   volume = 151,
+    pages = {257-274},
+      doi = {10.1006/icar.2000.6606},
+}
+
+@ARTICLE{Russ:06,
+   author = {{Russell}, C.~T. and {Strangeway}, R.~J. and {Zhang}, T.~L.},
+    title = "{Lightning detection on the Venus Express mission}",
+  journal = pss,
+     year = 2006,
+   volume = 54,
+    pages = {1344-1351},
+      doi = {10.1016/j.pss.2006.04.026},
+}
+
+@ARTICLE{Ring:07,
+   author = {{Ringrose}, T.~J. and {Patel}, M.~R. and {Towner}, M.~C. and 
+	{Balme}, M. and {Metzger}, S.~M. and {Zarnecki}, J.~C.},
+    title = "{The meteorological signatures of dust devils on Mars}",
+  journal = pss,
+     year = 2007,
+   volume = 55,
+    pages = {2151-2163},
+      doi = {10.1016/j.pss.2007.07.002},
+}
+
+@ARTICLE{Stan:08,
+   author = {{Stanzel}, C. and {P{\"a}tzold}, M. and {Williams}, D.~A. and 
+	{Whelley}, P.~L. and {Greeley}, R. and {Neukum}, G. and {The HRSC Co-Investigator Team}
+	},
+    title = "{Dust devil speeds, directions of motion and general characteristics observed by the Mars Express High Resolution Stereo Camera}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 197,
+    pages = {39-51},
+      doi = {10.1016/j.icarus.2008.04.017},
+}
+
+@INPROCEEDINGS{Wolk:08,
+   author = {
+{Wolkenberg}, P. and 
+{Formisano}, V. and 
+{Rinaldi}, G. and 
+{D'Amore}, M. and 
+{Geminale}, A. and 
+{Montabone}, L. and 
+{Spiga}, A. and 
+{Michaels}, T.
+}, 
+    title = "{An atmospheric hot ring around Olympus Mons – comparison with mesoscale models}",
+booktitle = {3rd Internat.Workshop on the Mars Atmosph.: Modeling and Observations, Williamsburg, USA},
+     year = 2008,
+}
+
+@ARTICLE{Will:03,
+   author = {{Williams}, G.~P.},
+    title = "{Jovian Dynamics. Part III: Multiple, Migrating, and Equatorial Jets.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2003,
+   volume = 60,
+    pages = {1270-1296},
+      doi = {10.1175/1520-0469(2003)60},
+}
+
+@ARTICLE{Yano:05,
+   author = {{Yano}, J.-I. and {Talagrand}, O. and {Drossart}, P.},
+    title = "{Deep two-dimensional turbulence: An idealized model for atmospheric jets of the giant outer planets}",
+  journal = {Geophysical and Astrophysical Fluid Dynamics},
+     year = 2005,
+   volume = 99,
+    pages = {137-150},
+      doi = {10.1080/03091920412331336398},
+}
+
+@ARTICLE{Li:06,
+   author = {{Li}, L. and {Ingersoll}, A.~P. and {Huang}, X.},
+    title = "{Interaction of moist convection with zonal jets on Jupiter and Saturn}",
+  journal = {Icarus},
+     year = 2006,
+   volume = 180,
+    pages = {113-123},
+      doi = {10.1016/j.icarus.2005.08.016},
+}
+
+@ARTICLE{Lian:10,
+   author = {{Lian}, Y. and {Showman}, A.~P.},
+    title = "{Generation of equatorial jets by large-scale latent heating on the giant planets}",
+  journal = {Icarus},
+archivePrefix = "arXiv",
+   eprint = {0910.3065},
+     year = 2010,
+   volume = 207,
+    pages = {373-393},
+      doi = {10.1016/j.icarus.2009.10.006},
+}
+
+
+@ARTICLE{Lebo:08gcm,
+   author = {{Lebonnois}, S. and {Forget}, F. and {Hourdin}, F.},
+    title = "{Using Terrestrial GCMs to Understand Climate on Venus, Mars and Titan}",
+  journal = {AGU Fall Meeting Abstracts},
+     year = 2008,
+    pages = {B2+},
+}
+
+@ARTICLE{Hour:04,
+   author = {{Hourdin}, F. and {Lebonnois}, S. and {Luz}, D. and {Rannou}, P.
+	},
+    title = "{Titan's stratospheric composition driven by condensation and dynamics}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2004,
+   volume = 109,
+    pages = {12005-+},
+      doi = {10.1029/2004JE002282},
+}
+
+@ARTICLE{Hour:06,
+   author = {{Hourdin}, F. and {Musat}, I. and {Bony}, S. and {Braconnot}, P. and 
+	{Codron}, F. and {Dufresne}, J.-L. and {Fairhead}, L. and {Filiberti}, M.-A. and 
+	{Friedlingstein}, P. and {Grandpeix}, J.-Y. and {Krinner}, G. and 
+	{Levan}, P. and {Li}, Z.-X. and {Lott}, F.},
+    title = "{The LMDZ4 general circulation model: climate performance and sensitivity to parametrized physics with emphasis on tropical convection}",
+  journal = {Climate Dynamics},
+     year = 2006,
+   volume = 27,
+    pages = {787-813},
+      doi = {10.1007/s00382-006-0158-0},
+}
+
+@ARTICLE{Blum:73,
+   author = {{Blumsack}, S.~L. and {Gierasch}, P.~J. and {Wessel}, W.~R.},
+    title = "{An analytical and numerical study of the Martian planetary boundary layer over slopes.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 1973,
+   volume = 30,
+    pages = {66-82},
+      doi = {10.1175/1520-0469(1973)030},
+}
+
+@ARTICLE{Mich:08,
+   author = {{Michaels}, T.~I. and {Rafkin}, S.~C.~R.},
+    title = "{Meteorological predictions for candidate 2007 Phoenix Mars Lander sites using the Mars Regional Atmospheric Modeling System (MRAMS)}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+   number = {E12},
+    pages = {0-+},
+      doi = {10.1029/2007JE003013},
+}
+
+@ARTICLE{Tyle:08,
+   author = {{Tyler}, D. and {Barnes}, J.~R. and {Skyllingstad}, E.~D.},
+    title = "{Mesoscale and large-eddy simulation model studies of the Martian atmosphere in support of Phoenix}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+   number = {E12},
+    pages = {0-+},
+      doi = {10.1029/2007JE003012},
+}
+
+@ARTICLE{Dear:80,
+   author = {{Deardorff}, J.~W.},
+    title = "{Stratocumulus-capped mixed layers derived from a three-dimensional model}",
+  journal = {Boundary-Layer Meteorology},
+     year = 1980,
+   volume = 18,
+    pages = {495-527},
+      doi = {10.1007/BF00119502},
+}
+
+@ARTICLE{Wild:85,
+   author = {{Wilde}, N.~P. and {Stull}, R.~B. and {Eloranta}, E.~W.},
+    title = "{The LCL Zone and Cumulus Onset.}",
+  journal = {Journal of Applied Meteorology},
+     year = 1985,
+   volume = 24,
+    pages = {640-657},
+      doi = {10.1175/1520-0450(1985)024},
+}
+
+@ARTICLE{Barn:08,
+   author = {{Barnes}, J.~R. and {Tyler}, D. and {Hinson}, D.~P.},
+    title = "{The Depth of the Daytime Convective Boundary Layer on Mars: A Case of Extremes}",
+  journal = {LPI Contributions},
+     year = 2008,
+   volume = 1447,
+    pages = {9076-+},
+}
+
+@ARTICLE{Whit:09,
+   author = {{Whiteway}, J.~A. and {Komguem}, L. and {Dickinson}, C. and 
+	{Cook}, C. and {Illnicki}, M. and {Seabrook}, J. and {Popovici}, V. and 
+	{Duck}, T.~J. and {Davy}, R. and {Taylor}, P.~A. and {Pathak}, J. and 
+	{Fisher}, D. and {Carswell}, A.~I. and {Daly}, M. and {Hipkin}, V. and 
+	{Zent}, A.~P. and {Hecht}, M.~H. and {Wood}, S.~E. and {Tamppari}, L.~K. and 
+	{Renno}, N. and {Moores}, J.~E. and {Lemmon}, M.~T. and {Daerden}, F. and 
+	{Smith}, P.~H.},
+    title = "{Mars Water-Ice Clouds and Precipitation}",
+  journal = {Science},
+     year = 2009,
+   volume = 325,
+    pages = {68-},
+      doi = {10.1126/science.1172344},
+}
+
+@ARTICLE{Hors:86,
+   author = {{Horst}, T.~W. and {Doran}, J.~C.},
+    title = "{Nocturnal drainage flow on simple slopes}",
+  journal = {Boundary-Layer Meteorology},
+     year = 1986,
+   volume = 34,
+    pages = {263-286},
+      doi = {10.1007/BF00122382},
+}
+
+@article{Papa:99,
+  title={{Evening and morning transition of katabatic flows}},
+  author={Papadopoulos, KH and Helmis, CG},
+  journal={Boundary-Layer Meteorology},
+  volume={92},
+  number={2},
+  pages={195--227},
+  year={1999},
+}
+
+@ARTICLE{Mahr:90,
+   author = {{Mahrt}, L. and {Larsen}, S.},
+    title = "{Relation of slope winds to the ambient flow over gentle terrain}",
+  journal = {Boundary-Layer Meteorology},
+     year = 1990,
+   volume = 53,
+    pages = {93-102},
+      doi = {10.1007/BF00122465},
+}
+
+@ARTICLE{Drob:03,
+   author = {{Drobinski}, P. and {Haeberli}, C. and {Richard}, E. and {Lothon}, M. and 
+	{Dabas}, A.~M. and {Flamant}, P.~H. and {Furger}, M. and {Steinacker}, R.
+	},
+    title = "{Scale interaction processes during the MAP IOP 12 south foehn event in the Rhine Valley}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2003,
+   volume = 129,
+    pages = {729-753},
+      doi = {10.1256/qj.02.35},
+}
+
+@ARTICLE{Skyl:03,
+   author = {{Skyllingstad}, E.~D.},
+    title = "{Large-Eddy Simulation of Katabatic Flows}",
+  journal = {Boundary-Layer Meteorology},
+     year = 2003,
+   volume = 106,
+    pages = {217-243},
+      doi = {10.1023/A:1021142828676},
+}
+
+@ARTICLE{Whit:99,
+   author = {{Whiteman}, C.~D. and {Zhong}, S. and {Bian}, X.},
+    title = "{Wintertime Boundary Layer Structure in the Grand Canyon.}",
+  journal = {Journal of Applied Meteorology},
+     year = 1999,
+   volume = 38,
+    pages = {1084-1102},
+      doi = {10.1175/1520-0450(1999)038},
+}
+
+@ARTICLE{Dora:90,
+   author = {{Doran}, J.~C. and {Horst}, T.~W. and {Whiteman}, C.~D.},
+    title = "{The development and structure of nocturnal slope winds in a simple valley}",
+  journal = {Boundary-Layer Meteorology},
+     year = 1990,
+   volume = 52,
+    pages = {41-68},
+      doi = {10.1007/BF00123177},
+}
+
+@ARTICLE{Pari:87,
+   author = {{Parish}, T.~R. and {Waight}, K.~T.},
+    title = "{The Forcing of Antarctic Katabatic Winds}",
+  journal = {Monthly Weather Review},
+     year = 1987,
+   volume = 115,
+    pages = {2214-+},
+      doi = {10.1175/1520-0493(1987)115},
+}
+
+@ARTICLE{Nyle:04,
+   author = {{Nylen}, T.~H. and {Fountain}, A.~G. and {Doran}, P.~T.},
+    title = "{Climatology of katabatic winds in the McMurdo dry valleys, southern Victoria Land, Antarctica}",
+  journal = {Journal of Geophysical Research (Atmospheres)},
+     year = 2004,
+   volume = 109,
+    pages = {D03114},
+      doi = {10.1029/2003JD003937},
+}
+
+@ARTICLE{Pari:07,
+   author = {{Parish}, T.~R. and {Bromwich}, D.~H.},
+    title = "{Reexamination of the Near-Surface Airflow over the Antarctic Continent and Implications on Atmospheric Circulations at High Southern Latitudes}",
+  journal = {Monthly Weather Review},
+     year = 2007,
+   volume = 135,
+    pages = {1961-+},
+      doi = {10.1175/MWR3374.1},
+}
+
+@ARTICLE{Lars:02,
+   author = {{Larsen}, S.~E. and {J{\o}rgensen}, H.~E. and {Landberg}, L. and 
+	{et al.}},
+    title = "{Aspects Of The Atmospheric Surface Layers On Mars And Earth}",
+  journal = {Boundary-Layer Meteorology},
+     year = 2002,
+   volume = 105,
+    pages = {451-470},
+      doi = {10.1023/A:1020338016753},
+}
+
+@ARTICLE{Hess:81,
+   author = {{Hess}, G.~D. and {Hicks}, B.~B. and {Yamada}, T.},
+    title = "{The impact of the Wangara experiment}",
+  journal = {Boundary-Layer Meteorology},
+     year = 1981,
+   volume = 20,
+    pages = {135-174},
+      doi = {10.1007/BF00119899},
+}
+
+@ARTICLE{Basu:08,
+   author = {{Basu}, S. and {Vinuesa}, J.-F. and {Swift}, A.},
+    title = "{Dynamic LES Modeling of a Diurnal Cycle}",
+  journal = {Journal of Applied Meteorology and Climatology},
+     year = 2008,
+   volume = 47,
+    pages = {1156-+},
+      doi = {10.1175/2007JAMC1677.1},
+}
+
+@ARTICLE{Mart:09,
+   author = {{Mart{\'{\i}}nez}, G. and {Valero}, F. and {V{\'a}zquez}, L.
+	},
+    title = "{Characterization of the Martian Convective Boundary Layer}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2009,
+   volume = 66,
+    pages = {2044-2058},
+}
+
+@article{Spig:10bl,
+   author = {Spiga, A. and Forget, F. and Lewis, S.~R. and Hinson, D.~P.},
+   journal = {Quarterly Journal of the Royal Meteorological Society},
+   title = {Structure and Dynamics of the Convective Boundary Layer on Mars as Inferred from Large-Eddy Simulations and Remote-Sensing Measurements},
+   year = {2010},
+   volume = 136,
+   pages = {414-428},
+}
+
+@ARTICLE{Alti:09,
+   author = {{Altieri}, F. and {Zasova}, L. and {D'Aversa}, E. and 
+	{Bellucci}, G. and {Carrozzo}, F.~G. and {Gondet}, B. and {Bibring}, {J.-P.}
+	},
+    title = "{O$_{2}$ 1.27 {$\mu$}m emission maps as derived from OMEGA/MEx data}",
+  journal = {Icarus},
+     year = 2009,
+   volume = 204,
+    pages = {499-511},
+      doi = {10.1016/j.icarus.2009.07.022},
+}
+
+@ARTICLE{Melo:06,
+   author = {{Melo}, S.~M.~L. and {Chiu}, O. and {Garcia-Munoz}, A. and {Strong}, K. and 
+	{McConnell}, J.~C. and {Slanger}, T.~G. and {Taylor}, M.~J. and 
+	{Lowe}, R.~P. and {McDade}, I.~C. and {Huestis}, D.~L.},
+    title = "{Using airglow measurements to observe gravity waves in the Martian atmosphere}",
+  journal = {Advances in Space Research},
+     year = 2006,
+   volume = 38,
+    pages = {730-738},
+      doi = {10.1016/j.asr.2005.08.041},
+}
+
+@ARTICLE{Yute:95,
+   author = {{Yuter}, S.~E. and {Houze}, R.~A.},
+    title = "{Three-Dimensional Kinematic and Microphysical Evolution of Florida Cumulonimbus. Part III: Vertical Mass Transport, Maw Divergence, and Synthesis}",
+  journal = {Monthly Weather Review},
+     year = 1995,
+   volume = 123,
+    pages = {1964-+},
+      doi = {10.1175/1520-0493(1995)123<1964:TDKAME>2.0.CO;2},
+}
+
+@INPROCEEDINGS{Spig:10ti,
+   author = {{Spiga}, A. and {Lewis}, S.~R. and {Forget}, F. and {Millour}, E. and 
+	{Montabone}, L. and {Madeleine}, {J.-B.}},
+    title = "{The Impact of Katabatic Winds on Martian Thermal Inertia Retrievals}",
+booktitle = {Lunar and Planetary Institute Science Conference Abstracts},
+     year = 2010,
+   series = {Lunar and Planetary Inst. Technical Report},
+   volume = 41,
+    pages = {1533},
+}
+
+
+@misc{Alti:10,
+   author = {{Altieri}, F. and {Spiga}, A. and {Zasova}, L. and {Bellucci}, G. and {Bibring}, J.~P.}, 
+   howpublished = {Geophys. Res. Lett. (submitted)},
+   title = {Gravity waves in Mars polar regions: O$_2$ airglow maps and mesoscale modelling},
+   year = {2010}
+}
+
+@misc{Spig:09tasi,
+   author = {{Spiga}, A. and {Bourrier}, V.}, 
+   howpublished = {Report Thales-Alenia Space (november 2009, contract ExoMars Environmental atmospheric support analysis)},
+   title = {Mesoscale Meteorology of the ExoMars Meridiani safe reference landing site in non-dusty spring conditions},
+   year = {2009}
+}
+
+@ARTICLE{Wolf:09,
+   author = {{Wolff}, M.~J. and {Smith}, M.~D. and {Clancy}, R.~T. and {Arvidson}, R. and 
+	{Kahre}, M. and {Seelos}, F. and {Murchie}, S. and {Savij{\"a}rvi}, H.
+	},
+    title = "{Wavelength dependence of dust aerosol single scattering albedo as observed by the Compact Reconnaissance Imaging Spectrometer}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2009,
+   volume = 114,
+   number = {E13},
+    pages = {0-+},
+      doi = {10.1029/2009JE003350},
+}
+
+@ARTICLE{Schn:09,
+   author = {{Schneider}, T. and {Liu}, J.},
+    title = "{Formation of Jets and Equatorial Superrotation on Jupiter}",
+  journal = {Journal of Atmospheric Sciences},
+archivePrefix = "arXiv",
+   eprint = {0809.4302},
+     year = 2009,
+   volume = 66,
+    pages = {579-+},
+      doi = {10.1175/2008JAS2798.1},
+}
+
+@ARTICLE{Lebe:98,
+   author = {{Lebeau}, R.~P. and {Dowling}, T.~E.},
+    title = "{EPIC simulations of time-dependent, three-dimensional vortices with application to Neptune's Great Dark Spot}",
+  journal = {Icarus},
+     year = 1998,
+   volume = 132,
+    pages = {239-265},
+      doi = {10.1006/icar.1998.5918},
+}
+
+@ARTICLE{Dowl:08,
+   author = {{Dowling}, T.~E.},
+    title = "{Music of the stratospheres}",
+  journal = {Nature},
+     year = 2008,
+   volume = 453,
+    pages = {163-164},
+}
+
+@ARTICLE{Mish:96,
+   author = {{Mishchenko}, M.~I. and {Travis}, L.~D. and {Mackowski}, D.~W.
+	},
+    title = "{T-matrix computations of light scattering by nonspherical particles: a review.}",
+  journal = {Journal of Quantitative Spectroscopy and Radiative Transfer},
+     year = 1996,
+   volume = 55,
+    pages = {535-575},
+      doi = {10.1016/0022-4073(96)00002-7},
+}
+
+@ARTICLE{Davy:09,
+   author = {{Davy}, R. and {Taylor}, P.~A. and {Weng}, W. and {Li}, {P.-Y.}
+	},
+    title = "{A model of dust in the Martian lower atmosphere}",
+  journal = {Journal of Geophysical Research (Atmospheres)},
+     year = 2009,
+   volume = 114,
+   number = {D13},
+    pages = {4108-+},
+      doi = {10.1029/2008JD010481},
+}
+
+@ARTICLE{Kauh:08,
+   author = {{Kauhanen}, J. and {Siili}, T. and {J{\"a}rvenoja}, S. and {Savij{\"a}rvi}, H.
+	},
+    title = "{The Mars limited area model and simulations of atmospheric circulations for the Phoenix landing area and season of operation}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+    pages = {E00A14},
+      doi = {10.1029/2007JE003011},
+}
+
+@ARTICLE{Souz:00,
+   author = {{Souza}, E.~P. and {Renn{\'o}}, N.~O. and {Silva Dias}, M.~A.~F.
+	},
+    title = "{Convective Circulations Induced by Surface Heterogeneities.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2000,
+   volume = 57,
+    pages = {2915-2922},
+      doi = {10.1175/1520-0469(2000)057<2915:CCIBSH>2.0.CO;2},
+}
+
+@ARTICLE{Tayl:08,
+   author = {{Taylor}, P.~A. and {Gunnlaugsson}, H.~P. and {Holstein-Rathlou}, C. and 
+	{Lange}, C.~F. and {Moores}, J. and {Cook}, C. and {Dickinson}, C. and 
+	{Popovici}, V. and {Seabrook}, J. and {Whiteway}, J.},
+    title = "{Phoenix: Summer Weather in Green Valley (126W, 68N on Mars)}",
+  journal = {LPI Contributions},
+     year = 2008,
+   volume = 1447,
+    pages = {9024-+},
+}
+
+@ARTICLE{Savi:91comp,
+   author = {{Savijarvi}, H.},
+    title = "{A model study of the PBL structure on Mars and the earth}",
+  journal = {Contributions to Atmospheric Physics/Beitraege zur Physik Atmosphaere},
+     year = 1991,
+   volume = 64,
+    pages = {219-229},
+}
+
+@ARTICLE{Davy:10,
+   author = {{Davy}, R. and {Davis}, J.~A. and {Taylor}, P.~A. and {Lange}, C.~F. and 
+	{Weng}, W. and {Whiteway}, J. and {Gunnlaugson}, H.~P.},
+    title = "{Initial analysis of air temperature and related data from the Phoenix MET station and their use in estimating turbulent heat fluxes}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2010,
+   volume = 115,
+   number = {E14},
+    pages = {0-+},
+      doi = {10.1029/2009JE003444},
+}
+
+@ARTICLE{Encr:08ica,
+   author = {{Encrenaz}, T. and {Greathouse}, T.~K. and {Richter}, M.~J.
+and 
+	{B{\'e}zard}, B. and {Fouchet}, T. and {Lef{\`e}vre}, F. and 
+	{Montmessin}, F. and {Forget}, F. and {Lebonnois}, S. and {Atreya},
+S.~K.
+	},
+    title = "{Simultaneous mapping of H$_2$O and H$_2$O$_2$ on Mars from
+infrared high-resolution imaging spectroscopy}",
+  journal = {Icarus},
+     year = 2008,
+   volume = 195,
+    pages = {547-556},
+      doi = {10.1016/j.icarus.2008.01.022},
+}
+
+@ARTICLE{Lang:08,
+   author = {{Langlais}, B. and {Leblanc}, F. and {Fouchet}, T. and
+{Barabash}, S. and 
+	{Breuer}, D. and {Chassefi{\`e}re}, E. and {Coates}, A. and 
+	{Dehant}, V. and {Forget}, F. and {Lammer}, H. and {Lewis}, S. and 
+	{Lopez-Valverde}, M. and {Mandea}, M. and {Menvielle}, M. and 
+	{Pais}, A. and {Paetzold}, M. and {Read}, P. and {Sotin}, C. and 
+	{Tarits}, P. and {Vennerstrom}, S. and {Branduardi-Raymont}, G. and
+	{Cremonese}, G. and {Merayo}, J.~G.~M. and {Ott}, T. and {R{\`e}me},
+H. and 
+	{Trotignon}, J.~G. and {Walhund}, J.~E.},
+    title = "{Mars environment and magnetic orbiter model payload}",
+  journal = {Experimental Astronomy},
+     year = 2008,
+    pages = {16-+},
+      doi = {10.1007/s10686-008-9101-1},
+}
+
+@ARTICLE{Encr:08aa,
+   author = {{Encrenaz}, T. and {Fouchet}, T. and {Melchiorri}, R. and
+{Drossart}, P. and 
+	{Gondet}, B. and {Langevin}, Y. and {Bibring}, J.-P. and {Forget},
+F. and 
+	{Maltagliati}, L. and {Titov}, D. and {Formisano}, V.},
+    title = "{A study of the Martian water vapor over Hellas using OMEGA
+and PFS aboard Mars Express}",
+  journal = aa,
+     year = 2008,
+   volume = 484,
+    pages = {547-553},
+      doi = {10.1051/0004-6361:20079288},
+}
+
+
+@ARTICLE{Habe:08,
+   author = {{Haberle}, R.~M. and {Forget}, F. and {Colaprete}, A. and
+{Schaeffer}, J. and 
+	{Boynton}, W.~V. and {Kelly}, N.~J. and {Chamberlain}, M.~A.
+	},
+    title = "{The effect of ground ice on the Martian seasonal CO$_2$
+cycle}",
+  journal = pss,
+     year = 2008,
+   volume = 56,
+    pages = {251-255},
+      doi = {10.1016/j.pss.2007.08.006},
+}
+
+@ARTICLE{Cava:08,
+   author = {{Cavali{\'e}}, T. and {Billebaud}, F. and {Encrenaz}, T. and
+
+	{Dobrijevic}, M. and {Brillet}, J. and {Forget}, F. and {Lellouch},
+E.
+	},
+    title = "{Vertical temperature profile and mesospheric winds
+retrieval on Mars from CO ;millimeter observations. Comparison with
+general circulation model predictions}",
+  journal = aap,
+     year = 2008,
+   volume = 489,
+    pages = {795-809},
+      doi = {10.1051/0004-6361:200809815},
+}
+
+@ARTICLE{Gonz:09a,
+   author = {{Gonz{\'a}lez-Galindo}, F. and {Forget}, F. and {L{\'o}pez-Valverde}, M.~A.  and {Angelats i Coll}, M. and {Millour}, E.},
+    title = "{A Ground-to-Exosphere Martian General Circulation Model. 1.
+Seasonal, Diurnal and Solar Cycle Variation of Thermospheric
+Temperatures}",
+  journal = {Journal of Geophysical Research (Planets), in press},
+     year = 2009,
+}
+
+
+@ARTICLE{Gonz:09b,
+   author = {{Gonz{\'a}lez-Galindo}, F. and {Forget}, F. and {L{\'o}pez-Valverde}, M.~A.  and {Angelats i Coll}, M.},
+    title = "{A Ground-to-Exosphere Martian General Circulation Model. 
+2. The Atmosphere During Perihelion Conditions: Thermospheric Polar
+Warming
+}",
+  journal = {Journal of Geophysical Research (Planets), in press},
+     year = 2009,
+}
+
+@ARTICLE{Hour:02,
+   author = {{Hourdin}, F. and {Couvreux}, F. and {Menut}, L.},
+    title = "{Parameterization of the Dry Convective Boundary Layer Based
+on a Mass Flux Representation of Thermals.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 2002,
+   volume = 59,
+    pages = {1105-1123},
+      doi = {10.1175/1520-0469(2002)059},
+}
+
+
+@ARTICLE{Galp:07,
+   author = {{Galperin}, B. and {Sukoriansky}, S. and {Anderson}, P.~S.},
+   title = "{On the critical Richardson number in stably stratified
+turbulence}",
+  journal = {Atmospheric Science Letters},
+     year = 2007,
+   volume = 8,
+    pages = {65-69},
+      doi = {10.1002/asl.153},
+}
+
+@ARTICLE{Suko:06,
+   author = {{Sukoriansky}, S. and {Galperin}, B. and {Perov}, V.},
+    title = "{A quasi-normal scale elimination model of turbulence and
+its application to stably stratified flows}",
+  journal = {Nonlinear Processes in Geophysics},
+     year = 2006,
+   volume = 13,
+    pages = {9-22},
+}
+
+@ARTICLE{Cant:06,
+   author = {{Cantor}, B.~A. and {Kanak}, K.~M. and {Edgett}, K.~S.},
+    title = "{Mars Orbiter Camera observations of Martian dust devils and their tracks (September
+1997 to January 2006) and evaluation of theoretical vortex models}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+   number = {E10},
+    pages = {12002-+},
+      doi = {10.1029/2006JE002700},
+}
+
+@ARTICLE{Forg:09,
+   author = {{Forget}, F. and {Montmessin}, F. and {Bertaux}, J.-L. and {Gonz{\'a}lez-Galindo}, F.
+and 
+	{Lebonnois}, S. and {Qu{\'e}merais}, E. and {Reberac}, A. and 
+	{Dimarellis}, E. and {L{\'o}pez-Valverde}, M.~A.},
+    title = "{Density and temperatures of the upper Martian atmosphere measured by stellar
+occultations with Mars Express SPICAM}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2009,
+   volume = 114,
+   number = {E13},
+    pages = {1004-+},
+      doi = {10.1029/2008JE003086},
+}
+
+@ARTICLE{Lefe:08,
+   author = {{Lef{\`e}vre}, F. and {Bertaux}, J.-L. and {Clancy}, R.~T. and 
+	{Encrenaz}, T. and {Fast}, K. and {Forget}, F. and {Lebonnois}, S. and 
+	{Montmessin}, F. and {Perrier}, S.},
+    title = "{Heterogeneous chemistry in the atmosphere of Mars}",
+  journal = {Nature},
+     year = 2008,
+   volume = 454,
+    pages = {971-975},
+      doi = {10.1038/nature07116},
+}
+
+@ARTICLE{Habe:08,
+   author = {{Haberle}, R.~M. and {Pilorget}, C. and {Wolff}, M. and
+{Lef{\`e}vre}, F. and 
+	{Forget}, F.},
+    title = "{Seasonal and Spatial Variability of Ozone as Inferred from
+MARCI UV Data}",
+  journal = {LPI Contributions},
+     year = 2008,
+   volume = 1447,
+    pages = {9109-+},
+}
+
+@INPROCEEDINGS{Mali:00spot,
+   author = {{Malin}, M.~C. and {Edgett}, K.~S.},
+    title = "{Frosting and Defrosting of Martian Polar Dunes}",
+booktitle = {Lunar and Planetary Institute Science Conference Abstracts},
+     year = 2000,
+   series = {Lunar and Planetary Inst. Technical Report},
+   volume = 31,
+    pages = {1056-+},
+}
+
+@INPROCEEDINGS{Supu:01,
+   author = {{Supulver}, K.~D. and {Edgett}, K.~S. and {Malin}, M.~C.},
+    title = "{Seasonal Changes in Frost Cover in the Martian South Polar
+Region: Mars Global Surveyor MOC and TES Monitoring of the Richardson
+Crater Dune Field}",
+booktitle = {Lunar and Planetary Institute Science Conference Abstracts},
+     year = 2001,
+   series = {Lunar and Planetary Inst. Technical Report},
+   volume = 32,
+    pages = {1966-+},
+}
+ 
+@ARTICLE{Kief:06,
+   author = {{Kieffer}, H.~H. and {Christensen}, P.~R. and {Titus}, T.~N.
+	},
+    title = "{CO2 jets formed by sublimation beneath translucent slab
+ice in Mars' seasonal south polar ice cap}",
+  journal = {Nature},
+     year = 2006,
+   volume = 442,
+    pages = {793-796},
+      doi = {10.1038/nature04945},
+}
+
+@ARTICLE{Kief:07,
+   author = {{Kieffer}, H.~H.},
+    title = "{Cold jets in the Martian polar caps}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+    pages = {8005-+},
+      doi = {10.1029/2006JE002816},
+}
+
+@INBOOK{Schu:92,
+   author = {{Schubert}, G. and {Solomon}, S.~C. and {Turcotte}, D.~L. and 
+	{Drake}, M.~J. and {Sleep}, N.~H.},
+    title = "{Origin and thermal evolution of Mars}",
+publisher = {Mars},
+     year = 1992,
+    pages = {147-183},
+}
+
+@ARTICLE{Kief:01,
+   author = {{Kieffer}, H.~H. and {Titus}, T.~N.},
+    title = "{TES Mapping of Mars' North Seasonal Cap}",
+  journal = {Icarus},
+     year = 2001,
+   volume = 154,
+    pages = {162-180},
+      doi = {10.1006/icar.2001.6670},
+   
+ }
+
+@INPROCEEDINGS{Dout:08,
+   author = {{Dout{\'e}}, S. and {Schmidt}, F. and {Schmitt}, B. and
+{Langevin}, Y. and 
+	{Vincendon}, M. and {Bibring}, J.-P. and {Omega Team}},
+    title = "{Physical Characterization of the South Seasonal Cap of
+Mars During Recession from OMEGA Observations}",
+booktitle = {Lunar and Planetary Institute Science Conference
+Abstracts},
+     year = 2008,
+   series = {Lunar and Planetary Inst. Technical Report},
+   volume = 39,
+    pages = {1736-+},
+}
+
+@ARTICLE{Schm:09,
+   author = {{The Omega Team} and {Schmidt}, F. and {Dout{\'e}}, S. and
+{Schmitt}, B. and 
+	{Vincendon}, M. and {Bibring}, J.-P. and {Langevin}, Y. and 
+	{The OMEGA Team}},
+    title = "{Albedo control of seasonal South Polar cap recession on
+Mars}",
+  journal = {Icarus},
+     year = 2009,
+   volume = 200,
+    pages = {374-394},
+      doi = {10.1016/j.icarus.2008.12.014},
+}
+
+@INPROCEEDINGS{Lang:09,
+   author = {{Langevin}, Y. and {Hansen}, C. and {Thomas}, N. and
+{Vincendon}, M. and 
+	{Titus}, T.~N. and {Piqueux}, S. and {Bibring}, J.-P. and {Gondet},
+B.
+	},
+    title = "{Investigations of Cryptic Regions of the South Seasonal
+Cap, 12/2008-02/2009}",
+booktitle = {Lunar and Planetary Institute Science Conference
+Abstracts},
+     year = 2009,
+   series = {Lunar and Planetary Inst. Technical Report},
+   volume = 40,
+    pages = {2017-+},
+}
+
+@ARTICLE{Titu:08,
+   author = {{Titus}, T.~N. and {Michaels}, T.~I. and {Colaprete}, A. and 
+	{Kieffer}, H.~H. and {Langevin}, Y. and {Murchie}, S.~L. and 
+	{Vincendon}, M. and {Crism Science Team}},
+    title = "{Exotic Processes within the Cryptic Region of Mars: A New
+Method for Near Real-Time Estimates of Wind Direction}",
+  journal = {LPI Contributions},
+     year = 2008,
+   volume = 1447,
+    pages = {9043-+},
+}
+
+@ARTICLE{Hans:05,
+   author = {{Hansen}, G.~B.},
+    title = "{Ultraviolet to near-infrared absorption spectrum of carbon
+dioxide ice from 0.174 to 1.8 {$\mu$}m}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2005,
+   volume = 110,
+   number = E9,
+    pages = {11003-+},
+      doi = {10.1029/2005JE002531},
+}
+
+@INPROCEEDINGS{Ahar:04,
+   author = {{Aharonson}, O.},
+    title = "{Sublimation at the Base of a Seasonal CO2 Slab on Mars}",
+booktitle = {Lunar and Planetary Institute Science Conference
+Abstracts},
+     year = 2004,
+   series = {Lunar and Planetary Institute Science Conference
+Abstracts},
+   volume = 35,
+   editor = {{Mackwell}, S. and {Stansbery}, E.},
+    pages = {1918-+},
+}
+
+@ARTICLE{Hans:99,
+   author = {{Hansen}, G.~B.},
+    title = "{Control of the radiative behavior of the Martian polar
+caps by surface {\lt}formula{\gt}CO$_{2}$ ice: Evidence from Mars Global
+Surveyor measurements}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 1999,
+   volume = 104,
+    pages = {16471-16486},
+      doi = {10.1029/1998JE000626},
+}
+  
+
+@ARTICLE{Roth:01,
+   author = {{Rothschild}, L.~J. and {Mancinelli}, R.~L.},
+    title = "{Life in extreme environments}",
+  journal = {Nature},
+     year = 2001,
+   volume = 409,
+    pages = {1092-1101},
+}
+
+@ARTICLE{Lamm:09,
+   author = {{Lammer}, H. and {Bredeh{\"o}ft}, J.~H. and {Coustenis}, A. and 
+	{Khodachenko}, M.~L. and {Kaltenegger}, L. and {Grasset}, O. and 
+	{Prieur}, D. and {Raulin}, F. and {Ehrenfreund}, P. and {Yamauchi}, M. and 
+	{Wahlund}, {J.-E.} and {Grie{\ss}meier}, {J.-M.} and {Stangl}, G. and 
+	{Cockell}, C.~S. and {Kulikov}, Y.~N. and {Grenfell}, J.~L. and 
+	{Rauer}, H.},
+    title = "{What makes a planet habitable?}",
+  journal = {The Astronomy and Astrophysics Review},
+     year = 2009,
+   volume = 17,
+    pages = {181-249},
+      doi = {10.1007/s00159-009-0019-z},
+}
+
+@ARTICLE{Spie:08,
+   author = {{Spiegel}, D.~S. and {Menou}, K. and {Scharf}, C.~A.},
+    title = "{Habitable Climates}",
+  journal = {Astrophys. Jour.},
+     year = 2008,
+   volume = 681,
+    pages = {1609-1623},
+      doi = {10.1086/588089},
+}
+
+@ARTICLE{Nimm:98,
+   author = {{Nimmo}, F. and {McKenzie}, D.},
+    title = "{Volcanism and Tectonics on Venus}",
+  journal = {Annual Review of Earth and Planetary Sciences},
+     year = 1998,
+   volume = 26,
+    pages = {23-53},
+      doi = {10.1146/annurev.earth.26.1.23},
+}
+
+@ARTICLE{Lope:05,
+   author = {{Lopez}, B. and {Schneider}, J. and {Danchi}, W.~C.},
+    title = "{Can Life Develop in the Expanded Habitable Zones around Red Giant Stars?}",
+  journal = apj,
+     year = 2005,
+   volume = 627,
+    pages = {974-985},
+      doi = {10.1086/430416},
+}
+
+
+@ARTICLE{Cern:05,
+   author = {{Cernicharo}, J. and {Crovisier}, J.},
+    title = "{Water in Space: The Water World of ISO}",
+  journal = {Space Science Reviews},
+     year = 2005,
+   volume = 119,
+    pages = {29-69},
+      doi = {10.1007/s11214-005-8058-x},
+}
+
+@ARTICLE{McKa:08,
+   author = {{McKay}, C.~P. and {Porco Carolyn C.} and {Altheide}, T. and 
+	{Davis}, W.~L. and {Kral}, T.~A.},
+    title = "{The Possible Origin and Persistence of Life on Enceladus and Detection of
+Biomarkers in the Plume}",
+  journal = {Astrobiology},
+     year = 2008,
+   volume = 8,
+    pages = {909-919},
+      doi = {10.1089/ast.2008.0265},
+}
+
+@ARTICLE{Rosi:05,
+   author = {{Rosing}, M.~T.},
+    title = "{Thermodynamics of life on the planetary scale}",
+  journal = {International Journal of Astrobiology},
+     year = 2005,
+   volume = 4,
+    pages = {9-11},
+      doi = {10.1017/S147355040500248X},
+}
+
+@ARTICLE{Vale:07,
+   author = {{Valencia}, D. and {O'Connell}, R.~J. and {Sasselov}, D.~D.},
+    title = "{Inevitability of Plate Tectonics on Super-Earths}",
+  journal = apj,
+     year = 2007,
+   volume = 670,
+    pages = {L45-L48},
+      doi = {10.1086/524012},
+}
+
+@INPROCEEDINGS{Stam:09,
+   author = {Stamenkovic, V. and Noack, L. and Breuer, D.},
+    title = "{Habitability of Super-Earths}",
+booktitle = {Europlanet Science Conference Abstracts},
+     year = 2009,
+   volume = 4,
+    pages = {372-3},
+}
+
+@ARTICLE{ONei:07,
+   author = {{O'Neill}, C. and {Lenardic}, A.},
+    title = "{Geological consequences of super-sized Earths}",
+  journal = grl,
+     year = 2007,
+   volume = 34,
+    pages = {19204-+},
+      doi = {10.1029/2007GL030598},
+}
+
+@ARTICLE{Josh:03,
+   author = {{Joshi}, M.},
+    title = "{Climate Model Studies of Synchronously Rotating Planets}",
+  journal = {Astrobiology},
+     year = 2003,
+   volume = 3,
+    pages = {415-427},
+      doi = {10.1089/153110703769016488},
+}
+
+@ARTICLE{Tart:07,
+   author = {{Tarter}, J.~C. and {Backus}, P.~R. and {Mancinelli}, R.~L. and 
+	{Aurnou}, J.~M. and {Backman}, D.~E. and {Basri}, G.~S. and 
+	{Boss}, A.~P. and {Clarke}, A. and {Deming}, D. and {Doyle}, L.~R. and 
+	{Feigelson}, E.~D. and {Freund}, F. and {Grinspoon}, D.~H. and 
+	{Haberle}, R.~M. and {Hauck}, II, S.~A. and {Heath}, M.~J. and 
+	{Henry}, T.~J. and {Hollingsworth}, J.~L. and {Joshi}, M.~M. and 
+	{Kilston}, S. and {Liu}, M.~C. and {Meikle}, E. and {Reid}, I.~N. and 
+	{Rothschild}, L.~J. and {Scalo}, J. and {Segura}, A. and {Tang}, C.~M. and 
+	{Tiedje}, J.~M. and {Turnbull}, M.~C. and {Walkowicz}, L.~M. and 
+	{Weber}, A.~L. and {Young}, R.~E.},
+    title = "{A Reappraisal of The Habitability of Planets around M Dwarf Stars}",
+  journal = {Astrobiology},
+     year = 2007,
+   volume = 7,
+    pages = {30-65},
+      doi = {10.1089/ast.2006.0124},
+}
+
+@ARTICLE{Bucc:07,
+   author = {{Buccino}, A.~P. and {Lemarchand}, G.~A. and {Mauas}, P.~J.~D.},
+    title = "{UV habitable zones around M stars}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 192,
+    pages = {582-587},
+      doi = {10.1016/j.icarus.2007.08.012},
+}
+ 
+@ARTICLE{Lebo:09,
+   author = {{Lebonnois}, S. and {Hourdin}, F. and {Eymet}, V. and {Crespin}, A. and 
+	{Fournier}, R. and {Forget}, F.},
+    title = "{Superrotation of Venus' atmosphere analyzed with a full general circulation model}",
+  journal = {Journal of Geophysical Research (Planets)},
+ keywords = {Planetary Sciences: Solid Surface Planets: Meteorology (3346), Atmospheric Processes: Planetary
+meteorology (5445, 5739), Atmospheric Composition and Structure: Planetary atmospheres (5210, 5405, 5704),
+Atmospheric Processes: General circulation (1223)},
+     year = 2010,
+   volume = 115,
+   number = E14,
+    pages = {E06006},
+      doi = {10.1029/2009JE003458},
+   adsurl = {http://adsabs.harvard.edu/abs/2010JGRE..11506006L},
+  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
+}
+
+
+@ARTICLE{Yama:75,
+   author = {{Yamada}, T. and {Mellor}, G.},
+    title = "{A Simulation of the Wangara Atmospheric Boundary Layer Data.}",
+  journal = {Journal of Atmospheric Sciences},
+     year = 1975,
+   volume = 32,
+    pages = {2309-2329},
+      doi = {10.1175/1520-0469(1975)032<2309:ASOTWA>2.0.CO;2},
+}
+
+@ARTICLE{Lewi:05,
+   author = {{Lewis}, S.~R. and {Barker}, P.~R.},
+    title = "{Atmospheric tides in a Mars general circulation model with data assimilation}",
+  journal = {Advances in Space Research},
+     year = 2005,
+   volume = 36,
+    pages = {2162-2168},
+      doi = {10.1016/j.asr.2005.05.122},
+}
+
+@ARTICLE{Mich:06dd,
+   author = {{Michaels}, T.~I.},
+    title = "{Numerical modeling of Mars dust devils: Albedo track generation}",
+  journal = grl,
+     year = 2006,
+   volume = 33,
+    pages = {19-+},
+      doi = {10.1029/2006GL026268},
+}
+
+@book{Gree:87,
+  title={{Wind as a Geological Process: On Earth, Mars, Venus and Titan}},
+  author={Greeley, R. and Iversen, J.D.},
+  year={1987},
+  publisher={Cambridge Univ Press}
+}
+
+@ARTICLE{Bagn:54,
+   author = {{Bagnold}, R.~A.},
+    title = "{Experiments on a Gravity-Free Dispersion of Large Solid Spheres in a Newtonian Fluid under Shear}",
+  journal = {Royal Society of London Proceedings Series A},
+     year = 1954,
+   volume = 225,
+    pages = {49-63},
+}
+
+@misc{Spig:10comp,
+   author = {Spiga, A.},
+   howpublished = {Planetary and Space Science, in press},
+   title = {Elements of comparison between Martian and terrestrial mesoscale meteorological phenomena: Katabatic winds and boundary layer convection},
+   year = {2010}
+}
+
+@ARTICLE{Gree:03lab,
+   author = {{Greeley}, R. and {Balme}, M.~R. and {Iversen}, J.~D. and {Metzger}, S. and 
+	{Mickelson}, R. and {Phoreman}, J. and {White}, B.},
+    title = "{Martian dust devils: Laboratory simulations of particle threshold}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2003,
+   volume = 108,
+    pages = {5041-+},
+      doi = {10.1029/2002JE001987},
+}
+
+@INPROCEEDINGS{Reis:09,
+   author = {{Reiss}, D. and {L{\"u}sebrink}, D. and {Hiesinger}, H. and 
+	{Kelling}, T. and {Wurm}, G. and {Teiser}, J.},
+    title = "{High Altitude Dust Devils on Arsia Mons, Mars: Testing the Greenhouse and Thermophoresis Hypothesis of Dust Lifting}",
+booktitle = {Lunar and Planetary Institute Science Conference Abstracts},
+     year = 2009,
+   series = {Lunar and Planetary Inst. Technical Report},
+   volume = 40,
+    pages = {1961-+},
+}
+
+@ARTICLE{Lefe:09,
+   author = {{Lef{\`e}vre}, F. and {Forget}, F.},
+    title = "{Observed variations of methane on Mars unexplained by known atmospheric chemistry and physics}",
+  journal = {Nature},
+     year = 2009,
+   volume = 460,
+    pages = {720-723},
+      doi = {10.1038/nature08228},
+}
+
+@ARTICLE{Jako:00,
+   author = {{Jakosky}, B.~M. and {Mellon}, M.~T. and {Kieffer}, H.~H. and 
+	{Christensen}, P.~R. and {Varnes}, E.~S. and {Lee}, S.~W.},
+    title = "{The thermal inertia of Mars from the Mars Global Surveyor Thermal Emission Spectrometer}",
+  journal = jgr,
+     year = 2000,
+   volume = 105,
+    pages = {9643-9652},
+      doi = {10.1029/1999JE001088},
+}
+
+@ARTICLE{Putz:07mix,
+   author = {{Putzig}, N.~E. and {Mellon}, M.~T.},
+    title = "{Thermal behavior of horizontally mixed surfaces on Mars}",
+  journal = {Icarus},
+     year = 2007,
+   volume = 191,
+    pages = {52-67},
+      doi = {10.1016/j.icarus.2007.03.022},
+}
+
+@ARTICLE{Band:08,
+   author = {{Bandfield}, J.~L. and {Feldman}, W.~C.},
+    title = "{Martian high latitude permafrost depth and surface cover thermal inertia distributions}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2008,
+   volume = 113,
+    pages = {E08001},
+      doi = {10.1029/2007JE003007},
+}
+
+@ARTICLE{Vinc:10grl,
+   author = {{Vincendon}, M. and {Mustard}, J. and {Forget}, F. and {Kreslavsky}, M. and 
+	{Spiga}, A. and {Murchie}, S. and {Bibring}, {J.-P.}},
+    title = "{Near-tropical subsurface ice on Mars}",
+  journal = grl,
+     year = 2010,
+   volume = 37,
+    pages = {L01202},
+      doi = {10.1029/2009GL041426},
+}
+
+@ARTICLE{Basi:06,
+   author = {{Basilevsky}, A.~T. and {Werner}, S.~C. and {Neukum}, G. and 
+	{Head}, J.~W. and {van Gasselt}, S. and {Gwinner}, K. and {Ivanov}, B.~A.
+	},
+    title = "{Geologically recent tectonic, volcanic and fluvial activity on the eastern flank of the Olympus Mons volcano, Mars}",
+  journal = grl,
+     year = 2006,
+   volume = 33,
+    pages = {L13201},
+      doi = {10.1029/2006GL026396},
+}
+
+@ARTICLE{Brac:96,
+   author = {{Brack}, A.},
+    title = "{Why exobiology on Mars?}",
+  journal = pss,
+     year = 1996,
+   volume = 44,
+    pages = {1435-1440},
+}
+
+@ARTICLE{Spig:11ti,
+   author = {{Spiga}, A. and {Forget}, F. and {Madeleine}, {J.-B.} and {Montabone}, L. and {Lewis}, S.~R. and {Millour}, E.},
+    title = "{The impact of Martian mesoscale winds on surface temperature and on the determination of thermal inertia}",
+  journal = {Icarus},
+     year = 2011,
+   volume = 212,
+    pages = {504-519},
+}   
+
+
+@ARTICLE{Spig:08will,
+   author = {{Spiga}, A. and {Forget}, F. and {Montabone}, L.},
+    title = "{Study of the Martian Boundary Layer, Mountain Meteorology and 2001 Dust Storm with the LMD Mesoscale Model}",
+  journal = {LPI Contributions},
+     year = 2008,
+   volume = 1447,
+    pages = {9028-+},
+}
+
+@ARTICLE{Ferg:06,
+   author = {{Fergason}, R.~L. and {Christensen}, P.~R. and {Bell}, J.~F. and 
+	{Golombek}, M.~P. and {Herkenhoff}, K.~E. and {Kieffer}, H.~H.
+	},
+    title = "{Physical properties of the Mars Exploration Rover landing sites as inferred from Mini-TES-derived thermal inertia}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+    pages = {E02S21},
+      doi = {10.1029/2005JE002583},
+}
+
+@ARTICLE{Hyne:07,
+   author = {{Hynek}, B.~M. and {Singer}, K.},
+    title = "{Ground truth from the Opportunity Rover for Mars thermal inertia data}",
+  journal = grl,
+     year = 2007,
+   volume = 34,
+    pages = {L11201},
+      doi = {10.1029/2007GL029687},
+}
+
+@ARTICLE{Putz:05,
+   author = {{Putzig}, N.~E. and {Mellon}, M.~T. and {Kretke}, K.~A. and 
+	{Arvidson}, R.~E.},
+    title = "{Global thermal inertia and surface properties of Mars from the MGS mapping mission}",
+  journal = {Icarus},
+     year = 2005,
+   volume = 173,
+    pages = {325-341},
+      doi = {10.1016/j.icarus.2004.08.017},
+}
+
+@ARTICLE{Wolk:10,
+   author = {{Wolkenberg}, P. and {Formisano}, V. and {Rinaldi}, G. and {Geminale}, A.
+	},
+    title = "{The atmospheric temperatures over Olympus Mons on Mars: An atmospheric hot ring}",
+  journal = {Icarus},
+     year = 2010,
+   volume = 207,
+    pages = {110-123},
+      doi = {10.1016/j.icarus.2009.11.005},
+}
+
+@ARTICLE{Blea:07,
+   author = {{Bleacher}, J.~E. and {Greeley}, R. and {Williams}, D.~A. and 
+	{Werner}, S.~C. and {Hauber}, E. and {Neukum}, G.},
+    title = "{Olympus Mons, Mars: Inferred changes in late Amazonian aged effusive activity from lava flow mapping of Mars Express High Resolution Stereo Camera data}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+    pages = {E04003},
+      doi = {10.1029/2006JE002826},
+}
+
+@article{McGo:09,
+  title={{Volcanic spreading and lateral variations in the structure of Olympus Mons, Mars}},
+  author={McGovern, P.J. and Morgan, J.K.},
+  journal={Geology},
+  volume={37},
+  number={2},
+  pages={139},
+  year={2009},
+}
+
+@ARTICLE{Joug:09,
+   author = {{Jouglet}, D. and {Poulet}, F. and {Langevin}, Y. and {Bibring}, {J.-P.} and 
+	{Gondet}, B. and {Vincendon}, M. and {Berthe}, M.},
+    title = "{OMEGA long wavelength channel: Data reduction during non-nominal stages}",
+  journal = pss,
+     year = 2009,
+   volume = 57,
+    pages = {1032-1042},
+      doi = {10.1016/j.pss.2008.07.025},
+}
+
+@article{Mahr:08,
+  title={{Bulk formulation of surface fluxes extended to weak-wind stable conditions}},
+  author={Mahrt, L.},
+  journal={Quarterly Journal of the Royal Meteorological Society},
+  volume={134},
+  number={630},
+  pages={1--10},
+  year={2008},
+}
+
+@book{Garr:92,
+   author = {Garratt, J.~R.},
+   address = {New York},
+   publisher = {Cambridge Univ. Press},
+   title = {The Atmospheric Boundary Layer},
+   year = {1992}
+}
+
+@article{Gris:07,
+  title={{The low-level katabatic jet height versus Monin--Obukhov height}},
+  author={Grisogono, B. and Kraljevi{\'c}, L. and Jeri{\v{c}}evi{\'c}, A.},
+  journal={Quarterly Journal of the Royal Meteorological Society},
+  volume={133},
+  number={629},
+  pages={2133--2136},
+  year={2007},
+}
+
+@ARTICLE{Cass:01,
+   author = {{Cassano}, J.~J. and {Parish}, T.~R. and {King}, J.~C.},
+    title = "{Evaluation of Turbulent Surface Flux Parameterizations for the Stable Surface Layer over Halley, Antarctica}",
+  journal = {Monthly Weather Review},
+     year = 2001,
+   volume = 129,
+    pages = {26--46},
+      doi = {10.1175/1520-0493(2001)129<0026:EOTSFP>2.0.CO;2},
+}
+
+@ARTICLE{Ditt:82,
+   author = {{Ditteon}, R.},
+    title = "{Daily temperature variations on Mars}",
+  journal = jgr,
+     year = 1982,
+   volume = 87,
+    pages = {10197-10214},
+      doi = {10.1029/JB087iB12p10197},
+}
+
+@ARTICLE{Howa:00,
+   author = {{Howard}, A.~D.},
+    title = "{The Role of Eolian Processes in Forming Surface Features of the Martian Polar Layered Deposits}",
+  journal = {Icarus},
+     year = 2000,
+   volume = 144,
+    pages = {267-288},
+      doi = {10.1006/icar.1999.6305},
+}
+
+@ARTICLE{Smit:10holt,
+   author = {{Smith}, I.~B. and {Holt}, J.~W.},
+    title = "{Onset and migration of spiral troughs on Mars revealed by orbital radar}",
+  journal = {Nature},
+     year = 2010,
+   volume = 465,
+    pages = {450-453},
+      doi = {10.1038/nature09049},
+}
+
+@ARTICLE{Holt:10,
+   author = {{Holt}, J.~W. and {Fishbaugh}, K.~E. and {Byrne}, S. and {Christian}, S. and 
+	{Tanaka}, K. and {Russell}, P.~S. and {Herkenhoff}, K.~E. and 
+	{Safaeinili}, A. and {Putzig}, N.~E. and {Phillips}, R.~J.},
+    title = "{The construction of Chasma Boreale on Mars}",
+  journal = {Nature},
+     year = 2010,
+   volume = 465,
+    pages = {446-449},
+      doi = {10.1038/nature09050},
+}
+
+@ARTICLE{Ng:06,
+   author = {{Ng}, F.~S.~L. and {Zuber}, M.~T.},
+    title = "{Patterning instability on the Mars polar ice caps}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2006,
+   volume = 111,
+    pages = {E02005},
+      doi = {10.1029/2005JE002533},
+}
+
+@ARTICLE{Vang:09,
+   author = {{Vangvichith}, M. and {Tran}, H. and {Hartmann}, {J.-M.}},
+    title = "{Line-mixing and collision induced absorption for O$_{2}$-CO$_{2}$ mixtures in the oxygen
+A-band region}",
+  journal = jqsrt,
+     year = 2009,
+   volume = 110,
+    pages = {2212-2216},
+      doi = {10.1016/j.jqsrt.2009.06.002},
+}
+
+@ARTICLE{Word:10,
+   author = {{Wordsworth}, R. and {Forget}, F. and {Eymet}, V.},
+    title = "{Infrared collision-induced and far-line absorption in dense CO$_{2}$ atmospheres}",
+  journal = {Icarus},
+     year = 2010,
+   volume = 210,
+    pages = {992-997},
+      doi = {10.1016/j.icarus.2010.06.010},
+}
+
+@ARTICLE{Lell:10,
+   author = {{Lellouch}, E. and {de Bergh}, C. and {Sicardy}, B. and {Ferron}, S. and {K{\"a}ufl}, {H.-U.}},
+    title = "{Detection of CO in Triton's atmosphere and the nature of surface-atmosphere interactions}",
+  journal = {aap},
+     year = 2010,
+   volume = 512,
+    pages = {L8+},
+      doi = {10.1051/0004-6361/201014339},
+}
+
+@ARTICLE{Spen:90,
+   author = {{Spencer}, J.~R.},
+    title = "{Nitrogen frost migration on Triton - A historical model}",
+  journal = {grl},
+     year = 1990,
+   volume = 17,
+    pages = {1769-1772},
+      doi = {10.1029/GL017i010p01769},
+}
+
+@INPROCEEDINGS{Schm:95,
+   author = {{Schmitt}, B. and {Quirico}, E. and {Dout{\'e}}, S. and {Owen}, T.~C. and 
+	{de Bergh}, C. and {Cruikshank}, D.~P. and {Geballe}, T.},
+    title = "{Physical State and Composition of the Ices on Triton and Pluto}",
+booktitle = {Bulletin of the American Astronomical Society},
+     year = 1995,
+    pages = {1099-+},
+}
+
+@article{Grun:10,
+   author = {{Grundy}, W.~M. and {Young}, L.~A. and {Stansberry}, J.~A. and 
+	{Buie}, M.~W. and {Olkin}, C.~B. and {Young}, E.~F.},
+    title = "{Near-infrared spectral monitoring of Triton with IRTF/SpeX II: Spatial distribution and evolution of ices}",
+  journal = {Icarus},
+     year = 2010,
+   volume = 205,
+    pages = {594-604},
+      doi = {10.1016/j.icarus.2009.08.005},
+}
+
+@ARTICLE{Smit:89,
+   author = {{Smith}, B.~A. and {Soderblom}, L.~A. and {Banfield}, D. and 
+	{Barnet}, C. and {Beebe}, R.~F. and {Bazilevskii}, A.~T. and 
+	{Bollinger}, K. and {Boyce}, J.~M. and {Briggs}, G.~A. and {Brahic}, A.
+	},
+    title = "{Voyager 2 at Neptune - Imaging science results}",
+  journal = {Science},
+     year = 1989,
+   volume = 246,
+    pages = {1422-1449},
+      doi = {10.1126/science.246.4936.1422},
+}
+
+@ARTICLE{Brow:90,
+   author = {{Brown}, R.~H. and {Johnson}, T.~V. and {Kirk}, R.~L. and {Soderblom}, L.~A.
+	},
+    title = "{Energy sources for Triton's geyser-like plumes}",
+  journal = {Science},
+     year = 1990,
+   volume = 250,
+    pages = {431-435},
+      doi = {10.1126/science.250.4979.431},
+}
+
+@ARTICLE{Saga:90,
+   author = {{Sagan}, C. and {Chyba}, C.},
+    title = "{Triton's streaks as windblown dust}",
+  journal = {Nature},
+     year = 1990,
+   volume = 346,
+    pages = {546-548},
+      doi = {10.1038/346546a0},
+}
+
+@ARTICLE{Habe:97,
+   author = {{Haberle}, R.~M. and {Barnes}, J.~R. and {Murphy}, J.~R. and 
+	{Joshi}, M.~M. and {Schaeffer}, J.},
+    title = "{Meteorological predictions for the Mars Pathfinder lander}",
+  journal = jgr,
+ keywords = {Meteorology and Atmospheric Dynamics: Synoptic-scale meteorology},
+     year = 1997,
+   volume = 102,
+    pages = {13301-13312},
+      doi = {10.1029/97JE01334},
+}
+
+@ARTICLE{Spig:10dust,
+   author = {{Spiga}, A. and {Lewis}, S.R.},
+    title = "{Mesoscale and microscale wind variability of relevance for dust lifting}",
+  journal = {Mars},
+     year = 2010,
+   volume = 5,
+    pages = {146-158},
+      doi = {10.1555/mars.2010.0006},
+}
+
+@ARTICLE{Maat:10,
+   author = {{M{\"a}{\"a}tt{\"a}nen}, A. and {Montmessin}, F. and {Gondet}, B. and 
+	{Scholten}, F. and {Hoffmann}, H. and {Gonz{\'a}lez-Galindo}, F. and 
+	{Spiga}, A. and {Forget}, F. and {Hauber}, E. and {Neukum}, G. and 
+	{Bibring}, {J.-P.} and {Bertaux}, {J.-L.}},
+    title = "{Mapping the mesospheric CO$_{2}$ clouds on Mars: MEx/OMEGA and MEx/HRSC observations and challenges for atmospheric models}",
+  journal = {Icarus},
+     year = 2010,
+   volume = 209,
+    pages = {452-469},
+      doi = {10.1016/j.icarus.2010.05.017},
+}
+
+@ARTICLE{With:10,
+   author = {{Withers}, P. and {Catling}, D.~C.},
+    title = "{Observations of atmospheric tides on Mars at the season and latitude of the Phoenix atmospheric entry}",
+  journal = grl,
+     year = 2010,
+   volume = 37,
+    pages = {24204-+},
+      doi = {10.1029/2010GL045382},
+}
+
+@ARTICLE{Clan:07,
+   author = {{Clancy}, R.~T. and {Wolff}, M.~J. and {Whitney}, B.~A. and 
+	{Cantor}, B.~A. and {Smith}, M.~D.},
+    title = "{Mars equatorial mesospheric clouds: Global occurrence and physical properties from Mars Global Surveyor Thermal Emission Spectrometer and Mars Orbiter Camera limb observations}",
+  journal = {Journal of Geophysical Research (Planets)},
+     year = 2007,
+   volume = 112,
+   number = {E11},
+    pages = {4004-+},
+      doi = {10.1029/2006JE002805},
+}
+
+@ARTICLE{Mcco:10,
+   author = {{McConnochie}, T.~H. and {Bell}, J.~F. and {Savransky}, D. and 
+	{Wolff}, M.~J. and {Toigo}, A.~D. and {Wang}, H. and {Richardson}, M.~I. and 
+	{Christensen}, P.~R.},
+    title = "{THEMIS-VIS observations of clouds in the martian mesosphere: Altitudes, wind speeds, and decameter-scale morphology}",
+  journal = {Icarus},
+     year = 2010,
+   volume = 210,
+    pages = {545-565},
+      doi = {10.1016/j.icarus.2010.07.021},
+}
+
+@misc{Gonz:11,
+   author = {{Gonz{\'a}lez-Galindo}, F. and {M{\"a}{\"a}tt{\"a}nen}, A. and 
+	{Forget}, F. and {Spiga}, A.},
+   howpublished = {Submitted to Icarus},
+   title = {The Martian mesosphere as revealed by CO2 clouds observations and General Circulation Modeling},
+   year = {2011}
+}
+
+@ARTICLE{Pari:09,
+   author = {{Parish}, H.~F. and {Schubert}, G. and {Hickey}, M.~P. and {Walterscheid}, R.~L.
+	},
+    title = "{Propagation of tropospheric gravity waves into the upper atmosphere of Mars}",
+  journal = {Icarus},
+     year = 2009,
+   volume = 203,
+    pages = {28-37},
+      doi = {10.1016/j.icarus.2009.04.031},
+}
+
+@ARTICLE{Hauc:87,
+   author = {{Hauchecorne}, A. and {Chanin}, M.~L. and {Wilson}, R.},
+    titlev = "{Mesospheric temperature inversion and gravity wave breaking}",
+  journal = grl,
+     year = 1987,
+   volume = 14,
+    pages = {933-936},
+      doi = {10.1029/GL014i009p00933},
+}
+
+@ARTICLE{Savi:10,
+   author = {{Savij{\"a}rvi}, H. and {M{\"a}{\"a}tt{\"a}nen}, A.},
+    title = "{Boundary-layer simulations for the Mars Phoenix lander site}",
+  journal = {Quarterly Journal of the Royal Meteorological Society},
+     year = 2010,
+   volume = 136,
+    pages = {1497-1505},
+      doi = {10.1002/qj.650},
+}
+
+@ARTICLE{McCl:10,
+   author = {{McCleese}, D.~J. and {Heavens}, N.~G. and {Schofield},
+J.~T. and 
+	{Abdou}, W.~A. and {Bandfield}, J.~L. and {Calcutt}, S.~B. and 
+	{Irwin}, P.~G.~J. and {Kass}, D.~M. and {Kleinb{\"o}hl}, A. and 
+	{Lewis}, S.~R. and {Paige}, D.~A. and {Read}, P.~L. and
+{Richardson}, M.~I. and 
+	{Shirley}, J.~H. and {Taylor}, F.~W. and {Teanby}, N. and {Zurek},
+R.~W.
+	},
+    title = "{Structure and dynamics of the Martian lower and middle
+atmosphere as observed by the Mars Climate Sounder: Seasonal variations
+in zonal mean temperature, dust, and water ice aerosols}",
+  journal = jgr,
+ keywords = {Planetary Sciences: Solar System Objects: Mars},
+     year = 2010,
+   volume = 115,
+   number = E14,
+    pages = {12016-+},
+      doi = {10.1029/2010JE003677},
+}
+
+@ARTICLE{Kono:11,
+   author = {{Konopliv}, A.~S. and {Asmar}, S.~W. and {Folkner}, W.~M. and 
+	{Karatekin}, {\"O}. and {Nunes}, D.~C. and {Smrekar}, S.~E. and 
+	{Yoder}, C.~F. and {Zuber}, M.~T.},
+    title = "{Mars high resolution gravity fields from MRO, Mars seasonal gravity, and other dynamical
+parameters}",
+  journal = {Icarus},
+     year = 2011,
+   volume = 211,
+    pages = {401-428},
+      doi = {10.1016/j.icarus.2010.10.004},
+   adsurl = {http://adsabs.harvard.edu/abs/2011Icar..211..401K},
+}
+
+@ARTICLE{Hins:04clouds,
+   author = {{Hinson}, D.~P. and {Wilson}, R.~J.},
+    title = "{Temperature inversions, thermal tides, and water ice clouds in the Martian tropics}",
+  journal = {Journal of Geophysical Research (Planets)},
+ keywords = {Planetary Sciences: Atmospheres-structure and dynamics, Meteorology and Atmospheric Dynamics: Planetary meteorology (5445, 5739), Planetary Sciences: Meteorology (3346), Planetology: Solar System Objects: Mars, Meteorology and Atmospheric Dynamics: Waves and tides},
+     year = 2004,
+   volume = 109,
+   number = E18,
+    pages = {1002-+},
+      doi = {10.1029/2003JE002129},
+   adsurl = {http://adsabs.harvard.edu/abs/2004JGRE..10901002H},
+}
+
+
+@ARTICLE{Heav:10,
+   author = {{Heavens}, N.~G. and {Benson}, J.~L. and {Kass}, D.~M. and {Kleinb{\"o}hl}, A. and 
+	{Abdou}, W.~A. and {McCleese}, D.~J. and {Richardson}, M.~I. and 
+	{Schofield}, J.~T. and {Shirley}, J.~H. and {Wolkenberg}, P.~M.
+	},
+    title = "{Water ice clouds over the Martian tropics during northern summer}",
+  journal = grl,
+ keywords = {Planetary Sciences: Solar System Objects: Mars, Atmospheric Composition and Structure: Cloud physics and chemistry, Atmospheric Composition and Structure: Cloud/radiation interaction, Atmospheric Processes: Clouds and cloud feedbacks, Atmospheric Processes: General circulation (1223)},
+     year = 2010,
+   volume = 37,
+    pages = {18202-+},
+      doi = {10.1029/2010GL044610},
+   adsurl = {http://adsabs.harvard.edu/abs/2010GeoRL..3718202H},
+}
+
+@ARTICLE{Spen:99,
+   author = {{Spencer}, D.~A. and {Blanchard}, R.~C. and {Braun}, R.~D. and 
+	{Kallemeyn}, P.~H. and {Thurman}, S.~W.},
+    title = "{Mars Pathfinder Entry, Descent, and Landing Reconstruction}",
+  journal = {Journal of Spacecraft and Rockets},
+     year = 1999,
+   volume = 36,
+    pages = {357-366},
+      doi = {10.2514/2.3478},
+   adsurl = {http://adsabs.harvard.edu/abs/1999JSpRo..36..357S},
+}
+
+
+@INPROCEEDINGS{Kara:04,
+   author = {{Karatekin}, {\"O}. and {Charbonnier}, {J.-M.} and {Wang}, F. and 
+	{Dehant}, V.},
+    title = "{Dynamic stability of atmospheric entry probes}",
+ keywords = {Planetary Atmospheres, Entry Probes},
+booktitle = {Planetary Probe Atmospheric Entry and Descent Trajectory Analysis and Science},
+     year = 2004,
+   series = {ESA Special Publication},
+   volume = 544,
+   editor = "{A.~Wilson}",
+    pages = {101-108},
+   adsurl = {http://adsabs.harvard.edu/abs/2004ESASP.544..101K},
+}
+
+@INPROCEEDINGS{Kara:01,
+   author = {{Karatekin}, {\"O}.},
+    title = "{Effect of surface pressure variations on the aerodynamic stability of planetary entry capsules}",
+     year = 2001,
+booktitle = {2nd International Symposium on Atmospheric reentry vehicles and systems}
+}
+
+@ARTICLE{Kara:10,
+   author = {{Karatekin}, {\"O}. and Viron, O. and Lambert, S. and Rosenblatt, P. and Dehant, V. and van Hoolst, T. and LeMaistre, S.},
+    title = "{Atmospheric angular momentum variations of Earth, Mars and Venus at seasonal time scales}",
+  journal = {Planetary and Space Science},
+     year = 2010,
+}
+
+@ARTICLE{Wood:97,
+   author = {{Wood}, G.~E. and {Asmar}, S.~W. and {Rebold}, T.~A. and {Lee}, R.~A.},
+    title = "{Mars Pathfinder EntryDescent, and Landing Communications}",
+  journal = {Telecommunications and Data Acquisition Progress Report},
+     year = 1997,
+   volume = 131,
+    pages = {1-19},
+   adsurl = {http://adsabs.harvard.edu/abs/1997TDAPR.131R...1W},
+}
+
+@INPROCEEDINGS{Vang:10dps,
+   author = {{Vangvichith}, M. and {Forget}, F. and {Wordsworth}, R. and 
+	{Millour}, E.},
+    title = "{A 3-D General Circulation Model of Triton's Atmosphere}",
+booktitle = {AAS/Division for Planetary Sciences Meeting Abstracts \#42},
+     year = 2010,
+   series = {Bulletin of the American Astronomical Society},
+   volume = 42,
+    month = oct,
+    pages = {952-+},
+   adsurl = {http://adsabs.harvard.edu/abs/2010DPS....42.0606V},
+  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
+}
+
+@article{Sieb:95,
+  title={{Evaluation of parametric assumptions for shallow cumulus convection}},
+  author={Siebesma, AP and Cuijpers, JWM},
+  journal={Journal of the atmospheric sciences},
+  volume={52},
+  number={6},
+  pages={650--666},
+  year={1995},
+}
+
+@ARTICLE{Toyo:11,
+   author = {{Toyota}, T. and {Kurita}, K. and {Spiga}, A.},
+    title = "{Distribution and time-variation of spire streaks at Pavonis Mons on Mars}",
+  journal = {Planetary and Space Science},
+     year = 2011,
+   volume = 59,
+    pages = {672-682},
+      doi = {10.1016/j.pss.2011.01.015},
+}
+
+@INPROCEEDINGS{Spig:11mamogw,
+   author = {{Spiga}, A. and {Gonzalez-Galindo}, F. and {Forget}, F. and 
+	{Lopez-Valverde}, M.-A.},
+    title = "{Martian Mesospheric CO2 Clouds and Gravity Wave Activity.}",
+booktitle = {Mars Atmosphere: Modelling and observation},
+     year = 2011,
+   editor = "{F.~Forget \& E.~Millour}",
+    pages = {409-412},
+}
Index: /trunk/LMDZ.TITAN/DOC/phystd.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/phystd.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/phystd.tex	(revision 1644)
@@ -0,0 +1,124 @@
+\chapter{Physical parameterizations of the generic model: some references}
+
+\label{sc:phystd}
+
+\section{General}
+
+The Generic Climate Model uses a large number of physical parameterizations based on various scientific theories. Some also use specific numerical methods. A list of these parameterizations is given below, along with the most appropriate references for each one. Most of these documents can be found at\\ 
+\verb+http://www.lmd.jussieu.fr/mars.html+.
+
+\paragraph{General references:}
+No documents attempt to give a complete scientific description of the current
+version of the GCM. Here's a reference to a Mars GCM description:
+\begin{itemize}
+\item  {\it Forget et al.} [1999] (article
+published in the JGR)
+\item  ``Updated Detailed Design Document for the Model''
+(ESA contract, Work Package 6, 1999, available on the web)
+which is simply a compilation of the preceding article with
+a few additions that were published separately.
+\end{itemize}
+
+\nocite{Forg:99}
+
+\section{Radiative transfer}
+
+The radiative transfer parameterizations are used to calculate the heating
+and cooling ratios in the atmosphere and the radiative flux at the surface.
+
+[TO WRITE: IMPORTANT SECTION - REFERENCES HERE ARE FOR MARS ONLY]
+
+%\end{itemize}
+
+
+\subsection{\bf Absorption/emission and diffusion by dust:}
+
+\subsubsection*{Dust spatial distribution}
+ (\verb+ dustopacity+)
+
+\begin{itemize}
+\item Vertical distribution and description of ``MGS'' and ``Viking'' scenarios
+in the ESA report {\it Mars Climate Database V3.0 Detailed Design Document}
+by Lewis et al. (2001), available on the web.
+\item For the ``MY24'' scenario, dust distribution obtained from assimilation
+of TES data is used (and read via the \verb+readtesassim+ routine).
+\end{itemize}
+\nocite{Forg:99,Lewi:99}
+
+\subsubsection*{Thermal IR radiation}
+ (\verb+ lwmain+)
+\begin{itemize}
+\item Numerical method:  {\it Toon et al.} [1989]
+\item Optical properties of dust:  {\it Forget} [1998]
+\nocite{Toon:89,Forg:98grl}
+\end{itemize}
+
+\subsubsection*{Solar radiation}
+ (\verb+ swmain+)
+\begin{itemize}
+\item Numerical method: {\it Fouquart and Bonel} [1980]
+\nocite{Fouq:80}
+
+\item Optical properties of dust:
+see the discussion in {\it Forget et al. } [1999], which quotes
+ {\it Ockert-Bell et al.} [1997] and {\it Clancy and Lee} [1991].
+\nocite{Ocke:97,Clan:91}
+\end{itemize}
+
+\section{Subgrid atmospheric dynamical processes}
+
+\subsection{Turbulent diffusion in the upper layer}
+ (\verb+ vdifc+)
+
+\begin{itemize}
+\item Implicit numerical scheme in the vertical:
+see the thesis of Laurent Li (LMD, Universit\'e Paris 7, 1990), Appendix C2.
+
+\item Calculation of the turbulent diffusion coefficients:
+{\it Forget et al. } [1999].
+\end{itemize}
+
+\subsection{Convection}
+ (\verb+ convadj+)
+
+See {\it Hourdin et al.} [1993]
+\nocite{Hour:93}
+
+\section{Surface thermal conduction}
+ (\verb+soil+)
+
+Thesis of Fr\'ed\'eric Hourdin (LMD, Universit\'e Paris 7, 1992) :
+ section 3.3 (equations) and Appendix A (Numerical scheme).
+
+\section{CO$_2$ Condensation}
+
+In {\it Forget et al.} [1998] (article published in Icarus): \\
+- Numerical method for calculating the condensation and sublimation levels
+at the surface and in the atmosphere (\verb+ newcondens+)
+ explained in the appendix.
+\\
+- Description of the numerical scheme for calculating the evolution of CO$_2$
+snow emissivity (\verb+co2snow+) explained in section 4.1
+\nocite{Forg:98}
+
+\section{Tracer transport and sources}
+\begin{itemize}
+\item ``Van-Leer'' transport scheme used in the dynamical part
+(\verb+ tracvl+ and  \verb+ vlsplt+ in the dynamical part):
+{\it Hourdin and Armengaud} [1999] \nocite{Hour:99}
+
+\item Transport by turbulent diffusion  (in \verb+ vdifc+), convection
+(in  \verb+ convadj+), sedimentation  (\verb+ sedim+),
+dust lifting by winds (\verb+ dustlift+) :
+see note ``Preliminary design of dust lifting and transport in the Model''
+(ESA contract, Work Package 4, 1998, available on the web).
+
+
+%\item Simplified water cycle (source in {\tt vdifc}, {\tt
+%watercloud}) : and also see the Maitrise study by Delphine Nobileau, LMD, 2000.
+\item {\bf Watercycle}, see {\it Montmessin et al.} [2004]
+\nocite{Mont:04jgr}
+
+\end{itemize}
+
+
Index: /trunk/LMDZ.TITAN/DOC/principe.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/principe.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/principe.tex	(revision 1644)
@@ -0,0 +1,294 @@
+\chapter{Main features of the model}
+
+\label{sc:apercu}
+
+\section{Basic principles}
+The General Circulation Model (GCM) calculates the temporal evolution of
+the different {\bf variables} (listed below)
+that control or describe the planetary meteorology and climate
+at different points of a {\bf 3D ``grid" } (see below) that covers
+the entire  atmosphere.
+
+From an initial state, the model calculates the evolution of these variables,
+timestep by timestep:
+\begin{itemize}
+\item At instant $t$, we know variable $X_t$ (temperature for example)
+at one point in the atmosphere.
+
+\item We calculate the evolution (the {\bf tendencies})
+$(\frac{\partial X}{\partial t})_1$ ,
+$(\frac{\partial X}{\partial t})_2$ , etc.
+arising from each physical phenomenon,
+calculated by a {\bf parameterization} of each of these phenomenon
+(for example, heating due to absorption of solar radiation).
+
+\item At the next time step $t + \delta t$, we can calculate $X_{t+ \delta t}$
+from  $X_t$ and $(\frac{\partial X}{\partial t})$.
+This is the {\bf``integration''} of the variables in time.
+(For example, $X_{t+ \delta t}=X_t +
+ \delta t(\frac{\partial X}{\partial t})_1 +
+ \delta t(\frac{\partial X}{\partial t})_2 + ...$)
+
+\end{itemize}
+
+{\bf The main task of the model is to calculate these tendencies}
+$(\frac{\partial X}{\partial t})$
+{\bf arising from the different parameterized phenomena.}
+
+\section{Dynamical-Physical separation}
+
+In practice, the 3D model operates in two parts:\\
+- a {\bf dynamical part} containing the numerical solution of
+the general equations for atmospheric circulation.
+This part (including the programming) is common to all terrestrial-type atmospheres, and applicable
+in certain cases to the upper atmospheres of gas giant planets.\\
+- a {\bf physical part} that is specific to the planet in question and
+which calculates the circulation forcing and climatic details at each point.
+
+The calculations for the dynamical part are made on a 3D grid
+with horizontal exchanges between the grid boxes,
+whereas the physical part can be seen as a juxtaposition of atmosphere
+``columns'' that do not interact with each other (see diagram~\ref{fg:fidyn}).
+
+The dynamical and physical parts deal with variables of different natures,
+and operate on grids that are differently constructed.
+The temporal integration of the variables is based
+on different numerical schemes
+(simple, such as the one above for the physical part,
+and more complicated, the ``Matsuno-Leapfrog'' scheme for the dynamical part).
+The timesteps are also different.
+The physical timestep  is {\tt iphysiq} times longer than the dynamical
+timestep, as the solution of the dynamic equations requires a shorter timestep
+than the forced calculation for the physical part.
+
+In practice, the main program that handles the whole model (\verb+gcm.F+)
+is located in the dynamical part.
+When the temporal evolution is being calculated,
+at each timestep the program calls the following:
+\begin{enumerate}
+\item Call to the subroutine that handles the total tendency calculation
+$(\frac{\partial X}{\partial t})$ arising from the dynamical part
+(\verb+caldyn.F+)
+\item Integration of these dynamical tendencies to calculate the evolution
+of the variables at the following timesteps (subroutine \verb+integrd.F+)
+\item Every {\tt iphysiq} dynamical timestep, a call to the interface
+subroutine (\verb+calfis.F+) with the physical model (\verb+physiq.F90+),
+that calculates the evolution of some of the purely physical variables
+(e.g: surface temperature {\tt tsurf}) and returns the tendencies
+$(\frac{\partial X}{\partial t})$
+arising from the physical part.
+\item Integration of the physical variables (subroutine \verb+addfi.F+)
+\item Similarly, calculation and integration of tendencies due to
+the horizontal dissipation and the ``sponge layer'' is done
+every {\tt idissip} dynamical time step.
+\end{enumerate}
+{\em {Remark:} The physical part can be run separately for a 1-D calculation
+for a single column using program \verb+rcm1d.F+.}
+
+
+\section{Grid boxes:} Examples of typical grid values are 64x48x25,
+64x48x32 or 32x24x25 in longitudexlatitudexaltitude. Grid box size depends
+on the planetary radius: for Mars (radius$\sim$3400~km), for example, a 64x48 horizontal grid corresponds
+to grid boxes of the order of 330x220 kilometers near the equator.
+
+
+\subsection{Horizontal grids}
+
+ \begin{figure}
+%%\centering
+\begin{center}
+\centerline{\framebox{\epsfig{figure=Fig/didi.eps,width=12.cm,clip=true}}}
+\caption{Physical/dynamical interface}
+\label{fg:fidyn}
+\end{center}
+\end{figure}
+
+\begin{figure}
+\centerline{\framebox[1.4\textwidth][c]{\includegraphics[width=1.2\textwidth]{Fig/grid.eps}}}
+\caption{Dynamical and physical grids for a 6 $\times$ 7 horizontal resolution.
+In the dynamics (but not in the physics) winds u and v are on specific
+staggered grids. Other dynamical variables are on the dynamical ``scalar'' grid.
+The physics uses the same ``scalar'' grid for all the variables,
+except that nodes are indexed in a single vector containing
+NGRID=2+(JM-1)$\times$IM points when counting from the north pole.
+N.B.: In the Fortran program, the following variables are used:
+ {\tt iim=IM , iip1=IM+1, jjm=JM , jjp1=JM+1}.\label{fg:grid}}
+\end{figure}
+
+
+Dynamics and physics use different grids.
+Figure~\ref{fg:grid} shows the correspondence and indexing
+of the physical and dynamical grids
+as well as the different locations of variables on these grids.
+To identify the coordinates of a variable (at one grid point up,
+down, right or left)
+we use coordinates {\tt rlonu}, {\tt rlatu},
+ {\tt rlonv}, {\tt rlatv} (longitudes and
+latitudes, in {\bf radians}).
+
+On the dynamical grid, values at {\tt i=1} are the same as at {\tt i=IM+1}
+as the latter node is a redundant point (due to the periodicity in longitude,
+these two nodes are actualy located at the same place).
+Similarly, the extreme {\tt j=1} and {\tt j=JM+1} nodes on the
+dynamical grid (respectively corresponding to North and South poles)
+are duplicated IM+1 times.\\
+In contrast, the physical grid does not contain redundant points
+(only one value for each pole and no extra point along longitudes),
+as shown in figure~\ref{fg:grid}.
+In practice, computations relative to the physics are made
+for a series of {\tt ngrid} atmospheric
+columns, where {\tt NGRID}={\tt IM}x({\tt JM}-1)+2.
+
+\subsection{Vertical grids}
+
+\begin{figure}[htbp]
+
+{\includegraphics[scale=0.85,clip=true]{Fig/coord.eps}}
+\caption[hybrides]
+ {Sketch illustrating the difference between hybrid and non-hybrid coordinates}
+ \label{fg:hybrid}
+\end{figure}
+
+
+The GCM was initially programmed using sigma coordinates $\sigma = p/ps$
+(atmospheric pressure over surface pressure ratio)
+which had the advantage of using a constant domain
+($\sigma=1$ at the surface and $\sigma=0$ at the top of the atmosphere)
+whatever the underlying topography.
+However, it is obvious that these coordinates significantly disturb
+the stratospheric dynamical representation as the topography is propagated
+to the top of the model by the coordinate system.
+This problem can elegantly be solved by using a hybrid sigma-P (sigma-pressure)
+hybrid coordinate which is equivalent to using $\sigma$ coordinates
+near the surface and gradually shifting to purely pressure $p$
+coordinates with increasing altitude.
+Figure~\ref{fg:hybrid} illustrates the importance of using these
+hybrid coordinates compared to simple $\sigma$ coordinates.
+The distribution of the vertical layers is irregular,
+to enable greater precision at ground level.
+In general we use 25 levels to describe the atmosphere to a height of 80 km,
+32 levels for simulations up to 120~km, or 50 levels to rise
+up to thermosphere.
+The first layer describes the first few meters above the ground,
+whereas the upper layers span several kilometers.
+Figure~\ref{fg:sigma} describes the vertical grid representation
+and associated variables.
+
+\begin{figure}
+\begin{verbatim}
+DYNAMICS                                               PHYSICS
+--------                                               -------
+[coordinates ap(),bp()]                                [pressures]
+
+ap(llm+1)=0,bp(llm+1)=0  ****************************  plev(nlayer+1)=0
+aps(llm),bps(llm)        .. llm .......... nlayer ...  play(nlayer)
+ap(llm),bp(llm)          ****************************  plev(nlayer)
+aps(llm-1),bps(llm-1)    .. llm-1 ........ nlayer-1 .  play(nlayer-1)
+ap(llm-1),bp(llm-1)      ****************************  plev(nlayer-1)
+                             :                :
+                             :                :
+                             :                :
+aps(2),bps(2)            ... 2  ............. 2  ....  play(2)
+ap(2),bp(2)              ****************************  plev(2)
+aps(1),bps(1)            ... 1  ............. 1  ....  play(1)
+ap(1)=1,bp(1)=0          **********surface***********  plev(1)=Ps
+\end{verbatim}
+\caption{Vertical grid description of the {\tt llm (or nlayer)}
+atmospheric layers
+in the programming code ({\tt llm} is the variable used in the dynamical part,
+and {\tt nlayer} is used in the physical part).
+Variables {\tt ap, bp} and {\tt aps, bps} indicate the hybrid levels at
+the interlayer levels and at middle of the layers respectively.
+Pressure at the interlayer is  $Plev(l)=ap(l)+bp(l) \times Ps$ and pressure
+in the middle of the layer is defined by $Play(l)=aps(l)+bps(l) \times Ps$,
+(where $Ps$ is surface pressure).
+Sigma coordinates are merely a specific case of hybrid
+coordinates such that $aps=0$ and $bps=P/Ps$.
+Note that for the hybrid coordinates, $bps=0$ above $\sim50$~km, leading to
+purely pressure levels.
+The user can choose whether to run the model using hybrid coordinates or not
+by setting variable {\tt hybrid} in run.def to True or False.}
+\label{fg:sigma}
+\end{figure}
+
+\section{Variables used in the model}
+
+\subsection{Dynamical variables}
+The dynamical state variables are the atmospheric temperature,
+surface pressure, winds and tracer concentrations.
+In practice, the formulation selected to solve the equations in
+the dynamics %(see chapter~\ref{sc:dynamic})
+is optimised using the following less ``natural'' variables:
+
+\begin{description}
+\item - {\bf potential temperature} $\theta$ ({\tt teta} in the code),
+linked to temperature {\bf T} by $\theta = T{(P/Pref)}^{-\kappa}$
+with $\kappa = R/C_p$
+(note that $\kappa$ is called {\tt kappa} in the dynamical code, and {\tt rcp}
+in the physical code). We take $Pref=610$ Pa on  Mars.
+\item - {\bf surface pressure} ({\tt ps} in the code).
+\item - {\bf mass} the atmosphere mass in each grid box ({\tt masse}
+in the code).
+\item - {\bf the covariant meridional and zonal winds}
+{\tt ucov} and {\tt vcov}.
+These variables are linked to the "natural" winds by
+\verb+ucov = cu * u+ and \verb+vcov = cv * v+, where
+\verb+cu+ and \verb+cv+ are constants that only depend on the latitude.
+%(see Appendix A).
+\item - {\bf mixing ratio of tracers} in the atmosphere, typically
+expressed in kg/kg (array {\tt q} in the code).
+\end{description}
+
+{\tt ucov} and {\tt vcov}, ``vectorial'' variables, are stored on
+``scalari'' grids u and v respectively, in the dynamics
+(see section \ref{fg:grid}).
+{\tt teta}, {\tt q}, {\tt ps}, {\tt masse}, ``scalar variables'',
+are stored on the ``scalar'' grid of the dynamics.
+
+
+
+\subsection{Physical variables}
+
+In the physics, the state variables of the dynamics are transmitted
+via an interface that interpolates the winds on the scalar grid
+(that corresponds to the physical grid) and transforms the dynamical variables
+into more ``natural'' variables.
+Thus we have winds {\bf u} and  {\bf v} (m.s$^{-1}$),
+temperature {\bf T} (K), pressure at the middle of the layers
+{\bf play} (Pa) and at interlayers {\bf plev} (Pa), tracers
+{\bf q}, etc. (kg/kg) on the same grid.
+
+Furthermore, the physics also handle the evolution of the purely
+physical state variables:
+\begin{description}
+\item - {\bf tsurf} surface temperature (K)
+\item - {\bf tsoil} temperature at different layers under the surface (K)
+\item - {\bf emis} surface emissivity
+\item - {\bf alb} surface albedo
+\item - {\bf q2} wind variance, or more precisely the square root of
+the turbulent kinetic energy
+\item - {\bf qsurf} tracer on the surface (kg.m$^{-2}$)
+\item - {\bf rnat} surface type (0 = ocean, 1 = continent)
+\item - {\bf beta} surface wetness (0 $\to$ 1 implies dry $\to$ saturated)
+\item - [anything else?]
+\end{description}
+
+\subsection{Tracers}
+The model may include different types of tracers:
+\begin{description}
+\item - condensed species (e.g., CO$_2$, H$_2$O, dust)
+\item - chemically active species (in principle only at the moment)
+\item - radiatively active gases (e.g., water vapor)
+\end{description}
+
+In the code, all tracers are stored in one three-dimensional array {\tt q},
+the third index of which corresponds to each individual tracer.
+In input and output files (``start.nc'', ``startfi.nc'',
+see Section~\ref{loc:contact1}) tracers are stored separately using their
+individual names. Loading specific tracers requires that
+the approriate tracer names are set in the {\tt traceur.def} file
+(see Section~\ref{sc:traceur.def}), and specific computations
+for given tracers (e.g. computing the water or CO$_2$ cycles) 
+is controlled by setting the corresponding options in the
+{\tt callphys.def} file (see Section~\ref{sc:callphys.def}).
+
Index: /trunk/LMDZ.TITAN/DOC/rcm1d.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/rcm1d.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/rcm1d.tex	(revision 1644)
@@ -0,0 +1,70 @@
+\chapter{1D version of the generic model}
+
+\label{sc:rcm1d}
+
+The physical part of the model can be used to run 1D radiative-convective simulations (one atmospheric column / globally averaged climate). In practice, the simulation is controlled from a main program called \verb+ rcm1d.F+ which, after initialization, then calls the master subroutine of the physics \verb+ physiq.F90+ described in the previous chapters.
+
+\section{Compilation}
+{\bf -} For example, to compile the generic model in 1D with 25 layers, type (in compliance with the makegcm function manual described in section \ref{sc:compil1})
+
+\begin{verbatim}
+makegcm -d 25 -t 1 -b 32x36 -p std rcm1d
+\end{verbatim}
+
+You can find executable {\bf rcm1d.e} (the compiled model)
+in the directory from which you ran the makegcm command.
+
+\section{1-D runs and input files}
+
+The 1D model does not use an initial state file (the simulation must be long enough to obtain a balanced state). Thus, to generate a simulation simply type:
+
+\begin{verbatim}
+> rcm1d.e
+\end{verbatim}
+
+The following example files are available in the {\tt deftank} directory
+(copy them into your working directory first):
+
+- {\bf callphys.def}~: controls the options in the physics,
+  just like for the 3D GCM.
+
+- {\bf z2sig.def}~:
+ controls the vertical discretization
+ (no change needed, in general), functions as with the 3D GCM.
+
+- {\bf traceur.def}~:
+ controls the tracer names (this file may not be present, as long
+ as you run without tracers (option {\tt tracer=.false.} in
+ callphys.def)
+
+- {\bf run.def}~: controls the 1D run parameters and initializations
+(this is actually file {\tt run.def.1d} the {\tt deftank} directory,
+which must be renamed {\tt run.def} to be read by the program).\\
+
+The last file is different from the 3D GCM's {\tt run.def} input file,
+as it contains options specific to the 1D model, as shown in the example
+below:
+\input{input/run.def.1d.tex}
+Note that, just as for the 3D GCM {\tt run.def} file, input
+parameters may be given in any order, or even not given at all
+(in which case default values are used by the program).
+
+
+\section{Output data}
+
+During the entire 1D simulation, you can obtain output data for any
+variable from any physical subroutine by using subroutine \verb+ writeg1d+.
+This subroutine creates file \verb+ g1d.nc+ that can be read by GRADS.
+This subroutine is typically called at the end of subroutine
+\verb+ physiq +. \\
+
+Example of a call to subroutine {\tt writeg1d} requesting
+temperature output:
+(\verb+ ngrid+ horizontal point, \verb+ nlayer + layers, variable
+\verb+ pt + called ``T'' in K units):
+
+\begin{verbatim}
+      CALL writeg1d(ngrid,nlayer,pt,'T','K')
+\end{verbatim}
+
+
Index: /trunk/LMDZ.TITAN/DOC/run.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/run.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/run.tex	(revision 1644)
@@ -0,0 +1,654 @@
+
+\chapter{Running the model: a practice simulation}
+
+\label{loc:contact1}
+
+This chapter is meant for first-time users of the LMD model.
+As the best introduction to the model is surely to run a simulation,
+here we explain how to go about it.
+All you will need are files necessary to build the GCM (all are in
+the {\tt LMDZ.GENERIC} directory) as well as some initial states
+to initiate simulations (see below).\\
+Once you have followed the example given below,
+you can then go on to change the control parameters and the initial states
+as you wish. A more detailed description of the model's organization
+as well as associated inputs and
+outputs are given in sections~\ref{sc:info} and~\ref{sc:io}.
+
+\section{Installing the model from SVN}
+
+The first thing is to download the model from our SVN server. If you cannot use SVN, just find an old school way to get a copy of the basic model directory \verb"LMDZ.GENERIC" (and all the other source files needed for visualization) and download it to your account. Then start directly from the fifth point.
+
+\begin{description}
+\item[$\bullet$] Go to the directory where you want to download the model. Not that only one directory (the root directory) will be added in the current directory.
+
+\item[$\bullet$] If svn is installed on your system, set up the root directory by tipping 
+\begin{verbatim}
+svn co "http://svn.lmd.jussieu.fr/Planeto/trunk" -N Name_of_root_directory
+cd Name_of_root_directory
+\end{verbatim}
+
+\item[$\bullet$] You can now download one of the LMDZ models (for Generic, Mars, Venus, Titan, ...) by tipping
+\begin{verbatim}
+svn update LMDZ.MODEL_YOU_WANT
+\end{verbatim}
+For the Generic model, just tipe
+\begin{verbatim}
+svn update LMDZ.GENERIC
+\end{verbatim}
+The contents of the directory that has been created are described in Chapter \ref{loc:contenu}.
+
+\item[$\bullet$] For visualization of the simulations, yo will need some utilities that we might as well download now by doing
+\begin{verbatim}
+svn update UTIL
+\end{verbatim}
+
+\item[$\bullet$] Now we must set up the {\tt makegcm} script that will perform the compilation of the model. Go into the {\tt LMDZ.GENERIC} directory and edit the appropriate \verb"makegcm_mycompiler" (hereafter called \verb"makegcm"), where \verb"mycompiler" is the compiler that you want to use.
+There are two important environment variables concerning source files that are initialized by \verb"makegcm" and that we need to set properly:
+\begin{enumerate}
+\item \verb"LMDGCM", the path to the source files. By default, the line
+\begin{verbatim}
+setenv LMDGCM `readlink -f $scriptdir`
+\end{verbatim}
+allows \verb"makegcm" to assume that it is executed in the root source directory so that this should work without any change. If \verb"makegcm" does not find the source, you can enter manually the path by changing the above line by
+ \begin{verbatim}
+setenv LMDGCM "path/to/source/directory/LMDZ.GENERIC"
+\end{verbatim}
+\item \verb"LIBOGCM", the path to the compilation directory where all object files will be kept. By default, the line
+\begin{verbatim}
+setenv LIBOGCM $LMDGCM/libo
+\end{verbatim}
+specifies that source will be kept in a \verb"libo" directory created in \verb"LMDZ.GENERIC". You can also change that if needed.
+\end{enumerate} 
+
+\item[$\bullet$]Install NetCDF
+%\item {\bf -} \htmladdnormallink{Install NetCDF}
+{http://www.unidata.ucar.edu/packages/netcdf/INSTALL.html}
+and set environment variables  \verb"NCDFINC" and \verb"NCDFLIB":
+
+  \begin{description}
+  \item The latest version of the NetCDF package is available on the web at the following address: {http://www.unidata.ucar.edu/software/netcdf}
+  along with instructions for building (or downloading precompiled
+  binaries of) the library.
+  \item Once the NetCDF library has been compiled (or downloaded),
+  you should have access to the library {\tt libnetcdf.a} itself,
+  the various files ({\tt netcdf.inc}, {\tt netcdf.mod}, ...)
+  to include in programs, and basic NetCDF software ({\it ncdump}
+  and {\it ncgen}).
+
+  \item To ensure that during compilation, the model can find the
+  NetCDF library and include files,
+  you must declare environment variables \verb"NCDFLIB" and \verb"NCDFINC".
+
+  \item \verb"NCDFLIB" must contain the path to the directory containing
+   the object library {\tt libnetcdf.a}
+   and \verb"NCDFINC" must contain the path to the directory containing
+   the include files ({\tt netcdf.inc},...)\\
+As for \verb"LMDGCM" variable, these variables can be declared by changing the right line in \verb"makegcm"
+  \begin{verbatim}
+  setenv NCDFINC /wherever/is/netcdf/include
+  setenv NCDFLIB /wherever/is/netcdf/lib
+  \end{verbatim}
+For example, if working at LMD and with \verb"ifort", the path is  
+   \begin{verbatim}
+  setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_ifort/include
+  setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_ifort/lib
+  \end{verbatim}
+  \end{description}
+  
+\item[$\bullet$] Install software for loading and displaying NetCDF files
+   such as GrAdS (http://grads.iges.org/grads/), Ferret (http://ferret.wrc.noaa.gov/Ferret), or Python. Some visualization scripts, especially for Python, can be found in the 
+\verb"UTIL" directory and will be described later.
+
+
+\item[$\bullet$] Finally, make sure that you have access to all the executables
+needed for building and using the model and
+remember to set environment variables to the correct corresponding pathes
+(note that if you do not want to have to redefine these every session,
+you should put the definitions in the corresponding {\tt .cshrc} or
+{\tt .bashrc} files).
+
+  \begin{description}
+  \item {\bf -} UNIX function {\it make}
+  \item {\bf -} a Fortran compiler
+  \item {\bf -} ncdump
+  \item {\bf -} grads (or ferret)
+  \end{description}
+
+\end{description}
+
+
+\section{Installing the model without SVN}
+
+ Create an alias so that the compilation script {\bf makegcm}
+  is available from anywhere (more convinient than having to type the full
+  path to the script, or copying it over where you want to run it).
+  The {\tt makegcm} script is in the LMDZ.GENERIC directory, which
+  is referenced by the {\bf LMDGCM} variable, so:\\
+  If using Csh:
+  \begin{verbatim}
+  alias makegcm $LMDGCM'/makegcm'
+  \end{verbatim}
+  if using Bash:
+  \begin{verbatim}
+  alias makegcm=$LMDGCM/makegcm
+  \end{verbatim}
+
+\section{Compiling the LMDZ.GENERIC model (sequential only)}
+\label{sc:run1}
+
+Two options exist to compile the model. 
+\begin{enumerate}
+\item Create an alias so that the compilation script \verb"makegcm"
+  is available from anywhere.
+  If using Csh:
+  \begin{verbatim}
+  alias makegcm 'path/to/LMDZ.GENERIC/makegcm'
+  \end{verbatim}
+  if using Bash:
+  \begin{verbatim}
+  alias makegcm=path/to/LMDZ.GENERIC/makegcm
+  \end{verbatim}
+Then the compilation is done by tipping 
+  \begin{verbatim}
+makegcm -options gcm
+  \end{verbatim}
+This solution can be convenient but is less flexible if you want to compile the model in many different configurations and keep track of it.
+
+\item Create and edit an executable script (that we will call \verb"compile") in the directory where you will want to run the model. Put the line
+  \begin{verbatim}
+/path/to/the/model/I/use/makegcm -options gcm
+  \end{verbatim}
+The advantage of this option is that the \verb"compile" is present in all of the working directories where the model is ran, allowing you to keep track of the options used.
+\end{enumerate}
+
+Just remains to choose the options. The basic options are as follows
+\begin{verbatim}
+makegcm -d LONxLATxALT -p std -t XX -s YY -b IRxVI gcm
+\end{verbatim}
+where \verb"LONxLATxALT" are the number of grid cells in longitude, latitude and altitude, \verb"XX" is the number of tracers, \verb"YY" is the number of scatterers that will be taken into account in the radiative code and \verb"IRxVI" is the number of spectral bands in the thermal emission and stellar part of the radiative code. The option \verb"-debug" is available with most compilers. The code runs much more slowly but can output more user friendly bug report messages.
+
+{\bf -} Example 1: Compiling the generic model at grid resolution 64x48x20
+for example, type (in compliance with the manual for the makegcm function
+given in section~\ref{sc:compil1})
+
+\begin{verbatim}
+makegcm -d 64x48x20 -p std gcm
+\end{verbatim}
+
+\noindent
+You can find executable {\bf gcm.e} (the compiled model) in the directory
+where you ran the makegcm command.
+
+{\bf -} Example 2: Compiling the generic model with 2 tracers
+(e.g. water vapour and ice to simulate the water cycle):
+\begin{verbatim}
+makegcm -d 32x32x20 -t 2 -p std gcm
+\end{verbatim}
+
+{\bf -} Example 3:
+Compiling the the generic model to check for and trace errors (with ifort compiler -
+useful for debugging - warning, the model then runs very slowly!):
+\begin{verbatim}
+makegcm -d 32x32x20 -p std -O "-g -fpe0 -traceback" gcm
+\end{verbatim}
+%**********
+\section{Compiling the LMDZ.COMMON model (sequential or parallel)}
+\label{sc:run1_common}
+\begin{enumerate}
+\item Prerequisites:
+\begin{itemize}
+\item[$\bullet$] Downloaded LMDZ.COMMON and LMDZ.OTHER\_MODEL containing the physic you want.
+\item[$\bullet$] Available MPI library and wrapped compiler (mpif90, mpiifort,...)
+\item[$\bullet$] Optional (but recommended) fcm:
+\begin{itemize}
+\item LMD: /distrib/local/fcm/bin
+\item Ciclad: /home/millour/FCM\_V1.2/bin
+\item Gnome: /san/home/millour/FCM\_V1.2/bin
+\item Other: fcm is just a collection of perl scripts; can be copied over on any other machine, or simply downloaded using svn:\\
+svn checkout http://forge.ipsl.jussieu.fr/fcm/svn/PATCHED/FCM\_V1.2
+\end{itemize}
+\end{itemize}
+\item Then choose the physic you want to couple with the LMDZ.COMMON dynamic core by creating a symbolic link in the LMDZ.COMMON/libf directory.\\
+If you want to use mars physic:
+\begin{verbatim}
+cd LMDZ.COMMON/libf
+ln -s path/to/LMDZ.MARS/libf/phymars .
+ln -s path/to/LMDZ.MARS/libf/aeronomars .
+\end{verbatim}
+Here, we want the LMDZ.GENERIC physic phystd:
+\begin{verbatim}
+cd LMDZ.COMMON/libf
+ln -s path/to/LMDZ.GENERIC/libf/phystd .
+\end{verbatim}
+\item  To compile in LMDZ.COMMON directory:
+\begin{verbatim}
+./makelmdz_fcm -s XX -t XX -d LONxLATxALT -b IRxVI -p physicSuffix 
+-arch archFile [-parallel mpi/mpi_omp] gcm
+\end{verbatim}
+\begin{itemize}
+\item[$\bullet$] \textbf{physicSuffix} is \verb|mars| for phymars, \verb|std| for phystd...
+\item[$\bullet$] \textbf{archFile} is the name of configuration files from LMDZ.COMMON/arch: use \verb|CICLADifort| the ifort compiler in a CICLAD environment, \verb|X64_ADA| for the ADA architecture...
+\item[$\bullet$] To compile in parallel with mpi, add \verb|-parallel mpi| option. By default it is serial code.
+\item[$\bullet$] For hybrid MPI-OpenMP parallelisation, add \verb|-parallel mpi_omp| option.
+\item[$\bullet$] For faster compilation, the option \verb|-j N| uses N simultaneous tasks.
+\item[$\bullet$] \verb|-full| option forces full (re)-compilation from scratch.
+\item[$\bullet$] Created program is in LMDZ.COMMON/bin directory, with dimensions included in the program name. e.g.: gcm\_64x48x29\_phymars\_para.e
+\end{itemize}
+\end{enumerate}
+NB: It is possible to compile without fcm by replacing \verb|makelmdz_fcm| by \verb|makelmdz|. Created program is in LMDZ.COMMON directory and named gcm.e.
+%**********
+\section{Input files (initial states and def files)}
+{\bf -} In directory \verb+LMDZ.GENERIC/deftank+
+you will find some examples of run
+parameter files ({\tt .def} files) which the model needs at runtime.
+The four files the model requires (they must be in the same directory as the
+executable {\tt gcm.e}) are:
+{\bf run.def} (described in
+section~\ref{loc:entrees}) {\bf callphys.def}
+(see section~\ref{sc:callphys.def}),
+{\bf gases.def}, {\bf z2sig.def} and {\bf traceur.def}.\\
+
+The example {\tt .def} files given in the {\tt deftank} directory
+are for various configurations (e.g. model resolution, planet type), copy (and eventually
+rename these files to match the generic names) to the directory where
+you will run the model.\\
+
+\noindent
+{\bf -} Copy initial condition files
+{\bf start.nc} and {startfi.nc}  (described in section
+\ref{loc:entrees}) to the same directory.\\
+You can extract such files from {\bf start\_archive}
+`banks of initial states' (i.e. files which
+contain collections of initial states from
+stndard scenarios and which can thus be used
+to check if the model is installed correctly) stored on the LMD website at\\
+\verb+http://www.lmd.jussieu.fr/~forget/datagcm/Starts+.
+See section~\ref{sc:newstart} for a description of how to proceed to
+extract {\bf start} files from {\bf start\_archives}.\\
+
+[NOTE: WITH THE GENERIC MODEL WE ALMOST ALWAYS START FROM ``startplanet'' FILES]
+%**********
+\section{Running the model}
+\begin{figure}
+\centerline{\framebox[1.4\textwidth][c]{\includegraphics[width=1.2\textwidth]{Fig/inout.eps}}}
+\caption{Input/output data}
+\label{fig:inout}
+\end{figure}
+
+IMPORTANT: The following line MUST be in file run.def (or callphys.def): 
+\begin{verbatim}
+planet_type = mars
+\end{verbatim}
+for using LMDZ.MARS model or
+\begin{verbatim}
+planet_type = generic
+\end{verbatim}
+for using LMDZ.GENERIC model.
+
+\begin{itemize}
+\item[$\bullet$] To run the serial {\bf gcm.e} interactively:\\
+Once you have the program {\bf gcm.e},
+input files {\bf start.nc} {\bf startfi.nc},
+and parameter files {\bf run.def, callphys.def, gases.def, traceur.def, and z2sig.def}
+in the same directory, simply execute the program to run a simulation:
+\begin{verbatim}
+gcm.e
+\end{verbatim}
+
+You might need more memory. Use \verb|ulimit -s unlimited| to change user limits.\\
+You might also want to keep all messages and diagnostics written to standard
+output (i.e. the screen). You should then redirect the standard output
+(and error) to some file, e.g. {\tt gcm.out}:\\
+If using Csh:
+\begin{verbatim}
+gcm.e >! gcm.out
+\end{verbatim}
+If using Bash:
+\begin{verbatim}
+gcm.e > gcm.out 2>&1
+\end{verbatim}
+
+
+\item [$\bullet$] To run the MPI-parallel {\bf gcm.e} interactively:
+\begin{verbatim}
+mpirun -np N gcm.e > gcm.out 2>&1
+\end{verbatim}
+\verb|-np N| specifies the number of procs to run on.\\
+IMPORTANT: one MUST use the \verb|mpirun| command corresponding to the \verb|mpif90| compiler specified in the \verb|arch| file.\\
+Output files (restart.nc, diagfi.nc ,etc.) are just as when running in serial. But standard output messages are written by each process.\\
+If using chained simulations (run\_mcd/run0 scripts), then the command line to run the gcm in \verb|run0| must be adapted for local settings.\\
+NB: LMDZ.COMMON dynamics set to run in double precision, so keep \verb|NC_DOUBLE| declaration (and real to double precision promotion) in the arch files.
+\item [$\bullet$] To run the hybrid parallel {\bf gcm.e} interactively:
+\begin{verbatim}
+export OMP_NUM_THREADS=2
+export OMP_STACKSIZE=2500MB
+mpirun -np 2 gcm.e > gcm.out 2>&1
+\end{verbatim}
+In this exemple, each of the 2 process MPI have 2 OpenMP tasks with a 2500MB memory.
+\item[$\bullet$] To run the MPI-parallel {\bf gcm.e} with a job scheduler (different on each machine):
+\begin{verbatim}
+PBS example (on Ciclad):
+#PBS -S  /bin/bash
+#PBS -N  job_mpi08
+#PBS -q short
+#PBS -j eo
+#PBS -l "nodes=1:ppn=8"
+# go to directory where the job was launched
+cd $PBS_O_WORKDIR
+mpirun gcm_64x48x29_phymars_para.e > gcm.out 2>&1
+\end{verbatim}
+\begin{verbatim}
+LoadLeveler example (on Gnome):
+# @ job_name = job_mip8
+# standard output file  
+# @ output = job_mpi8.out.$(jobid)
+# standard error file
+# @ error =  job_mpi8.err.$(jobid)
+# job type
+# @ job_type = mpich
+# @ blocking = unlimited
+# time
+# @ class = AP
+# Number of procs 
+# @ total_tasks = 8
+# @ resources=ConsumableCpus(1) ConsumableMemory(2500 mb)
+# @ queue
+set -vx
+mpirun gcm_32x24x11_phymars_para.e > gcm.out 2>&1
+\end{verbatim}
+\begin{verbatim}
+LoadLeveler example (on Ada):
+module load intel/2012.0
+# @ output  =  output.$(jobid)
+# @ error = $(output)
+# @ job_type = parallel
+## Number of MPI process
+# @ total_tasks = 8
+## Memory used by each MPI process
+# @ as_limit = 2500mb 
+# @ wall_clock_limit=01:00:00
+# @ core_limit = 0
+# @ queue
+set -x
+poe ./gcm.e -labelio yes > LOG 2>&1
+\end{verbatim}
+\item[$\bullet$] To run the hybrid MPI/OpenMP-parallel {\bf gcm.e} with a job scheduler (different on each machine):
+\begin{verbatim}
+LoadLeveler example (on Gnome):
+# @ job_name = job_mip8
+# standard output file  
+# @ output = job_mpi8.out.$(jobid)
+# standard error file
+# @ error =  job_mpi8.err.$(jobid)
+# job type
+# @ job_type = mpich
+# @ blocking = unlimited
+# time
+# @ class = AP
+# Number of procs 
+# @ total_tasks = 8
+# @ resources=ConsumableCpus(1) ConsumableMemory(5000 mb)
+# @ queue
+set -vx
+export OMP_NUM_THREADS=2 #sinon par defaut, lance 8 threads OpenMP
+export OMP_STACKSIZE=2500MB
+mpirun gcm_32x24x11_phymars_para.e > gcm.out 2>&1
+\end{verbatim}
+IMPORTANT: ConsumableMemory must be equal to OMP\_NUM\_THREADSxOMP\_STACKSIZE.\\
+In this case, we are using 8x2 cores.
+\begin{verbatim}
+LoadLeveler example (on Ada):
+module load intel/2012.0
+# @ output  =  output.$(jobid)
+# @ error = $(output)
+# @ job_type = parallel
+## Number of MPI process
+# @ total_tasks = 8
+## Number of OpenMP tasks attached to each MPI process
+# @ parallel_threads = 2
+## Memory used by each MPI process
+# @ as_limit = 5gb 
+# @ wall_clock_limit=01:00:00
+# @ core_limit = 0
+# @ queue
+set -x
+export OMP_STACKSIZE=2500MB
+poe ./gcm.e -labelio yes > LOG 2>&1
+\end{verbatim}
+IMPORTANT: In this case, each core needs 2.5gb and we are using 2 OpenMP tasks for each MPI process so $\verb|as_limit|=2 \times 2.5$.
+\end{itemize}
+%**********
+\section{Visualizing the output files}
+
+As the model runs it generates output files {\bf diagfi.nc} and
+{\bf stats.nc} files. The former contains instantaneous values of
+various fields and the later statistics (over the whole run) of some
+variables.
+
+\subsection{Using GrAds to visualize outputs}
+If you have never used the graphic software {\bf GrAds}, we strongly
+recommend spending half an hour to familiarize yourself with it by following
+the demonstration provided for that purpose.
+The demo is fast and easy to follow and you will learn the basic commands.
+To do this read file
+\begin{verbatim}
+/distrib/local/grads/sample
+\end{verbatim}
+
+For example, to visualize files {\tt diagfi.nc} and {\tt stats.nc}
+
+NetCDF files {\tt diagfi.nc} and {\tt stats.nc} can be accessed directly
+using GrAdS thanks to utility program gradsnc,
+(the user does not need to intervene).\\
+
+\noindent
+To visualize the temperature in the 5th layer using file
+{\tt diagfi.nc} for example:
+\label{loc:visu}
+
+\begin{description}
+\item {\bf -} GrAdS session:
+
+  \begin{description}
+  \item \verb+grads+ {\it return}
+
+  \item {\it return} (opens a landscape window)
+
+  \item \verb+ga-> sdfopen diagfi.nc+
+
+  \item \verb+ga-> query file+ (displays info about the open file, including the name of the stored variables. Shortcut: {\it q file})
+
+  \item \verb+ga-> set z 5+ (fixes the altitude to the 5th layer)
+
+  \item \verb+ga-> set t 1+ (fixes the time to the first stored value)
+
+  \item \verb+ga-> query dims+ (indicates the fixed values for the 4
+  dimensions. Shortcut: {\it q dims})
+
+  \item \verb+ga-> display temp+ (displays the temperature card for the 5th layer and for the first time value stored. Shortcut: {\it d
+  T})
+
+  \item \verb+ga-> clear+ (clears the display. Shortcut: {\it c})
+
+  \item \verb+ga-> set gxout shaded+ (not a contour plot, but a shaded one)
+
+  \item \verb+ga-> display temp+
+
+  \item \verb+ga-> set gxout contour+ (returns to contour mode to display the levels)
+
+  \item \verb+ga-> display temp+ (superimposes the contours if the clear command is not used)
+
+  \end{description}
+\end{description}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{Resuming a simulation}
+At the end of a simulation, the model generates {\bf restart} files
+(files {\tt restart.nc} and {\tt restartfi.nc})
+which contain the final state of the model.
+As shown in figure~\ref{fig:inout},
+these files (which are of the same format as the start files)
+can later be used as initial
+states for a new simulation.\\
+
+\noindent
+The {\bf restart} files just need to be renamed:
+\begin{verbatim}
+mv restart.nc start.nc
+mv restartfi.nc startfi.nc
+\end{verbatim}
+\noindent
+and running a simulation with these will in fact resume the simulation
+from where the previous run ended.
+
+\section{Chain simulations}
+
+In practice, we recommend running a chain of simulations lasting several
+days or longer (or hundreds of days at low resolution).
+
+To do this, a script named {\tt run0} is available in
+\verb+LMDZ.GENERIC/deftank+ , which should be used as follows:
+\begin{itemize}
+\item Set the length of each simulation in {\tt run.def}
+ (i.e. set the value of {\tt nday})
+\item Set the maximum number of simulations at the beginning of the {\tt run0}
+script (i.e. set the value of {\tt nummax})
+\item Copy start files {\tt start.nc  startfi.nc} over and rename them
+      {\tt start0.nc startfi0.nc}.
+\item Run script {\tt run0}
+\end{itemize}
+
+{\tt run0} runs a series of simulations that generate the indexed output
+files (e.g. {\tt start1, startfi1, diagfi1}, etc.)
+including files {\tt lrun1, lrun2}, etc. containing the redirection of the
+display and the information about the run.
+
+{\it NOTE:} to restart a series of simulations after a first series
+(for example, starting from {\tt start5 and  startfi5}), just write the
+index of the initial files (e.g. 5) in the file named {\tt num\_run}.
+If {\tt num\_run} exists, the model will start from the index written in
+{\tt num\_run}. If not it will start from, {\tt start0 and startfi0}.
+
+
+{\it NOTE}: A script is available for performing annual runs with 12 seasons
+at 30$^o$ solar longitude
+as it is in the database (script {\bf \tt run\_mcd}, also found in directory
+{\tt deftank}).
+This script functions with script run0. Just set the number of simulations to
+1 in run0. Then copy run.def into run.def.ref and set nday to 9999 in this
+file. To start from startN.c, edit the file run\_mcd and comment
+(with a \#) the N months already created and describe N in {\tt num\_run}.
+Then run  {\bf \tt run\_mcd}.
+
+
+\section{Creating and modifying initial states}
+
+\label{sc:newstart}
+
+\subsection{Using program ``newstart''}
+
+When working with the generic model, it is common to start with simple initial conditions (e.g., isothermal, motionless atmosphere). For this we create an initial state using {\bf newstart}. In practice, we usually take an old initial state, and simply modify it.
+
+Like the GCM, the program {\bf newstart} must be compiled (using the {\tt makegcm} script) to the required grid resolution.
+For example:
+\begin{verbatim}
+makegcm -d 32x32x20 -p std newstart
+\end{verbatim}
+
+Then run
+
+\begin{verbatim}
+newstart.e
+\end{verbatim}
+
+The program then gives you two options:
+
+\begin{verbatim}
+ From which kind of files do you want to create newstart and startfi files
+     0 - from a file start_archive
+     1 - from files start and startfi
+\end{verbatim}
+
+\begin{itemize}
+\item{-} Option ``1'' allows you to read and modify the information needed
+to create a new initial state  from the files
+\verb+ start.nc, startfi.nc +
+\item{-} Option ``0'' allows you to read and modify the information needed to
+create a new initial state from file
+\verb+ start_archive.nc + (whatever the \verb+ start_archive.nc +
+grid resolution is).\\
+\end{itemize}
+If you use tracers, make sure that they are taken into account in your
+start files (either start or start\_archive).\\ \\
+Then answer to the various questions in the scroll menu.
+These questions allow you to modify the initial state for the following
+parameters.\\
+
+
+\input{input/questions_inistate.tex}
+
+Program {\bf newstart.e} creates files
+{\tt restart.nc} and {\tt restartfi.nc}
+that you generally need to rename (for instance rename them in start0.nc
+and startfi0.nc if you want to use run0 or run\_mcd, starting with season 0;
+rename them {\tt start.nc} and {\tt startfi.nc} if you just want to perform
+one run with {\tt gcm.e}).
+
+
+\subsection{Creating the initial start\_archive.nc file }
+
+Archive file
+{\tt start\_archive.nc} is created from files
+{\tt start.nc} and {\tt startfi.nc} by program {\bf start2archive}.
+Program {\bf start2archive} compiles to the same grid resolution as the
+{\tt start.nc} and {\tt startfi.nc} grid resolution. For example:
+
+\begin{verbatim}
+makegcm -d 32x32x20 -p std start2archive
+\end{verbatim}
+Then run \verb+ start2archive.e+ \\ \\
+You now have a \verb+ start_archive.nc+ file for one season that you can
+use with newstart.
+If you want to gather other states obtained at other times of year, rerun
+{\tt start2archive.e} with the {\tt start.nc} and {\tt startfi.nc}
+ corresponding to these.
+These additional initial states will automatically be added to the
+{\tt start\_archive.nc} file present in the directory.
+
+\subsection{Changing the horizontal or vertical grid resolution}
+
+To run at a different grid resolution than available initial conditions
+files, one needs to use tools {\bf newstart} and {\bf start2archive}
+
+For example, to create initial states at grid resolution
+32$\times$24$\times$25 from NetCDF files
+\verb+ start + and \verb+ startfi + at grid resolution
+  64$\times$48$\times$32 :
+
+\begin{itemize}
+\item Create file \verb+ start_archive.nc +
+with {\bf start2archive.e} compiled at grid resolution
+64$\times$48$\times$32 using {\bf old file {\tt z2sig.def}
+ used previously}
+
+\item Create files
+{\tt newstart.nc} and {\tt newstartfi.nc}
+ with {\bf newstart.e}
+compiled at grid resolution 32$\times$24$\times$25,
+using {\bf new file {\tt z2sig.def}}
+
+\end{itemize}
+
+[NOT RELEVANT??]
+If you want to create starts files with tracers for 50 layers using a
+{\tt start\_archive.nc} obtained for 32 layers, do not forget to use the
+\verb+ ini_q+ option in newstart in order to correctly initialize tracers
+value for layer 33 to layer 50.
+You just have to answer yes to the question on thermosphere initialization
+if you want to initialize the thermosphere part only (l=33 to l=50),
+and no if you want to initialize tracers for all layers (l=0 to l=50).\\ \\
+
Index: /trunk/LMDZ.TITAN/DOC/sol2ls.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/sol2ls.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/sol2ls.tex	(revision 1644)
@@ -0,0 +1,76 @@
+\chapter{GCM Martian Calendar}
+
+\label{sc:sol2ls}
+
+
+For Mars, dates and seasons are expressed in Solar Longitude ($L_s$,
+in degrees or in radians) counting from the northern hemisphere spring equinox.
+In the GCM, time is counted in Martian solar days, or ``sols''
+(1 sols = 88775 s) from the northern spring equinox. 
+The following table gives the correspondence between sols and $L_s$,
+calculated for the GCM using one Martian year = 669 sols exactly.
+
+\vspace{0.5cm}
+
+\footnotesize
+
+\hspace*{-2.cm}\begin{tabular}{|c|c|c||c|c|c||c|c|c|}
+\hline
+ sol & $L_s$ & & sol & $L_s$ & & sol & $L_s$ &  \\
+\hline
+  0. & 360.000 & Spring equinox N &240. & 111.455& &480. & 247.408&  \\ 
+  5. &   2.550 & &245. & 113.816& &485. & 250.666&  \\ 
+ 10. &   5.080 & &250. & 116.190& &490. & 253.925&  \\ 
+ 15. &   7.590 & &255. & 118.578& &495. & 257.182&  \\ 
+ 20. &  10.081 & &260. & 120.981& &500. & 260.435&  \\ 
+ 25. &  12.554 & &265. & 123.400& &505. & 263.683&  \\ 
+ 30. &  15.009 & &270. & 125.835& &510. & 266.924&  \\ 
+  &  &  & & & &514.76 &   270.& Winter solstice N \\ 
+ 35. &  17.447 & &275. & 128.287& &515. & 270.156&  \\ 
+ 40. &  19.869 & &280. & 130.756& &520. & 273.377&  \\ 
+ 45. &  22.275 & &285. & 133.243& &525. & 276.587&  \\ 
+ 50. &  24.666 & &290. & 135.750& &530. & 279.783&  \\ 
+ 55. &  27.043 & &295. & 138.275& &535. & 282.965&  \\ 
+ 60. &  29.407 & &300. & 140.821& &540. & 286.130&  \\ 
+ 65. &  31.758 & &305. & 143.388& &545. & 289.277&  \\ 
+ 70. &  34.096 & &310. & 145.975& &550. & 292.406&  \\ 
+ 75. &  36.423 & &315. & 148.585& &555. & 295.515&  \\ 
+ 80. &  38.739 & &320. & 151.217& &560. & 298.604&  \\ 
+ 85. &  41.046 & &325. & 153.872& &565. & 301.671&  \\ 
+ 90. &  43.343 & &330. & 156.550& &570. & 304.715&  \\ 
+ 95. &  45.631 & &335. & 159.251& &575. & 307.737&  \\ 
+100. &  47.912 & &340. & 161.977& &580. & 310.735&  \\ 
+105. &  50.186 & &345. & 164.727& &585. & 313.709&  \\ 
+110. &  52.453 & &350. & 167.502& &590. & 316.658&  \\ 
+115. &  54.714 & &355. & 170.301& &595. & 319.583&  \\ 
+120. &  56.970 & &360. & 173.126& &600. & 322.483&  \\ 
+125. &  59.222 & &365. & 175.975& &605. & 325.358&  \\ 
+130. &  61.471 & &370. & 178.850& &610. & 328.207&  \\ 
+   . &         & &371.99 & 180.   & Autumn equinox N &   . &        &  \\ 
+135. &  63.716 & &375. & 181.750& &615. & 331.032&  \\ 
+140. &  65.959 & &380. & 184.675& &620. & 333.831&  \\ 
+145. &  68.201 & &385. & 187.624& &625. & 336.606&  \\ 
+150. &  70.442 & &390. & 190.598& &630. & 339.356&  \\ 
+155. &  72.683 & &395. & 193.596& &635. & 342.082&  \\ 
+160. &  74.925 & &400. & 196.618& &640. & 344.783&  \\ 
+165. &  77.168 & &405. & 199.662& &645. & 347.461&  \\ 
+170. &  79.413 & &410. & 202.729& &650. & 350.116&  \\ 
+175. &  81.661 & &415. & 205.818& &655. & 352.748&  \\ 
+180. &  83.912 & &420. & 208.927& &660. & 355.357&  \\ 
+185. &  86.167 & &425. & 212.056& &665. & 357.945&  \\ 
+  &  &  & & & &669. &   0.& Spring equinox N  \\ 
+190. &  88.427 & &430. & 215.203& &670. &   0.512&  \\ 
+193.47  & 90.  & Summer solstice N  & & & & &  &  \\ 
+195. &  90.693 & &435. & 218.368& &675. &   3.057&  \\ 
+200. &  92.965 & &440. & 221.549& &680. &   5.583&  \\ 
+205. &  95.245 & &445. & 224.746& &685. &   8.089&  \\ 
+210. &  97.532 & &450. & 227.955& &690. &  10.577&  \\ 
+215. &  99.827 & &455. & 231.177& &695. &  13.046&  \\ 
+220. & 102.131 & &460. & 234.409& &700. &  15.498&  \\ 
+225. & 104.446 & &465. & 237.650& &705. &  17.933&  \\ 
+230. & 106.770 & &470. & 240.898& &710. &  20.351&  \\ 
+235. & 109.107 & &475. & 244.151& &715. &  22.755&  \\ 
+240. & 111.455 & &480. & 247.408& &720. &  25.143&  \\ 
+\hline
+
+\end{tabular}
Index: /trunk/LMDZ.TITAN/DOC/test.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/test.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/test.tex	(revision 1644)
@@ -0,0 +1,105 @@
+%
+%
+%     Test comportement LATEX et LATEX2HTML
+%
+%
+%
+\documentclass[dvips]{report}
+\usepackage{makeidx}
+\usepackage{a4}
+\usepackage{graphicx}
+%
+% Pour definir un paragraph avec retour a la ligne
+\usepackage{loc}
+%
+\usepackage{html,htmllist}
+% \usepackage{times}
+\scrollmode
+% use %sort -f -u manual.idx > manual.index for a primitive index
+%
+%  NOTE:  You must use LaTeX2e in order to process this document
+%	If you do not have LaTeX2e, a PostScript version
+%	(manual.ps) is included with this distribution.
+%
+%%%%%%%%%%%%%%%%%%% No changes beyond this point %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\makeindex
+\sloppy
+% Transforms the \indexentry generated by \makeindex in the concepts.idx
+% file into a form understood by the theindex environment.
+% See below on how to produce an index.
+%
+\newcommand{\latextohtml}{\LaTeX 2\texttt{HTML}}
+\newcommand{\fn}[1]{{\ttfamily #1}}	% file names
+\newcommand{\Email}[1]{{\ttfamily <#1>}}% file names
+\newcommand{\HTML}[1]{{\ttfamily <#1>}}%  HTML tag
+\newcommand{\Meta}[1]{\texttt{<\emph{#1}>}}%  Meta string
+\newcommand{\indexentry}[2]{\item #1 #2}
+\def\contrat{contrat numero N de l'ESA}
+\newcommand{\onlinedoc}{http://www-dsed.llnl.gov/files/programs/unix/latex2html/manual/}
+\newcommand{\patches}{http://www-dsed.llnl.gov/files/programs/unix/latex2html}
+\newcommand{\sourceA}{ftp://www-dsed.llnl.gov/files/programs/unix/latex2html/sources/latex2html-96.1.tar.gz}
+\newcommand{\sourceB}{ftp://ftp.mpn.com/pub/nikos/latex2html-96.1.tar.gz}
+\newcommand{\sourceC}{ftp://ftp.rzg.mpg.de/outgoing/latex2html-96.1.tar.gz}
+\newcommand{\CTAN}{tex-archive/support/latex2html}
+
+%\setlength{\textwidth}{5.5in}
+%\setlength{\textwidth}{16cm}
+%\setlength{\changebarwidth}{1pt}
+%\addtolength{\oddsidemargin}{-1in}
+%\addtolength{\oddsidemargin}{-2cm}
+%\addtolength{\evensidemargin}{-1in}
+%\addtolength{\evensidemargin}{-2cm}
+ 
+% numero de la derniere section numerotee
+\setcounter{secnumdepth}{3}
+% numero de la derniere section a apparaitre dans la table des matieres
+\setcounter{tocdepth}{3}
+ 
+
+\begin{document}
+\bibliographystyle{abbrv}
+
+\input{def}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%    variables definies pour doc Terre ou Mars
+
+\def\planete{mars}
+\def\italique{{\it mars}}
+\def\planeteX{mars/}
+\def\STARTFI{startfi}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+planete sans espace -\planete-\\
+italique -\italique-\\
+planete en italique -{\it \planete}-\\
+
+planeteX sans espace -\planeteX-\\
+planete avec espace -\planete -\\
+planete avec /  -\planete/coucou\\
+STARTFI sans espace -\STARTFI-\\
+STARTFI avec espace -\STARTFI -\\
+
+
+% lorsqu'on appelle une variable definie au prealable dans une nouvelle
+%commande, latex2html ajoute un blanc apres cette variable.
+
+\def\OK#1#2{\planete/#1/#2.html}
+ecrit OK: \OK{dyn3d}{lectba}\\
+ecrit OK: mars/dyn3d/lectba.html\\
+
+ATTENTION: latex2html n'aime pas les \def\nom ou nom contient un
+chiffre!\\
+
+
+\def\sourceF#1#2{\htmladdnormallink{#2}{#1}}
+
+
+\sourceF{dyn3d}{lectba}
+
+\end{document}
Index: /trunk/LMDZ.TITAN/DOC/utilities.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/utilities.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/utilities.tex	(revision 1644)
@@ -0,0 +1,81 @@
+\chapter{Utilities}
+
+\label{sc:utilities}
+
+A few post-processing tools, which handle GCM outputs (files
+{\tt diagfi.nc} and {\tt stats.nc}) are available on the web at:\\
+\verb+http://www.lmd.jussieu.fr/~forget/datagcm/Utilities/+\\
+The directory contains compiled executables (\verb+*.e+ files) of the tools
+decribed below, along with some examples of input instruction
+(\verb+*.def+ files) and a \verb+README+.\\
+There is also a \verb+SOURCES+ directory which contains the (Fortran)
+sources of the codes, if you should need to recompile them
+on your platform.
+
+\section{concatnc}
+This program concatenates consecutive
+output files ({\tt diagfi.nc} or even {\tt stats.nc} files) for a selection of 
+variable, in order to obtain one single big file.
+The time dimension of the output can
+be "sols" or "Ls" (note that in that latter case, Ls values won't be
+evenly distributed, and
+software like Grads may not be able to use and plot the data).\\
+To obtain an evenly sampled "Ls"
+timescale, you can use the {\tt lslin.e} program (described below).\\
+The output file created by {\tt conctanc.e} is {\tt concat.nc}
+
+\section{lslin}
+
+This program is designed to interpolate data given
+in  irregular Solar Longitude (Ls) into an evenly sampled
+linear time coordinate (usable with Grads).
+Input Netcdf files may be {\tt diagfi.nc} or {\tt concat.nc}  
+files and the resulting
+output file is {\tt lslin.nc}
+lslin also create a {\tt lslin.ctl} file that can be read
+directly by grads (\verb+>xdfopen lslin.ctl+) to plot in Ls coordinate to
+avoid some problem with grads when Grads think that "the time interval
+is too small"...
+
+\section{localtime}
+
+The {\tt localtime.e} program is designed to re-interpolate data in order
+to yield values at the same given local time (useful to mimic satellite
+observations, or analyse day to day variations at given local time).\\
+Input files may be of {\tt diagfi.nc}, {\tt stats.nc} or {\tt concat.nc}
+type and the output file name is build from the input one, to which 
+{\tt \_LT.nc} is appened (e.g. if the input file is {\tt myfile.nc} then
+output file will be {\tt myfile\_LT.nc}).
+
+\section{zrecast}
+With this program you can recast atmospheric (i.e.: 4D-dimentional
+longitude-latitude-altitude-time) data from GCM outputs (e.g. as given in
+{\tt diagfi.nc}, {\tt concat.nc} and {\tt stats.nc} files) onto
+either {\it pressure} or {\it altitude above areoid} vertical coordinates.\\
+Since integrating the hydrostatic equation is required to recast the data,
+the input file must contain surface pressure and atmospheric temperature,
+as well as the ground geopotential.\\
+If recasting data onto {\it pressure} coordinates, then the output file name
+is given by the input file name to which {\tt\_P.nc} will be appened.
+If recasting data onto {\it altitude above areoid} coordinates, then a
+{\tt\_A.nc} will be appened.
+
+
+%\section{How to concat diagfi files?}
+%In the directory concatnc (available on the web at
+%http://www.lmd.jussieu.fr/\verb+~+forget/datagcm/Utilities/),
+%you will find a tool to concat the diagfi files.
+%To compile, juste type "make"
+%(make sure the makefile is updated: FC= pgf90 for PC and FC= f90 for suns).\\ \\
+%run concatnc.e \\ \\ 
+%Your data are in concat.nc
+%
+%\section{How to convert your output in pressure coordinates?} 
+%In your working directory, compile at the correct grid resolution, which is
+%the same as the one of your output files (stats or diagfi).\\ \\
+%makegcm  -d 64x48x32  -p mars anl\_stats-diag \\ \\
+%run anl\_stats-diag.e
+%Your data in pressure coordinate will be in the resuting diagfi.nc
+%(or stats.nc). \\
+%If needed, you can change the source file anl\_stats-diag.F in
+%yourpath/LMDZ.MARS/libf/dyn3d
Index: /trunk/LMDZ.TITAN/DOC/water.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/water.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/water.tex	(revision 1644)
@@ -0,0 +1,41 @@
+\chapter{Water Cycle Simulation}
+
+\label{sc:water}
+
+To simulate the water cycle with the LMD Generic Model:
+
+\begin{itemize}
+\item In {\tt callphys.def}, set tracer to true: {\tt tracer=.true.}. In the radiative
+transfer sub-section, chose an appropriate correlated-k database that includes the effect
+of water vapour (e.g. {\tt corrkdir=CO2H2Ovar}), and set {\tt varactive=.true.}, {\tt varfixed=.false.}.
+In the water cycle sub-section you can chose various parameters - see below for a standard example.
+
+\input{input/h2o_list.tex}
+
+\item You need to compile with at least 2 tracers. If you don't have CO2 clouds,
+dust or other tracers, compilation is done with the command lines:
+\begin{verbatim}
+makegcm -d 64x48x20 -t 2 -p std -b 32x36 newstart
+\end{verbatim}
+\begin{verbatim}
+makegcm -d 64x48x20 -t 2 -p std -b 32x36 gcm
+\end{verbatim}
+
+Of course, you will also need an appropriate {\tt traceur.def} file
+indicating you will use tracers {\tt h2o\_vap} and {\tt h2o\_ice};
+if you only run with 2 tracers, then the contents of the {\tt traceur.def}
+file should be:
+\begin{verbatim}
+2
+h2o_ice
+h2o_vap
+\end{verbatim}
+Note that the order in which tracers are set in the {\tt traceur.def} file
+is not important.
+
+\item {\bf Run} \\ \\
+Same as usual. Just make sure that your start files contains
+the initial states for water, with an initial state for water vapour / ice
+in the atmosphere and ice / liquid on the surface.
+
+\end {itemize}
Index: /trunk/LMDZ.TITAN/DOC/water.tex.sav
===================================================================
--- /trunk/LMDZ.TITAN/DOC/water.tex.sav	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/water.tex.sav	(revision 1644)
@@ -0,0 +1,52 @@
+\chapter{Water Cycle Simulation}
+
+\label{sc:water}
+
+To simulate the water cycle with the LMD Generic Model:
+
+\begin{itemize}
+
+
+\item In {\tt callphys.def}, set tracer to true: {\tt tracer=.true.}. In the radiative
+transfer sub-section, chose an appropriate correlated-k database that includes the effect
+of water vapour (e.g. {\tt corrkdir=CO2_H2Ovar}), and set {\tt varactive=.true.}, {\tt varfixed=.false.}.
+
+The important parameters are {\tt water=.true.}, to use water vapor
+and ice tracers, and {\tt sedimentation=.true.} to
+allow sedimentation of water ice clouds.
+
+In {\tt traceur.def}, include (at least) two tracers: {\tt h2o_ice} and {\tt h2o_vap}.
+
+\input{input/h2o_list.tex}
+
+\item {\bf Compilation}
+You need to compile with at least 2 tracers. If you don't have CO2 clouds,
+({\tt dustbin=0}) or other tracers,
+compilation is done with the command lines:
+\begin{verbatim}
+makegcm -d 64x48x25 -t 2 -p std newstart
+\end{verbatim}
+\begin{verbatim}
+makegcm -d 64x48x25 -t 2 -p std gcm
+\end{verbatim}
+
+Of course, you will also need an appropriate {\tt traceur.def} file
+indicating you will use tracers {\tt h2o\_vap} and {\tt h2o\_ice};
+if you only run with 2 tracers, then the contents of the {\tt traceur.def}
+file should be:
+\begin{verbatim}
+2
+h2o_ice
+h2o_vap
+\end{verbatim}
+Note that the order in which tracers are set in the {\tt traceur.def} file
+is not important.
+
+\item {\bf Run} \\ \\
+Same as usual. Just make sure that your start files contains
+the initial states for water, with an initial state for water vapor
+and water ice particles.
+
+[+LIQUID]
+
+\end {itemize}
Index: /trunk/LMDZ.TITAN/DOC/zoom.tex
===================================================================
--- /trunk/LMDZ.TITAN/DOC/zoom.tex	(revision 1644)
+++ /trunk/LMDZ.TITAN/DOC/zoom.tex	(revision 1644)
@@ -0,0 +1,121 @@
+\chapter{Zoomed simulations}
+
+\label{sc:zoom}
+
+The LMD GCM can use a zoom to enhance the resolution locally.
+In practice, one can
+increase the latitudinal resolution on the one hand,
+and the longitudinal resolution on
+the other hand. 
+
+\section{To define the zoomed area}
+
+The zoom is defined in {\tt run.def}.
+Here are the variables that you want to set:
+
+\begin{itemize}
+\item East longitude (in degrees) of zoom center {\tt clon}
+\item latitude (in degrees) of zoom center {\tt clat}
+\item zooming factors, along longitude {\tt grossismx}.
+      {\it Typically 1.5, 2 or even 3 (see below)}
+\item zooming factors, along latitude {\tt grossismy}. {\it Typically 1.5, 2
+or even 3 (see below)}
+\item {\tt fxyhypb}:
+      {\it {\bf must be set to "T" for a zoom}, whereas it must be F otherwise}
+\item extention in longitude  of zoomed area {\tt dzoomx}.
+      This is the total
+      longitudinal extension of the zoomed region (degree). \newline
+      {\it It is recommended that {\tt grossismx} $\times$
+      {\tt dzoomx} $< 200^o$}
+\item extention in latitude of the zoomed region {\tt dzoomy}.
+      This is the total
+      latitudinal extension of the zoomed region (degree). \newline
+      {\it It is recommended that {\tt
+      grossismy} $\times$ {\tt dzoomy} $< 100^o$}
+\item stiffness of the zoom along longitudes {\tt taux}.
+      2 is for a smooth transition in
+      longitude, more means sharper transition.
+\item stiffness of the zoom along latitudes {\tt taux}.
+      2 is for a smooth transition in
+      latitude, more means sharper transition.
+\end{itemize}
+
+\section{Making a zoomed initial state}
+
+One must start from an initial state archive {\tt start\_archive.nc}
+obtained from a previous
+simulation (see section~\ref{sc:newstart})
+Then compile and run {\tt newstart.e} {\bf using the {\tt run.def}
+file designed for the zoom}.
+
+After running {\tt newstart.e}. The zoomed grid may be visualized
+using grads, for instance.
+Here is a grads script that can be used to map the grid above a topography
+map:
+
+\begin{verbatim}
+set mpdraw off
+set grid off
+sdfopen restart.nc
+set gxout grid
+set digsiz 0
+set lon -180 180
+d ps
+close 1
+*** replace the path to surface.nc in the following line:
+sdfopen  /u/forget/WWW/datagcm/datafile/surface.nc
+set lon -180 180
+set gxout contour
+set clab off
+set cint 3
+d zMOL
+\end{verbatim}
+
+
+\section{Running a zoomed simulation and stability issue}
+
+\begin{itemize}
+
+\item {\bf dynamical timestep}
+Because of their higher resolution, zoomed simulation requires a higher
+timestep.
+Therefore in {\tt run.def}, the number of dynamical timestep per day
+{\tt day\_step} must be increased by more than {\tt grossismx} or
+{\tt grossismy} (twice that if necessary).
+However, you can keep the same physical timestep (48/sol) and thus increase
+ {\tt iphysiq} accordingly ({\tt iphysiq = day\_step/48}).
+
+\item It has been found that when zooming in longitude, on must set
+{\tt ngroup=1} in
+{\tt dyn3d/groupeun.F}. Otherwise the run is less stable.
+
+\item The very first initial state made with {\tt newstart.e} can be noisy and
+dynamically unstable.
+It may be necessary to strongly increase the intensity of the
+dissipation and increase {\tt day\_step} in {\tt run.def} for 1 to 3 sols,
+and then use less strict values. 
+
+\item If the run remains very unstable and requires too much dissipation
+or a too small timestep, a good tip to help stabilize the model
+is to decrease the vertical extension of your run and the number of
+layer (one generally zoom to study near-surface process, so 20 to 22
+layers and a vertical extension up to 60 or 80 km is usually enough).
+
+\end{itemize}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 
+
+
+
Index: /trunk/LMDZ.TITAN/README
===================================================================
--- /trunk/LMDZ.TITAN/README	(revision 1644)
+++ /trunk/LMDZ.TITAN/README	(revision 1644)
@@ -0,0 +1,1283 @@
+== 17/09/08 ==
+>>> Build a version with new soil but old radiative transfer,
+    but keeping possibility of switching back to new radiative transfer),
+    which incorporates changes & improvements currently included in the
+    'reference version' GCM (see /u/emlmd/LMDZ.MARS.mixdyn)
+
+>>> start by modifying makegcm as in /u/emlmd/LMDZ.MARS.mixdyn, so that it runs
+    without environment variables and set LIBOGCM to /tmp15/emlmd/libo
+
+>>> directory contents of 'aeronomars', 'grid' and 'filtrez' are simillar
+    to those in /u/emlmd/LMDZ.MARS.mixdyn
+
+>>> in bibio , only file mxva.F needed be upgraded
+
+>>> get phymars and dyn3d contents from /u/emlmd/LMDZ.MARS.mixdyn
+    (and remove all *old files)
+
+>>> check differences between dyn3d and /u/emlmd/LMDZ.MARS.170908/libf/dyn3d
+    and upgrade when necessary:
+    - removed 'netcdf.inc' file (has nothing to do there!)
+    - comgeom.h and comgeom.h : made fortran90 compliant
+    - control.h : made fortran90 compliant
+    - dynredem.F : more read/write controls + comments in english
+    - ini_archive.F : new soil/thermal inertia changes
+    - integrd.F : added additional information to output when crashing
+    - lect_start_archive.F : new soil/thermal inertia changes
+    - newstart.F : new soil/thermal inertia changes + comments in english
+    - start2archive.F : new soil/thermal inertia changes
+    - vanleer.F : removed inapropriate 'external' statement
+    - write_archive.F : enable writting a subterranean field
+
+>>> check differences between phymars and /u/emlmd/LMDZ.MARS.170908/libf/phymars
+    and upgrade when necessary:
+    New soil stuff:
+    - added comsoil.h
+    - iniwrite.F : new soil changes
+    - added iniwritesoil.F90 and writediagsoil.F90 for subterranean fields
+    - added interp_line.F (for subterranean grid interpolation)
+    - adapted phyetat0.F for subterranean temperature & inertia
+    - adapted physdem1.F to include new soil stuff
+    - physiq.F : added calls to writediagsoil 
+    - soil.F : new routine (fixed vertical grid + variable thermal inertia)
+    - added soil_settings.F (to read/initialize/interpolate soil properties)
+    - updated surfdat.h (since thermal inertia is now in comsoil.h)
+    - updated tabfi.F : include new soil properties
+    - updated testphys1d.F
+    - updated dimphys.h (set nsoil=18 as default)
+
+== 18/09/08 ==
+>>> add the possibility of easily switching to Tran radiative transfert
+    - updated aerdust.h.ocke97 (changed some variables name) so it can
+      replace aerdust.h (which is currently the same as aerdust.h.clan91).
+    - imported Tran's 'gfluxv.F' routine
+    - imported Trans' version of 'swr.F' routine, saved it as 'swr.F.toon'
+
+>>> Backup of 'old' Morcrette swr.F is 'swr.F.morc'
+    NB: to switch from one radiative transfer to the other, just copy
+    swr.F.morc or swr.F.toon to swr.F (and eventually 'touch swr.F' so that
+    makegcm recompiles swr.F)
+    No other dependencies (swr.F.toon uses 'gfluxv.F' and swr.F.morc uses
+    'dedd.F').
+
+>>> Changed the latter, so that users can switch from one to the other
+    - modified swr.F.toon to become swr_toon.F (and to include gfluxv.F)
+    - modified swr.F.morc to become swr_fouquart.F (and to include dedd.F)
+    - added a flag in callkeys.h, swrtype (parameter to be set/changed by
+      the user 1=Fouquart and 2=Toon)
+    - update readtesassim so that the coefficient by which opacity
+      is multiplied is set according to the 'swrtype' parameter
+
+== 25/09/08 ==
+>>> Implement the use of tracer-by-name in physics
+    - in phymars/tracer.h set 'noms' length to 20 (instead of 10)
+    - in phymars/callsedim2q.F and phymars/callsedim.F, use tracers by name
+    - in phymars/dustopacity.F, use tracers by name
+    - in phymars/vdifc.F, use tracers by name
+
+== 26/09/08 ==
+>>> Change implementation strategy (for now); don't move surface tracer around
+    i.e.: surface ice remains equivalent to qsurf(nqmx)=qsurf(i_h2o_vap)
+          and likewise for surface tendencies ...
+    - modified vdifc.F and callsedim.F back
+    - modified initracer.F (so that water names are h2o_vap & h2o_ice)
+    
+== 29/09/08 ==
+    - modified aeronomars/init_chimie_B (cosmetics)
+    - corrected aeronomars/moldiff.F internal routine tridag; changed
+      "pause" error messages to 'stop' messages
+    - modified phymars/watercloud.F to use tracers by name
+    - corrected aeronomars/molvis.F (undefined 'fac' and 'Akk' written to 
+       output at first call)
+    
+== 30/09/08 ==
+    - modified aeronomars/calchim.F to use tracers by name
+    - adapted aeronomars/photochemist_B.F to use tracers by name
+    - adapted aeronomars/chemtermos.F to use tracers by name
+    - adapted aeronomars/concentrations.F to use tracers by name
+    - corrected aeronomars/conduction.F (undefined 'Akk' written to output
+      at first call)
+    - adapted aeronomars/euvheat.F to use tracers by name
+    - adapted aeronomars/moldiff.F and moldiffcoeff.F to use tracers by name
+
+== 01/10/08 ==
+    - For more compatibility with LMDZ4; mimic reading a 'traceur.def' file
+      in the dynamics via a call to a routine 'iniadvtrac.F' and saving
+      tracers names in 'advtrac.h'
+     -> created 'iniadvtrac.F', 'advtrac.h' and modified gcm.F
+    - modified 'dynetat0.F' so that tracers are loaded from 'start.nc' by name
+    - modified 'dynredem.F' so that tracers are written to 'restart.nc'
+      by name
+    - modified 'initracer.F' tu use tracers by name
+
+== 02/10/08 ==
+    - removed use of 'nqchem_min' everywhere:
+      adapted 'euvheat.F','inifis.F','physiq.F'
+      (leave 'inichim.F' for later)
+    - updated 'phyetat0' and 'physdem1.F' to read/write surface tracers by name
+    - modify things so that surface water ice index is the same as
+      atmospheric water ice (except when running without water ice; then
+      simply set i_h2o_ice=i_h2o_vap).
+      NB: the easiest is to have global storage of tracer names/indexes in
+      tracer.h
+      => changed initracer.F & tracer.h to have global igcm_something indexes
+
+== 03/10/08 ==
+    - adaptations for surface ice index, modified files:
+      phyetat0.F : if there is a dynamical tracer 'h2o_vap' then load
+                   surface tracer called 'h2o_ice' instead
+      initracer.F : in 'old' tracer name case: move qsurf(nqmx)->qsurf(nqmx-1)
+                    and set i_h2o_ice=i_h2o_vap if iceparty=.false.
+      physdem1.F : if old tracer names: move qsurf(nqmx-1)->qsurf(nqmx)
+                   if iceparty=.false., write surface tracer 'h2o_ice'
+                   (and not 'h2o_vap') to file.
+      adapted vdifc.F, callsedim.F & watercloud.F & physiq.F so that surface
+      ice is now identified as qsurf(i_h2o_ice)
+    - updated aeronomars/perosat.F (cosmetics)
+
+== 06/10/08 ==
+    - modify newstart.F and lect_start_archive.F to use tracers by name
+== 07/10/08 ==
+    - adapted inichim_newstart.F (added qsurf to arguments)
+      and inichim_readcallphys.F
+== 08/10/08 ==
+    - implement reading traceur.def in dyn3d/iniadvtrac.F
+
+== 16/10/08==
+    -small change in inifis.F (only warn if too many tracers, compared
+     to the expected number, not stop).
+     - corrected bug in initracer.F
+== 21/10/08 ==
+    - modified newstart.F to load B.Diez subsurface ice maps.
+    - corrected small bug (uninitialized variable) in interp_horiz.F
+== 22/10/08 ==
+    - updated iniwritediagsoil.F so that thermal inertia is written to
+      diagsoil.nc
+== 31/10/08 ==
+    - changed xvik.F program so it works even if we don't have atmospheric
+     temperature at hand (then it uses a 10km reference scale height) and so
+     that it does surface pressure interpolation log-wise.
+== 03/11/08 ==
+    - modified physiq to compute (and output) co2 column.
+    - added improvement by Francois in newcondens.F about computing CO2
+      partial pressure. This behavior is turned on by setting internal logical
+      flag 'improved_ztcond' to '.true.' (and running with a co2 tracer)
+    - updated 'start2archive' to work with 'new' gcm output (soil, tracers ...)
+== 04/11/08 ==
+    - upgraded xvik program to look for temperature in 7th layer variable if
+     there is no global atmospheric temperature field at hand.
+== 05/11/08 ==
+    - more modifs to newcondens.F: added another internal flag 'bound_qco2' to
+     enforce (if set to .true.) that co2 mass mixing ratio remains bounded.
+== 07/11/08 ==
+    - corrected 'writediagfi' & 'writediagsoil' so that an error message is 
+      issued if called with a variable name which is too long.
+== 18/12/08 ==
+    - corrected bug in dyn3d 'addfi.F', (dimensions of local array p())
+== 23/02/09 ==
+    - modified "aeronomars/param_read.F" to do strictly fortran data
+     initialization (otherwise xlf compiler complains)
+    - changed a few '1.e-30' to '1.d-30' in aeronomars/photochemist_B.F
+     so that max functions has 2 doubles as arguments (otherwise xlf
+     compiler complains)
+
+==07/04/09 ==
+    -cosmetic changes/minor improvements in the handling of tracers in:
+     aeronomars/photochemist_B.F
+     aeronomars/perosat.F
+     aeronomoars/euvheat.F
+     aeronomars/moldiffcoeff.F
+     aeronomars/moldiff.F
+     aeronomars/cocentrations.F
+     aeronomars/chemtermos.F
+     aeronomars/calchim.F
+
+--> NB: still there are differences in outputs when order of tracers is changed
+
+== 09/04/09 ==
+>>> fixed problem in 'vdifc.F' which lead to different results when moving
+    tracers around.
+
+== 10/04/09 ==
+>>> corrected small bug in diagnostic outputs of 'watercloud.F' (tendencies were
+    not added to tracer values).
+
+== 21/04/09 ==
+>>> corrected small bug in "physdem1.F" about writing water ice surface tracer
+    to file
+
+== 07/05/09 ==
+>>> very minor correction (firstcall not set to true after first call
+    if no tracers) in convadj.F
+
+== 30/06/09 ==
+>>> Implement reading *def files with IOIPSL ersatz 'getin' function
+   - import "ioipsl_errioipsl.F90","ioipsl_getincom.F90","ioipsl_stringop.F90"
+     in bibio
+   - adapted 'dyn3d/defrun_new.F' to use "getin" function
+   - adapted 'phymars/inifis.F' to use "getin" function
+
+== 01/07/09 ==
+>>> Adapted 'create_make_gcm' so that the "use" in *.F files is identified and
+    corresponding dependencies included in the makefile rules.
+
+>>> Added the 3D scattering from aerosols by JB Madeleine:
+    - minor changes in aerave.F
+    - added the calls to aeropacity.F, and aeroptproperties.F in callradite.F
+    - changed the calls to lwu.F and swr.F in lwmain.F and swmain.F, respectively
+    - added 3D scattering properties in lwu.F and swr.F
+    - added the new aeroptproperties.F, aeropacity.F and suaer.F90 routines
+        (removed dustopacity.F)
+    - updated aeropacity.F with new tracer names
+    - changed the call to callradite.F in physiq.F, added the initialization 
+        of reffrad and nueffrad (aerosol effective radius and variance)
+    - removed all the lines relative to the old "activice" option, including
+        temperature variation due to latent heat release (now in comments)
+    - renamed nsize into naersize in watercloud.F, watersat.F and newsedim.F,
+        to avoid conflicts with another "nsize" variable in the radiative transfer
+    - added the statement of nuice in watercloud.F, which is the effective variance
+        of the log-normal distribution for ice
+    - updated yomaer.h and removed aerice.h (and corresponding "includes")
+
+== 02/07/09 ==
+>>> Adapted 'aeronomars/inichim_readcallphys.F' (called by newstart)
+     to use "getin" routine.
+    + minor correction in 'inifis.F' (close 'iradia.def' file)
+>>> Minor correction in 'dyn3d/dynetat0.F' and 'phymars/phyetat0.F'; do not
+    attempt to reindex tracers if none were found.
+
+>>> in 'deftank' added examples of 'traceur.def' files (traceur.def.co2 : 1
+    co2 tracer; traceur.def.watercycle : 2 traceurs, water vapour and water ice
+    tracer.def.chemistry : all 15 species)
+
+== 06/07/09 ==
+>>> Modified 'makegcm' and makegcm_g95' so that modules files are put 
+    with libraries (and not in current directory)
+
+==
+== WORK FOR GENERIC MODEL STARTS HERE
+== 
+    
+== 01/08/09 ==
+>>> Old Martian radiative transfer removed completely, new correlated-k
+    scheme implemented in its place. Central function is callcorrk.F.
+    Radiative properties are no longer stored in dimradmars.h, but in the two
+    files radinc_h.F90 and radcommon_h.F90. 3D aerosol scheme
+    incorporated into callcorrk.F. dustopacity.F renamed aeropacity.F
+    and substantially simplified. For now the option to include dust
+    as an aerosol has been removed.
+
+>>> newcondense.F replaced by condense_co2cloud.F90. This is basically
+    Francois' routine from the old model, adapted to work with the new
+    generalised tracer scheme.
+
+>>> Options added in physiq.F and tabfi.F to allow for planets with
+    varying orbital parameters, radii, gravity etc. For the moment we
+    select the planet using the variable 'planettype' in
+    callphys.def. This could probably be improved in the future.
+
+>>> Many new options added to callphys.def.
+
+    
+    
+    
+    
+== 25/11/2009 ==
+>>>> List of changes and modifications
+- modified watercloud.F: added sanity check (i.e. do we have a water tracer?)
+- modified dyn3d/dynetat0.F --> removed possibility of reindexing tracers
+- modified phyetat0.F --> removed possibility of reindexing tracers
+
+-- removed using a "co2ice" array to store surface CO2 ice
+  -> adapted surfini.F & physiq.F to use qsurf(:,igcm_co2_ice)
+     instead of co2ice(:)
+  -> modified initracer.F & tracer.h to properly initialize (and store)
+     a "co2_ice" tracer.
+  -> removed 'co2ice' from vdifc.F (it was not used there anyway)
+     and from phsdem1.F
+  -> removed possibility of calling 'newcondens' from physiq.F
+  -> cleaned up newstart.F, lect_start_archive.F, start2archive.F to not use
+  "co2ice" field but qsurf(igcm_co2_ice)
+
+-- adapted 'create_make_gcm' and 'makegcm' scripts so that we don't need
+   to have and (unused) 'aeronomars' directory around.
+ 
+-- shifted to reading traceur.def (dyn3d/iniadvtrac.F) in an Earth-LMDZ4-like
+   fashion:
+   first line == number of tracers
+   and then tracer name (1 per line; later we'll also add advection scheme type)
+-- NOTE BY RW: Here would be a good place to also note which tracer (if any) is
+   the 'variable gas' in the radiative transfer
+
+-- Made some changes in tabfi.F to let user change planet parameters
+   such as rotation rate, molar mass of atmosphere, ...
+   (NB: note however that we seem to lose dynamics/physics coherence ...
+    we should probably read these values from a planet.def file) 
+
+-- Changed condens_co2cloud.F : added a check for presence of CO2 gas and output
+   of corresponding tendency.
+
+
+== 15/12/2009 ==
+>>> Correlated-k radiative transfer now reads spectral bands and p-T
+    matrix values from ascii files; the code checks that the number of
+    bands and matrix elements in the files match those written in
+    radinc.F90 on the first call.
+
+>>> Water vapour tracer coupled to variable gas species in radiative
+    transfer; option also given to run with fixed relative humidity
+    profiles. 'Variable gas species' option added to callphys.def.
+
+>>> Surface albedo updated to be one band everywhere.
+
+>>> suaer_corrk.F90 modified to use different ep, omeg, g variables in
+    the visible and infrared. This is necessary because the number of
+    bands is, in general, different.
+
+>>> suaer_corrk.F90 has an option to accept Francois' new CO2 ice
+    values (and convert wvl to metres!!).
+
+>>> optci.F --> optci.F90 so that water vapour continuum subroutine
+    can be included.
+
+== 08/01/10 ==
+>>> Option to change pref for hybrid coordinates added to newstart.F.
+
+
+== 15/01/2010 ==
+>>> Upgraded newstart.F: added possibility to reset refrence surface pressure
+   "preff" (and pa)
+>>> tabfi.F: added possibility of changing value of "year_day"
+>>> cosmetic change in callphys.def : separate "universal" parameters
+    and planet-specific parameters (in a separate file, e.g. earlymars.def)
+    
+== 22/01/2010 ==
+==> call this version LMDZ.GENERIC
+>>> Some cleanup & upgrades:
+-- split parameters in callphys.def into generic stuff (stays in callphys.def)
+   and another more specific file (e.g. earlymars.def).
+-- added 'output_olr' key (in callkeys.h; read in physiq.F) to trigger
+   output of fluxes in ascii file 'olr.txt'
+-- removed (non-generic) 'kastprof' and 'nearcond' keys/options in physiq.F
+  (also removed file kastprof_fn.F)
+-- had to set 'fixh2ovap  =.false. in callcorrk.F to avoid
+   "out of range subscript" pb in callcorrk.F
+   ==> this should be improved / better controlled in the future
+-- updated newsedim.F to use "molrad, visc, avogado values from comcstfi.h
+   (and not local versions of these constants)
+-- fixed buggy -O option in makegcm (and makegcm_g95);
+
+== 22/02/2010 ==
+==> call this version LMDZ.GENERIC.v0.31
+-- rain.F, manabe.F and largescale.F subroutines added to water cycle
+-- several new toggles added to earlymars.def
+
+== 28/03/2010 ==
+==> call this version LMDZ.GENERIC.v0.4
+-- many changes for this version!
+-- radiative transfer --
+   A new system was implemented that automatically reads the p, T, g,
+   Q and band values from files. The dataset required is now specified
+   in callphys.def. We still need to edit radinc_h when the corrk array
+   sizes change - think about improving this in the future.
+-- water cycle --
+   A watercommon_h mod file was created, several files were renamed
+   and moist convection and precipitation subroutines were added.
+   Still needs some testing!
+-- OLR --
+   Two new functions were added: one to produce .nc files of the OLR
+   by band, and the other to save the upgoing radiation by band in 1D
+   as a .txt file. 
+-- general structure --
+   tabfi.F, newstart.F etc. cleaned up + it was checked that they pass
+   variables correctly. Several new options added to run.def for 1D,
+   in order to allow truly arbitrary planet simulations. The
+   'planettype' option has been removed as it screwed things up completely.
+-- energy conservation --
+   I found that the planckir function in the radiative transfer did not
+   always produce values that summed to sigma T^4. A new test was implemented
+   to check for this problem and the standard band widths in the IR
+   were increased.
+
+== 31/03/2010 ==
+==> call this version LMDZ.GENERIC.v0.5
+-- OLR --
+   The .nc functions were implemented and tested. It was necessary to add
+   new functions 'writediagspec.F' and 'iniwrite_spec.F'.
+-- CO2 condensation --
+   In 1D we now exit automatically if CO2 is condensing on the
+   surface.
+-- G1D --
+   We can now choose at the beginning of physiq.F, using saveG1D, how
+   many times we want to save per day in 1D (rather than every single
+   time that physiq is called).
+-- water cycle --
+   I corrected a nasty bug in callcorrk involving varfixed, real*8 and
+   epsi. I corrected a simple bug in the writing of qsurf in g1d.dat.
+   rain.F has been tested and the algorithm for precipitation evaporation
+   modified to that written in the manual of Larent Li. Cloud fraction
+   variable is now included. activice and iceparty are gone, ~replaced
+   by watercond and waterrain.
+-- orbit --
+   nres and tlocked were added as basic options to callphys.def
+-- radiative transfer --
+   I added error checking for out-of-bounds temperature in
+   callcorrk.F. I added a new file calc_rayleigh.F90 to calculate
+   Rayleigh scattering using a weighted mean, as opposed to simply the
+   midpoint band values. Band discretisation is now even more
+   automated than before: the coefficients are stored in directories
+   like /earth/32x36/, and we can compile the GCM like this:
+   makegcm -d 32x24x20 -b 32x36 -p std gcm.
+   A bug was fixed involving emissivity not being properly passed from
+   newstart.e to the main part of the code.
+   Stellar spectra are now calculated automatically for any range of
+   bands from high resolution data (originally from the VPL website).
+-- vertical discretisation --
+   I corrected a bug in testphys1d that used a fixed value of
+   temperature to compute the altitude levels in the model. Now we use
+   the scale height from z2sig.def instead. Values of preff and pa are
+   no longer defined in testphys1d (they're not needed).
+-- Non-ideal gases --
+   I have replaced cpp in many places with cpp_3D in physiq. This is a
+   major change, but there are enough cases where it will be useful to
+   make it worthwhile in the universal code. I have done the same with rcp.
+
+== 10/10/2010 ==
+==> call this version LMDZ.GENERIC.v0.6
+-- startup --
+   We now check water tracers exist in newstart.F before all watery initialisation options.
+   Added an option 'autozlevs' to run.def (and logic.h). When true this recalculates the scale
+   height in z2sig.def in order to get the same minimum pressure for any resolution.
+   Currently, this is only useful for one-d simulations.
+   Pressure is now distributed better in newstart.F. There was a bug before when the global mean of phi
+   was not equal to zero and the surface pressure was changed with topography still present.
+   In initracer, we no longer automatically set h2o_vap=h2o_ice.   
+
+-- general --
+   periheli, apheli --> periastr, apoastr. Note this necessitates a change in start_planet too.
+   testphys1d.F --> rcm1d.F
+   physiq.F, callcorrk.F upgraded to Fortran 90 to remove evil zerophys.
+   I cleaned up the method of displaying energy balance and temperature range in the model a bit.
+   Pure H2 atmospheres are now permitted, although the code is _untested_. Rayleigh scattering,
+   specific heat capacities and molar masses are varied, and the H2-H2 collision-induced data 
+   of Grushka et al. is used for the radiative transfer.
+
+-- boundary layer --
+   An improved version of vdifc.F has been created that includes the latent heat effect of water vapor,
+   following the method used in 'clmain' in the LMDZ terrestrial model.
+
+-- water cycle --
+   Benjamin's improvements have been added, namely the hydrology, and reevaporation.
+   Variable cloud fractions are allowed, or a global fixed value may be chosen
+   for use in aeropacity. Surface wetness (beta) is now calculated in a simple way, and
+   outputed as a diagnostic, along with the atmospheric relative humidity.
+  
+   mol/mol to kg/kg bug in callcorrk corrected.
+
+-- radiative transfer --
+   A major bug in gfluxv.F was corrected. It involved BSURF, the radiation reflected upwards from 
+   the ground.
+   In aeropacity, we now set the cloud opacity in the top layer of the atmosphere to zero. This solves
+   an instability problem that was occurring when CO2 clouds formed.
+   Dust is back! Only fixed profiles allowed for now. It is assigned "naerkind=3" in aeropacity.F90.
+   If 'CLFvarying' is enabled, the corrk subroutine is now called twice per timestep - once for clear
+   skies and once for cloudy. This slows things down but is effective for Earth-like simulations.
+   An optional Newtonian cooling scheme has been implemented that can replace the correlated-k method
+   for dynamical tests etc. It is pretty experimental and has not been extensively tested.
+
+-- Dynamics --
+   callgroupeun in gcm.F has been set to FALSE, as it does not conserve tracers.
+   The coefficient facup has been set to 1 in inidissip.F. We may need to mess
+   with this later if it makes the model too unstable.
+
+== 1/08/2011 ==
+==> call this version LMDZ.GENERIC.v0.7
+
+   Main change: a new file 'gases.def' now required at startup. This tells us which gases are in
+   the planet's atmosphere. It is used to calculate fundamental quantities like cpp and mugaz.
+   A check is made against the radiative transfer data to make sure they correspond.
+
+   Code has been tested successfully using the 'gfortran compiler'.
+
+-- startup --
+   a bug involving tsoil interpolation in lect_start_archive.F was corrected.   
+
+-- aerosols --
+   gauss integration number 5-->10 in aeroptproperties.F90
+
+-- water cycle --
+   Big fat bug in rain.F90 corrected. The routine internally updated the temperature 
+   with new tendencies before it was supposed to happen!
+   Bug in oborealis where phi not properly updated was corrected.
+   Improvements to hydrol.F90: zdtsurf_hyd --> pdtsurf_hyd
+   A 'sourceevol' option was added (accessed in callphys.def) that allows us to track the
+   evolution of the surface distribution over time.
+   Another bug in rain corrected involving evaporation - it was heating the atmosphere
+   rather than cooling it...
+
+-- convection --
+   I found a bug in convadj.F that breaks tracer conservation when convection stops at one layer 
+   and immediately restarts in the next one.
+
+-- diagnostics --
+   Some bugs corrected in the computation of 3D averages for the H2O / energy conservation 
+   diagnostics.
+
+-- radiative transfer --
+   A bug involving continuum opacities (variable DCONT) was corrected in optci.F90 and optcv.F0.
+   H2-H2 warming now in theory reliable and correct (60-1000 K).
+   A bug involving the definition of the Planck function boundaries was corrected in sfluxi.F90
+   and gfluxi.F.
+
+== 21/10/2011 == EM
+- added FF's upgrade of writediagfi. Now, if at runtime there is a diagfi.def
+  file, it should contain the list of variables (1 per line) than will be put
+  in the diagfi.nc file. If there is no diagfi.def file, then all variables
+  are put in the diagfi.nc file (as was the case before).
+
+=== 10/11/2011 == EM
+- Updated the makegcm(s) so that default behaviour is to set LMDGCM env variable
+  to be the directory in which the makegcm script is. Updated the makegcm_*
+  to use "SOURCE" to identify code and be compatible with latest
+  'create_make_gcm'.
+ 
+== 10/11/2011 == EM
+- Upgrade: The location of the 'datagcm' directory can now be given in the
+  callphys.def file ( datadir = /absolute/path/to/datagcm ). Changed
+  "datafile.h" into a F90 module "datafile_mod.F90" and spread this change
+  to all routines that used to use "datafile.h".
+
+== 10/11/2011 == EM
+- Upgrade of the 'create_make_gcm' script: objects are removed from the
+  libraries before compilation, which enforces that the gcm will fail to
+  compile if any routine failed to compile.
+
+== 12/12/2011 == AS
+- Use of allocatable arrays to set corrk stuff through reading *.dat files, without the need to change radinc_h manually.
+- Allocation is done in sugas_corrk which is within firstcall loop in callcorrk.
+- Note that N_LGAUSS is still a parameter. It is not supposed to change much.
+- Compiles fine. Tested with debugging options through pgdbg. Runs fine. Exact same results in Early Mars test case. 
+
+Modified files:
+M              469   libf/phystd/physiq.F90
+M              469   libf/phystd/sugas_corrk.F90
+M              469   libf/phystd/callcorrk.F90
+M              469   libf/phystd/radinc_h.F90
+M              469   libf/phystd/radcommon_h.F90
+
+== 13/12/2011 == AS
+- Same spirit as previous commit, but for ngasmx which is now read in gases.def -- before arrays w/ dim ngasmx are allocated dynamically
+- Allocation is done in su_gases.F90 which is called in inifis
+- Outside su_gases.F90, very few modifications to the code : the new module "gases_h.F90" simply replaces the old common "gases.h" !
+- Compiles fine. Tested with debugging options through pgdbg. Runs fine. Exact same results in Early Mars test case.
+
+== 20/12/2011 == JL + AS
+- Allocatable gastype in sugas_corrk instead of hardcoded (it was a problem for more than 4 gases!)
+
+== 13/02/2012 == JL + AS
+- All outputs are now in netCDF format. Even in 1D (No more G1D)
+- Clean up of the call to callcorrk when CLFvarying=true
+- Corrects a bug in writediagspecIR/VI. Output are now in W/m2/cm-1 as a function of the wavenumber in cm-1
+- Enable writediagspecIR/V to work in the CLFvarying=true case (output now done in Physiq after writediagfi)
+- Add a simple treatment for the supersaturation of CO2 (see forget et al 2012)
+- corrects a small bug when no clouds are present in aeropacity
+
+== 16/02/2012 == JL + EM
+- Mesh area now present in 1d diag files.
+- Spectral Bandwidth included in the diagspec files
+- Correction of a initialzation bug on day_step and ecritphy in rcm1d
+
+== 17/02/2012 == RW
+- qsurf bug in variable species rad. tran. removed
+- line to update kappa in newstart.F added - necessary to synchronise dynamics and physics
+- three obsolete files removed from dyn3d/ directory
+- calc_cpp_mugaz --> check_cpp_mugaz, with override option in callphys.def
+- kcm1d no longer consistent with new code, but I haven't updated as I'm still working on it
+  and as far as I know noone else uses it. If that changes let me know.
+
+== 27/02/2012 == AS
+- Temperature grid for Planck calculations can now be refined through the parameter NTfac in radinc_h. 
+  Default is NTfac = 1.0D-1, i.e. Delta T = 0.1 K
+
+== 16/03/2012 == JL
+- Removed cpp3D and nonideal stuff.
+
+== 19/03/2012 == EM
+Some cleanup and bug fixing:
+- "cloudfrac" was not well written to restartfi (wrong size).
+- missing save attribute for "reffrad" in physiq.F90.
+- cleanup recomputation of surface pressure in newstart and change loop order
+  in interp_horiz (which "fixes" an odd behaviour which fills some arrays with
+  zeros, but only when using some versions of ifort!)
+
+== 19/03/2012 == AS
+- Cleaned rcm1d.F and made it truly generic by asking for planetary constants without any default values.
+- Settings are now needed in a rcm1d.def file. Unbeknown to the user, we create a minimal run.def file, read parameters, then remove this dummy run.def.
+- Introduced a keyword force_cpp if the user wants to give values for cpp and mugaz in def files.
+
+== 19/03/2012 == AS+FF
+- Introduced global1d in callcorrk so that global (using sza) or local (using latitude) 1D simulations can be carried out.
+- Converted all astronomical distances in AU instead of Mkm.
+- This might cause problems with old start files. So added a test in iniorbit. A quite dirty test, but that'll do the job.
+
+== 22/03/2012 == JL
+- New turbulent diffusion scheme solving "most" energy conservation problems:
+     - Turbulent energy created by buoyancy effects is now dissipated back into enthalpy
+     - the scheme is now written in an enthalpy conservative way
+- Turbulent diffusion now treated in routine turbdiff (in F90).
+- Temporarily, for comparison, the old vdifc can be used
+      by setting UseTurbDiff=.false. in physiq.F90
+- The sensible heat flux is now an output
+- Corrected evaporation at the surface when all the surface water is evaporated (JL+BC).
+- Added new energy conservation diagnostic variables and output
+
+== 26/03/2012 == JL
+- Added double gray case (if graybody=true in callphys.def):
+   - opacities are set to a constant value in sugas_corrk.
+   - the values are kappa_IR m^2/kg in the infrared (to be read in callphys.def)
+                    kappa_VI m^2/kg in the visible (to be read in callphys.def)
+- Cleaned continuum part in optc*
+- Added .def files for a typical 1d earth case in deftank (dry case for the moment)
+- Corrects a bug on potential temperature calculation in physic 
+
+== 27/03/2012 == JL
+- Corrects the computation of planck function at the surface in sfluxi
+     so that its integral is equal to sigma Tsurf^4.
+- This ensure that no flux is lost due to:
+     -truncation of the planck function at high/low wavenumber
+     -numerical error during first spectral computation of the planck function
+     -discrepancy between Tsurf and NTS/NTfac in sfluxi
+- OLR now equal to LW net heating/cooling at equilibrium!
+- As much as possible, only the value of the stephan boltzmann constant defined in racommon_h (and the
+corresponding variable, sigma) should be used. Now done in physics, vdifc and turbdiff.
+  
+== 16/04/2012 == JL
+- Added consistency checks for calculations including water and global1d+diurnal.
+- Corrected small bugs in precipitation scheme
+
+== 04/05/2012 == JL
+- Correction a huge bug in newstart: rcp and cpp can now be changed in start.nc files and are the same as in startfi.nc; 
+       Even when starting from start and startfi files.
+   - rcp, cpp and mugaz can now be computed using gases.def in newstart
+- Correction of a bug arising in gcm.F when the solar days are long (thanks Melanie V.)
+- Corrected the temperature used to differentiate sublimation and evaporation in watersat_grad
+- Minor name changes in watercommon
+- Better physical parametrization of the effective radius of liquid and icy water cloud particles in callcorrk
+       (for radfixed=true)
+- Added consistency check in inifis
+- Moved 1d water initialization from physiqu to rcm1d
+- All enertests in physiq written in a matricial (F90) way. The rest of physiqu should follow soon
+
+== 25/05/2012 == EM
+- Significant update on how the number of scatterers is managed:
+  Instead of having to manualy change 'nearkind' in radinc_h.F90, the
+  number of scatterers must now be set when compiling, using makegcm
+  "makegcm -s 1" for one scatterer or "makegcm -s 2" for two (e.g. dust
+  and water ice), default behaviour (ie not specifying -s #) is -s 1
+  Modified phystd/radinc_h.F90 , added directory phystd/scatterers
+  with script make_scatterers , and adapted makegcm* scripts.
+
+== 06/06/2012 == EM
+- Corrected the polar mesh surface area which was wrong in the physics (changes
+  in phyetat0.F, calfis.F and newstart.F)
+- Some cleanup in newstart.F (removed some obsolete "Mars" options: mons_ice,..)
+  and also added option "q=profile" to initialize a tracer with a profile
+  read from file "profile_tracername"
+
+== 29/06/2012 == EM
+- Some cleanup in start2archive.F and ini_archive.F to get them to work for
+  the generic model (removed some "Martian" specificities).
+  
+== 17/07/2012 == JL for LK
+- Generalization of aerosol scheme:
+    - any number of aerosols can be used and id numbers are determined consistently by the code. Aerosol order
+    not important anymore.
+    - addition of a module with the id numbers for aerosols (aerosol_mod.F90).
+    - initialization of aerosols id numbers in iniaerosol.F90 
+    - compile with -s x where x *must* be equal to the number of aerosols turned on in callphys.def (either by a
+    flag or by dusttau>0 for dust).
+      => may have to erase object files when compiling with s option for the first time.
+- For no aerosols, run with aeroco2=.true. and aerofixco2=.true (the default distribution for fixed co2
+aerosols is 1.e-9; can be changed in aeropacity).
+- If starting from an old start file, recreate start file with the q=0 option in newstart.e.
+- update callphys.def with aeroXXX and aerofixXXX options (only XXX=co2,h2o supported for
+now). Dust is activated by setting dusttau>0. See the early mars case in deftank. 
+- To add other aerosols, see Laura Kerber.
+
+== 18/07/2012 == JL
+- New water cycle scheme:
+   - largescale now in F90. Robustness increased by i) including evap inside largescale ii) computing the 
+        condensed water amount iteratively
+   - same improvements in moistadj.
+   - Water thermodynamical data and saturation curves centralized in module watercommn_h
+       - The saturation curves used are now Tetens formula as they are analyticaly inversible (Ts(P)-> Ps(T)).
+          New saturation curve yields very good agreement with the former one.
+       - Saturation curves are now generalized for arbitrary water amount (not just q<<1)
+       - The old watersat should be removed soon.
+   - The effect of water vapor on total (surface) pressure can be taken into account by setting 
+      mass_redistrib=.true. in callphys.def (routine mass_redistribution inspired from co2_condense in martian
+      model but with a different scheme as many routines evaporate/condense water vapor).
+- New cloud and precipitation scheme (JL + BC):
+   - The default recovery assumption for computing the total cloud fraction has been changed (total random gave too
+      large cloud fractions). See totalcloudfrac.F90 for details and to change this.
+   - Totalcloudfraction now set the total cloud fraction to the fraction of the
+      optically thickest cloud and totalcloudfrac is thus called in aeropacity.
+   - Only the total cloud fraction is used to compute optical depth in aeropacity (no more effective 
+      optical depth with exponential formula).
+   - 4 precipitation schemes are now available (see rain.F90 for details). The choice can be made using precip_scheme
+      in callphys.def. Usage of the more physically based model of Boucher et al 95 (precip_scheme=4) is recommended.
+      default behavior is set to the former "simple scheme" (precip_scheme=1).
+   - See rain.f90 to determine the parameter to be defined in callphys.def as a function of the precipitation scheme used.
+- Physiq.F90 now written in a matricial (more F90) way.
+- Radii (H2O and CO2 cloud particles, aerosols, duts, ...) calculations now centralized in module radii_mod.F90 
+   and work with the new aerosol scheme implemented by Laura K. Some inconsistency may remain in callsedim.
+- Corrected gray gas mode. The use of kappa_VI or kappa_IR far a given band is now based on its wavenumber independently of
+   SW and LW calculations 
+   
+Implementation compiled with ifort and pgf90.
+gcm.e runs in Earth and Early Mars case with CO2 and H2O cycle + dust. 
+
+== 19/07/2012 == JL
+- Corrected precipitation evaporation scheme + snow fall (JL+BC)
+- Commented some unecessary writediagfi calls that where used for test.
+
+== 24/07/2012 == JL
+- Correction of a bug in turbulent diffusion (turbdiff.F90)
+   => This solves a water conservation problem arising when the code tries to
+   evaporate over dry land.
+
+== 26/07/2012 == AS
+- Bug fix in physiq : the size of OLR_nu is L_NSPECTI and not L_NSPECTV
+- A more robust aerosol_mod + iniaerosol : problems with ifort+parallel solved, while still OK with other compilers and seq runs.
+
+== 05/09/2012 == JL
+- Correction of the calculation of the solar longitude in tlocked case.
+    -Can now handle any prograde resonance with nres=omega_rot/omega_orb.
+    -Sun now goes westward for the standard 2:1 case, as expected.
+- In the gray case, the separation between kappa_IR and VI is now set by 
+    wave number, independently of the usual IR/VISIBLE calculation separation.
+    i.e. kappa_IR can be used in the calculation of the downward stellar flux
+      if the wavenumber in the band is low enough and vice versa.
+- In ave_stelspec, stellar flux averaging has been generalized to incorporate
+    very red/blue stellar spectra (great care must however be taken of the band
+    limit used for the corralated k distributions).
+     -Brown dwarf spectra from Allard et al. have been added.
+     -Any Black body temperature can now be used.
+
+== 19/09/2012 == JL
+- Correction in largescale to improve robustness when large water vapor amount
+- Correction in soil_setting to allow change of the number of subsurface layers
+
+== 19/09/2012 == AS
+
+(Sorry for long text but this is a quite major commit)
+
+Paving the path for parallel computations. And moving towards a more flexible code.
+
+Automatic allocation is used within all routines in phystd. No further mention to ngridmx and nqmx.
+
+1. ngridmx and nqmx are still used in LMDZ.GENERIC in the dyn3d part
+2. if the LMDZ4/LMDZ5 dynamical core is used, there is no more fixed dimensions ngridmx and nqmx
+   --> a fully flexible parallel implementation is now possible (e.g. no need to recompile when changing numbers of processors)
+
+The important stuff :
+- Compilation checked with ifort. OK with and without debug mode. No errors.
+  Checked for: gcm, newstart, rcm1d, kcm1d
+- RUN GCM: Running an Earth test case. Comparison with previous revision
+  --> debug mode : perfect match. bit by bit (diff command). checked with plots
+  --> O1 mode : close match (checked with plots)
+  --> O2 mode : sometimes up to 0.5 K departure.... 
+  BUT in this new version O2 and O1 are quite close while in previous version O1 and O2 differed by about, well, typically 0.5 K
+  (pictures available on request)
+- RUN NEWSTART : perfect match (bit-by-bit) in either debug or normal mode.
+- RUN RCM1D : perfect match in normal mode.
+- RUN KCM1D : not tested (I don't know what is the use of kcm1d)
+
+List of main changes :
+- Additional arguments to some subroutines (ngrid and nq)
+- F77 include strategy is obsolete and replaced by F90 module strategy
+  In this new strategy arrays are allocatable and allocated once at first use
+  This has to be done for all common featuring arrays defined with ngridmx or nqmx
+    surfdat.h >> surfdat_h.F90
+    tracer.h >> tracer_h.F90
+    comsaison.h >> comsaison_h.F90
+    comgeomfi.h >> comgeomfi_h.F90   
+    comsoil.h >> comsoil_h.F90
+    comdiurn.h >> comdiurn_h.F90
+    fisice.h >> DELETED. was not used. probably a fossil.
+    watercap.h >> DELETED. variable put in surfdat_h.F90
+- F77 'save' strategy is obsolete and replaced by F90 'allocatable save' strategy
+  (see previous point and e.g. new version of physiq.F90)
+- Suppressing any mention to advtrac.h which is a common in the dynamics and needs nqmx
+  This was easily solved by adding an argument with tracer names, coming from the dynamics
+  This is probably not a definitive solution, 
+  ... but this allows for generic physics to work easily with either LMDZ.GENERIC or LMDZ dynamical cores
+- Removing consistency tests between nq and nqmx ; and ngrid and ngridmx. No use now!
+- Adaptation of rcm1d, kcm1d, newstart given above-mentioned changes
+
+A note on phyetat0 and soil_setting:
+- Now written so that a slice of horizontal size 'ngrid' starting at grid point 'cursor' is read in startfi.nc
+  'cursor' is defined in dimphys.h and initialized by inifis (or in newstart)
+  this is useful for parallel computations. 
+  default behavior is the usual one : sequential runs, cursor is 1, size ngrid is the whole global domain
+
+A note on an additional change : 
+- nueffrad is now an argument to callcorrk as is the case for reffrad
+  both are saved in physiq
+  this is for consistency and lisibility (previously nueffrad was saved in callcorrk)
+  ... but there is a call to a function which modifies nueffrad in physiq
+  ... previously this was not modifying nueffrad (although it was quite cumbersome to detect this) 
+  ... to be conservative I kept this behaviour and highlighted it with an array nueffrad_dummy
+  ... I added a comment because someone might want to change this
+
+== 20/09/2012 == AS
+A more robust way to count lines in setspi and setspv. 
+bandlen.txt file is no longer used. This was causing problems with MPI computations.
+
+== 06/11/2012 == EM
+- Fixed bug in disvert: pseudo-altitude pseudoalt() should be computed using
+  the scale height H provided in "z2sig.def" (and not 10.0).
+
+== 10/11/2012 and 23/11/2012 == AS
+- Corrected problems with allocated arrays in start2archive and newstart since the 19/09/2012 major commit
+- Modified those programs (and iniadvtrac) so that they can be used when compiling with -t 0
+
+== 20/12/2012 == EM
+- Fixed sedimentation issue: ensure in callsedim that the correct radii are 
+  provided to newsedim and also that the updated temperature and tracer
+  mixing ratios are used to compute sedimentation.
+- Updated the way aerosol radii are considered and used; routines in radii_mod
+  (h2o_reffrad, co2_reffrad, etc.) only handle a single aerosol. The idea here
+  is that these can be called from anywhere and that the caller doesn't need to
+  have the full (naerkind size) array of aerosol radii.
+- cleanup (addition of intent(..) to routine arguments) in various routines
+
+== 10/01/2013 == AS
+- Fixed an allocating bug which arises from previous modifications 
+  owing to the double use of callcorrk with CLF_varying
+- Fixed a small bug in a diagnostic in the end of calc_rayleigh. Some picky compilers complain.
+- Fixed a small bug with the array noms which is not allocated when tracer is false. But still need in physdem1.
+
+== 10/01/2013 == AS
+Added calls to FH subroutines to output physical fields in parallel. This is under precompiling flags CPP_PARA.
+This allows for LMDZ.UNIVERSAL users to use writediagfi with parallel computations.
+These lines are not compiled by casual users of LMDZ.GENERIC (or users of LMDZ.UNIVERSAL in sequential mode).
+
+== 23/01/2013 == JL
+- Correction in largescale. a rneb factor was forgotten
+- Added some spectra in ave_stelpec
+- Corrected reevaporation in rain. Now conserve water better
+
+== 24/01/2013 == AS + JL
+A more robust way to refer to gas type. 
+- Gas names with an arbitrary number of characters (<20) can be used
+  This is good for C2H2, C2H6, H2SO4, C17H21NO4, etc...
+  !!! Remember this must be compliant with Q.dat in corrk_data !!!
+- igas_... labels are assigned once for all in su_gases 
+  Then using igas_... everywhere instead of gnom (except for kcm stuff)
+- Users can still use e.g. H2_ but H2 also works
+- Simplified condense_cloud so that igas_CO2 is used directly
+
+== 09/02/2013 == AS
+- Optimized calculations for continuum (done for H2 and He, to be done for others)
+      - new common bilinear interpolation routine (bilinearbig)
+      - optimization: only one calculation is actually needed
+                      to find indexes of wavelength for bilinear interpolation
+                      ... because this will not change with level and integration step!
+      - optimization: use while loop in bilinearbig
+      - completely similar results obtained (test case for a gas giant, many simulated days)
+  NB: those changes really improve gcm speed (factor 2.2 for whole model!)
+      continuum was very expensive, now very cheap
+      --> e.g. 1 day, 25 dyn ts, 5 phys ts
+      --> before: 243 seconds (including 120 seconds for continuum bilinear interpolation)
+      --> after: 108 seconds
+- Corrected a bug: Continuum in inifis instead of continuum
+    ... until now, most users (unbeknownst to them) were running with the continuum by default!
+- Cosmetic changes in optcv (mostly spaces and line breaks) 
+    ... so that comparisons with optci are easy e.g. through vimdiff
+    
+== 11/02/2013 == JL
+- Updated moist convection scheme to handle situations with a large water vapor content 
+- Added a keyword to enable ocean runoff in callphys.def (activerunoff)
+
+== 12/02/2013 == JL
+- Follows previous commit by Aymeric about bilinear interpolations:
+   - Extended to all existing continua
+   - generalized bilinearbig to work for various size inputs
+- because N2 and H2O continua databases are smaller, improvement around 15% for
+an earth case.
+ 
+== 25/02/2013 == EM
+- added "-fp-model precise" option when compiling with ifort (fixes unexplained
+  mass loss of tracer in the dynamics)
+  
+== 13/03/2013 == AS + EM
+- corrected a bug in bilinearbig (found with debug mode)
+  not harmful but possible -1 index at first call
+
+== 18/03/2013 == EM
+- removed the "-static" ifort compilation option (problematic on Gnome cluster)
+  and added some additional debug options
+- fixed bug in newstart about initialization of albedo and thermal inertia.
+
+== 28/03/2013 == JL
+- optimization of optci and optcv routines. 15to 25% gain on these routines.
+     around 10% on the whole code with 1 scatterer.
+     - No changes on output (byte to byte) 
+- corrected bug in gray case in callcorrk. 
+- added profiling option in makegcm_ifort. See the file for details
+- changed capcal back to default in physics
+
+== 01/05/2013 == AS + JL
+- added possibility to remove surface 
+  (particularly exchanges heat+momentum exchanges between surface and atmosphere)
+- added possibility to add an internal heat flux
+
+== 10/05/2013 == EM
+- moved the 'makbands' script from "grid" to (more appropriate) "phystd/bands"
+  subdirectory, and consequently adapted the makegcm_* scripts
+
+== 15/05/2013 == JL
+- correction in radiative scheme to enforce double precision
+- corrects calculation of ISR
+
+== 22/05/2013 == EM
+- made all outputs (stats.nc,diag*nc files) compatible with running in parallel
+  (MPI mode only)
+
+== 11/06/2013 == JL+EM
+- User manual (+ sources) added in DOC.
+
+== 12/06/2013 == EM
+- Moved "newstart" (and related "lect_start_archive.F") to phystd directory
+- Adapted makegcm_* scripts to enable compiling main prog from physics
+- Added in newstart the possibility to not read in any surface.nc file
+  (when loading a start_archive) with keyword "none" (instead of surface
+  file name)
+- Some general cleanup:
+  - in bibio: removed unused lmdstd.h readstd.F writestd.F mywrite.F 
+              readcoord.F scatter.F gather.F ini36.F from36.F to36.F
+              lnblnk.F (F90 len_trim() should be used instead)
+  - in dyn3d: removed unused inigrads.F wrgrads.F gradsdef.h
+              xvik.F (specific to current Mars)
+
+== 14/06/2013 == EM
+- Some minor changes so that gcm compiles with gfortran:
+  - Added option to compile "long lines" (>132 characters) in makegcm_gfortran
+  - Removed use of isnan() in physiq.F90 (it is not a standard function)
+  - Avoid possible underflow of psat in watercommon_h.F90
+  - Adapted the checks on the *IR and *VI band files to be more strict
+
+== 17/06/2013 == EM
+- Some more cleanup in dynamics:
+ - Moved "start2archive" (and auxilliary routines) to phystd
+ - removed unused (obsolete) testharm.F , para_netcdf.h , readhead_NC.F ,
+   angtot.h from dyn3d
+ - removed obsolete addit.F (and change corresponding lines in gcm)
+ - remove unused "description.h" (and many places where it was "included")
+
+== 21/06/2013 == AS
+- Added possibility to initialize temperature from a rcm1d profile (t=profile)
+- Added output for Ls in diagfi
+
+== 28/06/2013 == JL
+- bug fix in setspi & setspv : counters must be initialized in routine in
+  case of multiple calls
+
+== 02/07/2013 == EM
+- some cleanup: ismax and ismin were defined in multiple places...
+
+== 19/07/2013 == EM
+- update the sponge layer: trun it into a module and (more important)
+  compute the sponge quenching analytically rather than via Forward Euler
+  approximation.
+
+== 07/08/2013 == JL
+- Water cycle in double precision (largescale+moistadj)
+- Improved wate rayleigh.
+- First step for rayleigh with variable species. Now, just need to change optcv.
+- changed some interpolation indices in callcorrk to limit dependency of OLR on the number of layers
+
+== 05/12/2013 == JL
+- corrected sugascorrk to work in the two band gray aproximation with -b 1x1 and NGAUSS=2
+
+== 03/04/2014 == EM
+Major cleanup, in order to ease the use of LMDZ.GENERIC with (parallel) dynamics
+in LMDZ.COMMON: (NB: this will break LMDZ.UNIVERSAL, which should be thrashed
+in the near future)
+- Updated makegcm_* scripts (and makdim) and added the "-full" (to enforce
+  full recomputation of the model) option
+- In dyn3d: converted control.h to module control_mod.F90 and converted
+  iniadvtrac.F to module infotrac.F90
+- Added module mod_const_mpi.F90 in dyn3d (not used in serial mode)
+- Rearanged input/outputs routines everywhere to handle serial/MPI cases.
+  physdem.F => phyredem.F90 , phyetat0.F => phyetat0.F90 ; all read/write
+  routines for startfi files are gathered in module iostart.F90
+- added parallelism related routines init_phys_lmdz.F90, comgeomphy.F90,
+  dimphy.F90, iniphysiq.F90, mod_grid_phy_lmdz.F90, mod_phys_lmdz_mpi_data.F90,
+  mod_phys_lmdz_mpi_transfert.F90, mod_phys_lmdz_omp_data.F90,
+  mod_phys_lmdz_omp_transfert.F90, mod_phys_lmdz_para.F90,
+  mod_phys_lmdz_transfert_para.F90 in phymars
+  and mod_const_mpi.F90 in dyn3d (for compliance with parallelism)
+- added created generic routines 'planetwide_maxval' and 'planetwide_minval',
+  in module "planetwide_mod", that enable obtaining the max and min of a field
+  over the whole planet. This should be further imroved with computation of
+  means (possibly area weighed), etc.
+
+== 05/06/2014 == EM
+Bug fixes:
+- hice() in physiq.F90 must be a saved array.
+- bad use of min/max on arrays in h2o_cloudrad (radii_mod.F90) which actually
+  ended up setting all array elements to the same value.
+And some cosmetic cleanup in rain.F90, vdif_kc.F and turbdiff.F90
+
+== 10/07/2014 == EM
+Some cleanup to simplify dynamics/physics interactions by getting rid 
+of dimphys.h (i.e. the nlayermx parameter) and minimizing use of
+dimension.h in the physics.
+
+== 11/07/2014 == EM
+- Changed the variable passed from LMDZ.GENERIC dynamics to physics:
+it is now a mass flux (kg/s) which is then converted to a vertical
+velocity (m/s) in the physics. This is to be consistent with what is
+done in LMDZ.COMMON.
+
+== 18/08/2014 == JL
+- fixed variable type declaration bug in ave_stelspec
+- corrected insolation calculation in locked and inclined case (proper calculation of sub solar longitude and declination)
+- in the ring shadow calculation, temporary variables for the orbbital parameters are now used (we want the declin and RA output at the same time w and wo rings)
+
+== 29/09/2014 == EM
+- Added missing allocation in soil_settings, needed when changing number of
+  soil layers.
+
+== 04/03/2015 == EM
+- Some code cleanup: turning comcstfi.h into module comcstfi_mod
+
+== 31/03/2015 == EM
+- Reorganizing the physics/dynamics interface, for better compatibility
+  between models and with the parallel LMDZ.COMMON dyn core. Main structural
+  changes are:
+* misc: (replaces what was the "bibio" directory)
+- Should only contain extremely generic (and non physics or
+  dynamics-specific) routines
+* dynlonlat_phylonlat: (new interface directory)
+- This directory contains routines relevent to physics/dynamics grid
+  interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
+- Moreover the dynlonlat_phylonlat contains directory "phystd".
+  This subdirectories should only contain specific interfaces (e.g. 
+  iniphysiq) or main programs (e.g. newstart).
+* phystd/dyn1d: this subdirectory contains the 1D models.
+
+== 17/04/2015 == JL & SG
+- Correct radiative transfer bug for the Top layer in callcorrk (=rev 1419). Only impacts plevrad(2).
+== 04/05/2015 == SG
+- Return to a previous interpolation scheme for pmid and tmid in callcorrk.
+
+== 16/09/2015 == EM
+- reorganizing the "datadir" structure: aerosol properties should now be in 
+  subdirectory 'aerosol_properties' of datadir, and surface.nc files should
+  be in subdirectory 'surface_data'. These subdirectory names are stored in
+  module datafile_mod.
+- Made things retro-compatible so that using an 'old' datadir structure (ie.
+  aerosol properties files and surface files in datadir) still works.
+
+== 21/09/2015 == MT
+- Cleanup of physiq.F90 and changed condense_cloud.F90 to condense_co2.F90
+
+== 14/10/2015 == MT
+- Implementation of the Spectral Albedo. Albedo(ngrid) is now Albedo(ngrid,L_NSPECTV) and has a value for each visible band.
+- Albedodat/Albedo0 have been removed. We now use Albedo_bareground.
+- CO2 Ice Albedo North/South dichotomy has been removed. CO2 ice Albedo is no longer stocked in start file. You can now
+prescribe CO2 ice albedo in callphys.def with "albedoco2ice". Its default value is 0.5.
+
+== 14/10/2015 == MT
+- Cleanup of callcorrk.F90.
+
+== 15/10/2015 == MT
+- Harmonization of the calculation of the surface tracer tendencies in physiq.F90.
+
+== 22/10/2015 == MT
+- Cleaning of condense_co2.F90.
+
+== 04/11/2015 == MT
+- Corrections of bugs in phyetat0.F90 (vap tracer) and in physiq.F90 (ice evolution scheme).
+
+== 05/11/2015 == MT
+- Minor Albedo correction of bugs in rcm1d.
+
+== 13/11/2015 == MT
+- Spectral Snow Albebdo implemented in the code.
+
+== 13/01/2016 == EM
+- Fix/improvement on planetwide_min/max/sum for the 3D fields which assumed the vertical dimension to be klev.
+  Now works for any (klon,...) field (e.g. albedo).
+
+== 10/02/2016 == MT
+- Added a generic routine (in utilities directory) to extrapolate ice fields.
+- Added a generic version of streamfunction (in utilities directory).
+
+== 17/03/2016 == EM
+- Added tests to ensure that soil model settings are adequate to resolve
+  sub-surface diurnal and annual thermal waves.
+
+== 24/03/2016 == EM
+- Some fixes/adjustments to run using OpenMP (in the physics, best practice is to always have "save" variables,
+  this of course includes all module variables, as "threadprivate").
+
+== 25/03/2016 == EM
+- Code reorganization (to mach comming evolutions on all planetary models),
+  created a "phy_common" directory to contain routines common (wrt structural
+  nature of underlying code/grid) to all LMDZ-related physics packages.
+- Moved ioipsl_getincom_p.F90 from "misc" to "phy_common" and modified it
+  to match Earth GCM version and renamed it ioipsl_getin_p_mod.F90
+- Adapted calls from phystd/* routines accordingly
+- Adapted "create_make_gcm" and "makegcm*" scripts accordingly
+  (deleted obsolete makegcm_g95)
+
+== 28/03/2016 == EM
+- Added module "regular_lonlat_mod.F90" (to store information on global
+  lon-lat grid) in phy_common.
+- Turned iniphysiq (in dynlonlat_phylonlat/phymars)into module
+  "iniphysiq_mod.F90".
+
+== 29/03/2016 == EM
+- Added "time_phylmdz_mod.F90" module to store information on time and
+  calendar in the physics, should be used instead of accessing "temps_mod"
+  from the dynamics. And moved daysec and dtphys from module "comcstfi_mod"
+  to module "time_phylmdz_mod".
+- made "inifis" a module.
+
+== 30/03/2016 == EM
+- Got rid of references to "control_mod" from the physics. Added a couple
+  of relevent variables for outputs in time_phylmdz_mod.
+
+== 05/04/2016 == EM
+- Got rid of references to "dimensions.h" from physics packages:
+  use nbp_lon (=iim), nbp_lat (=jjp1) and nbp_lev 
+  from module mod_grid_phy_lmdz (in phy_common) instead.
+- Removed module "comhdiff_mod.F90", as it is only used by module
+  surf_heat_transp_mod.F90, moved module variables there.
+- Added in "surf_heat_transp_mod" local versions of some arrays
+  and routines (from dyn3d) required to compute gradient, divergence, etc. 
+  on the global dynamics grid.
+  As before, the slab ocean only works in serial.
+
+== 07/04/2016 == EM+MT
+- Fix buggy ouputs in 1D introduced by previous code modifications.
+
+== 07/04/2016 == MT
+- In rcm1d.F (1d model), tracers profiles added in input.
+
+== 08/04/2016 == EM
+- Adapted rcm1d.F so that it also runs when compiled from LMDZ.COMMON.
+
+== 08/04/2016 == EM
+- Bug fix in surf_heat_transp_mod (introduced with revision 1529, 05/04/2016, modifications).
+- Initialize runoff in hydrol.F90.
+
+== 08/04/2016 == EM
+- Made nsoilmx be no longer a "parameter" and thus added the possibility to define the 
+  number of subsurface layers nsoilmx, along with first layer thickness "lay1_soil" and
+  companion coefficient "alpha_soil", in callphys.def at run time.
+  As before (when these were hard-coded), these are such that the depth of
+  soil mid-layers are:
+  mlayer(k)=lay1_soil*alpha_soil**(k-1/2), for k=0,nsoil-1
+
+== 13/04/2016 == EM
+- Some code reorganization: "dynlonlat_phylonlat" directory becomes
+  "dynphy_lonlat".
+- "iniprint.h" moved from "dyn3d" to "misc".
+
+== 18/04/2016 == EM
+- fix for 1D in writediagfi to enable writing at 
+  "ecritphy" rate.
+- move iniprint.h to "misc"
+- Some code cleanup in anticipation of future updates:
+ - changed variable names in comgeomphy.F90: give them more
+   explicit names: rlond => longitude , 
+   rlatd => latitude, airephy => cell_area,
+   cuphy => dx , cvphy => dy
+ - removed long(), lati() and area() from comgeomfi_h.F90,
+   use longitude(), latitude() and cell_are() from
+   comgeomphy.F90 instead
+
+== 22/04/2016 == EM
+- Updates and cleanup wrt dynamics/physics separation:
+  Removed init_phys_lmdz.F90 and comgeomphy.F90 from phystd;
+  comgeomphy is replaced by geometry_mod (located in phy_common).
+  Added physics_distribution_mod.F90 in phy_common and
+  mod_interface_dyn_phys.F90 in dynphy_lonlat.
+  Added nrtype.F90 (contains math const. like PI, etc.) in "misc"
+
+== 02/05/2016 == JL+EM
+- bug fix in calfis: wrong array (pw) sent to physics: the transfered
+  mass flux should be on the physics grid, not the dynamics grid.
+  Moreover values at the poles needed to be correctly recomputed.
+
+== 06/05/2016 == EM
+- turn physiq.F90 into module physiq_mod.F90
+
+== 20/05/2016 == AS+EM
+- cleanup around iniphysiq: separate things between planet-independent
+  initializations (now done by inigeomphy in dynphy_lonlat) and
+  mosre physics-package specific things (remain in iniphysiq).
+
+== 20/05/2016 == EM
+- Fix in wstats: use "def_var_stats" and not "def_var" (intended for
+  writediagfi).
+
+== 27/05/2016 == EM
+- missing libf/dynphy_lonlat/phymars/inigeomphy_mod.F90 in updates around
+  iniphysiq
+
+== 12/07/2016 == EM
+- move initialization of dimphy from inigeomphy to iniphysiq (initializations
+related to routines in phy_common or dynphy_lonlat can be done in 
+inigeomphy, but any initialization for modules/routines in a physics
+package (directory phystd) must be done in the related phystd/iniphysiq
+routine.
+
+== 27/07/2016 == EM
+- further cleanup in the dynamics/physics interface: stop sending information
+  about tracer advection (tracerdyn) back from physics to dynamics as this
+  input parameter can be read and set in the dynamics.
+
+== 30/08/2016 == EM
+- fix newstart which was broken due to recent updates of the physics/dynamics
+  interface.
+
+== 09/09/2016 == EM
+- Some code cleanup (and harmonization with LMDZ.COMMON): remove "ecritphy"
+  from the dynamics (since it is read/used in the physics) and remove
+  "grireg" (unused) and "physic" (use iflag_phys instead) parameters from
+  the dynamics.
+
+== 13/09/2016 == EM
+- Further cleanup to harmonize with LMDZ.COMMON turn "idissip" into
+  "dissip_period".
+
+== 15/09/2016 == TB
+- bug fix in tpindex.F : when computing weights for abundance of species one
+  should not return the maximum index (leads to out-of-bounds index use in 
+  the caller).
+
+== 25/10/2016 == EM
+Updates for full physics/dynamics separation:
+- introduced module vertical_layers_mod.F90 in phy_common to store information
+  about the vertical grid to be used in the physics. Routines in the physics
+  should "use vertical_layers_mod" and not "use comvert_mod".
+- added nqtot to tracer_h.F90. Always "use tracer_h" in physics instead of
+  infotrac (which is in the dynamics).
+- removed some purely dynamics-related outputs (etot0, zoom parameters, etc.)
+  from diagfi.nc and stats.nc outputs as these informations are not available
+  in the physics.
+- added scalheight (atmospheric scale height) in comvert_mod.
+
+== 31/10/2016 == EM
+Introducing a first prototype of XIOS outputs: requires compiling with
+"-io xios" flag and having an XIOS library at hand. Corresponding
+companion xml files iodef.xml and context_lmdz_physics.xml in the "deftank"
+subdirectory. Still some work to do concerning the XIOS calendar (definition
+of an initial date and month number and lenght).
+
Index: /trunk/LMDZ.TITAN/create_make_gcm
===================================================================
--- /trunk/LMDZ.TITAN/create_make_gcm	(revision 1644)
+++ /trunk/LMDZ.TITAN/create_make_gcm	(revision 1644)
@@ -0,0 +1,263 @@
+#!/bin/sh
+#set -xv
+#
+# Ehouarn: added the following feature:
+#          create_make_gcm must be called with list of directories
+#          which contain header (or modules) which should be scanned
+#          by create_make_gcm when checking dependencies.
+#          Example:
+#          create_make_gcm dyn3d grid
+#          means that header/modules will be looked for in directories
+#          ., dyn3d and grid
+#
+
+# arguments given to create_make_gcm are the directories to scan
+src_dirs=$*
+
+machine=`hostname`
+os=`uname`
+gcm=`pwd`
+logfile=$gcm/create_make_gcm.log
+rm -f $logfile ; touch -f $logfile
+libf=$gcm/libf
+libo=$gcm/libo
+CRAY=0
+if [ "$machine" = "atlas" -o "$machine" = "etoile" -o "$machine" = "axis" ] ; then
+  CRAY=1
+fi
+XNEC=0
+if [ "$machine" = "rhodes" ] ; then
+  XNEC=1
+fi
+VPP=0
+if [ "$machine" = "nymphea0" ] ; then
+  VPP=1
+fi
+#
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo "# Definitions de Macros pour Make"
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo 
+echo "# create_make_gcm arguments: $*"
+echo
+echo "# Repertoires :"
+echo
+echo "GCM     = "$gcm
+if [ "$CRAY" = '0' ] ; then
+   echo "MACHINE = sun4"
+fi
+echo 'LIBF    = $(GCM)/libf'
+if [ "$CRAY" = '0' ] ; then
+#   echo 'LIBO    = $(GCM)/libo/$(MACHINE)'
+   echo 'LIBO    = $(LIBOGCM)/$(MACHINE)'
+else
+   echo 'LIBO    = $(GCM)/libo'
+fi
+#echo 'LOCAL_DIR=$(GCM)'
+#echo $localdir
+echo "LOCAL_DIR=`echo $localdir`"
+echo 'MISC    = $(LIBF)/misc'
+#echo 'AERONOMARS    = $(LIBF)/aeronomars'
+echo "FILTRE   = filtre"
+echo "PHYS  = "
+echo 'DYN  = $(DYNTYPE)'
+echo 'LIBPHY = $(LIBO)/libphy$(PHYS).a'
+echo 'LIBDYN_PHY = $(LIBO)/libdynlmdz_phy$(PHYS).a'
+echo 'DIRMAIN= $(DYN)$(DIM)d'
+echo 'RM=rm'
+echo
+echo "OPLINK = "
+echo
+echo '# Les differentes librairies pour l"edition des liens:'
+echo
+echo 'L_DYN      = -ldyn$(DIM)d'
+echo 'L_FILTRE   = -l$(FILTRE)'
+echo 'L_DYN_PHY = -ldynlmdz_phy$(PHYS) '
+echo 'L_PHY = -lphy$(PHYS) -lphy_common'
+echo 'L_MISC    = -lmisc'
+#echo 'L_AERONOMARS    = -laeronomars'
+echo 'L_ADJNT    ='
+echo
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo "# Option de compilation FORTRAN"
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo
+   echo 'COMPILE = $(F77) $(OPTIM) $(INCLUDE) -c'
+   echo 'COMPILE90 = $(F90) $(OPTIM90) $(INCLUDE) -c'
+   echo 'COMPTRU90 = $(F90) $(OPTIMTRU90) $(INCLUDE) -c'
+   echo "LINK    = $LINK"
+   echo "AR      = $AR"
+echo
+echo
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo "# Creation des differents executables"
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo
+echo "# Executables:"
+echo "# ------------"
+echo
+echo "PROG = code"
+echo 'DYN  = dyn$(DIM)d'
+echo
+echo 'main : $(DYN) misc phys phy_common dyn_phy $(OPTION_DEP) '
+echo '	cd $(LIBO) ; $(RANLIB) lib*.a ; cd $(GCM) ;\'
+echo '	cd $(LOCAL_DIR); \'
+echo '	$(COMPILE90) $(LIBF)/$(DIRMAIN)/$(SOURCE) -o $(PROG).o ; \'
+echo '	$(LINK) $(PROG).o -L$(LIBO) $(L_DYN) $(L_DYN_PHY) $(L_ADJNT) $(L_FILTRE) $(L_PHY) $(L_DYN_PHY) $(L_MISC) $(L_DYN) $(L_PHY) $(OPLINK) $(OPTION_LINK) -o $(LOCAL_DIR)/$(PROG).e ; $(RM) $(PROG).o '
+echo
+echo 'dyn : $(LIBO)/libdyn$(DIM)d.a $(FILTRE)$(DIM)d'
+echo
+echo 'olddyn : $(LIBO)/libolddyn$(DIM)d.a $(FILTRE)$(DIM)d'
+echo
+echo 'phys : $(LIBPHY)'
+echo 'phy_common : $(LIBPHY_COMMON)'
+echo
+echo 'dyn3d : $(LIBO)/libdyn3d.a $(LIBO)/lib$(FILTRE).a'
+echo 'dyn2d : $(LIBO)/libdyn2d.a'
+echo 'dyn1d : '
+echo
+echo 'dyn_phy: $(LIBDYN_PHYS)'
+echo
+echo 'misc : $(LIBO)/libmisc.a'
+echo
+#echo 'aeronomars : $(LIBO)/libaeronomars.a'
+#echo
+echo 'adjnt : $(LIBO)/libadjnt.a'
+echo
+echo '$(FILTRE)3d : $(LIBO)/lib$(FILTRE).a'
+echo
+echo '$(FILTRE)2d :'
+echo
+echo '$(FILTRE)1d :'
+echo
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo "# Contenu des differentes bibliotheques"
+echo "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+echo
+echo
+cd $libf >/dev/null 2>&1
+
+for diri in $src_dirs ; do
+
+   if [ -d $diri ] ; then
+   if [ "`ls $diri/*.F`" != "" ] || [ "`ls $diri/*.[fF]90`" != "" ]  ; then 
+#      cd $diri >/dev/null 2>&1
+      echo
+      listlib=""
+# Liste des fichiers .F et .F90 n'etant pas des programmes principaux
+      for fili in `ls $diri/*.[fF]` ; do
+         # Check if file is a routine or main program
+         # i.e: look for the "program" keword preceeded by leading spaces
+         test=` (  head $fili | grep -i '^ *program' ) `
+         # if it is not a main program, add it to the list
+         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi
+      done
+      for fili in `ls $diri/*.[fF]90` ; do
+         # Check if file is a routine or main program
+         # i.e. look for "program" keyword (with possibly some leading spaces)
+         test=` (  head $fili | grep -i '^ \{0,\}program' ) `
+         # if it is not a main program, add it to the list
+         if [ "$test" = "" ] ; then listlib=$listlib" "$fili ; fi 
+      done
+      echo
+      echo $listlib >> $logfile
+      echo
+      # topdiri contains main dir name (without trailing "/blabla" for subdirs)
+      topdiri=${diri%/*}
+      echo "#=================================================================="
+      echo "# Contenu de la bibliotheque correspondant au Directory "$diri
+      echo "#=================================================================="
+      echo
+      for trufile in $listlib ; do
+         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
+         echo '$(LIBO)/lib'$topdiri".a : " '$(LIBO)/lib'$topdiri".a("$fili".o)"
+         echo
+      done
+      echo '.PRECIOUS	: $(LIBO)/lib'$topdiri'.a'
+      echo
+      echo
+      echo "# Compilation of elements in $diri of library lib"$topdiri".a"
+      echo
+      for trufile in $listlib ; do
+         fili=`echo $trufile | awk -F/ ' { print $NF } ' | cut -d. -f1`
+         F90=0 ; egrep -i '^ *use ' $trufile > /dev/null 2>&1 && F90=1
+                 egrep -i '^ *module ' $trufile > /dev/null 2>&1 && F90=1
+                 egrep -i '#include*.inc ' $trufile > /dev/null 2>&1 && F90=1
+         str1='$(LIBO)/lib'$topdiri'.a('$fili'.o) : $(LIBF)/'$trufile
+         [ "$fili" = "$diri/chem.subs" ] && str1=$str1' $(LIBF)/'$diri/chem.mods.F
+
+##########################################################################
+# TRAITEMENT DES DEPENDANCES
+# Differents cas de dependance correspondant a des include ou des
+# use module.
+# soit dans le repertoire local soit dans un autre.
+# Pour dyn3d, il faudrait remplacer la chaine de caractere par $DYN
+# ou quelque chose du genre.
+##########################################################################
+
+         for stri in ` ( sed -e '/^[cC\!]/d' $trufile | sed -e "/\#include /s/\#include /XXnclude /" -e "/include /s/include /XXnclude /" -e "/INCLUDE /s/INCLUDE /XXnclude /" | sed -n "/XXnclude /s/XXnclude//p" | sed 's/\"//g' | sort | uniq ; sed -e '/^[cC\!]/d' $trufile | egrep -i '^ *use ' | sed -e 's/,/ /' | awk ' { print $2 } ' | sort | uniq ) ` ; do
+            echo $trufile $fili $stri >> $logfile
+            strj=`echo $stri | tr [A-Z] [a-z]`
+            str2=""
+            for dirinc in $src_dirs ; do
+# Recherche dans l'ordre hierarchique inverse car seule la derniere
+# ligne est conservee
+#               if [ $dirinc = phydev ] ; then
+#                   dirstr='$(PHYS)'
+#                   libstr='phy$(PHYS)'
+#               else
+                   dirstr=$dirinc
+                   libstr=$dirinc
+#               fi
+               echo dirinc $dirinc >> $logfile
+               if [ -f $dirinc/$stri ] ; then
+                  str2='$(LIBF)/'$dirstr/$stri
+               elif [ -f $dirinc/$strj ] ; then
+                  str2='$(LIBF)/'$dirstr/$stri
+               elif [ -f $dirinc/$strj.[fF]90 ]  || [ -f $dirinc/$strj.[fF] ]  ; then 
+                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
+                  str2='$(LIBO)/lib'$strlib'.a('$strj'.o)'
+               elif [ -f $dirinc/$stri.[fF]90 ]  || [ -f $dirinc/$stri.[fF] ]  ; then 
+                  strlib=`echo $libstr | awk -F/ ' { print $1 } '`
+                  str2='$(LIBO)/lib'$strlib'.a('$stri'.o)'
+               fi
+               echo stri $stri  >> $logfile
+               echo str2 $str2  >> $logfile
+            done
+               echo dernier str2 $str2  >> $logfile
+            if [ "$str2" = "" ] ; then
+               echo Warn: Include $diri $trufile $fili $stri pas trouve >> $logfile
+            elif [ "$str2" = "$str1" ] ; then
+               echo Warn: Include $diri $trufile $fili $stri $str1 trouve 2x >> $logfile
+            else
+               echo $str1 \\
+               str1=$str2
+            fi
+         done # Fin de la boucle sur les dependances et ecriture de la derniere
+         echo $str1
+         # Compile in LIBO directory; and before compiling, remove
+         # object from library
+         echo '	cd $(LIBO); \'
+         echo '	$(AR) d $(LIBO)/lib'$topdiri'.a '$fili'.o ; \'
+	 if [ "$F90" -eq '0' ] ; then
+         ## Fixed Form Fortran 77
+	   echo '	$(COMPILE) $(LIBF)/'$trufile' ; \'
+	 else
+         ## Fortran 90
+           if [ `echo $trufile | cut -d. -f2` = F90 ] ; then
+	      ## Free Form
+              echo '	$(COMPTRU90) $(LIBF)/'$trufile' ; \'
+           else
+	      echo '	$(COMPILE90) $(LIBF)/'$trufile' ; \'
+           fi
+	 fi
+         # Put generated object in library
+         echo '	$(AR) r $(LIBO)/lib'$topdiri'.a '$fili'.o ; $(RM) '$fili'.o ; \'
+	 echo
+      done
+#	 
+      echo
+   cd $libf
+   fi
+   fi
+done
Index: /trunk/LMDZ.TITAN/libf/chimtitan/aer.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/aer.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/aer.c	(revision 1644)
@@ -0,0 +1,206 @@
+/* aer: production of aerosol precursors by photochemistry */
+
+#include "titan.h"
+
+void aer( char corps[][10], double *tp, double *nb, double y[][NLEV],
+          int *zj, double **k_dep, double **f,
+          double *r1, double *r2, double *r3, double *r4, double *r5, double *r6,
+          int *utilaer, double *m, double *prod, double *csn, double *csh )
+{
+  int   re,x,z;
+  int   i,j,c2h2,c2,c2h,hc3n,c3n,c4h2,hcn,h2cn,c4h3,ac6h5,ac6h6;
+  int   nccn,ch3cn,c2h3cn,NMAX;
+  double v1,v2,v3,alpha,beta1,beta2,gamma,denom;
+  double temp,ct,dy_c2h2,dy_hc3n,dy_hcn;
+  double dy_nccn,dy_ch3cn,dy_c2h3cn;
+  char  sor1[20],sor2[20],sor3[20],outlog[10];
+  FILE  *fp, *out;
+
+  NMAX = 20;
+  z    = (*zj);
+  temp = tp[z];
+  ct   = nb[z];
+
+/* debug
+      out = fopen( "aer.log", "a" );
+      fprintf( out, "" );
+      fclose( out );
+*/
+
+/* composes interessants */
+/* --------------------- */
+/* !! decalage de 1 par rapport a calchim !! */
+
+     c2h2 = utilaer[2];
+       c2 = utilaer[3];
+      c2h = utilaer[4];
+     hc3n = utilaer[5];
+      hcn = utilaer[6];
+      c3n = utilaer[7];
+     h2cn = utilaer[8];
+     c4h2 = utilaer[9];
+     c4h3 = utilaer[10];
+    ac6h5 = utilaer[11];
+    ac6h6 = utilaer[12];
+     nccn = utilaer[13];
+    ch3cn = utilaer[14];
+   c2h3cn = utilaer[15];
+ 
+
+/* si C2H3CN n'est pas pris en compte: attribue a CH3CN, mais reaction nulle */
+
+/* vitesses de reactions */
+/* --------------------- */
+
+  /* v (et K) en cm3.s-1 */
+  v1 = 2.e-16;
+  v2 = 3.72e-13*exp(-1561./temp);
+  v3 = 1.0e-12*exp(-900./temp);
+
+  alpha = 6.;
+  beta1 = 1.;
+  beta2 = 1.;
+  gamma = 1.;
+
+  /* k en s-1 */
+  k_dep[1][1] = v1  *ct*y[c2h2][z]*y[c4h3][z];         /* C2H2 + C4H3 */
+  k_dep[2][1] = v1  *ct*y[hc3n][z]*y[c4h3][z] *alpha;  /* HC3N + C4H3 */
+  for( i = 3; i <= 5; i++ ) k_dep[i][1] = 0.;
+
+  k_dep[1][2] = v2  *ct*y[c2h2][z]*y[ac6h5][z];        /* C2H2 + AC6H5 */
+  k_dep[2][2] = v2  *ct* y[hcn][z]*y[ac6h5][z]*beta1;  /*  HCN + AC6H5 */
+  k_dep[3][2] = v2  *ct*y[hc3n][z]*y[ac6h5][z]*beta2;  /* HC3N + AC6H5 */
+/*  for( i = 4; i <= 5; i++ ) k_dep[i][2] = 0.; */
+  k_dep[4][2] = 5.2e-10 *ct* y[c2][z]*y[ac6h6][z];  /* C2  + AC6H6 */
+  k_dep[5][2] = 8.2e-11 *ct*y[c2h][z]*y[ac6h6][z];  /* C2H + AC6H6 */
+
+  k_dep[1][3] = v3  *ct* y[hcn][z]*y[h2cn][z];         /* HCNH +    HCN */
+/* !! debug !!
+  k_dep[2][3] = v3  *ct*y[hc3n][z]*y[h2cn][z]*gamma;      HCNH +   HC3N */
+  k_dep[2][3] = v3  *ct*y[hc3n][z]*y[h2cn][z]*1.e-10;  /* HCNH +   HC3N */
+  k_dep[3][3] = v3  *ct*y[nccn][z]*y[h2cn][z]*gamma;   /* HCNH +   NCCN */
+  k_dep[4][3] = v3 *ct*y[ch3cn][z]*y[h2cn][z]*gamma;   /* HCNH +  CH3CN */
+ if(c2h3cn!=ch3cn)
+  k_dep[5][3] = v3*ct*y[c2h3cn][z]*y[h2cn][z]*gamma;   /* HCNH + C2H3CN */
+ else 
+  k_dep[5][3] = 0.;
+
+/* Fractions de chaque compose dans les polymeres */
+/* ---------------------------------------------- */
+
+/* polyC2H2 */
+
+   denom   = y[c2h2][z] + alpha*y[hc3n][z];
+   f[1][1] = y[c2h2][z] / denom;       /* C2H2 */
+   f[2][1] = alpha*y[hc3n][z] / denom; /* HC3N */
+   for( i = 3; i <= 5; i++ ) f[i][1] = 0.;
+
+/* PAHs */
+
+   denom   = y[c2h2][z] + beta1*y[hcn][z] + beta2*y[hc3n][z];
+   f[1][2] = y[c2h2][z] / denom;       /* C2H2 */
+   f[2][2] = beta1*y[hcn][z] / denom;  /*  HCN */
+   f[3][2] = beta2*y[hc3n][z] / denom; /* HC3N */
+   for( i = 4; i <= 5; i++ ) f[i][2] = 0.;
+
+/* polyHCN */
+
+  if(c2h3cn!=ch3cn)
+   denom   = y[hcn][z] + gamma*(y[hc3n][z]+y[nccn][z]+y[ch3cn][z]+y[c2h3cn][z]);
+  else
+   denom   = y[hcn][z] + gamma*(y[hc3n][z]+y[nccn][z]+y[ch3cn][z]);
+   f[1][3] =          y[hcn][z] / denom;         /*    HCN */
+   f[2][3] = gamma*  y[hc3n][z] / denom;         /*   HC3N */
+   f[3][3] = gamma*  y[nccn][z] / denom;         /*   NCCN */
+   f[4][3] = gamma* y[ch3cn][z] / denom;         /*  CH3CN */
+  if(c2h3cn!=ch3cn)
+   f[5][3] = gamma*y[c2h3cn][z] / denom;         /* C2H3CN */
+  else
+   f[5][3] = 0.;         /* C2H3CN */
+
+/* Masse molaire et Rapports C/N et C/H */
+/* Taux de production en masse          */
+/* Taux de destruction molecules        */
+/* ------------------------------------ */
+
+/* polyC2H2 */
+
+    m[1]    = NMAX*(f[1][1]*26 + f[2][1]*51);  /* g.mol-1 */
+
+    prod[1] = 0.;
+    for( i = 1; i <= 5; i++ ) prod[1] += k_dep[i][1]; /* s-1 */
+
+    dy_c2h2 = prod[1] * NMAX * f[1][1];
+    dy_hc3n = prod[1] * NMAX * f[2][1];
+
+    if( f[2][1] != 0.0e0 ) csn[1] = (2*f[1][1] + 3*f[2][1]) / f[2][1];
+    else                   csn[1] = 1.0e30;
+                           csh[1] = (2*f[1][1] + 3*f[2][1]) / (2*f[1][1] + f[2][1]);
+
+/* PAHs */
+
+    m[2]    = NMAX*(f[1][2]*26 + f[2][2]*27 + f[3][2]*51);  /* g.mol-1 */
+
+    prod[2] = 0.;
+    for( i = 1; i <= 5; i++ ) prod[2] += k_dep[i][2]; /* s-1 */
+
+    dy_c2h2 += prod[2] * NMAX * f[1][2];
+    dy_hcn   = prod[2] * NMAX * f[2][2];
+    dy_hc3n += prod[2] * NMAX * f[3][2];
+
+    if( (f[2][2]+f[3][2]) != 0.0e0 )
+           csn[2] = (2*f[1][2] + f[2][2]+ 3*f[3][2]) / (f[2][2] + f[3][2]);
+    else   csn[2] = 1.0e30;
+           csh[2] = 1.;         /* probleme du nombre exact de H */
+
+/* polyHCN */
+
+    m[3]    = NMAX*(f[1][3]*27+f[2][3]*51+f[3][3]*52+f[4][3]*41+f[5][3]*53);  /* g.mol-1 */
+
+    prod[3] = 0.;
+    for( i = 1; i <= 5; i++ ) prod[3] += k_dep[i][3]; /* s-1 */
+
+    dy_hcn  += prod[3] * NMAX * f[1][3];
+    dy_hc3n += prod[3] * NMAX * f[2][3];
+    dy_nccn  = prod[3] * NMAX * f[3][3];
+    dy_ch3cn = prod[3] * NMAX * f[4][3];
+    dy_c2h3cn= prod[3] * NMAX * f[5][3];
+
+    csn[3] = (f[1][3]+3*f[2][3]+2*f[3][3]+2*f[4][3]+3*f[5][3])
+           / (f[1][3]+  f[2][3]+2*f[3][3]+  f[4][3]+  f[5][3]);
+    csh[3] = (f[1][3]+3*f[2][3]+2*f[3][3]+2*f[4][3]+3*f[5][3])
+           / (f[1][3]+  f[2][3]          +3*f[4][3]+3*f[5][3]);
+
+/* melange */
+
+    csn[0] =  (  prod[1]*(2*f[1][1]+3*f[2][1])
+               + prod[2]*(2*f[1][2]+  f[2][2]+3*f[3][2])
+               + prod[3]*(  f[1][3]+3*f[2][3]+2*f[3][3]+2*f[4][3]+3*f[5][3]) )
+            / (  prod[1]*(            f[2][1])
+               + prod[2]*(            f[2][2]+  f[3][2])
+               + prod[3]*(  f[1][3]+  f[2][3]+2*f[3][3]+  f[4][3]+  f[5][3]) );
+    csh[0] =  (  prod[1]*(2*f[1][1]+3*f[2][1])
+               + prod[2]*(2*f[1][2]+  f[2][2]+3*f[3][2])
+               + prod[3]*(  f[1][3]+3*f[2][3]+2*f[3][3]+2*f[4][3]+3*f[5][3]) )
+            / (  prod[1]*(2*f[1][1]+  f[2][1])
+               + prod[2]*(2*f[1][2]+  f[2][2]+  f[3][2])
+               + prod[3]*(  f[1][3]+  f[2][3]          +3*f[4][3]+3*f[5][3]) );
+
+/* mass production rates (in kg m-3 s-1) */
+
+    prod[0] = 0.;
+    for( i = 1; i <= 3; i++ )
+    {
+       prod[i]  =  prod[i] * ct * m[i] / 6.022e23 *1.e3;
+       prod[0] += prod[i];
+    }
+
+    *r1   = dy_c2h2;
+    *r2   = dy_hc3n;
+    *r3   = dy_hcn;
+    *r4   = dy_nccn;
+    *r5   = dy_ch3cn;
+    *r6   = dy_c2h3cn;
+
+}
+
Index: /trunk/LMDZ.TITAN/libf/chimtitan/chimie.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/chimie.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/chimie.c	(revision 1644)
@@ -0,0 +1,117 @@
+/* chimie: Chemistry fabric */
+/* GCCM */
+
+/* ko: low pressure limit:  3 body reaction (1st) */
+/* ki: high pressure limit: 2 body reaction (2nd) */
+
+#include "titan.h"
+
+void chimie_( char CORPS[][10], double *NB, double *TEMP, double KRATE[][NLEV], int REACTIF[][5],
+             int *NOM_PERTE, int *NOM_PROD, int PERTE[][200][2], int PROD[][200] )
+{
+   int    dep,i,j,k,l,lat;
+   double  ai,ao,ei,eo,ki,ko,m,ti,to;
+   FILE   *out;
+   char   corps[100][10];
+   static char   reaction[NREAC+1][12][10]={
+#include VERCHIM
+   "",       "",       "",       "",     "",  "","","","","","",""};
+
+   for( i = 0; i <= NC; i++)
+   {
+     strcpy( corps[i], CORPS[i] );
+     corps[i][strcspn(CORPS[i], " ")] = '\0';
+   }
+
+   for( i = 0; i <= NC-1; i++ )
+   {
+      NOM_PERTE[i] = NOM_PROD[i] = 0;
+      for( j = 0; j < 200; j++ )
+         PERTE[i][j][0] = PERTE[i][j][1] = PROD[i][j] = 0;
+   }
+   dep = 0;
+   for( i = dep; i <= NREAC-1; i++ )            /* Number of reactions */
+   {
+      for( j = 0; j <= 4; j++ )                 /* Number of compouds in each reactions */
+      {
+         k = 0;
+         if( (strcmp(reaction[i][j],"prod"))   /* prod and soot are not */
+          && (strcmp(reaction[i][j],"soot"))   /* considered in the compounds */
+          && (strcmp(reaction[i][j],""))     ) /* Which compound ? */
+         {
+            while( strcmp(reaction[i][j],corps[k]) )     /* Compound in reaction j, column i */
+            {
+               if( k == NC+1 )
+               {
+                  out = fopen( "err.log", "a" );
+                  fprintf( out, "I cannot find %s\n", reaction[i][j] );
+                  fclose( out );
+                  exit(0);
+               }
+               k++;
+            }
+            REACTIF[i][j] = k;                         /* is number k */
+         }
+         else REACTIF[i][j] = NC;
+      }
+   }
+   for( i = dep; i <= NREAC-1; i++ )     /* Total loss and production */
+   {
+      j = REACTIF[i][0];                 /* First compound reaction i */
+      k = NOM_PERTE[j] + 1;              /* Loss one more times */
+      if( k >= 200 ) exit(0);
+      NOM_PERTE[j] = k;
+      PERTE[j][k-1][0] = i;              /* Compound j loss in reaction i for the kth time */
+      PERTE[j][k-1][1] = REACTIF[i][1];  /* Compound j reacts with number 2 in reaction i */
+      j = REACTIF[i][1];                 /* Second compound reaction i */
+      if( j != NC )                      /* Neither photodissociation nor desexcitation */
+      {
+       k = NOM_PERTE[j] + 1;             /* Loss one more times */
+       if( k >= 200 ) exit(0);
+       NOM_PERTE[j] = k;
+       PERTE[j][k-1][0] = i;             /* Compound j is loss in reaction i for the kth times */
+       PERTE[j][k-1][1] = REACTIF[i][0]; /* Compound j reacts with number 1 reaction i */
+      }
+      for( j = 2; j < 5; j++ )           /* Compounds from 3 to 5 */
+      {
+         k = REACTIF[i][j];              /* Number of compound */
+         if( k != NC )
+         {
+            l = NOM_PROD[k] + 1;         /* One more time produced */
+            if( l >= 200 ) exit(0);
+            NOM_PROD[k]  = l;
+            PROD[k][l-1] = i;             /* at reaction i */
+         }
+      }
+   }
+   for( i = RDISS+1; i <= NREAC-1; i++ )   /* 0 a RDISS-1: photodiss, RDISS: disso N2 */
+   {
+      ao = strtod(reaction[i][5], NULL);
+      to = strtod(reaction[i][6], NULL);
+      eo = strtod(reaction[i][7], NULL);
+      ai = strtod(reaction[i][8], NULL);
+      ti = strtod(reaction[i][9], NULL);
+      ei = strtod(reaction[i][10],NULL);
+      m  = strtod(reaction[i][11],NULL);
+      for( j = 0; j <= NLEV-1; j++ )
+      {
+            ko = ao * pow( TEMP[j], to) * exp( eo / TEMP[j] );
+            if( m == 1.0e0 )
+               KRATE[i][j] = ko;
+            else if( m == 2.0e0 )
+            {
+               KRATE[i][j] = ko * pow( NB[j], 2.0e0 );
+            }
+            else if( m == 3.0e0 )
+            {
+               if( ai == 0.0e0 )
+                  KRATE[i][j] = ko * pow( NB[j], 3.0e0 );
+               else
+               {
+                  ki = ai * pow( TEMP[j], ti ) * exp( ei / TEMP[j] );
+                  KRATE[i][j] = pow( NB[j], 3.0e0 ) * ko * ki / ( ko * NB[j] + ki );
+               }
+            }
+      }
+   }
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit	(revision 1644)
@@ -0,0 +1,387 @@
+   "H2",     "HV",     "H",      "H",    "",  "","","","","","","",  /* 1 */
+   "CH3",    "HV",     "1CH2",   "H",    "",  "","","","","","","",  /* 2 */
+   "CH4",    "HV",     "1CH2",   "H2",   "",  "","","","","","","",  /* 3 */
+   "CH4",    "HV",     "CH",     "H2",   "H", "","","","","","","",  /* 4 */
+   "CH4",    "HV",     "CH3",    "H",    "",  "","","","","","","",  /* 5 */
+   "C2H2",   "HV",     "C2H",    "H",    "",  "","","","","","","",  /* 6 */
+   "C2H2",   "HV",     "C2",     "H2",   "",  "","","","","","","",  /* 7 */
+   "C2H4",   "HV",     "C2H2",   "H2",   "",  "","","","","","","",  /* 8 */
+   "C2H4",   "HV",     "C2H2",   "H",    "H", "","","","","","","",  /* 9 */
+   "C2H6",   "HV",     "C2H4",   "H2",   "",  "","","","","","","",  /* 10 */
+   "C2H6",   "HV",     "C2H4",   "H",    "H", "","","","","","","",  /* 11 */
+   "C2H6",   "HV",     "C2H2",   "H2",   "H2","","","","","","","",  /* 12 */
+   "C2H6",   "HV",     "CH4",    "1CH2", "",  "","","","","","","",  /* 13 */
+   "C2H6",   "HV",     "CH3",    "CH3",  "",  "","","","","","","",  /* 14 */
+   "C3H3",   "HV",     "C3H2",   "H",    "",  "","","","","","","",  /* 15 */
+   "CH2CCH2","HV",     "C3H3",   "H",    "",  "","","","","","","",  /* 16 */
+   "CH2CCH2","HV",     "C3H2",   "H2",   "",  "","","","","","","",  /* 17 */
+   "CH3CCH", "HV",     "C3H3",   "H",    "",  "","","","","","","",  /* 18 */
+   "CH3CCH", "HV",     "C3H2",   "H2",   "",  "","","","","","","",  /* 19 */
+   "C3H6",   "HV",     "CH2CCH2","H",    "H", "","","","","","","",  /* 20 */
+   "C3H6",   "HV",     "CH3CCH", "H",    "H", "","","","","","","",  /* 21 */
+   "C3H6",   "HV",     "C2H4",   "3CH2", "",  "","","","","","","",  /* 22 */
+   "C3H6",   "HV",     "C2H3",   "CH3",  "",  "","","","","","","",  /* 23 */
+   "C3H6",   "HV",     "C2H2",   "CH4",  "",  "","","","","","","",  /* 24 */
+   "C3H8",   "HV",     "C3H6",   "H2",   "",  "","","","","","","",  /* 25 */
+   "C3H8",   "HV",     "C2H6",   "1CH2", "",  "","","","","","","",  /* 26 */
+   "C3H8",   "HV",     "C2H5",   "CH3",  "",  "","","","","","","",  /* 27 */
+   "C3H8",   "HV",     "C2H4",   "CH4",  "",  "","","","","","","",  /* 28 */
+   "C4H2",   "HV",     "C4H",    "H",    "",  "","","","","","","",  /* 29 */
+   "C4H2",   "HV",     "C2H",    "C2H",  "",  "","","","","","","",  /* 30 */
+   "C4H2",   "HV",     "C2H2",   "C2",   "",  "","","","","","","",  /* 31 */
+   "C4H2",   "HV",     "C4H2s",  "",     "",  "","","","","","","",  /* 32 */
+   "C4H4",   "HV",     "C4H2",   "H2",   "",  "","","","","","","",  /* 33 */
+   "C4H4",   "HV",     "C2H2",   "C2H2", "",  "","","","","","","",  /* 34 */
+   "C4H6",   "HV",     "C4H4",   "H2",   "",  "","","","","","","",  /* 35 */
+   "C4H6",   "HV",     "C2H4",   "C2H2", "",  "","","","","","","",  /* 36 */
+   "C4H6",   "HV",     "CH3",    "C3H3", "",  "","","","","","","",  /* 37 */
+   "C4H10",  "HV",     "C3H5",   "CH3",  "H2","","","","","","","",  /* 38 */
+   "C4H10",  "HV",     "C2H4",   "C2H4", "H2","","","","","","","",  /* 39 */
+   "C4H10",  "HV",     "C3H6",   "CH4",  "",  "","","","","","","",  /* 40 */
+   "C4H10",  "HV",     "C3H6",   "CH3",  "H", "","","","","","","",  /* 41 */
+   "C4H10",  "HV",     "C2H4",   "C2H6", "",  "","","","","","","",  /* 42 */
+   "C4H10",  "HV",     "C2H2",   "C2H6", "H2","","","","","","","",  /* 43 */
+   "C4H10",  "HV",     "CH3",    "C3H7", "",  "","","","","","","",  /* 44 */
+   "C4H10",  "HV",     "C2H5",   "C2H5", "",  "","","","","","","",  /* 45 */
+
+   "AC6H6",  "HV",     "prod",   "CH3",  "",  "","","","","","","",  /* 46 */
+   "AC6H6",  "HV",     "AC6H5",  "H",    "",  "","","","","","","",  /* 47 */
+
+   "N2",     "HV",     "N4S",    "N4S",  "",  "","","","","","","",  /* 48 */
+   "HCN",    "HV",     "H",      "CN",   "",  "","","","","","","",  /* 49 */
+   "HC3N",   "HV",     "C2H",    "CN",   "",  "","","","","","","",  /* 50 */
+   "HC3N",   "HV",     "H",      "C3N",  "",  "","","","","","","",  /* 51 */
+   "NCCN",   "HV",     "CN",     "CN",   "",  "","","","","","","",  /* 52 */
+   "CH3CN",  "HV",     "CH3",    "CN",   "",  "","","","","","","",  /* 53 */
+   "C4N2",   "HV",     "C3N",    "CN",   "",  "","","","","","","",  /* 54 */
+
+   "N2",     "",       "N4S",    "N4S",  "",  "0.00e+00","+00.0","+00000","0.00e+00","+00.0","+00000","1", 
+
+   "H",      "H",      "H2",     "",     "",  "2.70e-31","-00.6","+00000","1.00e-11","+00.0","+00000","3", /* Baulch92 */
+   "H",      "1CH2",   "CH",     "H2",   "",  "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "3CH2",   "H2",     "CH",   "",  "3.54e-11","+0.32","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "3CH2",   "CH3",    "",     "",  "1.70e-25","-01.8","+00000","3.50e-11","+0.32","-00000","3", /* cf V05 */
+   "H",      "CH3",    "CH4",    "",     "",  "6.33e-21","-2.98","-00635","2.63e-08","-0.60","-00189","3", 
+   "H",      "CH3",    "H2",     "3CH2", "",  "1.00e-10","+00.0","-07600","0.00e+00","+00.0","+00000","2", 
+   "H",      "CH4",    "H2",     "CH3",  "",  "2.18e-20","+03.0","-04045","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H",    "C2H2",   "",     "",  "1.26e-18","-03.1","-00721","3.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C2H2",   "C2H3",   "",     "",  "3.30e-30","+00.0","-00740","1.40e-11","+00.0","-01300","3", 
+   "H",      "C2H3",   "H2",     "C2H2", "",  "6.86e-11","+00.0","+00023","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H3",   "C2H4",   "",     "",  "5.76e-24","-01.3","+00000","1.80e-10","+00.0","-00000","3", /* cf M05 */
+   "H",      "C2H4",   "C2H3",   "H2",   "",  "8.40e-17","+1.93","-06518","0.00e+00","+0.00","-00000","2", /* cf V05 */
+   "H",      "C2H4",   "C2H5",   "",     "",  "1.39e-29","+00.0","-00562","6.60e-15","+1.28","-00650","3", 
+   "H",      "C2H5",   "CH3",    "CH3",  "",  "1.20e-10","+00.0","-00000","0.00e+00","+00.0","+00000","2", /* Sillesen 93 */
+   "H",      "C2H5",   "H2",     "C2H4", "",  "3.00e-12","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H5",   "C2H6",   "",     "",  "5.50e-23","-2.00","-01040","1.66e-10","+00.0","+00000","3", 
+   "H",      "C2H6",   "H2",     "C2H5", "",  "2.40e-15","+01.5","-03730","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H2",   "C3H3",   "",     "",  "1.70e-23","-1.80","-00000","1.00e-10","+0.00","+00000","3", /* cf V05 */
+   "H",      "C3H3",   "CH3CCH", "",     "",  "9.40e-20","-3.30","-00000","1.00e-10","+0.00","+00000","3", /* cf M05 */
+   "H",      "C3H3",   "CH2CCH2","",     "",  "1.70e-25","-01.8","+00000","2.50e-10","+0.00","-00000","3", /* cf V05 */
+   "H",      "CH3CCH", "CH3",    "C2H2", "",  "8.00e-24","-02.0","-01225","9.63e-12","+00.0","-01560","3", /* cf W04 */
+   "H",      "CH3CCH", "C3H3",   "H2",   "",  "4.70e-16","+1.74","-03873","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "CH3CCH", "C3H5",   "",     "",  "4.40e-31","+00.0","-00000","6.00e-11","+00.0","-01233","3",  /* cf V05 */
+   "H",      "CH2CCH2","C2H2",   "CH3",  "",  "8.00e-24","-2.00","-01225","9.70e-13","+0.00","-01550","3", /* cf W04 */
+   "H",      "CH2CCH2","CH3CCH", "H",    "",  "1.30e-11","+0.00","-01156","0.00e+00","+0.00","-00000","2", /* cf V05 */
+   "H",      "CH2CCH2","C3H5",   "",     "",  "8.00e-24","+2.00","-01225","1.40e-11","+00.0","-01000","3",  /* cf V05 */
+   "H",      "C3H5",   "C2H3",   "CH3",  "",  "4.00e-12","+0.00","-00000","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "C3H5",   "CH2CCH2","H2",   "",  "1.40e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H5",   "CH3CCH", "H2",   "",  "1.40e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H5",   "C3H6",   "",     "",  "1.00e-24","+00.0","+00000","2.80e-10","+00.0","+00000","3",  /* cf V05 */
+   "H",      "C3H6",   "C3H5",   "H2",   "",  "2.87e-19","+02.5","-01254","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H6",   "CH3",    "C2H4", "",  "2.20e-11","+00.0","-01641","0.00e+00","+00.0","+00000","2",  /* M00 */
+   "H",      "C3H6",   "C3H7",   "",     "",  "1.30e-28","+00.0","-00380","9.47e-15","+1.16","-00440","3",  /* cf M05 */
+   "H",      "C3H7",   "C3H6",   "H2",   "",  "3.00e-12","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H7",   "C2H5",   "CH3",  "",  "6.00e-11","+0.00","-00000","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "C3H7",   "C3H8",   "",     "",  "2.50e-27","+0.00","-00000","2.50e-10","+0.00","-00000","3", /* cf M05 */
+   "H",      "C3H8",   "C3H7",   "H2",   "",  "2.20e-18","+2.54","-03400","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H",    "C4H2",   "",     "",  "1.26e-18","-03.1","-00721","3.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C4H2",   "C4H3",   "",     "",  "2.00e-26","+0.00","-00740","1.39e-10","+0.00","-01184","3", /* cf M05 */
+   "H",      "C4H3",   "C4H4",   "",     "",  "8.56e-10","+00.0","-00405","0.00e+00","+00.0","+00000","2",
+//   "H",      "C4H3",   "C4H4",   "",     "",  "1.50e-19","-03.0","-00300","8.56e-10","+00.0","-00405","3", /* cf M05 */
+   "H",      "C4H3",   "C4H2",   "H2",   "",  "1.20e-11","+00.0","-00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H3",   "C2H2",   "C2H2", "",  "3.30e-12","+00.0","-00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H4",   "C4H5",   "",     "",  "3.32e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+//   "H",      "C4H4",   "C4H5",   "",     "",  "8.76e-08","-7.00","-01390","3.32e-12","+0.00","+00000","3", /* cf W04 */
+   "H",      "C4H5",   "prod",   "",     "",  "1.50e-19","-03.0","-00300","1.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C4H6",   "H2",     "C4H5", "",  "1.05e-13","+0.70","-03019","0.00e+00","+0.00","+00000","2", /* Weisman 88 */
+   "H",      "C4H6",   "prod",   "",     "",  "7.70e-30","+0.00","-00380","8.50e-12","+0.00","-00000","3", /* cf V05 */
+   "H",      "C4H10",  "prod",   "H2",   "",  "3.50e-11","+0.00","-03970","0.00e+00","+0.00","-00000","2", /* cf V05 */
+//   "H",      "AC6H5",  "C4H2",   "C2H2", "",  "3.16e-05","-01.6","-01117","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "H",      "AC6H5",  "AC6H6",  "",     "",  "1.82e+28","-16.3","-03526","1.66e-10","+0.00","+00000","3", /* WetF 97 */
+   "H",      "AC6H6",  "AC6H5",  "H2",   "",  "4.15e-10","+0.00","-08057","0.00e+00","+0.00","+00000","2", /* WetF 97 */
+   "H2",     "CH",     "CH3",    "",     "",  "4.70e-26","-01.6","+00000","2.50e-10","-0.08","+00000","3", /* Brownsword 97 */
+   "H2",     "CH",     "3CH2",   "H",    "",  "3.10e-10","+0.00","-01650","0.00e+00","+00.0","+00000","2", 
+   "H2",     "1CH2",   "CH3",    "H",    "",  "1.20e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "H2",     "3CH2",   "CH3",    "H",    "",  "5.00e-15","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "H2",     "CH3",    "CH4",    "H",    "",  "1.14e-20","+2.74","-04740","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2",     "C2H",    "H",    "",  "1.77e-10","+0.00","-01470","0.00e+00","+00.0","+00000","2", /* cf V05,W04,M05 */
+   "H2",     "C2H",    "C2H2",   "H",    "",  "1.20e-11","+0.00","-00998","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2H3",   "H",      "C2H4", "",  "1.57e-20","+2.56","-02529","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2H5",   "C2H6",   "H",    "",  "5.11e-24","+03.6","-04253","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C3H5",   "H",      "C3H6", "",  "1.80e-19","+2.38","-09557","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C3H7",   "C3H8",   "H",    "",  "3.00e-21","+2.84","-04600","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C4H",    "C4H2",   "H",    "",  "9.20e-18","+2.17","-00478","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "H2",     "C4H5",   "C4H6",   "H",    "",  "6.61e-15","+0.50","-01864","0.00e+00","+0.00","+00000","2", /* Weisman 88 */
+   "H2",     "AC6H5",  "AC6H6",  "H",    "",  "9.48e-20","+2.43","-03159","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "CH",     "CH",     "C2H2",   "",     "",  "1.99e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH",     "CH4",    "C2H4",   "H",    "",  "3.96e-08","-1.04","-00036","0.00e+00","+00.0","+00000","2", 
+   "CH",     "C2H2",   "C3H2",   "H",    "",  "1.59e-09","-0.23","-00016","0.00e+00","+00.0","+00000","2", /* cf V05,W04,M05 */
+   "CH",     "C2H4",   "CH3CCH", "H",    "",  "3.90e-09","-0.55","-00029","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H4",   "CH2CCH2","H",    "",  "3.90e-09","-0.55","-00029","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H6",   "C2H4",   "CH3",  "",  "1.90e-08","-0.86","-00053","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H6",   "C3H6",   "H",    "",  "1.90e-08","-0.86","-00053","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "CH3CCH", "C4H4",   "H",    "",  "4.60e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Butler 81, cf M05 */
+   "CH",     "C3H8",   "prod",   "H",    "",  "1.90e-10","+0.00","+00240","0.00e+00","+00.0","+00000","2", 
+   "CH",     "C4H10",  "prod",   "",     "",  "4.40e-10","+0.00","+00028","0.00e+00","+00.0","+00000","2", /* Baulch 92 */
+   "1CH2",   "1CH2",   "C2H2",   "H",    "H", "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "1CH2",   "3CH2",   "C2H2",   "H",    "H", "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "CH3",    "C2H4",   "H",    "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "CH4",    "3CH2",   "CH4",  "",  "1.20e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "CH4",    "CH3",    "CH3",  "",  "5.90e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H",    "C2H2",   "CH",   "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H2",   "3CH2",   "C2H2", "",  "8.14e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H2",   "C3H3",   "H",    "",  "2.90e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H3",   "C2H2",   "CH3",  "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H4",   "3CH2",   "C2H4", "",  "2.30e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H4",   "C3H6",   "",     "",  "1.50e-18","-3.00","-00300","1.32e-10","+00.0","+00000","3", /* cf M05 */
+   "1CH2",   "C2H5",   "C2H4",   "CH3",  "",  "1.50e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H5",   "C3H6",   "H",    "",  "1.50e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H6",   "3CH2",   "C2H6", "",  "3.60e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H6",   "C2H5",   "CH3",  "",  "1.90e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H5",   "C4H6",   "H",    "",  "3.30e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H5",   "C2H4",   "C2H3", "",  "6.67e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H6",   "3CH2",   "C3H6", "",  "5.00e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Tsang 91 */
+   "1CH2",   "C3H6",   "C3H5",   "CH3",  "",  "8.70e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H7",   "C2H5",   "C2H4", "",  "4.29e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H7",   "C3H6",   "CH3",  "",  "1.71e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H8",   "C2H5",   "C2H5", "",  "1.60e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "N2",     "3CH2",   "N2",   "",  "1.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "3CH2",   "C2H2",   "H",    "H", "1.80e-10","+0.00","-00400","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "3CH2",   "C2H2",   "H2",   "",  "2.00e-11","-00.0","-00400","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "3CH2",   "CH3",    "C2H4",   "H",    "",  "7.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "CH4",    "CH3",    "CH3",  "",  "7.13e-12","+0.00","-05052","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "CH4",    "C2H6",   "",     "",  "3.50e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H",    "CH",     "C2H2", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H2",   "C3H2",   "H2",   "",  "1.00e-12","-00.0","-03332","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "3CH2",   "C2H2",   "C3H3",   "H",    "",  "2.00e-11","+0.00","-03330","0.00e+00","+00.0","+00000","2", /* cf W04,V05 */ 
+   "3CH2",   "C2H3",   "CH3",    "C2H2", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H4",   "C3H5",   "H",    "",  "5.31e-12","+0.00","-02658","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "3CH2",   "C2H5",   "CH3",    "C2H4", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H6",   "C3H8",   "",     "",  "8.13e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H6",   "CH3",    "C2H5", "",  "1.07e-11","+0.00","-03981","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H5",   "C4H6",   "H",    "",  "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H6",   "C3H5",   "CH3",  "",  "1.20e-12","+0.00","-03116","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H7",   "CH3",    "C3H6", "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H7",   "C2H4",   "C2H5", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H8",   "C4H10",  "",     "",  "8.13e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H8",   "C3H7",   "CH3",  "",  "1.50e-24","+3.65","-03600","0.00e+00","+00.0","+00000","2",  
+   "3CH2",   "C4H2",   "C4H",    "CH3",  "",  "2.16e-11","+0.00","-02165","0.00e+00","+00.0","+00000","2",  
+   "3CH2",   "C4H6"   ,"CH3CCH", "C2H4", "",  "6.14e-12","+0.00","-01731","0.00e+00","+0.00","+00000","2", /* Kraus 93 */
+   "3CH2",   "C4H10",  "prod",   "",     "",  "4.30e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "CH3",    "CH3",    "C2H5",   "H",    "",  "8.28e-12","0.099","-05335","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "CH3",    "C2H6",   "",     "",  "1.65e-04","-8.75","-00985","1.17e-10","+0.00","-00000","3", /* Cody 03 */
+   "CH3",    "C2H",    "C3H3",   "H",    "",  "4.00e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H2",   "CH3CCH", "H",    "",  "3.18e-20","+2.42","-06488","0.00e+00","+0.00","+00000","2", /* Diau 94 */
+   "CH3",    "C2H2",   "C3H5",   "",     "",  "3.30e-30","+0.00","-00740","1.00e-12","+0.00","-03900","3", /* cf V05 */
+   "CH3",    "C2H3",   "C2H2",   "CH4",  "",  "3.40e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H3",   "C3H6",   "",     "",  "5.00e-27","+0.00","-00000","1.10e-10","+0.00","+00000","3", /* cf M05 */
+   "CH3",    "C2H4",   "C2H3",   "CH4",  "",  "1.10e-23","+03.7","-04780","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H4",   "C3H7",   "",     "",  "1.39e-29","+00.0","-00562","3.50e-13","+00.0","-03700","3", /* cf V05 */
+   "CH3",    "C2H5",   "CH4",    "C2H4", "",  "3.25e-11","-0.50","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H5",   "C3H8",   "",     "",  "1.01e+20","-16.1","-01897","8.12e-10","-0.50","+00000","3", 
+   "CH3",    "C2H6",   "CH4",    "C2H5", "",  "2.50e-31","+6.00","-03043","0.00e+00","+00.0","+00000","2", 
+//   "CH3",    "C3H3",   "C4H6",   "",     "",  "3.50e-06","-07.0","-01390","6.80e-11","+00.0","+00130","3", /* cf V05 */ 
+   "CH3",    "CH3CCH", "C2H6",   "C2H",  "",  "8.32e-13","+00.0","-04428","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "CH2CCH2","C2H5",   "C2H2", "",  "3.32e-13","+00.0","-04076","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H5",   "CH2CCH2","CH4",  "",  "5.00e-12","-0.32","+00066","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H5",   "prod",   "",     "",  "1.28e-30","-0.32","+00066","1.69e-10","-0.32","+00066","3", /* cf W04 */
+   "CH3",    "C3H6",   "CH4",    "C3H5", "",  "2.66e-13","+00.0","-04440","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H6",   "prod",   "",     "",  "7.70e-29","+0.00","-00380","1.19e-13","+00.0","-03330","3", /* cf V05 */
+   "CH3",    "C3H7",   "C4H10",  "",     "",  "8.63e+28","-18.5","-02307","3.20e-10","-0.32","+00000","3", 
+   "CH3",    "C3H7",   "C3H6",   "CH4",  "",  "1.90e-11","-0.32","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H8",   "C3H7",   "CH4",  "",  "1.50e-24","+3.65","-03600","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C4H4",   "C4H3",   "CH4",  "",  "6.61e-13","+0.00","-02502","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C4H6",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","1.30e-13","+00.0","-02060","3", /* cf V05 */
+   "CH3",    "C4H10",  "prod",   "CH4",  "",  "6.60e-13","-00.0","-04840","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "CH4",    "C2",     "CH3CCH", "",     "",  "1.70e-11","+0.00","-02805","0.00e+00","+00.0","+00000","2",  /* Baulch 92 (3C2) */
+   "CH4",    "C2",     "CH3",    "C2H",  "",  "5.05e-11","+0.00","-00297","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C2H",    "C2H2",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C2H3",   "C2H4",   "CH3",  "",  "2.40e-24","+4.02","-02754","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C2H5",   "C2H6",   "CH3",  "",  "1.43e-25","+4.14","-06322","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C3H5",   "C3H6",  "CH3",   "",  "6.60e-23","+3.40","-11670","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "CH4",    "C3H7",   "C3H8",   "CH3",  "",  "4.00e-26","+4.02","-05473","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C4H",    "C4H2",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2", /* pas de 1/3 */
+   "CH4",    "AC6H5",  "AC6H6",  "CH3",  "",  "3.32e-12","+0.00","-04329","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "C2",     "C2H2",   "C2H",    "C2H",  "",  "4.30e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Baulch 92 (1C2) */
+   "C2",     "C2H4",   "C2H",    "C2H3", "",  "3.30e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Baulch 92 (1C2) */
+   "C2",     "C2H6",   "C2H",    "C2H5", "",  "1.60e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Baulch 92 (1C2) */
+   "C2",     "C3H8",   "C3H7",   "C2H",  "",  "3.30e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Baulch 92 (1C2) */
+   "C2",     "AC6H6",  "soot",   "",     "",  "5.20e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Reisler 80 */
+   "C2H",    "C2H",    "C2H2",   "C2",   "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H2",   "C4H2",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H2",   "C4H",    "H2",   "",  "8.60e-18","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* Ralf Kaiser */
+   "C2H",    "C2H3",   "C2H2",   "C2H2", "",  "1.60e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H4",   "C4H4",   "H",    "",  "7.80e-11","+0.00","+00134","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H5",   "C3H3",   "CH3",  "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H5",   "C2H2",   "C2H4", "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H6",   "C2H2",   "C2H5", "",  "5.10e-11","+0.00","-00076","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H",    "CH3CCH", "C4H2",  "CH3",   "",  "1.60e-10","+0.00","+00071","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H",    "CH2CCH2","C2H2",  "C3H3",  "",  "1.30e-10","+0.00","+00103","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H",    "C3H5",   "CH2CCH2","C2H2", "",  "1.20e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H6",   "prod",   "H",    "",  "2.00e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H7",   "C3H3",   "C2H5", "",  "2.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H7",   "C3H6",   "C2H2", "",  "1.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H8",   "C3H7",   "C2H2", "",  "9.80e-11","+0.00","-00071","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C4H6",   "AC6H6",  "H",    "",  "3.30e-10","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C2H",    "C4H10",  "prod",   "C2H2", "",  "1.20e-10","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C2H",    "AC6H6",  "soot",   "H",    "",  "8.20e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* WandF 97 */
+   "C2H2",   "C2H3",   "C4H4",   "H",    "",  "3.32e-12","+0.00","-02516","0.00e+00","+00.0","+00000","2", 
+   "C2H2",   "C2H3",   "C4H5",   "",     "",  "8.20e-30","+0.00","-00352","4.16e-19","+1.90","-01058","3", /* cf M05 */
+   "C2H2",   "C2H5",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","5.60e-14","+00.0","-03520","3", /* cf V05 */ 
+   "C2H2",   "C3H5",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","5.30e-14","+0.00","-03500","3", /* cf V05 */ 
+   "C2H2",   "C3H7",   "C3H5",   "C2H4", "",  "1.20e-12","+0.00","-04531","0.00e+00","+00.0","+00000","2", 
+   "C2H2",   "C4H",    "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* pas de 1/3 */
+   "C2H2",   "C4H3",   "soot",   "",     "",  "2.00e-16","+0.00","-00000","0.00e+00","+0.00","+00000","2", 
+   "C2H2",   "C4H5",   "AC6H6",  "H",    "",  "3.50e-09","-1.07","-02417","0.00e+00","+0.00","+00000","2", /* WetF 94 */
+   "C2H2",   "C4H5",   "AC6H6",  "H",    "",  "4.20e-19","+1.80","-00602","0.00e+00","+0.00","+00000","2", /* Weismann 88 */
+   "C2H2",   "AC6H5",  "soot",    "",    "",  "3.72e-13","+0.00","-01561","0.00e+00","+0.00","+00000","2", /* Yu 94 */
+   "C2H3",   "C2H3",   "C4H6",   "",     "",  "5.00e-18","-3.75","-00300","1.40e-10","+00.0","+00000","3", /* cf M05 */ 
+   "C2H3",   "C2H3",   "C2H2",   "C2H4", "",  "2.40e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C2H3",   "C2H4",   "C4H6",   "H",    "",  "8.30e-13","+0.00","-03676","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C3H5",   "CH3",  "",  "6.10e-47","+11.2","+03289","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C2H4",   "C2H4", "",  "8.00e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C2H2",   "C2H6", "",  "8.00e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "prod",   "",     "",  "1.90e-27","+0.00","+00000","2.50e-11","+00.0","+00000","3", /* cf W04 */
+   "C2H3",   "C2H6",   "C2H4",   "C2H5", "",  "9.98e-22","+3.30","-05285","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "CH2CCH2","C2H4", "",  "4.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "C3H6",   "C2H2", "",  "8.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "prod",   "H",    "H", "8.00e-11","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H3",   "C3H6",   "CH3",    "C4H6", "",  "1.20e-12","+0.00","-02520","0.00e+00","+00.0","+00000","2",
+   "C2H3",   "C3H6",   "C2H4",   "C3H5", "",  "3.68e-24","+3.50","-02356","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H6",   "prod",   "H",    "",  "1.20e-12","+0.00","-03240","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H3",   "C3H7",   "C2H4",   "C3H6", "",  "2.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H7",   "C3H8",   "C2H2", "",  "2.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H7",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","1.60e-11","+00.0","+00000","3", /* cf V05 */
+   "C2H3",   "C3H8",   "C3H7",   "C2H4", "",  "1.00e-21","+3.30","-05285","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C4H3",   "AC6H6",  "",     "",  "4.77e-10","+0.00","-00411","0.00e+00","+0.00","+00000","2", /* Duran 88 */
+   "C2H3",   "C4H5",   "AC6H6",  "H2",   "",  "3.05e-37","+7.07","-01817","0.00e+00","+0.00","+00000","2", /* Westmoreland 89 */
+   "C2H3",   "C4H6",   "prod",   "",     "",  "1.50e-14","-5.84","-02363","2.45e-12","-0.17","-01630","3", /* cf V05 */
+   "C2H4",   "C2H5",   "C2H3",   "C2H6", "",  "1.05e-21","+3.13","-09063","0.00e+00","+00.0","+00000","2", 
+   "C2H4",   "C3H5",   "prod",   "H",    "",  "1.00e-14","+0.00","-05776","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H4",   "C3H7",   "prod",   "",     "",  "7.70e-30","+0.00","-00380","1.80e-13","+00.0","-03670","3", /* cf V05 */
+   "C2H4",   "C4H",    "C4H2",   "C2H3", "",  "4.60e-11","+0.00","+00025","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "C2H4",   "AC6H5",  "prod",   "H",    "",  "1.20e-12","+0.00","-02250","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "C2H5",   "C2H5",   "C4H10",  "",     "",  "6.59e-06","-6.39","-00301","1.26e-11","+00.0","-00096","3", 
+   "C2H5",   "C2H5",   "C2H6",   "C2H4", "",  "2.40e-12","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* Baulch 92 */
+   "C2H5",   "CH2CCH2","C2H6",   "C3H3", "",  "5.25e-13","+0.00","-04579","0.00e+00","+0.00","+00000","2", /* Getty 67 */
+   "C2H5",   "C3H5",   "CH2CCH2","C2H6", "",  "1.60e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H5",   "C3H6",   "C2H4", "",  "4.30e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H5",   "prod",   "",     "",  "3.50e-07","-07.0","-01390","3.30e-11","+00.0","+00066","3", /* cf V05 */ 
+   "C2H5",   "C3H6",   "C2H6",   "C3H5", "",  "3.70e-24","+3.50","-03340","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H6",   "prod",   "",     "",  "7.70e-30","-00.0","-00380","1.70e-13","+00.0","+03625","3", /* cf V05 */ 
+   "C2H5",   "C3H7",   "C2H6",   "C3H6", "",  "2.40e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H7",   "C3H8",   "C2H4", "",  "1.90e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H7",   "prod",   "",     "",  "9.70e+28","-18.5","-02307","3.30e-11","+00.0","+00000","3", /* cf V05 */
+   "C2H5",   "C3H8",   "C3H7",   "C2H6", "",  "1.50e-24","+3.65","-04600","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C3H5",   "C2H5",   "C3H6", "",  "3.90e-22","+3.30","-09986","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C3H7",   "C3H8",   "C2H5", "",  "4.20e-25","+3.82","-04550","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C4H",    "C4H2",   "C2H5", "",  "3.50e-11","+0.00","+00003","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "C3H3",   "C3H3",   "AC6H6",  "",     "",  "6.00e-28","+0.00","+01680","1.20e-10","+0.00","+00000","3", /* Moses 00, Morter 94 */
+   "C3H3",   "C3H5",   "prod",   "",     "",  "2.90e-11","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C3H3",   "C4H2",   "CH3CCH", "C4H",  "",  "1.00e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Alkernade 89 */
+   "C3H5",   "C3H5",   "CH2CCH2","C3H6", "",  "1.40e-13","+0.00","+00132","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H5",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","1.70e-11","+0.00","+00132","3",  /* cf V05 */
+   "C3H5",   "C3H6",   "C2H5",   "C4H4", "",  "1.00e-14","+0.00","-05776","0.00e+00","+0.00","+00000","2", /* Tsang 91 */
+   "C3H5",   "C3H7",   "C3H6",   "C3H6", "",  "2.40e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H7",   "CH2CCH2","C3H8", "",  "1.20e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H7",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","3.40e-11","+0.00","+00066","3",  /* cf V05 */
+   "C3H5",   "C3H8",   "C3H7",   "C3H6", "",  "3.90e-22","+3.30","-09986","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C4H10",  "C3H6",  "prod",  "",  "7.00e-23","+3.30","-07800","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C3H6",   "C3H7",   "C3H5",   "C3H8", "",  "3.70e-24","+3.50","-03340","0.00e+00","+00.0","+00000","2", 
+   "C3H7",   "C3H7",   "C3H8",   "C3H6", "",  "2.80e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C3H7",   "C3H7",   "prod",   "",     "",  "2.90e-21","+0.00","+00000","1.70e-11","+00.0","+00000","3", /* cf V05 */
+   "C4H",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",  /* pad de 1/3 */
+   "C4H2s",  "",       "C4H2",   "",     "",  "1.00e+01","+0.00","+00000","0.00e+00","+00.0","+00000","1", 
+   "C4H2s",  "N2",     "C4H2",   "N2",   "",  "1.40e-15","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C4H2s",  "C2H2",   "prod",   "H",    "H", "3.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C2H4",   "prod",   "H",    "H", "4.20e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "H",    "H", "1.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "CH3",  "H", "2.30e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "C2H2", "",  "2.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "C2H3", "",  "8.70e-14","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "H",    "H", "1.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "CH3",  "H", "4.10e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "C2H2", "",  "2.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "C2H3", "",  "4.90e-14","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H2",   "prod",   "C2H2", "",  "8.20e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H2",   "prod",   "H",    "H", "1.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "soot",   "H",    "",  "9.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "AC6H6",  "C2H2", "",  "8.80e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "prod",   "C2H4", "",  "3.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C4H3",   "C4H3",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","7.00e-11","+0.00","+00000","3", /* cf V05 */
+   "C4H4",   "C4H4",   "prod",   "",     "",  "7.25e-14","+0.00","-09261","0.00e+00","+00.0","+00000","2", 
+   "AC6H5",  "AC6H6",  "prod",   "",     "",  "1.59e-12","+0.00","-02168","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+
+   "N4S",    "N4S",    "N2",     "",     "",  "8.27e-34","+0.00","+00490","0.00e+00","+00.0","+00000","3",
+   "N4S",    "CH",     "CN",     "H",    "",  "2.67e-10","-0.09","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3",    "HCN",    "H2",   "",  "6.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3",    "H2CN",   "H",    "",  "5.60e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+/*   "N4S",    "C2H2",   "CH2CN",  "",     "",  "1.70e-14","+0.00","+00000","0.00e+00","+0.00","+00000","2",  Sato 74 */
+   "N4S",    "C2H3",   "CH3CN",  "",     "",  "3.08e-12","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Payne 96 */
+   "N4S",    "C2H3",   "CH2CN",  "H",    "",  "6.16e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Payne 96 */
+   "N4S",    "C2H4",   "CH3",    "HCN",  "",  "3.32e-14","+0.00","-00352","0.00e+00","+0.00","+00000","2", /* Kerr 72 */
+   "N4S",    "C2H5",   "HCN",    "CH4",  "",  "1.10e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Stief 95 */
+   "N4S",    "C2H6",   "prod",   "",     "",  "0.00e-00","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3CCH", "CHCN",   "CH3",  "",  "1.15e-13","+0.00","-00745","0.00e+00","+0.00","+00000","2", /* Kerr 72 */
+   "N4S",    "C3H6",   "HCN",    "C2H4", "H", "2.49e-13","+0.00","-00830","0.00e+00","+0.00","+00000","2", /* Paraskevopoulos 67 */
+   "N4S",    "C3H8",   "HCN",    "C2H6", "H", "3.39e-13","+0.00","-02563","0.00e+00","+0.00","+00000","2", /* Onyzchuk 53 */
+   "N4S",    "C4H10",  "C3H8",   "HCN",  "H", "2.97e-14","+0.00","-01813","0.00e+00","+0.00","+00000","2", /* Back 54 */
+   "N4S",    "H2CN",   "HCN",    "prod", "",  "1.00e-10","+0.00","-00200","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CHCN",   "NCCN",   "H",    "",  "6.00e-15","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Safrany 68 */
+   "N4S",    "CH3CN",  "HCN",    "HCN",  "H", "2.28e-15","+0.00","-00813","0.00e+00","+0.00","+00000","2", /* Forst 57 */
+   "CN",     "H",      "HCN",    "",     "",  "2.40e-24","-2.20","-00567","2.99e-09","-0.50","+00000","3", /* Tsang 92 */
+   "CN",     "H2",     "HCN",    "H",    "",  "2.23e-21","+3.31","-00756","0.00e+00","+00.0","+00000","2",
+   "CN",     "CH4",    "HCN",    "CH3",  "",  "4.64e-16","+1.53","-00504","0.00e+00","+00.0","+00000","2", /* est, Yang 93 */
+   "CN",     "CH4",    "CH3CN",  "H",    "",  "5.15e-17","+1.53","-00504","0.00e+00","+0.00","+00000","2", /* est, Yang 93 */
+   "CN",     "C2H2",   "HC3N",   "H",    "",  "5.67e-09","-0.55","-00004","0.00e+00","+00.0","+00000","2",
+   "CN",     "C2H6",   "HCN",    "C2H5", "",  "5.91e-12","+0.22","+00058","0.00e+00","+00.0","+00000","2",
+   "CN",     "CH3CCH", "HC3N",   "CH3",  "",  "2.10e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Sayah 88 */
+   "CN",     "CH2CCH2","HCN",    "C3H3", "",  "2.63e-10","+0.00","+00167","0.00e+00","+0.00","+00000","2", /* Butterfield 93 */
+   "CN",     "C3H6",   "prod",   "H",    "",  "1.73e-10","+0.00","+00102","0.00e+00","+0.00","+00000","2", /* Sims 93 */
+   "CN",     "C3H8",   "C3H7",   "HCN",  "",  "2.44e-14","+1.19","+00378","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "C4H2",   "HC3N",   "C2H",  "",  "5.26e-09","-0.52","-00019","0.00e+00","+0.00","+00000","2", /* est. Sims 93 */
+   "CN",     "C4H4",   "C4H3",   "HCN",  "",  "1.07e-07","-0.82","-00228","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "CN",     "NCCN",   "",     "",  "9.44e-23","-2.61","+00000","9.40e-12","+0.00","+00000","3", /* Tsang 92 */
+   "CN",     "HCN",    "NCCN",   "H",    "",  "2.51e-17","+1.71","-00770","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "CH3CN",  "NCCN",   "CH3",  "",  "6.46e-11","+0.00","-01190","0.00e+00","+0.00","+00000","2", /* Zabarnick 89 */
+   "CN",     "NCCN",   "prod",   "",     "",  "2.19e-21","+2.70","-00325","0.00e+00","+00.0","+00000","2",
+   "CN",     "HC3N",   "C4N2",   "H",    "",  "1.70e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Halpern 89 */
+   "CN",     "C4N2",   "NCCN",   "C3N",  "",  "5.40e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Seki 96 */
+   "HCN",    "H",      "H2CN",   "",     "",  "4.40e-24","-2.73","-03855","5.50e-11","+00.0","-02438","3",
+   "HCN",    "CH",     "CHCN",   "H",    "",  "5.00e-11","+0.00","+00500","0.00e+00","+0.00","+00000","2", /* Zabarnick 91 */
+   "HCN",    "C2H",    "H",      "HC3N", "",  "5.26e-12","+0.00","-00770","0.00e+00","+00.0","+00000","2",
+   "HCN",    "H2CN",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "H",      "HCN",    "H2",   "",  "1.40e-10","+0.00","-00200","0.00e+00","+00.0","+00000","2",
+   "H2CN",   "H2CN",   "prod",   "HCN",  "",  "1.16e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Horne 70 */
+   "H2CN",   "CH3CN",  "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "NCCN",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "HC3N",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "N2",     "CH",     "prod",   "",     "",  "3.80e-25","-2.60","+00000","9.65e-11","-0.15","+00000","3", /* Fulle 96 */
+   "CHCN",   "H2",     "CH3CN",  "",     "",  "1.00e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Adamson 97 */
+   "CH2CN",  "CH2CN",  "C2H4",   "NCCN", "",  "1.80e-11","+0.00","-00769","0.00e+00","+0.00","+00000","2", /* est, Hoobler 97 */
+   "CH3CN",  "H",      "CH3",    "HCN",  "",  "3.39e-12","+0.00","-03954","0.00e+00","+0.00","+00000","2", /* Jamieson 70 */
+   "CH3CN",  "H",      "CH4",    "CN",   "",  "1.66e-13","+0.00","-01505","0.00e+00","+0.00","+00000","2", /* Jamieson 70 */
+   "CH3CN",  "C2H",    "HC3N",   "CH3",  "",  "1.80e-11","+0.00","-00769","0.00e+00","+0.00","+00000","2", /* Hoobler 97 */
+   "C3N",    "H2",     "HC3N",   "H",    "",  "1.20e-11","+0.00","-00998","0.00e+00","+00.0","+00000","2",
+   "C3N",    "CH4",    "HC3N",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H4",   "prod",   "H",    "",  "7.80e-11","+0.00","+00134","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H6",   "HC3N",   "C2H5", "",  "3.50e-11","+0.00","+00002","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C3H8",   "C3H7",   "HC3N", "",  "6.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "C3N",    "HC3N",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "H",      "HCN",    "C2H2", "",  "1.00e-28","+0.00","-00740","0.55e-12","+00.0","-00500","3",
+   "HC3N",   "C2H",    "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "C4H",    "prod",   "H",    "",  "2.90e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "C4H3",   "soot",   "",     "",  "1.20e-15","+0.00","-00000","0.00e+00","+0.00","+00000","2",
Index: /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit_051006
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit_051006	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit_051006	(revision 1644)
@@ -0,0 +1,388 @@
+   "H2",     "HV",     "H",      "H",    "",  "","","","","","","",  /* 1 */
+   "CH3",    "HV",     "1CH2",   "H",    "",  "","","","","","","",  /* 2 */
+   "CH4",    "HV",     "1CH2",   "H2",   "",  "","","","","","","",  /* 3 */
+   "CH4",    "HV",     "CH",     "H2",   "H", "","","","","","","",  /* 4 */
+   "CH4",    "HV",     "CH3",    "H",    "",  "","","","","","","",  /* 5 */
+   "C2H2",   "HV",     "C2H",    "H",    "",  "","","","","","","",  /* 6 */
+   "C2H2",   "HV",     "C2",     "H2",   "",  "","","","","","","",  /* 7 */
+   "C2H4",   "HV",     "C2H2",   "H2",   "",  "","","","","","","",  /* 8 */
+   "C2H4",   "HV",     "C2H2",   "H",    "H", "","","","","","","",  /* 9 */
+   "C2H6",   "HV",     "C2H4",   "H2",   "",  "","","","","","","",  /* 10 */
+   "C2H6",   "HV",     "C2H4",   "H",    "H", "","","","","","","",  /* 11 */
+   "C2H6",   "HV",     "C2H2",   "H2",   "H2","","","","","","","",  /* 12 */
+   "C2H6",   "HV",     "CH4",    "1CH2", "",  "","","","","","","",  /* 13 */
+   "C2H6",   "HV",     "CH3",    "CH3",  "",  "","","","","","","",  /* 14 */
+   "C3H3",   "HV",     "C3H2",   "H",    "",  "","","","","","","",  /* 15 */
+   "CH2CCH2","HV",     "C3H3",   "H",    "",  "","","","","","","",  /* 16 */
+   "CH2CCH2","HV",     "C3H2",   "H2",   "",  "","","","","","","",  /* 17 */
+   "CH3CCH", "HV",     "C3H3",   "H",    "",  "","","","","","","",  /* 18 */
+   "CH3CCH", "HV",     "C3H2",   "H2",   "",  "","","","","","","",  /* 19 */
+   "C3H6",   "HV",     "CH2CCH2","H",    "H", "","","","","","","",  /* 20 */
+   "C3H6",   "HV",     "CH3CCH", "H",    "H", "","","","","","","",  /* 21 */
+   "C3H6",   "HV",     "C2H4",   "3CH2", "",  "","","","","","","",  /* 22 */
+   "C3H6",   "HV",     "C2H3",   "CH3",  "",  "","","","","","","",  /* 23 */
+   "C3H6",   "HV",     "C2H2",   "CH4",  "",  "","","","","","","",  /* 24 */
+   "C3H8",   "HV",     "C3H6",   "H2",   "",  "","","","","","","",  /* 25 */
+   "C3H8",   "HV",     "C2H6",   "1CH2", "",  "","","","","","","",  /* 26 */
+   "C3H8",   "HV",     "C2H5",   "CH3",  "",  "","","","","","","",  /* 27 */
+   "C3H8",   "HV",     "C2H4",   "CH4",  "",  "","","","","","","",  /* 28 */
+   "C4H2",   "HV",     "C4H",    "H",    "",  "","","","","","","",  /* 29 */
+   "C4H2",   "HV",     "C2H",    "C2H",  "",  "","","","","","","",  /* 30 */
+   "C4H2",   "HV",     "C2H2",   "C2",   "",  "","","","","","","",  /* 31 */
+   "C4H2",   "HV",     "C4H2s",  "",     "",  "","","","","","","",  /* 32 */
+   "C4H4",   "HV",     "C4H2",   "H2",   "",  "","","","","","","",  /* 33 */
+   "C4H4",   "HV",     "C2H2",   "C2H2", "",  "","","","","","","",  /* 34 */
+   "C4H6",   "HV",     "C4H4",   "H2",   "",  "","","","","","","",  /* 35 */
+   "C4H6",   "HV",     "C2H4",   "C2H2", "",  "","","","","","","",  /* 36 */
+   "C4H6",   "HV",     "CH3",    "C3H3", "",  "","","","","","","",  /* 37 */
+   "C4H10",  "HV",     "C3H5",   "CH3",  "H2","","","","","","","",  /* 38 */
+   "C4H10",  "HV",     "C2H4",   "C2H4", "H2","","","","","","","",  /* 39 */
+   "C4H10",  "HV",     "C3H6",   "CH4",  "",  "","","","","","","",  /* 40 */
+   "C4H10",  "HV",     "C3H6",   "CH3",  "H", "","","","","","","",  /* 41 */
+   "C4H10",  "HV",     "C2H4",   "C2H6", "",  "","","","","","","",  /* 42 */
+   "C4H10",  "HV",     "C2H2",   "C2H6", "H2","","","","","","","",  /* 43 */
+   "C4H10",  "HV",     "CH3",    "C3H7", "",  "","","","","","","",  /* 44 */
+   "C4H10",  "HV",     "C2H5",   "C2H5", "",  "","","","","","","",  /* 45 */
+
+   "AC6H6",  "HV",     "prod",   "CH3",  "",  "","","","","","","",  /* 46 */
+   "AC6H6",  "HV",     "AC6H5",  "H",    "",  "","","","","","","",  /* 47 */
+
+   "N2",     "HV",     "N4S",    "N4S",  "",  "","","","","","","",  /* 48 */
+   "HCN",    "HV",     "H",      "CN",   "",  "","","","","","","",  /* 49 */
+   "HC3N",   "HV",     "C2H",    "CN",   "",  "","","","","","","",  /* 50 */
+   "HC3N",   "HV",     "H",      "C3N",  "",  "","","","","","","",  /* 51 */
+   "NCCN",   "HV",     "CN",     "CN",   "",  "","","","","","","",  /* 52 */
+   "CH3CN",  "HV",     "CH3",    "CN",   "",  "","","","","","","",  /* 53 */
+   "C4N2",   "HV",     "C3N",    "CN",   "",  "","","","","","","",  /* 54 */
+
+   "N2",     "",       "N4S",    "N4S",  "",  "0.00e+00","+00.0","+00000","0.00e+00","+00.0","+00000","1", 
+
+   "H",      "H",      "H2",     "",     "",  "2.70e-31","-00.6","+00000","1.00e-11","+00.0","+00000","3", /* Baulch92 */
+   "H",      "1CH2",   "CH",     "H2",   "",  "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "3CH2",   "H2",     "CH",   "",  "3.54e-11","+0.32","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "3CH2",   "CH3",    "",     "",  "1.70e-25","-01.8","+00000","3.50e-11","+0.32","-00000","3", /* cf V05 */
+   "H",      "CH3",    "CH4",    "",     "",  "6.33e-21","-2.98","-00635","2.63e-08","-0.60","-00189","3", 
+   "H",      "CH3",    "H2",     "3CH2", "",  "1.00e-10","+00.0","-07600","0.00e+00","+00.0","+00000","2", 
+   "H",      "CH4",    "H2",     "CH3",  "",  "2.18e-20","+03.0","-04045","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H",    "C2H2",   "",     "",  "1.26e-18","-03.1","-00721","3.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C2H2",   "C2H3",   "",     "",  "3.30e-30","+00.0","-00740","1.40e-11","+00.0","-01300","3", 
+   "H",      "C2H3",   "H2",     "C2H2", "",  "6.86e-11","+00.0","+00023","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H3",   "C2H4",   "",     "",  "5.76e-24","-01.3","+00000","1.80e-10","+00.0","-00000","3", /* cf M05 */
+   "H",      "C2H4",   "C2H3",   "H2",   "",  "8.40e-17","+1.93","-06518","0.00e+00","+0.00","-00000","2", /* cf V05 */
+   "H",      "C2H4",   "C2H5",   "",     "",  "1.39e-29","+00.0","-00562","6.60e-15","+1.28","-00650","3", 
+   "H",      "C2H5",   "CH3",    "CH3",  "",  "1.20e-10","+00.0","-00000","0.00e+00","+00.0","+00000","2", /* Sillesen 93 */
+   "H",      "C2H5",   "H2",     "C2H4", "",  "3.00e-12","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H5",   "C2H6",   "",     "",  "5.50e-23","-2.00","-01040","1.66e-10","+00.0","+00000","3", 
+   "H",      "C2H6",   "H2",     "C2H5", "",  "2.40e-15","+01.5","-03730","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H2",   "C3H3",   "",     "",  "1.70e-23","-1.80","-00000","1.00e-10","+0.00","+00000","3", /* cf V05 */
+   "H",      "C3H3",   "CH3CCH", "",     "",  "9.40e-20","-3.30","-00000","1.00e-10","+0.00","+00000","3", /* cf M05 */
+   "H",      "C3H3",   "CH2CCH2","",     "",  "1.70e-25","-01.8","+00000","2.50e-10","+0.00","-00000","3", /* cf V05 */
+   "H",      "CH3CCH", "CH3",    "C2H2", "",  "8.00e-24","-02.0","-01225","9.63e-12","+00.0","-01560","3", /* cf W04 */
+   "H",      "CH3CCH", "C3H3",   "H2",   "",  "4.70e-16","+1.74","-03873","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "CH3CCH", "C3H5",   "",     "",  "4.40e-31","+00.0","-00000","6.00e-11","+00.0","-01233","3",  /* cf V05 */
+   "H",      "CH2CCH2","C2H2",   "CH3",  "",  "8.00e-24","-2.00","-01225","9.70e-13","+0.00","-01550","3", /* cf W04 */
+   "H",      "CH2CCH2","CH3CCH", "H",    "",  "1.30e-11","+0.00","-01156","0.00e+00","+0.00","-00000","2", /* cf V05 */
+   "H",      "CH2CCH2","C3H5",   "",     "",  "8.00e-24","+2.00","-01225","1.40e-11","+00.0","-01000","3",  /* cf V05 */
+   "H",      "C3H5",   "C2H3",   "CH3",  "",  "4.00e-12","+0.00","-00000","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "C3H5",   "CH2CCH2","H2",   "",  "1.40e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H5",   "CH3CCH", "H2",   "",  "1.40e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H5",   "C3H6",   "",     "",  "1.00e-24","+00.0","+00000","2.80e-10","+00.0","+00000","3",  /* cf V05 */
+   "H",      "C3H6",   "C3H5",   "H2",   "",  "2.87e-19","+02.5","-01254","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H6",   "CH3",    "C2H4", "",  "2.20e-11","+00.0","-01641","0.00e+00","+00.0","+00000","2",  /* M00 */
+   "H",      "C3H6",   "C3H7",   "",     "",  "1.30e-28","+00.0","-00380","9.47e-15","+1.16","-00440","3",  /* cf M05 */
+   "H",      "C3H7",   "C3H6",   "H2",   "",  "3.00e-12","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H7",   "C2H5",   "CH3",  "",  "6.00e-11","+0.00","-00000","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "C3H7",   "C3H8",   "",     "",  "2.50e-27","+0.00","-00000","2.50e-10","+0.00","-00000","3", /* cf M05 */
+   "H",      "C3H8",   "C3H7",   "H2",   "",  "2.20e-18","+2.54","-03400","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H",    "C4H2",   "",     "",  "1.26e-18","-03.1","-00721","3.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C4H2",   "C4H3",   "",     "",  "2.00e-26","+0.00","-00740","1.39e-10","+0.00","-01184","3", /* cf M05 */
+   "H",      "C4H3",   "C4H4",   "",     "",  "8.56e-10","+00.0","-00405","0.00e+00","+00.0","+00000","2",
+//   "H",      "C4H3",   "C4H4",   "",     "",  "1.50e-19","-03.0","-00300","8.56e-10","+00.0","-00405","3", /* cf M05 */
+   "H",      "C4H3",   "C4H2",   "H2",   "",  "1.20e-11","+00.0","-00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H3",   "C2H2",   "C2H2", "",  "3.30e-12","+00.0","-00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H4",   "C4H5",   "",     "",  "3.32e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+//   "H",      "C4H4",   "C4H5",   "",     "",  "8.76e-08","-7.00","-01390","3.32e-12","+0.00","+00000","3", /* cf W04 */
+   "H",      "C4H5",   "prod",   "",     "",  "1.50e-19","-03.0","-00300","1.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C4H6",   "H2",     "C4H5", "",  "1.05e-13","+0.70","-03019","0.00e+00","+0.00","+00000","2", /* Weisman 88 */
+   "H",      "C4H6",   "prod",   "",     "",  "7.70e-30","+0.00","-00380","8.50e-12","+0.00","-00000","3", /* cf V05 */
+   "H",      "C4H10",  "prod",   "H2",   "",  "3.50e-11","+0.00","-03970","0.00e+00","+0.00","-00000","2", /* cf V05 */
+//   "H",      "AC6H5",  "C4H2",   "C2H2", "",  "3.16e-05","-01.6","-01117","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "H",      "AC6H5",  "AC6H6",  "",     "",  "1.82e+28","-16.3","-03526","1.66e-10","+0.00","+00000","3", /* WetF 97 */
+   "H",      "AC6H6",  "AC6H5",  "H2",   "",  "4.15e-10","+0.00","-08057","0.00e+00","+0.00","+00000","2", /* WetF 97 */
+   "H2",     "CH",     "CH3",    "",     "",  "4.70e-26","-01.6","+00000","2.50e-10","-0.08","+00000","3", /* Brownsword 97 */
+   "H2",     "CH",     "3CH2",   "H",    "",  "3.10e-10","+0.00","-01650","0.00e+00","+00.0","+00000","2", 
+   "H2",     "1CH2",   "CH3",    "H",    "",  "1.20e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "H2",     "3CH2",   "CH3",    "H",    "",  "5.00e-15","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "H2",     "CH3",    "CH4",    "H",    "",  "1.14e-20","+2.74","-04740","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2",     "C2H",    "H",    "",  "1.77e-10","+0.00","-01470","0.00e+00","+00.0","+00000","2", /* cf V05,W04,M05 */
+   "H2",     "C2H",    "C2H2",   "H",    "",  "1.20e-11","+0.00","-00998","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2H3",   "H",      "C2H4", "",  "1.57e-20","+2.56","-02529","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2H5",   "C2H6",   "H",    "",  "5.11e-24","+03.6","-04253","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C3H5",   "H",      "C3H6", "",  "1.80e-19","+2.38","-09557","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C3H7",   "C3H8",   "H",    "",  "3.00e-21","+2.84","-04600","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C4H",    "C4H2",   "H",    "",  "9.20e-18","+2.17","-00478","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "H2",     "C4H5",   "C4H6",   "H",    "",  "6.61e-15","+0.50","-01864","0.00e+00","+0.00","+00000","2", /* Weisman 88 */
+   "H2",     "AC6H5",  "AC6H6",  "H",    "",  "9.48e-20","+2.43","-03159","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "CH",     "CH",     "C2H2",   "",     "",  "1.99e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH",     "CH4",    "C2H4",   "H",    "",  "3.96e-08","-1.04","-00036","0.00e+00","+00.0","+00000","2", 
+   "CH",     "C2H2",   "C3H2",   "H",    "",  "1.59e-09","-0.23","-00016","0.00e+00","+00.0","+00000","2", /* cf V05,W04,M05 */
+   "CH",     "C2H4",   "CH3CCH", "H",    "",  "3.90e-09","-0.55","-00029","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H4",   "CH2CCH2","H",    "",  "3.90e-09","-0.55","-00029","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H6",   "C2H4",   "CH3",  "",  "1.90e-08","-0.86","-00053","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H6",   "C3H6",   "H",    "",  "1.90e-08","-0.86","-00053","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "CH3CCH", "C4H4",   "H",    "",  "4.60e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Butler 81, cf M05 */
+   "CH",     "C3H8",   "prod",   "H",    "",  "1.90e-10","+0.00","+00240","0.00e+00","+00.0","+00000","2", 
+   "CH",     "C4H10",  "prod",   "",     "",  "4.40e-10","+0.00","+00028","0.00e+00","+00.0","+00000","2", /* Baulch 92 */
+   "1CH2",   "1CH2",   "C2H2",   "H",    "H", "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "1CH2",   "3CH2",   "C2H2",   "H",    "H", "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "CH3",    "C2H4",   "H",    "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "CH4",    "3CH2",   "CH4",  "",  "1.20e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "CH4",    "CH3",    "CH3",  "",  "5.90e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H",    "C2H2",   "CH",   "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H2",   "3CH2",   "C2H2", "",  "8.14e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H2",   "C3H3",   "H",    "",  "2.90e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H3",   "C2H2",   "CH3",  "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H4",   "3CH2",   "C2H4", "",  "2.30e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H4",   "C3H6",   "",     "",  "1.50e-18","-3.00","-00300","1.32e-10","+00.0","+00000","3", /* cf M05 */
+   "1CH2",   "C2H5",   "C2H4",   "CH3",  "",  "1.50e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H5",   "C3H6",   "H",    "",  "1.50e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H6",   "3CH2",   "C2H6", "",  "3.60e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C2H6",   "C2H5",   "CH3",  "",  "1.90e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H5",   "C4H6",   "H",    "",  "3.30e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H5",   "C2H4",   "C2H3", "",  "6.67e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H6",   "3CH2",   "C3H6", "",  "5.00e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Tsang 91 */
+   "1CH2",   "C3H6",   "C3H5",   "CH3",  "",  "8.70e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H7",   "C2H5",   "C2H4", "",  "4.29e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H7",   "C3H6",   "CH3",  "",  "1.71e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "C3H8",   "C2H5",   "C2H5", "",  "1.60e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "1CH2",   "N2",     "3CH2",   "N2",   "",  "1.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "3CH2",   "C2H2",   "H",    "H", "1.80e-10","+0.00","-00400","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "3CH2",   "C2H2",   "H2",   "",  "2.00e-11","-00.0","-00400","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "3CH2",   "CH3",    "C2H4",   "H",    "",  "7.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "CH4",    "CH3",    "CH3",  "",  "7.13e-12","+0.00","-05052","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "CH4",    "C2H6",   "",     "",  "3.50e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H",    "CH",     "C2H2", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H2",   "C3H2",   "H2",   "",  "1.00e-12","-00.0","-03332","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "3CH2",   "C2H2",   "C3H3",   "H",    "",  "2.00e-11","+0.00","-03330","0.00e+00","+00.0","+00000","2", /* cf W04,V05 */ 
+   "3CH2",   "C2H3",   "CH3",    "C2H2", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H4",   "C3H5",   "H",    "",  "5.31e-12","+0.00","-02658","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "3CH2",   "C2H5",   "CH3",    "C2H4", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H6",   "C3H8",   "",     "",  "8.13e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C2H6",   "CH3",    "C2H5", "",  "1.07e-11","+0.00","-03981","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H5",   "C4H6",   "H",    "",  "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H6",   "C3H5",   "CH3",  "",  "1.20e-12","+0.00","-03116","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H7",   "CH3",    "C3H6", "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H7",   "C2H4",   "C2H5", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H8",   "C4H10",  "",     "",  "8.13e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "3CH2",   "C3H8",   "C3H7",   "CH3",  "",  "1.50e-24","+3.65","-03600","0.00e+00","+00.0","+00000","2",  
+   "3CH2",   "C4H2",   "C4H",    "CH3",  "",  "2.16e-11","+0.00","-02165","0.00e+00","+00.0","+00000","2",  
+   "3CH2",   "C4H6"   ,"CH3CCH", "C2H4", "",  "6.14e-12","+0.00","-01731","0.00e+00","+0.00","+00000","2", /* Kraus 93 */
+   "3CH2",   "C4H10",  "prod",   "",     "",  "4.30e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "CH3",    "CH3",    "C2H5",   "H",    "",  "8.28e-12","0.099","-05335","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "CH3",    "C2H6",   "",     "",  "1.65e-04","-8.75","-00985","1.17e-10","+0.00","-00000","3", /* Cody 03 */
+   "CH3",    "C2H",    "C3H3",   "H",    "",  "4.00e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H2",   "CH3CCH", "H",    "",  "3.18e-20","+2.42","-06488","0.00e+00","+0.00","+00000","2", /* Diau 94 */
+   "CH3",    "C2H2",   "C3H5",   "",     "",  "3.30e-30","+0.00","-00740","1.00e-12","+0.00","-03900","3", /* cf V05 */
+   "CH3",    "C2H3",   "C2H2",   "CH4",  "",  "3.40e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H3",   "C3H6",   "",     "",  "5.00e-27","+0.00","-00000","1.10e-10","+0.00","+00000","3", /* cf M05 */
+   "CH3",    "C2H4",   "C2H3",   "CH4",  "",  "1.10e-23","+03.7","-04780","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H4",   "C3H7",   "",     "",  "1.39e-29","+00.0","-00562","3.50e-13","+00.0","-03700","3", /* cf V05 */
+   "CH3",    "C2H5",   "CH4",    "C2H4", "",  "3.25e-11","-0.50","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H5",   "C3H8",   "",     "",  "1.01e+20","-16.1","-01897","8.12e-10","-0.50","+00000","3", 
+   "CH3",    "C2H6",   "CH4",    "C2H5", "",  "2.50e-31","+6.00","-03043","0.00e+00","+00.0","+00000","2", 
+//   "CH3",    "C3H3",   "C4H6",   "",     "",  "3.50e-06","-07.0","-01390","6.80e-11","+00.0","+00130","3", /* cf V05 */ 
+   "CH3",    "CH3CCH", "C2H6",   "C2H",  "",  "8.32e-13","+00.0","-04428","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "CH2CCH2","C2H5",   "C2H2", "",  "3.32e-13","+00.0","-04076","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H5",   "CH2CCH2","CH4",  "",  "5.00e-12","-0.32","+00066","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H5",   "prod",   "",     "",  "1.28e-30","-0.32","+00066","1.69e-10","-0.32","+00066","3", /* cf W04 */
+   "CH3",    "C3H6",   "CH4",    "C3H5", "",  "2.66e-13","+00.0","-04440","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H6",   "prod",   "",     "",  "7.70e-29","+0.00","-00380","1.19e-13","+00.0","-03330","3", /* cf V05 */
+   "CH3",    "C3H7",   "C4H10",  "",     "",  "8.63e+28","-18.5","-02307","3.20e-10","-0.32","+00000","3", 
+   "CH3",    "C3H7",   "C3H6",   "CH4",  "",  "1.90e-11","-0.32","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H8",   "C3H7",   "CH4",  "",  "1.50e-24","+3.65","-03600","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C4H4",   "C4H3",   "CH4",  "",  "6.61e-13","+0.00","-02502","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C4H6",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","1.30e-13","+00.0","-02060","3", /* cf V05 */
+   "CH3",    "C4H10",  "prod",   "CH4",  "",  "6.60e-13","-00.0","-04840","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+//   "CH4",    "C2",     "CH3CCH", "",     "",  "1.70e-11","+0.00","-02805","0.00e+00","+00.0","+00000","2",  /* Baulch 92 (3C2) */
+   "CH4",    "C2",     "CH3",    "C2H",  "",  "9.83e-11","-0.42","-00013","0.00e+00","+00.0","+00000","2", /* Canosa 06 (1C2) */
+   "CH4",    "C2H",    "C2H2",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C2H3",   "C2H4",   "CH3",  "",  "2.40e-24","+4.02","-02754","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C2H5",   "C2H6",   "CH3",  "",  "1.43e-25","+4.14","-06322","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C3H5",   "C3H6",  "CH3",   "",  "6.60e-23","+3.40","-11670","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "CH4",    "C3H7",   "C3H8",   "CH3",  "",  "4.00e-26","+4.02","-05473","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C4H",    "C4H2",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2", /* pas de 1/3 */
+   "CH4",    "AC6H5",  "AC6H6",  "CH3",  "",  "3.32e-12","+0.00","-04329","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "C2",     "C2H2",   "C4H",    "H",    "",  "1.92e-07","-1.14","-00077","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2) + produits: Nadia B. */
+   "C2",     "C2H4",   "C4H3",   "H",    "",  "5.10e-08","-0.93","-00058","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2) + produits: Nadia B. */
+   "C2",     "C2H6",   "C2H",    "C2H5", "",  "2.77e-08","-0.94","-00044","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2); Produits ? */
+   "C2",     "C3H8",   "C3H7",   "C2H",  "",  "3.89e-08","-1.31","-00094","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2); Produits ? */
+   "C2",     "AC6H6",  "soot",   "",     "",  "5.20e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Reisler 80 */
+   "C2H",    "C2H",    "C2H2",   "C2",   "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H2",   "C4H2",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* peu != de Chastaing 98 */
+   "C2H",    "C2H2",   "C4H",    "H2",   "",  "8.60e-18","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* Ralf Kaiser */
+   "C2H",    "C2H3",   "C2H2",   "C2H2", "",  "1.60e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H4",   "C4H4",   "H",    "",  "7.80e-11","+0.00","+00134","0.00e+00","+00.0","+00000","2", /* peu != de Chastaing 98 */
+   "C2H",    "C2H5",   "C3H3",   "CH3",  "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H5",   "C2H2",   "C2H4", "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H6",   "C2H2",   "C2H5", "",  "5.10e-11","+0.00","-00076","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H",    "CH3CCH", "C4H2",  "CH3",   "",  "1.60e-10","+0.00","+00071","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H",    "CH2CCH2","C2H2",  "C3H3",  "",  "1.30e-10","+0.00","+00103","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H",    "C3H5",   "CH2CCH2","C2H2", "",  "1.20e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H6",   "prod",   "H",    "",  "2.00e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", /* peu != de Chastaing 98 */
+   "C2H",    "C3H7",   "C3H3",   "C2H5", "",  "2.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H7",   "C3H6",   "C2H2", "",  "1.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H8",   "C3H7",   "C2H2", "",  "9.80e-11","+0.00","-00071","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C4H6",   "AC6H6",  "H",    "",  "3.30e-10","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C2H",    "C4H10",  "prod",   "C2H2", "",  "1.20e-10","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C2H",    "AC6H6",  "soot",   "H",    "",  "8.20e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* WandF 97 */
+   "C2H2",   "C2H3",   "C4H4",   "H",    "",  "3.32e-12","+0.00","-02516","0.00e+00","+00.0","+00000","2", 
+   "C2H2",   "C2H3",   "C4H5",   "",     "",  "8.20e-30","+0.00","-00352","4.16e-19","+1.90","-01058","3", /* cf M05 */
+   "C2H2",   "C2H5",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","5.60e-14","+00.0","-03520","3", /* cf V05 */ 
+   "C2H2",   "C3H5",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","5.30e-14","+0.00","-03500","3", /* cf V05 */ 
+   "C2H2",   "C3H7",   "C3H5",   "C2H4", "",  "1.20e-12","+0.00","-04531","0.00e+00","+00.0","+00000","2", 
+   "C2H2",   "C4H",    "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* pas de 1/3 */
+   "C2H2",   "C4H3",   "soot",   "",     "",  "2.00e-16","+0.00","-00000","0.00e+00","+0.00","+00000","2", 
+   "C2H2",   "C4H5",   "AC6H6",  "H",    "",  "3.50e-09","-1.07","-02417","0.00e+00","+0.00","+00000","2", /* WetF 94 */
+   "C2H2",   "C4H5",   "AC6H6",  "H",    "",  "4.20e-19","+1.80","-00602","0.00e+00","+0.00","+00000","2", /* Weismann 88 */
+   "C2H2",   "AC6H5",  "soot",    "",    "",  "3.72e-13","+0.00","-01561","0.00e+00","+0.00","+00000","2", /* Yu 94 */
+   "C2H3",   "C2H3",   "C4H6",   "",     "",  "5.00e-18","-3.75","-00300","1.40e-10","+00.0","+00000","3", /* cf M05 */ 
+   "C2H3",   "C2H3",   "C2H2",   "C2H4", "",  "2.40e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C2H3",   "C2H4",   "C4H6",   "H",    "",  "8.30e-13","+0.00","-03676","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C3H5",   "CH3",  "",  "6.10e-47","+11.2","+03289","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C2H4",   "C2H4", "",  "8.00e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C2H2",   "C2H6", "",  "8.00e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "prod",   "",     "",  "1.90e-27","+0.00","+00000","2.50e-11","+00.0","+00000","3", /* cf W04 */
+   "C2H3",   "C2H6",   "C2H4",   "C2H5", "",  "9.98e-22","+3.30","-05285","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "CH2CCH2","C2H4", "",  "4.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "C3H6",   "C2H2", "",  "8.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "prod",   "H",    "H", "8.00e-11","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H3",   "C3H6",   "CH3",    "C4H6", "",  "1.20e-12","+0.00","-02520","0.00e+00","+00.0","+00000","2",
+   "C2H3",   "C3H6",   "C2H4",   "C3H5", "",  "3.68e-24","+3.50","-02356","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H6",   "prod",   "H",    "",  "1.20e-12","+0.00","-03240","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H3",   "C3H7",   "C2H4",   "C3H6", "",  "2.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H7",   "C3H8",   "C2H2", "",  "2.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H7",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","1.60e-11","+00.0","+00000","3", /* cf V05 */
+   "C2H3",   "C3H8",   "C3H7",   "C2H4", "",  "1.00e-21","+3.30","-05285","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C4H3",   "AC6H6",  "",     "",  "4.77e-10","+0.00","-00411","0.00e+00","+0.00","+00000","2", /* Duran 88 */
+   "C2H3",   "C4H5",   "AC6H6",  "H2",   "",  "3.05e-37","+7.07","-01817","0.00e+00","+0.00","+00000","2", /* Westmoreland 89 */
+   "C2H3",   "C4H6",   "prod",   "",     "",  "1.50e-14","-5.84","-02363","2.45e-12","-0.17","-01630","3", /* cf V05 */
+   "C2H4",   "C2H5",   "C2H3",   "C2H6", "",  "1.05e-21","+3.13","-09063","0.00e+00","+00.0","+00000","2", 
+   "C2H4",   "C3H5",   "prod",   "H",    "",  "1.00e-14","+0.00","-05776","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H4",   "C3H7",   "prod",   "",     "",  "7.70e-30","+0.00","-00380","1.80e-13","+00.0","-03670","3", /* cf V05 */
+   "C2H4",   "C4H",    "C4H2",   "C2H3", "",  "4.60e-11","+0.00","+00025","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "C2H4",   "AC6H5",  "prod",   "H",    "",  "1.20e-12","+0.00","-02250","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "C2H5",   "C2H5",   "C4H10",  "",     "",  "6.59e-06","-6.39","-00301","1.26e-11","+00.0","-00096","3", 
+   "C2H5",   "C2H5",   "C2H6",   "C2H4", "",  "2.40e-12","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* Baulch 92 */
+   "C2H5",   "CH2CCH2","C2H6",   "C3H3", "",  "5.25e-13","+0.00","-04579","0.00e+00","+0.00","+00000","2", /* Getty 67 */
+   "C2H5",   "C3H5",   "CH2CCH2","C2H6", "",  "1.60e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H5",   "C3H6",   "C2H4", "",  "4.30e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H5",   "prod",   "",     "",  "3.50e-07","-07.0","-01390","3.30e-11","+00.0","+00066","3", /* cf V05 */ 
+   "C2H5",   "C3H6",   "C2H6",   "C3H5", "",  "3.70e-24","+3.50","-03340","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H6",   "prod",   "",     "",  "7.70e-30","-00.0","-00380","1.70e-13","+00.0","+03625","3", /* cf V05 */ 
+   "C2H5",   "C3H7",   "C2H6",   "C3H6", "",  "2.40e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H7",   "C3H8",   "C2H4", "",  "1.90e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H7",   "prod",   "",     "",  "9.70e+28","-18.5","-02307","3.30e-11","+00.0","+00000","3", /* cf V05 */
+   "C2H5",   "C3H8",   "C3H7",   "C2H6", "",  "1.50e-24","+3.65","-04600","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C3H5",   "C2H5",   "C3H6", "",  "3.90e-22","+3.30","-09986","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C3H7",   "C3H8",   "C2H5", "",  "4.20e-25","+3.82","-04550","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C4H",    "C4H2",   "C2H5", "",  "3.50e-11","+0.00","+00003","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "C3H3",   "C3H3",   "AC6H6",  "",     "",  "6.00e-28","+0.00","+01680","1.20e-10","+0.00","+00000","3", /* Moses 00, Morter 94 */
+   "C3H3",   "C3H5",   "prod",   "",     "",  "2.90e-11","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C3H3",   "C4H2",   "CH3CCH", "C4H",  "",  "1.00e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Alkernade 89 */
+   "C3H5",   "C3H5",   "CH2CCH2","C3H6", "",  "1.40e-13","+0.00","+00132","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H5",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","1.70e-11","+0.00","+00132","3",  /* cf V05 */
+   "C3H5",   "C3H6",   "C2H5",   "C4H4", "",  "1.00e-14","+0.00","-05776","0.00e+00","+0.00","+00000","2", /* Tsang 91 */
+   "C3H5",   "C3H7",   "C3H6",   "C3H6", "",  "2.40e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H7",   "CH2CCH2","C3H8", "",  "1.20e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H7",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","3.40e-11","+0.00","+00066","3",  /* cf V05 */
+   "C3H5",   "C3H8",   "C3H7",   "C3H6", "",  "3.90e-22","+3.30","-09986","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C4H10",  "C3H6",  "prod",  "",  "7.00e-23","+3.30","-07800","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C3H6",   "C3H7",   "C3H5",   "C3H8", "",  "3.70e-24","+3.50","-03340","0.00e+00","+00.0","+00000","2", 
+   "C3H7",   "C3H7",   "C3H8",   "C3H6", "",  "2.80e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C3H7",   "C3H7",   "prod",   "",     "",  "2.90e-21","+0.00","+00000","1.70e-11","+00.0","+00000","3", /* cf V05 */
+   "C4H",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",  /* pad de 1/3 */
+   "C4H2s",  "",       "C4H2",   "",     "",  "1.00e+01","+0.00","+00000","0.00e+00","+00.0","+00000","1", 
+   "C4H2s",  "N2",     "C4H2",   "N2",   "",  "1.40e-15","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C4H2s",  "C2H2",   "prod",   "H",    "H", "3.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C2H4",   "prod",   "H",    "H", "4.20e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "H",    "H", "1.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "CH3",  "H", "2.30e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "C2H2", "",  "2.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "C2H3", "",  "8.70e-14","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "H",    "H", "1.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "CH3",  "H", "4.10e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "C2H2", "",  "2.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "C2H3", "",  "4.90e-14","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H2",   "prod",   "C2H2", "",  "8.20e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H2",   "prod",   "H",    "H", "1.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "soot",   "H",    "",  "9.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "AC6H6",  "C2H2", "",  "8.80e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "prod",   "C2H4", "",  "3.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C4H3",   "C4H3",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","7.00e-11","+0.00","+00000","3", /* cf V05 */
+   "C4H4",   "C4H4",   "prod",   "",     "",  "7.25e-14","+0.00","-09261","0.00e+00","+00.0","+00000","2", 
+   "AC6H5",  "AC6H6",  "prod",   "",     "",  "1.59e-12","+0.00","-02168","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+
+   "N4S",    "N4S",    "N2",     "",     "",  "8.27e-34","+0.00","+00490","0.00e+00","+00.0","+00000","3",
+   "N4S",    "CH",     "CN",     "H",    "",  "2.67e-10","-0.09","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3",    "HCN",    "H2",   "",  "6.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3",    "H2CN",   "H",    "",  "5.60e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+/*   "N4S",    "C2H2",   "CH2CN",  "",     "",  "1.70e-14","+0.00","+00000","0.00e+00","+0.00","+00000","2",  Sato 74 */
+   "N4S",    "C2H3",   "CH3CN",  "",     "",  "3.08e-12","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Payne 96 */
+   "N4S",    "C2H3",   "CH2CN",  "H",    "",  "6.16e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Payne 96 */
+   "N4S",    "C2H4",   "CH3",    "HCN",  "",  "3.32e-14","+0.00","-00352","0.00e+00","+0.00","+00000","2", /* Kerr 72 */
+   "N4S",    "C2H5",   "HCN",    "CH4",  "",  "1.10e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Stief 95 */
+   "N4S",    "C2H6",   "prod",   "",     "",  "0.00e-00","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3CCH", "CHCN",   "CH3",  "",  "1.15e-13","+0.00","-00745","0.00e+00","+0.00","+00000","2", /* Kerr 72 */
+   "N4S",    "C3H6",   "HCN",    "C2H4", "H", "2.49e-13","+0.00","-00830","0.00e+00","+0.00","+00000","2", /* Paraskevopoulos 67 */
+   "N4S",    "C3H8",   "HCN",    "C2H6", "H", "3.39e-13","+0.00","-02563","0.00e+00","+0.00","+00000","2", /* Onyzchuk 53 */
+   "N4S",    "C4H10",  "C3H8",   "HCN",  "H", "2.97e-14","+0.00","-01813","0.00e+00","+0.00","+00000","2", /* Back 54 */
+   "N4S",    "H2CN",   "HCN",    "prod", "",  "1.00e-10","+0.00","-00200","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CHCN",   "NCCN",   "H",    "",  "6.00e-15","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Safrany 68 */
+   "N4S",    "CH3CN",  "HCN",    "HCN",  "H", "2.28e-15","+0.00","-00813","0.00e+00","+0.00","+00000","2", /* Forst 57 */
+   "CN",     "H",      "HCN",    "",     "",  "2.40e-24","-2.20","-00567","2.99e-09","-0.50","+00000","3", /* Tsang 92 */
+   "CN",     "H2",     "HCN",    "H",    "",  "2.23e-21","+3.31","-00756","0.00e+00","+00.0","+00000","2",
+   "CN",     "CH4",    "HCN",    "CH3",  "",  "4.64e-16","+1.53","-00504","0.00e+00","+00.0","+00000","2", /* est, Yang 93 */
+   "CN",     "CH4",    "CH3CN",  "H",    "",  "5.15e-17","+1.53","-00504","0.00e+00","+0.00","+00000","2", /* est, Yang 93 */
+   "CN",     "C2H2",   "HC3N",   "H",    "",  "5.67e-09","-0.55","-00004","0.00e+00","+00.0","+00000","2",
+   "CN",     "C2H6",   "HCN",    "C2H5", "",  "5.91e-12","+0.22","+00058","0.00e+00","+00.0","+00000","2",
+   "CN",     "CH3CCH", "HC3N",   "CH3",  "",  "2.10e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Sayah 88 */
+   "CN",     "CH2CCH2","HCN",    "C3H3", "",  "2.63e-10","+0.00","+00167","0.00e+00","+0.00","+00000","2", /* Butterfield 93 */
+   "CN",     "C3H6",   "prod",   "H",    "",  "1.73e-10","+0.00","+00102","0.00e+00","+0.00","+00000","2", /* Sims 93 */
+   "CN",     "C3H8",   "C3H7",   "HCN",  "",  "2.44e-14","+1.19","+00378","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "C4H2",   "HC3N",   "C2H",  "",  "5.26e-09","-0.52","-00019","0.00e+00","+0.00","+00000","2", /* est. Sims 93 */
+   "CN",     "C4H4",   "C4H3",   "HCN",  "",  "1.07e-07","-0.82","-00228","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "CN",     "NCCN",   "",     "",  "9.44e-23","-2.61","+00000","9.40e-12","+0.00","+00000","3", /* Tsang 92 */
+   "CN",     "HCN",    "NCCN",   "H",    "",  "2.51e-17","+1.71","-00770","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "CH3CN",  "NCCN",   "CH3",  "",  "6.46e-11","+0.00","-01190","0.00e+00","+0.00","+00000","2", /* Zabarnick 89 */
+   "CN",     "NCCN",   "prod",   "",     "",  "2.19e-21","+2.70","-00325","0.00e+00","+00.0","+00000","2",
+   "CN",     "HC3N",   "C4N2",   "H",    "",  "1.70e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Halpern 89 */
+   "CN",     "C4N2",   "NCCN",   "C3N",  "",  "5.40e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Seki 96 */
+   "HCN",    "H",      "H2CN",   "",     "",  "4.40e-24","-2.73","-03855","5.50e-11","+00.0","-02438","3",
+   "HCN",    "CH",     "CHCN",   "H",    "",  "5.00e-11","+0.00","+00500","0.00e+00","+0.00","+00000","2", /* Zabarnick 91 */
+   "HCN",    "C2H",    "H",      "HC3N", "",  "5.26e-12","+0.00","-00770","0.00e+00","+00.0","+00000","2",
+   "HCN",    "AC6H5",  "soot",   "",     "",  "3.72e-13","+0.00","-01561","0.00e+00","+0.00","+00000","2", 
+   "HCN",    "H2CN",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "H",      "HCN",    "H2",   "",  "1.40e-10","+0.00","-00200","0.00e+00","+00.0","+00000","2",
+   "H2CN",   "H2CN",   "prod",   "HCN",  "",  "1.16e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Horne 70 */
+   "H2CN",   "CH3CN",  "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "NCCN",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "HC3N",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "N2",     "CH",     "prod",   "",     "",  "3.80e-25","-2.60","+00000","9.65e-11","-0.15","+00000","3", /* Fulle 96 */
+   "CHCN",   "H2",     "CH3CN",  "",     "",  "1.00e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Adamson 97 */
+   "CH2CN",  "CH2CN",  "C2H4",   "NCCN", "",  "1.80e-11","+0.00","-00769","0.00e+00","+0.00","+00000","2", /* est, Hoobler 97 */
+   "CH3CN",  "H",      "CH3",    "HCN",  "",  "3.39e-12","+0.00","-03954","0.00e+00","+0.00","+00000","2", /* Jamieson 70 */
+   "CH3CN",  "H",      "CH4",    "CN",   "",  "1.66e-13","+0.00","-01505","0.00e+00","+0.00","+00000","2", /* Jamieson 70 */
+   "CH3CN",  "C2H",    "HC3N",   "CH3",  "",  "1.80e-11","+0.00","-00769","0.00e+00","+0.00","+00000","2", /* Hoobler 97 */
+   "C3N",    "H2",     "HC3N",   "H",    "",  "1.20e-11","+0.00","-00998","0.00e+00","+00.0","+00000","2",
+   "C3N",    "CH4",    "HC3N",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H4",   "prod",   "H",    "",  "7.80e-11","+0.00","+00134","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H6",   "HC3N",   "C2H5", "",  "3.50e-11","+0.00","+00002","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C3H8",   "C3H7",   "HC3N", "",  "6.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "C3N",    "HC3N",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "H",      "HCN",    "C2H2", "",  "1.00e-28","+0.00","-00740","0.55e-12","+00.0","-00500","3",
+   "HC3N",   "C2H",    "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "C4H",    "prod",   "H",    "",  "2.90e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "C4H3",   "soot",   "",     "",  "1.20e-15","+0.00","-00000","0.00e+00","+0.00","+00000","2",
Index: /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit_051006_bis
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit_051006_bis	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/chimie_simpnit_051006_bis	(revision 1644)
@@ -0,0 +1,388 @@
+   "H2",     "HV",     "H",      "H",    "",  "","","","","","","",  /* 1 */
+   "CH3",    "HV",     "CH2s",   "H",    "",  "","","","","","","",  /* 2 */
+   "CH4",    "HV",     "CH2s",   "H2",   "",  "","","","","","","",  /* 3 */
+   "CH4",    "HV",     "CH",     "H2",   "H", "","","","","","","",  /* 4 */
+   "CH4",    "HV",     "CH3",    "H",    "",  "","","","","","","",  /* 5 */
+   "C2H2",   "HV",     "C2H",    "H",    "",  "","","","","","","",  /* 6 */
+   "C2H2",   "HV",     "C2",     "H2",   "",  "","","","","","","",  /* 7 */
+   "C2H4",   "HV",     "C2H2",   "H2",   "",  "","","","","","","",  /* 8 */
+   "C2H4",   "HV",     "C2H2",   "H",    "H", "","","","","","","",  /* 9 */
+   "C2H6",   "HV",     "C2H4",   "H2",   "",  "","","","","","","",  /* 10 */
+   "C2H6",   "HV",     "C2H4",   "H",    "H", "","","","","","","",  /* 11 */
+   "C2H6",   "HV",     "C2H2",   "H2",   "H2","","","","","","","",  /* 12 */
+   "C2H6",   "HV",     "CH4",    "CH2s", "",  "","","","","","","",  /* 13 */
+   "C2H6",   "HV",     "CH3",    "CH3",  "",  "","","","","","","",  /* 14 */
+   "C3H3",   "HV",     "C3H2",   "H",    "",  "","","","","","","",  /* 15 */
+   "CH2CCH2","HV",     "C3H3",   "H",    "",  "","","","","","","",  /* 16 */
+   "CH2CCH2","HV",     "C3H2",   "H2",   "",  "","","","","","","",  /* 17 */
+   "CH3CCH", "HV",     "C3H3",   "H",    "",  "","","","","","","",  /* 18 */
+   "CH3CCH", "HV",     "C3H2",   "H2",   "",  "","","","","","","",  /* 19 */
+   "C3H6",   "HV",     "CH2CCH2","H",    "H", "","","","","","","",  /* 20 */
+   "C3H6",   "HV",     "CH3CCH", "H",    "H", "","","","","","","",  /* 21 */
+   "C3H6",   "HV",     "C2H4",   "CH2",  "",  "","","","","","","",  /* 22 */
+   "C3H6",   "HV",     "C2H3",   "CH3",  "",  "","","","","","","",  /* 23 */
+   "C3H6",   "HV",     "C2H2",   "CH4",  "",  "","","","","","","",  /* 24 */
+   "C3H8",   "HV",     "C3H6",   "H2",   "",  "","","","","","","",  /* 25 */
+   "C3H8",   "HV",     "C2H6",   "CH2s", "",  "","","","","","","",  /* 26 */
+   "C3H8",   "HV",     "C2H5",   "CH3",  "",  "","","","","","","",  /* 27 */
+   "C3H8",   "HV",     "C2H4",   "CH4",  "",  "","","","","","","",  /* 28 */
+   "C4H2",   "HV",     "C4H",    "H",    "",  "","","","","","","",  /* 29 */
+   "C4H2",   "HV",     "C2H",    "C2H",  "",  "","","","","","","",  /* 30 */
+   "C4H2",   "HV",     "C2H2",   "C2",   "",  "","","","","","","",  /* 31 */
+   "C4H2",   "HV",     "C4H2s",  "",     "",  "","","","","","","",  /* 32 */
+   "C4H4",   "HV",     "C4H2",   "H2",   "",  "","","","","","","",  /* 33 */
+   "C4H4",   "HV",     "C2H2",   "C2H2", "",  "","","","","","","",  /* 34 */
+   "C4H6",   "HV",     "C4H4",   "H2",   "",  "","","","","","","",  /* 35 */
+   "C4H6",   "HV",     "C2H4",   "C2H2", "",  "","","","","","","",  /* 36 */
+   "C4H6",   "HV",     "CH3",    "C3H3", "",  "","","","","","","",  /* 37 */
+   "C4H10",  "HV",     "C3H5",   "CH3",  "H2","","","","","","","",  /* 38 */
+   "C4H10",  "HV",     "C2H4",   "C2H4", "H2","","","","","","","",  /* 39 */
+   "C4H10",  "HV",     "C3H6",   "CH4",  "",  "","","","","","","",  /* 40 */
+   "C4H10",  "HV",     "C3H6",   "CH3",  "H", "","","","","","","",  /* 41 */
+   "C4H10",  "HV",     "C2H4",   "C2H6", "",  "","","","","","","",  /* 42 */
+   "C4H10",  "HV",     "C2H2",   "C2H6", "H2","","","","","","","",  /* 43 */
+   "C4H10",  "HV",     "CH3",    "C3H7", "",  "","","","","","","",  /* 44 */
+   "C4H10",  "HV",     "C2H5",   "C2H5", "",  "","","","","","","",  /* 45 */
+
+   "AC6H6",  "HV",     "prod",   "CH3",  "",  "","","","","","","",  /* 46 */
+   "AC6H6",  "HV",     "AC6H5",  "H",    "",  "","","","","","","",  /* 47 */
+
+   "N2",     "HV",     "N4S",    "N4S",  "",  "","","","","","","",  /* 48 */
+   "HCN",    "HV",     "H",      "CN",   "",  "","","","","","","",  /* 49 */
+   "HC3N",   "HV",     "C2H",    "CN",   "",  "","","","","","","",  /* 50 */
+   "HC3N",   "HV",     "H",      "C3N",  "",  "","","","","","","",  /* 51 */
+   "NCCN",   "HV",     "CN",     "CN",   "",  "","","","","","","",  /* 52 */
+   "CH3CN",  "HV",     "CH3",    "CN",   "",  "","","","","","","",  /* 53 */
+   "C4N2",   "HV",     "C3N",    "CN",   "",  "","","","","","","",  /* 54 */
+
+   "N2",     "",       "N4S",    "N4S",  "",  "0.00e+00","+00.0","+00000","0.00e+00","+00.0","+00000","1", 
+
+   "H",      "H",      "H2",     "",     "",  "2.70e-31","-00.6","+00000","1.00e-11","+00.0","+00000","3", /* Baulch92 */
+   "H",      "CH2s",   "CH",     "H2",   "",  "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "CH2",    "H2",     "CH",   "",  "3.54e-11","+0.32","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "CH2",    "CH3",    "",     "",  "1.70e-25","-01.8","+00000","3.50e-11","+0.32","-00000","3", /* cf V05 */
+   "H",      "CH3",    "CH4",    "",     "",  "6.33e-21","-2.98","-00635","2.63e-08","-0.60","-00189","3", 
+   "H",      "CH3",    "H2",     "CH2",  "",  "1.00e-10","+00.0","-07600","0.00e+00","+00.0","+00000","2", 
+   "H",      "CH4",    "H2",     "CH3",  "",  "2.18e-20","+03.0","-04045","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H",    "C2H2",   "",     "",  "1.26e-18","-03.1","-00721","3.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C2H2",   "C2H3",   "",     "",  "3.30e-30","+00.0","-00740","1.40e-11","+00.0","-01300","3", 
+   "H",      "C2H3",   "H2",     "C2H2", "",  "6.86e-11","+00.0","+00023","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H3",   "C2H4",   "",     "",  "5.76e-24","-01.3","+00000","1.80e-10","+00.0","-00000","3", /* cf M05 */
+   "H",      "C2H4",   "C2H3",   "H2",   "",  "8.40e-17","+1.93","-06518","0.00e+00","+0.00","-00000","2", /* cf V05 */
+   "H",      "C2H4",   "C2H5",   "",     "",  "1.39e-29","+00.0","-00562","6.60e-15","+1.28","-00650","3", 
+   "H",      "C2H5",   "CH3",    "CH3",  "",  "1.20e-10","+00.0","-00000","0.00e+00","+00.0","+00000","2", /* Sillesen 93 */
+   "H",      "C2H5",   "H2",     "C2H4", "",  "3.00e-12","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C2H5",   "C2H6",   "",     "",  "5.50e-23","-2.00","-01040","1.66e-10","+00.0","+00000","3", 
+   "H",      "C2H6",   "H2",     "C2H5", "",  "2.40e-15","+01.5","-03730","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H2",   "C3H3",   "",     "",  "1.70e-23","-1.80","-00000","1.00e-10","+0.00","+00000","3", /* cf V05 */
+   "H",      "C3H3",   "CH3CCH", "",     "",  "9.40e-20","-3.30","-00000","1.00e-10","+0.00","+00000","3", /* cf M05 */
+   "H",      "C3H3",   "CH2CCH2","",     "",  "1.70e-25","-01.8","+00000","2.50e-10","+0.00","-00000","3", /* cf V05 */
+   "H",      "CH3CCH", "CH3",    "C2H2", "",  "8.00e-24","-02.0","-01225","9.63e-12","+00.0","-01560","3", /* cf W04 */
+   "H",      "CH3CCH", "C3H3",   "H2",   "",  "4.70e-16","+1.74","-03873","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "CH3CCH", "C3H5",   "",     "",  "4.40e-31","+00.0","-00000","6.00e-11","+00.0","-01233","3",  /* cf V05 */
+   "H",      "CH2CCH2","C2H2",   "CH3",  "",  "8.00e-24","-2.00","-01225","9.70e-13","+0.00","-01550","3", /* cf W04 */
+   "H",      "CH2CCH2","CH3CCH", "H",    "",  "1.30e-11","+0.00","-01156","0.00e+00","+0.00","-00000","2", /* cf V05 */
+   "H",      "CH2CCH2","C3H5",   "",     "",  "8.00e-24","+2.00","-01225","1.40e-11","+00.0","-01000","3",  /* cf V05 */
+   "H",      "C3H5",   "C2H3",   "CH3",  "",  "4.00e-12","+0.00","-00000","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "C3H5",   "CH2CCH2","H2",   "",  "1.40e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H5",   "CH3CCH", "H2",   "",  "1.40e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H5",   "C3H6",   "",     "",  "1.00e-24","+00.0","+00000","2.80e-10","+00.0","+00000","3",  /* cf V05 */
+   "H",      "C3H6",   "C3H5",   "H2",   "",  "2.87e-19","+02.5","-01254","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H6",   "CH3",    "C2H4", "",  "2.20e-11","+00.0","-01641","0.00e+00","+00.0","+00000","2",  /* M00 */
+   "H",      "C3H6",   "C3H7",   "",     "",  "1.30e-28","+00.0","-00380","9.47e-15","+1.16","-00440","3",  /* cf M05 */
+   "H",      "C3H7",   "C3H6",   "H2",   "",  "3.00e-12","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C3H7",   "C2H5",   "CH3",  "",  "6.00e-11","+0.00","-00000","0.00e+00","+0.00","-00000","2", /* cf M05 */
+   "H",      "C3H7",   "C3H8",   "",     "",  "2.50e-27","+0.00","-00000","2.50e-10","+0.00","-00000","3", /* cf M05 */
+   "H",      "C3H8",   "C3H7",   "H2",   "",  "2.20e-18","+2.54","-03400","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H",    "C4H2",   "",     "",  "1.26e-18","-03.1","-00721","3.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C4H2",   "C4H3",   "",     "",  "2.00e-26","+0.00","-00740","1.39e-10","+0.00","-01184","3", /* cf M05 */
+   "H",      "C4H3",   "C4H4",   "",     "",  "8.56e-10","+00.0","-00405","0.00e+00","+00.0","+00000","2",
+//   "H",      "C4H3",   "C4H4",   "",     "",  "1.50e-19","-03.0","-00300","8.56e-10","+00.0","-00405","3", /* cf M05 */
+   "H",      "C4H3",   "C4H2",   "H2",   "",  "1.20e-11","+00.0","-00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H3",   "C2H2",   "C2H2", "",  "3.30e-12","+00.0","-00000","0.00e+00","+00.0","+00000","2", 
+   "H",      "C4H4",   "C4H5",   "",     "",  "3.32e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+//   "H",      "C4H4",   "C4H5",   "",     "",  "8.76e-08","-7.00","-01390","3.32e-12","+0.00","+00000","3", /* cf W04 */
+   "H",      "C4H5",   "prod",   "",     "",  "1.50e-19","-03.0","-00300","1.00e-10","+00.0","+00000","3", /* cf M05 */ 
+   "H",      "C4H6",   "H2",     "C4H5", "",  "1.05e-13","+0.70","-03019","0.00e+00","+0.00","+00000","2", /* Weisman 88 */
+   "H",      "C4H6",   "prod",   "",     "",  "7.70e-30","+0.00","-00380","8.50e-12","+0.00","-00000","3", /* cf V05 */
+   "H",      "C4H10",  "prod",   "H2",   "",  "3.50e-11","+0.00","-03970","0.00e+00","+0.00","-00000","2", /* cf V05 */
+//   "H",      "AC6H5",  "C4H2",   "C2H2", "",  "3.16e-05","-01.6","-01117","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "H",      "AC6H5",  "AC6H6",  "",     "",  "1.82e+28","-16.3","-03526","1.66e-10","+0.00","+00000","3", /* WetF 97 */
+   "H",      "AC6H6",  "AC6H5",  "H2",   "",  "4.15e-10","+0.00","-08057","0.00e+00","+0.00","+00000","2", /* WetF 97 */
+   "H2",     "CH",     "CH3",    "",     "",  "4.70e-26","-01.6","+00000","2.50e-10","-0.08","+00000","3", /* Brownsword 97 */
+   "H2",     "CH",     "CH2",    "H",    "",  "3.10e-10","+0.00","-01650","0.00e+00","+00.0","+00000","2", 
+   "H2",     "CH2s",   "CH3",    "H",    "",  "1.20e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "H2",     "CH2",    "CH3",    "H",    "",  "5.00e-15","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "H2",     "CH3",    "CH4",    "H",    "",  "1.14e-20","+2.74","-04740","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2",     "C2H",    "H",    "",  "1.77e-10","+0.00","-01470","0.00e+00","+00.0","+00000","2", /* cf V05,W04,M05 */
+   "H2",     "C2H",    "C2H2",   "H",    "",  "1.20e-11","+0.00","-00998","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2H3",   "H",      "C2H4", "",  "1.57e-20","+2.56","-02529","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C2H5",   "C2H6",   "H",    "",  "5.11e-24","+03.6","-04253","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C3H5",   "H",      "C3H6", "",  "1.80e-19","+2.38","-09557","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C3H7",   "C3H8",   "H",    "",  "3.00e-21","+2.84","-04600","0.00e+00","+00.0","+00000","2", 
+   "H2",     "C4H",    "C4H2",   "H",    "",  "9.20e-18","+2.17","-00478","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "H2",     "C4H5",   "C4H6",   "H",    "",  "6.61e-15","+0.50","-01864","0.00e+00","+0.00","+00000","2", /* Weisman 88 */
+   "H2",     "AC6H5",  "AC6H6",  "H",    "",  "9.48e-20","+2.43","-03159","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "CH",     "CH",     "C2H2",   "",     "",  "1.99e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH",     "CH4",    "C2H4",   "H",    "",  "3.96e-08","-1.04","-00036","0.00e+00","+00.0","+00000","2", 
+   "CH",     "C2H2",   "C3H2",   "H",    "",  "1.59e-09","-0.23","-00016","0.00e+00","+00.0","+00000","2", /* cf V05,W04,M05 */
+   "CH",     "C2H4",   "CH3CCH", "H",    "",  "3.90e-09","-0.55","-00029","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H4",   "CH2CCH2","H",    "",  "3.90e-09","-0.55","-00029","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H6",   "C2H4",   "CH3",  "",  "1.90e-08","-0.86","-00053","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "C2H6",   "C3H6",   "H",    "",  "1.90e-08","-0.86","-00053","0.00e+00","+00.0","+00000","2", /* cf V05,W04 */
+   "CH",     "CH3CCH", "C4H4",   "H",    "",  "4.60e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Butler 81, cf M05 */
+   "CH",     "C3H8",   "prod",   "H",    "",  "1.90e-10","+0.00","+00240","0.00e+00","+00.0","+00000","2", 
+   "CH",     "C4H10",  "prod",   "",     "",  "4.40e-10","+0.00","+00028","0.00e+00","+00.0","+00000","2", /* Baulch 92 */
+   "CH2s",   "CH2s",   "C2H2",   "H",    "H", "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "CH2s",   "CH2",    "C2H2",   "H",    "H", "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "CH3",    "C2H4",   "H",    "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "CH4",    "CH2",    "CH4",  "",  "1.20e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "CH4",    "CH3",    "CH3",  "",  "5.90e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H",    "C2H2",   "CH",   "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H2",   "CH2",    "C2H2", "",  "8.14e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H2",   "C3H3",   "H",    "",  "2.90e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H3",   "C2H2",   "CH3",  "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H4",   "CH2",    "C2H4", "",  "2.30e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H4",   "C3H6",   "",     "",  "1.50e-18","-3.00","-00300","1.32e-10","+00.0","+00000","3", /* cf M05 */
+   "CH2s",   "C2H5",   "C2H4",   "CH3",  "",  "1.50e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H5",   "C3H6",   "H",    "",  "1.50e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H6",   "CH2",    "C2H6", "",  "3.60e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C2H6",   "C2H5",   "CH3",  "",  "1.90e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C3H5",   "C4H6",   "H",    "",  "3.30e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C3H5",   "C2H4",   "C2H3", "",  "6.67e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C3H6",   "CH2",    "C3H6", "",  "5.00e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Tsang 91 */
+   "CH2s",   "C3H6",   "C3H5",   "CH3",  "",  "8.70e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C3H7",   "C2H5",   "C2H4", "",  "4.29e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C3H7",   "C3H6",   "CH3",  "",  "1.71e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "C3H8",   "C2H5",   "C2H5", "",  "1.60e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2s",   "N2",     "CH2",    "N2",   "",  "1.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "CH2",    "C2H2",   "H",    "H", "1.80e-10","+0.00","-00400","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "CH2",    "C2H2",   "H2",   "",  "2.00e-11","-00.0","-00400","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "CH2",    "CH3",    "C2H4",   "H",    "",  "7.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "CH4",    "CH3",    "CH3",  "",  "7.13e-12","+0.00","-05052","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "CH4",    "C2H6",   "",     "",  "3.50e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C2H",    "CH",     "C2H2", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C2H2",   "C3H2",   "H2",   "",  "1.00e-12","-00.0","-03332","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "CH2",    "C2H2",   "C3H3",   "H",    "",  "2.00e-11","+0.00","-03330","0.00e+00","+00.0","+00000","2", /* cf W04,V05 */ 
+   "CH2",    "C2H3",   "CH3",    "C2H2", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C2H4",   "C3H5",   "H",    "",  "5.31e-12","+0.00","-02658","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "CH2",    "C2H5",   "CH3",    "C2H4", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C2H6",   "C3H8",   "",     "",  "8.13e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C2H6",   "CH3",    "C2H5", "",  "1.07e-11","+0.00","-03981","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C3H5",   "C4H6",   "H",    "",  "5.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C3H6",   "C3H5",   "CH3",  "",  "1.20e-12","+0.00","-03116","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C3H7",   "CH3",    "C3H6", "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C3H7",   "C2H4",   "C2H5", "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C3H8",   "C4H10",  "",     "",  "8.13e-12","+0.00","-03332","0.00e+00","+00.0","+00000","2", 
+   "CH2",    "C3H8",   "C3H7",   "CH3",  "",  "1.50e-24","+3.65","-03600","0.00e+00","+00.0","+00000","2",  
+   "CH2",    "C4H2",   "C4H",    "CH3",  "",  "2.16e-11","+0.00","-02165","0.00e+00","+00.0","+00000","2",  
+   "CH2",    "C4H6"   ,"CH3CCH", "C2H4", "",  "6.14e-12","+0.00","-01731","0.00e+00","+0.00","+00000","2", /* Kraus 93 */
+   "CH2",    "C4H10",  "prod",   "",     "",  "4.30e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "CH3",    "CH3",    "C2H5",   "H",    "",  "8.28e-12","0.099","-05335","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "CH3",    "C2H6",   "",     "",  "1.65e-04","-8.75","-00985","1.17e-10","+0.00","-00000","3", /* Cody 03 */
+   "CH3",    "C2H",    "C3H3",   "H",    "",  "4.00e-11","+00.0","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H2",   "CH3CCH", "H",    "",  "3.18e-20","+2.42","-06488","0.00e+00","+0.00","+00000","2", /* Diau 94 */
+   "CH3",    "C2H2",   "C3H5",   "",     "",  "3.30e-30","+0.00","-00740","1.00e-12","+0.00","-03900","3", /* cf V05 */
+   "CH3",    "C2H3",   "C2H2",   "CH4",  "",  "3.40e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H3",   "C3H6",   "",     "",  "5.00e-27","+0.00","-00000","1.10e-10","+0.00","+00000","3", /* cf M05 */
+   "CH3",    "C2H4",   "C2H3",   "CH4",  "",  "1.10e-23","+03.7","-04780","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H4",   "C3H7",   "",     "",  "1.39e-29","+00.0","-00562","3.50e-13","+00.0","-03700","3", /* cf V05 */
+   "CH3",    "C2H5",   "CH4",    "C2H4", "",  "3.25e-11","-0.50","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C2H5",   "C3H8",   "",     "",  "1.01e+20","-16.1","-01897","8.12e-10","-0.50","+00000","3", 
+   "CH3",    "C2H6",   "CH4",    "C2H5", "",  "2.50e-31","+6.00","-03043","0.00e+00","+00.0","+00000","2", 
+//   "CH3",    "C3H3",   "C4H6",   "",     "",  "3.50e-06","-07.0","-01390","6.80e-11","+00.0","+00130","3", /* cf V05 */ 
+   "CH3",    "CH3CCH", "C2H6",   "C2H",  "",  "8.32e-13","+00.0","-04428","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "CH2CCH2","C2H5",   "C2H2", "",  "3.32e-13","+00.0","-04076","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H5",   "CH2CCH2","CH4",  "",  "5.00e-12","-0.32","+00066","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H5",   "prod",   "",     "",  "1.28e-30","-0.32","+00066","1.69e-10","-0.32","+00066","3", /* cf W04 */
+   "CH3",    "C3H6",   "CH4",    "C3H5", "",  "2.66e-13","+00.0","-04440","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H6",   "prod",   "",     "",  "7.70e-29","+0.00","-00380","1.19e-13","+00.0","-03330","3", /* cf V05 */
+   "CH3",    "C3H7",   "C4H10",  "",     "",  "8.63e+28","-18.5","-02307","3.20e-10","-0.32","+00000","3", 
+   "CH3",    "C3H7",   "C3H6",   "CH4",  "",  "1.90e-11","-0.32","+00000","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C3H8",   "C3H7",   "CH4",  "",  "1.50e-24","+3.65","-03600","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C4H4",   "C4H3",   "CH4",  "",  "6.61e-13","+0.00","-02502","0.00e+00","+00.0","+00000","2", 
+   "CH3",    "C4H6",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","1.30e-13","+00.0","-02060","3", /* cf V05 */
+   "CH3",    "C4H10",  "prod",   "CH4",  "",  "6.60e-13","-00.0","-04840","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+//   "CH4",    "C2",     "CH3CCH", "",     "",  "1.70e-11","+0.00","-02805","0.00e+00","+00.0","+00000","2",  /* Baulch 92 (3C2) */
+   "CH4",    "C2",     "CH3",    "C2H",  "",  "9.83e-11","-0.42","-00013","0.00e+00","+00.0","+00000","2", /* Canosa 06 (1C2) */
+   "CH4",    "C2H",    "C2H2",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C2H3",   "C2H4",   "CH3",  "",  "2.40e-24","+4.02","-02754","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C2H5",   "C2H6",   "CH3",  "",  "1.43e-25","+4.14","-06322","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C3H5",   "C3H6",  "CH3",   "",  "6.60e-23","+3.40","-11670","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "CH4",    "C3H7",   "C3H8",   "CH3",  "",  "4.00e-26","+4.02","-05473","0.00e+00","+00.0","+00000","2", 
+   "CH4",    "C4H",    "C4H2",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2", /* pas de 1/3 */
+   "CH4",    "AC6H5",  "AC6H6",  "CH3",  "",  "3.32e-12","+0.00","-04329","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "C2",     "C2H2",   "C4H",    "H",    "",  "1.92e-07","-1.14","-00077","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2) + produits: Nadia B. */
+   "C2",     "C2H4",   "C4H3",   "H",    "",  "5.10e-08","-0.93","-00058","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2) + produits: Nadia B. */
+   "C2",     "C2H6",   "C2H",    "C2H5", "",  "2.77e-08","-0.94","-00044","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2); Produits ? */
+   "C2",     "C3H8",   "C3H7",   "C2H",  "",  "3.89e-08","-1.31","-00094","0.00e+00","+0.00","+00000","2", /* Canosa 06 (1C2); Produits ? */
+   "C2",     "AC6H6",  "soot",   "",     "",  "5.20e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Reisler 80 */
+   "C2H",    "C2H",    "C2H2",   "C2",   "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H2",   "C4H2",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* peu != de Chastaing 98 */
+   "C2H",    "C2H2",   "C4H",    "H2",   "",  "8.60e-18","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* Ralf Kaiser */
+   "C2H",    "C2H3",   "C2H2",   "C2H2", "",  "1.60e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H4",   "C4H4",   "H",    "",  "7.80e-11","+0.00","+00134","0.00e+00","+00.0","+00000","2", /* peu != de Chastaing 98 */
+   "C2H",    "C2H5",   "C3H3",   "CH3",  "",  "3.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H5",   "C2H2",   "C2H4", "",  "3.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C2H6",   "C2H2",   "C2H5", "",  "5.10e-11","+0.00","-00076","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H",    "CH3CCH", "C4H2",  "CH3",   "",  "1.60e-10","+0.00","+00071","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H",    "CH2CCH2","C2H2",  "C3H3",  "",  "1.30e-10","+0.00","+00103","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H",    "C3H5",   "CH2CCH2","C2H2", "",  "1.20e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H6",   "prod",   "H",    "",  "2.00e-10","+0.00","+00000","0.00e+00","+00.0","+00000","2", /* peu != de Chastaing 98 */
+   "C2H",    "C3H7",   "C3H3",   "C2H5", "",  "2.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H7",   "C3H6",   "C2H2", "",  "1.00e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C3H8",   "C3H7",   "C2H2", "",  "9.80e-11","+0.00","-00071","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", 
+   "C2H",    "C4H6",   "AC6H6",  "H",    "",  "3.30e-10","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C2H",    "C4H10",  "prod",   "C2H2", "",  "1.20e-10","-00.0","-00000","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C2H",    "AC6H6",  "soot",   "H",    "",  "8.20e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* WandF 97 */
+   "C2H2",   "C2H3",   "C4H4",   "H",    "",  "3.32e-12","+0.00","-02516","0.00e+00","+00.0","+00000","2", 
+   "C2H2",   "C2H3",   "C4H5",   "",     "",  "8.20e-30","+0.00","-00352","4.16e-19","+1.90","-01058","3", /* cf M05 */
+   "C2H2",   "C2H5",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","5.60e-14","+00.0","-03520","3", /* cf V05 */ 
+   "C2H2",   "C3H5",   "prod",   "",     "",  "3.30e-30","+0.00","-00740","5.30e-14","+0.00","-03500","3", /* cf V05 */ 
+   "C2H2",   "C3H7",   "C3H5",   "C2H4", "",  "1.20e-12","+0.00","-04531","0.00e+00","+00.0","+00000","2", 
+   "C2H2",   "C4H",    "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2", /* pas de 1/3 */
+   "C2H2",   "C4H3",   "soot",   "",     "",  "2.00e-16","+0.00","-00000","0.00e+00","+0.00","+00000","2", 
+   "C2H2",   "C4H5",   "AC6H6",  "H",    "",  "3.50e-09","-1.07","-02417","0.00e+00","+0.00","+00000","2", /* WetF 94 */
+   "C2H2",   "C4H5",   "AC6H6",  "H",    "",  "4.20e-19","+1.80","-00602","0.00e+00","+0.00","+00000","2", /* Weismann 88 */
+   "C2H2",   "AC6H5",  "soot",    "",    "",  "3.72e-13","+0.00","-01561","0.00e+00","+0.00","+00000","2", /* Yu 94 */
+   "C2H3",   "C2H3",   "C4H6",   "",     "",  "5.00e-18","-3.75","-00300","1.40e-10","+00.0","+00000","3", /* cf M05 */ 
+   "C2H3",   "C2H3",   "C2H2",   "C2H4", "",  "2.40e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C2H3",   "C2H4",   "C4H6",   "H",    "",  "8.30e-13","+0.00","-03676","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C3H5",   "CH3",  "",  "6.10e-47","+11.2","+03289","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C2H4",   "C2H4", "",  "8.00e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "C2H2",   "C2H6", "",  "8.00e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C2H5",   "prod",   "",     "",  "1.90e-27","+0.00","+00000","2.50e-11","+00.0","+00000","3", /* cf W04 */
+   "C2H3",   "C2H6",   "C2H4",   "C2H5", "",  "9.98e-22","+3.30","-05285","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "CH2CCH2","C2H4", "",  "4.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "C3H6",   "C2H2", "",  "8.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H5",   "prod",   "H",    "H", "8.00e-11","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C2H3",   "C3H6",   "CH3",    "C4H6", "",  "1.20e-12","+0.00","-02520","0.00e+00","+00.0","+00000","2",
+   "C2H3",   "C3H6",   "C2H4",   "C3H5", "",  "3.68e-24","+3.50","-02356","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H6",   "prod",   "H",    "",  "1.20e-12","+0.00","-03240","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H3",   "C3H7",   "C2H4",   "C3H6", "",  "2.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H7",   "C3H8",   "C2H2", "",  "2.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C3H7",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","1.60e-11","+00.0","+00000","3", /* cf V05 */
+   "C2H3",   "C3H8",   "C3H7",   "C2H4", "",  "1.00e-21","+3.30","-05285","0.00e+00","+00.0","+00000","2", 
+   "C2H3",   "C4H3",   "AC6H6",  "",     "",  "4.77e-10","+0.00","-00411","0.00e+00","+0.00","+00000","2", /* Duran 88 */
+   "C2H3",   "C4H5",   "AC6H6",  "H2",   "",  "3.05e-37","+7.07","-01817","0.00e+00","+0.00","+00000","2", /* Westmoreland 89 */
+   "C2H3",   "C4H6",   "prod",   "",     "",  "1.50e-14","-5.84","-02363","2.45e-12","-0.17","-01630","3", /* cf V05 */
+   "C2H4",   "C2H5",   "C2H3",   "C2H6", "",  "1.05e-21","+3.13","-09063","0.00e+00","+00.0","+00000","2", 
+   "C2H4",   "C3H5",   "prod",   "H",    "",  "1.00e-14","+0.00","-05776","0.00e+00","+00.0","+00000","2", /* cf V05 */
+   "C2H4",   "C3H7",   "prod",   "",     "",  "7.70e-30","+0.00","-00380","1.80e-13","+00.0","-03670","3", /* cf V05 */
+   "C2H4",   "C4H",    "C4H2",   "C2H3", "",  "4.60e-11","+0.00","+00025","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "C2H4",   "AC6H5",  "prod",   "H",    "",  "1.20e-12","+0.00","-02250","0.00e+00","+00.0","+00000","2", /* cf M05 */ 
+   "C2H5",   "C2H5",   "C4H10",  "",     "",  "6.59e-06","-6.39","-00301","1.26e-11","+00.0","-00096","3", 
+   "C2H5",   "C2H5",   "C2H6",   "C2H4", "",  "2.40e-12","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* Baulch 92 */
+   "C2H5",   "CH2CCH2","C2H6",   "C3H3", "",  "5.25e-13","+0.00","-04579","0.00e+00","+0.00","+00000","2", /* Getty 67 */
+   "C2H5",   "C3H5",   "CH2CCH2","C2H6", "",  "1.60e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H5",   "C3H6",   "C2H4", "",  "4.30e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H5",   "prod",   "",     "",  "3.50e-07","-07.0","-01390","3.30e-11","+00.0","+00066","3", /* cf V05 */ 
+   "C2H5",   "C3H6",   "C2H6",   "C3H5", "",  "3.70e-24","+3.50","-03340","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H6",   "prod",   "",     "",  "7.70e-30","-00.0","-00380","1.70e-13","+00.0","+03625","3", /* cf V05 */ 
+   "C2H5",   "C3H7",   "C2H6",   "C3H6", "",  "2.40e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H7",   "C3H8",   "C2H4", "",  "1.90e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C2H5",   "C3H7",   "prod",   "",     "",  "9.70e+28","-18.5","-02307","3.30e-11","+00.0","+00000","3", /* cf V05 */
+   "C2H5",   "C3H8",   "C3H7",   "C2H6", "",  "1.50e-24","+3.65","-04600","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C3H5",   "C2H5",   "C3H6", "",  "3.90e-22","+3.30","-09986","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C3H7",   "C3H8",   "C2H5", "",  "4.20e-25","+3.82","-04550","0.00e+00","+00.0","+00000","2", 
+   "C2H6",   "C4H",    "C4H2",   "C2H5", "",  "3.50e-11","+0.00","+00003","0.00e+00","+00.0","+00000","2", /* cf W04 */
+   "C3H3",   "C3H3",   "AC6H6",  "",     "",  "6.00e-28","+0.00","+01680","1.20e-10","+0.00","+00000","3", /* Moses 00, Morter 94 */
+   "C3H3",   "C3H5",   "prod",   "",     "",  "2.90e-11","+0.00","-00000","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+   "C3H3",   "C4H2",   "CH3CCH", "C4H",  "",  "1.00e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Alkernade 89 */
+   "C3H5",   "C3H5",   "CH2CCH2","C3H6", "",  "1.40e-13","+0.00","+00132","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H5",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","1.70e-11","+0.00","+00132","3",  /* cf V05 */
+   "C3H5",   "C3H6",   "C2H5",   "C4H4", "",  "1.00e-14","+0.00","-05776","0.00e+00","+0.00","+00000","2", /* Tsang 91 */
+   "C3H5",   "C3H7",   "C3H6",   "C3H6", "",  "2.40e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H7",   "CH2CCH2","C3H8", "",  "1.20e-12","+0.00","+00066","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C3H7",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","3.40e-11","+0.00","+00066","3",  /* cf V05 */
+   "C3H5",   "C3H8",   "C3H7",   "C3H6", "",  "3.90e-22","+3.30","-09986","0.00e+00","+00.0","+00000","2", 
+   "C3H5",   "C4H10",  "C3H6",  "prod",  "",  "7.00e-23","+3.30","-07800","0.00e+00","+00.0","+00000","2", /* cf V05 */ 
+   "C3H6",   "C3H7",   "C3H5",   "C3H8", "",  "3.70e-24","+3.50","-03340","0.00e+00","+00.0","+00000","2", 
+   "C3H7",   "C3H7",   "C3H8",   "C3H6", "",  "2.80e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C3H7",   "C3H7",   "prod",   "",     "",  "2.90e-21","+0.00","+00000","1.70e-11","+00.0","+00000","3", /* cf V05 */
+   "C4H",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",  /* pad de 1/3 */
+   "C4H2s",  "",       "C4H2",   "",     "",  "1.00e+01","+0.00","+00000","0.00e+00","+00.0","+00000","1", 
+   "C4H2s",  "N2",     "C4H2",   "N2",   "",  "1.40e-15","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C4H2s",  "C2H2",   "prod",   "H",    "H", "3.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C2H4",   "prod",   "H",    "H", "4.20e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "H",    "H", "1.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "CH3",  "H", "2.30e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "C2H2", "",  "2.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "CH3CCH", "prod",   "C2H3", "",  "8.70e-14","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "H",    "H", "1.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "CH3",  "H", "4.10e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "C2H2", "",  "2.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C3H6",   "prod",   "C2H3", "",  "4.90e-14","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H2",   "prod",   "C2H2", "",  "8.20e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H2",   "prod",   "H",    "H", "1.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "soot",   "H",    "",  "9.50e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "AC6H6",  "C2H2", "",  "8.80e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C4H2s",  "C4H6",   "prod",   "C2H4", "",  "3.60e-13","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "C4H3",   "C4H3",   "prod",   "",     "",  "3.50e-07","-7.00","-01390","7.00e-11","+0.00","+00000","3", /* cf V05 */
+   "C4H4",   "C4H4",   "prod",   "",     "",  "7.25e-14","+0.00","-09261","0.00e+00","+00.0","+00000","2", 
+   "AC6H5",  "AC6H6",  "prod",   "",     "",  "1.59e-12","+0.00","-02168","0.00e+00","+00.0","+00000","2", /* cf W04 */ 
+
+   "N4S",    "N4S",    "N2",     "",     "",  "8.27e-34","+0.00","+00490","0.00e+00","+00.0","+00000","3",
+   "N4S",    "CH",     "CN",     "H",    "",  "2.67e-10","-0.09","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3",    "HCN",    "H2",   "",  "6.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3",    "H2CN",   "H",    "",  "5.60e-11","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+/*   "N4S",    "C2H2",   "CH2CN",  "",     "",  "1.70e-14","+0.00","+00000","0.00e+00","+0.00","+00000","2",  Sato 74 */
+   "N4S",    "C2H3",   "CH3CN",  "",     "",  "3.08e-12","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Payne 96 */
+   "N4S",    "C2H3",   "CH2CN",  "H",    "",  "6.16e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Payne 96 */
+   "N4S",    "C2H4",   "CH3",    "HCN",  "",  "3.32e-14","+0.00","-00352","0.00e+00","+0.00","+00000","2", /* Kerr 72 */
+   "N4S",    "C2H5",   "HCN",    "CH4",  "",  "1.10e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Stief 95 */
+   "N4S",    "C2H6",   "prod",   "",     "",  "0.00e-00","+0.00","+00000","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CH3CCH", "CHCN",   "CH3",  "",  "1.15e-13","+0.00","-00745","0.00e+00","+0.00","+00000","2", /* Kerr 72 */
+   "N4S",    "C3H6",   "HCN",    "C2H4", "H", "2.49e-13","+0.00","-00830","0.00e+00","+0.00","+00000","2", /* Paraskevopoulos 67 */
+   "N4S",    "C3H8",   "HCN",    "C2H6", "H", "3.39e-13","+0.00","-02563","0.00e+00","+0.00","+00000","2", /* Onyzchuk 53 */
+   "N4S",    "C4H10",  "C3H8",   "HCN",  "H", "2.97e-14","+0.00","-01813","0.00e+00","+0.00","+00000","2", /* Back 54 */
+   "N4S",    "H2CN",   "HCN",    "prod", "",  "1.00e-10","+0.00","-00200","0.00e+00","+00.0","+00000","2", 
+   "N4S",    "CHCN",   "NCCN",   "H",    "",  "6.00e-15","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Safrany 68 */
+   "N4S",    "CH3CN",  "HCN",    "HCN",  "H", "2.28e-15","+0.00","-00813","0.00e+00","+0.00","+00000","2", /* Forst 57 */
+   "CN",     "H",      "HCN",    "",     "",  "2.40e-24","-2.20","-00567","2.99e-09","-0.50","+00000","3", /* Tsang 92 */
+   "CN",     "H2",     "HCN",    "H",    "",  "2.23e-21","+3.31","-00756","0.00e+00","+00.0","+00000","2",
+   "CN",     "CH4",    "HCN",    "CH3",  "",  "4.64e-16","+1.53","-00504","0.00e+00","+00.0","+00000","2", /* est, Yang 93 */
+   "CN",     "CH4",    "CH3CN",  "H",    "",  "5.15e-17","+1.53","-00504","0.00e+00","+0.00","+00000","2", /* est, Yang 93 */
+   "CN",     "C2H2",   "HC3N",   "H",    "",  "5.67e-09","-0.55","-00004","0.00e+00","+00.0","+00000","2",
+   "CN",     "C2H6",   "HCN",    "C2H5", "",  "5.91e-12","+0.22","+00058","0.00e+00","+00.0","+00000","2",
+   "CN",     "CH3CCH", "HC3N",   "CH3",  "",  "2.10e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Sayah 88 */
+   "CN",     "CH2CCH2","HCN",    "C3H3", "",  "2.63e-10","+0.00","+00167","0.00e+00","+0.00","+00000","2", /* Butterfield 93 */
+   "CN",     "C3H6",   "prod",   "H",    "",  "1.73e-10","+0.00","+00102","0.00e+00","+0.00","+00000","2", /* Sims 93 */
+   "CN",     "C3H8",   "C3H7",   "HCN",  "",  "2.44e-14","+1.19","+00378","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "C4H2",   "HC3N",   "C2H",  "",  "5.26e-09","-0.52","-00019","0.00e+00","+0.00","+00000","2", /* est. Sims 93 */
+   "CN",     "C4H4",   "C4H3",   "HCN",  "",  "1.07e-07","-0.82","-00228","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "CN",     "NCCN",   "",     "",  "9.44e-23","-2.61","+00000","9.40e-12","+0.00","+00000","3", /* Tsang 92 */
+   "CN",     "HCN",    "NCCN",   "H",    "",  "2.51e-17","+1.71","-00770","0.00e+00","+0.00","+00000","2", /* Yang 92 */
+   "CN",     "CH3CN",  "NCCN",   "CH3",  "",  "6.46e-11","+0.00","-01190","0.00e+00","+0.00","+00000","2", /* Zabarnick 89 */
+   "CN",     "NCCN",   "prod",   "",     "",  "2.19e-21","+2.70","-00325","0.00e+00","+00.0","+00000","2",
+   "CN",     "HC3N",   "C4N2",   "H",    "",  "1.70e-10","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Halpern 89 */
+   "CN",     "C4N2",   "NCCN",   "C3N",  "",  "5.40e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Seki 96 */
+   "HCN",    "H",      "H2CN",   "",     "",  "4.40e-24","-2.73","-03855","5.50e-11","+00.0","-02438","3",
+   "HCN",    "CH",     "CHCN",   "H",    "",  "5.00e-11","+0.00","+00500","0.00e+00","+0.00","+00000","2", /* Zabarnick 91 */
+   "HCN",    "C2H",    "H",      "HC3N", "",  "5.26e-12","+0.00","-00770","0.00e+00","+00.0","+00000","2",
+   "HCN",    "AC6H5",  "soot",   "",     "",  "3.72e-13","+0.00","-01561","0.00e+00","+0.00","+00000","2", 
+   "HCN",    "H2CN",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "H",      "HCN",    "H2",   "",  "1.40e-10","+0.00","-00200","0.00e+00","+00.0","+00000","2",
+   "H2CN",   "H2CN",   "prod",   "HCN",  "",  "1.16e-11","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Horne 70 */
+   "H2CN",   "CH3CN",  "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "NCCN",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "H2CN",   "HC3N",   "soot",   "",     "",  "1.00e-12","+0.00","-00900","0.00e+00","+0.00","+00000","2",
+   "N2",     "CH",     "prod",   "",     "",  "3.80e-25","-2.60","+00000","9.65e-11","-0.15","+00000","3", /* Fulle 96 */
+   "CHCN",   "H2",     "CH3CN",  "",     "",  "1.00e-13","+0.00","+00000","0.00e+00","+0.00","+00000","2", /* Adamson 97 */
+   "CH2CN",  "CH2CN",  "C2H4",   "NCCN", "",  "1.80e-11","+0.00","-00769","0.00e+00","+0.00","+00000","2", /* est, Hoobler 97 */
+   "CH3CN",  "H",      "CH3",    "HCN",  "",  "3.39e-12","+0.00","-03954","0.00e+00","+0.00","+00000","2", /* Jamieson 70 */
+   "CH3CN",  "H",      "CH4",    "CN",   "",  "1.66e-13","+0.00","-01505","0.00e+00","+0.00","+00000","2", /* Jamieson 70 */
+   "CH3CN",  "C2H",    "HC3N",   "CH3",  "",  "1.80e-11","+0.00","-00769","0.00e+00","+0.00","+00000","2", /* Hoobler 97 */
+   "C3N",    "H2",     "HC3N",   "H",    "",  "1.20e-11","+0.00","-00998","0.00e+00","+00.0","+00000","2",
+   "C3N",    "CH4",    "HC3N",   "CH3",  "",  "1.20e-11","+0.00","-00491","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H4",   "prod",   "H",    "",  "7.80e-11","+0.00","+00134","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C2H6",   "HC3N",   "C2H5", "",  "3.50e-11","+0.00","+00002","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C3H8",   "C3H7",   "HC3N", "",  "6.00e-12","+0.00","+00000","0.00e+00","+00.0","+00000","2",
+   "C3N",    "C4H2",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "C3N",    "HC3N",   "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "H",      "HCN",    "C2H2", "",  "1.00e-28","+0.00","-00740","0.55e-12","+00.0","-00500","3",
+   "HC3N",   "C2H",    "prod",   "H",    "",  "8.60e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "C4H",    "prod",   "H",    "",  "2.90e-16","+1.80","+00474","0.00e+00","+00.0","+00000","2",
+   "HC3N",   "C4H3",   "soot",   "",     "",  "1.20e-15","+0.00","-00000","0.00e+00","+0.00","+00000","2",
Index: /trunk/LMDZ.TITAN/libf/chimtitan/comp.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/comp.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/comp.c	(revision 1644)
@@ -0,0 +1,547 @@
+/* comp: Compounds characteristics. */
+/* GCCM */
+
+#include "titan.h"
+
+void comp_(char CORPS[][10], double *CT, double *TEMP, 
+           double *MASS, double MD[][NLEV])
+{
+   int   i,j;
+   char  corps[NC+1][10];
+
+   double m,ma,epsa,sig,siga,p;
+
+   p         = 2.976e07;   /*9 10^7 R / 8 pi */
+
+      /* WARNING BACKGROUND GAS IS N2 */
+
+   ma   = 28.0134e0;               /* mass of background gas in g */
+   siga = 3.798e0;         /* Lennard-Jones length of background gas 1/10 nm */
+   epsa = 71.4e0;       /* Lennard-Jones energy of background gas */
+
+   for( i = 0; i <= NC; i++)
+   {
+     strcpy( corps[i], CORPS[i] );
+     corps[i][strcspn(CORPS[i], " ")] = '\0';
+   }
+
+   for( i = 0; i <= NC-1; i++)
+   {
+      for( j = 0; j <= NLEV-1; j++ ) MD[i][j] = 0.0e0;
+   }
+
+   for( i = 0; i <= NC-1; i++ )
+   {
+      if( strcmp(corps[i], "CH4") == 0 )
+      {
+         MASS[i] = 16.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.758e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,148.6e0) );
+      }
+      if( strcmp(corps[i], "H") == 0 )
+      {
+         MASS[i] = 1.01e0;
+      }
+      if( strcmp(corps[i], "H2") == 0 )
+      {
+         MASS[i] = 2.0158e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 2.827e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,59.7e0) );
+      }
+      if( strcmp(corps[i], "CH") == 0 )
+      {
+         MASS[i] = 13.02e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( ( strcmp( corps[i], "CH2" ) == 0 ) || ( strcmp( corps[i], "CH2s" ) == 0 ) )
+      {
+         MASS[i] = 14.03e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "CH3") == 0 )
+      {
+         MASS[i] = 15.03e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.7e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C") == 0 )
+      {
+         MASS[i] = 12.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 1.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C2") == 0 )
+      {
+         MASS[i] = 24.02e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.2e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C2H") == 0 )
+      {
+         MASS[i] = 25.03e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C2H3") == 0 )
+      {
+         MASS[i] = 27.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.8e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C2H4") == 0 )
+      {
+         MASS[i] = 28.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.163e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,224.7e0) );
+      }
+      if( strcmp(corps[i], "C2H2") == 0 )
+      {
+         MASS[i] = 26.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.033e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,231.8e0) );
+      }
+      if( strcmp(corps[i], "C2H5") == 0 )
+      {
+         MASS[i] = 29.06e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C2H6") == 0 )
+      {
+         MASS[i] = 30.07e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.443e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,215.7e0) );
+      }
+      if( strcmp(corps[i], "C3H2") == 0 )
+      {
+         MASS[i] = 38.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.6e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C3H3") == 0 )
+      {
+         MASS[i] = 39.06e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.7e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( ( strcmp(corps[i], "CH2CCH2") == 0 ) || ( strcmp(corps[i], "CH3CCH") == 0 ) )
+      {
+         MASS[i] = 40.07e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.761e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,251.8e0) );
+      }
+      if( strcmp(corps[i], "C3H5") == 0 )
+      {
+         MASS[i] = 41.07e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.78e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C3H6") == 0 )
+      {
+         MASS[i] = 42.08e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.807e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,248.9e0) );
+      }
+      if( strcmp(corps[i], "C3H7") == 0 )
+      {
+         MASS[i] = 43.09e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 5.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+       }
+      if( strcmp(corps[i], "C3H8") == 0 )
+      {
+         MASS[i] = 44.11e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 5.118e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,237.1e0) );
+      }
+      if( strcmp(corps[i], "C4H") == 0 )
+      {
+         MASS[i] = 49.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.2e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( ( strcmp(corps[i], "C4H2") == 0 )||( strcmp(corps[i], "C4H2s") == 0 ) )
+      {
+         MASS[i] = 50.06e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.3e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C4H3") == 0 )
+      {
+         MASS[i] = 51.07e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C4H4") == 0 )
+      {
+         MASS[i] = 52.08e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C4H5") == 0 )
+      {
+         MASS[i] = 53.07e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C4H6") == 0 )
+      {
+         MASS[i] = 54.09e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.6e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C4H10") == 0 )
+      {
+         MASS[i] = 58.13e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.687e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,531.4e0) );
+      }
+      if( strcmp(corps[i], "C6H") == 0 )
+      {
+         MASS[i] = 73.07e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 5.2e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C6H2") == 0 )
+      {
+         MASS[i] = 74.08e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 5.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C8H2") == 0 )
+      {
+         MASS[i] = 98.10e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 6.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp( corps[i], "AC6H6" ) == 0 )
+      {
+         MASS[i] = 78.1136e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 5.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )   /* P. G. L. */
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( ( strcmp( corps[i], "C6H5" ) == 0 ) || ( strcmp( corps[i], "AC6H5" ) == 0 ) )
+      {
+         MASS[i] = 77.1136e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 5.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp( corps[i], "C6H6" ) == 0 )
+      {
+         MASS[i] = 78.1136e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 5.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "N2") == 0 )
+      {
+         MASS[i] = 28.0134e0;
+      }
+      if( strcmp(corps[i], "N4S") == 0 )
+      {
+         MASS[i] = 14.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 1.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "NH") == 0 )
+      {
+         MASS[i] = 15.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "CN") == 0 )
+      {
+         MASS[i] = 26.02e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.2e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "HCN") == 0 )
+      {
+         MASS[i] = 27.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.63e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,569.1e0) );
+      }
+      if( strcmp(corps[i], "H2CN") == 0 )
+      {
+         MASS[i] = 28.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.8e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "C2N") == 0 )         /* C2N */
+      {
+         MASS[i] = 39.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp( corps[i], "CHCN" ) == 0 )
+      {
+         MASS[i]   = 39.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp( corps[i], "CH2CN" ) == 0 )
+      {
+         MASS[i]   = 40.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp( corps[i], "CH3CN" ) == 0 )
+      {
+         MASS[i]   = 41.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp( corps[i], "C2H3CN" ) == 0 )
+      {
+         MASS[i]   = 53.06e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "NCCN") == 0 )        /* NCCN */
+      {
+         MASS[i] = 52.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.361e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,348.6e0) );
+      }
+      if( strcmp(corps[i], "C3N") == 0 )         /* C3N */
+      {
+         MASS[i] = 50.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "HC3N") == 0 )        /* HC3N */
+      {
+         MASS[i] = 51.05e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp( corps[i], "C4N2" ) == 0 )
+      {
+         MASS[i]   = 76.1e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "H2O") == 0 )       
+      {
+         MASS[i] = 18.02e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 2.641e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) 
+           / ( CT[j] * sig * omega(TEMP[j],epsa,809.1e0) );
+      }
+      if( ( strcmp(corps[i], "O3P") == 0 ) || ( strcmp(corps[i], "O1D") == 0 ) )      
+      {
+         MASS[i] = 16.0e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 1.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "OH") == 0 )        
+      {
+         MASS[i] = 17.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.0e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "HO2") == 0 )
+      {
+         MASS[i] = 33.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "H2O2") == 0 )
+      {
+         MASS[i] = 33.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "O2") == 0 )
+      {
+         MASS[i] = 32.0e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.7e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "O3") == 0 )
+      {
+         MASS[i] = 32.0e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.7e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "CO") == 0 )          
+      {
+         MASS[i] = 28.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.69e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,91.7e0) );
+      }
+      if( strcmp(corps[i], "HCO") == 0 )        
+      {
+         MASS[i] = 29.02e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.7e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "CO2") == 0 )       
+      {
+         MASS[i] = 44.01e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.941e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) 
+           / ( CT[j] * sig * omega(TEMP[j],epsa,195.2e0) );
+      }
+      if( strcmp(corps[i], "CH2CO") == 0 )    
+      {
+         MASS[i] = 42.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 4.5e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "CH2O") == 0 )    
+      {
+         MASS[i] = 30.03e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.75e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( ( strcmp(corps[i], "CH2OH") == 0 ) || ( strcmp(corps[i], "CH3O") == 0 ) )  
+      {
+         MASS[i] = 31.04e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.4e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m ) / ( CT[j] * sig );
+      }
+      if( strcmp(corps[i], "CH3OH") == 0 )       
+      {
+         MASS[i] = 32.042e0;
+         m       = ( ma + MASS[i] ) / ( ma * MASS[i] );
+         sig     = 1.0e-16 * pow( ( siga + 3.626e0 ), 2.0e0 );
+         for( j = 0; j <= NLEV-1; j++ )
+            MD[i][j] = sqrt( p * TEMP[j] * m )
+           / ( CT[j] * sig * omega(TEMP[j],epsa,481.8e0) );
+      }
+   }
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/disso.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/disso.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/disso.c	(revision 1644)
@@ -0,0 +1,390 @@
+/* disso: photodissociation rates */
+/* GCCM */
+/* correspond a chimie_simpnit (version 301105) */
+/* !!! ATTENTION !!! */
+/* Doit etre mis a jour en fonction de la chimie utilisee ! */
+
+#include "titan.h"
+
+void disso_( double KRPD[][NLRT][RDISS+1][15], int *NLAT )
+{
+   static double sH2[62] = {  /* incertain en dessous de 70 et en dessus de 85... */
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,1.000e-18,5.000e-18,1.000e-17,
+          9.000e-18,6.500e-18,1.000e-18,1.000e-19 };
+   static double sCH4[62] = {
+          2.852e-19,7.816e-19,1.534e-18,2.069e-18,2.795e-18,4.088e-18,4.543e-18,
+          4.223e-18,3.314e-18,1.565e-18,8.892e-19,8.760e-19,8.792e-19,9.163e-19,
+          2.069e-18,9.378e-18,2.543e-17,3.785e-17,4.066e-17,3.302e-17,2.840e-17,
+          1.800e-17,1.920e-17,1.820e-17,1.840e-17,1.140e-17,2.656e-18,1.256e-19,
+          7.988e-22,1.366e-23,6.740e-24 };
+   static double sCH3CN[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,8.000e-17,8.000e-17,7.500e-17,
+          4.800e-17,3.700e-17,2.700e-17,4.100e-17,1.000e-17,8.600e-18,4.000e-18,
+          1.800e-18,1.100e-18,6.400e-19,3.600e-19,2.000e-19,1.200e-19,5.200e-20};
+   static double sC2H2[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,3.000e-17,
+          3.000e-17,3.200e-17,3.640e-17,4.260e-17,1.040e-16,9.900e-18,4.800e-18,
+          1.720e-17,1.782e-17,9.040e-19,9.600e-19,1.294e-18,1.352e-18,1.130e-18,
+          6.680e-19,3.700e-19,3.900e-19,1.660e-19,5.400e-20 };
+   static double sC2H4[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,.1992E-16,.2734E-16,.2594E-16,.1690E-16,.2258E-16,.8507E-17,
+          .1583E-16,.2227E-16,.3056E-16,.3743E-16,.3788E-16,.2737E-16,.3171E-17,
+          .6033E-18,.1223E-18,.7247E-19,1.000e-20 };
+   static double sC2H3CN[62] = { 
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e-00,0.000e-00,0.000e-00,
+          0.000e-00,0.000e-00,1.000e-17,6.600e-18,5.600e-18,3.600e-18,4.300e-18,
+          4.000e-18,3.000e-18,2.900e-18,2.700e-18,2.700e-18,3.300e-18,4.500e-18,
+          6.000e-18,7.100e-18,7.000e-18,5.000e-18,2.500e-18,6.600e-19,1.000e-19,
+          1.500e-20,1.000e-21};
+   static double sC2H6[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,2.000e-17,
+          2.000e-17,2.000e-17,2.060e-17,2.160e-17,1.540e-17,8.060e-18,3.860e-18,
+          1.484e-18,3.060e-19,9.600e-21 };
+   static double sCH3C2H[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,1.000e-17,
+          2.000e-17,4.580e-17,6.240e-17,5.880e-17,5.920e-17,1.940e-17,2.200e-17,
+          2.820e-17,3.380e-17,1.142e-17,6.600e-18,8.100e-18,7.000e-18,2.800e-18,
+          1.600e-18,2.300e-19,4.411e-19,2.119e-19,1.004e-19,2.934e-20,4.157e-21 };
+   static double sCH2CCH2[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,2.200e-17,2.200e-17,1.700e-17,1.700e-17,1.800e-17,
+          1.200e-17,1.500e-17,1.000e-17,2.100e-17,3.300e-17,4.000e-17,1.300e-17,
+          5.000e-18,2.900e-18,2.601e-18,1.037e-18,9.046e-19,6.565e-19,4.672e-19,
+          3.047e-19,1.579e-19,5.943e-20,2.261e-20 };
+   static double sC3H6[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,3.400e-17,
+          3.300e-17,2.400e-17,2.500e-17,4.000e-17,3.700e-17,2.300e-17,1.900e-17,
+          2.000e-17,1.500e-17,2.200e-17,2.500e-17,4.400e-17,4.200e-17,2.700e-17,
+          1.200e-17,5.800e-18,1.400e-19,9.100e-21 };
+   static double sC3H8[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,4.000e-17,4.000e-17,4.000e-17,
+          4.000e-17,4.000e-17,3.280e-17,3.100e-17,2.680e-17,2.200e-17,1.760e-17,
+          6.440e-18,3.000e-18,9.140e-19,7.000e-20 };
+   static double sC4H2[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,2.500e-17,6.100e-17,4.780e-17,5.780e-17,1.014e-16,
+          5.200e-17,4.200e-17,1.030e-16,1.770e-16,9.100e-17,1.290e-17,2.380e-18,
+          3.400e-19,2.800e-19,2.600e-19,1.513e-19,2.583e-19,3.353e-19,4.115e-19,
+          4.755e-19,4.990e-19,4.399e-19,5.358e-19,2.485e-19,3.931e-19,1.067e-19,
+          3.761e-20,2.370e-20,2.277e-20 };
+   static double sC4H4[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,4.200e-17,5.000e-17,2.000e-17,6.700e-18,
+          6.100e-18,8.000e-18,1.000e-17,1.400e-17,1.900e-17,2.200e-17,2.600e-17,
+          1.600e-17,1.600e-17,4.000e-18,5.700e-19,1.400e-19 };
+   static double sC4H6[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,6.000e-18,1.200e-17,1.500e-17,1.300e-17,
+          1.800e-17,3.100e-17,3.800e-17,6.600e-17,9.600e-17,1.060e-16,8.500e-17,
+          6.700e-17,1.100e-17,1.700e-18,3.300e-19,6.500e-20 };
+   static double sC4H10[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,6.000e-17,6.000e-17,6.000e-17,
+          6.000e-17,6.000e-17,5.500e-17,4.400e-17,4.400e-17,3.800e-17,3.100e-17,
+          1.900e-17,4.000e-18,1.300e-18,3.200e-19,2.000e-20 };
+   static double sC6H6[62] = { 
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,7.000e-17,
+          8.000e-17,5.000e-17,3.500e-17,3.500e-17,3.500e-17,2.000e-17,1.500e-17,
+          1.500e-17,1.500e-17,2.000e-17,2.500e-17,4.000e-17,9.500e-17,2.200e-16,
+          1.000e-16,2.000e-17,2.000e-17,2.000e-17,2.000e-17,5.000e-18,1.000e-20,
+          1.000e-20,1.000e-20,1.000e-20,1.000e-20,1.000e-19,2.000e-19,2.500e-19,
+          4.000e-19,2.000e-19,2.000e-19,1.000e-19 };
+   static double sN2[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,4.898e-18,1.097e-17,
+          2.192e-17,2.214e-17,2.336e-17,1.679e-17,1.893e-17 };
+   static double sHCN[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,2.800e-17,3.300e-17,2.800e-17,3.500e-17,
+          4.800e-17,2.800e-17,1.700e-17,3.600e-18,2.500e-18,4.700e-18,2.700e-18,
+          8.600e-19,4.400e-19,2.000e-19,1.429e-19,1.145e-19,7.482e-20,3.852e-20,
+          1.009e-20 };
+   static double sHC3N[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,3.402e-17,
+          3.647e-17,4.317e-17,3.759e-17,7.927e-17,3.796e-17,9.565e-17,1.716e-16,
+          1.247e-16,2.360e-17,8.411e-18,4.400e-18,8.600e-19,7.400e-19,6.200e-19,
+          4.899e-19,3.307e-19,2.128e-19,2.561e-19,2.621e-19,2.737e-19,3.601e-19,
+          1.564e-19,1.816e-19,8.427e-20 };
+   static double sC2N2[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,2.635e-17,
+          3.126e-17,4.392e-17,9.788e-17,1.682e-16,1.064e-16,6.513e-18,2.039e-18,
+          2.828e-18,5.136e-18,8.188e-18,8.857e-18,1.489e-18,9.000e-20,6.200e-20,
+          3.800e-20,4.483e-20,8.618e-20,1.008e-19,7.579e-20,6.666e-20,2.907e-20,
+          2.476e-20,1.142e-20 };
+   static double sH2O[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,1.927e-17,9.633e-18,7.440e-18,
+          1.087e-18,8.600e-18,8.850e-18,7.300e-18,4.100e-18,1.240e-18,5.600e-19,
+          7.977e-19,1.888e-18,3.333e-18,4.729e-18,4.963e-18,3.513e-18,1.440e-18,
+          1.563e-19 };
+   static double sCO[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,7.300e-17,2.050e-16,9.000e-17,7.180e-18,3.700e-17};
+   static double sCO2[62] = {
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,0.000e+00,
+          0.000e+00,1.022e-19,1.070e-19,4.220e-19,8.220e-19,6.640e-19,5.650e-19,
+          5.850e-19,4.400e-19,2.100e-19,8.700e-20,4.000e-20,2.130e-20,3.700e-21,
+          6.930e-22,4.040e-22,2.470e-23,4.800e-24,9.500e-25 };
+   static double sol[62] = {
+          9.45e+08,2.84e+08,4.24e+09,3.11e+09,1.22e+10,6.83e+09,2.54e+09,8.20e+08,
+          1.82e+09,1.30e+09,1.05e+09,1.37e+09,3.87e+08,4.29e+08,2.45e+09,4.09e+09,
+          1.06e+10,1.03e+10,4.08e+09,2.98e+10,7.00e+09,1.94e+09,7.40e+09,4.12e+11,
+          1.36e+10,4.92e+10,3.04e+10,3.81e+10,5.49e+10,1.00e+11,1.26e+11,1.67e+11,
+          2.97e+11,4.92e+11,7.17e+11,9.43e+11,1.34e+12,1.96e+12,2.96e+12,4.34e+12,
+          7.25e+12,1.76e+13,2.21e+13,3.10e+13,2.80e+13,2.97e+13,3.03e+13,3.77e+13,
+          3.44e+13,3.42e+13,7.08e+13,9.58e+13,1.63e+14,1.38e+14,1.26e+14,1.60e+14,
+          2.23e+14,3.70e+14,3.31e+14,3.26e+14,3.59e+14,4.05e+14};
+
+   int   i,j,l,s,lat,x;
+   double f,**flux;
+   double flact;
+   char   name[60],dir[24];
+   FILE   *fp,*out;
+
+   flux = dm2d(0,NLRT,0,14);
+
+/* lecture des flux actiniques:
+   - suppose que l'executable est dans $LMDGCM/RUN/xxx/
+   - et les moyennes dans $LMDGCM/INPUT/PHOT(NLAT)/Moy_(lat:1 a NLAT)
+*/
+   strcpy( dir, "../../INPUT/PHOT" );
+   if( (*NLAT) < 10 )
+   {
+     strcat( dir, "0"  );
+     strcat( dir, (const char *)ecvt((float)(*NLAT),1,&x,&x) );
+   }
+   else 
+     strcat( dir, (const char *)ecvt((float)(*NLAT),2,&x,&x) );
+   strcat( dir, "x/Moy_"  );
+   printf( "Directories for actinic fluxes: %s \n", dir );
+ 
+   for( lat = 0; lat <= (*NLAT)-1; lat++ )   /* Old array is set equal to 0. */
+     for( j = 0; j <= NLRT-1; j++ )
+       for( i = 0; i <= RDISS; i++ )                  
+         for( s = 0; s <= 14; s++ )
+            KRPD[lat][j][i][s] = 0.0e0;
+            
+   for( i = 0; i <= 13; i++ ) sCH4[i]  = 0.0e0;
+   for( i = 0; i <= 13; i++ ) sC2H2[i] = 0.0e0;
+   for( i = 0; i <= 16; i++ ) sC2H4[i] = 0.0e0;
+   for( i = 0; i <= 16; i++ ) sC2H6[i] = 0.0e0;
+
+   for( lat = 0; lat <= (*NLAT)-1; lat++ ) /*     Main loop on latitude */
+   for( i = 10; i <= 310; i += 5 )             /* Main loop on wavelength. */
+   {
+      strcpy( name, dir ); 
+      if( (lat+1) < 10 )
+      {
+       strcat( name, "0"  );
+       strcat( name, (const char *)ecvt((float)(lat+1),1,&x,&x) );
+      }
+      else 
+       strcat( name, (const char *)ecvt((float)(lat+1),2,&x,&x) );
+      if( i < 160 ) strcat( name, "/photmoy3a" );
+      else          strcat( name, "/photmoy3a" );
+      if( i < 100 )
+      {
+         strcat( name, ".0" );
+         strcat( name, (const char *)ecvt((float)i,2,&x,&x) );
+      }
+      else
+      {
+         strcat( name, "." );
+         strcat( name, (const char *)ecvt((float)i,3,&x,&x) );
+      }
+      if( !( fp = fopen( name, "r" ) ) )
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "I cannot open %s\n", name );
+         fclose( out );
+         exit(0);
+      }
+      for( j = 0; j <= NLRT-1; j++ )
+      {
+         fscanf( fp,"%d ",&l );
+         for( s = 0; s < 15; s++ )
+         {
+           fscanf( fp,"%lg ", &flact );
+           flux[j][s] = flact;
+         }
+      }
+      fclose(fp);
+
+      l = i / 5 - 2;                  /* Pointer on wavelength. */
+      
+/* taux de photodissociations */
+
+      for( s = 0; s <= 14; s++ )
+       for( j = 0; j <= NLRT-1; j++ )
+       {
+         f = flux[j][s] * sol[l] / ( 9.5e0 * 9.5e0 );   /* !! # de reac de 0 a RDISS-1 !! */
+         if( i == 220 ) KRPD[lat][j][1][s] += 4.4e-17 * f;  /* CH3 -> 1CH2 + H */
+         KRPD[lat][j][ 0][s] += sH2[l]     * f * 1.00;      /* H2  -> H + H */
+         KRPD[lat][j][ 7][s] += sC2H4[l]   * f * 0.51;      /* C2H4 -> C2H2 + H2 */
+         KRPD[lat][j][ 8][s] += sC2H4[l]   * f * 0.49;      /* C2H4 -> C2H2 + 2H */
+         KRPD[lat][j][15][s] += sCH2CCH2[l]* f * 0.89;      /* CH2CCH2 -> C3H3 + H    Jackson 91 */
+         KRPD[lat][j][16][s] += sCH2CCH2[l]* f * 0.11;      /* CH2CCH2 -> C3H2 + H2   Jackson 91 */
+         KRPD[lat][j][17][s] += sCH3C2H[l] * f * 0.89;      /* CH3C2H -> C3H3 + H     Jackson 91 */
+         KRPD[lat][j][18][s] += sCH3C2H[l] * f * 0.11;      /* CH3C2H -> C3H2 + H2    Jackson 91 */
+         KRPD[lat][j][19][s] += sC3H6[l]   * f * 0.33;      /* C3H6 -> CH2CCH2 + H2 */
+         KRPD[lat][j][20][s] += sC3H6[l]   * f * 0.17;      /* C3H6 -> CH3CCH + H2 */
+         KRPD[lat][j][21][s] += sC3H6[l]   * f * 0.03;      /* C3H6 -> C2H4 + 3CH2 */
+         KRPD[lat][j][22][s] += sC3H6[l]   * f * 0.35;      /* C3H6 -> C2H3 + CH3 */
+         KRPD[lat][j][23][s] += sC3H6[l]   * f * 0.05;      /* C3H6 -> C2H2 + CH4 */
+         KRPD[lat][j][32][s] += sC4H4[l]   * f * 0.80;      /* C4H4 -> C4H2 + H2     Gladstone 96 */
+         KRPD[lat][j][33][s] += sC4H4[l]   * f * 0.20;      /* C4H4 -> C2H2 + C2H2   Gladstone 96  */
+         KRPD[lat][j][34][s] += sC4H6[l]   * f * 0.04;      /* C4H6 -> C4H4 + H2 */
+         KRPD[lat][j][35][s] += sC4H6[l]   * f * 0.27;      /* C4H6 -> C2H4 + C2H2 */
+         KRPD[lat][j][36][s] += sC4H6[l]   * f * 0.69;      /* C4H6 -> CH3 + C3H3 */
+         KRPD[lat][j][45][s] += sC6H6[l]   * f * 0.04;      /* AC6H6 -> C5H3 (prod...) + CH3 */
+         KRPD[lat][j][46][s] += sC6H6[l]   * f * 0.96;      /* AC6H6 -> AC6H5 + H */
+         KRPD[lat][j][47][s] += sN2[l]     * f;             /* N2   -> 2N2d */
+         KRPD[lat][j][48][s] += sHCN[l]    * f;             /* HCN  -> H + CN */
+         KRPD[lat][j][51][s] += sC2N2[l]   * f * 0.3;       /* C2N2 -> 2CN */
+         KRPD[lat][j][52][s] += sCH3CN[l]  * f * 1.0;       /* CH3CN -> CH3 + CN */
+         KRPD[lat][j][53][s] += sC2N2[l]   * f * 0.3;       /* C4N2 -> C3N + CN */
+
+         if( i != 125 )          /* Not Lyman alpha */
+         {
+            KRPD[lat][j][ 2][s] += sCH4[l]  * f;            /* CH4 -> 1CH2 + H2 */
+            KRPD[lat][j][ 9][s] += sC2H6[l] * f * 0.56;     /* C2H6 -> C2H4 + H2 */
+            KRPD[lat][j][10][s] += sC2H6[l] * f * 0.14;     /* C2H6 -> C2H4 + 2H */
+            KRPD[lat][j][11][s] += sC2H6[l] * f * 0.27;     /* C2H6 -> C2H2 + 2H2 */
+            KRPD[lat][j][12][s] += sC2H6[l] * f * 0.02;     /* C2H6 -> CH4 + 3CH2 */
+            KRPD[lat][j][13][s] += sC2H6[l] * f * 0.01;     /* C2H6 -> 2CH3 */
+            KRPD[lat][j][24][s] += sC3H8[l] * f * 0.94;     /* C3H8 -> C3H6 + H2 */
+            KRPD[lat][j][27][s] += sC3H8[l] * f * 0.06;     /* C3H8 -> C2H4 + CH4 */
+         }
+         else                       /* Lyman alpha */
+         {
+            KRPD[lat][j][ 2][s] += sCH4[l]  * f * 0.64;     /* CH4 -> 1CH2 + H2 */
+            KRPD[lat][j][ 3][s] += sCH4[l]  * f * 0.07;     /* CH4 -> CH + H2 + H */
+            KRPD[lat][j][ 4][s] += sCH4[l]  * f * 0.29;     /* CH4 -> CH3 + H */
+            KRPD[lat][j][ 9][s] += sC2H6[l] * f * 0.13;     /* C2H6 -> C2H4 + H2 */
+            KRPD[lat][j][10][s] += sC2H6[l] * f * 0.3;      /* C2H6 -> C2H4 + 2H */
+            KRPD[lat][j][11][s] += sC2H6[l] * f * 0.25;     /* C2H6 -> C2H2 + 2H2 */
+            KRPD[lat][j][12][s] += sC2H6[l] * f * 0.25;     /* C2H6 -> CH4 + 3CH2 */
+            KRPD[lat][j][13][s] += sC2H6[l] * f * 0.08;     /* C2H6 -> 2CH3 */
+            KRPD[lat][j][24][s] += sC3H8[l] * f * 0.33;     /* C3H8 -> C3H6 + H2 */
+            KRPD[lat][j][25][s] += sC3H8[l] * f * 0.09;     /* C3H8 -> C2H6 + 3CH2 */
+            KRPD[lat][j][26][s] += sC3H8[l] * f * 0.39;     /* C3H8 -> C2H5 + CH3 */
+            KRPD[lat][j][27][s] += sC3H8[l] * f * 0.2;      /* C3H8 -> C2H4 + CH4 */
+         }
+         if( i < 145 )   /* C4H10: a revoir avec Jackson & Lias, 1974... */
+         {
+            KRPD[lat][j][37][s] += sC4H10[l]* f * 0.18;      /* C4H10 -> C4H8(ieC3H5+CH3)+H2 */
+            KRPD[lat][j][38][s] += sC4H10[l]* f * 0.20;      /* C4H10 -> 2 C2H4 + H2 */
+            KRPD[lat][j][39][s] += sC4H10[l]* f * 0.03;      /* C4H10 -> C3H6 + CH4 */
+            KRPD[lat][j][40][s] += sC4H10[l]* f * 0.07;      /* C4H10 -> C3H6 + CH3 + H */
+            KRPD[lat][j][41][s] += sC4H10[l]* f * 0.00;      /* C4H10 -> C2H6 + C2H4 */
+            KRPD[lat][j][42][s] += sC4H10[l]* f * 0.15;      /* C4H10 -> C2H6 + C2H2 + H2 */
+            KRPD[lat][j][43][s] += sC4H10[l]* f * 0.27;      /* C4H10 -> CH3 + C3H7 */
+            KRPD[lat][j][44][s] += sC4H10[l]* f * 0.10;      /* C4H10 -> 2 C2H5 */
+         }
+         else
+         {
+            KRPD[lat][j][37][s] += sC4H10[l]* f * 0.41;      /* C4H10 -> C4H8(ieC3H5+CH3)+H2 */
+            KRPD[lat][j][38][s] += sC4H10[l]* f * 0.12;      /* C4H10 -> 2 C2H4 + H2 */
+            KRPD[lat][j][39][s] += sC4H10[l]* f * 0.01;      /* C4H10 -> C3H6 + CH4 */
+            KRPD[lat][j][40][s] += sC4H10[l]* f * 0.07;      /* C4H10 -> C3H6 + CH3 + H */
+            KRPD[lat][j][41][s] += sC4H10[l]* f * 0.02;      /* C4H10 -> C2H6 + C2H4 */
+            KRPD[lat][j][42][s] += sC4H10[l]* f * 0.06;      /* C4H10 -> C2H6 + C2H2 + H2 */
+            KRPD[lat][j][43][s] += sC4H10[l]* f * 0.24;      /* C4H10 -> CH3 + C3H7 */
+            KRPD[lat][j][44][s] += sC4H10[l]* f * 0.07;      /* C4H10 -> 2 C2H5 */
+         }
+         if( i < 150 )
+         {
+            KRPD[lat][j][ 5][s] += sC2H2[l] * f * 0.3;      /* C2H2 -> C2H + H */
+            KRPD[lat][j][ 6][s] += sC2H2[l] * f * 0.1;      /* C2H2 -> C2 + H2 */
+            KRPD[lat][j][49][s] += sHC3N[l] * f * 0.3;      /* HC3N -> C2H + CN */
+            KRPD[lat][j][50][s] += sHC3N[l] * f * 0.09;     /* HC3N -> H + C3N */
+         }
+         else if( i < 205 )
+         {
+            KRPD[lat][j][ 5][s] += sC2H2[l] * f * 0.08;     /* C2H2 -> C2H + H */
+            KRPD[lat][j][ 6][s] += sC2H2[l] * f * 0.1;      /* C2H2 -> C2 + H2 */
+            KRPD[lat][j][49][s] += sHC3N[l] * f * 0.05;     /* HC3N -> C2H + CN */
+            KRPD[lat][j][50][s] += sHC3N[l] * f * 0.09;     /* HC3N -> H + C3N */
+         }
+         else if( i < 245 )
+         {
+            KRPD[lat][j][50][s] += sHC3N[l] * f * 0.09;     /* HC3N -> H + C3N */
+         }
+         if( i < 165 )
+         {
+            KRPD[lat][j][28][s] += sC4H2[l] * f * 0.2;      /* C4H2 -> C4H + H */
+            KRPD[lat][j][29][s] += sC4H2[l] * f * 0.03;     /* C4H2 -> 2C2H */
+            KRPD[lat][j][30][s] += sC4H2[l] * f * 0.1;      /* C4H2 -> C2H2 + C2 */
+            KRPD[lat][j][31][s] += sC4H2[l] * f * 0.67;     /* C4H2 -> C4H2* */
+         }
+         else if( i < 205 )
+         {
+            KRPD[lat][j][29][s] += sC4H2[l] * f * 0.01;     /* C4H2 -> 2C2H */
+            KRPD[lat][j][30][s] += sC4H2[l] * f * 0.06;     /* C4H2 -> C2H2 + C2 */
+            KRPD[lat][j][31][s] += sC4H2[l] * f * 0.93;     /* C4H2 -> C4H2* */
+         }
+         else
+         {
+            KRPD[lat][j][31][s] += sC4H2[l] * f * 1.00;     /* C4H2 -> C4H2* */
+         }
+         if( i < 190 ) KRPD[lat][j][14][s] += 4.e-17 * f;   /* C3H3 -> C3H2 + H */
+      }
+   }
+
+/* taux de dissociation de N2 ( e- et GCR ) */
+
+   for( lat = 0; lat <= (*NLAT)-1; lat++ ) 
+    for( s = 0; s <= 14; s++ )
+    {
+     for( j = 99; j <= NLRT-1; j++ )  /* level 100 = 200 km */
+      KRPD[lat][j][RDISS][s] = 1.0e-16;
+     for( j = 49; j <= 98; j++ )      /* level 50 = 100 km */
+      KRPD[lat][j][RDISS][s] = 1.0e-17+1.8e-18*(j-49);
+     for( j = 34; j <= 48; j++ )      /* level 35 = 70 km */
+      KRPD[lat][j][RDISS][s] = pow(10.,(-23+0.4*(j-34)));
+     for( j = 0; j <= 33; j++ )
+      KRPD[lat][j][RDISS][s] = 0.0e0;
+    }
+
+   fdm2d( flux, 0, NLEV, 0 );
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/dmxd.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/dmxd.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/dmxd.c	(revision 1644)
@@ -0,0 +1,345 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+                /* dm1d: memory allocation for a vector of double */
+                /* ---------------------------------------------- */
+                
+double *dm1d( int nl, int nh )
+{
+   double *m;
+   FILE  *out;
+
+   m = (double *)calloc( (unsigned)(nh-nl+1), sizeof(double) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in dm1d" );
+      fclose( out );
+      exit(0);
+   }
+   return m-nl;
+}
+
+                /* dm2d: memory allocation for a matrix of double */
+                /* ---------------------------------------------- */
+
+double **dm2d( int nrl, int nrh, int ncl, int nch )
+{
+   int   i;
+   double **m;
+   FILE  *out;
+
+   m = (double **)calloc( (unsigned)(nrh-nrl+1), sizeof(double *) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in dm2d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+   {
+      m[i] = (double *)calloc( (unsigned)(nch-ncl+1), sizeof(double) );
+      if(!m[i])
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "Memory allocation error in dm2d" );
+         fclose( out );
+         exit(0);
+      }
+      m[i] -= ncl;
+   }
+   return m;
+}
+
+                /* dm3d: memory allocation for a 3D vector of double */
+                /* ------------------------------------------------- */
+
+double ***dm3d( int nrl, int nrh, int ncl, int nch, int nal, int nah )
+{
+   int   i;
+   double ***m;
+   FILE  *out;
+
+   m = (double ***)calloc( (unsigned)(nrh-nrl+1), sizeof(double **) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in dm3d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+      m[i] = dm2d( ncl, nch, nal, nah );
+   return m;
+}
+
+                /* dm4d: memory allocation for a 4D vector of double */
+                /* ------------------------------------------------- */
+
+double ****dm4d( int nrl, int nrh, int ncl, int nch, int nal, int nah, int nll, int nlh )
+{
+   int   i;
+   double ****m;
+   FILE  *out;
+
+   m = (double ****)calloc( (unsigned)(nrh-nrl+1), sizeof(double ***) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in dm4d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+      m[i] = dm3d( ncl, nch, nal, nah, nll, nlh );
+   return m;
+}
+
+                     /* fdm1d: release a vector of double */
+                     /* --------------------------------- */
+
+void fdm1d(v,nl)
+double *v;
+int nl;
+{
+   free((char *)(v+nl));
+}
+
+                     /* fdm2d: release a matrix of double */
+                     /* --------------------------------- */
+
+void fdm2d(m,nrl,nrh,ncl)
+double **m;
+int ncl,nrh,nrl;
+{
+   int i;
+
+   for( i = nrh; i >= nrl; i-- ) free((char *)(m[i]+ncl));
+   free((char *)(m+nrl));
+}
+
+                     /* fdm3d: release a 3D vector of double */
+                     /* ------------------------------------ */
+
+void fdm3d(m,nrl,nrh,ncl,nch,nal)
+double ***m;
+int nch,ncl,nrh,nrl,nal;
+{
+   int i;
+
+   for( i = nrh; i >= nrl; i-- ) fdm2d(m[i],ncl,nch,nal);
+   free((char *)(m+nrl));
+}
+
+                     /* frm1d: release a vector of float */
+                     /* -------------------------------- */
+
+void frm1d(v,nl)
+float *v;
+int nl;
+{
+   free((char *)(v+nl));
+}
+
+                     /* frm2d: release a matrix of float */
+                     /* -------------------------------- */
+
+void frm2d(m,nrl,nrh,ncl)
+float **m;
+int ncl,nrh,nrl;
+{
+   int i;
+
+   for( i = nrh; i >= nrl; i-- ) free((char *)(m[i]+ncl));
+   free((char *)(m+nrl));
+}
+
+                     /* frm3d: release a 3D vector of float */
+                     /* ----------------------------------- */
+
+void frm3d(m,nrl,nrh,ncl,nch,nal)
+float ***m;
+int nch,ncl,nrh,nrl,nal;
+{
+   int i;
+
+   for( i = nrh; i >= nrl; i-- ) frm2d(m[i],ncl,nch,nal);
+   free((char *)(m+nrl));
+}
+
+                /* rm1d: memory allocation for a vector of float */
+                /* --------------------------------------------- */
+                
+float *rm1d( int nl, int nh )
+{
+   float *m;
+   FILE  *out;
+
+   m = (float *)calloc( (unsigned)(nh-nl+1), sizeof(float) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in rm1d" );
+      fclose( out );
+      exit(0);
+   }
+   return m-nl;
+}
+
+                /* rm2d: memory allocation for a matrix of float */
+                /* --------------------------------------------- */
+
+float **rm2d( int nrl, int nrh, int ncl, int nch )
+{
+   int   i;
+   float **m;
+   FILE  *out;
+
+   m = (float **)calloc( (unsigned)(nrh-nrl+1), sizeof(float *) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in rm2d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+   {
+      m[i] = (float *)calloc( (unsigned)(nch-ncl+1), sizeof(float) );
+      if(!m[i])
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "Memory allocation error in rm2d" );
+         fclose( out );
+         exit(0);
+      }
+      m[i] -= ncl;
+   }
+   return m;
+}
+
+                /* rm3d: memory allocation for a 3D vector of float */
+                /* ------------------------------------------------ */
+
+float ***rm3d( int nrl, int nrh, int ncl, int nch, int nal, int nah )
+{
+   int   i;
+   float ***m;
+   FILE  *out;
+
+   m = (float ***)calloc( (unsigned)(nrh-nrl+1), sizeof(float **) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in rm3d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+      m[i] = rm2d( ncl, nch, nal, nah );
+   return m;
+}
+
+                /* rm4d: memory allocation for a 4D vector of float */
+                /* ------------------------------------------------ */
+
+float ****rm4d( int nrl, int nrh, int ncl, int nch, int nal, int nah, int nll, int nlh )
+{
+   int   i;
+   float ****m;
+   FILE  *out;
+
+   m = (float ****)calloc( (unsigned)(nrh-nrl+1), sizeof(float ***) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in rm4d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+      m[i] = rm3d( ncl, nch, nal, nah, nll, nlh );
+   return m;
+}
+
+                /* im1d: memory allocation for a vector of integer */
+                /* ----------------------------------------------- */
+
+int *im1d( int nl, int nh )
+{
+   int *m;
+   FILE *out;
+
+   m = (int *)calloc( (unsigned)(nh-nl+1), sizeof(int ) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in im1d" );
+      fclose( out );
+      exit(0);
+   }
+   return m-nl;
+}
+
+                /* im2d: memory allocation for a matrix of integer */
+                /* ----------------------------------------------- */
+
+int **im2d( int nrl, int nrh, int ncl, int nch )
+{
+   int i,**m;
+   FILE *out;
+
+   m = (int **)calloc( (unsigned)(nrh-nrl+1), sizeof(int *) );
+   if( !m )
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in im2d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+   {
+      m[i] = (int *)calloc( (unsigned)(nch-ncl+1), sizeof(int) );
+      if(!m[i])
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "Memory allocation error in im2d" );
+         fclose( out );
+         exit(0);
+      }
+      m[i] -= ncl;
+   }
+   return m;
+}
+
+                /* im3d: memory allocation for a 3D vector of integer */
+                /* -------------------------------------------------- */
+
+int ***im3d( int nrl, int nrh, int ncl, int nch, int nal, int nah )
+{
+   int i,***m;
+   FILE *out;
+
+   m = (int ***)calloc( (unsigned)(nrh-nrl+1), sizeof(int **) );
+   if(!m)
+   {
+      out = fopen( "err.log", "a" );
+      fprintf( out, "Memory allocation error in im3d" );
+      fclose( out );
+      exit(0);
+   }
+   m -= nrl;
+   for( i = nrl; i <= nrh; i++ )
+      m[i] = im2d( ncl, nch, nal, nah );
+   return m;
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/gptitan.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/gptitan.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/gptitan.c	(revision 1644)
@@ -0,0 +1,919 @@
+/* gptitan: photochimie */
+/* GCCM */
+
+/* tout est passe en simple precision */
+/* sauf pour l'inversion de la matrice */
+
+/* nitriles et hydrocarbures separes pour l'inversion */
+
+/* flux variable au sommet */
+
+#include "titan.h"
+
+void gptitan_(
+     double *RA, double *TEMP, double *NB, 
+     char CORPS[][10], double Y[][NLEV],
+     double *FIN, int *LAT, double *MASS, double MD[][NLEV],
+     double *KEDD, double *botCH4, double KRATE[][NLEV],
+     int reactif[][5], int *nom_prod, int *nom_perte, 
+     int prod[][200], int perte[][200][2], int *aerprod, int *utilaer, 
+     double MAER[][NLEV], double PRODAER[][NLEV], 
+     double CSN[][NLEV], double CSH[][NLEV],
+     int *htoh2, double *surfhaze)
+{
+   char   outlog[100],corps[100][10];
+   int    i,j,k,l;
+   int    ireac,ncom1,ncom2;
+   double  ***a,***b,**c;
+   double  *fl,*fp,*mu,**jac,**ym1,**f;
+   double  fluxCH4;
+   double  conv,delta,deltamax;
+   double  cm,cp,dim,dip,dm,dp,dym,dyp,km,kp,r,dra,dram,drap;
+   double  np,nm,s,test,time,ts,v,dv;
+   char   str2[15];
+   FILE   *out;
+
+/* va avec htoh2 */
+   double  dyh,dyh2;
+
+/* va avec aer */
+   double  dyc2h2,dyhc3n,dyhcn,dynccn,dych3cn,dyc2h3cn;
+   double  **k_dep,**faer;
+   double  *productaer,*csurn,*csurh,*mmolaer;
+
+   if( (*aerprod) == 1 )
+   {
+    k_dep = dm2d( 1, 5, 1, 3 );     /* k en s-1, reactions d'initiation */
+    faer  = dm2d( 1, 5, 1, 3 );     /* fraction de chaque compose */
+    productaer  = dm1d( 0, 3 );     /* local production rate by pathways */
+    mmolaer     = dm1d( 0, 3 );     /* local molar mass by pathways */
+    csurn = dm1d( 0, 3 );           /* local C/N by pathways */
+    csurh = dm1d( 0, 3 );           /* local C/H by pathways */
+   }
+
+/* DEBUG */
+      printf("CHIMIE: lat=%d\n",(*LAT)+1);
+/**/
+
+   for( i = 0; i <= NC; i++)
+   {
+     strcpy( corps[i], CORPS[i] );
+     corps[i][strcspn(CORPS[i], " ")] = '\0';
+   }
+   
+   strcpy( outlog, "chimietitan" );
+   strcat( outlog, ".log" );
+   out = fopen( outlog, "w" );
+   fprintf(out,"CHIMIE: lat=%d\n",(*LAT)+1);
+   fclose( out );
+
+   deltamax = 1.e5;
+   test = 1.0e-15; 
+
+/* valeur de r:
+r = g0 R0^2 / R * 2 * 1E-3
+avec g0 en cm/s2, R0 en km, mu et mass en g
+*/
+   r        = 21.595656e0;
+
+/*  DEBUG 
+            out = fopen( outlog, "a" );
+   fprintf(out,"CHIMIE: lat=%d\n",(*LAT)+1);
+            fclose( out );
+*/
+   fl      = dm1d( 0,   NC-1 );
+   fp      = dm1d( 0,   NC-1 );
+   mu      = dm1d( 0, NLEV-1 );
+   ym1     = dm2d( 0,   NC-1, 0, NLEV-1 );
+   f       = dm2d( 0,   NC-1, 0, NLEV-1 );
+   jac     = dm2d( 0,   NC-1, 0,   NC-1 );
+   c       = dm2d( 0, NLEV-1, 0,   NC-1 );
+   a       = dm3d( 0, NLEV-1, 0,   NC-1, 0,   NC-1 );
+   b       = dm3d( 0, NLEV-1, 0,   NC-1, 1,    2 );
+
+/* DEBUG */
+/* 
+            out = fopen( "err.log", "a" );
+            fprintf( out,"%s\n", );
+            fclose( out );
+*/
+
+/* initialisation mu, CH4 au sol */
+     
+   for( j = 0; j <= NLEV-1; j++ )
+   {
+      mu[j] = 0.0e0;
+      for( i = 0; i <= ST-1; i++ ) 
+      {
+         if( ( strcmp(corps[i], "CH4") == 0 ) && ( Y[i][j] <= *botCH4 ) && ( j == 0 ) )
+         {
+             fluxCH4 = (*botCH4 - Y[i][j]);
+             Y[i][j] = *botCH4;
+         }
+         mu[j] += ( MASS[i] * Y[i][j] );
+      }
+   }
+
+/* initialisation compo avant calcul */
+   for( j = NLEV-1; j >= 0; j-- )
+      for( i = 0; i <= ST-1; i++ ) ym1[i][j] = max(Y[i][j],1.e-30);
+
+/* 
+==========================================================================
+   STRATEGIE:
+    INVERSION COMPLETE AVEC DIFFUSION ENTRE NLEV-1 et NLD 
+    PUIS INVERSION LOCALE PAR BLOC ENTRE NLD ET LA SURFACE
+==========================================================================
+
+PREMIERE ETAPE: 
+===============
+    INVERSION COMPLETE AVEC DIFFUSION ENTRE NLEV-1 et NLD 
+===============
+*/
+
+/* ****************** */
+/*  Time loop:        */
+/* ****************** */
+
+time     = ts = 0.0e0;
+delta    = 1.e-3;
+
+while( time < (*FIN) )     
+{
+
+
+/* DEBUG 
+   for( j = NLEV-1; j >= NLD; j-- )
+   {
+            out = fopen( outlog, "a" );
+        fprintf(out,"j=%d z=%e nb=%e T=%e\n",j,(RA[j]-R0),NB[j],TEMP[j]);
+            fclose( out );
+
+            out = fopen( "profils.log", "a" );
+    fprintf(out,"%d %e %e %e\n",j,(RA[j]-R0),NB[j],TEMP[j]);
+    for (i=0;i<=NREAC-1;i++) fprintf(out,"%d %e\n",i,KRATE[i][j]);
+    for (i=0;i<=ST-1;i++) fprintf(out,"%10s %e\n",corps[i],Y[i][j]);
+            fclose( out );
+    }
+   exit(0);
+*/
+
+
+/* ------------------------------ */
+/* Calculs variations et jacobien */
+/* ------------------------------ */
+
+   for( j = NLEV-1; j >= NLD; j-- )
+   {
+
+/* init of step */
+/* ------------ */
+         for( i = 0; i <= ST-1; i++ ) 
+         {
+            fp[i] = fl[i] = 0.0e0; 
+            for( l = 0; l <= ST-1; l++ ) jac[i][l] = 0.0e0;
+         }
+
+/* Chimie */
+/* ------ */
+
+/* productions et pertes chimiques */
+         for( i = 0; i <= ST-1; i++ )    
+         {
+            Y[i][j] = max(Y[i][j],1.e-30);                /* minimum */
+
+            for( l = 0; l <= nom_prod[i]-1; l++ )    /* Production term */
+            {
+               ireac = prod[i][l];                  /* Number of the reaction involves. */
+               ncom1 = reactif[ireac][0];           /* First compound which reacts. */
+               if( reactif[ireac][1] == NC )        /* Photodissociation or relaxation */
+               {
+                  jac[i][ncom1] += ( KRATE[ireac][j] * NB[j] );
+                  fp[i]         += ( KRATE[ireac][j] * NB[j] * Y[ncom1][j] );
+               }
+               else                                 /* General case. */
+               {
+                  ncom2          = reactif[ireac][1];                       /* Second compound which reacts. */
+                  jac[i][ncom1] += ( KRATE[ireac][j] * Y[ncom2][j] );       /* Jacobian compound #1. */
+                  jac[i][ncom2] += ( KRATE[ireac][j] * Y[ncom1][j] );       /* Jacobian compound #2. */
+                  fp[i] += ( KRATE[ireac][j] * Y[ncom1][j] * Y[ncom2][j] ); /* Production term. */
+               }
+            }
+            
+            for( l = 0; l <= nom_perte[i]-1; l++ )   /* Loss term. */
+            {
+               ireac = perte[i][l][0];              /* Reaction number. */
+               ncom2 = perte[i][l][1];              /* Compound #2 reacts. */
+               if( reactif[ireac][1] == NC )        /* Photodissociation or relaxation */
+               {
+                  jac[i][i] -= ( KRATE[ireac][j] * NB[j] );
+                  fl[i]     += ( KRATE[ireac][j] * NB[j] );
+               }
+               else                                 /* General case. */
+               {
+                  jac[i][ncom2] -= ( KRATE[ireac][j] * Y[i][j] );       /* Jacobian compound #1. */
+                  jac[i][i]     -= ( KRATE[ireac][j] * Y[ncom2][j] );   /* Jacobien compound #2. */
+                  fl[i]         += ( KRATE[ireac][j] * Y[ncom2][j] );   /* Loss term. */
+               }
+            }
+         }
+
+
+/* Aerosols */
+/* -------- */
+         if( (*aerprod) == 1 )
+         {
+             aer(corps,TEMP,NB,Y,&j,k_dep,faer,
+              &dyc2h2,&dyhc3n,&dyhcn,&dynccn,&dych3cn,&dyc2h3cn,utilaer,
+              mmolaer,productaer,csurn,csurh);
+
+             for( i = 0; i <= 3; i++ )
+             {
+               PRODAER[i][j] = productaer[i];
+                  MAER[i][j] = mmolaer[i];
+                   CSN[i][j] = csurn[i];
+                   CSH[i][j] = csurh[i];
+             }
+/* DEBUG
+printf("AERPROD : LAT = %d - J = %d\n",(*LAT),j);
+if(fabs(dyc2h2*NB[j])>fabs(fp[utilaer[2]]/10.))
+      printf("fp(%s) =%e; dyc2h2 =%e\n",corps[utilaer[2]],
+              fp[utilaer[2]],dyc2h2*NB[j]);
+if(fabs(dyhcn*NB[j])>fabs(fp[utilaer[5]]/10.))
+      printf("fp(%s) =%e; dyhcn  =%e\n",corps[utilaer[5]],
+              fp[utilaer[5]],dyhcn*NB[j]);
+if(fabs(dyhc3n*NB[j])>fabs(fp[utilaer[6]]/10.))
+      printf("fp(%s) =%e; dyhc3n =%e\n",corps[utilaer[6]],
+              fp[utilaer[6]],dyhc3n*NB[j]);
+if(fabs(dynccn*NB[j])>fabs(fp[utilaer[13]]/10.))
+      printf("fp(%s) =%e; dynccn =%e\n",corps[utilaer[13]],
+              fp[utilaer[13]],dynccn*NB[j]);
+if(fabs(dych3cn*NB[j])>fabs(fp[utilaer[14]]/10.))
+      printf("fp(%s) =%e; dych3cn=%e\n",corps[utilaer[14]],
+              fp[utilaer[14]],dych3cn*NB[j]);
+if(fabs(dyc2h3cn*NB[j])>fabs(fp[utilaer[15]]/10.))
+      printf("fp(%s) =%e; dyc2h3cn=%e\n",corps[utilaer[15]],
+              fp[utilaer[15]],dyc2h3cn*NB[j]);
+*/
+
+             fp[utilaer[2]] -= (   dyc2h2 * NB[j] );
+             fp[utilaer[5]] -= (    dyhcn * NB[j] );
+             fp[utilaer[6]] -= (   dyhc3n * NB[j] );
+             fp[utilaer[13]]-= (   dynccn * NB[j] );
+             fp[utilaer[14]]-= (  dych3cn * NB[j] );
+             fp[utilaer[15]]-= ( dyc2h3cn * NB[j] );
+             if( Y[utilaer[2]][j]  != 0.0 )
+       jac[utilaer[2]][utilaer[2]] -= (  dyc2h2 * NB[j] / Y[utilaer[2]][j] );
+             if( Y[utilaer[5]][j]  != 0.0 )
+       jac[utilaer[5]][utilaer[5]] -= (   dyhcn * NB[j] / Y[utilaer[5]][j] );
+             if( Y[utilaer[6]][j]  != 0.0 )
+       jac[utilaer[6]][utilaer[6]] -= (  dyhc3n * NB[j] / Y[utilaer[6]][j] );
+             if( Y[utilaer[13]][j] != 0.0 )
+     jac[utilaer[13]][utilaer[13]] -= (  dynccn * NB[j] / Y[utilaer[13]][j] );
+             if( Y[utilaer[14]][j] != 0.0 )
+     jac[utilaer[14]][utilaer[14]] -= ( dych3cn * NB[j] / Y[utilaer[14]][j] );
+             if( Y[utilaer[15]][j] != 0.0 )
+     jac[utilaer[15]][utilaer[15]] -= (dyc2h3cn * NB[j] / Y[utilaer[15]][j] );
+         }
+     
+       
+/* H -> H2 on haze particles */
+/* ------------------------- */
+         if( (*htoh2) == 1 )
+         {
+              heterohtoh2(corps,TEMP,NB,Y,surfhaze,&j,&dyh,&dyh2,utilaer);
+/* dyh <= 0 / 1.0 en adsor., 1 en reac. */
+
+/* DEBUG 
+printf("HTOH2 : LAT = %d - J = %d\n",(*LAT),j);
+if(fabs(dyh*NB[j])>fabs(fp[utilaer[0]]/10.))
+printf("fp(%s) = %e; dyh  = %e\n",corps[utilaer[0]],fp[utilaer[0]],dyh*NB[j]);
+if(fabs(dyh2*NB[j])>fabs(fp[utilaer[1]]/10.))
+printf("fp(%s) = %e; dyh2 = %e\n",corps[utilaer[1]],fp[utilaer[1]],dyh2*NB[j]);
+*/
+
+              fp[utilaer[0]] += ( dyh  * NB[j] ); 
+   /* pourquoi pas *2 ?? cf gptit dans 2da... */
+
+              fp[utilaer[1]] += ( dyh2 * NB[j] );
+              if( Y[utilaer[0]][j] != 0.0 )
+       jac[utilaer[0]][utilaer[0]] += ( dyh  * NB[j] / Y[utilaer[0]][j] );
+   /* pourquoi pas *2 ?? cf gptit dans 2da... */
+         }
+
+
+/* Backup jacobian level j. */
+/* ------------------------ */
+         for( i = 0; i <= ST-1; i++ )
+            for( k = 0; k <= ST-1; k++ )
+               a[j][i][k] = jac[i][k];     
+
+
+/* Diffusion verticale et flux exterieurs */
+/* -------------------------------------- */
+
+/*
+pour dy/dr, dr doit etre en cm...
+pareil pour dphi/dr
+*/
+         for( i = 0; i <= ST-1; i++ )
+         {
+
+/* First level. */
+            if( j == NLD )
+            {
+               v = dv = 0.0e0;
+               dra = RA[j+1]-RA[j];
+
+               cp  = (NB[j+1]+NB[j])/2.;  /* Mean total concentration. */
+               dip = r * (MASS[i]-(mu[j+1]+mu[j])/2.) / (TEMP[j+1]+TEMP[j]) /
+                     pow( RA[j+1], 2.0e0 );    /* Delta i,j level +1. */
+               dp  = (MD[i][j]+MD[i][j+1])/2.;     /* Mean molecular diffusion. */
+               dyp = (Y[i][j+1]-Y[i][j])/(RA[j+2]-RA[j])*2.e-5; /* Delta y level +1. */
+               kp  = (KEDD[j+1]+KEDD[j])/2.;       /* Mean eddy diffusion. */
+             /* div phi. */
+               f[i][j] = cp * ( dp * ( (Y[i][j+1]+Y[i][j])/2. * dip + dyp ) 
+                              + kp * dyp ) 
+                        * (4.e-5/dra/pow((1.+RA[j]/RA[j+1]),2.)) 
+                       + fp[i] - Y[i][j]*fl[i] + v;
+             /* dphi / dy this level. */
+               a[j][i][i] += ( cp * ( dp * 0.5e0 * dip 
+                                    - 2.e-5/(RA[j+2]-RA[j]) * (dp + kp) ) 
+                        * (4.e-5/dra/pow((1.+RA[j]/RA[j+1]),2.)) + dv );
+             /* dphi / dy level +1. */
+               c[j][i]     = -THETA * delta 
+                             * cp * ( dp * 0.5e0 * dip 
+                                    + 2.e-5/(RA[j+2]-RA[j]) * (dp + kp) ) 
+                        * (4.e-5/dra/pow((1.+RA[j]/RA[j+1]),2.));
+            }
+/* Last level. */
+            else if( j == NLEV-1 )
+            {
+               v = dv = 0.0e0;
+               dra = RA[NLEV-1]-RA[NLEV-2];
+
+   /* Jeans escape */
+               if( strcmp(corps[i], "H") == 0 )  
+               {
+                 dv = top_H  * NB[NLEV-1] 
+                        * (4.e-5/dra/pow((2.-dra/(RA[NLEV-1]+dra)),2.)); 
+                 v  = dv * Y[i][NLEV-1];
+               }
+               if( strcmp(corps[i], "H2") == 0 )
+               {
+                 dv = top_H2 * NB[NLEV-1]
+                        * (4.e-5/dra/pow((2.-dra/(RA[NLEV-1]+dra)),2.)); 
+                 v  = dv * Y[i][NLEV-1];
+               }
+   /* Input flux for N(4S) */
+               if( strcmp(corps[i], "N4S") == 0 )
+                 v  = top_N4S
+                        * (4.e-5/dra/pow((2.-dra/(RA[NLEV-1]+dra)),2.)); 
+
+               cm  = (NB[NLEV-1]+NB[NLEV-2])/2.;  /* Mean total concentration. */
+               dim = r * (MASS[i]-(mu[NLEV-1]+mu[NLEV-2])/2.)
+                       / (TEMP[NLEV-1]+TEMP[NLEV-2]) 
+                       / pow( RA[NLEV-1],   2.0e0 );  /* Delta i,j level -1. */
+               dm  = (MD[i][NLEV-1]+MD[i][NLEV-2])/2.;    /* Mean molecular diffusion. */
+               dym = (Y[i][NLEV-1]-Y[i][NLEV-2])/dra*1.e-5; /* Delta y level -1. */
+               km  = (KEDD[NLEV-1]+KEDD[NLEV-2])/2.;      /* Mean eddy diffusion. */
+             /* div phi. */
+               f[i][NLEV-1] = fp[i] - Y[i][NLEV-1]*fl[i] - v 
+                       - cm * ( dm * ( (Y[i][NLEV-1]+Y[i][NLEV-2])/2. * dim + dym ) 
+                              + km * dym ) 
+                        * (4.e-5/dra/pow((2.+dra/RA[NLEV-1]),2.)); 
+             /* dphi / dy this level */
+               a[NLEV-1][i][i] -= ( cm * ( dm * 0.5e0 * dim 
+                                    + 1.e-5/dra * (dm + km ) )
+                        * (4.e-5/dra/pow((2.+dra/RA[NLEV-1]),2.)) + dv );
+             /* dphi / dy level -1. */
+               b[NLEV-1][i][2]  =  THETA * delta 
+                                  * cm * ( dm * 0.5e0 * dim 
+                                    - 1.e-5/dra * (dm + km ) )
+                        * (4.e-5/dra/pow((2.+dra/RA[NLEV-1]),2.));
+            }
+            else
+            {
+               v = dv = 0.0e0;
+               dram=(RA[j+1]-RA[j-1])/2.;
+               if (j<NLEV-2)
+                 drap=(RA[j+1]-RA[j-1])/2.;
+               else
+                 drap=dram;
+
+               cm  = (NB[j]+NB[j-1])/2.;       /* Mean concentration level -1. */
+               cp  = (NB[j]+NB[j+1])/2.;       /* Mean concentration level +1. */
+               dip = r * (MASS[i]-(mu[j+1]+mu[j])/2.) / (TEMP[j+1]+TEMP[j]) /
+                     pow( RA[j+1], 2.0e0 );    /* Delta i,j level +1. */
+               dim = r * (MASS[i]-(mu[j]+mu[j-1])/2.) / (TEMP[j]+TEMP[j-1]) /
+                     pow( RA[j],   2.0e0 );    /* Delta i,j level -1. */
+               dm  = (MD[i][j-1]+MD[i][j])/2.;    /* Mean molecular diffusion level -1. */
+               dp  = (MD[i][j+1]+MD[i][j])/2.;    /* Mean molecular diffusion level +1. */
+               dym = (Y[i][j]-Y[i][j-1])/dram*1.e-5; /* Delta y level -1. */
+               dyp = (Y[i][j+1]-Y[i][j])/drap*1.e-5; /* Delta y level +1. */
+               km  = (KEDD[j]+KEDD[j-1])/2.;      /* Mean eddy diffusion level -1. */
+               kp  = (KEDD[j]+KEDD[j+1])/2.;      /* Mean eddy diffusion level +1. */
+             /* div phi. */
+               f[i][j] = cp * ( dp * ( (Y[i][j+1]+Y[i][j])/2. * dip + dyp ) 
+                              + kp * dyp ) 
+                        * (4.e-5/(RA[j+1]-RA[j])/pow((1.+RA[j]/RA[j+1]),2.)) 
+                       - cm * ( dm * ( (Y[i][j]+Y[i][j-1])/2. * dim + dym ) 
+                              + km * dym ) 
+                        * (4.e-5/(RA[j+1]-RA[j])/pow((1.+RA[j+1]/RA[j]),2.)) 
+                       + fp[i] - fl[i] * Y[i][j] + v;
+             /* dphi / dy this level */
+               a[j][i][i] += ( cp * ( dp * 0.5e0 * dip 
+                                    - 1.e-5/drap * (dp + kp) ) 
+                        * (4.e-5/(RA[j+1]-RA[j])/pow((1.+RA[j]/RA[j+1]),2.))
+                             - cm * ( dm * 0.5e0 * dim 
+                                    + 1.e-5/dram * (dm + km ) )
+                        * (4.e-5/(RA[j+1]-RA[j])/pow((1.+RA[j+1]/RA[j]),2.)) );
+             /* dphi / dy level -1. */
+               b[j][i][2]  =  THETA * delta 
+                             * cm * ( dm * 0.5e0 * dim
+                                    - 1.e-5/dram * (dm + km ) )
+                        * (4.e-5/(RA[j+1]-RA[j])/pow((1.+RA[j+1]/RA[j]),2.));
+             /* dphi / dy level +1. */
+               c[j][i]     = -THETA * delta
+                             * cp * ( dp * 0.5e0 * dip
+                                    + 1.e-5/drap * (dp + kp) ) 
+                        * (4.e-5/(RA[j+1]-RA[j])/pow((1.+RA[j]/RA[j+1]),2.));
+            }
+         }
+
+
+
+/* finition pour inversion */
+/* ----------------------- */
+
+         for( i = 0; i <= ST-1; i++ )
+         {
+            for( k = 0; k <= ST-1; k++ )
+            {
+               a[j][i][k] *= ( -THETA * delta );  /* Correction time step. */
+               if( k == i ) a[j][k][k] += NB[j];  /* Correction diagonal. */
+            }
+            f[i][j] *= delta;
+         }
+
+   }
+
+
+/* -------------------------------- */
+/* Inversion of matrix cf method LU */
+/* -------------------------------- */
+
+   for( j = NLD+1; j <= NLEV-1; j++ )
+   {
+         solve( a, j-1, 0, ST-1 );
+         for( i = 0; i <= ST-1; i++ )
+         {
+            s = 0.0e0;
+            for( k = 0; k <= ST-1; k++ )
+            {
+               a[j][i][k] -= ( b[j][i][2] * c[j-1][k] * a[j-1][i][k] );
+               s          += ( b[j][i][2] * f[k][j-1] * a[j-1][i][k] );
+            }
+            f[i][j] -= s;
+         }
+   }
+   solve( a, NLEV-1, 0, ST-1 );
+   for( j = NLEV-1; j >= NLD; j-- )     
+   {
+         if( j != NLEV-1 )
+            for( i = 0; i <= ST-1; i++ ) f[i][j] -= ( c[j][i] * b[j+1][i][1] );
+         for( i = 0; i <= ST-1; i++ )
+         {
+            s = 0.0e0;
+            for( k = 0; k <= ST-1; k++ ) s += ( a[j][i][k] * f[k][j] );
+            b[j][i][1]  = s;
+            Y[i][j]    += s;
+            if( Y[i][j] <= 1.0e-30 ) Y[i][j] = 0.0e0;
+         }
+   }
+
+/* ------------------ */
+/* Tests et evolution */
+/* ------------------ */
+
+/* Calcul deviation */
+/* ---------------- */
+
+   for( j = NLD; j <= NLEV-1; j++ )
+      for( i = 0; i <= ST-1; i++ )
+         if( ( Y[i][j] > test ) && ( ym1[i][j] > test ) )
+         {
+               conv = fabs( Y[i][j] - ym1[i][j] ) / ym1[i][j];
+               if( conv > ts )
+               {
+/*
+                  if( conv >= 0.1 )
+                  {
+                     out = fopen( outlog, "a" );
+                     fprintf( out, "Lat no %d;", (*LAT)+1);
+                     fprintf(out, " alt:%e; %s %e %e ; %e %e\n",(RA[j]-R0),corps[i],ym1[i],Y[i][j],time,delta);
+                     fclose( out );
+                  }
+*/
+                  ts = conv;
+               }
+         }
+
+/* test deviation */
+/* -------------- */
+
+         if( ts < 0.1e0 )
+         {
+            for( i = 0; i <= ST-1; i++ )
+               for( j = NLD; j <= NLEV-1; j++ )
+                 if( (Y[i][j] >= 0.5e0) && (strcmp(corps[i],"N2") != 0) )
+                 {
+                  out = fopen( outlog, "a" );
+                  fprintf( out, "WARNING %s mixing ratio is %e %e at %d\n",
+                           corps[i], ym1[i], Y[i][j], j );
+                  for( k = 0; k <= NLEV-1; k++ ) fprintf( out, "%d %e %e\n",k,ym1[i],Y[i][k] );
+                  fclose( out );
+                  exit(0); 
+//                  Y[i][j] = 1.e-20;
+                 }
+            for( j = NLD; j <= NLEV-1; j++ )
+               for( i = 0; i <= NC-1; i++ ) ym1[i][j] = max(Y[i][j],1.e-30);
+            time += delta;
+            if(   ts < 1.00e-5 )                      delta *= 1.0e2;
+            if( ( ts > 1.00e-5 ) && ( ts < 1.0e-4 ) ) delta *= 1.0e1;
+            if( ( ts > 1.00e-4 ) && ( ts < 1.0e-3 ) ) delta *= 5.0e0;
+            if( ( ts > 1.00e-3 ) && ( ts < 5.0e-3 ) ) delta *= 3.0e0;
+            if( ( ts > 5.00e-3 ) && ( ts < 0.01e0 ) ) delta *= 1.5e0;
+            if( ( ts > 0.010e0 ) && ( ts < 0.03e0 ) ) delta *= 1.2e0;
+            if( ( ts > 0.030e0 ) && ( ts < 0.05e0 ) ) delta *= 1.1e0;
+
+//            if( ( ts > 0.001e0 ) && ( ts < 0.01e0 ) ) delta *= 3.0e0;
+//            if( ( ts > 0.010e0 ) && ( ts < 0.05e0 ) ) delta *= 1.5e0;
+         
+            delta = min( deltamax, delta );
+         }
+         else
+         {
+            for( j = NLD; j <= NLEV-1; j++ )
+               for( i = 0; i <= NC-1; i++ ) Y[i][j] = ym1[i][j];
+
+            if(   ts > 0.8 )                    delta *= 1.e-6;
+            if( ( ts > 0.6 ) && ( ts <= 0.8 ) ) delta *= 1.e-4;
+            if( ( ts > 0.4 ) && ( ts <= 0.6 ) ) delta *= 1.e-2;
+            if( ( ts > 0.3 ) && ( ts <= 0.4 ) ) delta *= 0.1;
+            if( ( ts > 0.2 ) && ( ts <= 0.3 ) ) delta *= 0.2;
+            if( ( ts > 0.1 ) && ( ts <= 0.2 ) ) delta *= 0.3;
+         }
+         ts = 0.0e0;
+
+         out = fopen( outlog, "a" );
+         fprintf(out, "delta:%e; time:%e; fin:%e\n",delta,time,(*FIN));
+         fclose( out );
+
+}
+/* **************** */        
+/* end of time loop */
+/* **************** */        
+
+/*
+==========================================================================
+
+SECONDE ETAPE: 
+===============
+    INVERSION LOCALE PAR BLOC ENTRE NLD ET LA SURFACE
+===============
+*/
+   if( NLD != 0 ) 
+   for( j = NLD-1; j >= 0; j-- )
+   {
+      time     = ts = 0.0e0;
+      delta    = 1.e-3;
+
+/* ++++++++++++ */
+/*  time loop.  */
+/* ++++++++++++ */
+
+      while( time < (*FIN) )     
+      {
+
+/* init of step */
+/* ------------ */
+         for( i = 0; i <= ST-1; i++ ) 
+         {
+            fp[i] = fl[i] = 0.0e0; 
+            for( l = 0; l <= ST-1; l++ ) jac[i][l] = 0.0e0;
+         }
+
+/* Chimie */
+/* ------ */
+
+/* productions et pertes chimiques */
+         for( i = 0; i <= ST-1; i++ )    
+         {
+            Y[i][j] = max(Y[i][j],1.e-30);                /* minimum */
+
+            for( l = 0; l <= nom_prod[i]-1; l++ )    /* Production term */
+            {
+               ireac = prod[i][l];                  /* Number of the reaction involves. */
+               ncom1 = reactif[ireac][0];           /* First compound which reacts. */
+               if( reactif[ireac][1] == NC )        /* Photodissociation or relaxation */
+               {
+                  jac[i][ncom1] += ( KRATE[ireac][j] * NB[j] );
+                  fp[i]         += ( KRATE[ireac][j] * NB[j] * Y[ncom1][j] );
+               }
+               else                                 /* General case. */
+               {
+                  ncom2          = reactif[ireac][1];                       /* Second compound which reacts. */
+                  jac[i][ncom1] += ( KRATE[ireac][j] * Y[ncom2][j] );       /* Jacobian compound #1. */
+                  jac[i][ncom2] += ( KRATE[ireac][j] * Y[ncom1][j] );       /* Jacobian compound #2. */
+                  fp[i] += ( KRATE[ireac][j] * Y[ncom1][j] * Y[ncom2][j] ); /* Production term. */
+               }
+            }
+            
+            for( l = 0; l <= nom_perte[i]-1; l++ )   /* Loss term. */
+            {
+               ireac = perte[i][l][0];              /* Reaction number. */
+               ncom2 = perte[i][l][1];              /* Compound #2 reacts. */
+               if( reactif[ireac][1] == NC )        /* Photodissociation or relaxation */
+               {
+                  jac[i][i] -= ( KRATE[ireac][j] * NB[j] );
+                  fl[i]     += ( KRATE[ireac][j] * NB[j] );
+               }
+               else                                 /* General case. */
+               {
+                  jac[i][ncom2] -= ( KRATE[ireac][j] * Y[i][j] );       /* Jacobian compound #1. */
+                  jac[i][i]     -= ( KRATE[ireac][j] * Y[ncom2][j] );   /* Jacobien compound #2. */
+                  fl[i]         += ( KRATE[ireac][j] * Y[ncom2][j] );   /* Loss term. */
+               }
+            }
+         }
+
+
+/* Aerosols */
+/* -------- */
+         if( (*aerprod) == 1 )
+         {
+             aer(corps,TEMP,NB,Y,&j,k_dep,faer,
+              &dyc2h2,&dyhc3n,&dyhcn,&dynccn,&dych3cn,&dyc2h3cn,utilaer,
+              mmolaer,productaer,csurn,csurh);
+
+             for( i = 0; i <= 3; i++ )
+             {
+               PRODAER[i][j] = productaer[i];
+                  MAER[i][j] = mmolaer[i];
+                   CSN[i][j] = csurn[i];
+                   CSH[i][j] = csurh[i];
+             }
+/* DEBUG
+printf("AERPROD : LAT = %d - J = %d\n",(*LAT),j);
+if(fabs(dyc2h2*NB[j])>fabs(fp[utilaer[2]]/10.))
+      printf("fp(%s) =%e; dyc2h2 =%e\n",corps[utilaer[2]],
+              fp[utilaer[2]],dyc2h2*NB[j]);
+if(fabs(dyhcn*NB[j])>fabs(fp[utilaer[5]]/10.))
+      printf("fp(%s) =%e; dyhcn  =%e\n",corps[utilaer[5]],
+              fp[utilaer[5]],dyhcn*NB[j]);
+if(fabs(dyhc3n*NB[j])>fabs(fp[utilaer[6]]/10.))
+      printf("fp(%s) =%e; dyhc3n =%e\n",corps[utilaer[6]],
+              fp[utilaer[6]],dyhc3n*NB[j]);
+if(fabs(dynccn*NB[j])>fabs(fp[utilaer[13]]/10.))
+      printf("fp(%s) =%e; dynccn =%e\n",corps[utilaer[13]],
+              fp[utilaer[13]],dynccn*NB[j]);
+if(fabs(dych3cn*NB[j])>fabs(fp[utilaer[14]]/10.))
+      printf("fp(%s) =%e; dych3cn=%e\n",corps[utilaer[14]],
+              fp[utilaer[14]],dych3cn*NB[j]);
+if(fabs(dyc2h3cn*NB[j])>fabs(fp[utilaer[15]]/10.))
+      printf("fp(%s) =%e; dyc2h3cn=%e\n",corps[utilaer[15]],
+              fp[utilaer[15]],dyc2h3cn*NB[j]);
+*/
+
+             fp[utilaer[2]] -= (   dyc2h2 * NB[j] );
+             fp[utilaer[5]] -= (    dyhcn * NB[j] );
+             fp[utilaer[6]] -= (   dyhc3n * NB[j] );
+             fp[utilaer[13]]-= (   dynccn * NB[j] );
+             fp[utilaer[14]]-= (  dych3cn * NB[j] );
+             fp[utilaer[15]]-= ( dyc2h3cn * NB[j] );
+             if( Y[utilaer[2]][j]  != 0.0 )
+       jac[utilaer[2]][utilaer[2]] -= (  dyc2h2 * NB[j] / Y[utilaer[2]][j] );
+             if( Y[utilaer[5]][j]  != 0.0 )
+       jac[utilaer[5]][utilaer[5]] -= (   dyhcn * NB[j] / Y[utilaer[5]][j] );
+             if( Y[utilaer[6]][j]  != 0.0 )
+       jac[utilaer[6]][utilaer[6]] -= (  dyhc3n * NB[j] / Y[utilaer[6]][j] );
+             if( Y[utilaer[13]][j] != 0.0 )
+     jac[utilaer[13]][utilaer[13]] -= (  dynccn * NB[j] / Y[utilaer[13]][j] );
+             if( Y[utilaer[14]][j] != 0.0 )
+     jac[utilaer[14]][utilaer[14]] -= ( dych3cn * NB[j] / Y[utilaer[14]][j] );
+             if( Y[utilaer[15]][j] != 0.0 )
+     jac[utilaer[15]][utilaer[15]] -= (dyc2h3cn * NB[j] / Y[utilaer[15]][j] );
+         }
+     
+       
+/* H -> H2 on haze particles */
+/* ------------------------- */
+         if( (*htoh2) == 1 )
+         {
+              heterohtoh2(corps,TEMP,NB,Y,surfhaze,&j,&dyh,&dyh2,utilaer);
+/* dyh <= 0 / 1.0 en adsor., 1 en reac. */
+
+/* DEBUG 
+printf("HTOH2 : LAT = %d - J = %d\n",(*LAT),j);
+if(fabs(dyh*NB[j])>fabs(fp[utilaer[0]]/10.))
+printf("fp(%s) = %e; dyh  = %e\n",corps[utilaer[0]],fp[utilaer[0]],dyh*NB[j]);
+if(fabs(dyh2*NB[j])>fabs(fp[utilaer[1]]/10.))
+printf("fp(%s) = %e; dyh2 = %e\n",corps[utilaer[1]],fp[utilaer[1]],dyh2*NB[j]);
+*/
+
+              fp[utilaer[0]] += ( dyh  * NB[j] ); 
+   /* pourquoi pas *2 ?? cf gptit dans 2da... */
+
+              fp[utilaer[1]] += ( dyh2 * NB[j] );
+              if( Y[utilaer[0]][j] != 0.0 )
+       jac[utilaer[0]][utilaer[0]] += ( dyh  * NB[j] / Y[utilaer[0]][j] );
+   /* pourquoi pas *2 ?? cf gptit dans 2da... */
+         }
+
+
+/* Backup jacobian level j. */
+/* ------------------------ */
+         for( i = 0; i <= ST-1; i++ )
+         {
+            for( k = 0; k <= ST-1; k++ )
+               a[j][i][k] = jac[i][k];     
+            f[i][j] = fp[i] - fl[i] * Y[i][j];
+         }
+
+
+/* finition pour inversion */
+/* ----------------------- */
+
+         for( i = 0; i <= ST-1; i++ )
+         {
+            for( k = 0; k <= ST-1; k++ )
+            {
+               a[j][i][k] *= ( -THETA * delta );  /* Correction time step. */
+               if( k == i ) a[j][k][k] += NB[j];  /* Correction diagonal. */
+            }
+            f[i][j] *= delta;
+         }
+
+
+/* Inversion of matrix cf method LU */
+/* -------------------------------- */
+
+/* inversion by blocs: */
+/* Hydrocarbons */
+
+         solve_b( a, f, j, 0, NHC-1 );             
+         for( i = 0; i <= NHC-1; i++ )
+         {
+            Y[i][j] += f[i][j];
+            if( Y[i][j] <= 1.0e-30 ) Y[i][j] = 0.0e0;
+         }
+
+/* Nitriles */
+
+         solve_b( a, f, j, NHC, ST-1 );             
+         for( i = NHC+1; i <= ST-1; i++ )
+         {
+            Y[i][j] += f[i][j];
+            if( Y[i][j] <= 1.0e-30 ) Y[i][j] = 0.0e0;
+         }
+
+/* end inversion by blocs: */
+
+/* CH4 au sol */
+/* ---------- */
+   for( i = 0; i <= ST-1; i++ )
+     if( ( strcmp(corps[i], "CH4") == 0 ) && (j==0) && ( Y[i][0] < *botCH4 ) )
+     {
+          fluxCH4 += (*botCH4 - Y[i][0]);
+           Y[i][0] = *botCH4;
+     }
+
+/* ------------------ */
+/* Tests et evolution */
+/* ------------------ */
+
+/* Calcul deviation */
+/* ---------------- */
+
+         for( i = 0; i <= ST-1; i++ )
+         {
+            test = 1.0e-15; 
+            if( ( Y[i][j] > test ) && ( ym1[i][j] > test ) )
+            {
+               conv = fabs( Y[i][j] - ym1[i][j] ) / ym1[i][j];
+
+               if( conv > ts )
+               {
+/*
+                  if( conv >= 0.1 )
+                  {
+                     out = fopen( outlog, "a" );
+                     fprintf( out, "Lat no %d; declin:%e;", (*LAT)+1, (*DECLIN) );
+                     fprintf(out, " alt:%e; %s %e %e ; %e %e\n",(RA[j]-R0),corps[i],ym1[i],Y[i][j],time,delta);
+                     fclose( out );
+                  }
+*/
+                  ts = conv;
+               }
+            }
+         }
+
+/* test deviation */
+/* -------------- */
+
+         if( ts < 0.1e0 )
+         {
+            for( i = 0; i <= ST-1; i++ )
+                 if( (Y[i][j] >= 0.5e0) && (strcmp(corps[i],"N2") != 0) )
+                 {
+                  out = fopen( outlog, "a" );
+                  fprintf( out, "WARNING %s mixing ratio is %e %e at %d\n",
+                           corps[i], ym1[i][j], Y[i][j], j );
+                  for( k = 0; k <= NLEV-1; k++ ) fprintf( out, "%d %e %e\n",k,ym1[i][j],Y[i][k] );
+                  fclose( out );
+             //     exit(0); 
+                  Y[i][j] = 1.e-20;
+                 }
+            for( i = 0; i <= NC-1; i++ ) ym1[i][j] = max(Y[i][j],1.e-30);
+            time += delta;
+            if(   ts < 1.00e-5 )                      delta *= 1.0e2;
+            if( ( ts > 1.00e-5 ) && ( ts < 1.0e-4 ) ) delta *= 1.0e1;
+            if( ( ts > 1.00e-4 ) && ( ts < 1.0e-3 ) ) delta *= 5.0e0;
+            if( ( ts > 0.001e0 ) && ( ts < 0.01e0 ) ) delta *= 3.0e0;
+            if( ( ts > 0.010e0 ) && ( ts < 0.05e0 ) ) delta *= 1.5e0;
+         
+            delta = min( deltamax, delta );
+         }
+         else
+         {
+            for( i = 0; i <= NC-1; i++ ) Y[i][j] = ym1[i][j];
+
+            if(   ts > 0.8 )                    delta *= 1.e-6;
+            if( ( ts > 0.6 ) && ( ts <= 0.8 ) ) delta *= 1.e-4;
+            if( ( ts > 0.4 ) && ( ts <= 0.6 ) ) delta *= 1.e-2;
+            if( ( ts > 0.3 ) && ( ts <= 0.4 ) ) delta *= 0.1;
+            if( ( ts > 0.2 ) && ( ts <= 0.3 ) ) delta *= 0.2;
+            if( ( ts > 0.1 ) && ( ts <= 0.2 ) ) delta *= 0.3;
+         }
+         ts = 0.0e0;
+/*
+                     out = fopen( outlog, "a" );
+                     fprintf(out, " alt:%e; delta:%e; time:%e; fin:%e\n",(RA[j]-R0),delta,time,(*FIN));
+                     fclose( out );
+*/
+      }               
+
+/* +++++++++++++++++++ */
+/*  end of time loop.  */
+/* +++++++++++++++++++ */
+
+      for( i = 0; i <= ST-1; i++ ) 
+         if( ( strcmp(corps[i],"CH4") == 0 ) && ( j == 0 ) )
+            fluxCH4 *= ( MASS[i]/(6.022e23*time) ); 
+
+   }  /*  boucle j */
+
+
+/*
+==========================================================================
+
+FINALISATION: 
+===============
+*/
+      for( i = 0; i <= ST-1; i++ ) 
+         if( strcmp(corps[i],"CH4") == 0 )
+            fluxCH4 *= ( MASS[i]/(6.022e23*time) ); 
+
+/* Niveau de N2 */
+/* ------------ */
+      
+   for( j = 0; j <= NLEV-1; j++ ) 
+   {
+      conv = 0.0e0;
+      for( i = 0; i <= ST-1; i++ ) 
+         if( strcmp(corps[i],"N2") != 0 ) conv += Y[i][j];
+      for( i = 0; i <= ST-1; i++ ) 
+         if( strcmp(corps[i],"N2") == 0 ) Y[i][j] = 1. - conv;
+   }
+
+   if( (*aerprod) == 1 )
+   {
+    fdm2d( k_dep, 1, 5, 1 );
+    fdm2d(  faer, 1, 5, 1 );
+    fdm1d( productaer,  0 );
+    fdm1d( mmolaer,  0 );
+    fdm1d( csurn, 0 );
+    fdm1d( csurh, 0 );
+   }
+
+   fdm1d(      fl, 0 );
+   fdm1d(      fp, 0 );
+   fdm1d(      mu, 0 );
+   fdm2d(     ym1, 0,   NC-1, 0 );
+   fdm2d(       f, 0,   NC-1, 0 );
+   fdm2d(     jac, 0,   NC-1, 0 );
+   fdm2d(       c, 0, NLEV-1, 0 );
+   fdm3d(       a, 0, NLEV-1, 0,   NC-1, 0 );
+   fdm3d(       b, 0, NLEV-1, 0,   NC-1, 1 );
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/htoh2.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/htoh2.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/htoh2.c	(revision 1644)
@@ -0,0 +1,62 @@
+/* htoh2: production of H2 from heterogenous recombination of H
+   on the haze particles */
+
+#include "titan.h"
+
+void heterohtoh2( char corps[][10], double *tp, double *nb, double y[][NLEV],
+            double *sh, int *zj,
+            double *out1, double *out2, int *utilaer )
+{
+  int   z;
+  int   i,j,h,h2;
+  double dy_h2,dy_h,nbCsites;
+  double surfhaze,temp,ct;
+
+  z        = (*zj);
+  temp     = tp[z];
+  ct       = nb[z];
+  surfhaze = sh[z];
+
+/* composes interessants */
+/* --------------------- */
+/* !! decalage de 1 par rapport a calchim !! */
+
+  h  = utilaer[0];
+  h2 = utilaer[1];
+
+/* nbCsites: total nb of C sites */
+/* ----------------------------- */
+
+/* HYPOTHESE POUR LA TAILLE DU SITE D'UN C */
+
+/* 2e-9*4pi = 2.5e-8 = surface (um2) d'1 C
+   en supposant un disque PAH (correspond a un rayon de 0.9AA) */
+
+  nbCsites = surfhaze / 2.5e-8; 
+
+/* taux de recombinaison */
+/* --------------------- */
+
+/* H + bounded H -> H2 */
+  
+  dy_h2 = y[h][z]
+         * 1.58e4 * sqrt(temp)      /* kinetic speed of H atoms (cm s-1) */
+         * nbCsites                 /* haze: total nb of C sites (cm-3) */
+         * 1.8e-18*exp(-300/temp);  /* X-section Y.Sekine (cm2) */
+//         * 1.e-15*exp(-1700/temp);  /* X-section for bounded H atoms (cm2) */
+
+  dy_h  = -dy_h2;
+
+/* H + surface -> bounded H */
+
+  if(1==1)  // si faux, surface saturee
+  dy_h  = dy_h - y[h][z]
+         * 1.58e4 * sqrt(temp)      /* kinetic speed of H atoms (cm s-1) */
+	 * nbCsites                 /* haze: total nb of C sites (cm-3) */
+	 * 8.8e-16*exp(-1100/temp); /* Xsection Y.Sekine (cm2) */
+//         * 1.e-15*exp(-1700/temp);  /* X-section for bounded H atoms (cm2) */
+
+  *out1  = dy_h;
+  *out2  = dy_h2;
+}
+
Index: /trunk/LMDZ.TITAN/libf/chimtitan/omega.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/omega.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/omega.c	(revision 1644)
@@ -0,0 +1,14 @@
+/* omega: correction to perfect gas compound */
+/* 30 Oct 96 */
+
+#include "titan.h"
+
+double omega( ts, epsa, epsb )
+double epsa,epsb,ts;
+{
+   double t;
+
+   t = ts / sqrt( epsa * epsb );
+   return 1.06036e0 * pow( t, -0.1561e0 ) + 0.193e0 * exp( -0.47635e0 * t )
+          + 1.03587e0 * exp( -1.52996e0 * t ) + 1.76474e0 * exp( -3.89411e0 * t );
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/solve.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/solve.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/solve.c	(revision 1644)
@@ -0,0 +1,136 @@
+/* matrix inversion */
+/* cf Numerical Recipes LU Method for equations numbers */
+/* GCCM */
+/* similaire a inv (GP) */
+/* la matrice a est inversee seulement sur le bloc [n0;n1][n0;n1] */
+
+#include "titan.h"
+
+void solve( double ***aa, int m, int n0, int n1 )
+{
+   int    i,ii,imax,j,k,l,ll;
+   double **a,aamax,dum,*indx,sum,**vv,tmp;
+   FILE   *out;
+
+   indx = dm1d( n0, n1 );
+   vv   = dm2d( n0, n1, n0, n1 );
+   a    = dm2d( n0, n1, n0, n1 );
+   imax = n0;
+
+   for( i = n0; i <= n1; i++ ) for( j = n0; j <= n1; j++ ) a[i][j]=aa[m][i][j];
+   
+   for( i = n0; i <= n1; i++ )
+   {
+      aamax = 0.0e0;
+      for( k = n0; k <= n1; k++ )
+         if( (tmp=fabs(a[i][k])) > aamax ) aamax = tmp;
+      if( aamax < 1.0e-20 )
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "Singular matrix. n0=%ld k=%ld aamax=%le\n",
+                        n0,k,aamax);
+         fclose( out );
+         exit(0);   
+/*         aamax = 1.e-30; */
+      }
+      vv[i][1] = 1.0e0 / aamax;   /* Save the scaling */
+/*
+      if( (aamax > 1.0e100)||(aamax < 1.0e-100) )
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "ATTENTION aamax = %le\n", aamax );
+         fclose( out );
+         exit( 0 );
+      }
+*/
+   }
+   for( k = n0; k <= n1; k++ )
+   {
+      for( i = n0; i < k; i++ )      /* This is equation 2.3.12 except for i = j */
+      {
+         sum = a[i][k];
+         for( l = n0; l < i; l++ )
+            sum -= ( a[i][l] * a[l][k] );
+         a[i][k] = sum;
+      }
+      aamax = 0.0e0;                 /* Initialize for the search for largest pivot element */
+      for( i = k; i <= n1; i++ )     /* This is i = j of equation 2.3.12 and */
+      {
+         sum = a[i][k];              /* i = J + 1,...,N of equation 2.3.13 */
+         for( l = n0; l < k; l++ )
+            sum -= ( a[i][l] * a[l][k] );
+         a[i][k] = sum;
+         dum        = vv[i][1] * fabs(sum); /* Figure of merit for the pivot */
+         if( dum >= aamax )          /* Is it better than the best so far ? */
+         {
+            imax  = i;
+            aamax = dum;
+         }
+      }
+      if( k != imax )                /* Do we need to interchange rows ? */
+      {
+         for( l = n0; l <= n1; l++ ) /* Yes, do so... */
+         {
+            dum        = a[imax][l];
+            a[imax][l] = a[k][l];
+            a[k][l]    = dum;
+         }
+         vv[imax][1] = vv[k][1];    /* Also interchange the scale factor */
+      }
+      indx[k] = imax;
+      if( fabs(a[k][k]) < 1.0e-20 )
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "Pivot too small. n0=%ld k=%ld fabs(a[k][k])=%le\n",
+                        n0,k,fabs(a[k][k]) );
+         fclose( out );
+         exit(0);   
+/*         a[k][k] = 1.e-20; */
+      }
+      if( k != n1 )                   /* If the pivot element is less than 1.0d-20 we */
+      {                               /* assume that the matrix is singular */
+          dum = a[k][k];              /* ( at least to the precision of the algorithm and the machine ) */
+         for( i = k+1; i <= n1; i++ ) /* Now, finally devide by the pivot element */
+            a[i][k] /= dum;
+      }
+   }                                  /* Go back to the next column in the reduction */
+
+   for( i = n0; i <= n1; i++ )
+   {
+      for( k = n0; k <= n1; k++ )
+         vv[i][k] = 0.0e0;
+      vv[i][i] = 1.0e0;
+   }
+
+   for( l = n0; l <= n1; l++ )
+   {
+      ii = n0-1;
+      for( i = n0; i <= n1; i++ )
+      {
+         ll    = indx[i];
+         sum   = vv[ll][l];
+         vv[ll][l] = vv[i][l];
+         if( ii != (n0-1) )
+            for( k = ii; k < i; k++ )
+               sum -= ( a[i][k] * vv[k][l] );
+         else if( sum != 0.0e0 ) ii = i;
+         vv[i][l] = sum;
+      }
+      for( i = n1; i >= n0; i-- )
+      {
+         sum = vv[i][l];
+         if( i < n1 )
+            for( k = i+1; k <= n1; k++ )
+               sum -= ( a[i][k] * vv[k][l] );
+         vv[i][l] = sum / a[i][i];
+      }
+   }
+         
+   for( i = n0; i <= n1; i++ ) 
+     for( l = n0; l <= n1; l++ ) 
+       aa[m][i][l]=vv[i][l];
+
+   fdm1d( indx, n0 );
+   fdm2d(   vv, n0, n1, n0 );
+   fdm2d(    a, n0, n1, n0 );
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/solve_b.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/solve_b.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/solve_b.c	(revision 1644)
@@ -0,0 +1,126 @@
+/* matrix inversion */
+/* cf Numerical Recipes LU Method for equations numbers */
+/* GCCM */
+/* similaire a inv (GP) */
+/* la matrice a est inversee seulement sur le bloc [n0;n1][n0;n1] */
+
+#include "titan.h"
+
+void solve_b( double ***aa, double **f, int m, int n0, int n1 )
+{
+   int    i,ii,imax,j,k,l,ll;
+   double **a,aamax,dum,*indx,sum,*vv,tmp;
+   FILE   *out;
+
+   indx = dm1d( n0, n1 );
+   vv   = dm1d( n0, n1 );
+   a    = dm2d( n0, n1, n0, n1 );
+   imax = n0;
+
+   for( i = n0; i <= n1; i++ ) for( j = n0; j <= n1; j++ ) a[i][j]=aa[m][i][j];
+   
+   for( i = n0; i <= n1; i++ )
+   {
+      aamax = 0.0e0;
+      for( k = n0; k <= n1; k++ )
+         if( (tmp=fabs(a[i][k])) > aamax ) aamax = tmp;
+      if( aamax < 1.0e-20 )
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "Singular matrix. n0=%ld k=%ld aamax=%le\n",
+                        n0,k,aamax);
+         fclose( out );
+         exit(0);   
+/*         aamax = 1.e-30; */
+      }
+      vv[i] = 1.0e0 / aamax;   /* Save the scaling */
+/*
+      if( (aamax > 1.0e100)||(aamax < 1.0e-100) )
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "ATTENTION aamax = %le\n", aamax );
+         fclose( out );
+         exit( 0 );
+      }
+*/
+   }
+   for( k = n0; k <= n1; k++ )
+   {
+      for( i = n0; i < k; i++ )      /* This is equation 2.3.12 except for i = j */
+      {
+         sum = a[i][k];
+         for( l = n0; l < i; l++ )
+            sum -= ( a[i][l] * a[l][k] );
+         a[i][k] = sum;
+      }
+      aamax = 0.0e0;                 /* Initialize for the search for largest pivot element */
+      for( i = k; i <= n1; i++ )     /* This is i = j of equation 2.3.12 and */
+      {
+         sum = a[i][k];              /* i = J + 1,...,N of equation 2.3.13 */
+         for( l = n0; l < k; l++ )
+            sum -= ( a[i][l] * a[l][k] );
+         a[i][k] = sum;
+         dum        = vv[i] * fabs(sum); /* Figure of merit for the pivot */
+         if( dum >= aamax )          /* Is it better than the best so far ? */
+         {
+            imax  = i;
+            aamax = dum;
+         }
+      }
+      if( k != imax )                /* Do we need to interchange rows ? */
+      {
+         for( l = n0; l <= n1; l++ ) /* Yes, do so... */
+         {
+            dum        = a[imax][l];
+            a[imax][l] = a[k][l];
+            a[k][l]    = dum;
+         }
+         vv[imax] = vv[k];    /* Also interchange the scale factor */
+      }
+      indx[k] = imax;
+      if( fabs(a[k][k]) < 1.0e-20 )
+      {
+         out = fopen( "err.log", "a" );
+         fprintf( out, "Pivot too small. n0=%ld k=%ld fabs(a[k][k])=%le\n",
+                        n0,k,fabs(a[k][k]) );
+         fclose( out );
+         exit(0);   
+/*         a[k][k] = 1.e-20; */
+      }
+      if( k != n1 )                   /* If the pivot element is less than 1.0d-20 we */
+      {                               /* assume that the matrix is singular */
+          dum = a[k][k];              /* ( at least to the precision of the algorithm and the machine ) */
+         for( i = k+1; i <= n1; i++ ) /* Now, finally devide by the pivot element */
+            a[i][k] /= dum;
+      }
+   }                                  /* Go back to the next column in the reduction */
+
+   for( i = n0; i <= n1; i++ ) vv[i]=f[i][m];
+
+      ii = n0-1;
+      for( i = n0; i <= n1; i++ )
+      {
+         ll    = indx[i];
+         sum   = vv[ll];
+         vv[ll] = vv[i];
+         if( ii != (n0-1) )
+            for( k = ii; k < i; k++ )
+               sum -= ( a[i][k] * vv[k] );
+         else if( sum != 0.0e0 ) ii = i;
+         vv[i] = sum;
+      }
+      for( i = n1; i >= n0; i-- )
+      {
+         sum = vv[i];
+         if( i < n1 )
+            for( k = i+1; k <= n1; k++ )
+               sum -= ( a[i][k] * vv[k] );
+         vv[i] = sum / a[i][i];
+      }
+         
+   for( i = n0; i <= n1; i++ ) f[i][m]=vv[i];
+
+   fdm1d( indx, n0 );
+   fdm1d(   vv, n0 );
+   fdm2d(    a, n0, n1, n0 );
+}
Index: /trunk/LMDZ.TITAN/libf/chimtitan/titan.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/titan.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/titan.h	(revision 1644)
@@ -0,0 +1,59 @@
+/* titan.h: parameters for gptitan.c */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#define R0    (double)(2575.0) /* Titan's radius */
+#define NLEV  (int)(125)  /* Nbre de niv verticaux - =llm+70 dans common_mod */
+#define NLD   (int)(40)   /* Nbre de niv verticaux faits sans diff */
+#define NLRT  (int)(650)  /* Nbre de niv verticaux dans table fmoy - aussi dans common_mod */
+
+/* fluxes at 1300 km : upward is +, downward is - */
+#define top_H   (double)(+1.1e4)
+#define top_H2  (double)(+3.7e3)
+#define top_N4S (double)(-1.1e8) /* = -2.5e8/2.27 ... */
+
+/* DEPEND DE LA VERSION CHIMIE: */
+#define VERCHIM "chimie_simpnit_051006_bis"
+#define NREAC (int)(377)    /* nombre de reactions - aussi dans common_mod */
+#define RDISS (int)(54)     /* nombre de photodiss - aussi dans common_mod */
+#define NC    (int)(44)     /* nb de composes      - aussi dans common_mod */
+#define ST    (int)(NC)     /* nb de composes inverses */
+#define NHC   (int)(32)     /* nb hydrocarbons */
+
+#define THETA (double)(0.501)
+#ifndef M_PI
+#define M_PI  (double)(3.14159265358979323846e0)
+#endif
+#define RAD   (double)(M_PI / 180.0e0)
+#ifndef max
+#define max(a,b) ((a)>(b)?(a):(b))
+#define min(a,b) ((a)<=(b)?(a):(b))
+#endif
+
+void  chimie_(char (*)[10], double *, double *, double (*)[NLEV], 
+              int (*)[5], int *, int *, int (*)[200][2], int (*)[200]);
+void  comp_(char (*)[10], double *, double *, double *, double (*)[NLEV]);
+void  disso_(double (*)[NLRT][RDISS+1][15], int *);
+double omega( double, double, double );
+void  solve( double ***, int, int, int );
+void  solve_b( double ***, double **, int, int, int );
+float *rm1d( int, int );
+float **rm2d( int, int, int, int );
+float ***rm3d( int, int, int, int, int, int );
+float ****rm4d( int, int, int, int, int, int, int, int );
+double *dm1d( int, int );
+double **dm2d( int, int, int, int );
+double ***dm3d( int, int, int, int, int, int );
+double ****dm4d( int, int, int, int, int, int, int, int );
+void  frm1d( float *, int );
+void  frm2d( float **, int, int, int );
+void  frm3d( float ***, int, int, int, int, int );
+void  fdm1d( double *, int );
+void  fdm2d( double **, int, int, int );
+void  fdm3d( double ***, int, int, int, int, int );
+int   *im1d( int, int );
+int   **im2d( int, int, int, int );
+int   ***im3d( int, int, int, int, int, int );
Index: /trunk/LMDZ.TITAN/libf/chimtitan/tractitan.c
===================================================================
--- /trunk/LMDZ.TITAN/libf/chimtitan/tractitan.c	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/chimtitan/tractitan.c	(revision 1644)
@@ -0,0 +1,174 @@
+/* tractitan: suivi de traceurs avec constantes de temps de rappel */
+/* GCCM */
+
+#include "titan.h"
+
+void tractitan_( double *RB, char CORPS[][10], double Y[][NLEV], 
+     double Y0[][NLEV], double *FIN )
+{
+   char   outlog[100],corps[100][10];
+   int    i,j,k,l;
+   double  annee,**tau,**ym1;
+   double  cm,conv,cp,delta,deltamax,deltao;
+   double  test,time,ts;
+   char   str2[15];
+   FILE   *out;
+
+   for( i = 0; i <= NC; i++)
+   {
+     strcpy( corps[i], CORPS[i] );
+     corps[i][strcspn(CORPS[i], " ")] = '\0';
+   }
+   
+   time     = ts = 0.0e0;
+   annee    = 9.46728e8;
+   strcpy( outlog, "chimietitan" );
+   strcat( outlog, ".log" );
+   deltamax = 2.e5;
+   
+   deltao   = delta = 1.e5;
+
+   ym1       = dm2d( 0,   NC-1, 0, NLEV-1 );
+   tau       = dm2d( 0,   NC-1, 0, NLEV-1 );
+
+/* debug */
+/*
+            out = fopen( "err.log", "a" );
+            fprintf( out,"%s\n", );
+            fclose( out );
+*/
+
+/* Composition pour le rappel (identique a inichim): Y0 */
+   
+/* initialisation ym1 */
+     
+   for( j = 0; j <= NLEV-1; j++ )
+      for( i = 0; i <= NC-1; i++ ) ym1[i][j] = Y[i][j];
+       
+/* initialisation tau sans dependance en lat */
+    
+   for( i = 0; i <= NC-1; i++ )
+   { 
+    for( j = NLEV-1; j >= 0; j-- ) 
+    { 
+        tau[i][j] = 1.e6;   /* autres corps = 1.e6 s, donc rappel tres fort */
+        
+        if( strcmp(corps[i],"C2H2") == 0 ) 
+           tau[i][j] = annee*pow( 10., 2.+1.*(100.-(RB[j]-R0))/200. );
+        if( strcmp(corps[i],"C2H6") == 0 ) 
+           tau[i][j] = annee*pow( 10., 1.+1.*(200.-(RB[j]-R0))/300. );  
+        if( strcmp(corps[i],"HCN") == 0 )
+        { 
+          if( (RB[j]-R0) >= 350. ) 
+             tau[i][j] = annee*pow( 10., 1.+1.3*((RB[j]-R0)-350.)/150. );
+          else
+             tau[i][j] = annee*10.;  
+        }
+        if( strcmp(corps[i],"C4H2") == 0 )
+        {
+          if( (RB[j]-R0) >= 300. ) 
+             tau[i][j] = annee*pow( 10.,-1.+0.3*(300.-(RB[j]-R0))/200. );
+          else
+             tau[i][j] = annee*pow( 10., 0.+1.0*(100.-(RB[j]-R0))/200. );
+        }
+    }
+/* COUCHES HAUTES: RAPPEL FORCE PLUS GRAND */
+    tau[i][NLEV-1] = min(tau[i][NLEV-1],annee/100.);
+    tau[i][NLEV-2] = min(tau[i][NLEV-2],annee/50.);
+    tau[i][NLEV-3] = min(tau[i][NLEV-3],annee/10.);
+/*    tau[i][NLEV-4] = min(tau[i][NLEV-4],annee/100.); */
+   }
+
+/*   out = fopen( outlog, "a" ); */
+/* vu la rapidite, on laisse le fichier ouvert pendant toute la boucle */ 
+
+/* ***************** */
+/*  Main time loop.  */
+/* ***************** */
+
+   while( time < (*FIN) )             
+   {
+     for( i = 0; i <= NC-1; i++ )
+     {
+/* rappel */   
+/* ------ */
+       for( j = NLEV-2; j >= 0; j-- )  
+          Y[i][j] += delta * ( Y0[i][j] - Y[i][j] ) / tau[i][j];
+/* on laisse fixe la couche la plus haute */
+       Y[i][NLEV-1] = Y0[i][NLEV-1]; 
+     }
+     
+/* test evolution delta */
+/* -------------------- */
+     for( j = 0; j <= NLEV-2; j++ ) if( (RB[j]-R0) >= 90. ) 
+         for( i = 0; i <= NC-1; i++ )
+         {
+            test = 1.0e-15; 
+            if( ( Y[i][j] > test ) && ( ym1[i][j] > test ) )
+            {
+               conv = fabs( Y[i][j] - ym1[i][j] ) / ym1[i][j];
+               if( conv > ts )
+               {
+/*
+                  if( conv > 0.1 )
+                  {
+                     fprintf(out, "%d %s %e %e\n",j,corps[i],ym1[i][j],Y[i][j]); 
+                  }
+*/
+                  ts = conv;
+               }
+            }
+         }
+/*
+     fprintf(out, "%e %e %e\n",time,delta,ts); 
+*/
+     if( ts < 0.1e0 )
+     {
+         for( i = 0; i <= NC-1; i++ )
+               for( j = 0; j <= NLEV-1; j++ )
+                 if( Y[i][j] >= 1.0e0 )
+                 {
+/*
+                  fprintf( out, "WARNING %s mixing ratio is %e %e at %d",
+                           corps[i], ym1[i][j], Y[i][j], j );
+                  fclose( out );  
+*/
+                  exit(0);
+                 }
+         for( j = 0; j <= NLEV-1; j++ ) 
+               for( i = 0; i <= NC-1; i++ ) ym1[i][j] = Y[i][j];
+         time += ( deltao = delta );
+         if(   ts < 1.00e-5 )                      delta *= 10.e0;
+         if( ( ts > 1.00e-5 ) && ( ts < 1.0e-4 ) ) delta *= 5.0e0;
+         if( ( ts > 1.00e-4 ) && ( ts < 1.0e-3 ) ) delta *= 2.0e0;
+         if( ( ts > 0.001e0 ) && ( ts < 0.01e0 ) ) delta *= 1.5e0;
+         if( ( ts > 0.010e0 ) && ( ts < 0.05e0 ) ) delta *= 1.1e0;
+         
+         delta = min( deltamax, delta );
+         
+         if( ( time + delta ) > (*FIN) )
+         {
+            delta = (*FIN) - time;
+            time = (*FIN);
+         }
+     }
+     else
+     {
+         for( j = 0; j <= NLEV-1; j++ ) 
+               for( i = 0; i <= NC-1; i++ ) Y[i][j] = ym1[i][j];
+         delta *= 0.3e0;
+     }
+     ts = 0.0e0;
+   }               
+
+/* **************** */        
+/* end of main loop */
+/* **************** */        
+     
+/*
+   fprintf( out, "%e\n", time ); 
+   fclose( out ); 
+*/   
+   fdm2d(  ym1, 0,   NC-1, 0 );
+   fdm2d(  tau, 0,   NC-1, 0 );
+}
Index: /trunk/LMDZ.TITAN/libf/dyn3d/LISEZMOI
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/LISEZMOI	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/LISEZMOI	(revision 1644)
@@ -0,0 +1,136 @@
+
+Version abbrégé spécial Mars
+
+ ..  Version  du 28/12/1998  , avec  nouveau fxyhyper appele par inigeom ...
+ **************************************************************************
+
+ 1) Le gcm LMDZ.3.2  a des coordonnees  hybrides  verticalement ,c.a.d  des
+          ********
+   coordonnees equivalentes a sigma pres de la surface et a  P plus haut .     
+
+   Les pressions  p(ij,l) aux differents interfaces des  llm  couches verti- 
+   cales sont donnees  par   :
+
+    p( ij,l ) = ap(l) + bp(l) * ps(ij)    ,    1 << l << llm + 1    . 
+
+            
+   La fonction d'Exner  est calculee aux milieux des llm couches vertic.
+
+     pk(ij,l) = cp * ( p(ij,l)/preff ) ** kappa   ,  1 << l <<  llm
+
+   Les pressions  PLS(ij,l)  definies aux milieux des couches sont egales a :
+
+     pls(ij,l) = preff * ( pk(ij,l) /cp ) ** 1./kappa
+
+   
+
+ 2) Une des variables prognostiques de LMDZ.3  est   teta  , temperature 
+     potentielle  :    
+
+                 teta (ij,l) = temperature(ij,l) * cp/ pk(ij,l)
+ 
+    
+ 3) Dans  le programme principal gcm.F , il faut definir , au debut ,les para-
+    metres  IADV ,pour choisir le shema d'advection pour l'eau et les traceurs
+                    IADV = 3    , Van-Leer
+
+ 4) Il y a 2 shemas de dissipation   ( diffusion laterale )  :
+
+ a) La dissipation star ( qui ne fait pas intervenir la geometrie de la     
+    grille et qui est utilisee quand il y a un zoom ) 
+
+    Par expl . la diffusion d'un scalaire  comme  teta est formulee ( en 
+     appelant l'operateur  DIVGRAD2 )   comme :
+
+    d( ro * teta ) = (-1)**(it-1) *cdiv * Lap * ro**1/2 * Lap_gam** (it-2 ) *
+                           ro**1/2 * Lap * teta
+ avec  :
+ Lap     = 1/aire * Filt[ dx ( coefx*dx ) + dy( coefy*dy ) ] Filt
+       
+ Lap_gam = (1./aire)** -gam { dx[ coefx**(-gam) dx] + dy[ coefy**(-gam) dy ] } 
+
+
+  Filt est l'operateur  filtre 
+  ro   est la densite dp  de chaque couche
+  it   = nombre d'iterations de l'operateur de dissipation ( ici divgrad2 )
+  gam  = coefdis /( it -2 ) , coefdis = 0. si it = 2 , sinon = 1. habituellem.
+  dx   = operateur difference finie :
+    dx(A) = A( X +1/2 , Y, z ) - A( X -1/2, Y, z ) , dans le systeme de 
+  travail  (X,Y) , avec l'increment DX = 1.
+
+  Idem pour dy .
+
+  coefx = beta(ij) / alpha(ij)  , coefy = alpha(ij)/beta(ij)
+     avec    u_covariant(ij) = alpha(ij)* u_nat(ij) 
+             v_covariant(ij) = beta(ij) * v_nat(ij) 
+
+ Cette dissipation star est choisie en mettant le parametre lstardis a .TRUE.
+  dans le fichier run.def  lu  par le gcm en entree .
+
+ b) La dissipation ' non star '  fait intervenir les operateurs elementaires
+   diverg,grad,rotat .   Elle est choisie  avec lstardis = .FALSE.
+
+N.B : Dans les 2 shemas de dissipation , le gcm est plus stable  quand on
+     n'itere pas l'operateur ' GRADIV ' ou ' GRADIV2 " .            
+     
+ 5) Les constantes thermodynamiques Cp et kappa = R/Cp   utilisees dans la
+   partie dynamique ont ete mises , ce qui est normal, aux memes valeurs
+   qu'elles ont dans la partie ' physique ' , en changeant INICONST et en 
+   les mettant dans l'entete de controle de start et startphy ,en changeant
+   etat0_lmd , par rapport  a LMDZ.2.2 
+       
+ 6) Pour finir , quelques commentaires sur les parametres qui figurent sur
+    le fichier  run.def qui commandent le gcm .
+
+
+ c) coefdis , coefficient qui intervient dans le calcul de gam  , utilise 
+   dans les routines de dissipation star , vus plus haut .
+
+ d) iphysiq correspond ici a un appel de la physique toutes les 30 minutes.
+
+ e) alphax et alphay correspondent au grossissement pour le zoom dans la
+   direction X et Y .
+   En fait , les facteurs de grossissement sont egaux a  1./ ( 1.- alphax )
+     et 1./( 1.- alphay )  .
+
+ f) fxyhypb  est egal a .TRUE. si on choisit  pour la fonction f(x,y) qui 
+   definit la grille du modele  une fonction a tangente hyperbolique , un peu
+   adaptee pour le zoom , que la fonction sinusoidale , definie par fxy_new.h 
+   dans /..../gcm/libf/grid  et lu par  makegcm  lors de la compilation du 
+   code .
+
+
+N.B: Pour l'instant , cette fonction hyperbolique n'est activee eventuellement
+****            que pour  un zoom  latitudinal . 
+   Pour un zoom longitudinal , la fonction sinusoidale precisee dans fxy_new.h
+       est  choisie automatiquement .
+
+ g) psi0 et delta sont des parametres  pour cette fonction hyberbolique .
+   Ces valeurs de 0.3 et 0.5  ont ete adaptees pour 96x72  .
+  
+
+
+
+ ****************************************************************************
+
+ 
+ AA) Choisir les options du run  , avec   le fichier  run.def   .
+
+     Il y a entre autres choses , le nombre de jours qu'on veut integrer lors 
+       d'un run .
+     Il y a le nombre de pas a faire pour 1 jour , ce qui calcule donc le dt
+       temporel ( en secondes ) pour un pas dynamique .
+     Iperiod  est conseille  d'etre a 5 pas ( mais non obligatoiremnet = 5 ) . 
+     Idissip  peut etre mis a n'importe quelle valeur . Il est maintenant
+
+     Les parametres( la plupart des cles ) pour la physique commencent avec
+      la var. logique         **  physic  **
+
+           entiere( en pas )  ** iphysiq  ** qui est calculee de telle facon a
+                              appeler la physique tous les  30 minutes .
+
+           ( en jours )       ** ecritphy ** qui indique la frequence en jours
+                                du stockage   sur  diagfi
+
+
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/abort_gcm.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/abort_gcm.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/abort_gcm.F	(revision 1644)
@@ -0,0 +1,24 @@
+      SUBROUTINE abort_gcm(modname, message, ierr)
+     
+C
+C Stops the simulation cleanly, closing files and printing various
+C comments
+C
+C  Input: modname = name of calling program
+C         message = stuff to print
+C         ierr    = severity of situation ( = 0 normal )
+
+      character*20 modname
+      integer ierr
+      character*80 message
+
+      write(*,*) 'in abort_gcm'
+      write(*,*) 'Stopping in ', modname
+      write(*,*) 'Reason = ',message
+      if (ierr .eq. 0) then
+        write(*,*) 'Everything is cool'
+      else
+        write(*,*) 'Houston, we have a problem ', ierr
+      endif
+      STOP
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/addfi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/addfi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/addfi.F	(revision 1644)
@@ -0,0 +1,185 @@
+      SUBROUTINE addfi(nq, pdt, leapf, forward,
+     S          pucov, pvcov, pteta, pq   , pps , pmasse ,
+     S          pdufi, pdvfi, pdhfi,pdqfi, pdpfi  )
+
+      USE comvert_mod, ONLY: ap,bp     
+
+      IMPLICIT NONE
+c
+c=======================================================================
+c
+c    Addition of the physical tendencies
+c    Modif special Mars :
+c       - no special treatment of iq = 1, 2, FF 2003
+c       - recompute mass after incrementation of ps (EM,FF 2008)
+c
+c    Interface :
+c    -----------
+c
+c      Input :
+c      -------
+c      pdt                    time step of integration
+c      leapf                  logical
+c      forward                logical
+c      pucov(ip1jmp1,llm)     first component of the covariant velocity
+c      pvcov(ip1ip1jm,llm)    second component of the covariant velocity
+c      pteta(ip1jmp1,llm)     potential temperature
+c      pts(ip1jmp1,llm)       surface temperature
+c      pdufi(ip1jmp1,llm)     |
+c      pdvfi(ip1jm,llm)       |   respective
+c      pdhfi(ip1jmp1)         |      tendencies
+c      pdtsfi(ip1jmp1)        |
+c
+c      Output :
+c      --------
+c      pucov
+c      pvcov
+c      ph
+c      pts
+c      pmasse(ip1jmp1,llm)    ! mass
+c
+c
+c=======================================================================
+c
+c-----------------------------------------------------------------------
+c
+c    0.  Declarations :
+c    ------------------
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c    Arguments :
+c    -----------
+c
+      INTEGER nq
+
+      REAL pdt
+c
+      REAL pvcov(ip1jm,llm),pucov(ip1jmp1,llm)
+      REAL pteta(ip1jmp1,llm),pq(ip1jmp1,llm,nq),pps(ip1jmp1)
+c
+      REAL pdvfi(ip1jm,llm),pdufi(ip1jmp1,llm)
+      REAL pdqfi(ip1jmp1,llm,nq),pdhfi(ip1jmp1,llm),pdpfi(ip1jmp1)
+
+      real pmasse(ip1jmp1,llm)
+c
+      LOGICAL leapf,forward
+c
+c
+c    Local variables :
+c    -----------------
+c
+      REAL xpn(iim),xps(iim),tpn,tps
+      INTEGER j,k,iq,ij
+      REAL qtestw, qtestt
+      PARAMETER ( qtestw = 1.0e-15 )
+      PARAMETER ( qtestt = 1.0e-30 )
+
+      real p(ip1jmp1,llmp1) ! pressure
+
+      REAL SSUM
+      EXTERNAL SSUM
+c
+c-----------------------------------------------------------------------
+! increment potential temperature
+      DO k = 1,llm
+         DO j = 1,ip1jmp1
+            pteta(j,k)= pteta(j,k) + pdhfi(j,k) * pdt
+         ENDDO
+      ENDDO
+
+      DO  k    = 1, llm
+       DO  ij   = 1, iim
+         xpn(ij) = aire(   ij   ) * pteta(  ij    ,k)
+         xps(ij) = aire(ij+ip1jm) * pteta(ij+ip1jm,k)
+       ENDDO
+       tpn      = SSUM(iim,xpn,1)/ apoln
+       tps      = SSUM(iim,xps,1)/ apols
+
+       DO ij   = 1, iip1
+         pteta(   ij   ,k)  = tpn
+         pteta(ij+ip1jm,k)  = tps
+       ENDDO
+      ENDDO
+c
+
+! increment covariant zonal wind
+      DO k = 1,llm
+         DO j = iip2,ip1jm
+            pucov(j,k)= pucov(j,k) + pdufi(j,k) * pdt
+         ENDDO
+      ENDDO
+
+! increment covariant meridional wind
+      DO k = 1,llm
+         DO j = 1,ip1jm
+            pvcov(j,k)= pvcov(j,k) + pdvfi(j,k) * pdt
+         ENDDO
+      ENDDO
+
+c
+! increment surface pressure
+      DO j = 1,ip1jmp1
+         pps(j) = pps(j) + pdpfi(j) * pdt
+      ENDDO
+
+c     DO iq = 1, 2 ! special Mars: no special treatment for water
+c        DO k = 1,llm
+c           DO j = 1,ip1jmp1
+c              pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
+c              pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestw )
+c           ENDDO
+c        ENDDO
+c     ENDDO
+
+! increment tracers
+      DO iq = 1, nq
+         DO k = 1,llm
+            DO j = 1,ip1jmp1
+!               pq(j,k,iq)=  pdqfi(j,k,iq) * pdt
+               pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
+               pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestt ) ! forbid negative tracer values
+            ENDDO
+         ENDDO
+      ENDDO
+!      print*,'MAJOR TRACER MOD in addfi for test'
+                                       
+
+       DO  ij   = 1, iim
+         xpn(ij) = aire(   ij   ) * pps(  ij     )
+         xps(ij) = aire(ij+ip1jm) * pps(ij+ip1jm )
+       ENDDO
+       tpn      = SSUM(iim,xpn,1)/apoln
+       tps      = SSUM(iim,xps,1)/apols
+
+       DO ij   = 1, iip1
+         pps (   ij     )  = tpn
+         pps ( ij+ip1jm )  = tps
+       ENDDO
+
+! recompute mass: (to be synchronous with update of ps)
+      CALL pression ( ip1jmp1, ap, bp, pps, p )
+      CALL massdair (     p  , pmasse         )
+ 
+
+
+       DO iq = 1, nq
+         DO  k    = 1, llm
+           DO  ij   = 1, iim
+             xpn(ij) = aire(   ij   ) * pq(  ij    ,k,iq)
+             xps(ij) = aire(ij+ip1jm) * pq(ij+ip1jm,k,iq)
+           ENDDO
+           tpn      = SSUM(iim,xpn,1)/apoln
+           tps      = SSUM(iim,xps,1)/apols
+
+           DO ij   = 1, iip1
+             pq (   ij   ,k,iq)  = tpn
+             pq (ij+ip1jm,k,iq)  = tps
+           ENDDO
+         ENDDO
+       ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/adv_h2o.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/adv_h2o.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/adv_h2o.F	(revision 1644)
@@ -0,0 +1,132 @@
+      SUBROUTINE adv_h2o (nq,iq,q,w, pbaru, pbarv,dq)
+
+      USE logic_mod, ONLY: forward,leapf
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van / F.Forget
+c   -------
+c
+c   ********************************************************************
+c   Transport d'un traceur q par shema amont (horiz), moy arithmetique (vert)
+c   (Shema classique pour l'humidite specifique LMD)
+c   ********************************************************************
+c     nq,iq,q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c     dq 	       sont des arguments de sortie pour le s-pg ....
+c
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+
+c   Arguments:
+c   ----------
+      INTEGER nq,iq
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL q(ip1jmp1,llm,nq), dq( ip1jmp1,llm,nq )
+      REAL w(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      INTEGER   l,ij
+
+      REAL qbyv( ip1jm,llm ), qbxu( ip1jmp1,llm )
+      REAL wsur2(ip1jmp1),ww
+      REAL dqh( ip1jmp1,llm)
+
+      EXTERNAL     convflu
+
+c     ----------------------------------------------------------------
+c     --        calcul transport horiz. pour  dq                    --
+c     -                                                              -
+c     -         shema ' amont '  pour l'humidite specifique  q       -
+c     ----------------------------------------------------------------
+c
+      IF( iq.GT.2 )   THEN
+        DO   l = 1, llm
+         DO ij = 1, ip1jmp1
+          dq(ij,l,iq) = 0.
+         ENDDO
+        ENDDO
+            RETURN
+      ENDIF
+
+ 
+      IF( forward.OR.leapf )   THEN
+ 
+        DO 10 l = 1, llm
+ 
+        DO 6  ij     = iip2, ip1jm - 1
+ 
+          IF( pbaru(ij,l).GT.0.  )   THEN
+            qbxu( ij,l ) =  pbaru( ij,l )  * q(  ij  ,l,iq)
+          ELSE
+            qbxu( ij,l ) =  pbaru( ij,l )  * q(ij +1 ,l,iq)
+          ENDIF
+
+   6    CONTINUE
+ 
+c     ..... correction  pour  qbxu(iip1,j,l)   .....
+c     ...   qbxu(iip1,j,l)= qbxu(1,j,l)  ...
+ 
+CDIR$ IVDEP
+        DO  7   ij   = iip1 +iip1, ip1jm, iip1
+        qbxu( ij,l ) = qbxu( ij - iim, l )
+   7    CONTINUE
+ 
+        DO  8  ij     = 1, ip1jm
+         IF( pbarv(ij,l).GT.0.  )   THEN
+           qbyv( ij,l ) =  pbarv( ij,l )  * q(ij+iip1, l,iq)
+         ELSE
+           qbyv( ij,l ) =  pbarv( ij,l )  * q(   ij  , l,iq)
+         ENDIF
+   8    CONTINUE
+c
+  10    CONTINUE
+c
+ 
+c     stockage dans  dqh de la convergence horiz.du flux d'humidite  .
+c     ------------------------------------------------------------- 
+c
+                  CALL convflu(qbxu, qbyv, llm, dqh )
+
+c
+c ---------------------------------------------------------------
+c   .... calcul des termes d'advection vertic.pour q ....
+c              (moyenne arithmetique)
+c ---------------------------------------------------------------
+
+c calcul de  - d( q   * w )/ d(sigma)    qu'on ajoute a  dqh pour calculer dq
+c
+
+      DO 20 l = 1,llmm1
+
+c       preliminaires:
+c
+        DO 11 ij = 1,ip1jmp1
+         wsur2( ij ) = - 0.5 * w( ij,l+1 )
+  11    CONTINUE
+
+
+        DO 12 ij = 1,ip1jmp1
+          ww             = wsur2(ij)   * ( q(ij,l,iq) + q(ij,l+1,iq) )
+          dq (ij, l ,iq) = dqh(ij, l ) -  ww
+          dqh(ij,l+1   ) = dqh(ij,l+1) +  ww
+  12    CONTINUE
+c
+  20  CONTINUE 
+c
+c       special dq (ij,llm) (qui n'a pas ete rempli ! ) 
+c
+        DO  ij = 1,ip1jmp1
+          dq( ij,llm,iq ) = dqh( ij,llm ) 
+        END DO
+           
+      END IF
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/advect.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/advect.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/advect.F	(revision 1644)
@@ -0,0 +1,164 @@
+      SUBROUTINE advect(ucov,vcov,teta,w,massebx,masseby,du,dv,dteta)
+
+      USE comconst_mod, ONLY: daysec
+      USE logic_mod, ONLY: conser
+      USE ener_mod, ONLY: gtot
+
+      IMPLICIT NONE
+c=======================================================================
+c
+c   Auteurs:  P. Le Van , Fr. Hourdin  .
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   *************************************************************
+c   .... calcul des termes d'advection vertic.pour u,v,teta,q ...
+c   *************************************************************
+c        ces termes sont ajoutes a du,dv,dteta et dq .
+c  Modif F.Forget 03/94 : on retire q de advect
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm),teta(ip1jmp1,llm)
+      REAL massebx(ip1jmp1,llm),masseby(ip1jm,llm),w(ip1jmp1,llm)
+      REAL dv(ip1jm,llm),du(ip1jmp1,llm),dteta(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      REAL uav(ip1jmp1,llm),vav(ip1jm,llm),wsur2(ip1jmp1)
+      REAL unsaire2(ip1jmp1), ge(ip1jmp1)
+      REAL deuxjour, ww, gt, uu, vv
+
+      INTEGER  ij,l
+
+      EXTERNAL  SSUM
+      REAL      SSUM
+
+c-----------------------------------------------------------------------
+c   2. Calculs preliminaires:
+c   -------------------------
+
+      IF (conser)  THEN
+         deuxjour = 2. * daysec
+
+         DO   1  ij   = 1, ip1jmp1
+         unsaire2(ij) = unsaire(ij) * unsaire(ij)
+   1     CONTINUE
+      END IF
+
+
+c------------------  -yy ----------------------------------------------
+c   .  Calcul de     u
+
+      DO  l=1,llm
+         DO    ij     = iip2, ip1jmp1
+            uav(ij,l) = 0.25 * ( ucov(ij,l) + ucov(ij-iip1,l) )
+         ENDDO
+         DO    ij     = iip2, ip1jm
+            uav(ij,l) = uav(ij,l) + uav(ij+iip1,l)
+         ENDDO
+         DO      ij         = 1, iip1
+            uav(ij      ,l) = 0.
+            uav(ip1jm+ij,l) = 0.
+         ENDDO
+      ENDDO
+
+c------------------  -xx ----------------------------------------------
+c   .  Calcul de     v
+
+      DO  l=1,llm
+         DO    ij   = 2, ip1jm
+          vav(ij,l) = 0.25 * ( vcov(ij,l) + vcov(ij-1,l) )
+         ENDDO
+         DO    ij   = 1,ip1jm,iip1
+          vav(ij,l) = vav(ij+iim,l)
+         ENDDO
+         DO    ij   = 1, ip1jm-1
+          vav(ij,l) = vav(ij,l) + vav(ij+1,l)
+         ENDDO
+         DO    ij       = 1, ip1jm, iip1
+          vav(ij+iim,l) = vav(ij,l)
+         ENDDO
+      ENDDO
+
+c-----------------------------------------------------------------------
+
+c
+      DO 20 l = 1, llmm1
+
+
+c       ......   calcul de  - w/2.    au niveau  l+1   .......
+
+      DO 5   ij   = 1, ip1jmp1
+      wsur2( ij ) = - 0.5 * w( ij,l+1 )
+   5  CONTINUE
+
+
+c     .....................     calcul pour  du     ..................
+
+      DO 6 ij = iip2 ,ip1jm-1
+      ww        = wsur2 (  ij  )     + wsur2( ij+1 ) 
+      uu        = 0.5 * ( ucov(ij,l) + ucov(ij,l+1) )
+      du(ij,l)  = du(ij,l)   - ww * ( uu - uav(ij, l ) )/massebx(ij, l )
+      du(ij,l+1)= du(ij,l+1) + ww * ( uu - uav(ij,l+1) )/massebx(ij,l+1)
+   6  CONTINUE
+
+c     .....  correction pour  du(iip1,j,l)  ........
+c     .....     du(iip1,j,l)= du(1,j,l)   .....
+
+CDIR$ IVDEP
+      DO   7  ij   = iip1 +iip1, ip1jm, iip1
+      du( ij, l  ) = du( ij -iim, l  )
+      du( ij,l+1 ) = du( ij -iim,l+1 )
+   7  CONTINUE
+
+c     .................    calcul pour   dv      .....................
+
+      DO 8 ij = 1, ip1jm
+      ww        = wsur2( ij+iip1 )   + wsur2( ij )
+      vv        = 0.5 * ( vcov(ij,l) + vcov(ij,l+1) )
+      dv(ij,l)  = dv(ij, l ) - ww * (vv - vav(ij, l ) )/masseby(ij, l )
+      dv(ij,l+1)= dv(ij,l+1) + ww * (vv - vav(ij,l+1) )/masseby(ij,l+1)
+   8  CONTINUE
+
+c
+
+c     ............................................................
+c     ...............    calcul pour   dh      ...................
+c     ............................................................
+
+c                       ---z
+c       calcul de  - d( teta  * w )      qu'on ajoute a   dh
+c                   ...............
+
+        DO 15 ij = 1, ip1jmp1
+         ww            = wsur2(ij) * (teta(ij,l) + teta(ij,l+1) )
+         dteta(ij, l ) = dteta(ij, l )  -  ww
+         dteta(ij,l+1) = dteta(ij,l+1)  +  ww
+  15    CONTINUE
+
+      IF( conser)  THEN
+        DO 17 ij = 1,ip1jmp1
+        ge(ij)   = wsur2(ij) * wsur2(ij) * unsaire2(ij)
+  17    CONTINUE
+        gt       = SSUM( ip1jmp1,ge,1 )
+        gtot(l)  = deuxjour * SQRT( gt/ip1jmp1 )
+      END IF
+
+  20  CONTINUE
+ 
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/advtrac.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/advtrac.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/advtrac.h	(revision 1644)
@@ -0,0 +1,7 @@
+!
+! 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: /trunk/LMDZ.TITAN/libf/dyn3d/amont.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/amont.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/amont.F	(revision 1644)
@@ -0,0 +1,126 @@
+      SUBROUTINE amont (nq,iq,q,w, pbaru, pbarv,dq)
+
+      USE logic_mod, ONLY: forward,leapf
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van / F.Forget
+c   -------
+c
+c   ********************************************************************
+c   Transport d'un traceur q par shema amont 3D
+c   ********************************************************************
+c     nq,iq,q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c     dq 	       sont des arguments de sortie pour le s-pg ....
+c
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+
+c   Arguments:
+c   ----------
+      INTEGER nq,iq  
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL q(ip1jmp1,llm,nq), dq( ip1jmp1,llm,nq )
+      REAL w(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      INTEGER   l,ij
+
+      REAL qbyv( ip1jm,llm ), qbxu( ip1jmp1,llm )
+      REAL ww
+      REAL dqh( ip1jmp1,llm)
+
+      EXTERNAL     convflu
+
+c     ----------------------------------------------------------------
+c     --        calcul transport horiz. pour  dq                    --
+c     -                                                              -
+c     -         shema ' amont '                                      -
+c     ----------------------------------------------------------------
+c
+      IF( iq.GT.2 )   THEN
+       DO   l = 1, llm
+        DO ij = 1, ip1jmp1
+          dq(ij,l,iq) = 0.
+        ENDDO
+       ENDDO
+            RETURN
+      ENDIF
+ 
+c
+      IF( forward.OR.leapf )   THEN
+ 
+        DO 10 l = 1, llm
+ 
+        DO 6  ij     = iip2, ip1jm - 1
+           IF( pbaru(ij,l).GT.0.  )   THEN
+            qbxu( ij,l ) =  pbaru( ij,l )  * q(  ij  ,l,iq)
+           ELSE
+            qbxu( ij,l ) =  pbaru( ij,l )  * q(ij +1 ,l,iq)
+           ENDIF
+   6    CONTINUE
+ 
+c     ..... correction  pour  qbxu(iip1,j,l)   .....
+c     ...   qbxu(iip1,j,l)= qbxu(1,j,l)  ...
+ 
+CDIR$ IVDEP
+        DO  7   ij   = iip1 +iip1, ip1jm, iip1
+        qbxu( ij,l ) = qbxu( ij - iim, l )
+   7    CONTINUE
+ 
+        DO  8  ij     = 1, ip1jm
+           IF( pbarv(ij,l).GT.0.  )   THEN
+            qbyv( ij,l ) =  pbarv( ij,l )  * q(ij+iip1, l,iq)
+           ELSE
+            qbyv( ij,l ) =  pbarv( ij,l )  * q(   ij  , l,iq)
+           ENDIF
+   8    CONTINUE
+c
+  10    CONTINUE
+ 
+c     stockage dans  dqh de la convergence horiz.du flux d'humidite  .
+c     ------------------------------------------------------------- 
+c
+                  CALL convflu(qbxu, qbyv, llm, dqh )
+
+
+c ---------------------------------------------------------------
+c   .... calcul des termes d'advection vertic.pour q. Shema amont
+c ---------------------------------------------------------------
+
+c     calcul de  - d( q   * w )    qu'on ajoute a  dqh pour calculer dq
+c
+
+       DO 20 l = 1,llmm1
+c
+         DO 11 ij = 1,ip1jmp1
+           IF( w(ij,l+1).LT.0.  )   THEN
+            ww  =   - w( ij,l+1 ) * q( ij,  l  ,iq)
+           ELSE
+            ww  =   - w( ij,l+1 ) * q( ij, l +1,iq)
+           ENDIF
+
+          dq (ij, l ,iq ) = dqh(ij, l )   -  ww
+          dqh(ij,l+1    ) = dqh(ij,l+1)   +  ww
+  11     CONTINUE
+c
+  20   CONTINUE 
+
+c
+c       special dq (ij,llm) (qui n'a pas ete rempli ! ) 
+c
+        DO  ij = 1,ip1jmp1
+          dq( ij,llm,iq ) = dqh( ij,llm )
+        END DO
+           
+      END IF
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/amont_qsat.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/amont_qsat.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/amont_qsat.F	(revision 1644)
@@ -0,0 +1,151 @@
+      SUBROUTINE amont_qsat (nq,iq,q,teta,pk,w, pbaru, pbarv,dq)
+
+      USE comvert_mod, ONLY: preff
+      USE comconst_mod, ONLY: kappa,cpp
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van / F.Forget
+c   -------
+c
+c   ********************************************************************
+c   Transport d'un traceur q par shema amont 3D  avec contrainte thermi-
+c           -que
+c   ********************************************************************
+c     nq,iq,q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c     dq 	       sont des arguments de sortie pour le s-pg ....
+c
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+      INTEGER nq,iq  
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL q(ip1jmp1,llm,nq), dq( ip1jmp1,llm,nq )
+      REAL teta(ip1jmp1,llm),pk(ip1jmp1,llm)
+      REAL w(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      INTEGER   l,ij
+
+      REAL qbyv( ip1jm,llm ), qbxu( ip1jmp1,llm )
+      REAL ww
+      REAL dqh( ip1jmp1,llm)
+
+      REAL ptarg,pdelarg,foeew,zdelta
+      REAL rtt,retv,r3les,r3ies,r4les,r4ies,unskappa,play
+      REAL tempe(ip1jmp1),qsat(ip1jmp1,llm),r2es
+
+      EXTERNAL     convflu
+
+       FOEEW ( PTARG,PDELARG ) = EXP (
+     *          (R3LES*(1.-PDELARG)+R3IES*PDELARG) * (PTARG-RTT)
+     * / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG)) )
+C
+
+
+c     ----------------------------------------------------------------
+c     --        calcul transport horiz. pour  dq                    --
+c     -                                                              -
+c     -         shema ' amont '                                      -
+c     ----------------------------------------------------------------
+ 
+        r2es  = 380.11733 
+        r3les = 17.269
+        r3ies = 21.875
+        r4les = 35.86
+        r4ies = 7.66
+        retv = 0.6077667
+        rtt  = 273.16
+ 
+        unskappa =  1./ kappa
+
+        DO l = 1, llm
+         DO ij = 1, ip1jmp1
+          tempe(ij) = teta(ij,l) * pk(ij,l) /cpp
+         ENDDO
+         DO ij = 1, ip1jmp1
+          zdelta = MAX( 0., SIGN(1., rtt - tempe(ij)) )
+          play   =  preff * (pk(ij,l)/cpp) ** unskappa
+          qsat(ij,l) = MIN(0.5, r2es* FOEEW(tempe(ij),zdelta) / play )
+          qsat(ij,l) = qsat(ij,l) / ( 1. - retv * qsat(ij,l) )
+         ENDDO
+        ENDDO
+
+        DO 10 l = 1, llm
+
+        DO 6  ij     = iip2, ip1jm - 1
+         IF( pbaru(ij,l).GT.0  )  THEN
+          qbxu( ij,l ) = pbaru( ij,l ) * MIN( q(ij,l,iq),qsat(ij +1,l))
+         ELSE
+          qbxu( ij,l ) = pbaru( ij,l ) * MIN( q(ij+1,l,iq),qsat(ij,l) )
+         ENDIF
+       
+   6    CONTINUE
+ 
+c     ..... correction  pour  qbxu(iip1,j,l)   .....
+c     ...   qbxu(iip1,j,l)= qbxu(1,j,l)  ...
+ 
+CDIR$ IVDEP
+        DO  7   ij   = iip1 +iip1, ip1jm, iip1
+        qbxu( ij,l ) = qbxu( ij - iim, l )
+   7    CONTINUE
+ 
+        DO  8  ij     = 1, ip1jm
+         IF( pbarv(ij,l).GT.0  )  THEN
+          qbyv(ij,l) = pbarv( ij,l ) * MIN( q(ij+iip1,l,iq),qsat(ij,l) )
+         ELSE
+          qbyv(ij,l) = pbarv( ij,l ) * MIN( q(ij,l,iq),qsat(ij+iip1,l) )
+         ENDIF
+   8    CONTINUE
+c
+  10    CONTINUE
+ 
+c     stockage dans  dqh de la convergence horiz.du flux d'humidite  .
+c     ------------------------------------------------------------- 
+c
+                  CALL convflu(qbxu, qbyv, llm, dqh )
+
+
+c ---------------------------------------------------------------
+c   .... calcul des termes d'advection vertic.pour q. Shema amont
+c ---------------------------------------------------------------
+
+c calcul de  - d( q   * w )/ d(sigma)    qu'on ajoute a  dqh pour calculer dq
+c
+
+       DO 20 l = 1,llmm1
+c
+         DO 11 ij = 1,ip1jmp1
+           IF( w(ij,l+1).LT.0. )   THEN
+             ww =  -w(ij,l+1) * MIN( q(ij, l ,iq),qsat(ij ,l+1) )
+           ELSE
+             ww =  -w(ij,l+1) * MIN( q(ij,l+1,iq),qsat(ij , l ) )
+           ENDIF
+
+cc     .... Modif . P. Le Van  (26/09/95) ....
+
+          dq (ij, l ,iq ) = dqh(ij, l )   -  ww
+          dqh(ij,l+1    ) = dqh(ij,l+1)   +  ww
+  11     CONTINUE
+c
+  20   CONTINUE 
+
+c
+c       special dq (ij,llm) (qui n'a pas ete rempli ! ) 
+c
+        DO  ij = 1,ip1jmp1
+          dq( ij,llm,iq ) = dqh( ij,llm )
+        END DO
+           
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/bernoui.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/bernoui.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/bernoui.F	(revision 1644)
@@ -0,0 +1,55 @@
+      SUBROUTINE bernoui (ngrid,nlay,pphi,pecin,pbern)
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:   P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c     calcul de la fonction de Bernouilli aux niveaux s  .....
+c     phi  et  ecin  sont des arguments d'entree pour le s-pg .......
+c          bern       est un  argument de sortie pour le s-pg  ......
+c
+c    fonction de Bernouilli = bern = filtre de( geopotentiel + 
+c                              energ.cinet.)
+c
+c=======================================================================
+c
+c-----------------------------------------------------------------------
+c   Decalrations:
+c   -------------
+c
+#include "dimensions.h"
+#include "paramet.h"
+c
+c   Arguments:
+c   ----------
+c
+      INTEGER nlay,ngrid
+      REAL pphi(ngrid*nlay),pecin(ngrid*nlay),pbern(ngrid*nlay)
+c
+c   Local:
+c   ------
+c
+      INTEGER   ijl
+      EXTERNAL  filtreg
+c
+c-----------------------------------------------------------------------
+c   calcul de Bernouilli:
+c   ---------------------
+c
+      DO 4 ijl = 1,ngrid*nlay
+         pbern( ijl ) =  pphi( ijl ) + pecin( ijl )
+   4  CONTINUE
+c
+c-----------------------------------------------------------------------
+c   filtre:
+c   -------
+c
+      CALL filtreg( pbern, jjp1, llm, 2,1, .true., 1 )
+c
+c-----------------------------------------------------------------------
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/caldyn.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/caldyn.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/caldyn.F	(revision 1644)
@@ -0,0 +1,125 @@
+      SUBROUTINE caldyn
+     $ (itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
+     $  phi,conser,du,dv,dteta,dp,w,pbaru,pbarv,time )
+
+      USE comvert_mod, ONLY: ap,bp
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c  Auteur :  P. Le Van
+c
+c   Objet:
+c   ------
+c
+c   Calcul des tendances dynamiques.
+c
+c Modif 04/93 F.Forget
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c   0. Declarations:
+c   ----------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      LOGICAL conser
+
+      INTEGER itau
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm),teta(ip1jmp1,llm)
+      REAL ps(ip1jmp1),phis(ip1jmp1)
+      REAL pk(iip1,jjp1,llm),pkf(ip1jmp1,llm)
+      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
+      REAL phi(ip1jmp1,llm),masse(ip1jmp1,llm)
+      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
+      REAL dteta(ip1jmp1,llm),dp(ip1jmp1)
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
+      REAL time
+
+c   Local:
+c   ------
+
+      REAL ang(ip1jmp1,llm),p(ip1jmp1,llmp1)
+      REAL massebx(ip1jmp1,llm),masseby(ip1jm,llm),psexbarxy(ip1jm)
+      REAL vorpot(ip1jm,llm)
+      REAL w(ip1jmp1,llm),ecin(ip1jmp1,llm),convm(ip1jmp1,llm)
+      REAL bern(ip1jmp1,llm)
+      REAL massebxy(ip1jm,llm)
+    
+
+      INTEGER   ij,l
+      EXTERNAL  advect,bernoui,convmas,covcont,dteta1,dudv1,dudv2,
+     *          enercin,flumass,tourpot,vitvert,sortvarc,
+     *          pression,psextbar,massdair
+
+c-----------------------------------------------------------------------
+c   Calcul des tendances dynamiques:
+c   --------------------------------
+
+      CALL covcont  ( llm    , ucov    , vcov , ucont, vcont        )
+      CALL pression ( ip1jmp1, ap      , bp   ,  ps  , p            )
+      CALL psextbar (   ps   , psexbarxy                            )
+      CALL massdair (    p   , masse                                )
+      CALL massbar  (   masse, massebx , masseby                    )
+      call massbarxy(   masse, massebxy                             )
+      CALL flumass  ( massebx, masseby , vcont, ucont ,pbaru, pbarv )
+      CALL dteta1   (   teta , pbaru   , pbarv, dteta               )
+      CALL convmas  (   pbaru, pbarv   , convm                      )
+
+      DO ij =1, ip1jmp1
+         dp( ij ) = convm( ij,1 ) / airesurg( ij )
+      ENDDO
+c     write (38,*) "convm: ",convm
+c     write (38,*) "airesurg: ",airesurg
+c     write (38,*) "iip1: ",iip1
+c     close (38)
+
+
+      CALL vitvert ( convm  , w                                  )
+      CALL tourpot ( vcov   , ucov  , massebxy  , vorpot         )
+      CALL dudv1   ( vorpot , pbaru , pbarv     , du     , dv    )
+      CALL enercin ( vcov   , ucov  , vcont     , ucont  , ecin  )
+      CALL bernoui ( ip1jmp1, llm   , phi       , ecin   , bern  )
+      CALL dudv2   ( teta   , pkf   , bern      , du     , dv    )
+
+
+      DO l=1,llm
+         DO ij=1,ip1jmp1
+            ang(ij,l) = ucov(ij,l) + constang(ij)
+      ENDDO
+      ENDDO
+
+
+      CALL advect( ang, vcov, teta, w, massebx, masseby, du, dv,dteta ) 
+
+C  WARNING probleme de peridocite de dv sur les PC/linux. Pb d'arrondi 
+C          probablement. Observe sur le code compile avec pgf90 3.0-1 
+
+      DO l = 1, llm
+         DO ij = 1, ip1jm, iip1
+           IF( dv(ij,l).NE.dv(ij+iim,l) )  THEN
+c         PRINT *,'!!!ATTENTION!!! probleme de periodicite sur vcov',  
+c    ,   ' dans caldyn'
+c         PRINT *,' l,  ij = ', l, ij, ij+iim,dv(ij+iim,l),dv(ij,l)
+          dv(ij+iim,l) = dv(ij,l)
+          endif
+         enddo
+      enddo
+c-----------------------------------------------------------------------
+c   Sorties eventuelles des variables de controle:
+c   ----------------------------------------------
+!      write(*,*) 'CALDYN: itau=',itau,' conser=',conser
+      IF( conser )  THEN
+        CALL sortvarc
+     $ ( itau,ucov,teta,ps,masse,pk,phis,vorpot,phi,bern,dp,time,vcov )
+
+      ENDIF
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/caldyn0.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/caldyn0.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/caldyn0.F	(revision 1644)
@@ -0,0 +1,88 @@
+      SUBROUTINE caldyn0
+     $ (itau,ucov,vcov,teta,ps,masse,pk,phis ,
+     $  phi,w,pbaru,pbarv,time )
+
+      USE comvert_mod, ONLY: ap,bp
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c  Auteur :  P. Le Van
+c
+c   Objet:
+c   ------
+c
+c   Calcul des tendances dynamiques.
+c
+c Modif 04/93 F.Forget
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c   0. Declarations:
+c   ----------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      INTEGER itau
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm),teta(ip1jmp1,llm)
+      REAL ps(ip1jmp1),phis(ip1jmp1)
+      REAL pk(iip1,jjp1,llm)
+      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
+      REAL phi(ip1jmp1,llm),masse(ip1jmp1,llm)
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
+      REAL time
+
+c   Local:
+c   ------
+
+      REAL ang(ip1jmp1,llm),p(ip1jmp1,llmp1)
+      REAL massebx(ip1jmp1,llm),masseby(ip1jm,llm),psexbarxy(ip1jm)
+      REAL vorpot(ip1jm,llm)
+      REAL w(ip1jmp1,llm),ecin(ip1jmp1,llm),convm(ip1jmp1,llm)
+      REAL bern(ip1jmp1,llm)
+      REAL massebxy(ip1jm,llm), dp(ip1jmp1)
+    
+
+      INTEGER   ij,l
+      EXTERNAL  advect,bernoui,convmas,covcont ,
+     *          enercin,flumass,tourpot,vitvert,sortvarc,traceur,
+     *          pression,psextbar,massdair
+
+c-----------------------------------------------------------------------
+c   Calcul des tendances dynamiques:
+c   --------------------------------
+      CALL covcont  (llm,ucov,vcov,ucont,vcont)
+      CALL pression (ip1jmp1,ap,bp,ps,p)
+      CALL psextbar (ps,psexbarxy)
+      CALL massdair (p,masse)
+      CALL massbar  (masse,massebx,masseby)
+      CALL massbarxy(masse,massebxy)
+      CALL flumass  (massebx,masseby,vcont,ucont,pbaru,pbarv)
+      CALL convmas  (pbaru,pbarv,convm)
+
+      DO ij =1, ip1jmp1
+         dp( ij ) = convm( ij,1 ) / airesurg( ij )
+      ENDDO
+
+      CALL vitvert (convm,w)
+      CALL tourpot (vcov,ucov,massebxy,vorpot)
+      CALL enercin (vcov,ucov,vcont,ucont,ecin)
+      CALL bernoui (ip1jmp1,llm,phi,ecin,bern)
+
+      DO l=1,llm
+         DO ij=1,ip1jmp1
+            ang(ij,l) = ucov(ij,l) + constang(ij)
+         ENDDO
+      ENDDO
+
+        CALL sortvarc0
+     $ (itau,ucov,teta,ps,masse,pk,phis,vorpot,phi,bern,dp,time,vcov)
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/coefpoly.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/coefpoly.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/coefpoly.F	(revision 1644)
@@ -0,0 +1,38 @@
+c $Header: /users/lmdz/cvsroot/LMDZ.3.3/libf/dyn3d/coefpoly.F,v 1.1 2001/04/23 08:43:28 lmdz Exp $
+      SUBROUTINE coefpoly ( Xf1, Xf2, Xprim1, Xprim2, xtild1,xtild2 ,
+     ,                                          a0,a1,a2,a3         )
+      IMPLICIT NONE
+c
+c   ...  Auteur :   P. Le Van  ...
+c
+c
+c    Calcul des coefficients a0, a1, a2, a3 du polynome de degre 3 qui
+c      satisfait aux 4 equations  suivantes :
+
+c    a0 + a1*xtild1 + a2*xtild1*xtild1 + a3*xtild1*xtild1*xtild1 = Xf1
+c    a0 + a1*xtild2 + a2*xtild2*xtild2 + a3*xtild2*xtild2*xtild2 = Xf2
+c               a1  +     2.*a2*xtild1 +     3.*a3*xtild1*xtild1 = Xprim1
+c               a1  +     2.*a2*xtild2 +     3.*a3*xtild2*xtild2 = Xprim2
+
+c  On en revient a resoudre un systeme de 4 equat.a 4 inconnues a0,a1,a2,a3
+
+      REAL*8 Xf1, Xf2,Xprim1,Xprim2, xtild1,xtild2, xi 
+      REAL*8 Xfout, Xprim
+      REAL*8 a1,a2,a3,a0, xtil1car, xtil2car,derr,x1x2car
+
+      xtil1car = xtild1 * xtild1
+      xtil2car = xtild2 * xtild2 
+
+      derr= 2. *(Xf2-Xf1)/( xtild1-xtild2)
+
+      x1x2car = ( xtild1-xtild2)*(xtild1-xtild2)
+
+      a3 = (derr + Xprim1+Xprim2 )/x1x2car
+      a2     = ( Xprim1 - Xprim2 + 3.* a3 * ( xtil2car-xtil1car ) )    /
+     /           (  2.* ( xtild1 - xtild2 )  )
+
+      a1     = Xprim1 -3.* a3 * xtil1car     -2.* a2 * xtild1
+      a0     =  Xf1 - a3 * xtild1* xtil1car -a2 * xtil1car - a1 *xtild1
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comav.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comav.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comav.h	(revision 1644)
@@ -0,0 +1,3 @@
+      COMMON/comav/period_av,time0_av
+      REAL period_av ! periode de stockage en jour
+      REAL time0_av  ! date initiale de stokage en jour
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comconst_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comconst_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comconst_mod.F90	(revision 1644)
@@ -0,0 +1,11 @@
+MODULE comconst_mod
+
+IMPLICIT NONE  
+
+INTEGER im,jm,lllm,imp1,jmp1,lllmm1,lllmp1,lcl
+REAL dtvr,daysec
+REAL pi,dtphys,dtdiss,rad,r,cpp,kappa
+REAL cotot,unsim,g,omeg
+
+
+END MODULE comconst_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comdiss.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comdiss.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comdiss.h	(revision 1644)
@@ -0,0 +1,12 @@
+c-----------------------------------------------------------------------
+c INCLUDE 'comdiss.h'
+
+      INTEGER niter
+      REAL tetau(llm),tetah(llm),cdivu,cdivh,crot
+      LOGICAL dissipst
+
+      COMMON/comdissi/niter
+      COMMON/comdissr/tetau,tetah,cdivu,cdivh,crot
+      COMMON/comdissl/dissipst
+
+c-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comdissip.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comdissip.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comdissip.h	(revision 1644)
@@ -0,0 +1,12 @@
+!-----------------------------------------------------------------------
+! INCLUDE dissip.h
+
+      COMMON/comdissip/                                                 &
+     &    niterdis,coefdis,tetavel,tetatemp,gamdissip
+
+
+      INTEGER niterdis
+
+      REAL tetavel,tetatemp,coefdis,gamdissip
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comdissipn.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comdissipn.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comdissipn.h	(revision 1644)
@@ -0,0 +1,13 @@
+c-----------------------------------------------------------------------
+c INCLUDE comdissipn.h
+
+      REAL  tetaudiv, tetaurot, tetah, cdivu, crot, cdivh
+c
+      COMMON/comdissipn/ tetaudiv(llm),tetaurot(llm),tetah(llm)   ,
+     1                        cdivu,      crot,         cdivh
+
+c
+c    Les parametres de ce common proviennent des calculs effectues dans 
+c             Inidissip  .
+c
+c-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comdissnew.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comdissnew.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comdissnew.h	(revision 1644)
@@ -0,0 +1,15 @@
+c-----------------------------------------------------------------------
+c INCLUDE comdissnew.h
+
+      COMMON/comdissnew/ lstardis,nitergdiv,nitergrot,niterh,tetagdiv,
+     1                   tetagrot,tetatemp,coefdis 
+
+      LOGICAL lstardis
+      INTEGER nitergdiv, nitergrot, niterh
+      REAL     tetagdiv, tetagrot,  tetatemp, coefdis
+
+c
+c ... Les parametres de ce common comdissnew sont  lues par defrun_new 
+c              sur le fichier  run.def    ....
+c
+c-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comgeom.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comgeom.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comgeom.h	(revision 1644)
@@ -0,0 +1,36 @@
+!
+! Warning, these commons are also defined in comgeom2.h, so be careful
+! about possible mismatches if you modify either file.
+! For Fortran 77/Fortran 90 compliance always use line continuation
+! symbols '&' in columns 73 and 6
+!
+!CDK comgeom
+      COMMON/comgeom/                                                   &
+     & cu(ip1jmp1),cv(ip1jm),unscu2(ip1jmp1),unscv2(ip1jm),             &
+     & aire(ip1jmp1),airesurg(ip1jmp1),aireu(ip1jmp1),                  &
+     & airev(ip1jm),unsaire(ip1jmp1),apoln,apols,                       &
+     & unsairez(ip1jm),airuscv2(ip1jm),airvscu2(ip1jm),                 &
+     & aireij1(ip1jmp1),aireij2(ip1jmp1),aireij3(ip1jmp1),              &
+     & aireij4(ip1jmp1),alpha1(ip1jmp1),alpha2(ip1jmp1),                &
+     & alpha3(ip1jmp1),alpha4(ip1jmp1),alpha1p2(ip1jmp1),               &
+     & alpha1p4(ip1jmp1),alpha2p3(ip1jmp1),alpha3p4(ip1jmp1),           &
+     & fext(ip1jm),constang(ip1jmp1),rlatu(jjp1),rlatv(jjm),            &
+     & rlonu(iip1),rlonv(iip1),cuvsurcv(ip1jm),cvsurcuv(ip1jm),         &
+     & cvusurcu(ip1jmp1),cusurcvu(ip1jmp1),cuvscvgam1(ip1jm),           &
+     & cuvscvgam2(ip1jm),cvuscugam1(ip1jmp1),                           &
+     & cvuscugam2(ip1jmp1),cvscuvgam(ip1jm),cuscvugam(ip1jmp1),         &
+     & unsapolnga1,unsapolnga2,unsapolsga1,unsapolsga2,                 &
+     & unsair_gam1(ip1jmp1),unsair_gam2(ip1jmp1),unsairz_gam(ip1jm),    &
+     & aivscu2gam(ip1jm),aiuscv2gam(ip1jm),xprimu(iip1),xprimv(iip1)
+
+!
+        REAL                                                            &
+     & cu,cv,unscu2,unscv2,aire,airesurg,aireu,airev,unsaire,apoln     ,&
+     & apols,unsairez,airuscv2,airvscu2,aireij1,aireij2,aireij3,aireij4,&
+     & alpha1,alpha2,alpha3,alpha4,alpha1p2,alpha1p4,alpha2p3,alpha3p4 ,&
+     & fext,constang,rlatu,rlatv,rlonu,rlonv,cuvscvgam1,cuvscvgam2     ,&
+     & cvuscugam1,cvuscugam2,cvscuvgam,cuscvugam,unsapolnga1,unsapolnga2&
+     & ,unsapolsga1,unsapolsga2,unsair_gam1,unsair_gam2,unsairz_gam    ,&
+     & aivscu2gam ,aiuscv2gam,cuvsurcv,cvsurcuv,cvusurcu,cusurcvu,xprimu&
+     & , xprimv
+!
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comgeom2.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comgeom2.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comgeom2.h	(revision 1644)
@@ -0,0 +1,37 @@
+!
+! Warning, these commons are also defined in comgeom.h, so be careful
+! about possible mismatches if you modify either file.
+! For Fortran 77/Fortran 90 compliance always use line continuation
+! symbols '&' in columns 73 and 6
+!
+!CDK comgeom2
+      COMMON/comgeom/                                                   &
+     & cu(iip1,jjp1),cv(iip1,jjm),unscu2(iip1,jjp1),unscv2(iip1,jjm)  , &
+     & aire(iip1,jjp1),airesurg(iip1,jjp1),aireu(iip1,jjp1)           , &
+     & airev(iip1,jjm),unsaire(iip1,jjp1),apoln,apols                 , &
+     & unsairez(iip1,jjm),airuscv2(iip1,jjm),airvscu2(iip1,jjm)       , &
+     & aireij1(iip1,jjp1),aireij2(iip1,jjp1),aireij3(iip1,jjp1)       , &
+     & aireij4(iip1,jjp1),alpha1(iip1,jjp1),alpha2(iip1,jjp1)         , &
+     & alpha3(iip1,jjp1),alpha4(iip1,jjp1),alpha1p2(iip1,jjp1)        , &
+     & alpha1p4(iip1,jjp1),alpha2p3(iip1,jjp1),alpha3p4(iip1,jjp1)    , &
+     & fext(iip1,jjm),constang(iip1,jjp1), rlatu(jjp1),rlatv(jjm),      &
+     & rlonu(iip1),rlonv(iip1),cuvsurcv(iip1,jjm),cvsurcuv(iip1,jjm)  , &
+     & cvusurcu(iip1,jjp1),cusurcvu(iip1,jjp1)                        , &
+     & cuvscvgam1(iip1,jjm),cuvscvgam2(iip1,jjm),cvuscugam1(iip1,jjp1), &
+     & cvuscugam2(iip1,jjp1),cvscuvgam(iip1,jjm),cuscvugam(iip1,jjp1) , &
+     & unsapolnga1,unsapolnga2,unsapolsga1,unsapolsga2                , &
+     & unsair_gam1(iip1,jjp1),unsair_gam2(iip1,jjp1)                  , &
+     & unsairz_gam(iip1,jjm),aivscu2gam(iip1,jjm),aiuscv2gam(iip1,jjm)  &
+     & , xprimu(iip1),xprimv(iip1)
+
+!
+      REAL                                                              &
+     & cu,cv,unscu2,unscv2,aire,airesurg,aireu,airev,apoln,apols,unsaire&
+     & ,unsairez,airuscv2,airvscu2,aireij1,aireij2,aireij3,aireij4     ,&
+     & alpha1,alpha2,alpha3,alpha4,alpha1p2,alpha1p4,alpha2p3,alpha3p4 ,&
+     & fext,constang,rlatu,rlatv,rlonu,rlonv,cuvscvgam1,cuvscvgam2     ,&
+     & cvuscugam1,cvuscugam2,cvscuvgam,cuscvugam,unsapolnga1           ,&
+     & unsapolnga2,unsapolsga1,unsapolsga2,unsair_gam1,unsair_gam2     ,&
+     & unsairz_gam,aivscu2gam,aiuscv2gam,cuvsurcv,cvsurcuv,cvusurcu    ,&
+     & cusurcvu,xprimu,xprimv
+!
Index: /trunk/LMDZ.TITAN/libf/dyn3d/comvert_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/comvert_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/comvert_mod.F90	(revision 1644)
@@ -0,0 +1,14 @@
+MODULE comvert_mod
+
+IMPLICIT NONE  
+
+include "dimensions.h"
+include "paramet.h"
+
+REAL ap(llm+1),bp(llm+1),presnivs(llm),dpres(llm),pa,preff,	&
+     	nivsigs(llm),nivsig(llm+1)
+! Mars Ce qui suit vient de gcm
+REAL sig(llm+1),ds(llm),aps(llm),bps(llm),pseudoalt(llm)
+REAL scaleheight ! atmospheric scale height (km)
+
+END MODULE comvert_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/control_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/control_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/control_mod.F90	(revision 1644)
@@ -0,0 +1,18 @@
+
+module control_mod
+
+  implicit none
+
+  integer,save :: nday ! # of days to run
+  integer,save :: day_step ! # of dynamical time steps per day
+  integer,save :: iperiod  ! make a Matsuno step before avery iperiod-1 LF steps
+  integer,save :: iconser !
+  integer,save :: dissip_period ! apply dissipation every dissip_period dynamical step
+  integer,save :: iphysiq ! call physics every iphysiq dynamical steps
+  integer,save :: anneeref ! reference year # ! not used
+  real,save :: periodav
+!  integer,save :: ecritphy ! output data in "diagfi.nc" every ecritphy dynamical steps 
+  character(len=10),save :: planet_type ! planet type ('earth','mars',...)
+  character(len=4),save :: config_inca
+
+end module control_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/convflu.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/convflu.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/convflu.F	(revision 1644)
@@ -0,0 +1,60 @@
+      SUBROUTINE convflu( xflu,yflu,nbniv,convfl )
+c
+c  P. Le Van
+c
+c
+c    *******************************************************************
+c  ... calcule la (convergence horiz. * aire locale)du flux ayant pour
+c      composantes xflu et yflu ,variables extensives .  ......
+c    *******************************************************************
+c      xflu , yflu et nbniv sont des arguments d'entree pour le s-pg ..
+c      convfl                est  un argument de sortie pour le s-pg .
+c
+c     njxflu  est le nombre de lignes de latitude de xflu, 
+c     ( = jjm ou jjp1 )
+c     nbniv   est le nombre de niveaux vert. de  xflu et de yflu .
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+      REAL       xflu,yflu,convfl,convpn,convps
+      INTEGER    l,ij,nbniv
+      DIMENSION  xflu( ip1jmp1,nbniv ),yflu( ip1jm,nbniv ) ,
+     *         convfl( ip1jmp1,nbniv )
+c
+      EXTERNAL   SSUM
+      REAL       SSUM
+c
+c
+#include "comgeom.h"
+c
+      DO 5 l = 1,nbniv
+c
+      DO 2  ij = iip2, ip1jm - 1
+      convfl( ij + 1,l ) =  xflu(   ij,l ) - xflu( ij +  1,l )   +
+     *                      yflu(ij +1,l ) - yflu( ij -iim,l )
+   2  CONTINUE
+c
+c
+
+c     ....  correction pour  convfl( 1,j,l)  ......
+c     ....   convfl(1,j,l)= convfl(iip1,j,l) ...
+c
+CDIR$ IVDEP
+      DO 3 ij = iip2,ip1jm,iip1
+      convfl( ij,l ) = convfl( ij + iim,l )
+   3  CONTINUE
+c
+c     ......  calcul aux poles  .......
+c
+      convpn =   SSUM( iim, yflu(     1    ,l ),  1 )
+      convps = - SSUM( iim, yflu( ip1jm-iim,l ),  1 )
+      DO 4 ij = 1,iip1
+      convfl(     ij   ,l ) = convpn * aire(   ij     ) / apoln
+      convfl( ij+ ip1jm,l ) = convps * aire( ij+ ip1jm) / apols
+   4  CONTINUE
+c
+   5  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/convmas.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/convmas.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/convmas.F	(revision 1644)
@@ -0,0 +1,60 @@
+      SUBROUTINE convmas (pbaru, pbarv, convm )
+c
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteurs:  P. Le Van , F. Hourdin  .
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   ********************************************************************
+c   .... calcul de la convergence du flux de masse aux niveaux p ...
+c   ********************************************************************
+c
+c
+c     pbaru  et  pbarv  sont des arguments d'entree pour le s-pg  ....
+c      .....  convm      est  un argument de sortie pour le s-pg  ....
+c
+c    le calcul se fait de haut en bas, 
+c    la convergence de masse au niveau p(llm+1) est egale a 0. et
+c    n'est pas stockee dans le tableau convm .
+c
+c
+c=======================================================================
+c
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm ),convm(  ip1jmp1,llm )
+      INTEGER   l,ij
+
+      EXTERNAL   filtreg
+      EXTERNAL   convflu
+
+c-----------------------------------------------------------------------
+c    ....  calcul de - (d(pbaru)/dx + d(pbarv)/dy ) ......
+
+      CALL convflu( pbaru, pbarv, llm, convm )
+
+c-----------------------------------------------------------------------
+c   filtrage:
+c   ---------
+
+       CALL filtreg( convm, jjp1, llm, 2, 2, .true., 1 )
+
+c    integration de la convergence de masse de haut  en bas ......
+
+      DO      l      = llmm1, 1, -1
+        DO    ij     = 1, ip1jmp1
+         convm(ij,l) = convm(ij,l) + convm(ij,l+1)
+        ENDDO
+      ENDDO
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/coordij.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/coordij.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/coordij.F	(revision 1644)
@@ -0,0 +1,46 @@
+      SUBROUTINE coordij(lon,lat,ilon,jlat)
+
+c=======================================================================
+c
+c   calcul des coordonnees i et j de la maille scalaire dans
+c   laquelle se trouve le point (lon,lat) en radian
+c
+c=======================================================================
+
+      IMPLICIT NONE
+      REAL lon,lat
+      INTEGER ilon,jlat
+      INTEGER i,j
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      real zlon,zlat
+
+      zlon=lon
+      zlat=lat
+
+      DO i=1,iim+1
+        print*,i,' ',rlonu(i),' ',zlon 
+         IF (rlonu(i).GT.zlon) THEN
+            ilon=i
+            GOTO 10
+         ENDIF
+      ENDDO
+10    CONTINUE
+
+      j=0
+      DO j=1,jjm
+        print*,j,' ',rlatv(j),' ' ,zlat 
+         IF(rlatv(j).LT.zlat) THEN
+           
+            jlat=j
+            GOTO 20
+         ENDIF
+      ENDDO
+20    CONTINUE
+      IF(j.EQ.0) j=jjm+1
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/covcont.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/covcont.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/covcont.F	(revision 1644)
@@ -0,0 +1,41 @@
+      SUBROUTINE covcont (klevel,ucov, vcov, ucont, vcont )
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c  *********************************************************************
+c    calcul des compos. contravariantes a partir des comp.covariantes
+c  ********************************************************************
+c
+c=======================================================================
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      INTEGER klevel
+      REAL ucov ( ip1jmp1,klevel ),  vcov( ip1jm,klevel )
+      REAL ucont( ip1jmp1,klevel ), vcont( ip1jm,klevel )
+      INTEGER   l,ij
+
+
+      DO 10 l = 1,klevel
+
+      DO 2  ij = iip2, ip1jm
+      ucont( ij,l ) = ucov( ij,l ) * unscu2( ij )
+   2  CONTINUE
+
+      DO 4 ij = 1,ip1jm
+      vcont( ij,l ) = vcov( ij,l ) * unscv2( ij )
+   4  CONTINUE
+
+  10  CONTINUE
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/covnat.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/covnat.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/covnat.F	(revision 1644)
@@ -0,0 +1,46 @@
+      SUBROUTINE covnat (klevel,ucov, vcov, unat, vnat )
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  F Hourdin Phu LeVan
+c   -------
+c
+c   Objet:
+c   ------
+c
+c  *********************************************************************
+c    calcul des compos. naturelles a partir des comp.covariantes
+c  ********************************************************************
+c
+c=======================================================================
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      INTEGER klevel
+      REAL ucov( ip1jmp1,klevel ),  vcov( ip1jm,klevel )
+      REAL unat( ip1jmp1,klevel ), vnat( ip1jm,klevel )
+      INTEGER   l,ij
+
+
+      DO l = 1,klevel
+         DO ij = 1, iip1
+            unat (ij,l) =0.
+         END DO
+
+         DO ij = iip2, ip1jm
+            unat( ij,l ) = ucov( ij,l ) / cu(ij)
+         ENDDO
+         DO ij = ip1jm+1, ip1jmp1  
+            unat (ij,l) =0.
+         END DO
+
+         DO ij = 1,ip1jm
+            vnat( ij,l ) = vcov( ij,l ) / cv(ij)
+         ENDDO
+
+      ENDDO
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/defrun_new.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/defrun_new.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/defrun_new.F	(revision 1644)
@@ -0,0 +1,535 @@
+      SUBROUTINE defrun_new( tapedef, etatinit )
+#ifndef CPP_PARA
+c
+c-----------------------------------------------------------------------
+c     Auteurs :   L. Fairhead , P. Le Van  .
+c      Modif C. Hourdin F. Forget VERSION MARTIENNE
+c
+c
+c  -------------------------------------------------------------------
+c
+c                    MODIF JUIN 2000 (zoom)
+c       .........     Version  du 29/04/97       ..........
+c
+c   Nouveaux parametres nitergdiv,nitergrot,niterh,tetagdiv,tetagrot,
+c   tetatemp   ajoutes  pour la dissipation   .
+c
+c   Autre parametre ajoute en fin de liste : ** fxyhypb ** 
+c
+c   Si fxyhypb = .TRUE. , choix de la fonction a derivee tangente hyperb.
+c   Sinon , choix de fxynew  , a derivee sinusoidale  ..
+c
+c   ......  etatinit = . TRUE. si defrun_new  est appele dans NEWSTART
+c   ETAT0_LMD  ou  LIMIT_LMD  pour l'initialisation de start.dat (dic) et
+c   de limit.dat (dic)  ...........
+c   Sinon  etatinit = . FALSE .
+c
+c   Donc etatinit = .F.  si on veut comparer les valeurs de  alphax ,
+c   alphay,clon,clat, fxyhypb  lues sur  le fichier  start  avec
+c   celles passees  par run.def ,  au debut du gcm, apres l'appel a 
+c   lectba .  
+c   Ces parametres definissant entre autres la grille et doivent etre
+c   pareils et coherents , sinon il y aura  divergence du gcm .
+c
+c
+c-----------------------------------------------------------------------
+c   Declarations :
+c   --------------
+! to use  'getin'
+      USE ioipsl_getincom
+      use sponge_mod,only: callsponge,nsponge,mode_sponge,tetasponge
+      use control_mod,only: nday, day_step, iperiod, anneeref,
+     &                      iconser, dissip_period, iphysiq
+      USE logic_mod, ONLY: hybrid,purmats,fxyhypb,ysinus,iflag_phys
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy,
+     .			alphax,alphay,taux,tauy
+      IMPLICIT NONE
+
+#include "dimensions.h"
+#include "paramet.h"
+!#include "control.h"
+#include "comdissnew.h"
+#include "iniprint.h"
+c
+c   arguments:
+c   ---------
+      LOGICAL  etatinit ! should be .false. for a call from gcm.F
+                        ! and .true. for a call from newstart.F
+      INTEGER  tapedef  ! unit number to assign to 'run.def' file
+c
+c   local variables:
+c   ---------------
+
+      CHARACTER ch1*72,ch2*72,ch3*72,ch4*8 ! to store various strings
+      integer tapeerr ! unit number for error message
+      parameter (tapeerr=0)
+
+c     REAL clonn,clatt,alphaxx,alphayy
+c     LOGICAL  fxyhypbb
+      INTEGER ierr
+      REAL clonn,clatt,grossismxx,grossismyy
+      REAL dzoomxx,dzoomyy,tauxx,tauyy,temp
+      LOGICAL  fxyhypbb, ysinuss
+
+
+c   initialisations:
+c   ----------------
+ 
+!      lunout=6
+
+c-----------------------------------------------------------------------
+c  Parametres de controle du run:
+c-----------------------------------------------------------------------
+
+
+!Initialisation des parametres "terrestres", qui ne concernent pas
+!le modele martien et ne sont donc plus lues dans "run.def"
+
+        anneeref=0
+        ! Note: anneref is a common in 'control.h'
+
+      OPEN(tapedef,file='run.def',status='old',form='formatted'
+     .     ,iostat=ierr)
+      CLOSE(tapedef) ! first call to getin will open the file
+
+      !lunout: default unit for the text outputs
+      lunout=6
+      CALL getin('lunout', lunout)
+      IF (lunout /= 5 .and. lunout /= 6) THEN
+        OPEN(UNIT=lunout,FILE='lmdz.out',ACTION='write',
+     &       STATUS='unknown',FORM='formatted')
+      ENDIF
+
+      IF(ierr.EQ.0) THEN ! if file run.def is found
+        WRITE(lunout,*) "DEFRUN_NEW: reading file run.def"
+        
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "Number of days to run:"
+        nday=1 ! default value
+        call getin("nday",nday)
+        WRITE(lunout,*)" nday = ",nday
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "Number of dynamical steps per day:",
+     & "(should be a multiple of iperiod)"
+        day_step=960 ! default value
+        call getin("day_step",day_step)
+        WRITE(lunout,*)" day_step = ",day_step
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "periode pour le pas Matsuno (en pas)"
+        iperiod=5 ! default value
+        call getin("iperiod",iperiod)
+        WRITE(lunout,*)" iperiod = ",iperiod
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "periode de sortie des variables de ",
+     &  "controle (en pas)"
+        iconser=120 ! default value
+        call getin("iconser",iconser)
+        WRITE(lunout,*)" iconser = ",iconser
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "periode de la dissipation (en pas)"
+        dissip_period=5 ! default value
+        call getin("idissip",dissip_period)
+        ! if there is a "dissip_period" in run.def, it overrides "idissip"
+        call getin("dissip_period",dissip_period)
+        WRITE(lunout,*)" dissip_period = ",dissip_period
+
+ccc  ....   P. Le Van , modif le 29/04/97 .pour la dissipation  ...
+ccc
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "choix de l'operateur de dissipation ",
+     & "(star ou  non star )"
+        lstardis=.true. ! default value
+        call getin("lstardis",lstardis)
+        WRITE(lunout,*)" lstardis = ",lstardis
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "avec ou sans coordonnee hybrides"
+        hybrid=.true. ! default value
+        call getin("hybrid",hybrid)
+        WRITE(lunout,*)" hybrid = ",hybrid
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "nombre d'iterations de l'operateur de ",
+     & "dissipation   gradiv "
+        nitergdiv=1 ! default value
+        call getin("nitergdiv",nitergdiv)
+        WRITE(lunout,*)" nitergdiv = ",nitergdiv
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "nombre d'iterations de l'operateur de ",
+     & "dissipation  nxgradrot"
+        nitergrot=2 ! default value
+        call getin("nitergrot",nitergrot)
+        WRITE(lunout,*)" nitergrot = ",nitergrot
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "nombre d'iterations de l'operateur de ",
+     & "dissipation  divgrad"
+        niterh=2 ! default value
+        call getin("niterh",niterh)
+        WRITE(lunout,*)" niterh = ",niterh
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "temps de dissipation des plus petites ",
+     & "long.d ondes pour u,v (gradiv)"
+        tetagdiv=4000. ! default value
+        call getin("tetagdiv",tetagdiv)
+        WRITE(lunout,*)" tetagdiv = ",tetagdiv
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "temps de dissipation des plus petites ",
+     & "long.d ondes pour u,v(nxgradrot)"
+        tetagrot=5000. ! default value
+        call getin("tetagrot",tetagrot)
+        WRITE(lunout,*)" tetagrot = ",tetagrot
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "temps de dissipation des plus petites ",
+     & "long.d ondes pour  h ( divgrad)"
+        tetatemp=5000. ! default value
+        call getin("tetatemp",tetatemp)
+        WRITE(lunout,*)" tetatemp = ",tetatemp
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "coefficient pour gamdissip"
+        coefdis=0. ! default value
+        call getin("coefdis",coefdis)
+        WRITE(lunout,*)" coefdis = ",coefdis
+c
+c    ...............................................................
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "choix du shema d'integration temporelle ",
+     & "(true==Matsuno ou false==Matsuno-leapfrog)"
+        purmats=.false. ! default value
+        call getin("purmats",purmats)
+        WRITE(lunout,*)" purmats = ",purmats
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "avec ou sans physique"
+!        physic=.true. ! default value
+!        call getin("physic",physic)
+!        WRITE(lunout,*)" physic = ",physic
+        iflag_phys=1 ! default value
+        call getin("iflag_phys",iflag_phys)
+        WRITE(lunout,*)" iflag_phys = ",iflag_phys
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "periode de la physique (en pas)"
+        iphysiq=20 ! default value
+        call getin("iphysiq",iphysiq)
+        WRITE(lunout,*)" iphysiq = ",iphysiq
+
+!        WRITE(lunout,*) ""
+!        WRITE(lunout,*) "choix d'une grille reguliere"
+!        grireg=.true.
+!        call getin("grireg",grireg)
+!        WRITE(lunout,*)" grireg = ",grireg
+
+ccc   .... P.Le Van, ajout le 03/01/96 pour l'ecriture phys ...
+c
+!        WRITE(lunout,*) ""
+!        WRITE(lunout,*) "frequence (en pas) de l'ecriture ",
+!     & "du fichier diagfi.nc"
+!        ecritphy=240
+!        call getin("ecritphy",ecritphy)
+!        WRITE(lunout,*)" ecritphy = ",ecritphy
+
+ccc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
+c     .........   (  modif  le 17/04/96 )   .........
+c
+        if (.not.etatinit ) then 
+
+           clonn=63.
+           call getin("clon",clonn)
+           
+           IF( ABS(clon - clonn).GE. 0.001 )  THEN
+             PRINT *,' La valeur de clon passee par run.def est '
+     *       ,'differente de celle lue sur le fichier start '
+             STOP
+           ENDIF
+c
+c
+           clatt=0.
+           call getin("clat",clatt)
+  
+           IF( ABS(clat - clatt).GE. 0.001 )  THEN
+             PRINT *,' La valeur de clat passee par run.def est '
+     *       ,'differente de celle lue sur le fichier start '
+             STOP
+           ENDIF
+
+           grossismxx=1.0
+           call getin("grossismx",grossismxx)
+
+           if(grossismxx.eq.0) then  
+             write(*,*)
+             write(*,*)'ERREUR : dans run.def, grossismx =0'
+             write(*,*)'Attention a ne pas utiliser une version de'
+             write(*,*)'run.def avant le nouveau zoom LMDZ2.3 (06/2000)'
+             write(*,*)'(Il faut ajouter grossismx,dzoomx,etc... a la'
+             write(*,*)'place de alphax, alphay. cf. dyn3d). '
+             write(*,*)
+             stop
+           end if
+
+           IF( ABS(grossismx - grossismxx).GE. 0.001 )  THEN
+             PRINT *,' La valeur de grossismx passee par run.def est '
+     *       ,'differente de celle lue sur le fichier  start =',
+     *        grossismx
+             if (grossismx.eq.0) then
+                  write(*,*) 'OK,Normal : c est un vieux start'
+     *             , 'd avant le nouveau zoom LMDZ2.3 (06/2000)'
+                 grossismx=grossismxx
+             else
+                   STOP
+             endif
+           ENDIF
+
+           grossismyy=1.0
+           call getin("grossismy",grossismyy)
+
+           IF( ABS(grossismy - grossismyy).GE. 0.001 )  THEN
+             PRINT *,' La valeur de grossismy passee par run.def est '
+     *       ,'differente de celle lue sur le fichier  start =',
+     *        grossismy
+             if (grossismy.eq.0) then
+                  write(*,*) 'OK,Normal : c est un vieux start'
+     *             , 'd avant le nouveau zoom LMDZ2.3 (06/2000)'
+                 grossismy=grossismyy
+             else
+                   STOP
+             endif
+           ENDIF
+
+
+           IF( grossismx.LT.1. )  THEN
+             PRINT *,' ***  ATTENTION !! grossismx < 1 .   *** '
+             STOP
+           ELSE
+             alphax = 1. - 1./ grossismx
+           ENDIF
+
+           IF( grossismy.LT.1. )  THEN
+             PRINT *,' ***  ATTENTION !! grossismy < 1 .   *** '
+             STOP
+           ELSE
+             alphay = 1. - 1./ grossismy
+           ENDIF
+
+           PRINT *,' '
+           PRINT *,' --> In defrun: alphax alphay  ',alphax,alphay
+           PRINT *,' '
+c
+           fxyhypbb=.false.
+           call getin("fxyhypbb",fxyhypbb)
+  
+           IF( .NOT.fxyhypb )  THEN
+             IF( fxyhypbb )     THEN
+                PRINT *,' ********  PBS DANS  DEFRUN  ******** '
+                PRINT *,' *** fxyhypb lu sur le fichier start est F ',
+     *          'alors  qu il est  T  sur  run.def  ***'
+                STOP
+             ENDIF
+           ELSE
+             IF( .NOT.fxyhypbb )   THEN
+                PRINT *,' ********  PBS DANS  DEFRUN  ******** '
+                PRINT *,' ***  fxyhypb lu sur le fichier start est T ',
+     *         'alors  qu il est  F  sur  run.def  ****  '
+                STOP
+             ENDIF
+           ENDIF
+           dzoomxx=0.0
+           call getin("dzoomx",dzoomxx)
+
+           IF( fxyhypb )  THEN
+              IF( ABS(dzoomx - dzoomxx).GE. 0.001 )  THEN
+                PRINT *,' La valeur de dzoomx passee par run.def est '
+     *          ,'differente de celle lue sur le fichier  start '
+                STOP
+              ENDIF
+           ENDIF
+
+           dzoomyy=0.0
+           call getin("dzoomy",dzoomyy)
+
+           IF( fxyhypb )  THEN
+              IF( ABS(dzoomy - dzoomyy).GE. 0.001 )  THEN
+                PRINT *,' La valeur de dzoomy passee par run.def est '
+     *          ,'differente de celle lue sur le fichier  start '
+                STOP
+              ENDIF
+           ENDIF
+
+           tauxx=2.0
+           call getin("taux",tauxx)
+
+           tauyy=2.0
+           call getin("tauy",tauyy)
+
+           IF( fxyhypb )  THEN
+              IF( ABS(taux - tauxx).GE. 0.001 )  THEN
+                WRITE(6,*)' La valeur de taux passee par run.def est', 
+     *             'differente de celle lue sur le fichier  start '
+                CALL ABORT
+              ENDIF
+
+              IF( ABS(tauy - tauyy).GE. 0.001 )  THEN
+                WRITE(6,*)' La valeur de tauy passee par run.def est',
+     *          'differente de celle lue sur le fichier  start '
+                CALL ABORT
+              ENDIF
+           ENDIF
+  
+        ELSE    ! Below, case when etainit=.true.
+
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "longitude en degres du centre du zoom"
+           clon=63. ! default value
+           call getin("clon",clon)
+           WRITE(lunout,*)" clon = ",clon
+           
+c
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "latitude en degres du centre du zoom "
+           clat=0. ! default value
+           call getin("clat",clat)
+           WRITE(lunout,*)" clat = ",clat
+
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "facteur de grossissement du zoom,",
+     & " selon longitude"
+           grossismx=1.0 ! default value
+           call getin("grossismx",grossismx)
+           WRITE(lunout,*)" grossismx = ",grossismx
+
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "facteur de grossissement du zoom ,",
+     & " selon latitude"
+           grossismy=1.0 ! default value
+           call getin("grossismy",grossismy)
+           WRITE(lunout,*)" grossismy = ",grossismy
+
+           IF( grossismx.LT.1. )  THEN
+            PRINT *,' ***  ATTENTION !! grossismx < 1 .   *** '
+            STOP
+           ELSE
+             alphax = 1. - 1./ grossismx
+           ENDIF
+
+           IF( grossismy.LT.1. )  THEN
+             PRINT *,' ***  ATTENTION !! grossismy < 1 .   *** '
+             STOP
+           ELSE
+             alphay = 1. - 1./ grossismy
+           ENDIF
+
+           PRINT *,' Defrun  alphax alphay  ',alphax,alphay
+c
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "Fonction  f(y)  hyperbolique  si = .true.",
+     &  ", sinon  sinusoidale"
+           fxyhypb=.false. ! default value
+           call getin("fxyhypb",fxyhypb)
+           WRITE(lunout,*)" fxyhypb = ",fxyhypb
+
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "extension en longitude de la zone du zoom", 
+     & " (fraction de la zone totale)"
+           dzoomx=0. ! default value
+           call getin("dzoomx",dzoomx)
+           WRITE(lunout,*)" dzoomx = ",dzoomx
+
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "extension en latitude de la zone du zoom", 
+     & " (fraction de la zone totale)"
+           dzoomy=0. ! default value
+           call getin("dzoomy",dzoomy)
+           WRITE(lunout,*)" dzoomy = ",dzoomy
+
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "raideur du zoom en  X"
+           taux=2. ! default value
+           call getin("taux",taux)
+           WRITE(lunout,*)" taux = ",taux
+
+           WRITE(lunout,*) ""
+           WRITE(lunout,*) "raideur du zoom en  Y"
+           tauy=2.0 ! default value
+           call getin("tauy",tauy)
+           WRITE(lunout,*)" tauy = ",tauy
+
+        END IF ! of if (.not.etatinit )
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "Use a sponge layer?"
+        callsponge=.true. ! default value
+        call getin("callsponge",callsponge)
+        WRITE(lunout,*)" callsponge = ",callsponge
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "Sponge: number of layers over which",
+     &                    " sponge extends"
+        nsponge=3 ! default value
+        call getin("nsponge",nsponge)
+        WRITE(lunout,*)" nsponge = ",nsponge
+
+        WRITE(lunout,*)""
+        WRITE(lunout,*)"Sponge mode: (forcing is towards ..."
+        WRITE(lunout,*)"  over upper nsponge layers)"
+        WRITE(lunout,*)"  0: (h=hmean,u=v=0)"
+        WRITE(lunout,*)"  1: (h=hmean,u=umean,v=0)"
+        WRITE(lunout,*)"  2: (h=hmean,u=umean,v=vmean)"
+        mode_sponge=2 ! default value
+        call getin("mode_sponge",mode_sponge)
+        WRITE(lunout,*)" mode_sponge = ",mode_sponge
+
+        WRITE(lunout,*) ""
+        WRITE(lunout,*) "Sponge: characteristic time scale tetasponge"
+        WRITE(lunout,*) "(seconds) at topmost layer (time scale then "
+        WRITE(lunout,*) " doubles with decreasing layer index)."
+        tetasponge=50000.0
+        call getin("tetasponge",tetasponge)
+        WRITE(lunout,*)" tetasponge = ",tetasponge
+
+
+      WRITE(lunout,*) '-----------------------------------------------'
+      WRITE(lunout,*) ' '
+      WRITE(lunout,*) ' '
+c
+
+c       Unlike on Earth (cf LMDZ2.2) , always a regular grid on Mars :
+        ysinus = .false. !Mars Mettre a jour
+
+
+      WRITE(lunout,*) '-----------------------------------------------'
+      WRITE(lunout,*) ' '
+      WRITE(lunout,*) ' '
+cc
+      ELSE
+        write(tapeerr,*) ' WHERE IS run.def ? WE NEED IT !!!!!!!!!!!!!!'
+        stop
+      ENDIF ! of IF(ierr.eq.0)
+
+c     Test sur le zoom
+
+      if((grossismx.eq.1).and.(grossismy.eq.1)) then  
+c        Pas de zoom :
+         write(lunout,*) 'No zoom ? -> fxyhypb set to False'
+     &   ,'           (It runs better that way)'
+         fxyhypb = .false.
+      else     
+c        Avec Zoom
+         if (.not.fxyhypb) stop 'With zoom, fxyhypb should be set to T 
+     &in run.def for this version... -> STOP ! '     
+      end if
+#else
+      write(*,*) "defrun_new should not be used in parallel mode!"
+      stop
+#endif
+! of #ifndef CPP_PARA
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/diagadv.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/diagadv.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/diagadv.F	(revision 1644)
@@ -0,0 +1,77 @@
+      subroutine diagadv(q,masse,descript)
+      implicit none
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+      real q(iip1,jjp1,llm),masse(iip1,jjp1,llm)
+      integer i,j,l
+      character*10 descript
+      real sss,smas,smin,smax
+ 
+      external ismin,ismax
+      integer ismin,ismax
+ 
+      sss=0.
+      smas=0.
+      smin=1.e33
+      smax=-1.e33
+      do l=1,llm
+        do j=1,jjp1
+           do i=1,iim
+              sss=sss+masse(i,j,l)*q(i,j,l)
+              smas=smas+masse(i,j,l)
+              smin=min(smin,q(i,j,l))
+              smax=max(smax,q(i,j,l))
+           enddo
+        enddo
+      enddo
+
+      write(*,1000) descript,smin,smax,sss/smas,sss
+ 
+      return
+1000  format(a10,'   MIN:',e15.4,'   MAX:',e15.4,'   MOY:',e15.4
+     s   ,'   TOT:',e15.4)
+      end
+
+      FUNCTION ismin(n,sx,incx)
+c
+      IMPLICIT NONE
+c
+      integer n,i,incx,ismin,ix
+      real sx((n-1)*incx+1),sxmin
+c
+      ix=1
+      ismin=1
+      sxmin=sx(1)
+      DO i=1,n-1
+         ix=ix+incx
+         if(sx(ix).lt.sxmin) then
+             sxmin=sx(ix)
+             ismin=i+1
+         endif
+      ENDDO
+c
+      return
+      end
+C
+      function ismax(n,sx,incx)
+c
+      IMPLICIT NONE
+c
+      INTEGER n,i,incx,ismax,ix
+      real sx((n-1)*incx+1),sxmax
+c
+      ix=1
+      ismax=1
+      sxmax=sx(1)
+      do 10 i=1,n-1
+       ix=ix+incx
+       if(sx(ix).gt.sxmax) then
+         sxmax=sx(ix)
+         ismax=i+1
+       endif
+10    continue
+c
+      return
+      end
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/dissip.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/dissip.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/dissip.F	(revision 1644)
@@ -0,0 +1,143 @@
+      SUBROUTINE dissip( vcov,ucov,teta,p, dv,du,dh )
+c
+      USE comconst_mod, ONLY: dtdiss
+
+      IMPLICIT NONE
+
+
+c ..  Avec nouveaux operateurs star :  gradiv2 , divgrad2, nxgraro2  ...
+c                                 (  10/01/98  )
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   Dissipation horizontale
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "comdissnew.h"
+#include "comdissipn.h"
+
+c   Arguments:
+c   ----------
+
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm),teta(ip1jmp1,llm)
+      REAL  p( ip1jmp1,llmp1 )
+      REAL dv(ip1jm,llm),du(ip1jmp1,llm),dh(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      REAL gdx(ip1jmp1,llm),gdy(ip1jm,llm)
+      REAL grx(ip1jmp1,llm),gry(ip1jm,llm)
+      REAL te1dt(llm),te2dt(llm),te3dt(llm)
+      REAL deltapres(ip1jmp1,llm)
+
+      INTEGER l,ij
+
+      REAL  SSUM
+      EXTERNAL  gradiv ,nXgrarot,divgrad,initial0
+      EXTERNAL  gradiv2,nXgraro2,divgrad2,SSUM
+
+c-----------------------------------------------------------------------
+c   initialisations:
+c   ----------------
+
+      DO l=1,llm
+         te1dt(l) = tetaudiv(l) * dtdiss
+         te2dt(l) = tetaurot(l) * dtdiss
+         te3dt(l) = tetah(l)    * dtdiss
+      ENDDO
+      CALL initial0( ijp1llm, du )
+      CALL initial0( ijmllm , dv )
+      CALL initial0( ijp1llm, dh )
+
+c-----------------------------------------------------------------------
+c   Calcul de la dissipation:
+c   -------------------------
+
+c   Calcul de la partie   grad  ( div ) :
+c   -------------------------------------
+
+
+      IF(lstardis) THEN
+         CALL gradiv2( llm,ucov,vcov,nitergdiv,gdx,gdy )
+      ELSE
+         CALL gradiv ( llm,ucov,vcov,nitergdiv,gdx,gdy )
+      ENDIF
+
+      DO l=1,llm
+
+         DO ij = 1, iip1
+            gdx(     ij ,l) = 0.
+            gdx(ij+ip1jm,l) = 0.
+         ENDDO
+
+         DO ij = iip2,ip1jm
+            du(ij,l) = du(ij,l) - te1dt(l) *gdx(ij,l)
+         ENDDO
+         DO ij = 1,ip1jm
+            dv(ij,l) = dv(ij,l) - te1dt(l) *gdy(ij,l)
+         ENDDO
+
+       ENDDO
+
+c   calcul de la partie   n X grad ( rot ):
+c   ---------------------------------------
+
+      IF(lstardis) THEN
+         CALL nxgraro2( llm,ucov, vcov, nitergrot,grx,gry )
+      ELSE
+         CALL nxgrarot( llm,ucov, vcov, nitergrot,grx,gry )
+      ENDIF
+
+
+      DO l=1,llm
+         DO ij = 1, iip1
+            grx(ij,l) = 0.
+         ENDDO
+
+         DO ij = iip2,ip1jm
+            du(ij,l) = du(ij,l) - te2dt(l) * grx(ij,l)
+         ENDDO
+         DO ij =  1, ip1jm
+            dv(ij,l) = dv(ij,l) - te2dt(l) * gry(ij,l)
+         ENDDO
+      ENDDO
+
+c   calcul de la partie   div ( grad ):
+c   -----------------------------------
+
+        
+      IF(lstardis) THEN
+
+       DO l = 1, llm
+          DO ij = 1, ip1jmp1
+            deltapres(ij,l) = AMAX1( 0.,  p(ij,l) - p(ij,l+1) )
+          ENDDO
+       ENDDO
+
+         CALL divgrad2( llm,teta, deltapres  ,niterh, gdx )
+      ELSE
+         CALL divgrad ( llm,teta, niterh, gdx        )
+      ENDIF
+
+      DO l = 1,llm
+         DO ij = 1,ip1jmp1
+            dh( ij,l ) = dh( ij,l ) - te3dt(l) * gdx( ij,l )
+         ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/disvert.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/disvert.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/disvert.F	(revision 1644)
@@ -0,0 +1,310 @@
+      SUBROUTINE disvert 
+
+! to use  'getin'
+      USE ioipsl_getincom 
+      USE callkeys_mod, ONLY: kastprof,pceil
+      USE comvert_mod, ONLY: ap,bp,sig,nivsigs,nivsig,pa,preff,
+     .			aps,bps,presnivs,pseudoalt,scaleheight
+
+c    Auteur :  F. Forget Y. Wanherdrick, P. Levan
+c    Nouvelle version 100% Mars !!
+
+      USE comconst_mod, ONLY: pi
+      USE logic_mod, ONLY: autozlevs,hybrid
+
+      IMPLICIT NONE
+
+#include "dimensions.h"
+#include "paramet.h"
+
+
+c
+c=======================================================================
+c    Discretisation verticale en coordonnée hybride OU sigma
+c
+c=======================================================================
+c
+c   declarations:
+c   -------------
+c
+c
+      INTEGER l,ll
+      REAL snorm
+      REAL alpha,beta,gama,delta,deltaz,quoi,quand
+      REAL zsig(llm)
+      INTEGER np,ierr
+      integer :: ierr1,ierr2,ierr3,ierr4 
+      REAL x
+
+      REAL SSUM
+      EXTERNAL SSUM
+      real newsig 
+      REAL dz0,dz1,nhaut,sig1,esig,csig,zz
+      real tt,rr,gg, prevz
+      real s(llm),dsig(llm) 
+
+      integer iz 
+      real z, ps,p
+
+
+      real psurf, hmax ! for autozlevs
+
+c
+c-----------------------------------------------------------------------
+c
+      pi=2.*ASIN(1.)
+
+      open(99,file="z2sig.def",status='old',form='formatted',
+     s     iostat=ierr4)
+
+
+      autozlevs=.false.
+      PRINT *,'Auto-discretise vertical levels ?'
+      call getin("autozlevs",autozlevs)
+      write(*,*) " autozlevs = ", autozlevs
+
+      write(*,*)"Operate in kastprof mode?"
+      kastprof=.false.
+      call getin("kastprof",kastprof)
+      write(*,*)" kastprof = ",kastprof
+
+      print*,'kast=',kastprof
+
+      pceil=100.0 ! Pascals
+      PRINT *,'Ceiling pressure (Pa) ?'
+      call getin("pceil",pceil)
+      write(*,*) " pceil = ", pceil
+
+      if(autozlevs.and.iim.gt.1)then
+         print*,'autozlevs no good in 3D...'
+         call abort
+      endif
+
+      if(kastprof.and.iim.gt.1)then
+         print*,'kastprof no good in 3D...'
+         call abort
+      endif
+
+      psurf=610. ! default value for psurf
+      PRINT *,'Surface pressure (Pa) ?'
+      call getin("psurf",psurf)
+      write(*,*) " psurf = ",psurf
+
+      if(kastprof)then
+
+        sig(1)=1
+        do l=2,llm
+                                !sig(l)=1. - real(l-1)/real(llm) ! uses linear sigma spacing
+                                !sig(l)=exp(-real(l-1)*h/real(llm)) ! uses log sigma spacing
+                                !sig(l)=exp(-real(l-1)*Hmax/real(llm)) ! uses log sigma spacing
+           sig(l)=(pceil/psurf)**(real(l-1)/real(llm)) ! uses log sigma spacing
+           
+        end do
+        sig(llm+1)=0
+
+      elseIF(ierr4.eq.0)then
+         PRINT*,'****************************'
+         PRINT*,'Lecture de z2sig.def'
+         PRINT*,'****************************'
+
+         READ(99,*) scaleheight
+         do l=1,llm
+            read(99,*) zsig(l)
+         end do
+         CLOSE(99)
+
+
+         if(autozlevs)then
+            open(91,file="z2sig.def",form='formatted')
+            read(91,*) scaleheight
+            DO l=1,llm-2
+               read(91,*) Hmax
+            enddo
+            close(91)
+
+            print*,'Hmax = ',Hmax,' km'
+            print*,'Auto-shifting h in disvert.F to:'
+!            h = Hmax / log(psurf/100.0)
+            scaleheight = Hmax / log(psurf/pceil)
+            print*,'h = ',scaleheight,' km'
+        endif
+       
+        sig(1)=1
+        do l=2,llm
+           sig(l) = 0.5 * ( exp(-zsig(l)/scaleheight) + 
+     &                      exp(-zsig(l-1)/scaleheight) )
+        end do
+        sig(llm+1)=0
+
+c-----------------------------------------------------------------------
+      ELSE
+         write(*,*) 'didn_t you forget something?'
+         write(*,*) 'We need the file  z2sig.def!'! (OR esasig.def) '
+         stop
+      ENDIF
+c-----------------------------------------------------------------------
+
+
+      DO l=1,llm
+        nivsigs(l) = FLOAT(l)
+      ENDDO
+
+      DO l=1,llmp1
+        nivsig(l)= FLOAT(l)
+      ENDDO
+
+ 
+c-----------------------------------------------------------------------
+c    ....  Calculs  de ap(l) et de bp(l)  ....
+c    .........................................
+c
+c   .....  pa et preff sont lus  sur les fichiers start par dynetat0 .....
+c-----------------------------------------------------------------------
+c
+
+      if (hybrid) then
+         write(*,*) "*******************************"
+         write(*,*) "Systeme en coordonnees hybrides"
+         write(*,*) 
+c        Coordonnees hybrides avec mod
+         DO l = 1, llm
+
+         call sig_hybrid(sig(l),pa,preff,newsig)
+            bp(l) = EXP( 1. - 1./(newsig**2)  )
+            ap(l) = pa * (newsig - bp(l) )
+         enddo
+         bp(llmp1) = 0.
+         ap(llmp1) = 0.
+      else
+         write(*,*) "****************************"
+         write(*,*) "Systeme en coordonnees sigma"
+         write(*,*) 
+c        Pour ne pas passer en coordonnees hybrides
+         DO l = 1, llm
+            ap(l) = 0.
+            bp(l) = sig(l)
+         ENDDO
+         ap(llmp1) = 0.
+      endif
+
+      bp(llmp1) =   0.
+
+      PRINT *,' BP '
+      PRINT *,  bp
+      PRINT *,' AP '
+      PRINT *,  ap
+
+c     Calcul au milieu des couches :
+c     WARNING : le choix de placer le milieu des couches au niveau de
+c     pression intermédiaire est arbitraire et pourrait etre modifié.
+c     Le calcul du niveau pour la derniere couche 
+c     (on met la meme distance (en log pression)  entre P(llm)
+c     et P(llm -1) qu'entre P(llm-1) et P(llm-2) ) est
+c     Specifique.  Ce choix est spécifié ici ET dans exner_hyb.F
+
+      DO l = 1, llm-1
+       aps(l) =  0.5 *( ap(l) +ap(l+1)) 
+       bps(l) =  0.5 *( bp(l) +bp(l+1)) 
+      ENDDO
+     
+      if (hybrid) then
+         aps(llm) = aps(llm-1)**2 / aps(llm-2) 
+         bps(llm) = 0.5*(bp(llm) + bp(llm+1))
+      else
+         bps(llm) = bps(llm-1)**2 / bps(llm-2) 
+         aps(llm) = 0. ! what the hell is this???
+      end if
+
+      PRINT *,' BPs '
+      PRINT *,  bps
+      PRINT *,' APs'
+      PRINT *,  aps
+
+
+      DO l = 1, llm
+       presnivs(l) = aps(l)+bps(l)*preff
+       pseudoalt(l) = -scaleheight*log(presnivs(l)/preff)
+      ENDDO
+
+      PRINT *,' PRESNIVS' 
+      PRINT *,presnivs 
+      PRINT *,'Pseudo altitude des Presnivs : ' 
+      PRINT *,pseudoalt
+
+
+c     --------------------------------------------------
+c     This can be used to plot the vertical discretization
+c     (> xmgrace -nxy testhybrid.tab       (z = H*log(p(l)/pref))
+c     --------------------------------------------------
+c     open (53,file='testhybrid.tab')
+c     do iz=0,60
+c       z = -10 + min(iz,60-iz)
+c       ps = preff*exp(-z/10)
+c       do l=1,llm
+c          zsig(l)= -10.*log((aps(l) + bps(l)*ps)/preff)
+c       end do
+c       write(53,*)iz, (zsig(l),l=1,llm,1)
+c      end do
+c      close(53)
+c     --------------------------------------------------
+
+
+      RETURN
+      END
+
+c ************************************************************
+      subroutine sig_hybrid(sig,pa,preff,newsig)
+c     ----------------------------------------------
+c     Subroutine utilisee pour calculer des valeurs de sigma modifie
+c     pour conserver les coordonnees verticales decrites dans
+c     esasig.def/z2sig.def lors du passage en coordonnees hybrides
+c     F. Forget 2002
+c     Connaissant sig (niveaux "sigma" ou on veut mettre les couches)
+c     L'objectif est de calculer newsig telle que
+c       (1 -pa/preff)*exp(1-1./newsig**2)+(pa/preff)*newsig = sig
+c     Cela ne se résoud pas analytiquement: 
+c     => on résoud par iterration bourrine 
+c     ----------------------------------------------
+c     Information  : where exp(1-1./x**2) become << x
+c           x      exp(1-1./x**2) /x
+c           1           1
+c           0.68       0.5
+c           0.5        1.E-1
+c           0.391      1.E-2
+c           0.333      1.E-3
+c           0.295      1.E-4
+c           0.269      1.E-5
+c           0.248      1.E-6
+c        => on peut utiliser newsig = sig*preff/pa si sig*preff/pa < 0.25
+
+
+      implicit none
+      real x1, x2, sig,pa,preff, newsig, F
+      integer j
+
+      newsig = sig
+      x1=0
+      x2=1
+	  if (sig.ge.1) then
+	       newsig= sig
+      else if (sig*preff/pa.ge.0.25) then
+        DO J=1,9999  ! nombre d''iteration max
+          F=((1 -pa/preff)*exp(1-1./newsig**2)+(pa/preff)*newsig)/sig
+c         write(0,*) J, ' newsig =', newsig, ' F= ', F
+          if (F.gt.1) then
+              X2 = newsig
+              newsig=(X1+newsig)*0.5
+          else
+              X1 = newsig
+              newsig=(X2+newsig)*0.5
+          end if
+c         Test : on arete lorsque on approxime sig à moins de 0.01 m près 
+c         (en pseudo altiude) :
+          IF(abs(10.*log(F)).LT.1.E-5) goto 999
+        END DO
+       else   !    if (sig*preff/pa.le.0.25) then
+	        newsig= sig*preff/pa
+       end if
+ 999   continue
+       Return
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/disvert.orig
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/disvert.orig	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/disvert.orig	(revision 1644)
@@ -0,0 +1,341 @@
+      SUBROUTINE disvert 
+
+c    Auteur :  P. Le Van . F. Forget Y. Wanherdrick
+c    Many modif special mars !!
+
+      IMPLICIT NONE
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comvert.h"
+#include "comconst.h"
+#include "hybrid.h"
+c
+c=======================================================================
+c    Discretisation verticale en coordonnée hybride
+c
+c=======================================================================
+c
+c   declarations:
+c   -------------
+c
+c
+      INTEGER l,ll
+      REAL snorm
+      REAL alpha,beta,gama,delta,deltaz,h,zsig,quoi,quand
+      INTEGER np,ierr
+      integer :: ierr1,ierr2,ierr3,ierr4
+      REAL x
+
+      REAL SSUM
+      EXTERNAL SSUM
+      real newsig 
+      REAL dz0,dz1,nhaut,sig1,esig,csig,zz
+      real tt,rr,gg, prevz
+      real s(llm),dsig(llm) 
+
+c
+c-----------------------------------------------------------------------
+c
+      pi=2.*ASIN(1.)
+
+      open(99,file="sigma.def",status='old',form='formatted',
+     s   iostat=ierr1)
+! Ouverture possible de fichiers typiquement E.T.
+
+      if(ierr1.ne.0) then
+         close(99)
+         open(99,file="esasig.def",status='old',form='formatted',
+     s   iostat=ierr2)
+         if(ierr2.ne.0) then
+            close(99)
+            open(99,file="tritonsig.def",status='old',form='formatted',
+     s      iostat=ierr3)
+            if(ierr3.ne.0) then
+              close(99)
+              open(99,file="z2sig.def",status='old',form='formatted',
+     s        iostat=ierr4)
+            endif
+         endif
+      endif
+
+c-----------------------------------------------------------------------
+c   cas 1 on lit les options dans sigma.def:
+c   ----------------------------------------
+
+      IF (ierr1.eq.0) THEN
+
+         PRINT*,'*****************************'
+         PRINT*,'WARNING Lecture de sigma.def'
+         PRINT*,'*****************************'
+      READ(99,*) deltaz
+      READ(99,*) h
+      READ(99,*) beta
+      READ(99,*) gama
+      READ(99,*) delta
+      READ(99,*) np
+      CLOSE(99)
+      alpha=deltaz/(llm*h)
+c
+
+       DO l = 1, llm
+          dsig(l) = (alpha+(1.-alpha)*exp(-beta*(llm-l)))*
+     $          ( (tanh(gama*l)/tanh(gama*llm))**np +
+     $            (1.-l/FLOAT(llm))*delta )
+       ENDDO
+
+       sig(1)=1.
+       DO l=1,llm-1
+          sig(l+1)=sig(l)*(1.-dsig(l))/(1.+dsig(l))
+       ENDDO
+       sig(llm+1)=0.
+
+c
+
+! Debut de la partie martienne pour lecture de esasig.def
+c=========================================================
+
+      ELSE IF(ierr2.eq.0) then
+
+         PRINT*,'*****************************'
+         PRINT*,'WARNING Lecture de esasig.def'
+         PRINT*,'*****************************'
+         READ(99,*) h
+         READ(99,*) dz0
+         READ(99,*) dz1
+         READ(99,*) nhaut
+         CLOSE(99)
+
+         dz0=dz0/h
+         dz1=dz1/h
+
+         sig1=(1.-dz1)/tanh(.5*(llm-1)/nhaut)
+
+         esig=1.
+
+         PRINT*
+         do l=1,20
+            esig=-log((1./sig1-1.)*exp(-dz0)/esig)/(llm-1.)
+         enddo
+         print*,'esig=',esig
+         PRINT*
+         csig=(1./sig1-1.)/(exp(esig)-1.)
+
+         DO L = 2, llm
+            zz=csig*(exp(esig*(l-1.))-1.)
+            sig(l) =1./(1.+zz)
+     &      * tanh(.5*(llm+1-l)/nhaut)
+         ENDDO
+         sig(1)=1.
+         sig(llm+1)=0.
+
+c Fin de la partie martienne
+c ==========================
+
+      ELSE IF(ierr3.eq.0) then
+
+         PRINT*,'********************************'
+         PRINT*,'WARNING Lecture de tritonsig.def'
+         PRINT*,'********************************'
+         PRINT*,'kappa=', kappa
+         READ(99,*) gg
+         READ(99,*) rr
+         sig(1)=1.
+         prevz=0.
+         do l=1,llm-1
+           read(99,*) zz, tt
+           sig(l+1) = sig(l)* exp(-(zz-prevz)*gg/(rr*tt))
+           prevz=zz
+           if(l.eq.llm/2)h =1.e-3* rr*tt/gg
+         end do
+         sig(llm+1)=0.
+         CLOSE(99)
+
+      ELSE IF(ierr4.eq.0) then
+         PRINT*,'****************************'
+         PRINT*,'WARNING Lecture de z2sig.def'
+         PRINT*,'****************************'
+
+
+         READ(99,*) h
+         do l=1,llm
+            read(99,*) zsig
+            s(l) = exp(-kappa*zsig/h)
+         end do
+         CLOSE(99)
+
+         sig(1) =1
+         do l=2,llm
+           sig(l) = 0.5 * (s(l)**(1/kappa)+s(l-1)**(1/kappa))
+         end do
+         sig(llm+1) =0
+
+      ELSE
+c-----------------------------------------------------------------------
+c   cas 2 ancienne discretisation (LMD5...):
+c   ----------------------------------------
+
+      PRINT*,'********************************************'
+      PRINT*,'WARNING!!! Ancienne discretisation verticale'
+      PRINT*,'********************************************'
+      stop ! interdit sur MARS
+      h=7.
+      snorm  = 0.
+      DO l = 1, llm
+         x = 2.*asin(1.) * (FLOAT(l)-0.5) / float(llm+1)
+         dsig(l) = 1.0 + 7.0 * SIN(x)**2
+         snorm = snorm + dsig(l)
+      ENDDO
+      snorm = 1./snorm
+      DO l = 1, llm
+         dsig(l) = dsig(l)*snorm
+      ENDDO
+      sig(llm+1) = 0.
+      DO l = llm, 1, -1
+         sig(l) = sig(l+1) + dsig(l)
+      ENDDO
+
+      ENDIF
+c-----------------------------------------------------------------------
+
+      DO l=1,llm
+        nivsigs(l) = FLOAT(l)
+      ENDDO
+
+      DO l=1,llmp1
+        nivsig(l)= FLOAT(l)
+      ENDDO
+
+c    On ne recalcule s que dans les cas "classique"
+c    (esasig.def, sigma.def, ou ancienne discretisation sans fichier)
+      IF( (ierr1.eq.0) .or. (ierr2.eq.0)
+     &   .or. ((ierr3.ne.0).and.(ierr4.ne.0)) ) then
+         quoi      = 1. + 2.* kappa
+         s( llm )  = 1.
+         s(llm-1) = quoi
+         IF( llm.gt.2 )  THEN
+            DO  ll = 2, llm-1
+               l         = llm+1 - ll
+               quand     = sig(l+1)/ sig(l)
+               s(l-1)    = quoi * (1.-quand) * s(l)  + quand * s(l+1)
+            ENDDO
+         END IF
+c
+         snorm=(1.-.5*sig(2)+kappa*(1.-sig(2)))*s(1)+.5*sig(2)*s(2)
+         DO l = 1, llm
+            s(l)    = s(l)/ snorm
+         ENDDO
+      END IF
+
+c
+c    ....  Calculs  de ap(l) et de bp(l)  ....
+c    .........................................
+c
+c
+c   .....  pa et preff sont lus  sur les fichiers start par dynetat0 .....
+c
+
+
+      if (hybrid) then
+         write(*,*) "*******************************"
+         write(*,*) "Systeme en coordonnees hybrides"
+         write(*,*) 
+c        Coordonnees hybrides avec mod
+         write(*,*) "sig disvert",sig
+         DO l = 1, llm
+            call sig_hybrid(sig(l),pa,preff,1.e-6,newsig)
+            bp(l) = EXP( 1. -1./( newsig*newsig) )
+            ap(l) = pa * (newsig - bp(l) )
+         enddo
+         call sig_hybrid(sig(llmp1),pa,preff,1.e-6,newsig)
+         ap(llmp1) = pa * ( newsig - bp(llmp1) )
+      else
+         write(*,*) "****************************"
+         write(*,*) "Systeme en coordonnees sigma"
+         write(*,*) 
+c        Pour ne pas passer en coordonnees hybrides
+         DO l = 1, llm
+            ap(l) = 0.
+            bp(l) = sig(l)
+         ENDDO
+         ap(llmp1) = 0.
+      endif
+
+      bp(llmp1) =   0.
+
+      PRINT *,' BP '
+      PRINT *,  bp
+      PRINT *,' AP '
+      PRINT *,  ap
+
+c     Calcul au milieu des couches :
+c     WARNING : le choix de placer le milieu des couches au niveau de
+c     pression intermédiaire est arbitraire et pourrait etre modifié.
+c     Le calcul du niveau pour la derniere couche 
+c     (on met la meme distance (en log pression)  entre P(llm)
+c     et P(llm -1) qu'entre P(llm-1) et P(llm-2) ) est
+c     Specifique.  Ce choix est spécifié ici ET dans exner_hyb.F
+
+      DO l = 1, llm-1
+       aps(l) =  0.5 *( ap(l) +ap(l+1)) 
+       bps(l) =  0.5 *( bp(l) +bp(l+1)) 
+      ENDDO
+     
+      if (hybrid) then
+         aps(llm) = ap(llm-1)**2 / ap(llm-2) 
+         bps(llm) = 0.5*(bp(llm) + bp(llm+1))
+      else
+         bps(llm) = bp(llm-1)**2 / bp(llm-2) 
+         aps(llm) = 0.
+      end if
+
+      PRINT *,' BPs '
+      PRINT *,  bps
+      PRINT *,' APs'
+      PRINT *,  aps
+
+      DO l = 1, llm
+       presnivs(l) = aps(l)+bps(l)*preff
+       pseudoalt(l) = -10.*log(presnivs(l)/preff)
+      ENDDO
+
+      PRINT *,' PRESNIVS' 
+      PRINT *,presnivs 
+      PRINT *,'Pseudo altitude des Presnivs : ' 
+      PRINT *,pseudoalt
+
+      RETURN
+      END
+
+c ************************************************************
+      subroutine sig_hybrid(sig,pa,preff,xacc,newsig)
+c     ----------------------------------------------
+c     Subroutine utilisee pour calculer des valeurs de sigma modifie
+c     pour conserver les coordonnees verticales decrites dans
+c     esasig.def/z2sig.def lors du passage en coordonnees hybrides
+c     F. Forget 2002
+c     ----------------------------------------------
+      implicit none
+      real x1, x2, xacc, sig,pa,preff, newsig, F
+      integer j
+
+      newsig = sig
+      x1=0
+      x2=1
+      if ((sig.ne.0).and.(sig.ne.1)) then
+        DO J=1,9999  ! nombre d''iteration max
+          F=(1 -pa/preff)*exp(1-1./newsig**2)+(pa/preff)*newsig -sig
+          if (F.gt.0) then
+              X2 = newsig
+              newsig=(X1+newsig)*0.5
+          else
+              X1 = newsig
+              newsig=(X2+newsig)*0.5
+          end if
+c       write(0,*) J, ' newsig =', newsig, ' F= ', F
+
+        IF(X2-X1.LT.XACC) RETURN
+        END DO
+       end if
+       Return
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/diverg.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/diverg.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/diverg.F	(revision 1644)
@@ -0,0 +1,83 @@
+      SUBROUTINE diverg(klevel,x,y,div)
+c
+c     P. Le Van
+c
+c  *********************************************************************
+c  ... calcule la divergence a tous les niveaux d'1 vecteur de compos. 
+c     x et y...
+c              x et y  etant des composantes covariantes   ...
+c  *********************************************************************
+      IMPLICIT NONE
+c
+c      x  et  y  sont des arguments  d'entree pour le s-prog
+c        div      est  un argument  de sortie pour le s-prog
+c
+c
+c   ---------------------------------------------------------------------
+c
+c    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
+c
+c   ---------------------------------------------------------------------
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c    ..........          variables en arguments    ...................
+c
+      INTEGER klevel
+      REAL x( ip1jmp1,klevel ),y( ip1jm,klevel ),div( ip1jmp1,klevel )
+      INTEGER   l,ij
+c
+c    ...............     variables  locales   .........................
+
+      REAL aiy1( iip1 ) , aiy2( iip1 )
+      REAL sumypn,sumyps
+c    ...................................................................
+c
+      EXTERNAL  SSUM
+      REAL      SSUM
+c
+c
+      DO 10 l = 1,klevel
+c
+        DO  ij = iip2, ip1jm - 1
+         div( ij + 1, l )     =  
+     *   cvusurcu( ij+1 ) * x( ij+1,l ) - cvusurcu( ij ) * x( ij , l) +
+     *   cuvsurcv(ij-iim) * y(ij-iim,l) - cuvsurcv(ij+1) * y(ij+1,l) 
+        ENDDO
+c
+c     ....  correction pour  div( 1,j,l)  ......
+c     ....   div(1,j,l)= div(iip1,j,l) ....
+c
+CDIR$ IVDEP
+        DO  ij = iip2,ip1jm,iip1
+         div( ij,l ) = div( ij + iim,l )
+        ENDDO
+c
+c     ....  calcul  aux poles  .....
+c
+        DO  ij  = 1,iim
+         aiy1(ij) =    cuvsurcv(    ij       ) * y(     ij     , l )
+         aiy2(ij) =    cuvsurcv( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
+        ENDDO
+        sumypn = SSUM ( iim,aiy1,1 ) / apoln
+        sumyps = SSUM ( iim,aiy2,1 ) / apols
+c
+        DO  ij = 1,iip1
+         div(     ij    , l ) = - sumypn
+         div( ij + ip1jm, l ) =   sumyps
+        ENDDO
+  10  CONTINUE
+c
+
+ccc        CALL filtreg( div, jjp1, klevel, 2, 2, .TRUE., 1 )
+      
+c
+        DO l = 1, klevel
+           DO ij = iip2,ip1jm
+            div(ij,l) = div(ij,l) * unsaire(ij) 
+          ENDDO
+        ENDDO
+c
+       RETURN
+       END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/diverg_gam.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/diverg_gam.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/diverg_gam.F	(revision 1644)
@@ -0,0 +1,78 @@
+      SUBROUTINE diverg_gam(klevel,cuvscvgam,cvuscugam,unsairegam ,
+     *                       unsapolnga,unsapolsga,  x, y,  div )
+c
+c     P. Le Van
+c
+c  *********************************************************************
+c  ... calcule la divergence a tous les niveaux d'1 vecteur de compos. 
+c     x et y...
+c              x et y  etant des composantes covariantes   ...
+c  *********************************************************************
+      IMPLICIT NONE
+c
+c      x  et  y  sont des arguments  d'entree pour le s-prog
+c        div      est  un argument  de sortie pour le s-prog
+c
+c
+c   ---------------------------------------------------------------------
+c
+c    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
+c
+c   ---------------------------------------------------------------------
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c    ..........          variables en arguments    ...................
+c
+      INTEGER klevel
+      REAL x( ip1jmp1,klevel ),y( ip1jm,klevel ),div( ip1jmp1,klevel )
+      REAL cuvscvgam(ip1jm),cvuscugam(ip1jmp1),unsairegam(ip1jmp1)
+      REAL unsapolnga,unsapolsga
+c
+c    ...............     variables  locales   .........................
+
+      REAL aiy1( iip1 ) , aiy2( iip1 )
+      REAL sumypn,sumyps
+      INTEGER   l,ij
+c    ...................................................................
+c
+      EXTERNAL  SSUM
+      REAL      SSUM
+c
+c
+      DO 10 l = 1,klevel
+c
+        DO  ij = iip2, ip1jm - 1
+         div( ij + 1, l )     = (  
+     *  cvuscugam( ij+1 ) * x( ij+1,l ) - cvuscugam( ij ) * x( ij , l) +
+     *  cuvscvgam(ij-iim) * y(ij-iim,l) - cuvscvgam(ij+1) * y(ij+1,l) )* 
+     *         unsairegam( ij+1 )
+        ENDDO
+c
+c     ....  correction pour  div( 1,j,l)  ......
+c     ....   div(1,j,l)= div(iip1,j,l) ....
+c
+CDIR$ IVDEP
+        DO  ij = iip2,ip1jm,iip1
+         div( ij,l ) = div( ij + iim,l )
+        ENDDO
+c
+c     ....  calcul  aux poles  .....
+c
+        DO  ij  = 1,iim
+         aiy1(ij) =    cuvscvgam(    ij       ) * y(     ij     , l )
+         aiy2(ij) =    cuvscvgam( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
+        ENDDO
+        sumypn = SSUM ( iim,aiy1,1 ) * unsapolnga
+        sumyps = SSUM ( iim,aiy2,1 ) * unsapolsga
+c
+        DO  ij = 1,iip1
+         div(     ij    , l ) = - sumypn 
+         div( ij + ip1jm, l ) =   sumyps 
+        ENDDO
+  10  CONTINUE
+c
+
+       RETURN
+       END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/divergf.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/divergf.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/divergf.F	(revision 1644)
@@ -0,0 +1,83 @@
+      SUBROUTINE divergf(klevel,x,y,div)
+c
+c     P. Le Van
+c
+c  *********************************************************************
+c  ... calcule la divergence a tous les niveaux d'1 vecteur de compos. 
+c     x et y...
+c              x et y  etant des composantes covariantes   ...
+c  *********************************************************************
+      IMPLICIT NONE
+c
+c      x  et  y  sont des arguments  d'entree pour le s-prog
+c        div      est  un argument  de sortie pour le s-prog
+c
+c
+c   ---------------------------------------------------------------------
+c
+c    ATTENTION : pendant ce s-pg , ne pas toucher au COMMON/scratch/  .
+c
+c   ---------------------------------------------------------------------
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c    ..........          variables en arguments    ...................
+c
+      INTEGER klevel
+      REAL x( ip1jmp1,klevel ),y( ip1jm,klevel ),div( ip1jmp1,klevel )
+      INTEGER   l,ij
+c
+c    ...............     variables  locales   .........................
+
+      REAL aiy1( iip1 ) , aiy2( iip1 )
+      REAL sumypn,sumyps
+c    ...................................................................
+c
+      EXTERNAL  SSUM
+      REAL      SSUM
+c
+c
+      DO 10 l = 1,klevel
+c
+        DO  ij = iip2, ip1jm - 1
+         div( ij + 1, l )     =  
+     *   cvusurcu( ij+1 ) * x( ij+1,l ) - cvusurcu( ij ) * x( ij , l) +
+     *   cuvsurcv(ij-iim) * y(ij-iim,l) - cuvsurcv(ij+1) * y(ij+1,l) 
+        ENDDO
+c
+c     ....  correction pour  div( 1,j,l)  ......
+c     ....   div(1,j,l)= div(iip1,j,l) ....
+c
+CDIR$ IVDEP
+        DO  ij = iip2,ip1jm,iip1
+         div( ij,l ) = div( ij + iim,l )
+        ENDDO
+c
+c     ....  calcul  aux poles  .....
+c
+        DO  ij  = 1,iim
+         aiy1(ij) =    cuvsurcv(    ij       ) * y(     ij     , l )
+         aiy2(ij) =    cuvsurcv( ij+ ip1jmi1 ) * y( ij+ ip1jmi1, l )
+        ENDDO
+        sumypn = SSUM ( iim,aiy1,1 ) / apoln
+        sumyps = SSUM ( iim,aiy2,1 ) / apols
+c
+        DO  ij = 1,iip1
+         div(     ij    , l ) = - sumypn
+         div( ij + ip1jm, l ) =   sumyps
+        ENDDO
+  10  CONTINUE
+c
+
+        CALL filtreg( div, jjp1, klevel, 2, 2, .TRUE., 1 )
+      
+c
+        DO l = 1, klevel
+           DO ij = iip2,ip1jm
+            div(ij,l) = div(ij,l) * unsaire(ij) 
+          ENDDO
+        ENDDO
+c
+       RETURN
+       END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/divergst.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/divergst.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/divergst.F	(revision 1644)
@@ -0,0 +1,60 @@
+      SUBROUTINE divergst(klevel,x,y,div)
+      IMPLICIT NONE
+c
+c     P. Le Van
+c
+c  ******************************************************************
+c  ... calcule la divergence a tous les niveaux d'1 vecteur de compos. x et y...
+c           x et y  etant des composantes contravariantes   ...
+c  ****************************************************************
+c      x  et  y  sont des arguments  d'entree pour le s-prog
+c        div      est  un argument  de sortie pour le s-prog
+c
+c
+c   -------------------------------------------------------------------
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      INTEGER klevel
+      REAL x( ip1jmp1,klevel ),y( ip1jm,klevel ),div( ip1jmp1,klevel )
+      INTEGER ij,l,i
+      REAL aiy1( iip1 ) , aiy2( iip1 )
+      REAL sumypn,sumyps
+
+      REAL SSUM
+      EXTERNAL SSUM
+c
+c
+      DO 10 l = 1,klevel
+c
+      DO 1 ij = iip2, ip1jm - 1
+      div( ij + 1, l ) = x(ij+1,l) - x(ij,l)+ y(ij-iim,l)-y(ij+1,l)
+   1  CONTINUE
+c
+c     ....  correction pour  div( 1,j,l)  ......
+c     ....   div(1,j,l)= div(iip1,j,l) ....
+c
+CDIR$ IVDEP
+      DO 3 ij = iip2,ip1jm,iip1
+      div( ij,l ) = div( ij + iim,l )
+   3  CONTINUE
+c
+c     ....  calcul  aux poles  .....
+c
+c
+      DO 5 i  = 1,iim
+      aiy1(i)= y(i,l)
+      aiy2(i)= y(i+ip1jmi1,l)
+   5  CONTINUE
+      sumypn = SSUM ( iim,aiy1,1 )
+      sumyps = SSUM ( iim,aiy2,1 )
+      DO 7 i = 1,iip1
+      div(     i    , l ) = - sumypn/iim
+      div( i + ip1jm, l ) =   sumyps/iim
+   7  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/divgrad.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/divgrad.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/divgrad.F	(revision 1644)
@@ -0,0 +1,54 @@
+      SUBROUTINE divgrad (klevel,h, lh, divgra )
+      IMPLICIT NONE
+c
+c=======================================================================
+c
+c  Auteur :   P. Le Van
+c  ----------
+c
+c                              lh
+c      calcul de  (div( grad ))   de h  .....
+c      h  et lh  sont des arguments  d'entree pour le s-prog
+c      divgra     est  un argument  de sortie pour le s-prog
+c
+c=======================================================================
+c
+c   declarations:
+c   -------------
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "comdissipn.h"
+c
+      INTEGER klevel
+      REAL h( ip1jmp1,klevel ), divgra( ip1jmp1,klevel )
+c
+      REAL ghy(ip1jm,llm), ghx(ip1jmp1,llm)
+
+      INTEGER  l,ij,iter,lh
+c
+      EXTERNAL  filtreg
+      EXTERNAL  SCOPY, grad, covcont, diverg
+c
+c
+      CALL SCOPY ( ip1jmp1*klevel,h,1,divgra,1 )
+c
+      DO 10 iter = 1,lh
+
+      CALL filtreg ( divgra,jjp1,klevel,2,1,.true.,1  )
+
+      CALL grad (klevel,divgra, ghx  , ghy          )
+      CALL diverg (klevel,  ghx , ghy  , divgra       )
+
+      CALL filtreg ( divgra,jjp1,klevel,2,1,.true.,1)
+
+      DO 5 l = 1,klevel
+      DO 4  ij = 1, ip1jmp1
+      divgra( ij,l ) = - cdivh * divgra( ij,l )
+   4  CONTINUE
+   5  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/divgrad2.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/divgrad2.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/divgrad2.F	(revision 1644)
@@ -0,0 +1,78 @@
+      SUBROUTINE divgrad2 ( klevel, h, deltapres, lh, divgra )
+c
+c     P. Le Van
+c
+c   ***************************************************************
+c
+c     .....   calcul de  (div( grad ))   de (  pext * h ) .....
+c   ****************************************************************
+c   h ,klevel,lh et pext  sont des arguments  d'entree pour le s-prg
+c         divgra     est  un argument  de sortie pour le s-prg
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom2.h"
+#include "comdissipn.h"
+
+c    .......    variables en arguments   .......
+c
+      INTEGER klevel
+      REAL h( ip1jmp1,klevel ), deltapres( ip1jmp1,klevel )
+      REAL divgra( ip1jmp1,klevel)
+c
+c    .......    variables  locales    ..........
+c
+      REAL     signe, nudivgrs, sqrtps( ip1jmp1,llm )
+      INTEGER  l,ij,iter,lh
+c    ...................................................................
+
+      EXTERNAL  filtreg
+      EXTERNAL  SCOPY,  laplacien_gam
+c
+      signe    = (-1.)**lh
+      nudivgrs = signe * cdivh
+
+      CALL SCOPY ( ip1jmp1 * klevel, h, 1, divgra, 1 )
+
+c
+      CALL laplacien( klevel, divgra, divgra )
+     
+      DO l = 1, klevel
+       DO ij = 1, ip1jmp1
+        sqrtps( ij,l ) = SQRT( deltapres(ij,l) )
+       ENDDO
+      ENDDO
+c
+      DO l = 1, klevel
+        DO ij = 1, ip1jmp1
+         divgra(ij,l) = divgra(ij,l) * sqrtps(ij,l)
+        ENDDO
+      ENDDO
+   
+c    ........    Iteration de l'operateur  laplacien_gam    ........
+c
+      DO  iter = 1, lh - 2
+       CALL laplacien_gam ( klevel,cuvscvgam2,cvuscugam2,unsair_gam2,
+     *                     unsapolnga2, unsapolsga2,  divgra, divgra )
+      ENDDO
+c
+c    ...............................................................
+ 
+      DO l = 1, klevel
+        DO ij = 1, ip1jmp1
+          divgra(ij,l) = divgra(ij,l) * sqrtps(ij,l)
+        ENDDO
+      ENDDO
+c
+      CALL laplacien ( klevel, divgra, divgra )
+c
+      DO l  = 1,klevel
+      DO ij = 1,ip1jmp1
+      divgra(ij,l) =  nudivgrs * divgra(ij,l) / deltapres(ij,l)
+      ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/divgrad22.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/divgrad22.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/divgrad22.F	(revision 1644)
@@ -0,0 +1,55 @@
+      SUBROUTINE divgrad2_mars (klevel,h, lh, divgra )
+c
+c  P. Le Van
+c
+c   ************************************************************
+c
+c                                lh
+c        calcul de  (div( grad ))   de h  .....
+c   ************************************************************
+c      h  et lh  sont des arguments  d'entree pour le s-prog
+c      divgra     est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissipn.h"
+
+      INTEGER klevel
+      REAL h( ip1jmp1,klevel ), divgra( ip1jmp1,klevel )
+c
+      REAL ghy(ip1jm,llm), ghx(ip1jmp1,llm)
+      REAL signe, nudivgrs
+
+      INTEGER  l,ij,iter,lh
+
+      EXTERNAL  filtreg
+      EXTERNAL  SCOPY, grad, covcont, diverg, divergst
+
+
+      signe    = (-1.)**lh
+      nudivgrs = signe * cdivh
+
+      CALL SCOPY ( ip1jmp1*klevel,h,1,divgra,1 )
+
+      DO 2 iter = 1, lh -1
+      CALL grad (klevel,divgra, ghx  , ghy          )
+      CALL divergst (klevel,  ghx , ghy  , divgra       )
+   2  CONTINUE
+
+      CALL filtreg (divgra,jjp1,klevel,2,1,.true.,1)
+      CALL grad  (klevel,divgra, ghx, ghy      )
+      CALL covcont (klevel,ghx   , ghy, ghx ,ghy )
+      CALL diverg  (klevel,ghx   , ghy,divgra    )
+
+      CALL filtreg ( divgra,jjp1,klevel,2,1,.true.,1)
+
+      DO 5 l = 1,klevel
+      DO 4  ij = 1, ip1jmp1
+      divgra( ij,l ) = nudivgrs * divgra( ij,l )
+   4  CONTINUE
+   5  CONTINUE
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/dteta1.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/dteta1.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/dteta1.F	(revision 1644)
@@ -0,0 +1,66 @@
+      SUBROUTINE dteta1 ( teta, pbaru, pbarv, dteta)
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van
+c   -------
+c Modif F.Forget 03/94 (on retire q et dq  pour construire dteta1)
+c
+c   ********************************************************************
+c   ... calcul du terme de convergence horizontale du flux d'enthalpie
+c        potentielle   ......
+c   ********************************************************************
+c  .. teta,pbaru et pbarv sont des arguments d'entree  pour le s-pg ....
+c     dteta 	          sont des arguments de sortie pour le s-pg ....
+c
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+
+      REAL teta( ip1jmp1,llm ),pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL dteta( ip1jmp1,llm )
+      INTEGER   l,ij
+
+      REAL hbyv( ip1jm,llm ), hbxu( ip1jmp1,llm )
+
+      EXTERNAL     convflu
+      EXTERNAL     filtreg
+c
+
+      DO 5 l = 1,llm
+
+      DO 1  ij = iip2, ip1jm - 1
+      hbxu(ij,l) = pbaru(ij,l) * 0.5 * ( teta(ij,l) + teta(ij+1,l) )
+   1  CONTINUE
+
+c    .... correction pour  hbxu(iip1,j,l)  .....
+c    ....   hbxu(iip1,j,l)= hbxu(1,j,l) ....
+
+CDIR$ IVDEP
+      DO 2 ij = iip1+ iip1, ip1jm, iip1
+      hbxu( ij, l ) = hbxu( ij - iim, l )
+   2  CONTINUE
+
+
+      DO 3 ij = 1,ip1jm
+      hbyv(ij,l)= pbarv(ij, l)* 0.5 * ( teta(ij, l)+ teta(ij +iip1,l) )
+   3  CONTINUE
+
+   5  CONTINUE
+
+
+        CALL convflu ( hbxu, hbyv, llm, dteta )
+
+
+c    stockage dans  dh de la convergence horizont. filtree' du  flux
+c                  ....                           ...........
+c           d'enthalpie potentielle .
+
+      CALL filtreg( dteta, jjp1, llm, 2, 2, .true., 1)
+
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/dudv1.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/dudv1.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/dudv1.F	(revision 1644)
@@ -0,0 +1,50 @@
+      SUBROUTINE dudv1 ( vorpot, pbaru, pbarv, du, dv )
+      IMPLICIT NONE
+c
+c-----------------------------------------------------------------------
+c
+c   Auteur:   P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c   calcul du terme de  rotation
+c   ce terme est ajoute a  d(ucov)/dt et a d(vcov)/dt  ..
+c   vorpot, pbaru et pbarv sont des arguments d'entree  pour le s-pg ..
+c   du  et dv              sont des arguments de sortie pour le s-pg ..
+c
+c-----------------------------------------------------------------------
+
+#include "dimensions.h"
+#include "paramet.h"
+
+      REAL vorpot( ip1jm,llm ) ,pbaru( ip1jmp1,llm ) ,
+     *     pbarv( ip1jm,llm ) ,du( ip1jmp1,llm ) ,dv( ip1jm,llm )
+      INTEGER  l,ij
+c
+c
+      DO 10 l = 1,llm
+c
+      DO 2  ij = iip2, ip1jm - 1
+      du( ij,l ) = 0.125 *(  vorpot(ij-iip1, l) + vorpot( ij, l)  ) *
+     *                    (   pbarv(ij-iip1, l) + pbarv(ij-iim,  l) +
+     *                        pbarv(   ij  , l) + pbarv(ij+ 1 ,  l)   )
+   2  CONTINUE
+c
+      DO 3 ij = 1, ip1jm - 1
+      dv( ij+1,l ) = - 0.125 *(  vorpot(ij, l)  + vorpot(ij+1, l)  ) *
+     *                        (   pbaru(ij, l)  +  pbaru(ij+1   , l) +
+     *                       pbaru(ij+iip1, l)  +  pbaru(ij+iip2, l)  )
+   3  CONTINUE
+c
+c    .... correction  pour  dv( 1,j,l )  .....
+c    ....   dv(1,j,l)= dv(iip1,j,l) ....
+c
+CDIR$ IVDEP
+      DO 4 ij = 1, ip1jm, iip1
+      dv( ij,l ) = dv( ij + iim, l )
+   4  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/dudv2.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/dudv2.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/dudv2.F	(revision 1644)
@@ -0,0 +1,59 @@
+      SUBROUTINE dudv2 ( teta, pkf, bern, du, dv  )
+
+      IMPLICIT NONE
+c
+c=======================================================================
+c
+c   Auteur:  P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   *****************************************************************
+c   ..... calcul du terme de pression (gradient de p/densite )   et
+c          du terme de ( -gradient de la fonction de Bernouilli ) ...
+c   *****************************************************************
+c          Ces termes sont ajoutes a  d(ucov)/dt et a d(vcov)/dt  ..
+c
+c
+c    teta , pkf, bern  sont des arguments d'entree  pour le s-pg  ....
+c    du et dv          sont des arguments de sortie pour le s-pg  ....
+c
+c=======================================================================
+c
+#include "dimensions.h"
+#include "paramet.h"
+
+      REAL teta( ip1jmp1,llm ),pkf( ip1jmp1,llm ) ,bern( ip1jmp1,llm ),
+     *         du( ip1jmp1,llm ),  dv( ip1jm,llm )
+      INTEGER  l,ij
+c
+c
+      DO 5 l = 1,llm
+c
+      DO 2  ij  = iip2, ip1jm - 1
+       du(ij,l) = du(ij,l) + 0.5* ( teta( ij,l ) + teta( ij+1,l ) ) *
+     * ( pkf( ij,l ) - pkf(ij+1,l) )  + bern(ij,l) - bern(ij+1,l)
+   2  CONTINUE
+c
+c
+c    .....  correction  pour du(iip1,j,l),  j=2,jjm   ......
+c    ...          du(iip1,j,l) = du(1,j,l)                 ...
+c
+CDIR$ IVDEP
+      DO 3 ij = iip1+ iip1, ip1jm, iip1
+      du( ij,l ) = du( ij - iim,l )
+   3  CONTINUE
+c
+c
+      DO 4 ij  = 1,ip1jm
+      dv( ij,l) = dv(ij,l) + 0.5 * ( teta(ij,l) + teta( ij+iip1,l ) ) *
+     *                             ( pkf(ij+iip1,l) - pkf(  ij,l  ) )
+     *                           +   bern( ij+iip1,l ) - bern( ij  ,l )
+   4  CONTINUE
+c
+   5  CONTINUE
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/dump2d.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/dump2d.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/dump2d.F	(revision 1644)
@@ -0,0 +1,43 @@
+      SUBROUTINE dump2d(im,jm,z,nom_z)
+      IMPLICIT NONE
+      INTEGER im,jm
+      REAL z(im,jm)
+      CHARACTER (len=*) :: nom_z
+
+      INTEGER i,j,imin,illm,jmin,jllm
+      REAL zmin,zllm
+
+      PRINT*,nom_z
+
+      zmin=z(1,1)
+      zllm=z(1,1)
+      imin=1
+      illm=1
+      jmin=1
+      jllm=1
+
+      DO j=1,jm
+         DO i=1,im
+            IF(z(i,j).GT.zllm) THEN
+               illm=i
+               jllm=j
+               zllm=z(i,j)
+            ENDIF
+            IF(z(i,j).LT.zmin) THEN
+               imin=i
+               jmin=j
+               zmin=z(i,j)
+            ENDIF
+         ENDDO
+      ENDDO
+
+      PRINT*,'MIN: ',zmin
+      PRINT*,'MAX: ',zllm
+
+      IF(zllm.GT.zmin) THEN
+      DO j=1,jm
+      WRITE(*,'(72i1)') (NINT(10.*(z(i,j)-zmin)/(zllm-zmin)),i=1,im)
+      ENDDO
+      ENDIF
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/dynetat0.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/dynetat0.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/dynetat0.F	(revision 1644)
@@ -0,0 +1,435 @@
+      SUBROUTINE dynetat0(fichnom,vcov,ucov,
+     .                    teta,q,masse,ps,phis,time)
+      use infotrac, only: tname, nqtot
+      USE comvert_mod, ONLY: pa,preff
+      USE comconst_mod, ONLY: im,jm,lllm,daysec,dtvr,rad,omeg,g,cpp,
+     .			kappa
+      USE logic_mod, ONLY: fxyhypb,ysinus
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy,
+     .			taux,tauy
+      USE temps_mod, ONLY: day_ini
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van / L.Fairhead
+c   -------
+c
+c   objet:
+c   ------
+c
+c   Lecture de l'etat initial
+c
+c   Modifs: Oct.2008 read in tracers by name. Ehouarn Millour
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "netcdf.inc"
+!#include"advtrac.h"
+
+c   Arguments:
+c   ----------
+
+      CHARACTER*(*) fichnom
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm),teta(ip1jmp1,llm)
+      REAL q(iip1,jjp1,llm,nqtot),masse(ip1jmp1,llm)
+      REAL ps(ip1jmp1),phis(ip1jmp1)
+
+      REAL time
+
+c   Variables 
+c
+      INTEGER length,iq,i,j,l
+      PARAMETER (length = 100)
+      REAL tab_cntrl(length) ! tableau des parametres du run
+      INTEGER ierr, nid, nvarid, nqold
+      CHARACTER  str3*3,yes*1
+
+
+!     added by RW for test
+      real pmean,airetot
+      integer ij
+
+c-----------------------------------------------------------------------
+
+c  Ouverture NetCDF du fichier etat initial
+
+      ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
+      IF (ierr.NE.NF_NOERR) THEN
+        write(6,*)' Pb d''ouverture du fichier ',fichnom
+        CALL ABORT
+      ENDIF
+
+c
+      ierr = NF_INQ_VARID (nid, "controle", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <controle> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echoue pour <controle>"
+         CALL abort
+      ENDIF
+
+      im         = tab_cntrl(1)
+      jm         = tab_cntrl(2)
+      lllm       = tab_cntrl(3)
+      day_ini    = tab_cntrl(4)
+      rad        = tab_cntrl(5)
+      omeg       = tab_cntrl(6)
+      g          = tab_cntrl(7)
+      cpp        = tab_cntrl(8)
+      kappa      = tab_cntrl(9)
+      daysec     = tab_cntrl(10)
+      dtvr       = tab_cntrl(11)
+      etot0      = tab_cntrl(12)
+      ptot0      = tab_cntrl(13)
+      ztot0      = tab_cntrl(14)
+      stot0      = tab_cntrl(15)
+      ang0       = tab_cntrl(16)
+      pa         = tab_cntrl(17)
+      preff      = tab_cntrl(18)
+c
+      clon       = tab_cntrl(19)
+      clat       = tab_cntrl(20)
+      grossismx  = tab_cntrl(21)
+      grossismy  = tab_cntrl(22)
+c
+      IF ( tab_cntrl(23).EQ.1. )  THEN
+        fxyhypb  = . TRUE .
+        dzoomx   = tab_cntrl(24)
+        dzoomy   = tab_cntrl(25)
+        taux     = tab_cntrl(27)
+        tauy     = tab_cntrl(28)
+      ELSE
+        fxyhypb = . FALSE .
+        ysinus  = . FALSE .
+        IF( tab_cntrl(26).EQ.1. ) ysinus = . TRUE. 
+      ENDIF
+c   .................................................................
+c
+c
+      PRINT*,'dynetat0: rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa
+ 
+      IF(   im.ne.iim           )  THEN
+          PRINT 1,im,iim
+          STOP
+      ELSE  IF( jm.ne.jjm       )  THEN
+          PRINT 2,jm,jjm
+          STOP
+      ELSE  IF( lllm.ne.llm     )  THEN
+          PRINT 3,lllm,llm
+          STOP
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlonu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlonu> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonu)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonu)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <rlonu>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlatu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlatu> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatu)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatu)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <rlatu>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlonv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlonv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonv)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonv)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <rlonv>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "rlatv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <rlatv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatv)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatv)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour rlatv"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "cu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <cu> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, cu)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, cu)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <cu>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "cv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <cv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, cv)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, cv)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <cv>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "aire", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <aire> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, aire)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, aire)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <aire>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "phisinit", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <phisinit> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, phis)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, phis)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <phisinit>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "Time", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+	     ierr = NF_INQ_VARID (nid, "temps", nvarid)
+		 IF (ierr .NE. NF_NOERR) THEN
+           PRINT*, "dynetat0: <Time> or <temps> absent"
+           CALL abort
+         ENDIF
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, time)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, time)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee <Time>/<temps>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "ucov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <ucov> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ucov)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, ucov)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <ucov>"
+         CALL abort
+      ENDIF
+ 
+      ierr = NF_INQ_VARID (nid, "vcov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <vcov> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, vcov)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, vcov)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <vcov>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "teta", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <teta> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, teta)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, teta)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <teta>"
+         CALL abort
+      ENDIF
+
+
+      IF(nqtot.GE.1) THEN
+        write(*,*) 'dynetat0: loading tracers'
+         IF(nqtot.GT.99) THEN
+            PRINT*, "Trop de traceurs"
+            CALL abort
+         ENDIF
+         nqold=nqtot
+         DO iq=1,nqtot
+!           str3(1:1)='q'
+!           WRITE(str3(2:3),'(i2.2)') iq
+!           ierr =  NF_INQ_VARID (nid, str3, nvarid)
+! NB: tracers are now read in using their name ('tname' from infotrac)
+!           write(*,*) "  loading tracer:",trim(tname(iq))
+           ierr=NF_INQ_VARID(nid,tname(iq),nvarid)
+           IF (ierr .NE. NF_NOERR) THEN
+!              PRINT*, "dynetat0: Le champ <"//str3//"> est absent"
+              PRINT*, "dynetat0: Le champ <"//trim(tname(iq))//
+     &                "> est absent"
+              PRINT*, "          Il est donc initialise a zero"
+              CALL initial0(ijp1llm,q(1,1,1,iq))
+              nqold=min(iq-1,nqold)
+           ELSE
+#ifdef NC_DOUBLE
+           ierr = NF_GET_VAR_DOUBLE(nid, nvarid, q(1,1,1,iq))
+#else
+           ierr = NF_GET_VAR_REAL(nid, nvarid, q(1,1,1,iq))
+#endif
+             IF (ierr .NE. NF_NOERR) THEN
+!                 PRINT*, "dynetat0: Lecture echouee pour "//str3
+               PRINT*,"dynetat0: Lecture echouee pour "//trim(tname(iq))
+               CALL abort
+             ENDIF
+           ENDIF
+         ENDDO
+         if ((nqold.lt.nqtot).and.(nqold.ge.1)) then   
+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 ', nqtot,'are new'
+             write(*,*)' and initialized to zero'
+             q(:,:,:,nqold+1:nqtot)=0.0
+!             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) ?'
+!             read(*,fmt='(a)') yes
+!            end do
+!            if (yes.eq.'y') then
+!              write(*,*) 'OK, let s reindex the tracers'
+!              do l=1,llm
+!                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)   
+!                    end do
+!                    do iq=nqmx-nqold,1,-1
+!                       q(i,j,l,iq)= 0.
+!                    end do
+!                  end do
+!                end do
+!              end do
+!            end if 
+         end if ! of if ((nqold.lt.nqtot).and.(nqold.ge.1))
+      ENDIF ! of IF(nqtot.GE.1)
+
+      ierr = NF_INQ_VARID (nid, "masse", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <masse> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, masse)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, masse)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <masse>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "ps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Le champ <ps> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, ps)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, ps)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "dynetat0: Lecture echouee pour <ps>"
+         CALL abort
+      ENDIF
+
+      ierr = NF_CLOSE(nid)
+
+       day_ini=day_ini+INT(time)
+       time=time-INT(time)
+
+  1   FORMAT(//10x,'la valeur de im =',i4,2x,'lue sur le fichier de dem
+     *arrage est differente de la valeur parametree iim =',i4//)
+   2  FORMAT(//10x,'la valeur de jm =',i4,2x,'lue sur le fichier de dem
+     *arrage est differente de la valeur parametree jjm =',i4//)
+   3  FORMAT(//10x,'la valeur de lmax =',i4,2x,'lue sur le fichier dema
+     *rrage est differente de la valeur parametree llm =',i4//)
+   4  FORMAT(//10x,'la valeur de dtrv =',i4,2x,'lue sur le fichier dema
+     *rrage est differente de la valeur  dtinteg =',i4//)
+
+
+
+
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/dynredem.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/dynredem.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/dynredem.F	(revision 1644)
@@ -0,0 +1,1105 @@
+      SUBROUTINE dynredem0(fichnom,idayref,phis)
+      use infotrac, only: tname,nqtot
+      USE comvert_mod, ONLY: ap,bp,aps,bps,pa,preff,presnivs,pseudoalt
+      USE comconst_mod, ONLY: daysec,dtvr,rad,omeg,g,cpp,kappa,pi
+      USE logic_mod, ONLY: fxyhypb,ysinus
+      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,
+     .			dzoomx,dzoomy,taux,tauy
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      IMPLICIT NONE
+c=======================================================================
+c Ecriture du fichier de redemarrage sous format NetCDF (initialisation)
+c=======================================================================
+c   Declarations:
+c   -------------
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "netcdf.inc"
+!#include "advtrac.h"
+c   Arguments:
+c   ----------
+      INTEGER*4 idayref
+      REAL phis(ip1jmp1)
+      CHARACTER*(*) fichnom
+
+c   Local:
+c   ------
+      INTEGER iq,l
+      CHARACTER str3*3
+      INTEGER length
+      PARAMETER (length = 100)
+      REAL tab_cntrl(length) ! tableau des parametres du run
+      INTEGER ierr
+      character*20 modname
+      character*80 abort_message
+      character(len=80) :: txt ! to store some text
+
+c   Variables locales pour NetCDF:
+c
+      INTEGER dims2(2), dims3(3), dims4(4)
+      INTEGER idim_index
+      INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv
+      INTEGER idim_llm, idim_llmp1
+      INTEGER idim_tim
+      INTEGER nid,nvarid
+
+      REAL zan0,zjulian,hours
+      REAL sigs(llm)
+      INTEGER yyears0,jjour0, mmois0
+      data yyears0 /1/
+      data jjour0 /1/
+      data mmois0 /1/
+      character*30 unites
+
+
+c-----------------------------------------------------------------------
+      modname='dynredem'
+      do l=1,llm
+         sigs(l)=float(l)
+      enddo
+
+      DO l=1,length
+       tab_cntrl(l) = 0.
+      ENDDO
+       tab_cntrl(1)  = FLOAT(iim)
+       tab_cntrl(2)  = FLOAT(jjm)
+       tab_cntrl(3)  = FLOAT(llm)
+       tab_cntrl(4)  = FLOAT(idayref)
+       tab_cntrl(5)  = rad
+       tab_cntrl(6)  = omeg
+       tab_cntrl(7)  = g
+       tab_cntrl(8)  = cpp
+       tab_cntrl(9) = kappa
+       tab_cntrl(10) = daysec
+       tab_cntrl(11) = dtvr
+       tab_cntrl(12) = etot0
+       tab_cntrl(13) = ptot0
+       tab_cntrl(14) = ztot0
+       tab_cntrl(15) = stot0
+       tab_cntrl(16) = ang0
+       tab_cntrl(17) = pa
+       tab_cntrl(18) = preff
+c
+c    .....    parametres  pour le zoom      ......   
+
+       tab_cntrl(19)  = clon
+       tab_cntrl(20)  = clat
+       tab_cntrl(21)  = grossismx
+       tab_cntrl(22)  = grossismy
+c
+      IF ( fxyhypb )   THEN
+       tab_cntrl(23) = 1.
+       tab_cntrl(24) = dzoomx
+       tab_cntrl(25) = dzoomy
+       tab_cntrl(26) = 0.
+       tab_cntrl(27) = taux
+       tab_cntrl(28) = tauy
+      ELSE
+       tab_cntrl(23) = 0.
+       tab_cntrl(24) = dzoomx
+       tab_cntrl(25) = dzoomy
+       tab_cntrl(26) = 0.
+       tab_cntrl(27) = 0.
+       tab_cntrl(28) = 0.
+       IF( ysinus )  tab_cntrl(26) = 1. 
+      ENDIF
+c
+c    .........................................................
+c
+c Creation du fichier:
+c
+      ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
+      IF (ierr.NE.NF_NOERR) THEN
+         WRITE(6,*)" Failed creating file "//fichnom
+         WRITE(6,*)' ierr = ', ierr
+         CALL ABORT
+      ENDIF
+c
+c Preciser quelques attributs globaux:
+c
+      ierr = NF_PUT_ATT_TEXT (nid,NF_GLOBAL,"title",18,
+     .                       "Dynamic start file")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title in file "//fichnom
+        call abort
+      endif
+c
+c Definir les dimensions du fichiers:
+c
+      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <index> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <rlonu> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <latitude> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <longitude> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <rlatv> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <altitude> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_DEF_DIM (nid, "interlayer", llmp1, idim_llmp1)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <interlayer> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_DEF_DIM (nid, "Time", NF_UNLIMITED, idim_tim)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining dimension <Time> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+
+c     CHAMPS AJOUTES POUR LA VISUALISATION T,ps, etc... avec Grads ou ferret:
+c     ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu)
+c     ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv)
+c     ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm)
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+
+c
+c Definir et enregistrer certains champs invariants:
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"controle",NF_DOUBLE,1,idim_index,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"controle",NF_FLOAT,1,idim_index,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <controle> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Parametres de controle")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <controle> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <controle> ",
+     &             "in file "//fichnom
+        call abort
+!      else
+!       write(*,*) "dynredem0: controle(1)=",tab_cntrl(1)
+      endif
+
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <rlonu> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points U")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <rlonu> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <rlonu> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <rlatu> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points U")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <rlatu> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <rlatu> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <rlonv> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points V")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <rlonv> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <rlonv> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <rlatv> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points V")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <rlatv> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <rlatv> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_llmp1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_llmp1,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <ap> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 30,
+     .          "Coef A: hybrid pressure levels"  )
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <ap> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <ap> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_llmp1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_llmp1,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <bp> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 27,
+     .      "Coef B: hybrid sigma levels")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <bp> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bp)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <bp> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c
+c ----------------------
+c
+!      ierr = NF_REDEF (nid)
+!      if (ierr.ne.NF_NOERR) then
+!        write(*,*) "dynredem0: Failed to switch back to define mode"
+!        call abort
+!      endif
+!#ifdef NC_DOUBLE
+!      ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_llmp1,nvarid)
+!#else
+!      ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_llmp1,nvarid)
+!#endif
+!      if (ierr.ne.NF_NOERR) then
+!        write(*,*) "dynredem0: Failed defining <ap> ",
+!     &             "in file "//fichnom
+!        call abort
+!      endif
+!
+!      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 30,
+!     .          "Coef A: hybrid pressure levels"  )
+!      if (ierr.ne.NF_NOERR) then
+!        write(*,*) "dynredem0: Failed writing title attribute ",
+!     &             "for <ap> in file "//fichnom
+!
+!      ierr = NF_ENDDEF(nid)
+!      if (ierr.ne.NF_NOERR) then
+!        write(*,*) "dynredem0: Failed to switch out of define mode"
+!        call abort
+!      endif
+!#ifdef NC_DOUBLE
+!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
+!#else
+!      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
+!#endif
+!      if (ierr.ne.NF_NOERR) then
+!        write(*,*) "dynredem0: Failed writing <bp> ",
+!     &             "in file "//fichnom
+!        call abort
+!      endif
+c
+c ----------------------
+c
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"aps",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"aps",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <aps> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 37,
+     .      "Coef AS: hybrid pressure at midlayers")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <aps> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aps)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <aps> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"bps",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"bps",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <bps> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 34,
+     .      "Coef BS: hybrid sigma at midlayers")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute ",
+     &             "for <bps> in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bps)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <bps> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c
+c ----------------------
+c
+      ierr = NF_REDEF (nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <presniv> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_ENDDEF(nid)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch out of define mode"
+        call abort
+      endif
+
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,presnivs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,presnivs)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing <presniv> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+c ------------------------------------------------------------------
+c ------------------------------------------------------------------
+c  Variable uniquement pour visualisation avec Grads ou Ferret
+c ------------------------------------------------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"latitude",NF_DOUBLE,1,idim_rlatu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"latitude",NF_FLOAT,1,idim_rlatu,nvarid)
+#endif
+      ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "North latitude")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
+#endif
+c ----------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "East longitude")
+      ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
+#endif
+c --------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1,
+     .       idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1,
+     .       idim_llm,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",10,"pseudo-alt")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up")
+  
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt)
+#endif
+  
+  
+c ----------------------
+c ----------------------
+c
+c Coefficients de passage cov. <-> contra. <--> naturel
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonu
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cu",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cu",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
+#endif
+c
+c ----------------------
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatv
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cv",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cv",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
+#endif
+c
+c ----------------------
+c Aire de chaque maille:
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"aire",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"aire",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Aires de chaque maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
+#endif
+c
+c ----------------------
+c Geopentiel au sol:
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
+     .                       "Geopotentiel au sol")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,phis)
+#endif
+c
+c ----------------------
+c Definir les variables pour pouvoir les enregistrer plus tard:
+c
+      ierr = NF_REDEF (nid) ! entrer dans le mode de definition
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed to switch back to define mode"
+        call abort
+      endif
+
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"Time",NF_DOUBLE,1,idim_tim,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"Time",NF_FLOAT,1,idim_tim,nvarid)
+#endif
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed defining <Time> ",
+     &             "in file "//fichnom
+        call abort
+      endif
+
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
+     &                       "Temps de simulation")
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing title attribute",
+     &             "for <Time> in file "//fichnom
+        call abort
+      endif
+
+
+      write(unites,200)yyears0,mmois0,jjour0
+200   format('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "units", 30,
+     .                         unites)
+      if (ierr.ne.NF_NOERR) then
+        write(*,*) "dynredem0: Failed writing units attribute",
+     &             "for <Time> in file "//fichnom
+        call abort
+      endif
+
+
+c
+      dims4(1) = idim_rlonu
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_llm
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ucov",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ucov",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
+     .                       "Vitesse U")
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatv
+      dims4(3) = idim_llm
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"vcov",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"vcov",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
+     .                       "Vitesse V")
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_llm
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"teta",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"teta",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 11,
+     .                       "Temperature")
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_llm
+      dims4(4) = idim_tim
+      IF(nqtot.GE.1) THEN
+         DO iq=1,nqtot
+            IF (iq.GT.99) THEN
+               PRINT*, "Trop de traceurs"
+               CALL abort
+            ELSE
+!               str3(1:1)='q'
+!               WRITE(str3(2:3),'(i2.2)') iq
+!#ifdef NC_DOUBLE
+!               ierr = NF_DEF_VAR (nid,str3,NF_DOUBLE,4,dims4,nvarid)
+!#else
+!               ierr = NF_DEF_VAR (nid,str3,NF_FLOAT,4,dims4,nvarid)
+!#endif
+!               ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12,
+!     .                          "Traceurs "//str3)
+             txt="Traceur "//trim(tname(iq))
+#ifdef NC_DOUBLE
+               ierr=NF_DEF_VAR(nid,tname(iq),NF_DOUBLE,4,dims4,nvarid)
+#else
+               ierr=NF_DEF_VAR(nid,tname(iq),NF_FLOAT,4,dims4,nvarid)
+#endif
+               ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title",
+     .                  len_trim(txt),trim(txt))
+            ENDIF
+         ENDDO
+      ENDIF
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_llm
+      dims4(4) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"masse",NF_DOUBLE,4,dims4,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"masse",NF_FLOAT,4,dims4,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 12,
+     .                       "C est quoi ?")
+c
+      dims3(1) = idim_rlonv
+      dims3(2) = idim_rlatu
+      dims3(3) = idim_tim
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ps",NF_DOUBLE,3,dims3,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ps",NF_FLOAT,3,dims3,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 15,
+     .                       "Pression au sol")
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+      ierr = NF_CLOSE(nid) ! fermer le fichier
+
+      write(*,*)'dynredem0: iim,jjm,llm,idayref',iim,jjm,llm,idayref
+      write(*,*)'dynredem0: rad,omeg,g,cpp,kappa',
+     &        rad,omeg,g,cpp,kappa
+      
+!      stop "dynredem0 halt"
+      
+      RETURN
+      END
+
+c ================================================================
+c ================================================================
+
+      SUBROUTINE dynredem1(fichnom,time,
+     .                     vcov,ucov,teta,q,masse,ps)
+      use infotrac, only: nqtot, tname
+      IMPLICIT NONE
+c=================================================================
+c  Ecriture du fichier de redemarrage sous format NetCDF
+c=================================================================
+#include "dimensions.h"
+#include "paramet.h"
+#include "netcdf.inc"
+#include "comgeom.h"
+!#include"advtrac.h"
+
+      INTEGER l
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) 
+      REAL teta(ip1jmp1,llm)                   
+      REAL ps(ip1jmp1),masse(ip1jmp1,llm)                   
+      REAL q(iip1,jjp1,llm,nqtot)
+      REAL q3d(iip1,jjp1,llm) !temporary variable
+      CHARACTER*(*) fichnom
+     
+      REAL time
+      INTEGER nid, nvarid
+      INTEGER ierr
+      INTEGER iq
+      CHARACTER str3*3
+      character*20 modname
+      character*80 abort_message
+c
+      INTEGER nb,i,j
+      SAVE nb
+      DATA nb / 0 /
+
+      modname = 'dynredem1'
+      ierr = NF_OPEN(fichnom, NF_WRITE, nid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Pb. d ouverture "//fichnom
+         CALL abort
+      ENDIF
+
+c  Ecriture/extension de la coordonnee temps
+
+      nb = nb + 1
+      ierr = NF_INQ_VARID(nid, "Time", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         print *, NF_STRERROR(ierr)
+         abort_message='Variable Time n est pas definie'
+         CALL abort_gcm(modname,abort_message,ierr)
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR1_DOUBLE (nid,nvarid,nb,time)
+#else
+      ierr = NF_PUT_VAR1_REAL (nid,nvarid,nb,time)
+#endif
+      PRINT*, "Enregistrement pour ", nb, time
+
+c  Ecriture des champs
+c
+      ierr = NF_INQ_VARID(nid, "ucov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable ucov n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ucov)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ucov)
+#endif
+
+      ierr = NF_INQ_VARID(nid, "vcov", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable vcov n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,vcov)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,vcov)
+#endif
+
+      ierr = NF_INQ_VARID(nid, "teta", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable teta n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,teta)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,teta)
+#endif
+
+      IF (nqtot.GT.99) THEN
+         PRINT*, "Trop de traceurs"
+         CALL abort
+      ENDIF
+      IF(nqtot.GE.1) THEN
+         DO iq=1,nqtot
+!            str3(1:1)='q'
+!            WRITE(str3(2:3),'(i2.2)') iq
+!            ierr = NF_INQ_VARID(nid, str3, nvarid)
+            ierr=NF_INQ_VARID(nid,tname(iq),nvarid)
+            IF (ierr .NE. NF_NOERR) THEN
+!               PRINT*, "Variable "//str3//" n est pas definie"
+              PRINT*,"Variable "//trim(tname(iq))//" n est pas definie"
+              CALL abort
+            ENDIF
+            do l=1,llm
+               do j=1,jjp1
+                  do i=1,iip1
+                     q3d(i,j,l)=q(i,j,l,iq)
+                  enddo
+               enddo
+            enddo
+#ifdef NC_DOUBLE
+            ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,q3d)
+#else
+            ierr = NF_PUT_VAR_REAL (nid,nvarid,q3d)
+#endif
+            IF (ierr .NE. NF_NOERR) THEN
+               PRINT*, "Error: ", NF_STRERROR(ierr)
+               CALL abort
+            ENDIF
+         ENDDO
+      ENDIF
+c
+      ierr = NF_INQ_VARID(nid, "masse", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable masse n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,masse)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,masse)
+#endif
+c
+      ierr = NF_INQ_VARID(nid, "ps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Variable ps n est pas definie"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ps)
+#endif
+
+      ierr = NF_CLOSE(nid)
+c
+      RETURN
+      END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/ener_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/ener_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/ener_mod.F90	(revision 1644)
@@ -0,0 +1,12 @@
+MODULE ener_mod
+
+IMPLICIT NONE  
+
+include "dimensions.h"
+include "paramet.h"
+
+      REAL ang0,etot0,ptot0,ztot0,stot0,			&
+		ang,etot,ptot,ztot,stot,rmsdpdt,rmsv,gtot(llmm1)
+
+
+END MODULE ener_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/enercin.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/enercin.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/enercin.F	(revision 1644)
@@ -0,0 +1,96 @@
+      SUBROUTINE enercin ( vcov, ucov, vcont, ucont, ecin )
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur: P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c *********************************************************************
+c .. calcul de l'energie cinetique aux niveaux s  ......
+c *********************************************************************
+c  vcov, vcont, ucov et ucont sont des arguments d'entree pour le s-pg .
+c  ecin         est  un  argument de sortie pour le s-pg
+c
+c=======================================================================
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      REAL vcov( ip1jm,llm ),vcont( ip1jm,llm ),
+     * ucov( ip1jmp1,llm ),ucont( ip1jmp1,llm ),ecin( ip1jmp1,llm )
+
+      REAL ecinni( iip1 ),ecinsi( iip1 )
+
+      REAL ecinpn, ecinps
+      INTEGER     l,ij,i
+
+      EXTERNAL    SSUM
+      REAL        SSUM
+
+
+
+c                 . V
+c                i,j-1
+
+c      alpha4 .       . alpha1
+
+
+c        U .      . P     . U
+c       i-1,j    i,j      i,j
+
+c      alpha3 .       . alpha2
+
+
+c                 . V
+c                i,j
+
+c    
+c  L'energie cinetique au point scalaire P(i,j) ,autre que les poles, est :
+c       Ecin = 0.5 * U(i-1,j)**2 *( alpha3 + alpha4 )  +
+c              0.5 * U(i  ,j)**2 *( alpha1 + alpha2 )  +
+c              0.5 * V(i,j-1)**2 *( alpha1 + alpha4 )  +
+c              0.5 * V(i,  j)**2 *( alpha2 + alpha3 )
+
+
+      DO 5 l = 1,llm
+
+      DO 1  ij = iip2, ip1jm -1
+      ecin( ij+1, l )  =    0.5  *
+     * (   ucov( ij   ,l ) * ucont( ij   ,l ) * alpha3p4( ij +1 )   +
+     *     ucov( ij+1 ,l ) * ucont( ij+1 ,l ) * alpha1p2( ij +1 )   +
+     *     vcov(ij-iim,l ) * vcont(ij-iim,l ) * alpha1p4( ij +1 )   +
+     *     vcov( ij+ 1,l ) * vcont( ij+ 1,l ) * alpha2p3( ij +1 )   )
+   1  CONTINUE
+
+c    ... correction pour  ecin(1,j,l)  ....
+c    ...   ecin(1,j,l)= ecin(iip1,j,l) ...
+
+CDIR$ IVDEP
+      DO 2 ij = iip2, ip1jm, iip1
+      ecin( ij,l ) = ecin( ij + iim, l )
+   2  CONTINUE
+
+c     calcul aux poles  .......
+
+
+      DO 3 i = 1, iim
+      ecinni(i) = vcov(    i  ,  l) * vcont(    i    ,l) * aire(   i   )
+      ecinsi(i) = vcov(i+ip1jmi1,l) * vcont(i+ip1jmi1,l) * aire(i+ip1jm)
+   3  CONTINUE
+
+      ecinpn = 0.5 * SSUM( iim,ecinni,1 ) / apoln
+      ecinps = 0.5 * SSUM( iim,ecinsi,1 ) / apols
+
+      DO 4 ij = 1,iip1
+      ecin(   ij     , l ) = ecinpn
+      ecin( ij+ ip1jm, l ) = ecinps
+   4  CONTINUE
+
+   5  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/exner.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/exner.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/exner.F	(revision 1644)
@@ -0,0 +1,30 @@
+      SUBROUTINE exner(ngrid,pext,aire,pks,pksf)
+
+      USE comconst_mod, ONLY: kappa,jmp1
+
+      IMPLICIT NONE
+
+c      .........    Version du 16/04/96     .........
+c
+c-----------------------------------------------------------------------
+c   declarations:
+c   -------------
+
+      INTEGER ngrid
+      REAL pext(ngrid),aire(ngrid),pks(ngrid),pksf(ngrid)
+
+      INTEGER ig,iii
+
+      EXTERNAL filtreg
+
+c-----------------------------------------------------------------------
+
+      DO 3 ig = 1,ngrid
+         pks( ig )     = ( pext( ig )/ aire( ig ) ) ** kappa
+         pksf( ig )    = pks( ig )
+   3  CONTINUE
+
+      CALL filtreg (pksf,jmp1,1,2,1,.true.,1)
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/exner_hyb.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/exner_hyb.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/exner_hyb.F	(revision 1644)
@@ -0,0 +1,102 @@
+      SUBROUTINE  exner_hyb ( ngrid, ps, p,beta, pks, pk, pkf )
+c
+c     Auteurs :  F. Forget , Y. Wanherdrick
+c P.Le Van  , Fr. Hourdin  .
+c    ..........
+c
+c    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
+c    .... beta, pks,pk,pkf   sont des argum.de sortie au sous-prog ...
+c
+c   ************************************************************************
+c    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des 
+c    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
+c    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
+c   ************************************************************************
+c    .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
+c    la pression et la fonction d'Exner  au  sol  .
+c
+c     WARNING : CECI est une version speciale de exner_hyb originale
+c               Utilis dans la version martienne pour pouvoir 
+c               tourner avec des coordonnes verticales complexe
+c              => Il ne verifie PAS la condition la proportionalit en 
+c              nergie totale/ interne / potentielle (F.Forget 2001)
+c    ( voir note de Fr.Hourdin )  ,
+c
+      USE comvert_mod, ONLY: preff
+      USE comconst_mod, ONLY: jmp1,kappa,cpp
+
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      INTEGER  ngrid
+      REAL p(ngrid,llmp1),pk(ngrid,llm),pkf(ngrid,llm)
+      REAL ps(ngrid),pks(ngrid), beta(ngrid,llm)
+
+c    .... variables locales   ...
+
+      INTEGER l, ij
+      REAL dum1
+
+      REAL ppn(iim),pps(iim)
+      REAL xpn, xps
+      REAL SSUM
+      EXTERNAL filtreg, SSUM
+      
+c     -------------
+c     Calcul de pks
+c     -------------
+   
+      DO   ij  = 1, ngrid
+        pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
+      ENDDO
+
+      DO  ij   = 1, iim
+        ppn(ij) = aire(   ij   ) * pks(  ij     )
+        pps(ij) = aire(ij+ip1jm) * pks(ij+ip1jm )
+      ENDDO
+      xpn      = SSUM(iim,ppn,1) /apoln
+      xps      = SSUM(iim,pps,1) /apols
+
+      DO ij   = 1, iip1
+        pks(   ij     )  =  xpn
+        pks( ij+ip1jm )  =  xps
+      ENDDO
+c
+c
+c    .... Calcul de pk  pour la couche l 
+c    --------------------------------------------
+c
+      dum1 = cpp * (2*preff)**(-kappa) 
+      DO l = 1, llm-1
+        DO   ij   = 1, ngrid
+         pk(ij,l) = dum1 * (p(ij,l) + p(ij,l+1))**kappa
+        ENDDO
+      ENDDO
+
+c    .... Calcul de pk  pour la couche l = llm ..
+c    (on met la meme distance (en log pression)  entre Pk(llm)
+c    et Pk(llm -1) qu'entre Pk(llm-1) et Pk(llm-2)
+
+      DO   ij   = 1, ngrid
+         pk(ij,llm) = pk(ij,llm-1)**2 / pk(ij,llm-2)
+      ENDDO
+
+
+c    calcul de pkf
+c    -------------
+      CALL SCOPY   ( ngrid * llm, pk, 1, pkf, 1 )
+      CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 )
+      
+c    EST-CE UTILE ?? : calcul de beta
+c    --------------------------------
+      DO l = 2, llm
+        DO   ij   = 1, ngrid
+          beta(ij,l) = pk(ij,l) / pk(ij,l-1)   
+        ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/flumass.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/flumass.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/flumass.F	(revision 1644)
@@ -0,0 +1,107 @@
+      SUBROUTINE flumass (massebx,masseby, vcont, ucont, pbaru, pbarv )
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteurs:  P. Le Van, F. Hourdin  .
+c   -------
+c
+c   Objet:
+c   ------
+c
+c *********************************************************************
+c     .... calcul du flux de masse  aux niveaux s ......
+c *********************************************************************
+c   massebx,masseby,vcont et ucont sont des argum. d'entree pour le s-pg .
+c       pbaru  et pbarv            sont des argum.de sortie pour le s-pg .
+c
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      REAL massebx( ip1jmp1,llm ),masseby( ip1jm,llm ) ,
+     * vcont( ip1jm,llm ),ucont( ip1jmp1,llm ),pbaru( ip1jmp1,llm ),
+     * pbarv( ip1jm,llm )
+
+      REAL apbarun( iip1 ),apbarus( iip1 )
+
+      REAL sairen,saireun,saires,saireus,ctn,cts,ctn0,cts0
+      INTEGER  l,ij,i
+
+      EXTERNAL   SSUM
+      REAL       SSUM
+
+
+      DO  5 l = 1,llm
+
+      DO  1 ij = iip2,ip1jm
+      pbaru( ij,l ) = massebx( ij,l ) * ucont( ij,l )
+   1  CONTINUE
+
+      DO 3 ij = 1,ip1jm
+      pbarv( ij,l ) = masseby( ij,l ) * vcont( ij,l )
+   3  CONTINUE
+
+   5  CONTINUE
+
+c    ................................................................
+c     calcul de la composante du flux de masse en x aux poles .......
+c    ................................................................
+c     par la resolution d'1 systeme de 2 equations .
+
+c     la premiere equat.decrivant le calcul de la divergence en 1 point i
+c     du pole,ce calcul etant itere de i=1 a i=im .
+c                 c.a.d   ,
+c     ( ( 0.5*pbaru(i)-0.5*pbaru(i-1) - pbarv(i))/aire(i)   =
+c                                           - somme de ( pbarv(n) )/aire pole
+
+c     l'autre equat.specifiant que la moyenne du flux de masse au pole est =0.
+c     c.a.d    somme de pbaru(n)*aire locale(n) = 0.
+
+c     on en revient ainsi a determiner la constante additive commune aux pbaru
+c     qui representait pbaru(0,j,l) dans l'equat.du calcul de la diverg.au pt
+c     i=1 .
+c     i variant de 1 a im
+c     n variant de 1 a im
+
+      sairen = SSUM( iim,  aire(   1     ), 1 )
+      saireun= SSUM( iim, aireu(   1     ), 1 )
+      saires = SSUM( iim,  aire( ip1jm+1 ), 1 )
+      saireus= SSUM( iim, aireu( ip1jm+1 ), 1 )
+
+      DO 20 l = 1,llm
+
+      ctn =  SSUM( iim, pbarv(    1     ,l),  1 )/ sairen
+      cts =  SSUM( iim, pbarv(ip1jmi1+ 1,l),  1 )/ saires
+
+      pbaru(    1   ,l )=   pbarv(    1     ,l ) - ctn * aire(    1    )
+      pbaru( ip1jm+1,l )= - pbarv( ip1jmi1+1,l ) + cts * aire( ip1jm+1 )
+
+      DO 11 i = 2,iim
+      pbaru(    i    ,l ) = pbaru(   i - 1   ,l )    +
+     *                      pbarv(    i      ,l ) - ctn * aire(   i    )
+
+      pbaru( i+ ip1jm,l ) = pbaru( i+ ip1jm-1,l )    -
+     *                      pbarv( i+ ip1jmi1,l ) + cts * aire(i+ ip1jm)
+  11  CONTINUE
+      DO 12 i = 1,iim
+      apbarun(i) = aireu(    i   ) * pbaru(   i    , l)
+      apbarus(i) = aireu(i +ip1jm) * pbaru(i +ip1jm, l)
+  12  CONTINUE
+      ctn0 = -SSUM( iim,apbarun,1 )/saireun
+      cts0 = -SSUM( iim,apbarus,1 )/saireus
+      DO 14 i = 1,iim
+      pbaru(   i    , l) = 2. * ( pbaru(   i    , l) + ctn0 )
+      pbaru(i+ ip1jm, l) = 2. * ( pbaru(i +ip1jm, l) + cts0 )
+  14  CONTINUE
+
+      pbaru(   iip1 ,l ) = pbaru(    1    ,l )
+      pbaru( ip1jmp1,l ) = pbaru( ip1jm +1,l )
+  20  CONTINUE
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/fluxstoke.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/fluxstoke.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/fluxstoke.F	(revision 1644)
@@ -0,0 +1,150 @@
+      SUBROUTINE fluxstoke(pbaru,pbarv,masse,teta,phi,phis)
+c
+c     Auteur :  F. Hourdin
+c
+c
+ccc   ..   Modif. P. Le Van  ( 20/12/97 )  ...
+c
+      USE comvert_mod, ONLY: presnivs
+      USE comconst_mod, ONLY: dtvr,pi
+
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "tracstoke.h"
+
+
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
+      REAL masse(ip1jmp1,llm),teta(ip1jmp1,llm),phi(ip1jmp1,llm)
+      REAL phis(ip1jmp1)
+
+      REAL pbaruc(ip1jmp1,llm),pbarvc(ip1jm,llm)
+      REAL massem(ip1jmp1,llm),tetac(ip1jmp1,llm),phic(ip1jmp1,llm)
+
+      REAL pbarug(ip1jmp1,llm),pbarvg(iip1,jjm,llm),wg(ip1jmp1,llm)
+
+      REAL pbarvst(iip1,jjp1,llm)
+
+
+      INTEGER iadvtr 
+      INTEGER ij,l,irec,i,j
+ 
+      SAVE iadvtr, massem,pbaruc,pbarvc,irec
+      SAVE phic,tetac
+      logical first
+      save first
+      data first/.true./
+      DATA iadvtr/0/
+
+      if(first) then
+#ifdef CRAY
+         CALL ASSIGN("assign -N ieee -F null f:fluxmass")
+#endif
+         open(47,file='fluxmass',form='unformatted',
+     s        access='direct',recl=4*(6*ijp1llm))
+         irec=1
+         first=.false.
+
+         open(77,file='fluxmass.ctl',status='unknown',form='formatted')
+
+      endif
+
+
+      IF(iadvtr.EQ.0) THEN
+         CALL initial0(ijp1llm,phic)
+         CALL initial0(ijp1llm,tetac)
+         CALL initial0(ijp1llm,pbaruc)
+         CALL initial0(ijmllm,pbarvc)
+      ENDIF
+
+c   accumulation des flux de masse horizontaux
+      DO l=1,llm
+         DO ij = 1,ip1jmp1
+            pbaruc(ij,l) = pbaruc(ij,l) + pbaru(ij,l)
+            tetac(ij,l) = tetac(ij,l) + teta(ij,l)
+            phic(ij,l) = phic(ij,l) + phi(ij,l)
+         ENDDO
+         DO ij = 1,ip1jm
+            pbarvc(ij,l) = pbarvc(ij,l) + pbarv(ij,l)
+         ENDDO
+      ENDDO
+
+c   selection de la masse instantannee des mailles avant le transport.
+      IF(iadvtr.EQ.0) THEN
+         CALL SCOPY(ip1jmp1*llm,masse,1,massem,1)
+      ENDIF
+
+      iadvtr   = iadvtr+1
+
+
+c   Test pour savoir si on advecte a ce pas de temps
+      IF ( iadvtr.EQ.istdyn ) THEN
+
+c    normalisation
+      DO l=1,llm
+         DO ij = 1,ip1jmp1
+            pbaruc(ij,l) = pbaruc(ij,l)/float(istdyn)
+            tetac(ij,l) = tetac(ij,l)/float(istdyn)
+            phic(ij,l) = phic(ij,l)/float(istdyn)
+         ENDDO
+         DO ij = 1,ip1jm
+            pbarvc(ij,l) = pbarvc(ij,l)/float(istdyn)
+         ENDDO
+      ENDDO
+
+c   traitement des flux de masse avant advection.
+c     1. calcul de w
+c     2. groupement des mailles pres du pole.
+
+        CALL groupe( massem, pbaruc,pbarvc, pbarug,pbarvg,wg )
+
+        do l=1,llm
+           do j=1,jjm
+              do i=1,iip1
+                 pbarvst(i,j,l)=pbarvg(i,j,l)
+              enddo
+           enddo
+           do i=1,iip1
+              pbarvst(i,jjp1,l)=0.
+           enddo
+        enddo
+
+         iadvtr=0
+
+         irec=irec+1
+         write(47,rec=1) float(irec),dtvr,float(istdyn),
+     s    float(iim),float(jjm),float(llm),rlonu,rlonv,rlatu,rlatv
+     s    ,aire,phis
+         write(47,rec=irec) massem,pbarug,pbarvst,wg,tetac,phic
+
+c   on reinitialise a zero les flux de masse cumules.
+
+      write(77,'(a4,2x,a40)')
+     &       'DSET ','^fluxmass'
+
+      write(77,'(a12)') 'UNDEF 1.0E30'
+      write(77,'(a5,1x,a40)') 'TITLE ','Titre a voir'
+      call formcoord(77,iip1,rlonv,180./pi,.false.,'XDEF')
+      call formcoord(77,jjp1,rlatu,180./pi,.true.,'YDEF')
+      call formcoord(77,llm,presnivs,1.,.false.,'ZDEF')
+      write(77,'(a4,i10,a30)')
+     &       'TDEF ',irec,' LINEAR 02JAN1987 1DY '
+      write(77,'(a4,2x,i5)') 'VARS',6
+      write(77,1000) 'masse',llm,99,'masse    '
+      write(77,1000) 'pbaru',llm,99,'pbaru    '
+      write(77,1000) 'pbarv',llm,99,'pbarv    '
+      write(77,1000) 'w    ',llm,99,'w        '
+      write(77,1000) 'teta ',llm,99,'teta     '
+      write(77,1000) 'phi  ',llm,99,'phi      '
+      write(77,'(a7)') 'ENDVARS'
+
+1000  format(a5,3x,i4,i3,1x,a39)
+
+
+
+      ENDIF ! if iadvtr.EQ.istdyn
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/fxhyp.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/fxhyp.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/fxhyp.F	(revision 1644)
@@ -0,0 +1,448 @@
+       SUBROUTINE fxhyp ( xzoomdeg,grossism,dzoom,tau ,
+     , rlonm025,xprimm025,rlonv,xprimv,rlonu,xprimu,rlonp025,xprimp025,
+     , champmin,champmax                                               )
+
+c      Auteur :  P. Le Van 
+
+       IMPLICIT NONE
+
+c    Calcule les longitudes et derivees dans la grille du GCM pour une
+c     fonction f(x) a tangente  hyperbolique  .
+c
+c     grossism etant le grossissement ( = 2 si 2 fois, = 3 si 3 fois,etc.)
+c     dzoom  etant  la distance totale de la zone du zoom
+c     tau  la raideur de la transition de l'interieur a l'exterieur du zoom
+c
+c    On doit avoir grossism x dzoom <  pi ( radians )   , en longitude.
+c   ********************************************************************
+
+
+       INTEGER nmax, nmax2
+       PARAMETER (  nmax = 30000, nmax2 = 2*nmax )
+c
+       LOGICAL scal180
+       PARAMETER ( scal180 = .TRUE. )
+
+c      scal180 = .TRUE.  si on veut avoir le premier point scalaire pour   
+c      une grille reguliere ( grossism = 1.,tau=0.,clon=0. ) a -180. degres.
+c      sinon scal180 = .FALSE.
+
+#include "dimensions.h"
+#include "paramet.h"
+       
+c     ......  arguments  d'entree   .......
+c
+       REAL xzoomdeg,dzoom,tau,grossism
+
+c    ......   arguments  de  sortie  ......
+
+       REAL rlonm025(iip1),xprimm025(iip1),rlonv(iip1),xprimv(iip1),
+     ,  rlonu(iip1),xprimu(iip1),rlonp025(iip1),xprimp025(iip1)
+
+c     .... variables locales  ....
+c
+       REAL*8 xlon(iip1),xprimm(iip1),xuv
+       REAL*8 xtild(0:nmax2)
+       REAL*8 fhyp(0:nmax2),ffdx,beta,Xprimt(0:nmax2)
+       REAL*8 Xf(0:nmax2),xxpr(0:nmax2)
+       REAL*8 xvrai(iip1),xxprim(iip1) 
+       REAL*8 pi,depi,epsilon,xzoom,fa,fb
+       REAL*8 Xf1, Xfi , a0,a1,a2,a3,xi2
+       INTEGER i,it,ik,iter,ii,idif,ii1,ii2
+       REAL*8 xi,xo1,xmoy,xlon2,fxm,Xprimin
+       REAL*8 champmin,champmax,decalx
+       INTEGER is2
+       SAVE is2
+
+       REAL*8 heavyside
+       EXTERNAL coefpoly,heavyside
+
+       pi       = 2. * ASIN(1.)
+       depi     = 2. * pi
+       epsilon  = 1.e-3
+       xzoom    = xzoomdeg * pi/180. 
+c
+           decalx   = .75
+       IF( grossism.EQ.1..AND.scal180 )  THEN
+           decalx   = 1.
+       ENDIF
+
+       WRITE(6,*) 'FXHYP scal180,decalx', scal180,decalx
+c
+       IF( dzoom.LT.1.)  THEN
+         dzoom = dzoom * depi
+       ELSEIF( dzoom.LT. 25. ) THEN
+         WRITE(6,*) ' Le param. dzoomy pour fxhyp est trop petit ! L aug
+     ,menter et relancer ! '
+         STOP 1
+       ELSE
+         dzoom = dzoom * pi/180.
+       ENDIF
+
+       WRITE(6,*) ' xzoom( rad.),grossism,tau,dzoom (radians)'
+       WRITE(6,24) xzoom,grossism,tau,dzoom
+
+       DO i = 0, nmax2 
+        xtild(i) = - pi + FLOAT(i) * depi /nmax2
+       ENDDO
+
+       DO i = nmax, nmax2
+
+       fa  = tau*  ( dzoom/2.  - xtild(i) )
+       fb  = xtild(i) *  ( pi - xtild(i) )
+
+         IF( 200.* fb .LT. - fa )   THEN
+           fhyp ( i) = - 1.
+         ELSEIF( 200. * fb .LT. fa ) THEN
+           fhyp ( i) =   1.
+         ELSE
+            IF( ABS(fa).LT.1.e-13.AND.ABS(fb).LT.1.e-13)  THEN
+                IF(   200.*fb + fa.LT.1.e-10 )  THEN
+                    fhyp ( i ) = - 1.
+                ELSEIF( 200.*fb - fa.LT.1.e-10 )  THEN
+                    fhyp ( i )  =   1.
+                ENDIF
+            ELSE
+                    fhyp ( i )  =  TANH ( fa/fb )
+            ENDIF
+         ENDIF
+
+        IF ( xtild(i).EQ. 0. )  fhyp(i) =  1.
+        IF ( xtild(i).EQ. pi )  fhyp(i) = -1.
+
+       ENDDO
+
+cc  ....  Calcul  de  beta  ....
+c   ............................
+
+       ffdx = 0.
+
+       DO i = nmax +1,nmax2
+
+       xmoy    = 0.5 * ( xtild(i-1) + xtild( i ) )
+       fa  = tau*  ( dzoom/2.  - xmoy )
+       fb  = xmoy *  ( pi - xmoy )
+
+       IF( 200.* fb .LT. - fa )   THEN
+         fxm = - 1.
+       ELSEIF( 200. * fb .LT. fa ) THEN
+         fxm =   1.
+       ELSE
+            IF( ABS(fa).LT.1.e-13.AND.ABS(fb).LT.1.e-13)  THEN
+                IF(   200.*fb + fa.LT.1.e-10 )  THEN
+                    fxm   = - 1.
+                ELSEIF( 200.*fb - fa.LT.1.e-10 )  THEN
+                    fxm   =   1.
+                ENDIF
+            ELSE
+                    fxm   =  TANH ( fa/fb )
+            ENDIF
+       ENDIF
+
+       IF ( xmoy.EQ. 0. )  fxm  =  1.
+       IF ( xmoy.EQ. pi )  fxm  = -1.
+
+       ffdx = ffdx + fxm * ( xtild(i) - xtild(i-1) )
+
+       ENDDO
+
+        beta  = ( grossism * ffdx - pi ) / ( ffdx - pi )
+
+       IF( 2.*beta - grossism.LE. 0.)  THEN
+        WRITE(6,*) ' **  Attention ! La valeur beta calculee dans la rou
+     ,tine fxhyp est mauvaise ! '
+        WRITE(6,*)'Modifier les valeurs de  grossismx ,tau ou dzoomx ',
+     , ' et relancer ! ***  '
+        CALL ABORT
+       ENDIF
+c
+c   .....  calcul  de  Xprimt   .....
+c
+       
+       DO i = nmax, nmax2
+        Xprimt(i) = beta  + ( grossism - beta ) * fhyp(i)
+       ENDDO
+c   
+       DO i =  nmax+1, nmax2
+        Xprimt( nmax2 - i ) = Xprimt( i )
+       ENDDO
+c
+
+c   .....  Calcul  de  Xf     ........
+
+       Xf(0) = - pi
+
+       DO i =  nmax +1, nmax2
+
+       xmoy    = 0.5 * ( xtild(i-1) + xtild( i ) )
+       fa  = tau*  ( dzoom/2.  - xmoy )
+       fb  = xmoy *  ( pi - xmoy )
+
+       IF( 200.* fb .LT. - fa )   THEN
+         fxm = - 1.
+       ELSEIF( 200. * fb .LT. fa ) THEN
+         fxm =   1.
+       ELSE
+         fxm =  TANH ( fa/fb )
+       ENDIF
+
+       IF ( xmoy.EQ. 0. )  fxm =  1.
+       IF ( xmoy.EQ. pi )  fxm = -1.
+       xxpr(i)    = beta + ( grossism - beta ) * fxm
+
+       ENDDO
+
+       DO i = nmax+1, nmax2
+        xxpr(nmax2-i+1) = xxpr(i)
+       ENDDO
+
+        DO i=1,nmax2
+         Xf(i)   = Xf(i-1) + xxpr(i) * ( xtild(i) - xtild(i-1) )
+        ENDDO
+
+
+c    *****************************************************************
+c
+
+c     .....  xuv = 0.   si  calcul  aux pts   scalaires   ........
+c     .....  xuv = 0.5  si  calcul  aux pts      U        ........
+c
+      WRITE(6,18)
+c
+      DO 5000  ik = 1, 4
+
+       IF( ik.EQ.1 )        THEN
+         xuv =  -0.25
+       ELSE IF ( ik.EQ.2 )  THEN
+         xuv =   0.
+       ELSE IF ( ik.EQ.3 )  THEN
+         xuv =   0.50
+       ELSE IF ( ik.EQ.4 )  THEN
+         xuv =   0.25
+       ENDIF
+
+      xo1   = 0.
+
+      ii1=1
+      ii2=iim
+      IF(ik.EQ.1.and.grossism.EQ.1.) THEN
+        ii1 = 2 
+        ii2 = iim+1
+      ENDIF
+
+      DO 1500 i = ii1, ii2
+
+      xlon2 = - pi + (FLOAT(i) + xuv - decalx) * depi / FLOAT(iim) 
+
+      Xfi    = xlon2
+c
+      DO 250 it =  nmax2,0,-1
+      IF( Xfi.GE.Xf(it))  GO TO 350
+250   CONTINUE
+
+      it = 0
+
+350   CONTINUE
+
+c    ......  Calcul de   Xf(xi)    ...... 
+c
+      xi  = xtild(it)
+
+      IF(it.EQ.nmax2)  THEN
+       it       = nmax2 -1
+       Xf(it+1) = pi
+      ENDIF
+c  .....................................................................
+c
+c   Appel de la routine qui calcule les coefficients a0,a1,a2,a3 d'un
+c   polynome de degre 3  qui passe  par les points (Xf(it),xtild(it) )
+c          et (Xf(it+1),xtild(it+1) )
+
+       CALL coefpoly ( Xf(it),Xf(it+1),Xprimt(it),Xprimt(it+1),
+     ,                xtild(it),xtild(it+1),  a0, a1, a2, a3  )
+
+       Xf1     = Xf(it)
+       Xprimin = a1 + 2.* a2 * xi + 3.*a3 * xi *xi
+
+       DO 500 iter = 1,300
+        xi = xi - ( Xf1 - Xfi )/ Xprimin
+
+        IF( ABS(xi-xo1).LE.epsilon)  GO TO 550
+         xo1      = xi
+         xi2      = xi * xi
+         Xf1      = a0 +  a1 * xi +     a2 * xi2  +     a3 * xi2 * xi
+         Xprimin  =       a1      + 2.* a2 *  xi  + 3.* a3 * xi2
+500   CONTINUE
+        WRITE(6,*) ' Pas de solution ***** ',i,xlon2,iter
+          STOP 6
+550   CONTINUE
+
+       xxprim(i) = depi/ ( FLOAT(iim) * Xprimin )
+       xvrai(i)  =  xi + xzoom
+
+1500   CONTINUE
+
+
+       IF(ik.EQ.1.and.grossism.EQ.1.)  THEN
+         xvrai(1)    = xvrai(iip1)-depi
+         xxprim(1)   = xxprim(iip1)
+       ENDIF
+       DO i = 1 , iim
+        xlon(i)     = xvrai(i)
+        xprimm(i)   = xxprim(i)
+       ENDDO
+  
+       DO i = 1, iim -1
+        IF( xvrai(i+1). LT. xvrai(i) )  THEN
+         WRITE(6,*) ' PBS. avec rlonu(',i+1,') plus petit que rlonu(',i,
+     ,  ')'
+        STOP 7
+        ENDIF
+       ENDDO
+c
+c   ... Reorganisation  des  longitudes  pour les avoir  entre - pi et pi ..
+c   ........................................................................
+
+       champmin =  1.e12
+       champmax = -1.e12
+       DO i = 1, iim
+        champmin = MIN( champmin,xvrai(i) )
+        champmax = MAX( champmax,xvrai(i) )
+       ENDDO
+
+      IF(champmin .GE.-pi-0.10.and.champmax.LE.pi+0.10 )  THEN
+                GO TO 1600
+      ELSE
+       WRITE(6,*) 'Reorganisation des longitudes pour avoir entre - pi',
+     ,  ' et pi '
+c
+        IF( xzoom.LE.0.)  THEN
+          IF( ik.EQ. 1 )  THEN
+          DO i = 1, iim
+           IF( xvrai(i).GE. - pi )  GO TO 80
+          ENDDO
+            WRITE(6,*)  ' PBS. 1 !  Xvrai plus petit que  - pi ! '
+            STOP 8
+ 80       CONTINUE
+          is2 = i
+          ENDIF
+
+          IF( is2.NE. 1 )  THEN
+            DO ii = is2 , iim
+             xlon  (ii-is2+1) = xvrai(ii)
+             xprimm(ii-is2+1) = xxprim(ii)
+            ENDDO
+            DO ii = 1 , is2 -1
+             xlon  (ii+iim-is2+1) = xvrai(ii) + depi
+             xprimm(ii+iim-is2+1) = xxprim(ii) 
+            ENDDO
+          ENDIF
+        ELSE 
+          IF( ik.EQ.1 )  THEN
+           DO i = iim,1,-1
+             IF( xvrai(i).LE. pi ) GO TO 90
+           ENDDO
+             WRITE(6,*) ' PBS.  2 ! Xvrai plus grand  que   pi ! '
+              STOP 9
+ 90        CONTINUE
+            is2 = i
+          ENDIF
+           idif = iim -is2
+           DO ii = 1, is2
+            xlon  (ii+idif) = xvrai(ii)
+            xprimm(ii+idif) = xxprim(ii)
+           ENDDO
+           DO ii = 1, idif
+            xlon (ii)  = xvrai (ii+is2) - depi
+            xprimm(ii) = xxprim(ii+is2) 
+           ENDDO
+         ENDIF
+      ENDIF
+c
+c     .........   Fin  de la reorganisation   ............................
+
+ 1600    CONTINUE
+
+
+         xlon  ( iip1)  = xlon(1) + depi
+         xprimm( iip1 ) = xprimm (1 )
+       
+         DO i = 1, iim+1
+         xvrai(i) = xlon(i)*180./pi
+         ENDDO
+
+         IF( ik.EQ.1 )  THEN
+c          WRITE(6,*)  ' XLON aux pts. V-0.25   apres ( en  deg. ) '
+c          WRITE(6,18) 
+c          WRITE(6,68) xvrai
+c          WRITE(6,*) ' XPRIM k ',ik
+c          WRITE(6,566)  xprimm
+
+           DO i = 1,iim +1
+             rlonm025(i) = xlon( i )
+            xprimm025(i) = xprimm(i)
+           ENDDO
+           
+         ELSE IF( ik.EQ.2 )  THEN
+c          WRITE(6,18) 
+c          WRITE(6,*)  ' XLON aux pts. V   apres ( en  deg. ) '
+c          WRITE(6,68) xvrai
+c          WRITE(6,*) ' XPRIM k ',ik
+c          WRITE(6,566)  xprimm
+
+           DO i = 1,iim + 1
+             rlonv(i) = xlon( i )
+            xprimv(i) = xprimm(i)
+           ENDDO
+
+         ELSE IF( ik.EQ.3)   THEN
+c          WRITE(6,18) 
+c          WRITE(6,*)  ' XLON aux pts. U   apres ( en  deg. ) '
+c          WRITE(6,68) xvrai
+c          WRITE(6,*) ' XPRIM ik ',ik
+c          WRITE(6,566)  xprimm
+
+           DO i = 1,iim + 1
+             rlonu(i) = xlon( i )
+            xprimu(i) = xprimm(i)
+           ENDDO
+
+         ELSE IF( ik.EQ.4 )  THEN
+c          WRITE(6,18) 
+c          WRITE(6,*)  ' XLON aux pts. V+0.25   apres ( en  deg. ) '
+c          WRITE(6,68) xvrai
+c          WRITE(6,*) ' XPRIM ik ',ik
+c          WRITE(6,566)  xprimm
+
+           DO i = 1,iim + 1
+             rlonp025(i) = xlon( i )
+            xprimp025(i) = xprimm(i)
+           ENDDO
+
+         ENDIF
+
+5000    CONTINUE
+c
+       WRITE(6,18)
+c
+c    ...........  fin  de la boucle  do 5000      ............
+
+        DO i = 1, iim
+         xlon(i) = rlonv(i+1) - rlonv(i)
+        ENDDO
+        champmin =  1.e12
+        champmax = -1.e12
+        DO i = 1, iim
+         champmin = MIN( champmin, xlon(i) )
+         champmax = MAX( champmax, xlon(i) )
+        ENDDO
+         champmin = champmin * 180./pi
+         champmax = champmax * 180./pi
+
+18     FORMAT(/)
+24     FORMAT(2x,'Parametres xzoom,gross,tau ,dzoom pour fxhyp ',4f8.3)
+68     FORMAT(1x,7f9.2)
+566    FORMAT(1x,7f9.4)
+
+       RETURN
+       END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/fxy.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/fxy.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/fxy.F	(revision 1644)
@@ -0,0 +1,67 @@
+      SUBROUTINE fxy (rlatu,yprimu,rlatv,yprimv,rlatu1,yprimu1,
+     ,                    rlatu2,yprimu2,
+     , rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025)
+
+      USE comconst_mod, ONLY: pi
+      USE serre_mod, ONLY: pxo,pyo,alphax,alphay,transx,transy
+
+      IMPLICIT NONE
+
+c     Auteur  :  P. Le Van
+c
+c     Calcul  des longitudes et des latitudes  pour une fonction f(x,y)
+c           a tangente sinusoidale et eventuellement avec zoom  .
+c
+c
+#include "dimensions.h"
+#include "paramet.h"
+
+       INTEGER i,j
+
+       REAL rlatu(jjp1), yprimu(jjp1),rlatv(jjm), yprimv(jjm),
+     , rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
+       REAL rlonu(iip1),xprimu(iip1),rlonv(iip1),xprimv(iip1),
+     , rlonm025(iip1),xprimm025(iip1), rlonp025(iip1),xprimp025(iip1)
+
+#include "fxy_new.h"
+
+
+c    ......  calcul  des  latitudes  et de y'   .....
+c
+       DO j = 1, jjm + 1 
+          rlatu(j) = fy    ( FLOAT( j )        )
+         yprimu(j) = fyprim( FLOAT( j )        )
+       ENDDO
+
+
+       DO j = 1, jjm
+
+         rlatv(j)  = fy    ( FLOAT( j ) + 0.5  )
+         rlatu1(j) = fy    ( FLOAT( j ) + 0.25 ) 
+         rlatu2(j) = fy    ( FLOAT( j ) + 0.75 ) 
+
+        yprimv(j)  = fyprim( FLOAT( j ) + 0.5  ) 
+        yprimu1(j) = fyprim( FLOAT( j ) + 0.25 )
+        yprimu2(j) = fyprim( FLOAT( j ) + 0.75 )
+
+       ENDDO
+
+c
+c     .....  calcul   des  longitudes et de  x'   .....
+c
+       DO i = 1, iim + 1
+           rlonv(i)     = fx    (   FLOAT( i )          )
+           rlonu(i)     = fx    (   FLOAT( i ) + 0.5    )
+        rlonm025(i)     = fx    (   FLOAT( i ) - 0.25  )
+        rlonp025(i)     = fx    (   FLOAT( i ) + 0.25  )
+
+         xprimv  (i)    = fxprim (  FLOAT( i )          )
+         xprimu  (i)    = fxprim (  FLOAT( i ) + 0.5    )
+        xprimm025(i)    = fxprim (  FLOAT( i ) - 0.25   )
+        xprimp025(i)    = fxprim (  FLOAT( i ) + 0.25   )
+       ENDDO
+
+c
+       RETURN
+       END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/fxyhyper.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/fxyhyper.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/fxyhyper.F	(revision 1644)
@@ -0,0 +1,137 @@
+c
+c $Header: /users/lmdz/cvsroot/LMDZ.3.3/libf/dyn3d/fxyhyper.F,v 1.4 2001/04/24 13:12:44 lmdz Exp $
+c
+       SUBROUTINE fxyhyper ( yzoom, grossy, dzoomy,tauy  ,   
+     ,                       xzoom, grossx, dzoomx,taux  ,
+     , rlatu,yprimu,rlatv,yprimv,rlatu1,  yprimu1,  rlatu2,  yprimu2  , 
+     , rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025)
+
+       IMPLICIT NONE
+c
+c      Auteur :  P. Le Van .
+c
+c      d'apres  formulations de R. Sadourny .
+c
+c
+c     Ce spg calcule les latitudes( routine fyhyp ) et longitudes( fxhyp )
+c            par des  fonctions  a tangente hyperbolique .
+c
+c     Il y a 3 parametres ,en plus des coordonnees du centre du zoom (xzoom
+c                      et  yzoom )   :  
+c
+c     a) le grossissement du zoom  :  grossy  ( en y ) et grossx ( en x )
+c     b) l' extension     du zoom  :  dzoomy  ( en y ) et dzoomx ( en x )
+c     c) la raideur de la transition du zoom  :   taux et tauy   
+c
+c  N.B : Il vaut mieux avoir   :   grossx * dzoomx <  pi    ( radians )
+c ******
+c                  et              grossy * dzoomy <  pi/2  ( radians )
+c
+#include "dimensions.h"
+#include "paramet.h"
+
+
+c   .....  Arguments  ...
+c
+       REAL xzoom,yzoom,grossx,grossy,dzoomx,dzoomy,taux,tauy
+       REAL rlatu(jjp1), yprimu(jjp1),rlatv(jjm), yprimv(jjm),
+     , rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
+       REAL rlonu(iip1),xprimu(iip1),rlonv(iip1),xprimv(iip1),
+     , rlonm025(iip1),xprimm025(iip1), rlonp025(iip1),xprimp025(iip1)
+       REAL*8  dxmin, dxmax , dymin, dymax
+
+c   ....   var. locales   .....
+c
+       INTEGER i,j
+c
+
+       CALL fyhyp ( yzoom, grossy, dzoomy,tauy  , 
+     ,  rlatu, yprimu,rlatv,yprimv,rlatu2,yprimu2,rlatu1,yprimu1 ,
+     ,  dymin,dymax                                               )
+
+       CALL fxhyp(xzoom,grossx,dzoomx,taux,rlonm025,xprimm025,rlonv,
+     , xprimv,rlonu,xprimu,rlonp025,xprimp025 , dxmin,dxmax         )
+
+
+        DO i = 1, iip1
+          IF(rlonp025(i).LT.rlonv(i))  THEN
+           WRITE(6,*) ' Attention !  rlonp025 < rlonv',i
+            STOP
+          ENDIF
+
+          IF(rlonv(i).LT.rlonm025(i))  THEN 
+           WRITE(6,*) ' Attention !  rlonm025 > rlonv',i
+            STOP
+          ENDIF
+
+          IF(rlonp025(i).GT.rlonu(i))  THEN
+           WRITE(6,*) ' Attention !  rlonp025 > rlonu',i
+            STOP
+          ENDIF
+        ENDDO
+
+        WRITE(6,*) '  *** TEST DE COHERENCE  OK    POUR   FX **** '
+
+c
+       DO j = 1, jjm
+c
+       IF(rlatu1(j).LE.rlatu2(j))   THEN
+         WRITE(6,*)'Attention ! rlatu1 < rlatu2 ',rlatu1(j), rlatu2(j),j
+         STOP 13
+       ENDIF
+c
+       IF(rlatu2(j).LE.rlatu(j+1))  THEN
+        WRITE(6,*)'Attention ! rlatu2 < rlatup1 ',rlatu2(j),rlatu(j+1),j
+        STOP 14
+       ENDIF
+c
+       IF(rlatu(j).LE.rlatu1(j))    THEN
+        WRITE(6,*)' Attention ! rlatu < rlatu1 ',rlatu(j),rlatu1(j),j
+        STOP 15
+       ENDIF
+c
+       IF(rlatv(j).LE.rlatu2(j))    THEN
+        WRITE(6,*)' Attention ! rlatv < rlatu2 ',rlatv(j),rlatu2(j),j
+        STOP 16
+       ENDIF
+c
+       IF(rlatv(j).ge.rlatu1(j))    THEN
+        WRITE(6,*)' Attention ! rlatv > rlatu1 ',rlatv(j),rlatu1(j),j
+        STOP 17
+       ENDIF
+c
+       IF(rlatv(j).ge.rlatu(j))     THEN
+        WRITE(6,*) ' Attention ! rlatv > rlatu ',rlatv(j),rlatu(j),j
+        STOP 18
+       ENDIF
+c
+       ENDDO
+c
+       WRITE(6,*) '  *** TEST DE COHERENCE  OK    POUR   FY **** '
+c
+        WRITE(6,18)
+        WRITE(6,*) '  Latitudes  '
+        WRITE(6,*) ' *********** '
+        WRITE(6,18)
+        WRITE(6,3)  dymin, dymax
+        WRITE(6,*) ' Si cette derniere est trop lache , modifiez les par
+     ,ametres  grossism , tau , dzoom pour Y et repasser ! '
+c
+        WRITE(6,18)
+        WRITE(6,*) '  Longitudes  '
+        WRITE(6,*) ' ************ '
+        WRITE(6,18)
+        WRITE(6,3)  dxmin, dxmax
+        WRITE(6,*) ' Si cette derniere est trop lache , modifiez les par
+     ,ametres  grossism , tau , dzoom pour Y et repasser ! '
+        WRITE(6,18)
+c
+3      Format(1x, ' Au centre du zoom , la longueur de la maille est',
+     ,  ' d environ ',f8.2 ,' degres  ',
+     , ' alors que la maille en dehors de la zone du zoom est d environ
+     , ', f8.2,' degres ' )
+18      FORMAT(/)
+
+       RETURN
+       END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/fxysinus.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/fxysinus.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/fxysinus.F	(revision 1644)
@@ -0,0 +1,66 @@
+      SUBROUTINE fxysinus (rlatu,yprimu,rlatv,yprimv,rlatu1,yprimu1,
+     ,                    rlatu2,yprimu2,
+     ,  rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025)
+
+      USE comconst_mod, ONLY: pi
+
+      IMPLICIT NONE
+c
+c     Calcul  des longitudes et des latitudes  pour une fonction f(x,y)
+c            avec y = Asin( j )  .
+c
+c     Auteur  :  P. Le Van
+c
+c
+#include "dimensions.h"
+#include "paramet.h"
+
+       INTEGER i,j
+
+       REAL rlatu(jjp1), yprimu(jjp1),rlatv(jjm), yprimv(jjm),
+     , rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
+       REAL rlonu(iip1),xprimu(iip1),rlonv(iip1),xprimv(iip1),
+     , rlonm025(iip1),xprimm025(iip1), rlonp025(iip1),xprimp025(iip1)
+
+#include "fxy_sin.h"
+
+
+c    ......  calcul  des  latitudes  et de y'   .....
+c
+       DO j = 1, jjm + 1 
+          rlatu(j) = fy    ( FLOAT( j )        )
+         yprimu(j) = fyprim( FLOAT( j )        )
+       ENDDO
+
+
+       DO j = 1, jjm
+
+         rlatv(j)  = fy    ( FLOAT( j ) + 0.5  )
+         rlatu1(j) = fy    ( FLOAT( j ) + 0.25 ) 
+         rlatu2(j) = fy    ( FLOAT( j ) + 0.75 ) 
+
+        yprimv(j)  = fyprim( FLOAT( j ) + 0.5  ) 
+        yprimu1(j) = fyprim( FLOAT( j ) + 0.25 )
+        yprimu2(j) = fyprim( FLOAT( j ) + 0.75 )
+
+       ENDDO
+
+c
+c     .....  calcul   des  longitudes et de  x'   .....
+c
+       DO i = 1, iim + 1
+           rlonv(i)     = fx    (   FLOAT( i )          )
+           rlonu(i)     = fx    (   FLOAT( i ) + 0.5    )
+        rlonm025(i)     = fx    (   FLOAT( i ) - 0.25  )
+        rlonp025(i)     = fx    (   FLOAT( i ) + 0.25  )
+
+         xprimv  (i)    = fxprim (  FLOAT( i )          )
+         xprimu  (i)    = fxprim (  FLOAT( i ) + 0.5    )
+        xprimm025(i)    = fxprim (  FLOAT( i ) - 0.25   )
+        xprimp025(i)    = fxprim (  FLOAT( i ) + 0.25   )
+       ENDDO
+
+c
+       RETURN
+       END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/fyhyp.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/fyhyp.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/fyhyp.F	(revision 1644)
@@ -0,0 +1,376 @@
+C
+c $Header: /users/lmdz/cvsroot/LMDZ.3.3/libf/dyn3d/fyhyp.F,v 1.5 2001/07/04 10:46:06 lmdz Exp $
+c
+       SUBROUTINE fyhyp ( yzoomdeg, grossism, dzoom,tau  ,  
+     ,  rrlatu,yyprimu,rrlatv,yyprimv,rlatu2,yprimu2,rlatu1,yprimu1 ,
+     ,  champmin,champmax                                            ) 
+
+cc    ...  Version du 01/04/2001 ....
+
+       IMPLICIT NONE
+c
+c    ...   Auteur :  P. Le Van  ... 
+c
+c    .......    d'apres  formulations  de R. Sadourny  .......
+c
+c     Calcule les latitudes et derivees dans la grille du GCM pour une
+c     fonction f(y) a tangente  hyperbolique  .
+c
+c     grossism etant le grossissement ( = 2 si 2 fois, = 3 si 3 fois , etc)
+c     dzoom  etant  la distance totale de la zone du zoom ( en radians )
+c     tau  la raideur de la transition de l'interieur a l'exterieur du zoom   
+c
+c
+c N.B : Il vaut mieux avoir : grossism * dzoom  <  pi/2  (radians) ,en lati.
+c      ********************************************************************
+c
+c
+#include "dimensions.h"
+#include "paramet.h"
+
+       INTEGER      nmax , nmax2
+       PARAMETER (  nmax = 30000, nmax2 = 2*nmax )
+c
+c
+c     .......  arguments  d'entree    .......
+c
+       REAL yzoomdeg, grossism,dzoom,tau 
+c         ( rentres  par  run.def )
+
+c     .......  arguments  de sortie   .......
+c
+       REAL rrlatu(jjp1), yyprimu(jjp1),rrlatv(jjm), yyprimv(jjm),
+     , rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
+
+c
+c     .....     champs  locaux    .....
+c
+     
+       REAL*8 ylat(jjp1), yprim(jjp1)
+       REAL*8 yuv
+       REAL*8 yt(0:nmax2)
+       REAL*8 fhyp(0:nmax2),beta,Ytprim(0:nmax2),fxm(0:nmax2)
+       SAVE Ytprim, yt,Yf
+       REAL*8 Yf(0:nmax2),yypr(0:nmax2)
+       REAL*8 yvrai(jjp1), yprimm(jjp1),ylatt(jjp1)
+       REAL*8 pi,depi,pis2,epsilon,y0,pisjm
+       REAL*8 yo1,yi,ylon2,ymoy,Yprimin,champmin,champmax
+       REAL*8 yfi,Yf1,ffdy
+       REAL*8 ypn,deply,y00
+       SAVE y00, deply
+
+       INTEGER i,j,it,ik,iter,jlat
+       INTEGER jpn,jjpn
+       SAVE jpn
+       REAL*8 a0,a1,a2,a3,yi2,heavyy0,heavyy0m
+       REAL*8 fa(0:nmax2),fb(0:nmax2)
+       REAL y0min,y0max
+
+       REAL*8     heavyside
+       EXTERNAL   heavyside
+
+       pi       = 2. * ASIN(1.)
+       depi     = 2. * pi
+       pis2     = pi/2.
+       pisjm    = pi/ FLOAT(jjm)
+       epsilon  = 1.e-3
+       y0       =  yzoomdeg * pi/180. 
+
+       IF( dzoom.LT.1.)  THEN
+         dzoom = dzoom * pi
+       ELSEIF( dzoom.LT. 12. ) THEN
+         WRITE(6,*) ' Le param. dzoomy pour fyhyp est trop petit ! L aug
+     ,menter et relancer ! '
+         STOP 1
+       ELSE
+         dzoom = dzoom * pi/180.
+       ENDIF
+
+       WRITE(6,18)
+       WRITE(6,*) ' yzoom( rad.),grossism,tau,dzoom (radians)'
+       WRITE(6,24) y0,grossism,tau,dzoom
+
+       DO i = 0, nmax2 
+        yt(i) = - pis2  + FLOAT(i)* pi /nmax2
+       ENDDO
+
+       heavyy0m = heavyside( -y0 )
+       heavyy0  = heavyside(  y0 )
+       y0min    = 2.*y0*heavyy0m - pis2
+       y0max    = 2.*y0*heavyy0  + pis2
+
+       fa = 999.999
+       fb = 999.999
+
+       DO i = 0, nmax2 
+        IF( yt(i).LT.y0 )  THEN
+         fa (i) = tau*  (yt(i)-y0+dzoom/2. )
+         fb(i) =   (yt(i)-2.*y0*heavyy0m +pis2) * ( y0 - yt(i) )
+        ELSEIF ( yt(i).GT.y0 )  THEN
+         fa(i) =   tau *(y0-yt(i)+dzoom/2. )
+         fb(i) = (2.*y0*heavyy0 -yt(i)+pis2) * ( yt(i) - y0 ) 
+       ENDIF
+        
+       IF( 200.* fb(i) .LT. - fa(i) )   THEN
+         fhyp ( i) = - 1.
+       ELSEIF( 200. * fb(i) .LT. fa(i) ) THEN
+         fhyp ( i) =   1.
+       ELSE  
+         fhyp(i) =  TANH ( fa(i)/fb(i) )
+       ENDIF
+
+       IF( yt(i).EQ.y0 )  fhyp(i) = 1.
+       IF(yt(i).EQ. y0min. OR.yt(i).EQ. y0max ) fhyp(i) = -1.
+
+       ENDDO
+
+cc  ....  Calcul  de  beta  ....
+c
+       ffdy   = 0.
+
+       DO i = 1, nmax2
+        ymoy    = 0.5 * ( yt(i-1) + yt( i ) )
+        IF( ymoy.LT.y0 )  THEN
+         fa(i)= tau * ( ymoy-y0+dzoom/2.) 
+         fb(i) = (ymoy-2.*y0*heavyy0m +pis2) * ( y0 - ymoy )
+        ELSEIF ( ymoy.GT.y0 )  THEN
+         fa(i)= tau * ( y0-ymoy+dzoom/2. ) 
+         fb(i) = (2.*y0*heavyy0 -ymoy+pis2) * ( ymoy - y0 )
+        ENDIF
+
+        IF( 200.* fb(i) .LT. - fa(i) )    THEN
+         fxm ( i) = - 1.
+        ELSEIF( 200. * fb(i) .LT. fa(i) ) THEN
+         fxm ( i) =   1.
+        ELSE
+         fxm(i) =  TANH ( fa(i)/fb(i) )
+        ENDIF
+         IF( ymoy.EQ.y0 )  fxm(i) = 1.
+         IF (ymoy.EQ. y0min. OR.yt(i).EQ. y0max ) fxm(i) = -1.
+         ffdy = ffdy + fxm(i) * ( yt(i) - yt(i-1) )
+
+        ENDDO
+
+        beta  = ( grossism * ffdy - pi ) / ( ffdy - pi )
+
+       IF( 2.*beta - grossism.LE. 0.)  THEN
+
+        WRITE(6,*) ' **  Attention ! La valeur beta calculee dans la rou
+     ,tine fyhyp est mauvaise ! '
+        WRITE(6,*)'Modifier les valeurs de  grossismy ,tauy ou dzoomy',
+     , ' et relancer ! ***  '
+        CALL ABORT
+
+       ENDIF
+c
+c   .....  calcul  de  Ytprim   .....
+c
+       
+       DO i = 0, nmax2
+        Ytprim(i) = beta  + ( grossism - beta ) * fhyp(i)
+       ENDDO
+
+c   .....  Calcul  de  Yf     ........
+
+       Yf(0) = - pis2
+       DO i = 1, nmax2
+        yypr(i)    = beta + ( grossism - beta ) * fxm(i)
+       ENDDO
+
+       DO i=1,nmax2
+        Yf(i)   = Yf(i-1) + yypr(i) * ( yt(i) - yt(i-1) )
+       ENDDO
+
+c    ****************************************************************
+c
+c   .....   yuv  = 0.   si calcul des latitudes  aux pts.  U  .....
+c   .....   yuv  = 0.5  si calcul des latitudes  aux pts.  V  .....
+c
+      WRITE(6,18)
+c
+      DO 5000  ik = 1,4
+
+       IF( ik.EQ.1 )  THEN
+         yuv  = 0.
+         jlat = jjm + 1
+       ELSE IF ( ik.EQ.2 )  THEN
+         yuv  = 0.5
+         jlat = jjm 
+       ELSE IF ( ik.EQ.3 )  THEN
+         yuv  = 0.25
+         jlat = jjm 
+       ELSE IF ( ik.EQ.4 )  THEN
+         yuv  = 0.75
+         jlat = jjm 
+       ENDIF
+c
+       yo1   = 0.
+       DO 1500 j =  1,jlat
+        yo1   = 0.
+        ylon2 =  - pis2 + pisjm * ( FLOAT(j)  + yuv  -1.)  
+        yfi    = ylon2
+c
+       DO 250 it =  nmax2,0,-1
+        IF( yfi.GE.Yf(it))  GO TO 350
+250    CONTINUE
+       it = 0
+350    CONTINUE
+
+       yi = yt(it)
+       IF(it.EQ.nmax2)  THEN
+        it       = nmax2 -1
+        Yf(it+1) = pis2
+       ENDIF
+c  .................................................................
+c  ....  Interpolation entre  yi(it) et yi(it+1)   pour avoir Y(yi)  
+c      .....           et   Y'(yi)                             .....
+c  .................................................................
+
+       CALL coefpoly ( Yf(it),Yf(it+1),Ytprim(it), Ytprim(it+1),   
+     ,                  yt(it),yt(it+1) ,   a0,a1,a2,a3   )      
+
+       Yf1     = Yf(it)
+       Yprimin = a1 + 2.* a2 * yi + 3.*a3 * yi *yi
+
+       DO 500 iter = 1,300
+         yi = yi - ( Yf1 - yfi )/ Yprimin
+
+        IF( ABS(yi-yo1).LE.epsilon)  GO TO 550
+         yo1      = yi
+         yi2      = yi * yi
+         Yf1      = a0 +  a1 * yi +     a2 * yi2  +     a3 * yi2 * yi
+         Yprimin  =       a1      + 2.* a2 *  yi  + 3.* a3 * yi2
+500   CONTINUE
+        WRITE(6,*) ' Pas de solution ***** ',j,ylon2,iter
+         STOP 2
+550   CONTINUE
+c
+       Yprimin   = a1  + 2.* a2 *  yi   + 3.* a3 * yi* yi
+       yprim(j)  = pi / ( jjm * Yprimin )
+       yvrai(j)  = yi 
+
+1500    CONTINUE
+
+       DO j = 1, jlat -1
+        IF( yvrai(j+1). LT. yvrai(j) )  THEN
+         WRITE(6,*) ' PBS. avec  rlat(',j+1,') plus petit que rlat(',j,
+     ,  ')'
+         STOP 3
+        ENDIF
+       ENDDO
+
+       WRITE(6,*) 'Reorganisation des latitudes pour avoir entre - pi/2'
+     , ,' et  pi/2 '
+c
+        IF( ik.EQ.1 )   THEN
+           ypn = pis2 
+          DO j = jlat,1,-1
+           IF( yvrai(j).LE. ypn ) GO TO 1502
+          ENDDO
+1502     CONTINUE
+
+         jpn   = j
+         y00   = yvrai(jpn)
+         deply = pis2 -  y00
+        ENDIF
+
+         DO  j = 1, jjm +1 - jpn
+           ylatt (j)  = -pis2 - y00  + yvrai(jpn+j-1)
+           yprimm(j)  = yprim(jpn+j-1)
+         ENDDO
+
+         jjpn  = jpn
+         IF( jlat.EQ. jjm ) jjpn = jpn -1
+
+         DO j = 1,jjpn 
+          ylatt (j + jjm+1 -jpn) = yvrai(j) + deply
+          yprimm(j + jjm+1 -jpn) = yprim(j)
+         ENDDO
+
+c      ***********   Fin de la reorganisation     *************
+c
+ 1600   CONTINUE
+
+       DO j = 1, jlat
+          ylat(j) =  ylatt( jlat +1 -j )
+         yprim(j) = yprimm( jlat +1 -j )
+       ENDDO
+  
+        DO j = 1, jlat
+         yvrai(j) = ylat(j)*180./pi
+        ENDDO
+
+        IF( ik.EQ.1 )  THEN
+c         WRITE(6,18) 
+c         WRITE(6,*)  ' YLAT  en U   apres ( en  deg. ) '
+c         WRITE(6,68) (yvrai(j),j=1,jlat)
+cc         WRITE(6,*) ' YPRIM '
+cc         WRITE(6,445) ( yprim(j),j=1,jlat)
+
+          DO j = 1, jlat
+            rrlatu(j) =  ylat( j )
+           yyprimu(j) = yprim( j )
+          ENDDO
+
+        ELSE IF ( ik.EQ. 2 )  THEN
+c         WRITE(6,18) 
+c         WRITE(6,*) ' YLAT   en V  apres ( en  deg. ) '
+c         WRITE(6,68) (yvrai(j),j=1,jlat)
+cc         WRITE(6,*)' YPRIM '
+cc         WRITE(6,445) ( yprim(j),j=1,jlat)
+
+          DO j = 1, jlat
+            rrlatv(j) =  ylat( j )
+           yyprimv(j) = yprim( j )
+          ENDDO
+
+        ELSE IF ( ik.EQ. 3 )  THEN
+c         WRITE(6,18) 
+c         WRITE(6,*)  ' YLAT  en U + 0.75  apres ( en  deg. ) '
+c         WRITE(6,68) (yvrai(j),j=1,jlat)
+cc         WRITE(6,*) ' YPRIM '
+cc         WRITE(6,445) ( yprim(j),j=1,jlat)
+
+          DO j = 1, jlat
+            rlatu2(j) =  ylat( j )
+           yprimu2(j) = yprim( j )
+          ENDDO
+
+        ELSE IF ( ik.EQ. 4 )  THEN
+c         WRITE(6,18) 
+c         WRITE(6,*)  ' YLAT en U + 0.25  apres ( en  deg. ) '
+c         WRITE(6,68)(yvrai(j),j=1,jlat)
+cc         WRITE(6,*) ' YPRIM '
+cc         WRITE(6,68) ( yprim(j),j=1,jlat)
+
+          DO j = 1, jlat
+            rlatu1(j) =  ylat( j )
+           yprimu1(j) = yprim( j )
+          ENDDO
+
+        ENDIF
+
+5000   CONTINUE
+c
+        WRITE(6,18)
+c
+c  .....     fin de la boucle  do 5000 .....
+
+        DO j = 1, jjm
+         ylat(j) = rrlatu(j) - rrlatu(j+1)
+        ENDDO
+        champmin =  1.e12
+        champmax = -1.e12
+        DO j = 1, jjm
+         champmin = MIN( champmin, ylat(j) )
+         champmax = MAX( champmax, ylat(j) )
+        ENDDO
+         champmin = champmin * 180./pi
+         champmax = champmax * 180./pi
+
+24     FORMAT(2x,'Parametres yzoom,gross,tau ,dzoom pour fyhyp ',4f8.3)
+18      FORMAT(/)
+68      FORMAT(1x,7f9.2)
+
+        RETURN
+        END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/gcm.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/gcm.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/gcm.F	(revision 1644)
@@ -0,0 +1,728 @@
+      PROGRAM gcm
+
+      use ioipsl_getincom, only: getin
+      use infotrac, only: iniadvtrac, nqtot, iadv
+      use sponge_mod,only: callsponge,mode_sponge,sponge
+      use control_mod, only: nday, day_step, iperiod, iphysiq,
+     &                       iconser, dissip_period
+!      use comgeomphy, only: initcomgeomphy
+      USE mod_const_mpi, ONLY: COMM_LMDZ
+      use filtreg_mod, only: inifilr
+      USE comvert_mod, ONLY: ap,bp
+      USE comconst_mod, ONLY: daysec,dtvr,dtphys,dtdiss,rad,g,r,cpp
+      USE logic_mod, ONLY: ecripar,forward,leapf,apphys,statcl,conser,
+     .		apdiss,purmats,iflag_phys,apphys
+      USE temps_mod, ONLY: day_ini,day_end,itaufin,dt
+      USE iniphysiq_mod, ONLY: iniphysiq
+      IMPLICIT NONE
+
+c      ......   Version  du 10/01/98    ..........
+
+c             avec  coordonnees  verticales hybrides 
+c   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   GCM LMD nouvelle grille
+c
+c=======================================================================
+c
+c  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
+c      et possibilite d'appeler une fonction f(y)  a derivee tangente
+c      hyperbolique a la  place de la fonction a derivee sinusoidale.
+
+c  ... Possibilite de choisir le shema de Van-leer pour l'advection de
+c        q  , en faisant iadv = 3  dans   traceur  (29/04/97) .
+c
+c      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
+c
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissnew.h"
+#include "comgeom.h"
+!#include "control.h"
+#include "netcdf.inc"
+#include "tracstoke.h"
+!#include"advtrac.h"
+
+      INTEGER*4  iday ! jour julien
+      REAL       time ! Heure de la journee en fraction d''1 jour
+      REAL zdtvr
+
+c   variables dynamiques
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
+      real, dimension(ip1jmp1,llm) :: teta   ! temperature potentielle 
+      REAL,allocatable :: q(:,:,:)           ! champs advectes
+      REAL ps(ip1jmp1)                       ! pression  au sol
+      REAL pext(ip1jmp1)                     ! pression  extensive
+      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
+      REAL pks(ip1jmp1)                      ! exner au  sol
+      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
+      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
+      REAL masse(ip1jmp1,llm)                ! masse d''air
+      REAL phis(ip1jmp1)                     ! geopotentiel au sol
+      REAL phi(ip1jmp1,llm)                  ! geopotentiel
+      REAL w(ip1jmp1,llm)                    ! vitesse verticale
+
+c variables dynamiques intermediaire pour le transport
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm) !flux de masse
+
+c   variables dynamiques au pas -1
+      REAL vcovm1(ip1jm,llm),ucovm1(ip1jmp1,llm)
+
+      REAL tetam1(ip1jmp1,llm),psm1(ip1jmp1)
+      REAL massem1(ip1jmp1,llm)
+
+c   tendances dynamiques
+      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
+      REAL dteta(ip1jmp1,llm),dp(ip1jmp1)
+      REAL,ALLOCATABLE :: dq(:,:,:)
+
+c   tendances de la dissipation
+      REAL dvdis(ip1jm,llm),dudis(ip1jmp1,llm)
+      REAL dhdis(ip1jmp1,llm)
+
+c   tendances physiques
+      REAL dvfi(ip1jm,llm),dufi(ip1jmp1,llm)
+      REAL dhfi(ip1jmp1,llm),dpfi(ip1jmp1)
+      REAL,ALLOCATABLE :: dqfi(:,:,:)
+
+c   variables pour le fichier histoire
+      REAL dtav      ! intervalle de temps elementaire
+
+      REAL tppn(iim),tpps(iim),tpn,tps
+c
+!      INTEGER iadv(nqmx) ! indice schema de transport pour le traceur iq
+
+      INTEGER itau,itaufinp1,iav
+
+
+      EXTERNAL caldyn, traceur
+      EXTERNAL dissip,geopot,iniconst
+      EXTERNAL integrd,SCOPY
+      EXTERNAL inigeom
+      EXTERNAL exner_hyb
+      EXTERNAL defrun_new, test_period
+      REAL  SSUM
+      REAL time_0 , finvmaold(ip1jmp1,llm)
+
+      LOGICAL lafin
+      INTEGER ij,iq,l,ierr,numvanle,iapp_tracvl
+
+      REAL rdayvrai,rdaym_ini,rday_ecri
+!      LOGICAL first
+      REAL beta(ip1jmp1,llm)
+
+      LOGICAL offline  ! Controle du stockage ds "fluxmass"
+      PARAMETER (offline=.false.)
+
+      character*20 modname
+      character*80 abort_message
+
+! flag to run with or without tracer transport (read from run.def)
+      logical tracer
+      
+C Calendrier
+      LOGICAL true_calendar
+      PARAMETER (true_calendar = .false.)
+
+! flag to set/remove calls to groupeun
+      logical callgroupeun
+      parameter (callgroupeun = .false.)
+
+!     added by RDW for tests without dynamics
+      logical calldyn
+      parameter (calldyn = .true.)
+
+!     added by RW for test
+!      real pmean,airetot
+
+!     added by FF for dissipation / energy conservation tests
+      logical dissip_conservative
+      parameter (dissip_conservative = .false.)
+      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
+!     d (theta)/ d t (pot. temperature) due to the creation 
+!     of thermal energy by dissipation
+      REAL dtetaecdt(ip1jmp1,llm)
+      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
+
+c-----------------------------------------------------------------------
+c    variables pour l'initialisation de la physique :
+c    ------------------------------------------------
+!      INTEGER ngridmx
+!      PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm   )
+!      REAL zcufi(ngridmx),zcvfi(ngridmx)
+!      REAL latfi(ngridmx),lonfi(ngridmx)
+!      REAL airefi(ngridmx)
+!      SAVE latfi, lonfi, airefi
+!      INTEGER i,j
+
+c-----------------------------------------------------------------------
+c   Initialisations:
+c   ----------------
+
+      modname = 'gcm'
+      lafin    = .FALSE.
+
+c-----------------------------------------------------------------------
+      CALL defrun_new( 99, .TRUE. )
+      WRITE(*,*) ""
+      WRITE(*,*) "Run with or without tracer transport ?"
+      tracer=.true. ! default value
+      call getin("tracer",tracer)
+      WRITE(*,*)" tracer = ",tracer
+
+! 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",vcov,ucov,
+     .              teta,q,masse,ps,phis, time_0)
+
+c  on recalcule eventuellement le pas de temps
+
+      IF(MOD(day_step,iperiod).NE.0)
+     * STOP'Il faut choisir un nb de pas par jour multiple de iperiod'
+
+      IF(MOD(day_step,iphysiq).NE.0)
+     * STOP'Il faut choisir un nb de pas par jour multiple de iphysiq'
+
+      zdtvr    = daysec/FLOAT(day_step)
+
+        IF(dtvr.NE.zdtvr) THEN
+         PRINT*,'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
+        ENDIF
+
+c  nombre d'etats dans les fichiers demarrage et histoire
+
+      dtvr = zdtvr
+      CALL iniconst
+      CALL inigeom
+      CALL inifilr
+
+c
+c   ......    P.Le Van    ( modif  le 29/04/97 )   .........  
+c
+
+      CALL inidissip ( lstardis, nitergdiv, nitergrot, niterh   ,
+     *                tetagdiv, tetagrot , tetatemp              )
+c
+
+c-----------------------------------------------------------------------
+c   Initialisation de la physique :
+c   -------------------------------
+
+!      IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100)) THEN
+!         latfi(1)=rlatu(1)
+!         lonfi(1)=0.
+!         zcufi(1) = cu(1)
+!         zcvfi(1) = cv(1)
+!         DO j=2,jjm
+!            DO i=1,iim
+!               latfi((j-2)*iim+1+i)= rlatu(j)
+!               lonfi((j-2)*iim+1+i)= rlonv(i)
+!               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
+!               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
+!            ENDDO
+!         ENDDO
+!         latfi(ngridmx)= rlatu(jjp1)
+!         lonfi(ngridmx)= 0.
+!         zcufi(ngridmx) = cu(ip1jm+1)
+!         zcvfi(ngridmx) = cv(ip1jm-iim)
+!
+!         ! build airefi(), mesh area on physics grid
+!         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
+!         ! Poles are single points on physics grid
+!         airefi(1)=airefi(1)*iim
+!         airefi(ngridmx)=airefi(ngridmx)*iim
+
+! Initialisation de la physique: pose probleme quand on tourne 
+! SANS physique, car iniphysiq.F est dans le repertoire phy[]... 
+! Il faut une cle CPP_PHYS
+!#ifdef CPP_PHYS
+!         CALL iniphysiq(iim,jjm,llm,daysec,day_ini,dtphys/nsplit_phys,
+         CALL iniphysiq(iim,jjm,llm,
+     &                  (jjm-1)*iim+2,comm_lmdz,
+     &                  daysec,day_ini,dtphys,
+     &                  rlatu,rlatv,rlonu,rlonv,
+     &                  aire,cu,cv,rad,g,r,cpp,
+     &                iflag_phys)
+!#endif
+!         call_iniphys=.false.
+!      ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1))
+
+      CALL pression ( ip1jmp1, ap, bp, ps, p       )
+
+      call dump2d(iip1,jjp1,ps,'PRESSION SURFACE')
+      CALL exner_hyb( ip1jmp1, ps, p,beta, pks, pk, pkf )
+
+
+c  numero de stockage pour les fichiers de redemarrage:
+
+c-----------------------------------------------------------------------
+c   temps de depart et de fin:
+c   --------------------------
+
+      itau = 0
+      iday = day_ini+itau/day_step
+      time = FLOAT(itau-(iday-day_ini)*day_step)/day_step+time_0
+
+
+         IF(time.GT.1.) THEN
+          time = time-1.
+          iday = iday+1
+         ENDIF
+      itaufin   = nday*day_step
+c ********************************
+c      itaufin = 120   ! temporaire !!
+c ********************************
+      itaufinp1 = itaufin +1
+
+      day_end = day_ini + nday
+      PRINT 300, itau,itaufin,day_ini,day_end
+ 300  FORMAT('1'/,15x,'run du pas',i7,2x,'au pas',i7,2x,  
+     . 'c''est a dire du jour',i7,3x,'au jour',i7//)
+
+      CALL dynredem0("restart.nc",day_end,phis)
+
+      ecripar = .TRUE.
+
+      dtav = iperiod*dtvr/daysec
+
+
+c   Quelques initialisations pour les traceurs
+      call initial0(ijp1llm*nqtot,dq)
+c     istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
+c     istphy=istdyn/iphysiq
+
+      write(*,*) "gcm: callgroupeun set to:",callgroupeun
+c-----------------------------------------------------------------------
+c   Debut de l'integration temporelle:
+c   ----------------------------------
+
+   1  CONTINUE
+c
+      IF( MOD( itau, 10* day_step ).EQ.0 )  THEN
+        CALL test_period ( ucov,vcov,teta,q,p,phis )
+        PRINT *,' ----   Test_period apres continue   OK ! -----', itau
+      ENDIF 
+
+      if (callgroupeun) then
+        call groupeun(jjp1,llm,ucov,.true.)
+        call groupeun(jjm,llm,vcov,.true.)
+        call groupeun(jjp1,llm,teta,.true.)
+        call groupeun(jjp1,llm,masse,.true.)
+        call groupeun(jjp1,1,ps,.false.)
+      endif
+
+      CALL SCOPY( ijmllm ,vcov , 1, vcovm1 , 1 )
+      CALL SCOPY( ijp1llm,ucov , 1, ucovm1 , 1 )
+      CALL SCOPY( ijp1llm,teta , 1, tetam1 , 1 )
+      CALL SCOPY( ijp1llm,masse, 1, massem1, 1 )
+      CALL SCOPY( ip1jmp1, ps  , 1,   psm1 , 1 )
+
+      forward = .TRUE.
+      leapf   = .FALSE.
+      dt      =  dtvr
+
+c   ...    P.Le Van .26/04/94  ....
+
+      CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
+      CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
+
+
+   2  CONTINUE
+
+c-----------------------------------------------------------------------
+
+c   date:
+c   -----
+
+!      write(*,*) 'GCM: itau=',itau
+
+c   gestion des appels de la physique et des dissipations:
+c   ------------------------------------------------------
+c
+c   ...    P.Le Van  ( 6/02/95 )  ....
+
+      apphys = .FALSE.
+      statcl = .FALSE.
+      conser = .FALSE.
+      apdiss = .FALSE.
+
+      IF( purmats ) THEN
+         IF( MOD(itau,iconser) .EQ.0.AND.  forward    ) conser = .TRUE.
+         IF( MOD(itau,dissip_period ).EQ.0
+     &                              .AND..NOT.forward ) apdiss = .TRUE.
+         IF( MOD(itau,iphysiq ).EQ.0.AND..NOT.forward 
+     $                        .AND. (iflag_phys.eq.1) ) apphys = .TRUE.
+      ELSE
+         IF( MOD(itau   ,iconser) .EQ. 0              ) conser = .TRUE.
+         IF( MOD(itau+1,dissip_period)  .EQ. 0        ) apdiss = .TRUE.
+         IF( MOD(itau+1,iphysiq).EQ.0
+     &                     .AND. (iflag_phys.eq.1)    ) apphys = .TRUE.
+      END IF
+
+c-----------------------------------------------------------------------
+c   calcul des tendances dynamiques:
+c   --------------------------------
+
+      CALL geopot  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
+
+      if(calldyn)then
+         CALL caldyn 
+     $        ( itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
+     $        phi,conser,du,dv,dteta,dp,w,pbaru,pbarv,time+iday-day_ini)
+      endif
+
+c-----------------------------------------------------------------------
+c   calcul des tendances advection des traceurs (dont l'humidite)
+c   -------------------------------------------------------------
+
+
+
+      if (tracer) then
+       IF( forward. OR . leapf )  THEN
+
+        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. nqtot )   THEN
+c
+            iapp_tracvl = 5
+c
+cccc     iapp_tracvl est la frequence en pas du groupement des flux
+cccc      de masse pour  Van-Leer dans la routine  tracvl  .
+c
+
+            CALL vanleer(numvanle,iapp_tracvl,nqtot,q,pbaru,pbarv,
+     *                      p, masse, dq,  iadv(1), teta, pk     )
+
+c
+c                   ...  Modif  F.Codron  ....
+c
+         ENDIF
+c
+        ENDDO
+C
+c        IF (offline) THEN
+C maf stokage du flux de masse pour traceurs OFF-LINE
+
+c           CALL fluxstokenc(pbaru,pbarv,masse,teta,phi,phis,
+c    .   time_step, itau)
+
+c        ENDIF
+c
+      ENDIF
+	  END IF   ! tracer
+
+
+c-----------------------------------------------------------------------
+c   integrations dynamique et traceurs:
+c   ----------------------------------
+
+          if(calldyn)then
+             CALL integrd(2,vcovm1,ucovm1,tetam1,psm1,massem1, 
+     $            dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis,
+     $            finvmaold)
+          else
+             print*,'Currently no dynamics in this GCM...'
+          endif
+
+
+
+
+
+c .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
+c
+c-----------------------------------------------------------------------
+c   calcul des tendances physiques:
+c   -------------------------------
+c    ########   P.Le Van ( Modif le  6/02/95 )   ###########
+c
+       IF( purmats )  THEN
+          IF( itau.EQ.itaufin.AND..NOT.forward ) lafin = .TRUE.
+       ELSE
+          IF( itau+1. EQ. itaufin )              lafin = .TRUE.
+       ENDIF
+c
+c
+       IF( apphys )  THEN
+c
+c     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
+c
+
+         CALL pression (  ip1jmp1, ap, bp, ps,  p      )
+         CALL exner_hyb(  ip1jmp1, ps, p,beta,pks, pk, pkf )
+
+           rdaym_ini  = itau * dtvr / daysec
+           rdayvrai   = rdaym_ini  + day_ini
+
+! Ehouarn: what was this for ??
+!           IF ( ecritphy.LT.1. )  THEN
+!             rday_ecri = rdaym_ini
+!           ELSE
+             rday_ecri = INT(rdaym_ini)+INT(day_ini)
+!           ENDIF
+c
+
+
+
+        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)
+
+
+c      ajout des tendances physiques:
+c      ------------------------------
+!        if(1.eq.2)then
+          CALL addfi( nqtot, dtphys, leapf, forward   ,
+     $                  ucov, vcov, teta , q   ,ps , masse,
+     $                 dufi, dvfi, dhfi , dqfi ,dpfi  )
+!       else
+!          print*,'Currently no physics in this GCM...'
+!       endif
+c
+       ENDIF
+
+       CALL pression ( ip1jmp1, ap, bp, ps, p                  )
+
+       CALL exner_hyb( ip1jmp1, ps, p,beta, pks, pk, pkf )
+c   ----------------------------------------------------------
+
+c
+c
+c   dissipation horizontale et verticale  des petites echelles:
+c   ----------------------------------------------------------
+
+      IF(apdiss) THEN
+
+c        Sponge layer
+c        ~~~~~~~~~~~~
+
+         IF (callsponge) THEN
+           pext(1:ip1jmp1)=ps(1:ip1jmp1)*aire(1:ip1jmp1)
+           CALL sponge(ucov,vcov,teta,pext,dtdiss,mode_sponge)
+         ENDIF
+
+c        Dissipation horizontale
+c        ~~~~~~~~~~~~~~~~~~~~~~~
+
+
+         if(dissip_conservative) then
+!     calculate kinetic energy before dissipation
+            call covcont(llm,ucov,vcov,ucont,vcont)
+            call enercin(vcov,ucov,vcont,ucont,ecin0)
+         end if
+
+         CALL dissip(vcov,ucov,teta,p,dvdis,dudis,dhdis)
+
+         ucov(:,:)=ucov(:,:)+dudis(:,:)
+         vcov(:,:)=vcov(:,:)+dvdis(:,:)
+
+
+         if (dissip_conservative) then
+C           On rajoute la tendance due a la transform. Ec -> E therm. cree
+C           lors de la dissipation
+            call covcont(llm,ucov,vcov,ucont,vcont)
+            call enercin(vcov,ucov,vcont,ucont,ecin)
+            dtetaecdt(:,:) = (ecin0(:,:)-ecin(:,:))/ pk(:,:)
+            dhdis(:,:)     = dhdis(:,:) + dtetaecdt(:,:)
+         endif
+
+         teta(:,:)=teta(:,:)+dhdis(:,:)
+
+
+c    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
+c   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
+c
+
+        DO l  =  1, llm
+          DO ij =  1,iim
+           tppn(ij)  = aire(  ij    ) * teta(  ij    ,l)
+           tpps(ij)  = aire(ij+ip1jm) * teta(ij+ip1jm,l)
+          ENDDO
+
+           tpn  = SSUM(iim,tppn,1)/apoln
+           tps  = SSUM(iim,tpps,1)/apols
+
+          DO ij = 1, iip1
+           teta(  ij    ,l) = tpn
+           teta(ij+ip1jm,l) = tps
+          ENDDO
+        ENDDO
+
+        DO ij =  1,iim
+          tppn(ij)  = aire(  ij    ) * ps (  ij    )
+          tpps(ij)  = aire(ij+ip1jm) * ps (ij+ip1jm)
+        ENDDO
+          tpn  = SSUM(iim,tppn,1)/apoln
+
+          tps  = SSUM(iim,tpps,1)/apols
+
+        DO ij = 1, iip1
+          ps(  ij    ) = tpn
+          ps(ij+ip1jm) = tps
+        ENDDO
+
+
+
+
+
+
+
+      END IF
+        
+c   ********************************************************************
+c   ********************************************************************
+c   .... fin de l'integration dynamique  et physique pour le pas itau ..
+c   ********************************************************************
+c   ********************************************************************
+
+c   preparation du pas d'integration suivant  ......
+
+      IF ( .NOT.purmats ) THEN
+c       ........................................................
+c       ..............  schema matsuno + leapfrog  ..............
+c       ........................................................
+
+            IF(forward. OR. leapf) THEN
+              itau= itau + 1
+              iday= day_ini+itau/day_step
+              time= FLOAT(itau-(iday-day_ini)*day_step)/day_step+time_0
+                IF(time.GT.1.) THEN
+                  time = time-1.
+                  iday = iday+1
+                ENDIF
+            ENDIF
+
+
+            IF( itau. EQ. itaufinp1 ) then  
+              abort_message = 'Simulation finished'
+              call abort_gcm(modname,abort_message,0)
+            ENDIF
+c-----------------------------------------------------------------------
+c   ecriture du fichier histoire moyenne:
+c   -------------------------------------
+
+c           IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
+c              IF(itau.EQ.itaufin) THEN
+c                 iav=1
+c              ELSE
+c                 iav=0
+c              ENDIF
+c              CALL writedynav(histaveid, nqtot, itau,vcov ,
+c    ,                          ucov,teta,pk,phi,q,masse,ps,phis)
+c           ENDIF
+
+c-----------------------------------------------------------------------
+
+
+            IF(itau.EQ.itaufin) THEN
+
+
+       PRINT *,' Appel test_period avant redem ', itau
+       CALL test_period ( ucov,vcov,teta,q,p,phis )
+       CALL dynredem1("restart.nc",0.0,
+     .                     vcov,ucov,teta,q,masse,ps)
+
+              CLOSE(99)
+            ENDIF
+
+c-----------------------------------------------------------------------
+c   gestion de l'integration temporelle:
+c   ------------------------------------
+
+            IF( MOD(itau,iperiod).EQ.0 )    THEN
+                    GO TO 1
+            ELSE IF ( MOD(itau-1,iperiod). EQ. 0 ) THEN
+
+                   IF( forward )  THEN
+c      fin du pas forward et debut du pas backward
+
+                      forward = .FALSE.
+                        leapf = .FALSE.
+                           GO TO 2
+
+                   ELSE
+c      fin du pas backward et debut du premier pas leapfrog
+
+                        leapf =  .TRUE.
+                        dt  =  2.*dtvr
+                        GO TO 2
+                   END IF
+            ELSE
+
+c      ......   pas leapfrog  .....
+
+                 leapf = .TRUE.
+                 dt  = 2.*dtvr
+                 GO TO 2
+            END IF
+
+      ELSE
+
+c       ........................................................
+c       ..............       schema  matsuno        ...............
+c       ........................................................
+            IF( forward )  THEN
+
+             itau =  itau + 1
+             iday = day_ini+itau/day_step
+             time = FLOAT(itau-(iday-day_ini)*day_step)/day_step+time_0
+
+                  IF(time.GT.1.) THEN
+                   time = time-1.
+                   iday = iday+1
+                  ENDIF
+
+               forward =  .FALSE.
+               IF( itau. EQ. itaufinp1 ) then  
+                 abort_message = 'Simulation finished'
+                 call abort_gcm(modname,abort_message,0)
+               ENDIF
+               GO TO 2
+
+            ELSE
+
+            IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
+               IF(itau.EQ.itaufin) THEN
+                  iav=1
+               ELSE
+                  iav=0
+               ENDIF
+c              CALL writedynav(histaveid, nqtot, itau,vcov ,
+c    ,                          ucov,teta,pk,phi,q,masse,ps,phis)
+
+            ENDIF
+
+
+                 IF(itau.EQ.itaufin)
+     . CALL dynredem1("restart.nc",0.0,
+     .                     vcov,ucov,teta,q,nqtot,masse,ps)
+
+                 forward = .TRUE.
+                 GO TO  1
+
+
+            ENDIF
+
+      END IF
+
+      STOP
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/geopot.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/geopot.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/geopot.F	(revision 1644)
@@ -0,0 +1,68 @@
+      SUBROUTINE geopot (ngrid, teta, pk, pks, phis, phi )
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c    *******************************************************************
+c    ....   calcul du geopotentiel aux milieux des couches    .....
+c    *******************************************************************
+c
+c     ....   l'integration se fait de bas en haut  ....
+c
+c     .. ngrid,teta,pk,pks,phis sont des argum. d'entree pour le s-pg ..
+c              phi               est un  argum. de sortie pour le s-pg .
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+
+c   Arguments:
+c   ----------
+
+      INTEGER ngrid
+      REAL teta(ngrid,llm),pks(ngrid),phis(ngrid),pk(ngrid,llm) ,
+     *       phi(ngrid,llm)
+      real zz(ngrid)
+
+
+c   Local:
+c   ------
+
+      INTEGER  l, ij, count
+      logical flag 
+
+
+c-----------------------------------------------------------------------
+c     calcul de phi au niveau 1 pres du sol  .....
+
+      flag=.false.
+      count=0
+c     call dump2d(iip1,jjp1,teta(:,1),'TETA COUCHE 1')
+c     zz(:)=pks(:)-pk(:,1)
+c     call dump2d(iip1,jjp1,zz(:),'DPK SURF-1')
+
+      DO   ij  = 1, ngrid
+          phi( ij,1 ) = phis( ij ) + teta(ij,1) * ( pks(ij) - pk(ij,1) )
+      ENDDO
+
+c     calcul de phi aux niveaux superieurs  .......
+
+      DO  l = 2,llm
+        DO  ij    = 1,ngrid
+        phi(ij,l) = phi(ij,l-1) + 0.5 * ( teta(ij,l)  + teta(ij,l-1) ) 
+     *                              *   (  pk(ij,l-1) -  pk(ij,l)    )
+        ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/gr_int_dyn.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/gr_int_dyn.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/gr_int_dyn.F	(revision 1644)
@@ -0,0 +1,46 @@
+      subroutine gr_int_dyn(champin,champdyn,iim,jp1)
+      implicit none
+c=======================================================================
+c   passage d'un champ interpole a un champ sur grille scalaire
+c=======================================================================
+c-----------------------------------------------------------------------
+c   declarations:
+c   -------------
+
+      INTEGER iim
+      integer ip1, jp1
+      REAL champin(iim, jp1)
+      REAL champdyn(iim+1, jp1)
+
+      INTEGER i, j
+      real polenord, polesud
+
+c-----------------------------------------------------------------------
+c   calcul:
+c   -------
+
+      ip1 = iim + 1
+      polenord = 0.
+      polesud = 0.
+      do i = 1, iim
+        polenord = polenord + champin (i, 1)
+        polesud = polesud + champin (i, jp1)
+      enddo
+      polenord = polenord / iim
+      polesud = polesud / iim
+      do j = 1, jp1
+        do i = 1, iim
+          if (j .eq. 1) then
+            champdyn(i, j) = polenord
+          else if (j .eq. jp1) then
+            champdyn(i, j) = polesud
+          else
+            champdyn(i, j) = champin (i, j)
+          endif
+        enddo
+        champdyn(ip1, j) = champdyn(1, j)
+      enddo
+
+      RETURN
+      END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/gr_u_scal.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/gr_u_scal.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/gr_u_scal.F	(revision 1644)
@@ -0,0 +1,57 @@
+      SUBROUTINE gr_u_scal(nx,x_u,x_scal)
+c%W%    %G%
+c=======================================================================
+c
+c   Author:    Frederic Hourdin      original: 11/11/92
+c   -------
+c
+c   Subject:
+c   ------
+c
+c   Method:
+c   --------
+c
+c   Interface:
+c   ----------
+c
+c      Input:
+c      ------
+c
+c      Output:
+c      -------
+c
+c=======================================================================
+      IMPLICIT NONE
+c-----------------------------------------------------------------------
+c   Declararations:
+c   ---------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      INTEGER nx
+      REAL x_u(ip1jmp1,nx),x_scal(ip1jmp1,nx)
+
+c   Local:
+c   ------
+
+      INTEGER l,ij
+
+c-----------------------------------------------------------------------
+
+      DO l=1,nx
+         DO ij=ip1jmp1,2,-1
+            x_scal(ij,l)=
+     s      (aireu(ij)*x_u(ij,l)+aireu(ij-1)*x_u(ij-1,l))
+     s      /(aireu(ij)+aireu(ij-1))
+         ENDDO
+      ENDDO
+
+      CALL SCOPY(nx*jjp1,x_scal(iip1,1),iip1,x_scal(1,1),iip1)
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/gr_v_scal.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/gr_v_scal.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/gr_v_scal.F	(revision 1644)
@@ -0,0 +1,61 @@
+      SUBROUTINE gr_v_scal(nx,x_v,x_scal)
+c%W%    %G%
+c=======================================================================
+c
+c   Author:    Frederic Hourdin      original: 11/11/92
+c   -------
+c
+c   Subject:
+c   ------
+c
+c   Method:
+c   --------
+c
+c   Interface:
+c   ----------
+c
+c      Input:
+c      ------
+c
+c      Output:
+c      -------
+c
+c=======================================================================
+      IMPLICIT NONE
+c-----------------------------------------------------------------------
+c   Declararations:
+c   ---------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      INTEGER nx
+      REAL x_v(ip1jm,nx),x_scal(ip1jmp1,nx)
+
+c   Local:
+c   ------
+
+      INTEGER l,ij
+
+c-----------------------------------------------------------------------
+
+      DO l=1,nx
+         DO ij=iip2,ip1jm
+            x_scal(ij,l)=
+     s      (airev(ij-iip1)*x_v(ij-iip1,l)+airev(ij)*x_v(ij,l))
+     s      /(airev(ij-iip1)+airev(ij))
+         ENDDO
+         DO ij=1,iip1
+            x_scal(ij,l)=0.
+         ENDDO
+         DO ij=ip1jm+1,ip1jmp1
+            x_scal(ij,l)=0.
+         ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/grad.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/grad.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/grad.F	(revision 1644)
@@ -0,0 +1,41 @@
+      SUBROUTINE  grad(klevel, pg,pgx,pgy )
+c
+c      P. Le Van
+c
+c    ******************************************************************
+c     .. calcul des composantes covariantes en x et y du gradient de g
+c
+c    ******************************************************************
+c             pg        est un   argument  d'entree pour le s-prog
+c       pgx  et  pgy    sont des arguments de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+      INTEGER klevel
+      REAL  pg( ip1jmp1,klevel )
+      REAL pgx( ip1jmp1,klevel ) , pgy( ip1jm,klevel )
+      INTEGER  l,ij
+c
+c
+      DO 6 l = 1,klevel
+c
+      DO 2  ij = 1, ip1jmp1 - 1
+      pgx( ij,l ) = pg( ij +1,l ) - pg( ij,l )
+   2  CONTINUE
+c
+c    .... correction pour  pgx(ip1,j,l)  ....
+c    ...    pgx(iip1,j,l)= pgx(1,j,l)  ....
+CDIR$ IVDEP
+      DO 3  ij = iip1, ip1jmp1, iip1
+      pgx( ij,l ) = pgx( ij -iim,l )
+   3  CONTINUE
+c
+      DO 4 ij = 1,ip1jm
+      pgy( ij,l ) = pg( ij,l ) - pg( ij +iip1,l )
+   4  CONTINUE
+c
+   6  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/gradiv.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/gradiv.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/gradiv.F	(revision 1644)
@@ -0,0 +1,55 @@
+      SUBROUTINE gradiv(klevel, xcov, ycov, ld, gdx, gdy )
+c
+c    Auteur :   P. Le Van
+c
+c   ***************************************************************
+c
+c                                ld
+c       calcul  de  (grad (div) )   du vect. v ....
+c
+c     xcov et ycov etant les composant.covariantes de v
+c   ****************************************************************
+c    xcov , ycov et ld  sont des arguments  d'entree pour le s-prog
+c     gdx   et  gdy     sont des arguments de sortie pour le s-prog
+c
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissipn.h"
+
+      INTEGER klevel
+c
+      REAL xcov( ip1jmp1,klevel ), ycov( ip1jm,klevel )
+      REAL gdx( ip1jmp1,klevel ),   gdy( ip1jm,klevel )
+
+      REAL div(ip1jmp1,llm)
+
+      INTEGER l,ij,iter,ld
+c
+      EXTERNAL   SCOPY, diverg,  grad
+      EXTERNAL   filtreg
+c
+c
+      CALL SCOPY( ip1jmp1*klevel,xcov,1,gdx,1 )
+      CALL SCOPY( ip1jm*klevel,  ycov,1,gdy,1 )
+c
+      DO 10 iter = 1,ld
+c
+      CALL diverg( klevel,  gdx , gdy, div          )
+      CALL filtreg( div, jjp1, klevel, 2,1, .true.,2 )
+      CALL grad( klevel,  div, gdx, gdy           )
+c
+      DO 5  l = 1, klevel
+      DO 3 ij = 1, ip1jmp1
+      gdx( ij,l ) = - gdx( ij,l ) * cdivu
+   3  CONTINUE
+      DO 4 ij = 1, ip1jm
+      gdy( ij,l ) = - gdy( ij,l ) * cdivu
+   4  CONTINUE
+   5  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/gradiv2.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/gradiv2.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/gradiv2.F	(revision 1644)
@@ -0,0 +1,77 @@
+      SUBROUTINE gradiv2(klevel, xcov, ycov, ld, gdx, gdy )
+c
+c     P. Le Van
+c
+c   **********************************************************
+c                                ld
+c       calcul  de  (grad (div) )   du vect. v ....
+c
+c     xcov et ycov etant les composant.covariantes de v
+c   **********************************************************
+c     xcont , ycont et ld  sont des arguments  d'entree pour le s-prog
+c      gdx   et  gdy       sont des arguments de sortie pour le s-prog
+c
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "comdissipn.h"
+c
+c     ........    variables en arguments      ........
+
+      INTEGER klevel
+      REAL  xcov( ip1jmp1,klevel ), ycov( ip1jm,klevel )
+      REAL   gdx( ip1jmp1,klevel ),  gdy( ip1jm,klevel )
+c
+c     ........       variables locales       .........
+c
+      REAL div(ip1jmp1,llm)
+      REAL signe, nugrads
+      INTEGER l,ij,iter,ld
+      
+c    ........................................................
+c
+      EXTERNAL   SCOPY, divergf, grad, laplacien_gam, filtreg
+c
+      CALL SCOPY( ip1jmp1 * klevel, xcov, 1, gdx, 1 )
+      CALL SCOPY(   ip1jm * klevel, ycov, 1, gdy, 1 )
+c
+c
+      signe   = (-1.)**ld
+      nugrads = signe * cdivu
+c
+
+
+      CALL divergf( klevel, gdx,   gdy , div )
+
+      IF( ld.GT.1 )   THEN
+
+        CALL laplacien ( klevel, div,  div     )
+
+c    ......  Iteration de l'operateur laplacien_gam   .......
+
+        DO iter = 1, ld -2
+         CALL laplacien_gam ( klevel,cuvscvgam1,cvuscugam1,unsair_gam1,
+     *                       unsapolnga1, unsapolsga1,  div, div       )
+        ENDDO
+
+      ENDIF
+
+
+       CALL filtreg( div   , jjp1, klevel, 2, 1, .TRUE., 1 )
+       CALL grad  ( klevel,  div,   gdx,  gdy             )
+
+c
+       DO   l = 1, klevel
+         DO  ij = 1, ip1jmp1
+          gdx( ij,l ) = gdx( ij,l ) * nugrads
+         ENDDO
+         DO  ij = 1, ip1jm
+          gdy( ij,l ) = gdy( ij,l ) * nugrads
+         ENDDO
+       ENDDO
+c
+       RETURN
+       END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/grid_atob.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/grid_atob.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/grid_atob.F	(revision 1644)
@@ -0,0 +1,968 @@
+      SUBROUTINE grille_m(imdep, jmdep, xdata, ydata, entree,
+     .                    imar, jmar, x, y, sortie)
+c=======================================================================
+c z.x.li (le 1 avril 1994) (voir aussi A. Harzallah et L. Fairhead)
+c
+c Methode naive pour transformer un champ d'une grille fine a une
+c grille grossiere. Je considere que les nouveaux points occupent
+c une zone adjacente qui comprend un ou plusieurs anciens points
+c
+c Aucune ponderation est consideree (voir grille_p)
+c
+c           (c)
+c        ----d-----
+c        | . . . .|
+c        |        |
+c     (b)a . * . .b(a)
+c        |        |
+c        | . . . .|
+c        ----c-----
+c           (d)
+C=======================================================================
+c INPUT:
+c        imdep, jmdep: dimensions X et Y pour depart
+c        xdata, ydata: coordonnees X et Y pour depart
+c        entree: champ d'entree a transformer
+c OUTPUT:
+c        imar, jmar: dimensions X et Y d'arrivee
+c        x, y: coordonnees X et Y d'arrivee
+c        sortie: champ de sortie deja transforme
+C=======================================================================
+      IMPLICIT none
+
+      INTEGER imdep, jmdep
+      REAL xdata(imdep),ydata(jmdep) 
+      REAL entree(imdep,jmdep)
+c
+      INTEGER imar, jmar
+      REAL x(imar),y(jmar)
+      REAL sortie(imar,jmar)
+c
+      INTEGER i, j, ii, jj
+      REAL a(2200),b(2200),c(1100),d(1100)
+      REAL number(2200,1100)
+      REAL distans(2200*1100)
+      INTEGER i_proche, j_proche, ij_proche
+#ifdef CRAY
+      INTEGER ISMIN
+#else
+      REAL zzmin
+#endif
+c
+      IF (imar.GT.2200 .OR. jmar.GT.1100) THEN
+         PRINT*, 'imar ou jmar trop grand', imar, jmar
+         CALL ABORT
+      ENDIF
+c
+c Calculer les limites des zones des nouveaux points
+c
+
+      a(1) = x(1) - (x(2)-x(1))/2.0
+      b(1) = (x(1)+x(2))/2.0
+      DO i = 2, imar-1
+         a(i) = b(i-1)
+         b(i) = (x(i)+x(i+1))/2.0
+      ENDDO
+      a(imar) = b(imar-1)
+      b(imar) = x(imar) + (x(imar)-x(imar-1))/2.0
+
+      c(1) = y(1) - (y(2)-y(1))/2.0
+      d(1) = (y(1)+y(2))/2.0
+      DO j = 2, jmar-1
+         c(j) = d(j-1)
+         d(j) = (y(j)+y(j+1))/2.0
+      ENDDO
+      c(jmar) = d(jmar-1)
+      d(jmar) = y(jmar) + (y(jmar)-y(jmar-1))/2.0
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         number(i,j) = 0.0
+         sortie(i,j) = 0.0
+      ENDDO
+      ENDDO
+c
+c Determiner la zone sur laquelle chaque ancien point se trouve
+c
+c
+c  .....  Modif  P. Le Van ( 23/08/95 )  ....
+
+      DO ii = 1, imar
+      DO jj = 1, jmar
+        DO i = 1, imdep
+         IF( ( xdata(i)-a(ii).GE.1.e-5.AND.xdata(i)-b(ii).LE.1.e-5 ).OR.
+     .     (   xdata(i)-a(ii).LE.1.e-5.AND.xdata(i)-b(ii).GE.1.e-5 )   )
+     .           THEN
+          DO j = 1, jmdep
+          IF( (ydata(j)-c(jj).GE.1.e-5.AND.ydata(j)-d(jj).LE.1.e-5 ).OR.
+     .      (  ydata(j)-c(jj).LE.1.e-5.AND.ydata(j)-d(jj).GE.1.e-5 )   )
+     .           THEN
+               number(ii,jj) = number(ii,jj) + 1.0
+               sortie(ii,jj) = sortie(ii,jj) + entree(i,j)
+          ENDIF
+          ENDDO
+         ENDIF
+        ENDDO
+      ENDDO
+      ENDDO
+c
+c Si aucun ancien point tombe sur une zone, c'est un probleme
+c
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         IF (number(i,j) .GT. 0.001) THEN
+         sortie(i,j) = sortie(i,j) / number(i,j)
+         ELSE
+         PRINT*, 'probleme,i,j=', i,j
+ccc         CALL ABORT
+         CALL dist_sphe(x(i),y(j),xdata,ydata,imdep,jmdep,distans)
+#ifdef CRAY
+         ij_proche = ISMIN(imdep*jmdep,distans,1)
+#else
+         ij_proche = 1
+         zzmin = distans(ij_proche)
+         DO ii = 2, imdep*jmdep
+            IF (distans(ii).LT.zzmin) THEN
+               zzmin = distans(ii)
+               ij_proche = ii
+            ENDIF
+         ENDDO
+#endif
+         j_proche = (ij_proche-1)/imdep + 1
+         i_proche = ij_proche - (j_proche-1)*imdep
+         PRINT*, "solution:", ij_proche, i_proche, j_proche
+         sortie(i,j) = entree(i_proche,j_proche)
+         ENDIF
+      ENDDO
+      ENDDO
+
+      RETURN
+      END
+
+
+      SUBROUTINE grille_p(imdep, jmdep, xdata, ydata, entree,
+     .                    imar, jmar, x, y, sortie)
+c=======================================================================
+c z.x.li (le 1 avril 1994) (voir aussi A. Harzallah et L. Fairhead)
+c
+c Methode naive pour transformer un champ d'une grille fine a une
+c grille grossiere. Je considere que les nouveaux points occupent
+c une zone adjacente qui comprend un ou plusieurs anciens points
+c
+c Consideration de la distance des points (voir grille_m)
+c
+c           (c)
+c        ----d-----
+c        | . . . .|
+c        |        |
+c     (b)a . * . .b(a)
+c        |        |
+c        | . . . .|
+c        ----c-----
+c           (d)
+C=======================================================================
+c INPUT:
+c        imdep, jmdep: dimensions X et Y pour depart
+c        xdata, ydata: coordonnees X et Y pour depart
+c        entree: champ d'entree a transformer
+c OUTPUT:
+c        imar, jmar: dimensions X et Y d'arrivee
+c        x, y: coordonnees X et Y d'arrivee
+c        sortie: champ de sortie deja transforme
+C=======================================================================
+      IMPLICIT none
+
+      INTEGER imdep, jmdep
+      REAL xdata(imdep),ydata(jmdep) 
+      REAL entree(imdep,jmdep)
+c
+      INTEGER imar, jmar
+      REAL x(imar),y(jmar)
+      REAL sortie(imar,jmar)
+c
+      INTEGER i, j, ii, jj
+      REAL a(400),b(400),c(200),d(200)
+      REAL number(400,200)
+      INTEGER indx(400,200), indy(400,200)
+      REAL dist(400,200), distsom(400,200)
+c
+      IF (imar.GT.400 .OR. jmar.GT.200) THEN
+         PRINT*, 'imar ou jmar trop grand', imar, jmar
+         CALL ABORT
+      ENDIF
+c
+      IF (imdep.GT.400 .OR. jmdep.GT.200) THEN
+         PRINT*, 'imdep ou jmdep trop grand', imdep, jmdep
+         CALL ABORT
+      ENDIF
+c
+c calculer les bords a et b de la nouvelle grille
+c
+      a(1) = x(1) - (x(2)-x(1))/2.0
+      b(1) = (x(1)+x(2))/2.0
+      DO i = 2, imar-1
+         a(i) = b(i-1)
+         b(i) = (x(i)+x(i+1))/2.0
+      ENDDO
+      a(imar) = b(imar-1)
+      b(imar) = x(imar) + (x(imar)-x(imar-1))/2.0
+
+c
+c calculer les bords c et d de la nouvelle grille
+c
+      c(1) = y(1) - (y(2)-y(1))/2.0
+      d(1) = (y(1)+y(2))/2.0
+      DO j = 2, jmar-1
+         c(j) = d(j-1)
+         d(j) = (y(j)+y(j+1))/2.0
+      ENDDO
+      c(jmar) = d(jmar-1)
+      d(jmar) = y(jmar) + (y(jmar)-y(jmar-1))/2.0
+
+c
+c trouver les indices (indx,indy) de la nouvelle grille sur laquelle
+c un point de l'ancienne grille est tombe.
+c
+c
+c  .....  Modif  P. Le Van ( 23/08/95 )  ....
+
+      DO ii = 1, imar
+      DO jj = 1, jmar
+        DO i = 1, imdep
+         IF( ( xdata(i)-a(ii).GE.1.e-5.AND.xdata(i)-b(ii).LE.1.e-5 ).OR.
+     .     (   xdata(i)-a(ii).LE.1.e-5.AND.xdata(i)-b(ii).GE.1.e-5 )   )
+     .           THEN
+          DO j = 1, jmdep
+          IF( (ydata(j)-c(jj).GE.1.e-5.AND.ydata(j)-d(jj).LE.1.e-5 ).OR.
+     .      (  ydata(j)-c(jj).LE.1.e-5.AND.ydata(j)-d(jj).GE.1.e-5 )   )
+     .           THEN
+               indx(i,j) = ii
+               indy(i,j) = jj
+          ENDIF
+          ENDDO
+         ENDIF
+        ENDDO
+      ENDDO
+      ENDDO
+c
+c faire une verification
+c
+
+      DO i = 1, imdep
+      DO j = 1, jmdep
+         IF (indx(i,j).GT.imar .OR. indy(i,j).GT.jmar) THEN
+            PRINT*, 'Probleme grave,i,j,indx,indy=',
+     .              i,j,indx(i,j),indy(i,j)
+            CALL abort
+         ENDIF
+      ENDDO
+      ENDDO
+
+c
+c calculer la distance des anciens points avec le nouveau point,
+c on prend ensuite une sorte d'inverse pour ponderation.
+c
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         number(i,j) = 0.0
+         distsom(i,j) = 0.0
+      ENDDO
+      ENDDO
+      DO i = 1, imdep
+      DO j = 1, jmdep
+         dist(i,j) = SQRT ( (xdata(i)-x(indx(i,j)))**2
+     .                     +(ydata(j)-y(indy(i,j)))**2 )
+         distsom(indx(i,j),indy(i,j)) = distsom(indx(i,j),indy(i,j))
+     .                                  + dist(i,j)
+         number(indx(i,j),indy(i,j)) = number(indx(i,j),indy(i,j)) +1.
+      ENDDO
+      ENDDO
+      DO i = 1, imdep
+      DO j = 1, jmdep
+         dist(i,j) = 1.0 - dist(i,j)/distsom(indx(i,j),indy(i,j))
+      ENDDO
+      ENDDO
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         number(i,j) = 0.0
+         sortie(i,j) = 0.0
+      ENDDO
+      ENDDO
+      DO i = 1, imdep
+      DO j = 1, jmdep
+         sortie(indx(i,j),indy(i,j)) = sortie(indx(i,j),indy(i,j))
+     .                                 + entree(i,j) * dist(i,j)
+         number(indx(i,j),indy(i,j)) = number(indx(i,j),indy(i,j))
+     .                                 + dist(i,j)
+      ENDDO
+      ENDDO
+      DO i = 1, imar
+      DO j = 1, jmar
+         IF (number(i,j) .GT. 0.001) THEN
+         sortie(i,j) = sortie(i,j) / number(i,j)
+         ELSE
+         PRINT*, 'probleme,i,j=', i,j
+         CALL ABORT
+         ENDIF
+      ENDDO
+      ENDDO
+
+      RETURN
+      END
+
+
+
+
+      SUBROUTINE mask_c_o(imdep, jmdep, xdata, ydata, relief,
+     .                    imar, jmar, x, y, mask)
+c=======================================================================
+c z.x.li (le 1 avril 1994): A partir du champ de relief, on fabrique
+c                           un champ indicateur (masque) terre/ocean
+c                           terre:1; ocean:0
+c
+c Methode naive (voir grille_m)
+C=======================================================================
+      IMPLICIT none
+
+      INTEGER imdep, jmdep
+      REAL xdata(imdep),ydata(jmdep) 
+      REAL relief(imdep,jmdep)
+c
+      INTEGER imar, jmar
+      REAL x(imar),y(jmar)
+      REAL mask(imar,jmar)
+c
+      INTEGER i, j, ii, jj
+      REAL a(2200),b(2200),c(1100),d(1100)
+      REAL num_tot(2200,1100), num_oce(2200,1100)
+c
+      IF (imar.GT.2200 .OR. jmar.GT.1100) THEN
+         PRINT*, 'imar ou jmar trop grand', imar, jmar
+         CALL ABORT
+      ENDIF
+c
+
+      a(1) = x(1) - (x(2)-x(1))/2.0
+      b(1) = (x(1)+x(2))/2.0
+      DO i = 2, imar-1
+         a(i) = b(i-1)
+         b(i) = (x(i)+x(i+1))/2.0
+      ENDDO
+      a(imar) = b(imar-1)
+      b(imar) = x(imar) + (x(imar)-x(imar-1))/2.0
+
+      c(1) = y(1) - (y(2)-y(1))/2.0
+      d(1) = (y(1)+y(2))/2.0
+      DO j = 2, jmar-1
+         c(j) = d(j-1)
+         d(j) = (y(j)+y(j+1))/2.0
+      ENDDO
+      c(jmar) = d(jmar-1)
+      d(jmar) = y(jmar) + (y(jmar)-y(jmar-1))/2.0
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         num_oce(i,j) = 0.0
+         num_tot(i,j) = 0.0
+      ENDDO
+      ENDDO
+
+c
+c  .....  Modif  P. Le Van ( 23/08/95 )  ....
+
+      DO ii = 1, imar
+      DO jj = 1, jmar
+        DO i = 1, imdep
+         IF( ( xdata(i)-a(ii).GE.1.e-5.AND.xdata(i)-b(ii).LE.1.e-5 ).OR.
+     .     (   xdata(i)-a(ii).LE.1.e-5.AND.xdata(i)-b(ii).GE.1.e-5 )   )
+     .           THEN
+          DO j = 1, jmdep
+          IF( (ydata(j)-c(jj).GE.1.e-5.AND.ydata(j)-d(jj).LE.1.e-5 ).OR.
+     .      (  ydata(j)-c(jj).LE.1.e-5.AND.ydata(j)-d(jj).GE.1.e-5 )   )
+     .           THEN
+               num_tot(ii,jj) = num_tot(ii,jj) + 1.0
+               IF (.NOT. ( relief(i,j) - 0.9. GE. 1.e-5 ) )
+     .             num_oce(ii,jj) = num_oce(ii,jj) + 1.0
+          ENDIF
+          ENDDO
+         ENDIF
+        ENDDO
+      ENDDO
+      ENDDO
+c
+c
+c
+      DO i = 1, imar
+      DO j = 1, jmar
+         IF (num_tot(i,j) .GT. 0.001) THEN
+           IF ( num_oce(i,j)/num_tot(i,j) - 0.5 .GE. 1.e-5 ) THEN
+              mask(i,j) = 0.
+           ELSE
+              mask(i,j) = 1.
+           ENDIF
+         ELSE
+         PRINT*, 'probleme,i,j=', i,j
+         CALL ABORT
+         ENDIF
+      ENDDO
+      ENDDO
+
+      RETURN
+      END
+c
+c
+
+
+      SUBROUTINE rugosite(imdep, jmdep, xdata, ydata, entree,
+     .                    imar, jmar, x, y, sortie, mask)
+c=======================================================================
+c z.x.li (le 1 avril 1994): Transformer la longueur de rugosite d'une
+c grille fine a une grille grossiere. Sur l'ocean, on impose une valeur
+c fixe (0.001m).
+c
+c Methode naive (voir grille_m)
+C=======================================================================
+      IMPLICIT none
+
+      INTEGER imdep, jmdep
+      REAL xdata(imdep),ydata(jmdep) 
+      REAL entree(imdep,jmdep)
+c
+      INTEGER imar, jmar
+      REAL x(imar),y(jmar)
+      REAL sortie(imar,jmar), mask(imar,jmar)
+c
+      INTEGER i, j, ii, jj
+      REAL a(400),b(400),c(400),d(400)
+      REAL num_tot(400,400)
+      REAL distans(400*400)
+      INTEGER i_proche, j_proche, ij_proche
+#ifdef CRAY
+      INTEGER ISMIN
+#else
+      REAL zzmin
+#endif
+c
+      IF (imar.GT.400 .OR. jmar.GT.400) THEN
+         PRINT*, 'imar ou jmar trop grand', imar, jmar
+         CALL ABORT
+      ENDIF
+c
+
+      a(1) = x(1) - (x(2)-x(1))/2.0
+      b(1) = (x(1)+x(2))/2.0
+      DO i = 2, imar-1
+         a(i) = b(i-1)
+         b(i) = (x(i)+x(i+1))/2.0
+      ENDDO
+      a(imar) = b(imar-1)
+      b(imar) = x(imar) + (x(imar)-x(imar-1))/2.0
+
+      c(1) = y(1) - (y(2)-y(1))/2.0
+      d(1) = (y(1)+y(2))/2.0
+      DO j = 2, jmar-1
+         c(j) = d(j-1)
+         d(j) = (y(j)+y(j+1))/2.0
+      ENDDO
+      c(jmar) = d(jmar-1)
+      d(jmar) = y(jmar) + (y(jmar)-y(jmar-1))/2.0
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         num_tot(i,j) = 0.0
+         sortie(i,j) = 0.0
+      ENDDO
+      ENDDO
+
+c
+c
+c  .....  Modif  P. Le Van ( 23/08/95 )  ....
+
+      DO ii = 1, imar
+      DO jj = 1, jmar
+        DO i = 1, imdep
+         IF( ( xdata(i)-a(ii).GE.1.e-5.AND.xdata(i)-b(ii).LE.1.e-5 ).OR.
+     .     (   xdata(i)-a(ii).LE.1.e-5.AND.xdata(i)-b(ii).GE.1.e-5 )   )
+     .           THEN
+          DO j = 1, jmdep
+          IF( (ydata(j)-c(jj).GE.1.e-5.AND.ydata(j)-d(jj).LE.1.e-5 ).OR.
+     .      (  ydata(j)-c(jj).LE.1.e-5.AND.ydata(j)-d(jj).GE.1.e-5 )   )
+     .           THEN
+              sortie(ii,jj)  = sortie(ii,jj) + LOG(entree(i,j))
+              num_tot(ii,jj) = num_tot(ii,jj) + 1.0
+          ENDIF
+          ENDDO
+         ENDIF
+        ENDDO
+      ENDDO
+      ENDDO
+c
+
+      DO i = 1, imar
+      DO j = 1, jmar
+       IF (NINT(mask(i,j)).EQ.1) THEN
+         IF (num_tot(i,j) .GT. 0.0) THEN
+            sortie(i,j) = sortie(i,j) / num_tot(i,j)
+            sortie(i,j) = EXP(sortie(i,j))
+         ELSE
+            PRINT*, 'probleme,i,j=', i,j
+ccc            CALL ABORT
+         CALL dist_sphe(x(i),y(j),xdata,ydata,imdep,jmdep,distans)
+#ifdef CRAY
+         ij_proche = ISMIN(imdep*jmdep,distans,1)
+#else
+         ij_proche = 1
+         zzmin = distans(ij_proche)
+         DO ii = 2, imdep*jmdep
+            IF (distans(ii).LT.zzmin) THEN
+               zzmin = distans(ii)
+               ij_proche = ii
+            ENDIF
+         ENDDO
+#endif
+         j_proche = (ij_proche-1)/imdep + 1
+         i_proche = ij_proche - (j_proche-1)*imdep
+         PRINT*, "solution:", ij_proche, i_proche, j_proche
+         sortie(i,j) = entree(i_proche,j_proche)
+         ENDIF
+       ELSE
+         sortie(i,j) = 0.001
+       ENDIF
+      ENDDO
+      ENDDO
+
+      RETURN
+      END
+
+
+
+
+
+      SUBROUTINE sea_ice(imdep, jmdep, xdata, ydata, glace01,
+     .                    imar, jmar, x, y, frac_ice)
+c=======================================================================
+c z.x.li (le 1 avril 1994): Transformer un champ d'indicateur de la
+c glace (1, sinon 0) d'une grille fine a un champ de fraction de glace
+c (entre 0 et 1) dans une grille plus grossiere.
+c
+c Methode naive (voir grille_m)
+C=======================================================================
+      IMPLICIT none
+
+      INTEGER imdep, jmdep
+      REAL xdata(imdep),ydata(jmdep) 
+      REAL glace01(imdep,jmdep)
+c
+      INTEGER imar, jmar
+      REAL x(imar),y(jmar)
+      REAL frac_ice(imar,jmar)
+c
+      INTEGER i, j, ii, jj
+      REAL a(400),b(400),c(400),d(400)
+      REAL num_tot(400,400), num_ice(400,400)
+      REAL distans(400*400)
+      INTEGER i_proche, j_proche, ij_proche
+#ifdef CRAY
+      INTEGER ISMIN
+#else
+      REAL zzmin
+#endif
+c
+      IF (imar.GT.400 .OR. jmar.GT.400) THEN
+         PRINT*, 'imar ou jmar trop grand', imar, jmar
+         CALL ABORT
+      ENDIF
+c
+
+      a(1) = x(1) - (x(2)-x(1))/2.0
+      b(1) = (x(1)+x(2))/2.0
+      DO i = 2, imar-1
+         a(i) = b(i-1)
+         b(i) = (x(i)+x(i+1))/2.0
+      ENDDO
+      a(imar) = b(imar-1)
+      b(imar) = x(imar) + (x(imar)-x(imar-1))/2.0
+
+      c(1) = y(1) - (y(2)-y(1))/2.0
+      d(1) = (y(1)+y(2))/2.0
+      DO j = 2, jmar-1
+         c(j) = d(j-1)
+         d(j) = (y(j)+y(j+1))/2.0
+      ENDDO
+      c(jmar) = d(jmar-1)
+      d(jmar) = y(jmar) + (y(jmar)-y(jmar-1))/2.0
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         num_ice(i,j) = 0.0
+         num_tot(i,j) = 0.0
+      ENDDO
+      ENDDO
+
+c
+c
+c  .....  Modif  P. Le Van ( 23/08/95 )  ....
+
+      DO ii = 1, imar
+      DO jj = 1, jmar
+        DO i = 1, imdep
+         IF( ( xdata(i)-a(ii).GE.1.e-5.AND.xdata(i)-b(ii).LE.1.e-5 ).OR.
+     .     (   xdata(i)-a(ii).LE.1.e-5.AND.xdata(i)-b(ii).GE.1.e-5 )   )
+     .           THEN
+          DO j = 1, jmdep
+          IF( (ydata(j)-c(jj).GE.1.e-5.AND.ydata(j)-d(jj).LE.1.e-5 ).OR.
+     .      (  ydata(j)-c(jj).LE.1.e-5.AND.ydata(j)-d(jj).GE.1.e-5 )   )
+     .           THEN
+             num_tot(ii,jj) = num_tot(ii,jj) + 1.0
+              IF (NINT(glace01(i,j)).EQ.1 ) 
+     .       num_ice(ii,jj) = num_ice(ii,jj) + 1.0
+          ENDIF
+          ENDDO
+         ENDIF
+        ENDDO
+      ENDDO
+      ENDDO
+c
+c
+
+      DO i = 1, imar
+      DO j = 1, jmar
+         IF (num_tot(i,j) .GT. 0.001) THEN
+           IF (num_ice(i,j).GT.0.001) THEN
+            frac_ice(i,j) = num_ice(i,j) / num_tot(i,j)
+           ELSE
+              frac_ice(i,j) = 0.0
+           ENDIF
+         ELSE
+           PRINT*, 'probleme,i,j=', i,j
+ccc           CALL ABORT
+         CALL dist_sphe(x(i),y(j),xdata,ydata,imdep,jmdep,distans)
+#ifdef CRAY
+         ij_proche = ISMIN(imdep*jmdep,distans,1)
+#else
+         ij_proche = 1
+         zzmin = distans(ij_proche)
+         DO ii = 2, imdep*jmdep
+            IF (distans(ii).LT.zzmin) THEN
+               zzmin = distans(ii)
+               ij_proche = ii
+            ENDIF
+         ENDDO
+#endif
+         j_proche = (ij_proche-1)/imdep + 1
+         i_proche = ij_proche - (j_proche-1)*imdep
+         PRINT*, "solution:", ij_proche, i_proche, j_proche
+         IF (NINT(glace01(i_proche,j_proche)).EQ.1 ) THEN
+            frac_ice(i,j) = 1.0
+         ELSE
+            frac_ice(i,j) = 0.0
+         ENDIF
+         ENDIF
+      ENDDO
+      ENDDO
+
+      RETURN
+      END
+
+
+
+      SUBROUTINE rugsoro(imrel, jmrel, xrel, yrel, relief,
+     .                    immod, jmmod, xmod, ymod, rugs)
+c=======================================================================
+c Calculer la longueur de rugosite liee au relief en utilisant
+c l'ecart-type dans une maille de 1x1
+C=======================================================================
+      IMPLICIT none
+c
+#ifdef CRAY
+      INTEGER ISMIN
+#else
+      REAL zzmin
+#endif
+c
+      REAL amin, AMAX
+c
+      INTEGER imrel, jmrel
+      REAL xrel(imrel),yrel(jmrel)
+      REAL relief(imrel,jmrel)
+c
+      INTEGER immod, jmmod
+      REAL xmod(immod),ymod(jmmod)
+      REAL rugs(immod,jmmod)
+c
+      INTEGER imtmp, jmtmp
+      PARAMETER (imtmp=360,jmtmp=180)
+      REAL xtmp(imtmp), ytmp(jmtmp)
+      REAL*8 cham1tmp(imtmp,jmtmp), cham2tmp(imtmp,jmtmp)
+      REAL zzzz
+c
+      INTEGER i, j, ii, jj
+      REAL a(2200),b(2200),c(1100),d(1100)
+      REAL number(2200,1100)
+c
+      REAL distans(400*400)
+      INTEGER i_proche, j_proche, ij_proche
+c
+      IF (immod.GT.2200 .OR. jmmod.GT.1100) THEN
+         PRINT*, 'immod ou jmmod trop grand', immod, jmmod
+         CALL ABORT
+      ENDIF
+c
+c Calculs intermediares:
+c
+      xtmp(1) = -180.0 + 360.0/FLOAT(imtmp) / 2.0
+      DO i = 2, imtmp
+         xtmp(i) = xtmp(i-1) + 360.0/FLOAT(imtmp)
+      ENDDO
+      DO i = 1, imtmp
+         xtmp(i) = xtmp(i) /180.0 * 4.0*ATAN(1.0)
+      ENDDO
+      ytmp(1) = -90.0 + 180.0/FLOAT(jmtmp) / 2.0
+      DO j = 2, jmtmp
+         ytmp(j) = ytmp(j-1) + 180.0/FLOAT(jmtmp)
+      ENDDO
+      DO j = 1, jmtmp
+         ytmp(j) = ytmp(j) /180.0 * 4.0*ATAN(1.0)
+      ENDDO
+c
+      a(1) = xtmp(1) - (xtmp(2)-xtmp(1))/2.0
+      b(1) = (xtmp(1)+xtmp(2))/2.0
+      DO i = 2, imtmp-1
+         a(i) = b(i-1)
+         b(i) = (xtmp(i)+xtmp(i+1))/2.0
+      ENDDO
+      a(imtmp) = b(imtmp-1)
+      b(imtmp) = xtmp(imtmp) + (xtmp(imtmp)-xtmp(imtmp-1))/2.0
+
+      c(1) = ytmp(1) - (ytmp(2)-ytmp(1))/2.0
+      d(1) = (ytmp(1)+ytmp(2))/2.0
+      DO j = 2, jmtmp-1
+         c(j) = d(j-1)
+         d(j) = (ytmp(j)+ytmp(j+1))/2.0
+      ENDDO
+      c(jmtmp) = d(jmtmp-1)
+      d(jmtmp) = ytmp(jmtmp) + (ytmp(jmtmp)-ytmp(jmtmp-1))/2.0
+
+      DO i = 1, imtmp
+      DO j = 1, jmtmp
+         number(i,j) = 0.0
+         cham1tmp(i,j) = 0.0
+         cham2tmp(i,j) = 0.0
+      ENDDO
+      ENDDO
+c
+c
+c
+c  .....  Modif  P. Le Van ( 23/08/95 )  ....
+
+      DO ii = 1, imtmp
+      DO jj = 1, jmtmp
+        DO i = 1, imrel
+         IF( ( xrel(i)-a(ii).GE.1.e-5.AND.xrel(i)-b(ii).LE.1.e-5 ).OR.
+     .     (   xrel(i)-a(ii).LE.1.e-5.AND.xrel(i)-b(ii).GE.1.e-5 )   )
+     .           THEN
+          DO j = 1, jmrel
+          IF( (yrel(j)-c(jj).GE.1.e-5.AND.yrel(j)-d(jj).LE.1.e-5 ).OR.
+     .      (  yrel(j)-c(jj).LE.1.e-5.AND.yrel(j)-d(jj).GE.1.e-5 )   )
+     .           THEN
+              number(ii,jj) = number(ii,jj) + 1.0
+              cham1tmp(ii,jj) = cham1tmp(ii,jj) + relief(i,j)
+              cham2tmp(ii,jj) = cham2tmp(ii,jj) 
+     .                              + relief(i,j)*relief(i,j)
+          ENDIF
+          ENDDO
+         ENDIF
+        ENDDO
+      ENDDO
+      ENDDO
+c
+c
+      DO i = 1, imtmp
+      DO j = 1, jmtmp
+         IF (number(i,j) .GT. 0.001) THEN
+         cham1tmp(i,j) = cham1tmp(i,j) / number(i,j)
+         cham2tmp(i,j) = cham2tmp(i,j) / number(i,j)
+         zzzz=cham2tmp(i,j)-cham1tmp(i,j)**2
+         if (zzzz .lt. 0.0) then
+           if (zzzz .gt. -7.5) then
+             zzzz = 0.0
+             print*,'Pb rugsoro, -7.5 < zzzz < 0, => zzz = 0.0'
+           else
+              stop 'Pb rugsoro, zzzz <-7.5'
+           endif
+         endif
+         cham2tmp(i,j) = SQRT(zzzz)
+         ELSE
+         PRINT*, 'probleme,i,j=', i,j
+         CALL ABORT
+         ENDIF
+      ENDDO
+      ENDDO
+c
+      amin = cham2tmp(1,1)
+      AMAX = cham2tmp(1,1)
+      DO j = 1, jmtmp
+      DO i = 1, imtmp
+         IF (cham2tmp(i,j).GT.AMAX) AMAX = cham2tmp(i,j)
+         IF (cham2tmp(i,j).LT.amin) amin = cham2tmp(i,j)
+      ENDDO
+      ENDDO
+      PRINT*, 'Ecart-type 1x1:', amin, AMAX
+c
+c
+c
+      a(1) = xmod(1) - (xmod(2)-xmod(1))/2.0
+      b(1) = (xmod(1)+xmod(2))/2.0
+      DO i = 2, immod-1
+         a(i) = b(i-1)
+         b(i) = (xmod(i)+xmod(i+1))/2.0
+      ENDDO
+      a(immod) = b(immod-1)
+      b(immod) = xmod(immod) + (xmod(immod)-xmod(immod-1))/2.0
+
+      c(1) = ymod(1) - (ymod(2)-ymod(1))/2.0
+      d(1) = (ymod(1)+ymod(2))/2.0
+      DO j = 2, jmmod-1
+         c(j) = d(j-1)
+         d(j) = (ymod(j)+ymod(j+1))/2.0
+      ENDDO
+      c(jmmod) = d(jmmod-1)
+      d(jmmod) = ymod(jmmod) + (ymod(jmmod)-ymod(jmmod-1))/2.0
+c
+      DO i = 1, immod
+      DO j = 1, jmmod
+         number(i,j) = 0.0
+         rugs(i,j) = 0.0
+      ENDDO
+      ENDDO
+c
+c
+c
+c  .....  Modif  P. Le Van ( 23/08/95 )  ....
+
+      DO ii = 1, immod
+      DO jj = 1, jmmod
+        DO i = 1, imtmp
+         IF( ( xtmp(i)-a(ii).GE.1.e-5.AND.xtmp(i)-b(ii).LE.1.e-5 ).OR.
+     .     (   xtmp(i)-a(ii).LE.1.e-5.AND.xtmp(i)-b(ii).GE.1.e-5 )   )
+     .           THEN
+          DO j = 1, jmtmp
+          IF( (ytmp(j)-c(jj).GE.1.e-5.AND.ytmp(j)-d(jj).LE.1.e-5 ).OR.
+     .      (  ytmp(j)-c(jj).LE.1.e-5.AND.ytmp(j)-d(jj).GE.1.e-5 )   )
+     .           THEN
+              number(ii,jj) = number(ii,jj) + 1.0
+              rugs(ii,jj) = rugs(ii,jj)
+     .                       + LOG(MAX(0.001,real(cham2tmp(i,j))))
+          ENDIF
+          ENDDO
+         ENDIF
+        ENDDO
+      ENDDO
+      ENDDO
+c
+c
+      DO i = 1, immod
+      DO j = 1, jmmod
+         IF (number(i,j) .GT. 0.001) THEN
+         rugs(i,j) = rugs(i,j) / number(i,j)
+         rugs(i,j) = EXP(rugs(i,j))
+         ELSE
+         PRINT*, 'probleme,i,j=', i,j
+ccc         CALL ABORT
+         CALL dist_sphe(xmod(i),ymod(j),xtmp,ytmp,imtmp,jmtmp,distans)
+#ifdef CRAY
+         ij_proche = ISMIN(imtmp*jmtmp,distans,1)
+#else
+         ij_proche = 1
+         zzmin = distans(ij_proche)
+         DO ii = 2, imtmp*jmtmp
+            IF (distans(ii).LT.zzmin) THEN
+               zzmin = distans(ii)
+               ij_proche = ii
+            ENDIF
+         ENDDO
+#endif
+         j_proche = (ij_proche-1)/imtmp + 1
+         i_proche = ij_proche - (j_proche-1)*imtmp
+         PRINT*, "solution:", ij_proche, i_proche, j_proche
+         rugs(i,j) = LOG(MAX(0.001,real(cham2tmp(i_proche,j_proche))))
+         ENDIF
+      ENDDO
+      ENDDO
+c
+      amin = rugs(1,1)
+      AMAX = rugs(1,1)
+      DO j = 1, jmmod
+      DO i = 1, immod
+         IF (rugs(i,j).GT.AMAX) AMAX = rugs(i,j)
+         IF (rugs(i,j).LT.amin) amin = rugs(i,j)
+      ENDDO
+      ENDDO
+      PRINT*, 'Ecart-type du modele:', amin, AMAX
+c
+      DO j = 1, jmmod
+      DO i = 1, immod
+         rugs(i,j) = rugs(i,j) / AMAX * 20.0
+      ENDDO
+      ENDDO
+c
+      amin = rugs(1,1)
+      AMAX = rugs(1,1)
+      DO j = 1, jmmod
+      DO i = 1, immod
+         IF (rugs(i,j).GT.AMAX) AMAX = rugs(i,j)
+         IF (rugs(i,j).LT.amin) amin = rugs(i,j)
+      ENDDO
+      ENDDO
+      PRINT*, 'Longueur de rugosite du modele:', amin, AMAX
+c
+      RETURN
+      END
+c
+      SUBROUTINE dist_sphe(rf_lon,rf_lat,rlon,rlat,im,jm,distance)
+c
+c Auteur: Laurent Li (le 30 decembre 1996)
+c
+c Ce programme calcule la distance minimale (selon le grand cercle)
+c entre deux points sur la terre
+c
+c Input:
+      INTEGER im, jm ! dimensions
+      REAL rf_lon ! longitude du point de reference (degres)
+      REAL rf_lat ! latitude du point de reference (degres)
+      REAL rlon(im), rlat(jm) ! longitude et latitude des points
+c
+c Output:
+      REAL distance(im,jm) ! distances en metre
+c
+      REAL rlon1, rlat1
+      REAL rlon2, rlat2
+      REAL dist
+      REAL pa, pb, p, pi
+c
+      REAL radius
+      PARAMETER (radius=6371229.)
+c
+      pi = 4.0 * ATAN(1.0)
+c
+      DO 9999 j = 1, jm
+      DO 9999 i = 1, im
+c
+      rlon1=rf_lon
+      rlat1=rf_lat
+      rlon2=rlon(i)
+      rlat2=rlat(j)
+      pa = pi/2.0 - rlat1*pi/180.0 ! dist. entre pole n et point a
+      pb = pi/2.0 - rlat2*pi/180.0 ! dist. entre pole n et point b
+      p = (rlon1-rlon2)*pi/180.0 ! angle entre a et b (leurs meridiens)
+c
+      dist = ACOS( COS(pa)*COS(pb) + SIN(pa)*SIN(pb)*COS(p))
+      dist = radius * dist
+      distance(i,j) = dist
+c
+ 9999 CONTINUE
+c
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/grid_noro.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/grid_noro.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/grid_noro.F	(revision 1644)
@@ -0,0 +1,487 @@
+
+      SUBROUTINE grid_noro(imdep, jmdep, xdata, ydata, zdata,
+     .             imar, jmar, x, y,
+     .             zphi,zmea,zstd,zsig,zgam,zthe,
+     .             zpic,zval,mask)
+c=======================================================================
+c (F. Lott) (voir aussi z.x. Li, A. Harzallah et L. Fairhead)
+c
+c      Compute the Parameters of the SSO scheme as described in
+c      LOTT & MILLER (1997) and LOTT(1999).
+c      Target points are on a rectangular grid:
+c      iim+1 latitudes including North and South Poles;
+c      jjm+1 longitudes, with periodicity jjm+1=1.
+c      aux poles.  At the poles the fields value is repeated
+c      jjm+1 time.
+c      The parameters a,b,c,d represent the limite of the target
+c      gridpoint region. The means over this region are calculated
+c      from USN data, ponderated by a weight proportional to the 
+c      surface occupated by the data inside the model gridpoint area.
+c      In most circumstances, this weight is the ratio between the
+c      surface of the USN gridpoint area and the surface of the
+c      model gridpoint area. 
+c
+c           (c)
+c        ----d-----
+c        | . . . .|
+c        |        |
+c     (b)a . * . .b(a)
+c        |        |
+c        | . . . .|
+c        ----c-----
+c           (d)
+C=======================================================================
+c INPUT:
+c        imdep, jmdep: dimensions X and Y input field
+c        xdata, ydata: coordinates X and Y input field
+c        zdata: Input field
+c        In this version it is assumed that the entry data come from
+c        the USNavy dataset: imdep=iusn=2160, jmdep=jusn=1080.
+c OUTPUT:
+c        imar, jmar: dimensions X and Y Output field
+c        x, y: ccordinates  X and Y Output field.
+c             zmea:  Mean orographie   
+c             zstd:  Standard deviation
+c             zsig:  Slope
+c             zgam:  Anisotropy
+c             zthe:  Orientation of the small axis
+c             zpic:  Maximum altitude
+c             zval:  Minimum altitude
+C=======================================================================
+      IMPLICIT INTEGER (I,J)
+      IMPLICIT REAL(X,Z) 
+      
+      parameter(iusn=2160,jusn=1080,iext=216)
+#include "dimensions.h"
+      REAL xusn(iusn+2*iext),yusn(jusn+2)	
+      REAL zusn(iusn+2*iext,jusn+2)
+
+      INTEGER imdep, jmdep
+      REAL xdata(imdep),ydata(jmdep) 
+      REAL zdata(imdep,jmdep)
+c
+      INTEGER imar, jmar
+  
+C INTERMEDIATE FIELDS  (CORRELATIONS OF OROGRAPHY GRADIENT)
+
+      REAL ztz(iim+1,jjm+1),zxtzx(iim+1,jjm+1)
+      REAL zytzy(iim+1,jjm+1),zxtzy(iim+1,jjm+1)
+      REAL weight(iim+1,jjm+1)
+
+C CORRELATIONS OF USN OROGRAPHY GRADIENTS
+
+      REAL zxtzxusn(iusn+2*iext,jusn+2),zytzyusn(iusn+2*iext,jusn+2)
+      REAL zxtzyusn(iusn+2*iext,jusn+2)
+      REAL x(imar+1),y(jmar),zphi(imar+1,jmar)
+      REAL zmea(imar+1,jmar),zstd(imar+1,jmar)
+      REAL zsig(imar+1,jmar),zgam(imar+1,jmar),zthe(imar+1,jmar)
+      REAL zpic(imar+1,jmar),zval(imar+1,jmar)
+      integer mask(imar+1,jmar)
+      real num_tot(2200,1100),num_lan(2200,1100)
+c
+      REAL a(2200),b(2200),c(1100),d(1100)
+c
+      print *,' parametres de l orographie a l echelle sous maille' 
+      xpi=acos(-1.)
+      rad    = 6 371 229.
+      zdeltay=2.*xpi/float(jusn)*rad
+
+c
+c  quelques tests de dimensions:
+c    
+c
+      if(iim.ne.imar) STOP 'Problem dim. x'
+      if(jjm.ne.jmar-1) STOP 'Problem dim. y'
+      IF (imar.GT.2200 .OR. jmar.GT.1100) THEN
+         PRINT*, 'imar or jmar too big', imar, jmar
+         CALL ABORT
+      ENDIF
+
+      IF(imdep.ne.iusn.or.jmdep.ne.jusn)then
+         print *,' imdep or jmdep bad dimensions:',imdep,jmdep
+         call abort
+      ENDIF
+
+      IF(imar+1.ne.iim+1.or.jmar.ne.jjm+1)THEN
+        print *,' imar or jmar bad dimensions:',imar,jmar
+        call abort
+      ENDIF
+
+
+c      print *,'xdata:',xdata
+c      print *,'ydata:',ydata
+c      print *,'x:',x
+c      print *,'y:',y
+c
+C  EXTENSION OF THE USN DATABASE TO POCEED COMPUTATIONS AT
+C  BOUNDARIES:
+c
+      DO j=1,jusn
+        yusn(j+1)=ydata(j)
+      DO i=1,iusn
+        zusn(i+iext,j+1)=zdata(i,j)
+        xusn(i+iext)=xdata(i)
+      ENDDO
+      DO i=1,iext
+        zusn(i,j+1)=zdata(iusn-iext+i,j)
+        xusn(i)=xdata(iusn-iext+i)-2.*xpi
+        zusn(iusn+iext+i,j+1)=zdata(i,j)
+        xusn(iusn+iext+i)=xdata(i)+2.*xpi
+      ENDDO
+      ENDDO
+
+        yusn(1)=ydata(1)+(ydata(1)-ydata(2))
+        yusn(jusn+2)=ydata(jusn)+(ydata(jusn)-ydata(jusn-1))
+       DO i=1,iusn/2+iext
+        zusn(i,1)=zusn(i+iusn/2,2)
+        zusn(i+iusn/2+iext,1)=zusn(i,2)
+        zusn(i,jusn+2)=zusn(i+iusn/2,jusn+1)
+        zusn(i+iusn/2+iext,jusn+2)=zusn(i,jusn+1)
+       ENDDO
+c  
+c COMPUTE LIMITS OF MODEL GRIDPOINT AREA
+C     ( REGULAR GRID)
+c
+      a(1) = x(1) - (x(2)-x(1))/2.0
+      b(1) = (x(1)+x(2))/2.0
+      DO i = 2, imar
+         a(i) = b(i-1)
+         b(i) = (x(i)+x(i+1))/2.0
+      ENDDO
+      a(imar+1) = b(imar)
+      b(imar+1) = x(imar+1) + (x(imar+1)-x(imar))/2.0
+
+      c(1) = y(1) - (y(2)-y(1))/2.0
+      d(1) = (y(1)+y(2))/2.0
+      DO j = 2, jmar-1
+         c(j) = d(j-1)
+         d(j) = (y(j)+y(j+1))/2.0
+      ENDDO
+      c(jmar) = d(jmar-1)
+      d(jmar) = y(jmar) + (y(jmar)-y(jmar-1))/2.0
+
+c
+c  initialisations:
+c
+
+c     write (*,*) "zpic: ",zpic
+
+      DO i = 1, imar+1
+         DO j = 1, jmar
+            weight(i,j) = 0.0
+            zxtzx(i,j)  = 0.0
+            zytzy(i,j)  = 0.0
+            zxtzy(i,j)  = 0.0
+            ztz(i,j)    = 0.0
+            zmea(i,j)   = 0.0
+            zpic(i,j)  = -1.E+10
+            zval(i,j)  = 1.E+10
+         ENDDO
+      ENDDO
+c
+c  COMPUTE SLOPES CORRELATIONS ON USN GRID
+c
+         DO j = 1,jusn+2 
+         DO i = 1, iusn+2*iext
+            zytzyusn(i,j)=0.0
+            zxtzxusn(i,j)=0.0
+            zxtzyusn(i,j)=0.0
+         ENDDO
+         ENDDO
+
+
+         DO j = 2,jusn+1 
+            zdeltax=zdeltay*cos(yusn(j))
+         DO i = 2, iusn+2*iext-1
+            zytzyusn(i,j)=(zusn(i,j+1)-zusn(i,j-1))**2/zdeltay**2
+            zxtzxusn(i,j)=(zusn(i+1,j)-zusn(i-1,j))**2/zdeltax**2
+            zxtzyusn(i,j)=(zusn(i,j+1)-zusn(i,j-1))/zdeltay
+     *                   *(zusn(i+1,j)-zusn(i-1,j))/zdeltax
+         ENDDO
+         ENDDO
+c
+c  SUMMATION OVER GRIDPOINT AREA
+c 
+      zleny=xpi/float(jusn)*rad
+      xincr=xpi/2./float(jusn)
+       DO ii = 1, imar+1
+       DO jj = 1, jmar
+       num_tot(ii,jj)=0.
+       num_lan(ii,jj)=0.
+c        PRINT *,' iteration ii jj:',ii,jj
+         DO j = 2,jusn+1 
+c         DO j = 3,jusn 
+            zlenx=zleny*cos(yusn(j))
+            zdeltax=zdeltay*cos(yusn(j))
+            zbordnor=(c(jj)-yusn(j)+xincr)*rad
+            zbordsud=(yusn(j)-d(jj)+xincr)*rad
+            weighy=AMAX1(0.,
+     *             amin1(zbordnor,zbordsud,zleny))
+         IF(weighy.ne.0)THEN
+         DO i = 2, iusn+2*iext-1
+            zbordest=(xusn(i)-a(ii)+xincr)*rad*cos(yusn(j))
+            zbordoue=(b(ii)+xincr-xusn(i))*rad*cos(yusn(j))
+            weighx=AMAX1(0.,
+     *             amin1(zbordest,zbordoue,zlenx))
+            IF(weighx.ne.0)THEN
+            num_tot(ii,jj)=num_tot(ii,jj)+1.0
+            if(zusn(i,j).ge.1.)num_lan(ii,jj)=num_lan(ii,jj)+1.0
+            weight(ii,jj)=weight(ii,jj)+weighx*weighy
+            zxtzx(ii,jj)=zxtzx(ii,jj)+zxtzxusn(i,j)*weighx*weighy
+            zytzy(ii,jj)=zytzy(ii,jj)+zytzyusn(i,j)*weighx*weighy
+            zxtzy(ii,jj)=zxtzy(ii,jj)+zxtzyusn(i,j)*weighx*weighy
+            ztz(ii,jj)  =ztz(ii,jj)  +zusn(i,j)*zusn(i,j)*weighx*weighy
+c mean
+            zmea(ii,jj) =zmea(ii,jj)+zusn(i,j)*weighx*weighy
+c peacks
+            zpic(ii,jj)=amax1(zpic(ii,jj),zusn(i,j))
+c valleys
+            zval(ii,jj)=amin1(zval(ii,jj),zusn(i,j))
+            ENDIF
+         ENDDO
+         ENDIF
+         ENDDO
+       ENDDO
+       ENDDO
+c
+c  COMPUTE PARAMETERS NEEDED BY THE LOTT & MILLER (1997) AND
+C  LOTT (1999) SSO SCHEME.
+c
+      zllmmea=0.
+      zllmstd=0.
+      zllmsig=0.
+      zllmgam=0.
+      zllmpic=0.
+      zllmval=0.
+      zllmthe=0.
+      zminthe=0.
+c     print 100,' '
+c100  format(1X,A1,'II JJ',4X,'H',8X,'SD',8X,'SI',3X,'GA',3X,'TH') 
+       DO ii = 1, imar+1
+       DO jj = 1, jmar
+         IF (weight(ii,jj) .NE. 0.0) THEN
+c  Mask
+           if(num_lan(ii,jj)/num_tot(ii,jj).ge.0.5)then
+             mask(ii,jj)=1
+           else
+             mask(ii,jj)=0
+           endif
+c  Mean Orography:
+           zmea (ii,jj)=zmea (ii,jj)/weight(ii,jj)
+           zxtzx(ii,jj)=zxtzx(ii,jj)/weight(ii,jj)
+           zytzy(ii,jj)=zytzy(ii,jj)/weight(ii,jj)
+           zxtzy(ii,jj)=zxtzy(ii,jj)/weight(ii,jj)
+           ztz(ii,jj)  =ztz(ii,jj)/weight(ii,jj)
+c  Standard deviation:
+           zstd(ii,jj)=sqrt(AMAX1(0.,ztz(ii,jj)-zmea(ii,jj)**2))
+         ELSE
+            PRINT*, 'probleme,ii,jj=', ii,jj
+         ENDIF
+       ENDDO
+       ENDDO
+
+C CORRECT VALUES OF HORIZONTAL SLOPE NEAR THE POLES:
+
+       DO ii = 1, imar+1
+         zxtzx(ii,1)=zxtzx(ii,2)
+         zxtzx(ii,jmar)=zxtzx(ii,jmar-1)
+         zxtzy(ii,1)=zxtzy(ii,2)
+         zxtzy(ii,jmar)=zxtzy(ii,jmar-1)
+         zytzy(ii,1)=zytzy(ii,2)
+         zytzy(ii,jmar)=zytzy(ii,jmar-1)
+       ENDDO
+
+C  FILTERS TO SMOOTH OUT FIELDS FOR INPUT INTO SSO SCHEME.
+
+C  FIRST FILTER, MOVING AVERAGE OVER 9 POINTS.
+
+       CALL MVA9(zmea,iim+1,jjm+1)
+       CALL MVA9(zstd,iim+1,jjm+1)
+       CALL MVA9(zpic,iim+1,jjm+1)
+       CALL MVA9(zval,iim+1,jjm+1)
+       CALL MVA9(zxtzx,iim+1,jjm+1)
+       CALL MVA9(zxtzy,iim+1,jjm+1)
+       CALL MVA9(zytzy,iim+1,jjm+1)
+
+       DO ii = 1, imar
+       DO jj = 1, jmar
+         IF (weight(ii,jj) .NE. 0.0) THEN
+c  Coefficients K, L et M:
+           xk=(zxtzx(ii,jj)+zytzy(ii,jj))/2.
+           xl=(zxtzx(ii,jj)-zytzy(ii,jj))/2.
+           xm=zxtzy(ii,jj)
+           xp=xk-sqrt(xl**2+xm**2)
+           xq=xk+sqrt(xl**2+xm**2)
+           xw=1.e-8
+           if(xp.le.xw) xp=0.
+           if(xq.le.xw) xq=xw
+           if(abs(xm).le.xw) xm=xw*sign(1.,xm)
+c slope: 
+           zsig(ii,jj)=sqrt(xq)*mask(ii,jj)
+c isotropy:
+           zgam(ii,jj)=xp/xq*mask(ii,jj)
+c angle theta:
+           zthe(ii,jj)=57.29577951*atan2(xm,xl)/2.*mask(ii,jj)
+           zphi(ii,jj)=zmea(ii,jj)*mask(ii,jj)
+           zmea(ii,jj)=zmea(ii,jj)*mask(ii,jj)
+           zpic(ii,jj)=zpic(ii,jj)*mask(ii,jj)
+           zval(ii,jj)=zval(ii,jj)*mask(ii,jj)
+           zstd(ii,jj)=zstd(ii,jj)*mask(ii,jj)
+
+c          print 101,ii,jj,
+c    *           zmea(ii,jj),zstd(ii,jj),zsig(ii,jj),zgam(ii,jj),
+c    *           zthe(ii,jj)
+c101  format(1x,2(1x,i2),2(1x,f7.1),1x,f7.4,2x,f4.2,1x,f5.1)     
+         ELSE
+c           PRINT*, 'probleme,ii,jj=', ii,jj
+         ENDIF
+      zllmmea=AMAX1(zmea(ii,jj),zllmmea)
+      zllmstd=AMAX1(zstd(ii,jj),zllmstd)
+      zllmsig=AMAX1(zsig(ii,jj),zllmsig)
+      zllmgam=AMAX1(zgam(ii,jj),zllmgam)
+      zllmthe=AMAX1(zthe(ii,jj),zllmthe)
+      zminthe=amin1(zthe(ii,jj),zminthe)
+      zllmpic=AMAX1(zpic(ii,jj),zllmpic)
+      zllmval=AMAX1(zval(ii,jj),zllmval)
+       ENDDO
+       ENDDO
+
+      print *,'  MEAN ORO:',zllmmea
+      print *,'  ST. DEV.:',zllmstd
+      print *,'  PENTE:',zllmsig
+      print *,' ANISOTROP:',zllmgam
+      print *,'  ANGLE:',zminthe,zllmthe	
+      print *,'  pic:',zllmpic
+      print *,'  val:',zllmval
+      
+C
+c gamma and theta a 1. and 0. at poles
+c
+      DO jj=1,jmar
+      zmea(imar+1,jj)=zmea(1,jj)
+      zphi(imar+1,jj)=zphi(1,jj)
+      zpic(imar+1,jj)=zpic(1,jj)
+      zval(imar+1,jj)=zval(1,jj)
+      zstd(imar+1,jj)=zstd(1,jj)
+      zsig(imar+1,jj)=zsig(1,jj)
+      zgam(imar+1,jj)=zgam(1,jj)
+      zthe(imar+1,jj)=zthe(1,jj)
+      ENDDO
+
+
+      zmeanor=0.0
+      zmeasud=0.0
+      zstdnor=0.0
+      zstdsud=0.0
+      zsignor=0.0
+      zsigsud=0.0
+      zweinor=0.0
+      zweisud=0.0
+      zpicnor=0.0
+      zpicsud=0.0                                   
+      zvalnor=0.0
+      zvalsud=0.0 
+
+      DO ii=1,imar
+      zweinor=zweinor+              weight(ii,   1)
+      zweisud=zweisud+              weight(ii,jmar)
+      zmeanor=zmeanor+zmea(ii,   1)*weight(ii,   1)
+      zmeasud=zmeasud+zmea(ii,jmar)*weight(ii,jmar)
+      zstdnor=zstdnor+zstd(ii,   1)*weight(ii,   1)
+      zstdsud=zstdsud+zstd(ii,jmar)*weight(ii,jmar)
+      zsignor=zsignor+zsig(ii,   1)*weight(ii,   1)
+      zsigsud=zsigsud+zsig(ii,jmar)*weight(ii,jmar)
+      zpicnor=zpicnor+zpic(ii,   1)*weight(ii,   1)
+      zpicsud=zpicsud+zpic(ii,jmar)*weight(ii,jmar)
+      zvalnor=zvalnor+zval(ii,   1)*weight(ii,   1)
+      zvalsud=zvalsud+zval(ii,jmar)*weight(ii,jmar)
+      ENDDO
+
+      DO ii=1,imar+1
+      zmea(ii,   1)=zmeanor/zweinor
+      zmea(ii,jmar)=zmeasud/zweisud
+      zphi(ii,   1)=zmeanor/zweinor
+      zphi(ii,jmar)=zmeasud/zweisud
+      zpic(ii,   1)=zpicnor/zweinor
+      zpic(ii,jmar)=zpicsud/zweisud
+      zval(ii,   1)=zvalnor/zweinor
+      zval(ii,jmar)=zvalsud/zweisud
+      zstd(ii,   1)=zstdnor/zweinor
+      zstd(ii,jmar)=zstdsud/zweisud
+      zsig(ii,   1)=zsignor/zweinor
+      zsig(ii,jmar)=zsigsud/zweisud
+      zgam(ii,   1)=1.
+      zgam(ii,jmar)=1.
+      zthe(ii,   1)=0.
+      zthe(ii,jmar)=0.
+      ENDDO
+
+      RETURN
+      END
+
+      SUBROUTINE MVA9(X,IMAR,JMAR)
+
+C MAKE A MOVING AVERAGE OVER 9 GRIDPOINTS OF THE X FIELDS
+
+      PARAMETER (ISMo=300,JSMo=200)
+      REAL X(IMAR,JMAR),XF(ISMo,JSMo)
+      real weight(-1:1,-1:1)
+
+      if(imar.gt.ismo) stop'surdimensionner ismo dans mva9 (grid_noro)'
+      if(jmar.gt.jsmo) stop'surdimensionner jsmo dans mva9 (grid_noro)'
+      
+      SUM=0.
+      DO IS=-1,1
+      DO JS=-1,1
+      WEIGHT(IS,JS)=1./FLOAT((1+IS**2)*(1+JS**2))
+      SUM=SUM+WEIGHT(IS,JS)
+      ENDDO
+      ENDDO
+
+      DO IS=-1,1
+      DO JS=-1,1
+      WEIGHT(IS,JS)=WEIGHT(IS,JS)/SUM
+      ENDDO
+      ENDDO
+
+      DO J=2,JMAR-1
+      DO I=2,IMAR-1
+      XF(I,J)=0.
+      DO IS=-1,1
+      DO JS=-1,1
+         XF(I,J)=XF(I,J)+X(I+IS,J+JS)*WEIGHT(IS,JS)
+      ENDDO
+      ENDDO
+      ENDDO
+      ENDDO
+
+      DO J=2,JMAR-1
+         XF(1,J)=0.
+      IS=IMAR-1
+      DO JS=-1,1 
+         XF(1,J)=XF(1,J)+X(IS,J+JS)*WEIGHT(-1,JS)
+      ENDDO
+      DO IS=0,1 
+      DO JS=-1,1 
+         XF(1,J)=XF(1,J)+X(1+IS,J+JS)*WEIGHT(IS,JS)
+      ENDDO
+      ENDDO
+         XF(IMAR,J)=XF(1,J)
+      ENDDO
+
+      DO I=1,IMAR
+      XF(I,1)=XF(I,2)
+      XF(I,JMAR)=XF(I,JMAR-1)
+      ENDDO
+
+      DO I=1,IMAR
+      DO J=1,JMAR
+         X(I,J)=XF(I,J)
+      ENDDO
+      ENDDO
+
+      RETURN
+      END
+
+
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/groupe.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/groupe.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/groupe.F	(revision 1644)
@@ -0,0 +1,81 @@
+      subroutine groupe(pext,pbaru,pbarv,pbarum,pbarvm,wm)
+      implicit none
+
+c   SEE COMMENTS IN groupeun.F
+c
+c   sous-programme servant a fitlrer les champs de flux de masse aux
+c   poles en "regroupant" les mailles 2 par 2 puis 4 par 4 etc. au fur
+c   et a mesure qu'on se rapproche du pole.
+c
+c   en entree: pext, pbaru et pbarv
+c
+c   en sortie:  pbarum,pbarvm et wm.
+c
+c   remarque, le wm est recalcule a partir des pbaru pbarv et on n'a donc
+c   pas besoin de w en entree.
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom2.h"
+
+
+      real pbaru(iip1,jjp1,llm),pbarv(iip1,jjm,llm)
+      real pext(iip1,jjp1,llm)
+
+      real pbarum(iip1,jjp1,llm),pbarvm(iip1,jjm,llm)
+      real wm(iip1,jjp1,llm)
+
+      real zconvm(iip1,jjp1,llm),zconvmm(iip1,jjp1,llm)
+
+      real uu
+
+      integer i,j,l
+
+c   Champs 1D
+
+      call convflu(pbaru,pbarv,llm,zconvm)
+
+c
+      call scopy(ijp1llm,zconvm,1,zconvmm,1)
+      call scopy(ijmllm,pbarv,1,pbarvm,1)
+
+c
+      call groupeun(jjp1,llm,zconvmm)
+      call groupeun(jjm,llm,pbarvm)
+
+c   Champs 3D
+
+      do l=1,llm
+         do j=2,jjm
+            uu=pbaru(iim,j,l)
+            do i=1,iim
+               uu=uu+pbarvm(i,j,l)-pbarvm(i,j-1,l)-zconvmm(i,j,l)
+               pbarum(i,j,l)=uu
+c     zconvm(i,j,l ) =  xflu(i-1,j,l)-xflu(i,j,l)+
+c    *                      yflu(i,j,l)-yflu(i,j-1,l)
+            enddo
+            pbarum(iip1,j,l)=pbarum(1,j,l)
+         enddo
+      enddo
+
+c    integration de la convergence de masse de haut  en bas ......
+      do l=1,llm
+         do j=1,jjp1
+            do i=1,iip1
+               zconvmm(i,j,l)=zconvmm(i,j,l)
+            enddo
+         enddo
+      enddo
+      do  l = llm-1,1,-1
+          do j=1,jjp1
+             do i=1,iip1
+                zconvmm(i,j,l)=zconvmm(i,j,l)+zconvmm(i,j,l+1)
+             enddo
+          enddo
+      enddo
+
+      CALL vitvert(zconvmm,wm)
+
+      return
+      end
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/groupeun.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/groupeun.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/groupeun.F	(revision 1644)
@@ -0,0 +1,144 @@
+!Mars importe directement de la version martienne 
+      subroutine groupeun(jjmax,llmax,q)
+      implicit none
+
+c *********************************************************
+c     lissage fort des champs aux poles pour permettre 
+c     de tourner avec plafond haut.
+c     F. Hourdin, 1997.
+c     (commentaire et test sur ngroup par Francois Forget, 05/2000)
+c
+c     Technique :
+c
+c     1) Les points sont regroupes par paquet de 2**ngroup 
+c     aux poles (e.g. ngroup=3 -> paquet de 8), puis 2**(ngroup-1)
+c     2**(ngroup-2), etc... aux latitude plus basse en s'eloignant du pole
+c
+c     2) Plus ngroup est eleve, plus le lissage est efficace
+c
+c     3) MAIS, il faut iim divisible par 2**ngroup !!!
+c
+c
+c *********************************************************
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom2.h"
+
+      integer jjmax,llmax
+      real q(iip1,jjmax,llmax)
+
+      integer ngroup
+      parameter (ngroup=2) 
+
+      logical intensive
+
+      real airen,airecn,qn
+      real aires,airecs,qs
+
+      integer i,j,l,ig,j1,j2,i0,jd
+      logical firstcall
+      DATA firstcall/.true./
+
+c -------------------------------------------------------
+c   test sur ngroup :
+
+      if (firstcall) then
+        IF(MOD(iim,2**ngroup).NE.0) then
+           write(*,*) 'Problem in groupeun.F'
+           write(*,*) 'iim= ', iim, ' ngroup=', ngroup
+           write(*,*) 'iim must be divisible by par 2**ngroup= ',
+     &                 2**ngroup
+           write(*,*) ' YOU must change ngroup in groupeun.F'
+           write(*,*) ' Have fun... '
+           stop
+        END IF
+        write(*,*) 'in groupeun.F, ngroup=', ngroup
+        firstcall = .false.
+      end if
+      
+
+c Champs 3D
+      intensive=.true.
+      if (intensive) then
+      jd=jjp1-jjmax
+      do l=1,llmax
+       j1=1+jd
+       j2=2
+       do ig=1,ngroup
+         do j=j1-jd,j2-jd
+c           print*,'groupe ',ig,'  j= ',j,2**(ngroup-ig+1),'pts groupes'
+            do i0=1,iim,2**(ngroup-ig+1)
+               airen=0.
+               airecn=0.
+               qn=0.
+               aires=0.
+               airecs=0.
+               qs=0.
+               do i=i0,i0+2**(ngroup-ig+1)-1
+                  airen=airen+aire(i,j)
+                  aires=aires+aire(i,jjp1-j+1)
+                  qn=qn+q(i,j,l)*aire(i,j)
+                  qs=qs+q(i,jjp1-j+1-jd,l)*aire(i,jjp1-j+1)
+               enddo
+               airecn=0.
+               airecs=0.
+               do i=i0,i0+2**(ngroup-ig+1)-1
+                  q(i,j,l)=qn/airen
+                  q(i,jjp1-j+1-jd,l)=qs/aires
+               enddo
+            enddo
+            q(iip1,j,l)=q(1,j,l)
+            q(iip1,jjp1-j+1-jd,l)=q(1,jjp1-j+1-jd,l)
+         enddo
+         j1=j2+1
+         j2=j2+2**ig
+       enddo
+      enddo
+
+c  ---------------
+      else
+c   Cas sans multiplication par les aires.
+c  ---------------
+
+      jd=jjp1-jjmax
+      do l=1,llmax
+      j1=1+jd
+      j2=2
+      do ig=1,ngroup
+         do j=j1-jd,j2-jd
+c           print*,'groupe ',ig,'  j= ',j,2**(ngroup-ig+1),'pts groupes'
+            do i0=1,iim,2**(ngroup-ig+1)
+               airen=0.
+               airecn=0.
+               qn=0.
+               aires=0.
+               airecs=0.
+               qs=0.
+               do i=i0,i0+2**(ngroup-ig+1)-1
+                  airen=airen+aire(i,j)
+                  aires=aires+aire(i,jjp1-j+1)
+                  qn=qn+q(i,j,l)
+                  qs=qs+q(i,jjp1-j+1-jd,l)
+               enddo
+               airecn=0.
+               airecs=0.
+               do i=i0,i0+2**(ngroup-ig+1)-1
+                  q(i,j,l)=qn*aire(i,j)/airen
+                  q(i,jjp1-j+1-jd,l)=qs*aire(i,jjp1-j+1)/aires
+               enddo
+            enddo
+            q(iip1,j,l)=q(1,j,l)
+            q(iip1,jjp1-j+1-jd,l)=q(1,jjp1-j+1-jd,l)
+         enddo
+         j1=j2+1
+         j2=j2+2**ig
+      enddo
+      enddo
+
+      endif
+
+c     print*,'On groupe jusque j=',j1-1,rlatu(j1-1)*180./pi
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/dyn3d/heavyside.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/heavyside.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/heavyside.F	(revision 1644)
@@ -0,0 +1,21 @@
+c
+c $Header: /users/lmdz/cvsroot/LMDZ.3.3/libf/dyn3d/heavyside.F,v 1.2 2001/04/13 15:49:10 lmdz Exp $
+c
+       FUNCTION heavyside(a)
+
+c      ...   P. Le Van  ....
+c
+       IMPLICIT NONE
+
+       REAL*8 heavyside , a
+
+       IF ( a.LE.0. )  THEN
+         heavyside = 0.
+       ELSE
+         heavyside = 1.
+       ENDIF
+
+       RETURN
+       END
+
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/infotrac.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/infotrac.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/infotrac.F90	(revision 1644)
@@ -0,0 +1,572 @@
+MODULE infotrac
+
+IMPLICIT NONE
+! nqtot : total number of tracers and higher order of moment, water vapor and liquid included
+  INTEGER, SAVE :: nqtot
+! CR: add number of tracers for water (for Earth model only!!)
+  INTEGER, SAVE :: nqo
+
+! nbtr : number of tracers not including higher order of moment or water vapor or liquid
+!        number of tracers used in the physics
+  INTEGER, SAVE :: nbtr
+
+! Name variables
+  CHARACTER(len=20), ALLOCATABLE, DIMENSION(:), SAVE :: tname ! tracer short name for restart and diagnostics
+  CHARACTER(len=23), ALLOCATABLE, DIMENSION(:), SAVE :: ttext ! tracer long name for diagnostics
+
+! iadv  : index of trasport schema for each tracer
+  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: iadv
+
+! niadv : vector keeping the coorspondance between all tracers(nqtot) treated in the 
+!         dynamic part of the code and the tracers (nbtr+2) used in the physics part of the code. 
+  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE    :: niadv ! equivalent dyn / physique
+
+! conv_flg(it)=0 : convection desactivated for tracer number it 
+  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: conv_flg
+! pbl_flg(it)=0  : boundary layer diffusion desactivaded for tracer number it 
+  INTEGER, ALLOCATABLE, DIMENSION(:), SAVE  :: pbl_flg
+
+  CHARACTER(len=4),SAVE :: type_trac
+  CHARACTER(len=8),DIMENSION(:),ALLOCATABLE, SAVE :: solsym
+ 
+CONTAINS
+
+  SUBROUTINE infotrac_init
+    USE control_mod
+#ifdef REPROBUS
+    USE CHEM_REP, ONLY : Init_chem_rep_trac
+#endif
+    IMPLICIT NONE
+!=======================================================================
+!
+!   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
+!   -------
+!   Modif special traceur F.Forget 05/94
+!   Modif M-A Filiberti 02/02 lecture de traceur.def
+!
+!   Objet:
+!   ------
+!   GCM LMD nouvelle grille
+!
+!=======================================================================
+!   ... modification de l'integration de q ( 26/04/94 ) ....
+!-----------------------------------------------------------------------
+! Declarations
+
+    INCLUDE "dimensions.h"
+    INCLUDE "iniprint.h"
+
+! Local variables
+    INTEGER, ALLOCATABLE, DIMENSION(:) :: hadv  ! index of horizontal trasport schema
+    INTEGER, ALLOCATABLE, DIMENSION(:) :: vadv  ! index of vertical trasport schema
+
+    CHARACTER(len=15), ALLOCATABLE, DIMENSION(:) :: tnom_0  ! tracer short name
+    CHARACTER(len=3), DIMENSION(30) :: descrq
+    CHARACTER(len=1), DIMENSION(3)  :: txts
+    CHARACTER(len=2), DIMENSION(9)  :: txtp
+    CHARACTER(len=23)               :: str1,str2
+  
+    INTEGER :: nqtrue  ! number of tracers read from tracer.def, without higer order of moment
+    INTEGER :: iq, new_iq, iiq, jq, ierr, ierr2, ierr3
+    
+    character(len=80) :: line ! to store a line of text
+ 
+    character(len=*),parameter :: modname="infotrac_init"
+!-----------------------------------------------------------------------
+! Initialization :
+!
+    txts=(/'x','y','z'/)
+    txtp=(/'x ','y ','z ','xx','xy','xz','yy','yz','zz'/)
+
+    descrq(14)='VLH'
+    descrq(10)='VL1'
+    descrq(11)='VLP'
+    descrq(12)='FH1'
+    descrq(13)='FH2'
+    descrq(16)='PPM'
+    descrq(17)='PPS'
+    descrq(18)='PPP'
+    descrq(20)='SLP'
+    descrq(30)='PRA'
+    
+    IF (planet_type=='earth') THEN
+     ! Coherence test between parameter type_trac, config_inca and preprocessing keys
+     IF (type_trac=='inca') THEN
+       WRITE(lunout,*) 'You have choosen to couple with INCA chemestry model : type_trac=', &
+            type_trac,' config_inca=',config_inca
+       IF (config_inca/='aero' .AND. config_inca/='aeNP' .AND. config_inca/='chem') THEN
+          WRITE(lunout,*) 'Incoherence between type_trac and config_inca. Model stops. Modify run.def'
+          CALL abort_gcm('infotrac_init','Incoherence between type_trac and config_inca',1)
+       END IF
+#ifndef INCA
+       WRITE(lunout,*) 'To run this option you must add cpp key INCA and compile with INCA code'
+       CALL abort_gcm('infotrac_init','You must compile with cpp key INCA',1)
+#endif
+     ELSE IF (type_trac=='repr') THEN
+       WRITE(lunout,*) 'You have choosen to couple with REPROBUS chemestry model : type_trac=', type_trac
+#ifndef REPROBUS
+       WRITE(lunout,*) 'To run this option you must add cpp key REPROBUS and compile with REPRPBUS code'
+       CALL abort_gcm('infotrac_init','You must compile with cpp key REPROBUS',1)
+#endif
+     ELSE IF (type_trac == 'lmdz') THEN
+       WRITE(lunout,*) 'Tracers are treated in LMDZ only : type_trac=', type_trac
+     ELSE
+       WRITE(lunout,*) 'type_trac=',type_trac,' not possible. Model stops'
+       CALL abort_gcm('infotrac_init','bad parameter',1)
+     END IF
+
+     ! Test if config_inca is other then none for run without INCA
+     IF (type_trac/='inca' .AND. config_inca/='none') THEN
+       WRITE(lunout,*) 'config_inca will now be changed to none as you do not couple with INCA model'
+       config_inca='none'
+     END IF
+    ELSE
+     type_trac='plnt'  ! planets... May want to dissociate between each later.
+    ENDIF ! of IF (planet_type=='earth')
+
+!-----------------------------------------------------------------------
+!
+! 1) Get the true number of tracers + water vapor/liquid
+!    Here true tracers (nqtrue) means declared tracers (only first order)
+!
+!-----------------------------------------------------------------------
+    IF (planet_type=='earth') THEN
+     IF (type_trac == 'lmdz' .OR. type_trac == 'repr') THEN
+       OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
+       IF(ierr.EQ.0) THEN
+          WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
+          READ(90,*) nqtrue
+       ELSE 
+          WRITE(lunout,*) trim(modname),': Problem in opening traceur.def'
+          WRITE(lunout,*) trim(modname),': WARNING using defaut values'
+          nqtrue=4 ! Defaut value
+       END IF
+       ! For Earth, water vapour & liquid tracers are not in the physics
+       nbtr=nqtrue-2
+     ELSE ! type_trac=inca
+       ! nbtr has been read from INCA by init_cont_lmdz() in gcm.F 
+       nqtrue=nbtr+2
+     END IF
+
+     IF (nqtrue < 2) THEN
+       WRITE(lunout,*) trim(modname),': nqtrue=',nqtrue, ' is not allowded. 2 tracers is the minimum'
+       CALL abort_gcm('infotrac_init','Not enough tracers',1)
+     END IF
+
+! Transfert number of tracers to Reprobus
+     IF (type_trac == 'repr') THEN
+#ifdef REPROBUS
+       CALL Init_chem_rep_trac(nbtr)
+#endif
+     END IF
+
+    ELSE  ! not Earth
+       OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
+       IF(ierr.EQ.0) THEN
+          WRITE(lunout,*) 'Open traceur.def : ok'
+          READ(90,*) nqtrue
+       ELSE 
+          WRITE(lunout,*) 'Problem in opening traceur.def'
+          WRITE(lunout,*) 'ATTENTION using defaut values: nqtrue=1'
+          nqtrue=1 ! Defaut value
+       END IF
+       ! Other planets (for now); we have the same number of tracers
+       ! in the dynamics than in the physics
+       nbtr=nqtrue
+     
+    ENDIF  ! planet_type
+!
+! Allocate variables depending on nqtrue and nbtr
+!
+    ALLOCATE(tnom_0(nqtrue), hadv(nqtrue), vadv(nqtrue))
+    ALLOCATE(conv_flg(nbtr), pbl_flg(nbtr), solsym(nbtr))
+    conv_flg(:) = 1 ! convection activated for all tracers
+    pbl_flg(:)  = 1 ! boundary layer activated for all tracers
+
+!-----------------------------------------------------------------------
+! 2)     Choix  des schemas d'advection pour l'eau et les traceurs
+!
+!     iadv = 1    schema  transport type "humidite specifique LMD"
+!     iadv = 2    schema   amont
+!     iadv = 14   schema  Van-leer + humidite specifique 
+!                            Modif F.Codron
+!     iadv = 10   schema  Van-leer (retenu pour l'eau vapeur et liquide)
+!     iadv = 11   schema  Van-Leer pour hadv et version PPM (Monotone) pour vadv
+!     iadv = 12   schema  Frederic Hourdin I
+!     iadv = 13   schema  Frederic Hourdin II
+!     iadv = 16   schema  PPM Monotone(Collela & Woodward 1984)
+!     iadv = 17   schema  PPM Semi Monotone (overshoots autorisés)
+!     iadv = 18   schema  PPM Positif Defini (overshoots undershoots autorisés)
+!     iadv = 20   schema  Slopes
+!     iadv = 30   schema  Prather
+!
+!        Dans le tableau q(ij,l,iq) : iq = 1  pour l'eau vapeur
+!                                     iq = 2  pour l'eau liquide
+!       Et eventuellement             iq = 3,nqtot pour les autres traceurs
+!
+!        iadv(1): choix pour l'eau vap. et  iadv(2) : choix pour l'eau liq.
+!------------------------------------------------------------------------
+!
+!    Get choice of advection schema from file tracer.def or from INCA
+!---------------------------------------------------------------------
+    IF (planet_type=='earth') THEN
+     IF (type_trac == 'lmdz' .OR. type_trac == 'repr') THEN
+       IF(ierr.EQ.0) THEN
+          ! Continue to read tracer.def
+          DO iq=1,nqtrue
+             READ(90,*) hadv(iq),vadv(iq),tnom_0(iq)
+          END DO
+          CLOSE(90)  
+       ELSE ! Without tracer.def, set default values (for Earth!)
+         if ((nqtrue==4).and.(planet_type=="earth")) then
+          hadv(1) = 14
+          vadv(1) = 14
+          tnom_0(1) = 'H2Ov'
+          hadv(2) = 10
+          vadv(2) = 10
+          tnom_0(2) = 'H2Ol'
+          hadv(3) = 10
+          vadv(3) = 10
+          tnom_0(3) = 'RN'
+          hadv(4) = 10
+          vadv(4) = 10
+          tnom_0(4) = 'PB'
+         else
+           ! Error message, we need a traceur.def file
+           write(lunout,*) trim(modname),&
+           ': Cannot set default tracer names!'
+           write(lunout,*) trim(modname),' Make a traceur.def file!!!'
+           CALL abort_gcm('infotrac_init','Need a traceur.def file!',1)
+         endif ! of if (nqtrue==4)
+       END IF
+       
+!CR: nombre de traceurs de l eau
+       if (tnom_0(3) == 'H2Oi') then
+          nqo=3
+       else
+          nqo=2
+       endif
+
+       WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
+       WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
+       DO iq=1,nqtrue
+          WRITE(lunout,*) hadv(iq),vadv(iq),tnom_0(iq)
+       END DO
+
+     ELSE  ! type_trac=inca : config_inca='aero' ou 'chem'
+! le module de chimie fournit les noms des traceurs
+! et les schemas d'advection associes.
+     
+#ifdef INCA
+       CALL init_transport( &
+            hadv, &
+            vadv, &
+            conv_flg, &
+            pbl_flg,  &
+            tracnam)
+#endif
+       tnom_0(1)='H2Ov'
+       tnom_0(2)='H2Ol'
+
+       DO iq =3,nqtrue
+          tnom_0(iq)=solsym(iq-2)
+       END DO
+       nqo = 2
+
+     END IF ! type_trac
+
+    ELSE  ! not Earth
+       IF(ierr.EQ.0) THEN
+          ! Continue to read tracer.def
+          DO iq=1,nqtrue
+             !READ(90,*) hadv(iq),vadv(iq),tnom_0(iq)
+            ! try to be smart when reading traceur.def
+            read(90,'(80a)') line ! store the line from traceur.def
+            ! assume format is hadv,vadv,tnom_0
+            read(line,*,iostat=ierr2) hadv(iq),vadv(iq),tnom_0(iq)
+            if (ierr2.ne.0) then
+              ! maybe format is tnom0,hadv,vadv
+              read(line,*,iostat=ierr3) tnom_0(iq),hadv(iq),vadv(iq)
+              if (ierr3.ne.0) then
+                ! assume only tnom0 is provided (havd and vad default to 10)
+                read(line,*) tnom_0(iq)
+                hadv(iq)=10
+                vadv(iq)=10
+              endif
+            endif ! of if(ierr2.ne.0)
+          END DO ! of DO iq=1,nqtrue
+          CLOSE(90)  
+       ELSE ! Without tracer.def
+          hadv(1) = 10
+          vadv(1) = 10
+          tnom_0(1) = 'dummy'
+       END IF
+       
+       WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
+       WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
+       DO iq=1,nqtrue
+          WRITE(lunout,*) hadv(iq),vadv(iq),tnom_0(iq)
+       END DO
+
+    ENDIF  ! planet_type
+
+!-----------------------------------------------------------------------
+!
+! 3) Verify if advection schema 20 or 30 choosen
+!    Calculate total number of tracers needed: nqtot
+!    Allocate variables depending on total number of tracers
+!-----------------------------------------------------------------------
+    new_iq=0
+    DO iq=1,nqtrue
+       ! Add tracers for certain advection schema
+       IF (hadv(iq)<20 .AND. vadv(iq)<20 ) THEN
+          new_iq=new_iq+1  ! no tracers added
+       ELSE IF (hadv(iq)==20 .AND. vadv(iq)==20 ) THEN
+          new_iq=new_iq+4  ! 3 tracers added
+       ELSE IF (hadv(iq)==30 .AND. vadv(iq)==30 ) THEN
+          new_iq=new_iq+10 ! 9 tracers added
+       ELSE
+          WRITE(lunout,*) trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
+          CALL abort_gcm('infotrac_init','Bad choice of advection schema - 1',1)
+       END IF
+    END DO
+    
+    IF (new_iq /= nqtrue) THEN
+       ! The choice of advection schema imposes more tracers
+       ! Assigne total number of tracers
+       nqtot = new_iq
+
+       WRITE(lunout,*) trim(modname),': The choice of advection schema for one or more tracers'
+       WRITE(lunout,*) 'makes it necessary to add tracers'
+       WRITE(lunout,*) trim(modname)//': ',nqtrue,' is the number of true tracers'
+       WRITE(lunout,*) trim(modname)//': ',nqtot, ' is the total number of tracers needed'
+
+    ELSE
+       ! The true number of tracers is also the total number
+       nqtot = nqtrue
+    END IF
+
+!
+! Allocate variables with total number of tracers, nqtot
+!
+    ALLOCATE(tname(nqtot), ttext(nqtot))
+    ALLOCATE(iadv(nqtot), niadv(nqtot))
+
+!-----------------------------------------------------------------------
+!
+! 4) Determine iadv, long and short name
+!
+!-----------------------------------------------------------------------
+    new_iq=0
+    DO iq=1,nqtrue
+       new_iq=new_iq+1
+
+       ! Verify choice of advection schema
+       IF (hadv(iq)==vadv(iq)) THEN
+          iadv(new_iq)=hadv(iq)
+       ELSE IF (hadv(iq)==10 .AND. vadv(iq)==16) THEN
+          iadv(new_iq)=11
+       ELSE
+          WRITE(lunout,*)trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
+
+          CALL abort_gcm('infotrac_init','Bad choice of advection schema - 2',1)
+       END IF
+      
+       str1=tnom_0(iq)
+       tname(new_iq)= tnom_0(iq)
+       IF (iadv(new_iq)==0) THEN
+          ttext(new_iq)=trim(str1)
+       ELSE
+          ttext(new_iq)=trim(tnom_0(iq))//descrq(iadv(new_iq))
+       END IF
+
+       ! schemas tenant compte des moments d'ordre superieur
+       str2=ttext(new_iq)
+       IF (iadv(new_iq)==20) THEN
+          DO jq=1,3
+             new_iq=new_iq+1
+             iadv(new_iq)=-20
+             ttext(new_iq)=trim(str2)//txts(jq)
+             tname(new_iq)=trim(str1)//txts(jq)
+          END DO
+       ELSE IF (iadv(new_iq)==30) THEN
+          DO jq=1,9
+             new_iq=new_iq+1
+             iadv(new_iq)=-30
+             ttext(new_iq)=trim(str2)//txtp(jq)
+             tname(new_iq)=trim(str1)//txtp(jq)
+          END DO
+       END IF
+    END DO
+
+!
+! Find vector keeping the correspodence between true and total tracers
+!
+    niadv(:)=0
+    iiq=0
+    DO iq=1,nqtot
+       IF(iadv(iq).GE.0) THEN
+          ! True tracer
+          iiq=iiq+1
+          niadv(iiq)=iq
+       ENDIF
+    END DO
+
+
+    WRITE(lunout,*) trim(modname),': Information stored in infotrac :'
+    WRITE(lunout,*) trim(modname),': iadv  niadv tname  ttext :'
+    DO iq=1,nqtot
+       WRITE(lunout,*) iadv(iq),niadv(iq),&
+       ' ',trim(tname(iq)),' ',trim(ttext(iq))
+    END DO
+
+!
+! Test for advection schema. 
+! This version of LMDZ only garantees iadv=10 and iadv=14 (14 only for water vapour) .
+!
+    DO iq=1,nqtot
+       IF (iadv(iq)/=10 .AND. iadv(iq)/=14 .AND. iadv(iq)/=0) THEN
+          WRITE(lunout,*)trim(modname),' STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
+          CALL abort_gcm('infotrac_init','In this version only iadv=10 and iadv=14 is tested!',1)
+       ELSE IF (iadv(iq)==14 .AND. iq/=1) THEN
+          WRITE(lunout,*)trim(modname),'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
+          CALL abort_gcm('infotrac_init','In this version iadv=14 is only permitted for water vapour!',1)
+       END IF
+    END DO
+
+!-----------------------------------------------------------------------
+! Finalize :
+!
+    DEALLOCATE(tnom_0, hadv, vadv)
+
+
+  END SUBROUTINE infotrac_init
+
+! Ehouarn: routine iniadvtrac => from Mars/generic; does essentially the
+!          same job as infotrac_init. To clean up and merge at some point...
+      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(tname(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) tname(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: /trunk/LMDZ.TITAN/libf/dyn3d/iniav.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/iniav.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/iniav.F	(revision 1644)
@@ -0,0 +1,237 @@
+      SUBROUTINE iniav(fichnom,pday0,pyear0,pfrac0,pperiod,phis,nq)
+
+      USE comvert_mod, ONLY: ap,bp,nivsigs,nivsig,presnivs
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   pday0    jour de reference pour le stockage
+c   pfrac0   decalage du debut du stockage par rapport a pday0 (en jour)
+c   pperiod  period de stockage en secondes
+c   phis     geopotentiel au sol
+c   
+c   initialisation de l'ecriture des moyennes temporelles.
+c
+c=======================================================================
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comav.h"
+#include "netcdf.inc"
+#include "comgeom.h"
+
+      REAL pperiod
+
+      INTEGER*4 pday0,pyear0
+      REAL pfrac0
+      CHARACTER*(*) fichnom
+      REAL phis(ip1jmp1)
+c
+      CHARACTER str3*3
+c
+      INTEGER nq
+      INTEGER ierr, nid, nvarid, iq
+      INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv
+      INTEGER idim_s, idim_sig
+      INTEGER idim_tim
+      INTEGER dims2(2), dims3(3), dims4(4)
+
+      period_av=pperiod
+      time0_av=pfrac0
+c
+      ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
+      IF (ierr.NE.NF_NOERR) THEN
+         WRITE(6,*)" Pb d ouverture du fichier "//fichnom
+         WRITE(6,*)' ierr = ', ierr
+         CALL ABORT
+      ENDIF
+c
+c Preciser quelques attributs globaux:
+c
+      ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 32,
+     .                       "Fichier moyen histoire dynamique")
+c
+c Definir les dimensions du fichiers:
+c
+      ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
+      ierr = NF_DEF_DIM (nid, "rlatu", jjp1, idim_rlatu)
+      ierr = NF_DEF_DIM (nid, "rlonv", iip1, idim_rlonv)
+      ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv)
+      ierr = NF_DEF_DIM (nid, "sigs", llm, idim_s)
+      ierr = NF_DEF_DIM (nid, "sig", llmp1, idim_sig)
+      ierr = NF_DEF_DIM (nid, "temps", NF_UNLIMITED, idim_tim)
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+c
+c Definir et enregistrer certains champs invariants:
+c
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid)
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid)
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid)
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid)
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"nivsigs",NF_DOUBLE,1,idim_s,nvarid)
+      ierr = NF_DEF_VAR (nid,"nivsigs",NF_FLOAT,1,idim_s,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsigs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsigs)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"nivsig",NF_DOUBLE,1,idim_sig,nvarid)
+      ierr = NF_DEF_VAR (nid,"nivsig",NF_FLOAT,1,idim_sig,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,nivsig)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,nivsig)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_sig,nvarid)
+      ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_sig,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_sig,nvarid)
+      ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_sig,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bp)
+#endif
+c
+      ierr = NF_REDEF (nid)
+ccc      ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_s,nvarid)
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_s,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,presnivs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,presnivs)
+#endif
+c
+c Geopentiel au sol:
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+ccc      ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid)
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid)
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,phis)
+#endif
+c
+c Definir les variables pour pouvoir les enregistrer plus tard:
+c
+      ierr = NF_REDEF (nid) ! entrer dans le mode de definition
+c
+ccc      ierr = NF_DEF_VAR (nid,"temps",NF_DOUBLE,1,idim_tim,nvarid)
+      ierr = NF_DEF_VAR (nid,"temps",NF_FLOAT,1,idim_tim,nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "iniav: Erreur pour definir <temps>"
+         CALL abort
+      ENDIF
+c
+      dims4(1) = idim_rlonu
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+ccc      ierr = NF_DEF_VAR (nid,"vitu",NF_DOUBLE,4,dims4,nvarid)
+      ierr = NF_DEF_VAR (nid,"vitu",NF_FLOAT,4,dims4,nvarid)
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatv
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+ccc      ierr = NF_DEF_VAR (nid,"vitv",NF_DOUBLE,4,dims4,nvarid)
+      ierr = NF_DEF_VAR (nid,"vitv",NF_FLOAT,4,dims4,nvarid)
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+ccc      ierr = NF_DEF_VAR (nid,"temp",NF_DOUBLE,4,dims4,nvarid)
+      ierr = NF_DEF_VAR (nid,"temp",NF_FLOAT,4,dims4,nvarid)
+c
+      dims4(1) = idim_rlonv
+      dims4(2) = idim_rlatu
+      dims4(3) = idim_s
+      dims4(4) = idim_tim
+      IF(nq.GE.1) THEN
+      DO iq=1,nq
+      IF (iq.GT.99) THEN
+         PRINT*, "Trop de traceurs"
+         CALL abort
+      ELSE
+         str3(1:1)='q'
+         WRITE(str3(2:3),'(i2.2)') iq
+ccc         ierr = NF_DEF_VAR (nid,str3,NF_DOUBLE,4,dims4,nvarid)
+         ierr = NF_DEF_VAR (nid,str3,NF_FLOAT,4,dims4,nvarid)
+      ENDIF
+      ENDDO
+      ENDIF
+c
+      dims3(1) = idim_rlonv
+      dims3(2) = idim_rlatu
+      dims3(3) = idim_tim
+ccc      ierr = NF_DEF_VAR (nid,"ps",NF_DOUBLE,3,dims3,nvarid)
+      ierr = NF_DEF_VAR (nid,"ps",NF_FLOAT,3,dims3,nvarid)
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+      ierr = NF_CLOSE(nid) ! fermer le fichier
+
+      PRINT*,'le fichier hist.moy stoke les variables toutes'
+      PRINT*,'les ',period_av,'s'
+      PRINT*,'A partir du jour de reference day0'
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/iniconst.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/iniconst.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/iniconst.F	(revision 1644)
@@ -0,0 +1,60 @@
+      SUBROUTINE iniconst
+
+      use control_mod, only: iphysiq, dissip_period
+      USE comconst_mod, ONLY: im,jm,lllm,imp1,jmp1,lllmp1,lllmm1,
+     .			dtdiss,dtvr,dtphys,pi,r,cpp,kappa,unsim
+      IMPLICIT NONE
+c
+c      P. Le Van
+c
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+c
+#include "dimensions.h"
+#include "paramet.h"
+!#include "control.h"
+
+
+      INTEGER :: l
+c
+c
+      EXTERNAL disvert
+c
+c-----------------------------------------------------------------------
+c   dimension des boucles:
+c   ----------------------
+
+      im      = iim
+      jm      = jjm
+      lllm    = llm
+      imp1    = iim 
+      jmp1    = jjm + 1
+      lllmm1  = llm - 1
+      lllmp1  = llm + 1
+
+c-----------------------------------------------------------------------
+
+      dtdiss  = dissip_period * dtvr
+      dtphys  = iphysiq * dtvr
+      unsim   = 1./iim
+      pi      = 2.*ASIN( 1. )
+
+!      print*,'iphysiq=',iphysiq
+!      print*,'dtvr=',dtvr
+!      print*,'dtphys=',dtphys
+!      stop
+
+c-----------------------------------------------------------------------
+c
+
+      r       = cpp * kappa
+
+      PRINT*,' R  CPP  Kappa ',  r , cpp,  kappa
+c
+c-----------------------------------------------------------------------
+      CALL disvert
+c
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/inidissip.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/inidissip.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/inidissip.F	(revision 1644)
@@ -0,0 +1,296 @@
+      SUBROUTINE inidissip ( lstardis,nitergdiv,nitergrot,niterh  ,
+     *                       tetagdiv,tetagrot,tetatemp             )
+c=======================================================================
+c   initialisation de la dissipation horizontale
+c=======================================================================
+c-----------------------------------------------------------------------
+c   declarations:
+c   -------------
+
+      use control_mod, only: dissip_period, iperiod
+      USE comvert_mod, ONLY: aps,bps,pseudoalt,preff
+      USE comconst_mod, ONLY: dtdiss,dtvr
+      IMPLICIT NONE
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissipn.h"
+!#include "control.h"
+
+      LOGICAL lstardis
+      INTEGER nitergdiv,nitergrot,niterh
+      REAL    tetagdiv,tetagrot,tetatemp
+      REAL zvert(llm),zz
+      REAL zh(ip1jmp1),zu(ip1jmp1),zv(ip1jm),deltap(ip1jmp1,llm)
+      REAL ullm,vllm,umin,vmin,zhmin,zhmax
+      REAL zllm,z1llm
+
+      INTEGER l,ij,idum,ii
+      REAL tetamin
+
+      EXTERNAL ran1
+      REAL ran1
+      real sig_s(llm)
+      save sig_s
+      logical firstcall
+      data firstcall/.true./
+      save firstcall 
+
+      REAL fac_mid
+      REAL fac_up
+      REAL delta
+      REAL middle,startalt
+      SAVE fac_mid, fac_up, delta, startalt, middle
+
+c ------------------------------------------------------
+      if (firstcall) then
+         firstcall=.false.
+         do l=1,llm
+            sig_s(l)=aps(l)/preff + bps(l)
+         enddo
+
+c        COMPUTING THE VARIATION OF DISSIPATION AS A FUNCTION OF MODEL TOP :
+c         FF 2004       
+         if (pseudoalt(llm).lt.160.) then 
+!     currently disabled for the universal model!!!
+             fac_mid=2  ! coeff  pour dissipation aux basses/moyennes altitudes
+             fac_up=10 ! coeff multiplicateur pour dissipation hautes altitudes
+             startalt=90. ! altitude en Km de la transition mid / up
+             delta=20.! Intervalle (km) pour le changement mid / up
+
+!             fac_mid=1  ! coeff  pour dissipation aux basses/moyennes altitudes
+!             fac_up=1 ! coeff multiplicateur pour dissipation hautes altitudes
+!             startalt=100. ! altitude en Km de la transition mid / up
+!             delta=20.! Intervalle (km) pour le changement mid / up
+
+         else ! thermosphere model
+             fac_mid=2 ! coeff pour dissipation aux basses/moyennes altitudes
+             fac_up=25 ! coeff multiplicateur pour dissipation hautes altitudes
+c            startalt: 95 OK for MY24
+             startalt=95. ! altitude en Km de la transition mid / up
+             delta=30.! Intervalle (km) pour le changement mid /up
+         end if
+         middle=startalt+delta/2
+         write(*,*) 'Dissipation : '
+         write(*,*) 'Multiplication de la dissipation en altitude :',
+     &          ' fac_mid, fac_up =', fac_mid, fac_up 
+         write(*,*) 'Transition mid /up : startalt, delta =',
+     &             startalt, delta , '(km)'
+      endif
+
+c-----------------------------------------------------------------------
+c
+c   calcul des valeurs propres des operateurs par methode iterrative:
+c   -----------------------------------------------------------------
+
+      crot     = -1.
+      cdivu    = -1.
+      cdivh    = -1.
+
+c   calcul de la valeur propre de divgrad:
+c   --------------------------------------
+      idum = 0
+      DO l = 1, llm
+       DO ij = 1, ip1jmp1
+        deltap(ij,l) = 1.
+       ENDDO
+      ENDDO
+
+      idum  = -1
+      zh(1) = RAN1(idum)-.5
+      idum  = 0
+      DO ij = 2, ip1jmp1
+        zh(ij) = RAN1(idum) -.5
+      ENDDO
+
+      CALL filtreg (zh,jjp1,1,2,1,.TRUE.,1)
+
+      CALL minmax(iip1*jjp1,zh,zhmin,zhmax )
+
+      IF ( zhmin .GE. zhmax  )     THEN
+         PRINT*,'  Inidissip  zh min max  ',zhmin,zhmax
+         STOP'probleme generateur alleatoire dans inidissip'
+      ENDIF
+
+      zllm = ABS( zhmax )
+      DO l = 1,50
+         IF(lstardis) THEN
+            CALL divgrad2(1,zh,deltap,niterh,zh)
+         ELSE
+            CALL divgrad (1,zh,niterh,zh)
+         ENDIF
+
+        CALL minmax(iip1*jjp1,zh,zhmin,zhmax )
+
+         zllm  = ABS( zhmax )
+         z1llm = 1./zllm
+         DO ij = 1,ip1jmp1
+            zh(ij) = zh(ij)* z1llm
+         ENDDO
+      ENDDO
+
+      IF(lstardis) THEN
+         cdivh = 1./ zllm
+      ELSE
+         cdivh = zllm ** ( -1./niterh )
+      ENDIF
+
+c   calcul des valeurs propres de gradiv (ii =1) et  nxgrarot(ii=2)
+c   -----------------------------------------------------------------
+      print*,'calcul des valeurs propres'
+
+      DO  20  ii = 1, 2
+c
+         DO ij = 1, ip1jmp1
+           zu(ij)  = RAN1(idum) -.5
+         ENDDO
+         CALL filtreg (zu,jjp1,1,2,1,.TRUE.,1)
+         DO ij = 1, ip1jm
+            zv(ij) = RAN1(idum) -.5
+         ENDDO
+         CALL filtreg (zv,jjm,1,2,1,.FALSE.,1)
+
+         CALL minmax(iip1*jjp1,zu,umin,ullm )
+         CALL minmax(iip1*jjm, zv,vmin,vllm )
+
+         ullm = ABS ( ullm )
+         vllm = ABS ( vllm )
+
+         DO  5  l = 1, 50
+            IF(ii.EQ.1) THEN
+               IF(lstardis) THEN
+                  CALL gradiv2( 1,zu,zv,nitergdiv,zu,zv )
+               ELSE
+                  CALL gradiv ( 1,zu,zv,nitergdiv,zu,zv )
+               ENDIF
+            ELSE
+               IF(lstardis) THEN
+                  CALL nxgraro2( 1,zu,zv,nitergrot,zu,zv )
+               ELSE
+                  CALL nxgrarot( 1,zu,zv,nitergrot,zu,zv )
+               ENDIF
+            ENDIF
+
+            CALL minmax(iip1*jjp1,zu,umin,ullm )
+            CALL minmax(iip1*jjm, zv,vmin,vllm )
+
+            ullm = ABS  ( ullm )
+            vllm = ABS  ( vllm )
+
+            zllm  = MAX( ullm,vllm )
+            z1llm = 1./ zllm
+            DO ij = 1, ip1jmp1
+              zu(ij) = zu(ij)* z1llm
+            ENDDO
+            DO ij = 1, ip1jm
+               zv(ij) = zv(ij)* z1llm
+            ENDDO
+ 5       CONTINUE
+
+         IF ( ii.EQ.1 ) THEN
+            IF(lstardis) THEN
+               cdivu  = 1./zllm
+            ELSE
+               cdivu  = zllm **( -1./nitergdiv )
+            ENDIF
+         ELSE
+            IF(lstardis) THEN
+               crot   = 1./ zllm
+            ELSE
+               crot   = zllm **( -1./nitergrot )
+            ENDIF
+         ENDIF
+
+ 20   CONTINUE
+
+c   petit test pour les operateurs non star:
+c   ----------------------------------------
+
+c     IF(.NOT.lstardis) THEN
+c        fac_mid    = rad*24./float(jjm)
+c        fac_mid    = fac_mid*fac_mid
+c        PRINT*,'coef u ', fac_mid/cdivu, 1./cdivu
+c        PRINT*,'coef r ', fac_mid/crot , 1./crot
+c        PRINT*,'coef h ', fac_mid/cdivh, 1./cdivh
+c     ENDIF
+
+c-----------------------------------------------------------------------
+c   variation verticale du coefficient de dissipation:
+c   --------------------------------------------------
+
+      DO l=1,llm
+         zvert(l)=1.
+      ENDDO
+
+c
+      DO l = 1, llm
+         zz   = 1. -1./sig_s(l)
+         zvert(l)= fac_mid -( fac_mid-1.)/( 1.+zz*zz )
+
+c ---------------------------------------------------------------
+c Utilisation de la fonction tangente hyperbolique pour augmenter
+c arbitrairement la dissipation et donc la stabilite du modele a 
+c partir d'une certaine altitude.
+
+c   Le facteur multiplicatif de basse atmosphere etant deja pris 
+c   en compte, il faut diviser le facteur multiplicatif de haute 
+c   atmosphere par celui-ci.
+c   ============================================================
+
+         zvert(l)= zvert(l)*(1.0+((fac_up/fac_mid-1)
+     &   *(1-(0.5*(1+tanh(-6./delta*    
+     &   (10.*(-log(sig_s(l)))-middle)))))
+     &   ))
+      ENDDO
+ 
+c -----------------------------------------------------------------------------
+
+c
+
+      PRINT*,'Constantes de temps de la diffusion horizontale'
+
+      tetamin =  1.e+6
+
+
+      DO l=1,llm
+        tetaudiv(l)   = zvert(l)/tetagdiv
+        tetaurot(l)   = zvert(l)/tetagrot
+        tetah(l)      = zvert(l)/tetatemp
+
+        IF( tetamin.GT. (1./tetaudiv(l)) ) tetamin = 1./ tetaudiv(l)
+        IF( tetamin.GT. (1./tetaurot(l)) ) tetamin = 1./ tetaurot(l)
+        IF( tetamin.GT. (1./   tetah(l)) ) tetamin = 1./    tetah(l)
+      ENDDO
+
+c     Calcul automatique de dissip_period
+c     -----------------------------
+c    :::::::::::::::::::::
+c     A Commenter pour garder la valeur de run.def :
+c     dissip_period = INT( tetamin/( 2.*dtvr*iperiod) ) * iperiod
+c     dissip_period = MAX(iperiod,idissip)
+c    :::::::::::::::::::::
+      dtdiss  = dissip_period * dtvr
+ 
+      PRINT *,' INIDI tetamin dtvr ',tetamin,dtvr,iperiod
+      PRINT *,' INIDI tetamin dissip_period ',tetamin,dissip_period
+      PRINT *,' INIDI dissip_period dtdiss ',dissip_period,dtdiss
+
+      PRINT*,'pseudoZ(km)  zvert  dt(tetagdiv) dt(tetagrot) dt(divgrad)'
+      DO l = 1,llm
+         PRINT*,pseudoalt(l),zvert(l),dtdiss*tetaudiv(l),
+     *        dtdiss*tetaurot(l),dtdiss*tetah(l)
+         if ( (dtdiss*tetaudiv(l).gt.1.9).or.
+     &        (dtdiss*tetaurot(l).gt.1.9).or.
+     &        (dtdiss*tetah(l).gt.1.9)) then
+          PRINT *,'STOP : your dissipation is too intense for the '      
+          PRINT *,'dissipation timestep : unstable model !'
+          PRINT *,'in run.def, you must increase tetagdiv,' 
+          PRINT *,'(or tetagrot and tetatemp if they are smaller than'
+          PRINT *,'tetagdiv) OR decrease dissip_period'
+          PRINT *,'OR increase day_step)' 
+          stop
+         end if
+  
+      ENDDO
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/inigeom.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/inigeom.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/inigeom.F	(revision 1644)
@@ -0,0 +1,701 @@
+c
+c $Header: /users/lmdz/cvsroot/LMDZ.3.3/libf/dyn3d/inigeom.F,v 1.3 2001/04/13 15:49:10 lmdz Exp $
+c
+      SUBROUTINE inigeom
+c
+c     Auteur :  P. Le Van
+c
+c   ............      Version  du 01/04/2001     ........................
+c
+c  Calcul des elongations cuij1,.cuij4 , cvij1,..cvij4  aux memes en-
+c     endroits que les aires aireij1,..aireij4 .
+
+c  Choix entre f(y) a derivee sinusoid. ou a derivee tangente hyperbol.
+c
+c
+      USE comconst_mod, ONLY: rad,omeg,g,pi
+      USE logic_mod, ONLY: fxyhypb,ysinus
+      USE serre_mod, ONLY: clon,clat,transx,transy,alphax,alphay,
+     .		pxo,pyo,grossismx,grossismy,dzoomx,dzoomy,taux,tauy
+
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom2.h"
+#include "comdissnew.h"
+
+c-----------------------------------------------------------------------
+c   ....  Variables  locales   ....
+c
+      INTEGER  i,j,itmax,itmay,iter
+      REAL cvu(iip1,jjp1),cuv(iip1,jjm)
+      REAL ai14,ai23,airez,rlatp,rlatm,xprm,xprp,un4rad2,yprp,yprm
+      REAL eps,x1,xo1,f,df,xdm,y1,yo1,ydm
+      REAL coslatm,coslatp,radclatm,radclatp
+      REAL cuij1(iip1,jjp1),cuij2(iip1,jjp1),cuij3(iip1,jjp1),
+     *     cuij4(iip1,jjp1)
+      REAL cvij1(iip1,jjp1),cvij2(iip1,jjp1),cvij3(iip1,jjp1),
+     *     cvij4(iip1,jjp1)
+      REAL rlonvv(iip1),rlatuu(jjp1)
+      REAL rlatu1(jjm),yprimu1(jjm),rlatu2(jjm),yprimu2(jjm) ,
+     *     yprimv(jjm),yprimu(jjp1)
+      REAL gamdi_gdiv, gamdi_grot, gamdi_h
+ 
+      REAL rlonm025(iip1),xprimm025(iip1), rlonp025(iip1),
+     ,  xprimp025(iip1)
+      SAVE rlatu1,yprimu1,rlatu2,yprimu2,yprimv,yprimu
+      SAVE rlonm025,xprimm025,rlonp025,xprimp025
+
+      REAL      SSUM
+      EXTERNAL  SSUM
+c
+c
+c   ------------------------------------------------------------------
+c   -                                                                -
+c   -    calcul des coeff. ( cu, cv , 1./cu**2,  1./cv**2  )         -
+c   -                                                                -
+c   ------------------------------------------------------------------
+c
+c      les coef. ( cu, cv ) permettent de passer des vitesses naturelles
+c      aux vitesses covariantes et contravariantes , ou vice-versa ...
+c
+c
+c     on a :  u (covariant) = cu * u (naturel)   , u(contrav)= u(nat)/cu
+c             v (covariant) = cv * v (naturel)   , v(contrav)= v(nat)/cv
+c
+c       on en tire :  u(covariant) = cu * cu * u(contravariant)
+c                     v(covariant) = cv * cv * v(contravariant)
+c
+c
+c     on a l'application (  x(X) , y(Y) )   avec - im/2 +1 <  X  < im/2
+c                                                          =     =
+c                                           et   - jm/2    <  Y  < jm/2
+c                                                          =     =
+c
+c      ...................................................
+c      ...................................................
+c      .  x  est la longitude du point  en radians       .
+c      .  y  est la  latitude du point  en radians       .
+c      .                                                 .
+c      .  on a :  cu(i,j) = rad * COS(y) * dx/dX         .
+c      .          cv( j ) = rad          * dy/dY         .
+c      .        aire(i,j) =  cu(i,j) * cv(j)             .
+c      .                                                 .
+c      . y, dx/dX, dy/dY calcules aux points concernes   .
+c      .                                                 .
+c      ...................................................
+c      ...................................................
+c
+c
+c
+c                                                           ,
+c    cv , bien que dependant de j uniquement,sera ici indice aussi en i
+c          pour un adressage plus facile en  ij  .
+c
+c
+c
+c  **************  aux points  u  et  v ,           *****************
+c      xprimu et xprimv sont respectivement les valeurs de  dx/dX
+c      yprimu et yprimv    .  .  .  .  .  .  .  .  .  .  .  dy/dY
+c      rlatu  et  rlatv    .  .  .  .  .  .  .  .  .  .  .la latitude
+c      cvu    et   cv      .  .  .  .  .  .  .  .  .  .  .    cv
+c
+c  **************  aux points u, v, scalaires, et z  ****************
+c      cu, cuv, cuscal, cuz sont respectiv. les valeurs de    cu
+c
+c
+c
+c         Exemple de distribution de variables sur la grille dans le
+c             domaine de travail ( X,Y ) .
+c     ................................................................
+c                  DX=DY= 1
+c
+c   
+c        +     represente  un  point scalaire ( p.exp  la pression )
+c        >     represente  la composante zonale du  vent
+c        V     represente  la composante meridienne du vent
+c        o     represente  la  vorticite
+c
+c       ----  , car aux poles , les comp.zonales covariantes sont nulles
+c
+c
+c
+c         i ->
+c
+c         1      2      3      4      5      6      7      8
+c  j
+c  v  1   + ---- + ---- + ---- + ---- + ---- + ---- + ---- + --
+c
+c         V   o  V   o  V   o  V   o  V   o  V   o  V   o  V  o
+c
+c     2   +   >  +   >  +   >  +   >  +   >  +   >  +   >  +  >
+c
+c         V   o  V   o  V   o  V   o  V   o  V   o  V   o  V  o
+c
+c     3   +   >  +   >  +   >  +   >  +   >  +   >  +   >  +  >
+c
+c         V   o  V   o  V   o  V   o  V   o  V   o  V   o  V  o
+c
+c     4   +   >  +   >  +   >  +   >  +   >  +   >  +   >  +  >
+c
+c         V   o  V   o  V   o  V   o  V   o  V   o  V   o  V  o
+c
+c     5   + ---- + ---- + ---- + ---- + ---- + ---- + ---- + --
+c
+c
+c      Ci-dessus,  on voit que le nombre de pts.en longitude est egal
+c                 a   IM = 8
+c      De meme ,   le nombre d'intervalles entre les 2 poles est egal
+c                 a   JM = 4
+c
+c      Les points scalaires ( + ) correspondent donc a des valeurs
+c       entieres  de  i ( 1 a IM )   et  de  j ( 1 a  JM +1 )   .
+c
+c      Les vents    U       ( > ) correspondent a des valeurs  semi-
+c       entieres  de i ( 1+ 0.5 a IM+ 0.5) et entieres de j ( 1 a JM+1)
+c
+c      Les vents    V       ( V ) correspondent a des valeurs entieres
+c       de     i ( 1 a  IM ) et semi-entieres de  j ( 1 +0.5  a JM +0.5)
+c
+c
+c
+      WRITE(6,3) 
+ 3    FORMAT( // 10x,' ....  INIGEOM  date du 01/06/98   ..... ',
+     * //5x,'   Calcul des elongations cu et cv  comme sommes des 4 ' /
+     *  5x,' elong. cuij1, .. 4  , cvij1,.. 4  qui les entourent , aux 
+     * '/ 5x,' memes endroits que les aires aireij1,...j4   . ' / )
+c
+c
+      IF( nitergdiv.NE.2 ) THEN
+        gamdi_gdiv = coefdis/ ( float(nitergdiv) -2. )
+      ELSE
+        gamdi_gdiv = 0.
+      ENDIF
+      IF( nitergrot.NE.2 ) THEN
+        gamdi_grot = coefdis/ ( float(nitergrot) -2. )
+      ELSE
+        gamdi_grot = 0.
+      ENDIF
+      IF( niterh.NE.2 ) THEN
+        gamdi_h = coefdis/ ( float(niterh) -2. )
+      ELSE
+        gamdi_h = 0.
+      ENDIF
+
+      WRITE(6,*) ' gamdi_gd ',gamdi_gdiv,gamdi_grot,gamdi_h,coefdis,
+     *  nitergdiv,nitergrot,niterh
+c
+      pi    = 2.* ASIN(1.)
+c
+      WRITE(6,990) 
+
+c     ----------------------------------------------------------------
+c
+      IF( .NOT.fxyhypb )   THEN
+c
+c
+       IF( ysinus )  THEN
+c
+        WRITE(6,*) ' ***  Inigeom ,  Y = Sinus ( Latitude ) *** '
+c
+c   .... utilisation de f(x,y )  avec  y  =  sinus de la latitude  .....
+
+        CALL  fxysinus (rlatu,yprimu,rlatv,yprimv,rlatu1,yprimu1,
+     ,                    rlatu2,yprimu2,
+     ,  rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025)
+
+       ELSE
+c
+        WRITE(6,*) '*** Inigeom ,  Y = Latitude  , der. sinusoid . ***'
+
+c  .... utilisation  de f(x,y) a tangente sinusoidale , y etant la latit. ...
+c
+ 
+        pxo   = clon *pi /180.
+        pyo   = 2.* clat* pi /180.
+c
+c  ....  determination de  transx ( pour le zoom ) par Newton-Raphson ...
+c
+        itmax = 10
+        eps   = .1e-7
+c
+        xo1 = 0.
+        DO 10 iter = 1, itmax
+        x1  = xo1
+        f   = x1+ alphax *SIN(x1-pxo)
+        df  = 1.+ alphax *COS(x1-pxo)
+        x1  = x1 - f/df
+        xdm = ABS( x1- xo1 )
+        IF( xdm.LE.eps )GO TO 11
+        xo1 = x1
+ 10     CONTINUE
+ 11     CONTINUE
+c
+        transx = xo1
+
+        itmay = 10
+        eps   = .1e-7
+C
+        yo1  = 0.
+        DO 15 iter = 1,itmay
+        y1   = yo1
+        f    = y1 + alphay* SIN(y1-pyo)
+        df   = 1. + alphay* COS(y1-pyo)
+        y1   = y1 -f/df
+        ydm  = ABS(y1-yo1)
+        IF(ydm.LE.eps) GO TO 17
+        yo1  = y1
+ 15     CONTINUE
+c
+ 17     CONTINUE
+        transy = yo1
+
+        CALL fxy ( rlatu,yprimu,rlatv,yprimv,rlatu1,yprimu1,
+     ,              rlatu2,yprimu2,
+     ,  rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025)
+
+       ENDIF
+c
+      ELSE
+c
+c   ....  Utilisation  de fxyhyper , f(x,y) a derivee tangente hyperbol.
+c   .....................................................................
+
+      WRITE(6,*)'*** Inigeom , Y = Latitude  , der.tg. hyperbolique ***'
+ 
+       CALL fxyhyper( clat, grossismy, dzoomy, tauy    , 
+     ,                clon, grossismx, dzoomx, taux    ,
+     , rlatu,yprimu,rlatv, yprimv,rlatu1, yprimu1,rlatu2,yprimu2  ,
+     , rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025 )
+
+  
+      ENDIF
+c
+c  -------------------------------------------------------------------
+
+c
+      rlatu(1)    =     ASIN(1.)
+      rlatu(jjp1) =  - rlatu(1)
+c
+c
+c   ....  calcul  aux  poles  ....
+c
+      yprimu(1)      = 0.
+      yprimu(jjp1)   = 0.
+c
+c
+      un4rad2 = 0.25 * rad * rad
+c
+c   --------------------------------------------------------------------
+c   --------------------------------------------------------------------
+c   -                                                                  -
+c   -  calcul  des aires ( aire,aireu,airev, 1./aire, 1./airez  )      -
+c   -      et de   fext ,  force de coriolis  extensive  .             -
+c   -                                                                  -
+c   --------------------------------------------------------------------
+c   --------------------------------------------------------------------
+c
+c
+c
+c   A 1 point scalaire P (i,j) de la grille, reguliere en (X,Y) , sont
+c   affectees 4 aires entourant P , calculees respectivement aux points
+c            ( i + 1/4, j - 1/4 )    :    aireij1 (i,j)
+c            ( i + 1/4, j + 1/4 )    :    aireij2 (i,j)
+c            ( i - 1/4, j + 1/4 )    :    aireij3 (i,j)
+c            ( i - 1/4, j - 1/4 )    :    aireij4 (i,j)
+c
+c           ,
+c   Les cotes de chacun de ces 4 carres etant egaux a 1/2 suivant (X,Y).
+c   Chaque aire centree en 1 point scalaire P(i,j) est egale a la somme
+c   des 4 aires  aireij1,aireij2,aireij3,aireij4 qui sont affectees au
+c   point (i,j) .
+c   On definit en outre les coefficients  alpha comme etant egaux a
+c    (aireij / aire), c.a.d par exp.  alpha1(i,j)=aireij1(i,j)/aire(i,j)
+c
+c   De meme, toute aire centree en 1 point U est egale a la somme des
+c   4 aires aireij1,aireij2,aireij3,aireij4 entourant le point U .
+c    Idem pour  airev, airez .
+c
+c       On a ,pour chaque maille :    dX = dY = 1
+c
+c
+c                             . V
+c
+c                 aireij4 .        . aireij1
+c
+c                   U .       . P      . U
+c
+c                 aireij3 .        . aireij2
+c
+c                             . V
+c
+c
+c
+c
+c
+c   ....................................................................
+c
+c    Calcul des 4 aires elementaires aireij1,aireij2,aireij3,aireij4
+c   qui entourent chaque aire(i,j) , ainsi que les 4 elongations elemen
+c   taires cuij et les 4 elongat. cvij qui sont calculees aux memes 
+c     endroits  que les aireij   .    
+c
+c   ....................................................................
+c
+c     .......  do 35  :   boucle sur les  jjm + 1  latitudes   .....
+c
+c
+      DO 35 j = 1, jjp1
+c
+      IF ( j. eq. 1 )  THEN
+c
+      yprm           = yprimu1(j)
+      rlatm          = rlatu1(j)
+c
+      coslatm        = COS( rlatm )
+      radclatm       = 0.5* rad * coslatm
+c
+      DO 30 i = 1, iim
+      xprp           = xprimp025( i )
+      xprm           = xprimm025( i )
+
+      aireij2( i,1 ) = un4rad2 * coslatm  * xprp * yprm
+      aireij3( i,1 ) = un4rad2 * coslatm  * xprm * yprm
+      cuij2  ( i,1 ) = radclatm * xprp
+      cuij3  ( i,1 ) = radclatm * xprm
+      cvij2  ( i,1 ) = 0.5* rad * yprm
+      cvij3  ( i,1 ) = cvij2(i,1)
+  30  CONTINUE
+c
+      DO  i = 1, iim
+      aireij1( i,1 ) = 0.
+      aireij4( i,1 ) = 0.
+      cuij1  ( i,1 ) = 0.
+      cuij4  ( i,1 ) = 0.
+      cvij1  ( i,1 ) = 0.
+      cvij4  ( i,1 ) = 0.
+      ENDDO
+c
+      END IF
+c
+      IF ( j. eq. jjp1 )  THEN
+       yprp               = yprimu2(j-1)
+       rlatp              = rlatu2 (j-1)
+ccc       yprp             = fyprim( FLOAT(j) - 0.25 )
+ccc       rlatp            = fy    ( FLOAT(j) - 0.25 )
+c
+      coslatp             = COS( rlatp )
+      radclatp            = 0.5* rad * coslatp
+c
+      DO 31 i = 1,iim
+        xprp              = xprimp025( i )
+        xprm              = xprimm025( i )
+        aireij1( i,jjp1 ) = un4rad2 * coslatp  * xprp * yprp
+        aireij4( i,jjp1 ) = un4rad2 * coslatp  * xprm * yprp
+        cuij1(i,jjp1)     = radclatp * xprp
+        cuij4(i,jjp1)     = radclatp * xprm
+        cvij1(i,jjp1)     = 0.5 * rad* yprp
+        cvij4(i,jjp1)     = cvij1(i,jjp1)
+ 31   CONTINUE
+c
+       DO   i    = 1, iim
+        aireij2( i,jjp1 ) = 0.
+        aireij3( i,jjp1 ) = 0.
+        cvij2  ( i,jjp1 ) = 0.
+        cvij3  ( i,jjp1 ) = 0.
+        cuij2  ( i,jjp1 ) = 0.
+        cuij3  ( i,jjp1 ) = 0.
+       ENDDO
+c
+      END IF
+c
+
+      IF ( j .gt. 1 .AND. j .lt. jjp1 )  THEN
+c
+        rlatp    = rlatu2 ( j-1 )
+        yprp     = yprimu2( j-1 )
+        rlatm    = rlatu1 (  j  )
+        yprm     = yprimu1(  j  )
+cc         rlatp    = fy    ( FLOAT(j) - 0.25 )
+cc         yprp     = fyprim( FLOAT(j) - 0.25 )
+cc         rlatm    = fy    ( FLOAT(j) + 0.25 )
+cc         yprm     = fyprim( FLOAT(j) + 0.25 )
+
+         coslatm  = COS( rlatm )
+         coslatp  = COS( rlatp )
+         radclatp = 0.5* rad * coslatp
+         radclatm = 0.5* rad * coslatm
+c
+         DO 32 i = 1,iim
+         xprp            = xprimp025( i )
+         xprm            = xprimm025( i )
+      
+         ai14            = un4rad2 * coslatp * yprp
+         ai23            = un4rad2 * coslatm * yprm
+         aireij1 ( i,j ) = ai14 * xprp
+         aireij2 ( i,j ) = ai23 * xprp
+         aireij3 ( i,j ) = ai23 * xprm
+         aireij4 ( i,j ) = ai14 * xprm
+         cuij1   ( i,j ) = radclatp * xprp
+         cuij2   ( i,j ) = radclatm * xprp
+         cuij3   ( i,j ) = radclatm * xprm
+         cuij4   ( i,j ) = radclatp * xprm
+         cvij1   ( i,j ) = 0.5* rad * yprp
+         cvij2   ( i,j ) = 0.5* rad * yprm
+         cvij3   ( i,j ) = cvij2(i,j)
+         cvij4   ( i,j ) = cvij1(i,j)
+  32     CONTINUE
+c
+      END IF
+c
+c    ........       periodicite   ............
+c
+         cvij1   (iip1,j) = cvij1   (1,j)
+         cvij2   (iip1,j) = cvij2   (1,j)
+         cvij3   (iip1,j) = cvij3   (1,j)
+         cvij4   (iip1,j) = cvij4   (1,j)
+         cuij1   (iip1,j) = cuij1   (1,j)
+         cuij2   (iip1,j) = cuij2   (1,j)
+         cuij3   (iip1,j) = cuij3   (1,j)
+         cuij4   (iip1,j) = cuij4   (1,j)
+         aireij1 (iip1,j) = aireij1 (1,j )
+         aireij2 (iip1,j) = aireij2 (1,j )
+         aireij3 (iip1,j) = aireij3 (1,j )
+         aireij4 (iip1,j) = aireij4 (1,j )
+        
+  35  CONTINUE
+c
+c    ..............................................................
+c
+      DO 37 j = 1, jjp1
+      DO 36 i = 1, iim
+      aire    ( i,j )  = aireij1(i,j) + aireij2(i,j) + aireij3(i,j) +
+     *                          aireij4(i,j)
+      alpha1  ( i,j )  = aireij1(i,j) / aire(i,j)
+      alpha2  ( i,j )  = aireij2(i,j) / aire(i,j)
+      alpha3  ( i,j )  = aireij3(i,j) / aire(i,j)
+      alpha4  ( i,j )  = aireij4(i,j) / aire(i,j)
+      alpha1p2( i,j )  = alpha1 (i,j) + alpha2 (i,j)
+      alpha1p4( i,j )  = alpha1 (i,j) + alpha4 (i,j)
+      alpha2p3( i,j )  = alpha2 (i,j) + alpha3 (i,j)
+      alpha3p4( i,j )  = alpha3 (i,j) + alpha4 (i,j)
+  36  CONTINUE
+c
+c
+      aire    (iip1,j) = aire    (1,j)
+      alpha1  (iip1,j) = alpha1  (1,j)
+      alpha2  (iip1,j) = alpha2  (1,j)
+      alpha3  (iip1,j) = alpha3  (1,j)
+      alpha4  (iip1,j) = alpha4  (1,j)
+      alpha1p2(iip1,j) = alpha1p2(1,j)
+      alpha1p4(iip1,j) = alpha1p4(1,j)
+      alpha2p3(iip1,j) = alpha2p3(1,j)
+      alpha3p4(iip1,j) = alpha3p4(1,j)
+  37  CONTINUE
+c
+
+      DO 42 j = 1,jjp1
+      DO 41 i = 1,iim
+      aireu       (i,j)= aireij1(i,j) + aireij2(i,j) + aireij4(i+1,j) +
+     *                                aireij3(i+1,j)
+      unsaire    ( i,j)= 1./ aire(i,j)
+      unsair_gam1( i,j)= unsaire(i,j)** ( - gamdi_gdiv )
+      unsair_gam2( i,j)= unsaire(i,j)** ( - gamdi_h    )
+      airesurg   ( i,j)= aire(i,j)/ g
+  41  CONTINUE
+      aireu     (iip1,j)  = aireu  (1,j)
+      unsaire   (iip1,j)  = unsaire(1,j)
+      unsair_gam1(iip1,j) = unsair_gam1(1,j)
+      unsair_gam2(iip1,j) = unsair_gam2(1,j)
+      airesurg   (iip1,j) = airesurg(1,j)
+  42  CONTINUE
+c
+c
+      DO 48 j = 1,jjm
+c
+        DO i=1,iim
+         airev     (i,j) = aireij2(i,j)+ aireij3(i,j)+ aireij1(i,j+1) +
+     *                           aireij4(i,j+1)
+        ENDDO
+         DO i=1,iim
+          airez         = aireij2(i,j)+aireij1(i,j+1)+aireij3(i+1,j) +
+     *                           aireij4(i+1,j+1)
+          unsairez(i,j) = 1./ airez
+          unsairz_gam(i,j)= unsairez(i,j)** ( - gamdi_grot )
+          fext    (i,j)   = airez * SIN(rlatv(j))* 2.* omeg
+         ENDDO
+        airev     (iip1,j)  = airev(1,j)
+        unsairez  (iip1,j)  = unsairez(1,j)
+        fext      (iip1,j)  = fext(1,j)
+        unsairz_gam(iip1,j) = unsairz_gam(1,j)
+c
+  48  CONTINUE
+c
+c
+c    .....      Calcul  des elongations cu,cv, cvu     .........
+c
+      DO    j   = 1, jjm
+       DO   i  = 1, iim
+       cv(i,j) = 0.5 *( cvij2(i,j)+cvij3(i,j)+cvij1(i,j+1)+cvij4(i,j+1))
+       cvu(i,j)= 0.5 *( cvij1(i,j)+cvij4(i,j)+cvij2(i,j)  +cvij3(i,j) )
+       cuv(i,j)= 0.5 *( cuij2(i,j)+cuij3(i,j)+cuij1(i,j+1)+cuij4(i,j+1))
+       unscv2(i,j) = 1./ ( cv(i,j)*cv(i,j) )
+       ENDDO
+       DO   i  = 1, iim
+       cuvsurcv (i,j)    = airev(i,j)  * unscv2(i,j)
+       cvsurcuv (i,j)    = 1./cuvsurcv(i,j)
+       cuvscvgam1(i,j)   = cuvsurcv (i,j) ** ( - gamdi_gdiv )
+       cuvscvgam2(i,j)   = cuvsurcv (i,j) ** ( - gamdi_h )
+       cvscuvgam(i,j)    = cvsurcuv (i,j) ** ( - gamdi_grot )
+       ENDDO
+       cv       (iip1,j)  = cv       (1,j)
+       cvu      (iip1,j)  = cvu      (1,j)
+       unscv2   (iip1,j)  = unscv2   (1,j)
+       cuv      (iip1,j)  = cuv      (1,j)
+       cuvsurcv (iip1,j)  = cuvsurcv (1,j)
+       cvsurcuv (iip1,j)  = cvsurcuv (1,j)
+       cuvscvgam1(iip1,j) = cuvscvgam1(1,j)
+       cuvscvgam2(iip1,j) = cuvscvgam2(1,j)
+       cvscuvgam(iip1,j)  = cvscuvgam(1,j)
+      ENDDO
+
+      DO  j     = 2, jjm
+        DO   i  = 1, iim
+        cu(i,j) = 0.5*(cuij1(i,j)+cuij4(i+1,j)+cuij2(i,j)+cuij3(i+1,j))
+        unscu2    (i,j)  = 1./ ( cu(i,j) * cu(i,j) )
+        cvusurcu  (i,j)  =  aireu(i,j) * unscu2(i,j)
+        cusurcvu  (i,j)  = 1./ cvusurcu(i,j)
+        cvuscugam1 (i,j) = cvusurcu(i,j) ** ( - gamdi_gdiv ) 
+        cvuscugam2 (i,j) = cvusurcu(i,j) ** ( - gamdi_h    ) 
+        cuscvugam (i,j)  = cusurcvu(i,j) ** ( - gamdi_grot )
+        ENDDO
+        cu       (iip1,j)  = cu(1,j)
+        unscu2   (iip1,j)  = unscu2(1,j)
+        cvusurcu (iip1,j)  = cvusurcu(1,j)
+        cusurcvu (iip1,j)  = cusurcvu(1,j)
+        cvuscugam1(iip1,j) = cvuscugam1(1,j)
+        cvuscugam2(iip1,j) = cvuscugam2(1,j)
+        cuscvugam (iip1,j) = cuscvugam(1,j)
+      ENDDO
+
+c
+c   ....  calcul aux  poles  ....
+c
+      DO    i      =  1, iip1
+        cu    ( i, 1 )  =   0.
+        unscu2( i, 1 )  =   0.
+        cvu   ( i, 1 )  =   0.
+c
+        cu    (i, jjp1) =   0.
+        unscu2(i, jjp1) =   0.
+        cvu   (i, jjp1) =   0.
+      ENDDO
+c
+c    ..............................................................
+c
+      DO j = 1, jjm
+        DO i= 1, iim
+         airvscu2  (i,j) = airev(i,j)/ ( cuv(i,j) * cuv(i,j) )
+         aivscu2gam(i,j) = airvscu2(i,j)** ( - gamdi_grot )
+        ENDDO
+         airvscu2  (iip1,j)  = airvscu2(1,j)
+         aivscu2gam(iip1,j)  = aivscu2gam(1,j)
+      ENDDO
+
+      DO j=2,jjm
+        DO i=1,iim
+         airuscv2   (i,j)    = aireu(i,j)/ ( cvu(i,j) * cvu(i,j) )
+         aiuscv2gam (i,j)    = airuscv2(i,j)** ( - gamdi_grot ) 
+        ENDDO
+         airuscv2  (iip1,j)  = airuscv2  (1,j)
+         aiuscv2gam(iip1,j)  = aiuscv2gam(1,j)
+      ENDDO
+
+c
+c   calcul des aires aux  poles :
+c   -----------------------------
+c
+      apoln       = SSUM(iim,aire(1,1),1)
+      apols       = SSUM(iim,aire(1,jjp1),1)
+      unsapolnga1 = 1./ ( apoln ** ( - gamdi_gdiv ) )
+      unsapolsga1 = 1./ ( apols ** ( - gamdi_gdiv ) )
+      unsapolnga2 = 1./ ( apoln ** ( - gamdi_h    ) )
+      unsapolsga2 = 1./ ( apols ** ( - gamdi_h    ) )
+c
+c-----------------------------------------------------------------------
+c     gtitre='Coriolis version ancienne'
+c     gfichier='fext1'
+c     CALL writestd(fext,iip1*jjm)
+c
+c   changement F. Hourdin calcul conservatif pour fext
+c   constang contient le produit a * cos ( latitude ) * omega
+c
+      DO i=1,iim
+         constang(i,1) = 0.
+      ENDDO
+      DO j=1,jjm-1
+        DO i=1,iim
+         constang(i,j+1) = rad*omeg*cu(i,j+1)*COS(rlatu(j+1))
+        ENDDO
+      ENDDO
+      DO i=1,iim
+         constang(i,jjp1) = 0.
+      ENDDO
+c
+c   periodicite en longitude
+c
+      DO j=1,jjm
+        fext(iip1,j)     = fext(1,j)
+      ENDDO
+      DO j=1,jjp1
+        constang(iip1,j) = constang(1,j)
+      ENDDO
+
+c fin du changement
+
+c
+c-----------------------------------------------------------------------
+c
+       WRITE(6,*) '   ***  Coordonnees de la grille  *** '
+       WRITE(6,995)
+c
+       WRITE(6,*) '   LONGITUDES  aux pts.   V  ( degres )  '
+       WRITE(6,995)
+        DO i=1,iip1
+         rlonvv(i) = rlonv(i)*180./pi
+        ENDDO
+       WRITE(6,400) rlonvv
+c
+       WRITE(6,995)
+       WRITE(6,*) '   LATITUDES   aux pts.   V  ( degres )  '
+       WRITE(6,995)
+        DO i=1,jjm
+         rlatuu(i)=rlatv(i)*180./pi
+        ENDDO
+       WRITE(6,400) (rlatuu(i),i=1,jjm)
+c
+        DO i=1,iip1
+          rlonvv(i)=rlonu(i)*180./pi
+        ENDDO
+       WRITE(6,995)
+       WRITE(6,*) '   LONGITUDES  aux pts.   U  ( degres )  '
+       WRITE(6,995)
+       WRITE(6,400) rlonvv
+       WRITE(6,995)
+
+       WRITE(6,*) '   LATITUDES   aux pts.   U  ( degres )  '
+       WRITE(6,995)
+        DO i=1,jjp1
+         rlatuu(i)=rlatu(i)*180./pi
+        ENDDO
+       WRITE(6,400) (rlatuu(i),i=1,jjp1)
+       WRITE(6,995)
+c
+444    format(f10.3,f6.0)
+400    FORMAT(1x,8f8.2)
+990    FORMAT(//)
+995    FORMAT(/)
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/iniinterp_h.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/iniinterp_h.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/iniinterp_h.F	(revision 1644)
@@ -0,0 +1,239 @@
+      subroutine iniinterp_h (imo,jmo,imn,jmn ,kmax,
+     &       rlonuo,rlatvo,rlonun,rlatvn,
+     &       ktotal,iik,jjk,jk,ik,intersec,airen)
+   
+      implicit none
+
+
+
+c ---------------------------------------------------------
+c Prepare l' interpolation des variables d'une grille LMDZ
+c  dans une autre grille LMDZ en conservant la quantite
+c  totale pour les variables intensives (/m2) : ex : Pression au sol
+c
+c   (Pour chaque case autour d'un point scalaire de la nouvelle
+c    grille, on calcule la surface (en m2)en intersection avec chaque
+c    case de l'ancienne grille , pour la future interpolation)
+c
+c on calcule aussi l' aire dans la nouvelle grille 
+c
+c
+c   Auteur:  F.Forget 01/1995
+c   -------
+c
+c ---------------------------------------------------------
+c   Declarations:
+c ==============
+c
+c  ARGUMENTS
+c  """""""""
+c INPUT
+       integer imo, jmo ! dimensions ancienne grille
+       integer imn,jmn  ! dimensions nouvelle grille
+       integer kmax ! taille du tableau des intersections
+       real rlonuo(imo+1)     !  Latitude et
+       real rlatvo(jmo)       !  longitude des
+       real rlonun(imn+1)     !  bord des
+       real rlatvn(jmn)     !  cases "scalaires" (input)
+
+c OUTPUT
+       integer ktotal ! nombre totale d''intersections reperees
+       integer iik(kmax), jjk(kmax),jk(kmax),ik(kmax)
+       real intersec(kmax)  ! surface des intersections (m2)
+       real airen (imn+1,jmn+1) ! aire dans la nouvelle grille
+
+
+       
+ 
+c Autres variables
+c """"""""""""""""
+       integer i,j,ii,jj
+       integer imomx,jmomx,imnmx1,jmnmx1
+!       parameter (imomx=361,jmomx=180,imnmx1=190,jmnmx1=100)
+       parameter (imomx=361,jmomx=180,imnmx1=360,jmnmx1=190)
+       real a(imomx+1),b(imomx+1),c(jmomx+1),d(jmomx+1)
+       real an(imnmx1+1),bn(imnmx1+1)
+       real cn(jmnmx1+1),dn(jmnmx1+1)
+       real aa, bb,cc,dd
+       real pi
+
+       pi      = 2.*ASIN( 1. )
+
+c Test dimensions imnmx1 jmnmx1
+c""""""""""""""""""""""""""""""
+c test dimensionnement tableau airetest
+      if (imn.GT.imnmx1.OR.jmn.GT.jmnmx1) then
+        write(*,*) 'STOP pb dimensionnement'
+        write(*,*) 'il faut imn < imnmx1 et jmn < jmnmx1'
+        write(*,*) 'imn imnmx1', imn,imnmx1
+        write(*,*) 'jmn jmnmx1', jmn,jmnmx1
+        call exit(1)
+      endif
+
+      if (imo.GT.imomx.OR.jmo.GT.jmomx) then
+        write(*,*) 'STOP pb dimensionnement'
+        write(*,*) 'il faut imo < imomx et jmo < jmomx'
+        write(*,*) 'imo imomx', imo,imomx
+        write(*,*) 'jmo jmomx', jmo,jmomx
+        call exit(1)
+      endif
+
+c On repere les frontieres des cases :
+c =================================== 
+c
+c Attention, on ruse avec des latitudes = 90 deg au pole.
+
+
+c  Ancienne grile
+c  """"""""""""""
+      a(1) =   - rlonuo(imo+1)
+      b(1) = rlonuo(1)
+      do i=2,imo+1
+         a(i) = rlonuo(i-1)
+         b(i) =  rlonuo(i)
+      end do
+
+      d(1) = pi/2 
+      do j=1,jmo
+         c(j) = rlatvo(j) 
+         d(j+1) = rlatvo(j)
+      end do
+      c(jmo+1) = -pi/2 
+      
+
+c  Nouvelle grille
+c  """""""""""""""
+      an(1) =  - rlonun(imn+1)
+      bn(1) = rlonun(1)
+      do i=2,imn+1
+         an(i) = rlonun(i-1)
+         bn(i) =  rlonun(i)
+      end do
+
+      dn(1) = pi/2 
+      do j=1,jmn
+         cn(j) = rlatvn(j)
+         dn(j+1) = rlatvn(j)
+      end do
+      cn(jmn+1) = -pi/2 
+
+c Calcul de la surface des cases scalaires de la nouvelle grille
+c ==============================================================
+      do ii=1,imn + 1
+        do jj = 1,jmn+1
+           airen(ii,jj) = (bn(ii)-an(ii))*(sin(dn(jj))-sin(cn(jj)))
+        end do
+      end do
+
+c Calcul de la surface des intersections
+c ======================================
+
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c test dimenssion kmax (calcul de ktotal)
+c"""""""""""""""""""""""""""""""""""""""
+c Calcul de ktotal, mais ralonge beaucoup en temps => pour debug
+      write(*,*) 
+      write(*,*) 'DEBUT DU TEST KMAX'
+      ktotal = 0
+      do jj = 1,jmn+1
+       do j=1, jmo+1
+          if((cn(jj).lt.d(j)).and.(dn(jj).gt.c(j)))then
+              do ii=1,imn + 1
+                do i=1, imo +1
+                    if (  ((an(ii).lt.b(i)).and.(bn(ii).gt.a(i)))
+     &        .or. ((an(ii).lt.b(i)-2*pi).and.(bn(ii).gt.a(i)-2*pi)
+     &             .and.(b(i)-2*pi.lt.-pi) )
+     &        .or. ((an(ii).lt.b(i)+2*pi).and.(bn(ii).gt.a(i)+2*pi)
+     &             .and.(a(i)+2*pi.gt.pi) )
+     &                     )then
+                      ktotal = ktotal +1
+                     end if
+                enddo
+              enddo
+           end if
+        enddo
+      enddo
+
+      if (kmax.LT.ktotal) then
+         write(*,*)
+         write(*,*) '******** ATTENTION ********' 
+         write(*,*) 'kmax =',kmax 
+         write(*,*) 'ktotal =',ktotal 
+         write(*,*) 'Changer la valeur de kmax dans interp_horiz.F ' 
+         write(*,*) 'avec kmax >= ktotal' 
+         write(*,*) 'EXIT dans iniinterp_h'
+         call exit(1)
+      else
+         write(*,*) 'kmax =',kmax 
+         write(*,*) 'ktotal =',ktotal
+      end if
+      write(*,*) 'FIN DU TEST KMAX'
+      write(*,*) 
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
+c     boucle sur la nouvelle grille
+c     """"""""""""""""""""""""""""
+      ktotal = 0
+      do jj = 1,jmn+1
+       do j=1, jmo+1
+          if((cn(jj).lt.d(j)).and.(dn(jj).gt.c(j)))then
+              do ii=1,imn + 1
+                do i=1, imo +1
+                    if (  ((an(ii).lt.b(i)).and.(bn(ii).gt.a(i)))
+     &        .or. ((an(ii).lt.b(i)-2*pi).and.(bn(ii).gt.a(i)-2*pi)
+     &             .and.(b(i)-2*pi.lt.-pi) )
+     &        .or. ((an(ii).lt.b(i)+2*pi).and.(bn(ii).gt.a(i)+2*pi)
+     &             .and.(a(i)+2*pi.gt.pi) )
+     &                     )then
+                      ktotal = ktotal +1
+                      iik(ktotal) =ii
+                      jjk(ktotal) =jj
+                      ik(ktotal) =i
+                      jk(ktotal) =j
+
+                      dd = min(d(j), dn(jj))
+                      cc = cn(jj)
+                      if (cc.lt. c(j))cc=c(j)
+                      if((an(ii).lt.b(i)-2*pi).and.
+     &                  (bn(ii).gt.a(i)-2*pi)) then 
+                          bb = min(b(i)-2*pi,bn(ii))
+                          aa = an(ii)
+                          if (aa.lt.a(i)-2*pi) aa=a(i)-2*pi
+                      else if((an(ii).lt.b(i)+2*pi).and.
+     &                       (bn(ii).gt.a(i)+2*pi)) then
+                          bb = min(b(i)+2*pi,bn(ii))
+                          aa = an(ii)
+                          if (aa.lt.a(i)+2*pi) aa=a(i)+2*pi
+                      else 
+                          bb = min(b(i),bn(ii))
+                          aa = an(ii)
+                          if (aa.lt.a(i)) aa=a(i)
+                      end if
+                      intersec(ktotal)=(bb-aa)*(sin(dd)-sin(cc))
+                     end if
+                end do
+               end do
+             end if
+         end do
+       end do       
+
+
+c     TEST  INFO
+c     DO k=1,ktotal 
+c      ii = iik(k) 
+c      jj = jjk(k)
+c      i = ik(k)
+c      j = jk(k)
+c      if ((ii.eq.10).and.(jj.eq.10).and.(i.eq.10).and.(j.eq.10))then
+c      if (jj.eq.2.and.(ii.eq.1))then
+c          write(*,*) '**************** jj=',jj,'ii=',ii
+c          write(*,*) 'i,j =',i,j
+c          write(*,*) 'an,bn,cn,dn', an(ii), bn(ii), cn(jj),dn(jj)
+c          write(*,*) 'a,b,c,d', a(i), b(i), c(j),d(j)
+c          write(*,*) 'intersec(k)',intersec(k)
+c          write(*,*) 'airen(ii,jj)=',airen(ii,jj)
+c      end if
+c     END DO 
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/dyn3d/initial0.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/initial0.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/initial0.F	(revision 1644)
@@ -0,0 +1,9 @@
+      SUBROUTINE initial0(n,x)
+      IMPLICIT NONE
+      INTEGER n,i
+      REAL x(n)
+      DO 10 i=1,n
+         x(i)=0.
+10    CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/integrd.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/integrd.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/integrd.F	(revision 1644)
@@ -0,0 +1,187 @@
+      SUBROUTINE integrd
+     $  (  nq,vcovm1,ucovm1,tetam1,psm1,massem1,
+     $     dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis,finvmaold )
+
+      USE comvert_mod, ONLY: ap,bp
+      USE logic_mod, ONLY: leapf
+      USE serre_mod, ONLY: alphax
+      USE temps_mod, ONLY: dt
+
+      IMPLICIT NONE
+
+
+c=======================================================================
+cccccccccccccccccccccccccccccccccccccccccccc
+c
+!Mars       VERSION MARTIENNE de integrd.F
+c
+c   ..   modification de l'integration de  q   . 26/04/94 ..
+c   ....   Si shema Van-leer pour advection de q , on n'integre pas  q
+c      car q  a ete deja integre   dans "tracvl.F" appele par vanleer   ...
+cccccccccccccccccccccccccccccccccccccccccccc
+
+c
+c   Auteur:  P. Le Van
+c   -------
+c
+c   objet:
+c   ------
+c
+c   Incrementation des tendances dynamiques
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      INTEGER nq
+
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm),teta(ip1jmp1,llm)
+      REAL q(ip1jmp1,llm,nq)
+      REAL ps(ip1jmp1),masse(ip1jmp1,llm),phis(ip1jmp1)
+
+      REAL vcovm1(ip1jm,llm),ucovm1(ip1jmp1,llm)
+      REAL tetam1(ip1jmp1,llm),psm1(ip1jmp1),massem1(ip1jmp1,llm)
+
+      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
+      REAL dteta(ip1jmp1,llm),dp(ip1jmp1)
+      REAL dq(ip1jmp1,llm,nq), finvmaold(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      REAL vscr( ip1jm ),uscr( ip1jmp1 ),hscr( ip1jmp1 ),pscr(ip1jmp1)
+      REAL massescr( ip1jmp1,llm ), finvmasse(ip1jmp1,llm)
+      REAL p(ip1jmp1,llmp1)
+      REAL tpn,tps,tppn(iim),tpps(iim)
+      REAL qpn,qps,qppn(iim),qpps(iim)
+      REAL deltap( ip1jmp1,llm )
+
+      INTEGER  l,ij,iq
+
+      EXTERNAL  filtreg,massdair,pression
+      EXTERNAL  SCOPY 
+      REAL SSUM
+      EXTERNAL SSUM
+
+c-----------------------------------------------------------------------
+
+      DO  l = 1,llm
+        DO  ij = 1,iip1
+         ucov(    ij    , l) = 0.
+         ucov( ij +ip1jm, l) = 0.
+         uscr(     ij      ) = 0.
+         uscr( ij +ip1jm   ) = 0.
+        ENDDO
+      ENDDO
+
+
+c    ............    integration  de       ps         ..............
+
+      CALL SCOPY(ip1jmp1*llm, masse, 1, massescr, 1)
+
+      DO 2 ij = 1,ip1jmp1
+       pscr (ij)    = ps(ij)
+       ps (ij)      = psm1(ij) + dt * dp(ij)
+
+   2  CONTINUE
+c
+      DO ij = 1,ip1jmp1
+        IF( ps(ij).LT.0. ) THEN
+         PRINT*,' Au point ij = ',ij, ' , pression sol neg. ', ps(ij)
+         write(*,*)'psm1(ij)=',psm1(ij),' dp(ij)=',dp(ij),
+     &             'dp(ij)*dt=',dp(ij)*dt
+         STOP' dans integrd'
+        ENDIF
+      ENDDO
+c
+      IF( alphax.NE.0. )   THEN
+         DO  ij    = 1, iim
+          tppn(ij) = aire(   ij   ) * ps(  ij    )
+          tpps(ij) = aire(ij+ip1jm) * ps(ij+ip1jm)
+         ENDDO
+          tpn      = SSUM(iim,tppn,1)/apoln
+          tps      = SSUM(iim,tpps,1)/apols
+         DO ij   = 1, iip1
+          ps(   ij   )  = tpn
+          ps(ij+ip1jm)  = tps
+         ENDDO
+      ENDIF
+c
+c  ... Calcul  de la nouvelle masse d'air au dernier temps integre t+1 ...
+c
+      CALL pression ( ip1jmp1, ap, bp, ps, p )
+      CALL massdair (     p  , masse         )
+
+      CALL SCOPY( ijp1llm  , masse, 1, finvmasse,  1      )
+      CALL filtreg( finvmasse, jjp1, llm, -2, 2, .TRUE., 1  )
+c
+
+c    ............   integration  de  ucov, vcov,  h     ..............
+
+      DO 10 l = 1,llm
+
+      DO 4 ij = iip2,ip1jm
+      uscr( ij )   =  ucov( ij,l )
+      ucov( ij,l ) = ucovm1( ij,l ) + dt * du( ij,l )
+   4  CONTINUE
+
+      DO 5 ij = 1,ip1jm
+      vscr( ij )   =  vcov( ij,l )
+      vcov( ij,l ) = vcovm1( ij,l ) + dt * dv( ij,l )
+   5  CONTINUE
+
+      DO 6 ij = 1,ip1jmp1
+      hscr( ij )    =  teta(ij,l)
+      teta ( ij,l ) = tetam1(ij,l) *  massem1(ij,l) / masse(ij,l) 
+     $                + dt * dteta(ij,l) / masse(ij,l)
+   6  CONTINUE
+
+c   ....  Calcul de la valeur moyenne, unique  aux poles pour  teta    ......
+c
+c
+      DO  ij   = 1, iim
+        tppn(ij) = aire(   ij   ) * teta(  ij    ,l)
+        tpps(ij) = aire(ij+ip1jm) * teta(ij+ip1jm,l)
+      ENDDO
+        tpn      = SSUM(iim,tppn,1)/apoln
+        tps      = SSUM(iim,tpps,1)/apols
+
+      DO ij   = 1, iip1
+        teta(   ij   ,l)  = tpn
+        teta(ij+ip1jm,l)  = tps
+      ENDDO
+c
+
+      IF(leapf)  THEN
+         CALL SCOPY ( ip1jmp1, uscr(1), 1, ucovm1(1, l), 1 )
+         CALL SCOPY (   ip1jm, vscr(1), 1, vcovm1(1, l), 1 )
+         CALL SCOPY ( ip1jmp1, hscr(1), 1, tetam1(1, l), 1 )
+      END IF
+
+  10  CONTINUE
+
+
+c
+c   .......  integration de   q   ......
+c
+c
+c     .....   FIN  de l'integration  de   q    .......
+
+c    .................................................................
+
+
+      IF( leapf )  THEN
+         CALL SCOPY (    ip1jmp1 ,  pscr   , 1,   psm1  , 1 )
+         CALL SCOPY ( ip1jmp1*llm, massescr, 1,  massem1, 1 )
+      END IF
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/interp_horiz.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/interp_horiz.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/interp_horiz.F	(revision 1644)
@@ -0,0 +1,188 @@
+      subroutine interp_horiz (varo,varn,imo,jmo,imn,jmn,lm,
+     &  rlonuo,rlatvo,rlonun,rlatvn)  
+
+c===========================================================
+c  Interpolation Horizontales des variables d'une grille LMDZ
+c (des points SCALAIRES au point SCALAIRES)
+c  dans une autre grille LMDZ en conservant la quantite
+c  totale pour les variables intensives (/m2) : ex : Pression au sol
+c
+c Francois Forget (01/1995)
+c===========================================================
+
+      IMPLICIT NONE 
+
+c   Declarations:
+c ==============
+c
+c  ARGUMENTS
+c  """""""""
+        
+       INTEGER,INTENT(IN) :: imo, jmo ! dimensions ancienne grille (input)
+       INTEGER,INTENT(IN) :: imn,jmn  ! dimensions nouvelle grille (input)
+
+       REAL,INTENT(IN) :: rlonuo(imo+1)     !  Latitude et
+       REAL,INTENT(IN) :: rlatvo(jmo)       !  longitude des
+       REAL,INTENT(IN) :: rlonun(imn+1)     !  bord des 
+       REAL,INTENT(IN) :: rlatvn(jmn)     !  cases "scalaires" (input)
+
+       INTEGER,INTENT(IN) :: lm ! dimension verticale (input)
+       REAL,INTENT(IN) :: varo (imo+1, jmo+1,lm) ! var dans l'ancienne grille (input)
+       REAL,INTENT(OUT) :: varn (imn+1,jmn+1,lm) ! var dans la nouvelle grille (output)
+
+c Autres variables
+c """"""""""""""""
+       INTEGER imnmx2,jmnmx2
+c       parameter (imnmx2=190,jmnmx2=100)
+       parameter (imnmx2=360,jmnmx2=190)
+       REAL airetest(imnmx2+1,jmnmx2+1)
+       INTEGER ii,jj,l
+
+       REAL,SAVE :: airen ((imnmx2+1)*(jmnmx2+1)) ! aire dans la nouvelle grille
+       REAL airentotn	! aire totale pole nord dans la nouvelle grille
+       REAL airentots	! aire totale pole sud dans la nouvelle grille
+c    Info sur les ktotal intersection entre les cases new/old grille
+
+c kmax: le nombre  max  d'intersections entre les 2 grilles horizontales
+c On fixe kmax a la taille de la grille des donnees martiennes (360x179) 
+c + des pouiemes (cas ou une maille est a cheval sur 2 ou 4 mailles)
+c  Il y a un test dans iniinterp_h pour s'assurer que ktotal < kmax
+       INTEGER kmax, k
+       integer,save :: ktotal
+       parameter (kmax = 360*179 + 200000)
+c      parameter (kmax = 360*179 + 40000)
+
+       INTEGER,SAVE :: iik(kmax), jjk(kmax),jk(kmax),ik(kmax)
+       REAL,SAVE :: intersec(kmax)
+       REAL r
+       REAL totn, tots
+       integer,save :: prev_sumdim=0
+
+       logical,save :: firsttest=.true. , aire_ok=.true.
+
+       integer,save :: imoS,jmoS,imnS,jmnS
+
+c Test dimensions imnmx2 jmnmx2
+c""""""""""""""""""""""""""""""
+c test dimensionnement tableau airetest
+      if (imn.GT.imnmx2.OR.jmn.GT.jmnmx2) then
+         write(*,*) 'STOP pb dimensionnement tableau airetest'
+         write(*,*) 'il faut imn < imnmx2 et jmn < jmnmx2'
+         write(*,*) 'imn imnmx2', imn,imnmx2
+         write(*,*) 'jmn jmnmx2', jmn,jmnmx2
+         call exit(1)
+      endif
+
+c initialisation
+c --------------
+c Si c'est le premier appel,  on prepare l'interpolation
+c en calculant pour chaque case autour d'un point scalaire de la
+c nouvelle grille, la surface  de intersection avec chaque
+c    case de l'ancienne grille.
+
+c  This must also be done if we change the dimension
+      if (imo+jmo+imn+jmn.ne.prev_sumdim) then
+          firsttest=.true.
+          prev_sumdim=imo+jmo+imn+jmn
+      end if       
+
+      if (firsttest) then 
+        call iniinterp_h(imo,jmo,imn,jmn ,kmax,
+     &       rlonuo,rlatvo,rlonun,rlatvn,
+     &          ktotal,iik,jjk,jk,ik,intersec,airen)
+       imoS=imo
+       jmoS=jmo
+       imnS=imn
+       jmnS=jmn
+      else
+       if(imo.NE.imoS.OR.jmo.NE.jmoS.OR.imn.NE.imnS.OR.jmn.NE.jmnS) then
+        call iniinterp_h(imo,jmo,imn,jmn ,kmax,
+     &       rlonuo,rlatvo,rlonun,rlatvn,
+     &          ktotal,iik,jjk,jk,ik,intersec,airen)
+       imoS=imo
+       jmoS=jmo
+       imnS=imn
+       jmnS=jmn
+       end if
+      end if
+
+! initialize varn() to zero
+      varn(1:imn+1,1:jmn+1,1:lm)=0.
+       
+c Interpolation horizontale
+c -------------------------
+c boucle sur toute les ktotal intersections entre les cases
+c de l'ancienne et la  nouvelle grille
+c
+! Ehouarn 2012: for some strange reason, with ifort v12.x,
+!               when the order of the loop below is changed
+!               values of varn(:,:,l=2...) are then sometimes remain zero!   
+      do l=1,lm
+        do k=1,ktotal
+         varn(iik(k),jjk(k),l) = varn(iik(k),jjk(k),l) 
+     &   + varo(ik(k), jk(k),l)*intersec(k)/airen(iik(k)
+     &   +(jjk(k)-1)*(imn+1))
+        end do
+      end do
+
+c Une seule valeur au pole pour les variables ! :
+c -----------------------------------------------
+      DO l=1, lm
+         totn =0.
+         tots =0.
+
+
+c moyenne du champ au poles (ponderee par les aires)
+c"""""""""""""""""""""""""""""""
+         airentotn=0.
+         airentots=0.
+
+         do ii =1, imn+1
+            totn = totn + varn(ii,1,l)*airen(ii)
+            tots = tots + varn (ii,jmn+1,l)*airen(jmn*(imn+1)+ii)
+            airentotn=airentotn + airen(ii)
+            airentots=airentots + airen(jmn*(imn+1)+ii)
+         end do 
+
+         do ii =1, imn+1
+            varn(ii,1,l) = totn/airentotn
+            varn(ii,jmn+1,l) = tots/airentots
+         end do 
+
+      ENDDO ! of DO l=1, lm
+           
+
+c---------------------------------------------------------------
+c  TEST  TEST  TEST  TEST  TEST  TEST  TEST  TEST  TEST  TEST 
+      if (firsttest) then
+      firsttest = .false.
+      write (*,*) 'INTERP. HORIZ. : TEST SUR LES AIRES:'
+
+      do jj =1 , jmn+1
+        do ii=1, imn+1
+          airetest(ii,jj) =0.
+        end do
+      end do 
+      do k=1,ktotal
+         airetest(iik(k),jjk(k))= airetest(iik(k),jjk(k)) +intersec(k) 
+      end do
+      do jj =1 , jmn+1
+       do ii=1, imn+1
+         r = airen(ii+(jj-1)*(imn+1))/airetest(ii,jj)
+         if ((r.gt.1.001).or.(r.lt.0.999)) then
+             write (*,*) '********** PROBLEME D'' AIRES !!!',
+     &                   ' DANS L''INTERPOLATION HORIZONTALE'
+             write(*,*)'ii,jj,airen,airetest',
+     &          ii,jj,airen(ii+(jj-1)*(imn+1)),airetest(ii,jj)
+             aire_ok = .false.
+         end if
+       end do
+      end do
+      if (aire_ok) write(*,*) 'INTERP. HORIZ. : AIRES OK'
+      endif ! of if (firsttest)
+
+c FIN TEST  FIN TEST  FIN TEST  FIN TEST  FIN TEST  FIN TEST  FIN TEST
+c --------------------------------------------------------------------
+
+
+        end
Index: /trunk/LMDZ.TITAN/libf/dyn3d/laplacien.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/laplacien.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/laplacien.F	(revision 1644)
@@ -0,0 +1,38 @@
+      SUBROUTINE laplacien ( klevel, teta, divgra )
+c
+c     P. Le Van
+c
+c   ************************************************************
+c    ....     calcul de  (div( grad ))   de   teta  .....
+c   ************************************************************
+c     klevel et teta  sont des arguments  d'entree pour le s-prog
+c      divgra     est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c
+c    .........      variables  en arguments   ..............
+c
+      INTEGER klevel
+      REAL teta( ip1jmp1,klevel ), divgra( ip1jmp1,klevel )
+c
+c    ............     variables  locales      ..............
+c
+      REAL ghy(ip1jm,llm), ghx(ip1jmp1,llm)
+c    .......................................................
+
+      EXTERNAL  SCOPY, grad, divergf, filtreg
+
+c
+      CALL SCOPY ( ip1jmp1 * klevel, teta, 1, divgra, 1 )
+
+      CALL filtreg( divgra,  jjp1, klevel,  2, 1, .TRUE., 1 )
+      CALL grad ( klevel,divgra,   ghx , ghy              )
+      CALL divergf ( klevel, ghx , ghy  , divgra           )
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_gam.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_gam.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_gam.F	(revision 1644)
@@ -0,0 +1,52 @@
+      SUBROUTINE laplacien_gam ( klevel, cuvsga, cvusga, unsaigam ,
+     *                        unsapolnga, unsapolsga, teta, divgra )
+
+c  P. Le Van
+c
+c   ************************************************************
+c
+c      ....   calcul de  (div( grad ))   de   teta  .....
+c   ************************************************************
+c    klevel et teta  sont des arguments  d'entree pour le s-prog
+c      divgra     est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c
+c    ............     variables  en arguments    ..........
+c
+      INTEGER klevel
+      REAL teta( ip1jmp1,klevel ), divgra( ip1jmp1,klevel )
+      REAL cuvsga(ip1jm) , cvusga( ip1jmp1 ),unsaigam(ip1jmp1),
+     *     unsapolnga, unsapolsga
+c
+c    ...........    variables  locales    .................
+c
+      REAL ghy(ip1jm,llm), ghx(ip1jmp1,llm)
+c    ......................................................
+
+      EXTERNAL  filtreg
+      EXTERNAL  SCOPY, grad, divergst
+c
+c
+c   ...  cvuscugam  = ( cvu/ cu ) ** (- gamdissip )
+c   ...  cuvscvgam  = ( cuv/ cv ) ** (- gamdissip )  calcules dans inigeom  ..
+c   ...  unsairegam =  1. /  aire ** (- gamdissip )
+c
+
+      CALL SCOPY ( ip1jmp1 * klevel, teta, 1, divgra, 1 )
+c
+      CALL grad ( klevel, divgra, ghx, ghy )
+c
+      CALL diverg_gam ( klevel, cuvsga, cvusga,  unsaigam  ,
+     *                 unsapolnga, unsapolsga, ghx , ghy , divgra )
+
+c
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_rot.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_rot.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_rot.F	(revision 1644)
@@ -0,0 +1,37 @@
+      SUBROUTINE laplacien_rot ( klevel, rotin, rotout,ghx,ghy )
+c
+c    P. Le Van
+c
+c   ************************************************************
+c    ...  calcul de  ( rotat x nxgrad )  du rotationnel rotin  .
+c   ************************************************************
+c
+c     klevel et rotin  sont des arguments  d'entree pour le s-prog
+c      rotout           est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c 
+c   ..........    variables  en  arguments     .............
+c
+      INTEGER klevel
+      REAL rotin( ip1jm,klevel ), rotout( ip1jm,klevel )
+c
+c   ..........    variables   locales       ................
+c
+      REAL ghy(ip1jm,klevel), ghx(ip1jmp1,klevel)
+c   ........................................................
+c
+      EXTERNAL  filtreg, nxgrad, rotatf
+c
+      CALL filtreg ( rotin ,   jjm, klevel,   2, 1, .FALSE., 1 )
+
+      CALL nxgrad ( klevel, rotin,   ghx ,  ghy               )
+      CALL rotatf  ( klevel, ghx  ,   ghy , rotout             )
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_rotgam.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_rotgam.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/laplacien_rotgam.F	(revision 1644)
@@ -0,0 +1,42 @@
+      SUBROUTINE laplacien_rotgam ( klevel, rotin, rotout )
+c
+c     P. Le Van
+c
+c   ************************************************************
+c   ... calcul de  (rotat x nxgrad)_gam  du rotationnel rotin ..
+c   ************************************************************
+c     klevel et teta  sont des arguments  d'entree pour le s-prog
+c      divgra     est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c
+c    .............   variables  en  arguments    ...........
+c
+      INTEGER klevel
+      REAL rotin( ip1jm,klevel ), rotout( ip1jm,klevel )
+c
+c   ............     variables   locales     ...............
+c
+      INTEGER l, ij
+      REAL ghy(ip1jm,llm), ghx(ip1jmp1,llm)
+c   ........................................................
+c
+      EXTERNAL   nxgrad_gam, rotat_nfil
+c
+
+      CALL nxgrad_gam ( klevel, rotin,   ghx ,   ghy  )
+      CALL rotat_nfil ( klevel, ghx  ,   ghy , rotout )
+c
+      DO l = 1, klevel
+        DO ij = 1, ip1jm
+         rotout(ij,l) = rotout(ij,l) * unsairz_gam(ij)
+        ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/lectflux.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/lectflux.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/lectflux.F	(revision 1644)
@@ -0,0 +1,232 @@
+      SUBROUTINE lectflux(irec,massem,pbarun,pbarvn,wn,tetan,phin,
+     s     nrec,avant,airefi,
+     s     zmfu, zmfd, zen_u, zde_u,zen_d, zde_d, coefkz,
+     s     yu1,yv1,ftsol,pctsrf,
+     s     frac_impa,frac_nucl,phis)
+
+      USE comconst_mod, ONLY: dtvr,dtphys
+
+      IMPLICIT NONE
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom2.h"
+
+#include "tracstoke.h"
+
+      integer irec,nrec,i,j
+
+      integer ngridmx,ig,l
+      parameter (ngridmx=iim*(jjm-1)+2)
+      INTEGER nbsrf
+      PARAMETER (nbsrf=4) ! nombre de sous-fractions pour une maille
+
+      real zmfd(ngridmx,llm),zde_d(ngridmx,llm),zen_d(ngridmx,llm)
+      real zmfu(ngridmx,llm),zde_u(ngridmx,llm),zen_u(ngridmx,llm)
+      real coefkz(ngridmx,llm)
+      real frac_impa(ngridmx,llm),frac_nucl(ngridmx,llm)
+      real yu1(ngridmx), yv1(ngridmx)
+      real ftsol(ngridmx,nbsrf),pctsrf(ngridmx,nbsrf)
+      integer imfu,imfd,ien_u,ide_u,
+     s      ien_d,ide_d,
+     s      icoefkz,izu1,izv1,
+     s      itsol,ipsf,
+     s      ilei, ilec
+      parameter(imfu=1,imfd=llm+1,ien_u=2*llm+1,ide_u=3*llm+1,
+     s      ien_d=4*llm+1,ide_d=5*llm+1,
+     s      icoefkz=6*llm+1,
+     s      ilei=7*llm+1,ilec=8*llm+1,
+     s      izu1=9*llm+1,izv1=9*llm+2,
+     s      itsol=9*llm+3,ipsf=9*llm+3+nbsrf)
+      logical avant
+
+      real massefi(ngridmx,llm)
+
+      real massem(ip1jmp1,llm),tetan(ip1jmp1,llm)
+      real pbarun(iip1,jjp1,llm),pbarvn(iip1,jjm,llm)
+      real pbarvst(iip1,jjp1,llm)
+      real wn(iip1,jjp1,llm),phin(iip1,jjp1,llm)
+      real phis(iip1,jjp1)
+
+      real airefi(ngridmx)
+
+      real xlecn(ngridmx,9*llm+2+2*nbsrf)
+
+      real zcontrole(ngridmx),zmass,tmpdyn(iip1,jjp1),zflux
+
+      real ziadvtrac,zrec,ziadvtrac2,zrec2
+      real zim,zjm,zlm,zklon,zklev
+
+      real zpi
+
+      zpi=2.*asin(1.)
+
+
+c==================================================================
+c   Si le numero du record est 0 alors: INITIALISATION
+c==================================================================
+c
+      print*,'ENTREE DANS LECTFLUX'
+        print*,'IREC=',IREC
+      if(irec.eq.0) then
+
+        print*,'IREC==',0
+
+C test         call inigeom
+
+c==================================================================
+c   ouverture des fichiers
+c==================================================================
+
+c   Fichier fluxmass
+#ifdef CRAY
+         CALL ASSIGN("assign -N ieee -F null f:fluxmass")
+#endif
+      open(47,file='fluxmass',form='unformatted',
+     s     access='direct'
+     s     ,recl=4*(6*ijp1llm))
+      read(47,rec=1) zrec,dtvr,ziadvtrac,zim,zjm,zlm,
+     s   rlonu,rlonv,rlatu,rlatv,aire
+     s    ,phis
+      print*,'zrec,dtvr,ziadvtrac,zim,zjm,zlm'
+      print*,zrec,dtvr,ziadvtrac,zim,zjm,zlm
+      print*,rlonv
+
+
+
+c  Fichier physique
+c  Fichier lessivage (supprime les donnees utiles sont dans "physique")
+#ifdef CRAY
+         CALL ASSIGN("assign -N ieee -F null f:physique")
+#endif
+      open(49,file='physique',form='unformatted',
+     s     access='direct'
+     s     ,recl=4*ngridmx*(9*llm+2+2*nbsrf))
+      read(49,rec=1) zrec2,ziadvtrac2,zklon,zklev
+      print*,'Entete du fichier physique'
+      print*,zrec2,ziadvtrac2,zklon,zklev
+
+      nrec=zrec
+      print*,'nrec=',nrec
+
+      istdyn=ziadvtrac
+      istphy=ziadvtrac2
+
+c==================================================================
+c   Fin des initialisations
+      else ! irec=0
+c==================================================================
+
+
+c-----------------------------------------------------------------------
+c   Lecture des fichiers fluxmass et  physique:
+c   -----------------------------------------------------
+
+c  Variables dynamiques
+         read(47,rec=irec) massem,pbarun,pbarvst,wn,tetan,phin
+        do l=1,llm
+           do j=1,jjm
+              do i=1,iip1
+                 pbarvn(i,j,l)=pbarvst(i,j,l)
+              enddo
+           enddo
+        enddo
+
+c  Variables physiques
+         read(49,rec=irec) ((xlecn(ig,l),ig=1,ngridmx),
+     s                                    l=1,9*llm+2+2*nbsrf)
+
+       do l=1,llm
+          do ig=1,ngridmx
+             coefkz(ig,l)=xlecn(ig,icoefkz+l-1)
+             frac_impa(ig,l)=xlecn(ig,ilei+l-1)
+             frac_nucl(ig,l)=xlecn(ig,ilec+l-1)
+          enddo
+       enddo
+       do l=1,nbsrf
+          do ig=1,ngridmx
+             ftsol(ig,l)=xlecn(ig,itsol+l-1)
+             pctsrf(ig,l)=xlecn(ig,ipsf+l-1)
+          enddo
+       enddo
+       do ig=1,ngridmx
+          yv1(ig)=xlecn(ig,izv1)
+          yu1(ig)=xlecn(ig,izu1)
+       enddo
+C
+      if(avant) then
+c   Simu directe
+       do l=1,llm
+          do ig=1,ngridmx
+             zmfu(ig,l)=xlecn(ig,imfu+l-1)
+             zmfd(ig,l)=xlecn(ig,imfd+l-1)
+             zde_u(ig,l)=xlecn(ig,ide_u+l-1)
+             zen_u(ig,l)=xlecn(ig,ien_u+l-1)
+             zde_d(ig,l)=xlecn(ig,ide_d+l-1)
+             zen_d(ig,l)=xlecn(ig,ien_d+l-1)
+          enddo
+       enddo
+      else
+c   Simu retro
+       do l=1,llm
+          do ig=1,ngridmx
+             zmfd(ig,l)=-xlecn(ig,imfu+l-1)
+             zmfu(ig,l)=-xlecn(ig,imfd+l-1)
+             zen_d(ig,l)=xlecn(ig,ide_u+l-1)
+             zde_d(ig,l)=xlecn(ig,ien_u+l-1)
+             zen_u(ig,l)=xlecn(ig,ide_d+l-1)
+             zde_u(ig,l)=xlecn(ig,ien_d+l-1)
+          enddo
+       enddo
+      endif
+
+c-----------------------------------------------------------------------
+c   PETIT CONTROLE SUR LES FLUX CONVECTIFS...
+c-----------------------------------------------------------------------
+
+      print*,'Ap redec irec'
+
+         call gr_dyn_fi(llm,iip1,jjp1,ngridmx,massem,massefi)
+
+         do ig=1,ngridmx
+            zcontrole(ig)=1.
+         enddo
+c   zmass=(max(massem(ig,l),massem(ig,l-1))/airefi(ig)
+         do l=2,llm
+            do ig=1,ngridmx
+               zmass=max(massefi(ig,l),massefi(ig,l-1))/airefi(ig)
+               zflux=max(abs(zmfu(ig,l)),abs(zmfd(ig,l)))*dtphys
+               if(zflux.gt.0.9*zmass) then
+                 zcontrole(ig)=min(zcontrole(ig),0.9*zmass/zflux)
+               endif
+            enddo
+         enddo
+
+         do ig=1,ngridmx
+            if(zcontrole(ig).lt.0.99999) then
+               print*,'ATTENTION !!! on reduit les flux de masse '
+               print*,'convectifs au point ig=',ig
+            endif
+         enddo
+
+         call gr_fi_dyn(1,ngridmx,iip1,jjp1,zcontrole,tmpdyn)
+
+         do l=1,llm
+            do ig=1,ngridmx
+               zmfu(ig,l)=zmfu(ig,l)*zcontrole(ig)
+               zmfd(ig,l)=zmfd(ig,l)*zcontrole(ig)
+               zen_u(ig,l)=zen_u(ig,l)*zcontrole(ig)
+               zde_u(ig,l)=zde_u(ig,l)*zcontrole(ig)
+               zen_d(ig,l)=zen_d(ig,l)*zcontrole(ig)
+               zde_d(ig,l)=zde_d(ig,l)*zcontrole(ig)
+            enddo
+         enddo
+
+
+      endif ! irec=0
+
+
+      RETURN
+      END
+
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/logic_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/logic_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/logic_mod.F90	(revision 1644)
@@ -0,0 +1,10 @@
+MODULE logic_mod
+
+IMPLICIT NONE  
+
+LOGICAL purmats,forward,leapf,apphys,statcl,conser, &
+     & apdiss,apdelq,saison,ecripar,fxyhypb,ysinus,hybrid,autozlevs
+
+INTEGER iflag_phys ! ==1 if calling a physics package
+
+END MODULE logic_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/massbar.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/massbar.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/massbar.F	(revision 1644)
@@ -0,0 +1,96 @@
+      SUBROUTINE massbar(  masse, massebx, masseby )
+c
+c **********************************************************************
+c
+c  Calcule les moyennes en x et  y de la masse d'air dans chaque maille.
+c **********************************************************************
+c    Auteurs : P. Le Van , Fr. Hourdin  .
+c   ..........
+c
+c  ..  masse                 est  un argum. d'entree  pour le s-pg ...
+c  ..  massebx,masseby      sont des argum. de sortie pour le s-pg ...
+c     
+c
+c     IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+      REAL    masse( ip1jmp1,llm ), massebx( ip1jmp1,llm )  ,
+     *      masseby(   ip1jm,llm )
+c
+c
+c   Methode pour calculer massebx et masseby .
+c   ----------------------------------------
+c
+c    A chaque point scalaire P (i,j) est affecte 4 coefficients d'aires
+c       alpha1(i,j)  calcule  au point ( i+1/4,j-1/4 )
+c       alpha2(i,j)  calcule  au point ( i+1/4,j+1/4 )
+c       alpha3(i,j)  calcule  au point ( i-1/4,j+1/4 )
+c       alpha4(i,j)  calcule  au point ( i-1/4,j-1/4 )
+c
+c    Avec  alpha1(i,j) = aire(i+1/4,j-1/4)/ aire(i,j)        
+c
+c    N.B .  Pour plus de details, voir s-pg  ...  iniconst ...
+c
+c
+c
+c   alpha4 .         . alpha1    . alpha4
+c    (i,j)             (i,j)       (i+1,j)
+c
+c             P .        U .          . P
+c           (i,j)       (i,j)         (i+1,j)
+c
+c   alpha3 .         . alpha2    .alpha3 
+c    (i,j)              (i,j)     (i+1,j)
+c
+c             V .        Z .          . V
+c           (i,j)
+c
+c   alpha4 .         . alpha1    .alpha4
+c   (i,j+1)            (i,j+1)   (i+1,j+1) 
+c
+c             P .        U .          . P
+c          (i,j+1)                    (i+1,j+1)
+c
+c
+c
+c                       On  a :
+c
+c    massebx(i,j) = masse(i  ,j) * ( alpha1(i  ,j) + alpha2(i,j))   +
+c                   masse(i+1,j) * ( alpha3(i+1,j) + alpha4(i+1,j) )
+c     localise  au point  ... U (i,j) ...
+c
+c    masseby(i,j) = masse(i,j  ) * ( alpha2(i,j  ) + alpha3(i,j  )  +
+c                   masse(i,j+1) * ( alpha1(i,j+1) + alpha4(i,j+1)  
+c     localise  au point  ... V (i,j) ...
+c
+c
+c=======================================================================
+
+      DO   100    l = 1 , llm
+c
+        DO  ij = 1, ip1jmp1 - 1
+         massebx(ij,l) =  masse( ij, l) * alpha1p2( ij  )     + 
+     *                   masse(ij+1, l) * alpha3p4(ij+1 )
+        ENDDO
+
+c    .... correction pour massebx( iip1,j) .....
+c    ...    massebx(iip1,j)= massebx(1,j) ...
+c
+CDIR$ IVDEP
+        DO  ij = iip1, ip1jmp1, iip1
+         massebx( ij,l ) = massebx( ij - iim,l )
+        ENDDO
+
+
+         DO  ij = 1,ip1jm
+         masseby( ij,l ) = masse(  ij   , l ) * alpha2p3(   ij    )  +
+     *                     masse(ij+iip1, l ) * alpha1p4( ij+iip1 )
+         ENDDO
+
+100   CONTINUE
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/massbarxy.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/massbarxy.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/massbarxy.F	(revision 1644)
@@ -0,0 +1,43 @@
+      SUBROUTINE massbarxy(  masse, massebxy )
+c
+c **********************************************************************
+c
+c  Calcule les moyennes en x et  y de la masse d'air dans chaque maille.
+c **********************************************************************
+c    Auteurs : P. Le Van , Fr. Hourdin  .
+c   ..........
+c
+c  ..  masse          est  un  argum. d'entree  pour le s-pg ...
+c  ..  massebxy       est  un  argum. de sortie pour le s-pg ...
+c     
+c
+c     IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+       REAL  masse( ip1jmp1,llm ), massebxy( ip1jm,llm )
+c
+
+      DO l = 1 , llm
+c
+         DO ij = 1, ip1jm - 1
+            massebxy( ij,l ) = masse(    ij  ,l ) * alpha2(   ij    ) +
+     +                      masse(   ij+1 ,l ) * alpha3(  ij+1   ) +
+     +                      masse( ij+iip1,l ) * alpha1( ij+iip1 ) +
+     +                      masse( ij+iip2,l ) * alpha4( ij+iip2 )
+         ENDDO
+
+c    ....  correction pour     massebxy( iip1,j )  ........
+
+CDIR$ IVDEP
+
+         DO ij = iip1, ip1jm, iip1
+            massebxy( ij,l ) = massebxy( ij - iim,l )
+         ENDDO
+
+      ENDDO
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/massdair.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/massdair.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/massdair.F	(revision 1644)
@@ -0,0 +1,106 @@
+      SUBROUTINE massdair( p, masse )
+c
+c *********************************************************************
+c       ....  Calcule la masse d'air  dans chaque maille   ....
+c *********************************************************************
+c
+c    Auteurs : P. Le Van , Fr. Hourdin  .
+c   ..........
+c
+c  ..    p                      est  un argum. d'entree pour le s-pg ...
+c  ..  masse                    est un  argum.de sortie pour le s-pg ...
+c     
+c  ....  p est defini aux interfaces des llm couches   .....
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c  .....   arguments  ....
+c
+      REAL p(ip1jmp1,llmp1), masse(ip1jmp1,llm)
+
+c   ....  Variables locales  .....
+
+      INTEGER l,ij
+      REAL massemoyn, massemoys
+
+      REAL SSUM
+      EXTERNAL SSUM
+c
+c
+c   Methode pour calculer massebx et masseby .
+c   ----------------------------------------
+c
+c    A chaque point scalaire P (i,j) est affecte 4 coefficients d'aires
+c       alpha1(i,j)  calcule  au point ( i+1/4,j-1/4 )
+c       alpha2(i,j)  calcule  au point ( i+1/4,j+1/4 )
+c       alpha3(i,j)  calcule  au point ( i-1/4,j+1/4 )
+c       alpha4(i,j)  calcule  au point ( i-1/4,j-1/4 )
+c
+c    Avec  alpha1(i,j) = aire(i+1/4,j-1/4)/ aire(i,j)        
+c
+c    N.B .  Pour plus de details, voir s-pg  ...  iniconst ...
+c
+c
+c
+c   alpha4 .         . alpha1    . alpha4
+c    (i,j)             (i,j)       (i+1,j)
+c
+c             P .        U .          . P
+c           (i,j)       (i,j)         (i+1,j)
+c
+c   alpha3 .         . alpha2    .alpha3 
+c    (i,j)              (i,j)     (i+1,j)
+c
+c             V .        Z .          . V
+c           (i,j)
+c
+c   alpha4 .         . alpha1    .alpha4
+c   (i,j+1)            (i,j+1)   (i+1,j+1) 
+c
+c             P .        U .          . P
+c          (i,j+1)                    (i+1,j+1)
+c
+c
+c
+c                       On  a :
+c
+c    massebx(i,j) = masse(i  ,j) * ( alpha1(i  ,j) + alpha2(i,j))   +
+c                   masse(i+1,j) * ( alpha3(i+1,j) + alpha4(i+1,j) )
+c     localise  au point  ... U (i,j) ...
+c
+c    masseby(i,j) = masse(i,j  ) * ( alpha2(i,j  ) + alpha3(i,j  )  +
+c                   masse(i,j+1) * ( alpha1(i,j+1) + alpha4(i,j+1)  
+c     localise  au point  ... V (i,j) ...
+c
+c
+c=======================================================================
+
+      DO   100    l = 1 , llm
+c
+        DO    ij     = 1, ip1jmp1
+         masse(ij,l) = airesurg(ij) * ( p(ij,l) - p(ij,l+1) )
+        ENDDO
+c
+        DO   ij = 1, ip1jmp1,iip1
+         masse(ij+ iim,l) = masse(ij,l)
+        ENDDO
+c
+c       DO    ij     = 1,  iim
+c        masse(   ij   ,l) = masse(   ij   ,l) * aire(  ij    )
+c        masse(ij+ip1jm,l) = masse(ij+ip1jm,l) * aire(ij+ip1jm) 
+c       ENDDO
+c        massemoyn         = SSUM(iim,masse(   1   ,l),1)/ apoln
+c        massemoys         = SSUM(iim,masse(ip1jm+1,l),1)/ apols
+c       DO    ij     = 1, iip1
+c        masse(   ij   ,l )    = massemoyn
+c        masse(ij+ip1jm,l )    = massemoys
+c       ENDDO
+       
+100   CONTINUE
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/minmax.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/minmax.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/minmax.F	(revision 1644)
@@ -0,0 +1,20 @@
+       SUBROUTINE minmax(imax, xi, zmin, zmax )
+c
+c      P. Le Van
+
+       INTEGER imax
+       REAL    xi(imax)
+       REAL    zmin,zmax
+       INTEGER i
+
+       zmin = xi(1)
+       zmax = xi(1)
+
+       DO i = 2, imax
+         zmin = MIN( zmin,xi(i) )
+         zmax = MAX( zmax,xi(i) )
+       ENDDO
+
+       RETURN
+       END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/mod_const_mpi.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/mod_const_mpi.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/mod_const_mpi.F90	(revision 1644)
@@ -0,0 +1,16 @@
+MODULE mod_const_mpi
+
+  INTEGER :: COMM_LMDZ
+  INTEGER :: MPI_REAL_LMDZ
+ 
+
+CONTAINS 
+
+  SUBROUTINE init_const_mpi
+  IMPLICIT NONE
+  
+    COMM_LMDZ=0
+    MPI_REAL_LMDZ=0
+  END SUBROUTINE init_const_mpi
+
+END MODULE mod_const_mpi
Index: /trunk/LMDZ.TITAN/libf/dyn3d/multipl.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/multipl.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/multipl.F	(revision 1644)
@@ -0,0 +1,17 @@
+      SUBROUTINE multipl(n,x1,x2,y)
+      IMPLICIT NONE
+c=======================================================================
+c
+c   multiplication de deux vecteurs
+c
+c=======================================================================
+c
+      INTEGER n,i
+      REAL x1(n),x2(n),y(n)
+c
+      DO 10 i=1,n
+         y(i)=x1(i)*x2(i)
+10    CONTINUE
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/multscal.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/multscal.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/multscal.F	(revision 1644)
@@ -0,0 +1,9 @@
+      SUBROUTINE multscal(n,x,lambda,y)
+      IMPLICIT NONE
+      INTEGER i,n
+      REAL lambda,x(n),y(n)
+      DO 10 i=1,n
+         y(i)=x(i)*lambda
+10    CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/nxgrad.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/nxgrad.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/nxgrad.F	(revision 1644)
@@ -0,0 +1,45 @@
+      SUBROUTINE nxgrad (klevel, rot, x, y )
+c
+c     P. Le Van
+c
+c   ********************************************************************
+c      calcul du gradient tourne de pi/2 du rotationnel du vect.v
+c   ********************************************************************
+c       rot          est un argument  d'entree pour le s-prog
+c       x  et y    sont des arguments de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+      INTEGER klevel
+      REAL rot( ip1jm,klevel ),x( ip1jmp1,klevel ),y(ip1jm,klevel )
+      INTEGER   l,ij
+c
+c
+      DO 10 l = 1,klevel
+c
+      DO 1  ij = 2, ip1jm
+      y( ij,l ) = (  rot( ij,l ) - rot( ij-1,l )  ) * cvsurcuv( ij )
+   1  CONTINUE
+c
+c    ..... correction pour  y ( 1,j,l )  ......
+c
+c    ....    y(1,j,l)= y(iip1,j,l) ....
+CDIR$ IVDEP
+      DO 2  ij = 1, ip1jm, iip1
+      y( ij,l ) = y( ij +iim,l )
+   2  CONTINUE
+c
+      DO 4  ij = iip2,ip1jm
+      x( ij,l ) = (  rot( ij,l ) - rot( ij -iip1,l )  ) * cusurcvu( ij )
+   4  CONTINUE
+      DO 6 ij = 1,iip1
+      x(    ij    ,l ) = 0.
+      x( ij +ip1jm,l ) = 0.
+   6  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/nxgrad_gam.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/nxgrad_gam.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/nxgrad_gam.F	(revision 1644)
@@ -0,0 +1,46 @@
+      SUBROUTINE nxgrad_gam( klevel, rot, x, y )
+c
+c  P. Le Van
+c
+c   ********************************************************************
+c      calcul du gradient tourne de pi/2 du rotationnel du vect.v
+c   ********************************************************************
+c       rot          est un argument  d'entree pour le s-prog
+c       x  et y    sont des arguments de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+      INTEGER klevel
+      REAL rot( ip1jm,klevel ),x( ip1jmp1,klevel ),y(ip1jm,klevel )
+      INTEGER   l,ij
+      integer ismin,ismax
+      external ismin,ismax
+c
+      DO 10 l = 1,klevel
+c
+      DO 1  ij = 2, ip1jm
+      y( ij,l ) = (rot( ij,l ) - rot( ij-1,l )) * cvscuvgam( ij )
+   1  CONTINUE
+c
+c    ..... correction pour  y ( 1,j,l )  ......
+c
+c    ....    y(1,j,l)= y(iip1,j,l) ....
+CDIR$ IVDEP
+      DO 2  ij = 1, ip1jm, iip1
+      y( ij,l ) = y( ij +iim,l )
+   2  CONTINUE
+c
+      DO 4  ij = iip2,ip1jm
+      x( ij,l ) = (rot( ij,l ) - rot( ij -iip1,l )) * cuscvugam( ij )
+   4  CONTINUE
+      DO 6 ij = 1,iip1
+      x(    ij    ,l ) = 0.
+      x( ij +ip1jm,l ) = 0.
+   6  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/nxgradst.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/nxgradst.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/nxgradst.F	(revision 1644)
@@ -0,0 +1,44 @@
+      SUBROUTINE nxgradst (klevel,rot, x, y )
+c
+      IMPLICIT NONE
+c     Auteur :  P. Le Van
+c
+c   ********************************************************************
+c      calcul du gradient tourne de pi/2 du rotationnel du vect.v
+c   ********************************************************************
+c       rot          est un argument  d'entree pour le s-prog
+c       x  et y    sont des arguments de sortie pour le s-prog
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      INTEGER klevel
+      REAL rot( ip1jm,klevel ),x( ip1jmp1,klevel ),y(ip1jm,klevel )
+      INTEGER l,ij
+c
+      DO 10 l = 1,klevel
+c
+      DO 1  ij = 2, ip1jm
+      y(ij,l)=( rot(ij,l) - rot(ij-1,l))
+   1  CONTINUE
+c
+c    ..... correction pour  y ( 1,j,l )  ......
+c
+c    ....    y(1,j,l)= y(iip1,j,l) ....
+
+      DO 2  ij = 1, ip1jm, iip1
+      y( ij,l ) = y( ij +iim,l )
+   2  CONTINUE
+c
+      DO 4  ij = iip2,ip1jm
+      x(ij,l)= rot(ij,l)-rot(ij-iip1,l)
+   4  CONTINUE
+      DO 6 ij = 1,iip1
+      x(    ij    ,l ) = 0.
+      x( ij +ip1jm,l ) = 0.
+   6  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/nxgraro2.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/nxgraro2.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/nxgraro2.F	(revision 1644)
@@ -0,0 +1,67 @@
+       SUBROUTINE nxgraro2 (klevel,xcov, ycov, lr, grx, gry )
+c
+c      P.Le Van .
+c   ***********************************************************
+c                                 lr
+c      calcul de  ( nxgrad (rot) )   du vect. v  ....
+c
+c       xcov et ycov  etant les compos. covariantes de  v
+c   ***********************************************************
+c     xcov , ycov et lr  sont des arguments  d'entree pour le s-prog
+c      grx   et  gry     sont des arguments de sortie pour le s-prog
+c
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissipn.h"
+c
+c    ......  variables en arguments  .......
+c
+      INTEGER klevel
+      REAL xcov( ip1jmp1,klevel ), ycov( ip1jm,klevel )
+      REAL  grx( ip1jmp1,klevel ),  gry( ip1jm,klevel )
+c
+c    ......   variables locales     ........
+c
+      REAL rot(ip1jm,llm) , signe, nugradrs
+      INTEGER l,ij,iter,lr
+c    ........................................................
+c
+      EXTERNAL    filtreg
+      EXTERNAL  SCOPY, rotatf, nxgrad, laplacien_rotgam
+c
+c
+      signe    = (-1.)**lr
+      nugradrs = signe * crot
+c
+      CALL SCOPY ( ip1jmp1* klevel, xcov, 1, grx, 1 )
+      CALL SCOPY (  ip1jm * klevel, ycov, 1, gry, 1 )
+c
+      CALL rotatf     ( klevel, grx, gry, rot )
+c
+      CALL laplacien_rot ( klevel, rot, rot,grx,gry      )
+
+c
+c    .....   Iteration de l'operateur laplacien_rotgam  .....
+c
+      DO  iter = 1, lr -2
+        CALL laplacien_rotgam ( klevel, rot, rot )
+      ENDDO
+c
+c
+      CALL filtreg( rot, jjm, klevel, 2,1, .FALSE.,1)
+      CALL nxgrad ( klevel, rot, grx, gry )
+c
+      DO    l = 1, klevel
+         DO  ij = 1, ip1jm
+          gry( ij,l ) = gry( ij,l ) * nugradrs
+         ENDDO
+         DO  ij = 1, ip1jmp1
+          grx( ij,l ) = grx( ij,l ) * nugradrs
+         ENDDO
+      ENDDO
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/nxgrarot.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/nxgrarot.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/nxgrarot.F	(revision 1644)
@@ -0,0 +1,53 @@
+      SUBROUTINE nxgrarot (klevel,xcov, ycov, lr, grx, gry )
+c   ***********************************************************
+c
+c    Auteur :  P.Le Van  
+c
+c                                 lr
+c      calcul de  ( nXgrad (rot) )   du vect. v  ....
+c
+c       xcov et ycov  etant les compos. covariantes de  v
+c   ***********************************************************
+c     xcov , ycov et lr  sont des arguments  d'entree pour le s-prog
+c      grx   et  gry     sont des arguments de sortie pour le s-prog
+c
+c
+      IMPLICIT NONE
+c
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissipn.h"
+c
+      INTEGER klevel
+      REAL xcov( ip1jmp1,klevel ), ycov( ip1jm,klevel )
+      REAL  grx( ip1jmp1,klevel ),  gry( ip1jm,klevel )
+c
+      REAL rot(ip1jm,llm)
+
+      INTEGER l,ij,iter,lr
+c
+      EXTERNAL    filtreg
+      EXTERNAL       SCOPY, rotat, nXgrad
+c
+c
+      CALL SCOPY ( ip1jmp1*klevel, xcov, 1, grx, 1 )
+      CALL SCOPY (  ip1jm*klevel, ycov, 1, gry, 1 )
+c
+      DO 10 iter = 1,lr
+      CALL rotat (klevel,grx, gry, rot )
+      CALL filtreg( rot, jjm, klevel, 2,1, .false.,2)
+      CALL nxgrad (klevel,rot, grx, gry )
+c
+      DO 5  l = 1, klevel
+      DO 2 ij = 1, ip1jm
+      gry( ij,l ) = - gry( ij,l ) * crot
+   2  CONTINUE
+      DO 3 ij = 1, ip1jmp1
+      grx( ij,l ) = - grx( ij,l ) * crot
+   3  CONTINUE
+   5  CONTINUE
+c
+  10  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/paramet.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/paramet.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/paramet.h	(revision 1644)
@@ -0,0 +1,19 @@
+!-----------------------------------------------------------------------
+!   INCLUDE 'paramet.h'
+
+      INTEGER  iip1,iip2,iip3,jjp1,llmp1,llmp2,llmm1
+      INTEGER  kftd,ip1jm,ip1jmp1,ip1jmi1,ijp1llm
+      INTEGER  ijmllm,mvar
+      INTEGER jcfil,jcfllm
+
+      PARAMETER( iip1= iim+1-1/iim,iip2=iim+2,iip3=iim+3)
+      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 )
+      PARAMETER( ijp1llm= ip1jmp1 * llm, ijmllm= ip1jm * llm )
+      PARAMETER( mvar= ip1jmp1*( 2*llm+1) + ijmllm )
+      PARAMETER( jcfil=jjm/2+5, jcfllm=jcfil*llm )
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/dyn3d/pression.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/pression.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/pression.F	(revision 1644)
@@ -0,0 +1,29 @@
+      SUBROUTINE pression( ngrid, ap, bp, ps, p )
+c
+
+c      Auteurs : P. Le Van , Fr.Hourdin  .
+
+c  ************************************************************************
+c     Calcule la pression p(l) aux differents niveaux l = 1 ( niveau du
+c     sol) a l = llm +1, ces niveaux correspondant aux interfaces des (llm) 
+c     couches , avec  p(ij,llm +1) = 0.  et p(ij,1) = ps(ij)  .      
+c  ************************************************************************
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+c
+      INTEGER ngrid
+      INTEGER l,ij
+ 
+      REAL ap(llmp1), bp(llmp1), ps(ngrid), p(ngrid,llmp1) 
+      
+      DO    l    = 1, llmp1
+        DO  ij   = 1, ngrid
+         p(ij,l) = ap(l) + bp(l) * ps(ij)
+        ENDDO
+      ENDDO
+   
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/ps_amontF
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/ps_amontF	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/ps_amontF	(revision 1644)
@@ -0,0 +1,452 @@
+      SUBROUTINE ps_amont(nq,iq,q,w,pbaru,pbarv,dq)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " .
+c    ********************************************************************
+c     nq,iq,q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c     dq 	       sont des arguments de sortie pour le s-pg ....
+c
+c
+c   --------------------------------------------------------------------
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c
+c   Arguments:
+c   ----------
+      INTEGER nq,iq
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL q(ip1jmp1,llm,nq), dq( ip1jmp1,llm,nq )
+      REAL w(ip1jmp1,llm)
+c
+c      Local 
+c   ---------
+c
+      INTEGER i,ij,l
+c
+      REAL airej2,airejjm,airescb(iim),airesch(iim)
+      REAL pente(ip1jmp1),xg(ip1jmp1),xd(ip1jmp1),xs(ip1jmp1) ,
+     *     xn(ip1jmp1),xb(ip1jmp1),xh(ip1jmp1)
+      REAL qg(ip1jmp1),qd(ip1jmp1),qs(ip1jmp1) ,
+     *     qn(ip1jmp1),qb(ip1jmp1,llm),qh(ip1jmp1,llm)
+      REAL qbyv(ip1jm,llm), qbxu(ip1jmp1,llm), ww,dqh(ip1jmp1,llm)
+      REAL qpns,qpsn
+      logical first,extrpn,extrps
+      save first
+c
+c
+      REAL      SSUM,CVMGP,CVMGT
+      EXTERNAL  SSUM, convflu
+
+      data first/.true./
+
+      if(first) then
+         print*,'SCHEMA AMONT NOUVEAU'
+         first=.false.
+      endif
+
+
+c
+c
+      IF( forward.OR.leapf )   THEN
+c
+c
+      DO  100  l = 1, llm
+c
+c   ...  Boucle sur les  llm niveaux verticaux ...
+c
+c
+c  --------------------------------------------------------------
+c  --------------------------------------------------------------
+c  .............      Traitement en longitude     ...............
+c  --------------------------------------------------------------
+c  --------------------------------------------------------------
+c
+c     
+c        |          |            |           |
+c        |   q(i-1) |     q(i)   |   q(i+1)  |
+c        |          |qg(i)  qd(i)|qg(i+1)    |
+c
+c
+c      En  longitude ,
+c      Pour chaque maille ( i ) avec q(i,j,l,iq), on cherche a determiner
+c      avec une methode de ' pente' les valeurs qg(i) et qd(i) qui se trouvent
+c      au bord gauche et droite de cette maille .
+c
+c      Si ( q(i+1)-q(i) ) * ( q(i)-q(i-1)) < 0. ,on a qg(i)=qd(i)=q(i)
+c              Sinon
+c      qg(i)= q(i) - 1/4 * ( q(i+1) - q(i-1))
+c      qd(i)= q(i) + 1/4 * ( q(i+1) - q(i-1) )
+c
+c      On utilisera la meme methode pour determiner les valeurs qs(i) et qn(i)
+c      en latitude , ainsi que les valeurs qb(i) et qh(i) en  altitude .
+c
+c
+c
+       DO      ij    = 1,iip1
+       qg(ij)        = 0.
+       qd(ij)        = 0.
+       qg(ij+ ip1jm) = 0.
+       qd(ij+ ip1jm) = 0.
+       ENDDO
+c
+c     ....  calculs pour les lignes j= 2 a j = jjm  ....
+c
+       DO   ij    = iip2, ip1jm -1
+       pente(ij)  =( q(ij+1,l,iq)-q(ij,l,iq)) *(q(ij,l,iq)-q(ij-1,l,iq)) 
+       xg(ij)     = q(ij,l,iq) - 0.25 * ( q(ij+1,l,iq) - q(ij-1,l,iq) )
+       xd(ij)     = q(ij,l,iq) + 0.25 * ( q(ij+1,l,iq) - q(ij-1,l,iq) )
+       qg(ij)     = CVMGP( xg(ij), q(ij,l,iq) ,pente(ij) )
+       qd(ij)     = CVMGP( xd(ij), q(ij,l,iq), pente(ij) )
+       ENDDO
+
+c    ... Correction aux points  ( i= 1,  j )  .....
+c
+       DO   ij   = iip2, ip1jm, iip1
+       pente(ij) = ( q(ij+1,l,iq) - q(ij,l,iq) )     * 
+     *                                ( q(ij,l,iq)  - q(ij+iim-1,l,iq) )
+       xg(ij)    = q(ij,l,iq) - 0.25* ( q(ij+1,l,iq)- q(ij+iim-1,l,iq) )
+       xd(ij)    = q(ij,l,iq) + 0.25* ( q(ij+1,l,iq)- q(ij+iim-1,l,iq) )
+       qg(ij)    = CVMGP( xg(ij), q(ij,l,iq) ,pente(ij) )
+       qd(ij)    = CVMGP( xd(ij), q(ij,l,iq), pente(ij) )
+       ENDDO
+c
+c    ... Correction aux points ( i= iip1,  j ) .....
+c
+       DO     ij      = iip2, ip1jm, iip1
+       qg( ij+ iim  ) = qg( ij )
+       qd( ij+ iim )  = qd( ij )
+       ENDDO
+c
+c   .............................................................
+c   .........    Limitation des pentes a gauche des boites  .....
+c
+c    Si (q(i)-qg(i))*(qg(i)-q(i-1)) < 0.  , on a  qg(i)=q(i-1)  
+c                                         et qd(i)=2*q(i)-qg(i)
+c   .............................................................
+c
+       DO   ij  = iip2,ip1jm -1
+       pente(ij)= ( qg(ij) -q(ij-1,l,iq))*(q(ij,l,iq)-qg(ij) )
+       qg(ij)   = CVMGP( qg(ij), q(ij-1,l,iq) ,pente(ij) )
+       qd(ij)   = CVMGP( qd(ij), 
+     *                q(ij,l,iq)+ q(ij,l,iq) -qg(ij) , pente(ij) ) 
+       ENDDO
+c
+c      .....   Correction aux points ( i= 1,  j )  ......
+c
+       DO    ij  = iip2 ,ip1jm, iip1
+       qg(ij)    =  qg(ij+ iim)
+       qd(ij)    =  qd(ij+ iim)
+       ENDDO
+c    
+c      ...............................................................
+c      ...... Limitation des pentes a droite des boites      .........
+c      Si (q(i+1)-qd(i))*(qd(i)-q(i)) < 0. , on a qd(i)=q(i+1)
+c                                              et qg(i)=2*q(i)-qd(i) .
+c      ...............................................................
+c
+       DO ij = iip2, ip1jm -1
+       pente(ij) = ( qd(ij)-q(ij,l,iq) )*(q(ij+1,l,iq)-qd(ij) ) 
+       qd(ij)    =  CVMGP( qd(ij), q(ij+1,l,iq), pente(ij) )
+       qg(ij)    =  CVMGP( qg(ij), 
+     *                q(ij,l,iq)+ q(ij,l,iq) -qd(ij) , pente(ij) ) 
+       ENDDO
+c
+c      ....  Correction aux points ( i = iip1, j )  .....
+c
+       DO     ij     = iip2, ip1jm, iip1
+       qg( ij+ iim ) = qg( ij )
+       qd( ij+ iim ) = qd( ij )
+       ENDDO
+c
+
+c     -------------------------------------------------------------
+c     -------------------------------------------------------------
+c     .............    Traitement en  latitude    .................
+c     -------------------------------------------------------------
+c     -------------------------------------------------------------
+c
+c
+c      q(j=1)   PN
+c   --------------
+c     ---------  
+c   --------------
+c
+c      q(j-1)
+c
+c   --------------
+c            qn(j)
+c      q(j)
+c            qs(j)
+c   --------------
+c        
+c      q(j+1)
+c
+c   --------------
+c
+c      q(jjp1)  PS
+c
+c   --------------
+c
+c
+c     ......   operations pour les lignes j= 2 a j= jjm  .......
+c
+       DO    ij    = iip2, ip1jm
+       pente(ij)   = ( q(ij-iip1,l,iq)- q(ij,l,iq)  )  *
+     *               ( q(ij,l,iq) - q(ij+iip1,l,iq) )
+       xs(ij) = q(ij,l,iq) - 0.25 * ( q(ij-iip1,l,iq) -q(ij+iip1,l,iq) )
+       xn(ij) = q(ij,l,iq) + 0.25 * ( q(ij-iip1,l,iq) -q(ij+iip1,l,iq) )
+       qs(ij) = CVMGP( xs(ij), q(ij,l,iq), pente(ij) )
+       qn(ij) = CVMGP( xn(ij), q(ij,l,iq), pente(ij) )
+       ENDDO
+c
+c
+c     ......    Calculs aux  poles   .............................
+c     ............................................................
+c
+c     On n'a pas besoin des valeurs de  qn au pole Nord ( j=    1) ,
+c      ainsi que de celles de           qs au pole Sud  ( j= jjp1)
+c
+c
+      airej2 = SSUM( iim, aire(iip2), 1 )
+      airejjm= SSUM( iim, aire(ip1jm -iim), 1 ) 
+      DO i = 1, iim
+      airescb(i) = aire(i+ iip1) * q(i+ iip1,l,iq)
+      airesch(i) = aire(i+ ip1jm- iip1) * q(i+ ip1jm- iip1,l,iq)
+      ENDDO
+      qpns   = SSUM( iim,  airescb ,1 ) / airej2
+      qpsn   = SSUM( iim,  airesch ,1 ) / airejjm
+c
+c     qpns , val.moyenne de q sur la ligne j= 2
+c     qpsn , val.moyenne de q sur la ligne j= jjm
+c
+c
+c
+c  on cherche si on a un extremum au pole
+c
+      extrpn=.true.
+      extrps=.true.
+      DO ij=2,iim
+         if((q(iip1+i,l,iq)-q(1,l,iq))*(q(iip2,l,iq)-q(1,l,iq)).lt.0.)
+     .   extrpn=.false.
+         if((q(ip1jm-iip1+i,l,iq)-q(1,l,iq))*
+     .     (q(ip1jm-iim,l,iq)-q(1,l,iq)).lt.0.)
+     .      extrps=.false.
+      ENDDO
+
+c   calcul des pentes au pole
+
+      if(extrpn) then
+         DO    ij     = 1, iip1
+            qs(ij)= q(ij,l,iq)
+         ENDDO
+      else
+         DO    ij     = 1, iip1
+            qs(ij)= q(ij,l,iq) + 0.5 * ( q(ij+ iip1,l,iq) - qpns )
+         ENDDO
+      endif
+
+      if(extrps) then
+         DO    ij     = 1, iip1
+            qn(ij+ip1jm) = q(ij+ip1jm,l,iq)
+         ENDDO
+      else
+         DO    ij     = 1, iip1
+            qn(ij+ip1jm) = q(ij+ip1jm,l,iq) +   0.5 *
+     *                    ( q(ij+ip1jm-iip1,l,iq) - qpsn )
+         ENDDO
+      endif
+
+c
+c
+c    .........................................................
+c    ......    Limitation des pentes au sud des boites   .....
+c    .........................................................    
+c
+      DO   ij     = 1, ip1jm
+      pente(ij)   = ( qs(ij) - q (ij+iip1,l,iq) )   *
+     *              ( q( ij,l,iq) - qs( ij ) )
+      qs(ij) = CVMGP( qs(ij) , q(ij+iip1,l,iq), pente(ij) )
+      qn(ij) = CVMGP( qn(ij) , 
+     *                q(ij,l,iq)+ q(ij,l,iq) -qs(ij), pente(ij) )
+      ENDDO
+c
+c
+c     .......................................................
+c     .... Limitation des pentes au nord des boites .........
+c     .......................................................
+c
+      DO   ij     = iip2, ip1jmp1
+      pente(ij)   = ( qn( ij  ) -  q(ij,l,iq) )  *
+     *              (  q(ij-iip1,l,iq) - qn(ij) )
+      qn(ij)      = CVMGP( qn(ij), q(ij-iip1,l,iq), pente(ij) )
+      qs(ij)      = CVMGP( qs(ij), 
+     *                q(ij,l,iq)+ q(ij,l,iq) -qn(ij) , pente(ij) )
+      ENDDO
+c
+c
+c    .............................................................
+c    .....   Calculs des flux de  q  sur le plan horizontal ......
+c    .............................................................
+c
+c
+c
+c      
+c      ....  Selon   X  .... 
+c
+         DO  ij     = iip2, ip1jm - 1
+c
+         qbxu( ij,l ) =  pbaru( ij,l )   *
+     *            CVMGT( qd(ij), qg(ij +1), pbaru(ij,l).GT.0. )
+         ENDDO
+c
+c     ..... correction  pour  qbxu(iip1,j,l)   .....
+c     ...   qbxu(iip1,j,l)= qbxu(1,j,l)  ...
+c
+c           &&&CDIR$ IVDEP
+         DO    ij     = iip1 +iip1, ip1jm, iip1
+         qbxu( ij,l ) = qbxu( ij - iim, l )
+         ENDDO
+c
+c      .... Selon Y  .....
+c
+         DO    ij     = 1, ip1jm
+         qbyv( ij,l ) =  pbarv( ij,l )    *
+     *             CVMGT( qn(ij+iip1), qs(ij), pbarv(ij,l).GT.0. )
+         ENDDO
+c
+c
+c
+  100  CONTINUE
+c
+c     ..........................................................
+c     ( ... fin des traitements en longitude et latitude  ... )
+c
+c
+c   stockage dans  dqh  de la convergence horiz.du flux d'humidite  .
+c                   ....
+c
+c
+                 CALL convflu( qbxu, qbyv, llm, dqh )
+c
+c
+c
+c    ----------------------------------------------------------------
+c    ----------------------------------------------------------------
+c    .............      Traitement  en  altitude        .............
+c    ----------------------------------------------------------------
+c    ----------------------------------------------------------------
+c
+c
+c     -------------
+c        q (llm)
+c
+c     -------------
+c     -------------
+c
+c        q(l+1)
+c
+c     -------------
+c             qh(l)
+c        q(l)
+c             qb(l)
+c     -------------
+c
+c        q(l-1)
+c
+c     -------------
+c     -------------
+c        q(1)
+c     -------------
+c
+c
+c    ... Calculs pour les niveaux 2 a llm -1  ...
+c
+c
+      DO  200   l = 2, llm -1
+
+       DO   ij     = 1, ip1jmp1
+       pente(ij)   = ( q(ij, l+1 ,iq)  - q(ij , l  ,   iq) )  * 
+     *               ( q(ij,   l ,iq)  - q(ij ,l-1 ,   iq) )
+       xb(ij)      = q(ij,l,iq) - 0.25* ( q(ij,l+1,iq) - q(ij,l-1,iq) )
+       xh(ij)      = q(ij,l,iq) + 0.25* ( q(ij,l+1,iq) - q(ij,l-1,iq) )
+       qb(ij,l)    = CVMGP( xb(ij), q(ij,l,iq), pente(ij) )
+       qh(ij,l)    = CVMGP( xh(ij), q(ij,l,iq), pente(ij) )
+       ENDDO
+c
+c     ........................................................
+c     ......  Limitation des pentes en bas des boites   ......
+c     ........................................................
+c
+       DO   ij     = 1, ip1jmp1
+       pente(ij)   = ( qb(ij,l) - q ( ij,l-1,iq) )   *
+     *                ( q (ij,l,iq) - qb( ij,l ) )
+       qb(ij,l)    = CVMGP( qb(ij,l), q(ij,l-1,iq), pente(ij) )
+       qh(ij,l)    = CVMGP( qh(ij,l), 
+     *               q(ij,l,iq) + q(ij,l,iq) -qb(ij,l), pente(ij) )
+       ENDDO
+c
+c
+c     ........................................................
+c     ......  Limitation des pentes en haut des boites   ......
+c     ........................................................
+c
+       DO   ij     = 1, ip1jmp1
+       pente(ij)   = ( qh(ij,l) - q ( ij,l+1,iq) )   *
+     *                ( q (ij,l,iq) - qh( ij,l ) )
+       qh(ij,l)    = CVMGP( qh(ij,l), q(ij,l+1,iq), pente(ij) )
+       qb(ij,l)    = CVMGP( qb(ij,l), 
+     *               q(ij,l,iq) + q(ij,l,iq) -qh(ij,l), pente(ij) )
+       ENDDO
+c
+c
+  200  CONTINUE
+c
+c
+c    ............................................................
+c    .....     Calculs pour les niveaux l= 1 et l= llm  .........
+c    ............................................................
+c
+      DO   ij    = 1, ip1jmp1
+      qb(ij,1)   = q(ij, 1 , iq)
+      qb(ij,llm) = q(ij,llm, iq)
+      qh(ij,1)   = q(ij, 1 , iq)
+      qh(ij,llm) = q(ij,llm, iq)
+      ENDDO
+c
+
+c ---------------------------------------------------------------
+c   .... calcul des termes d'advection verticale  .......
+c ---------------------------------------------------------------
+
+c calcul de  - d( q   * w )/ d(sigma)    qu'on ajoute a  dqh pour calculer dq
+c
+
+       DO 300 l = 1,llmm1
+c
+         DO  ij = 1,ip1jmp1
+          ww= - w( ij,l+1 ) * 
+     *        CVMGT ( qh(ij,l), qb(ij,l+1), w(ij,l+1).LT.0.)
+
+          dq (ij, l ,iq ) = dqh(ij, l )   - dsig1( l ) * ww
+          dqh(ij,l+1    ) = dqh(ij,l+1)   + dsig1(l+1) * ww
+         ENDDO
+c
+  300   CONTINUE 
+c
+c
+c
+        DO  ij = 1,ip1jmp1
+          dq( ij,llm,iq ) = dqh( ij,llm )
+        END DO
+c
+c
+      END IF
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/psextbar.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/psextbar.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/psextbar.F	(revision 1644)
@@ -0,0 +1,105 @@
+      SUBROUTINE psextbar ( ps, psexbarxy )
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c **********************************************************************
+c calcul des moyennes en x et en y de (pression au sol*aire variable) ..
+c **********************************************************************
+c
+c         ps          est un  argum. d'entree  pour le s-pg ..
+c         psexbarxy   est un  argum. de sortie pour le s-pg ..
+c
+c   Methode:
+c   --------
+c
+c    A chaque point scalaire P (i,j) est affecte 4 coefficients d'aires
+c       alpha1(i,j)  calcule  au point ( i+1/4,j-1/4 )
+c       alpha2(i,j)  calcule  au point ( i+1/4,j+1/4 )
+c       alpha3(i,j)  calcule  au point ( i-1/4,j+1/4 )
+c       alpha4(i,j)  calcule  au point ( i-1/4,j-1/4 )
+c
+c    Avec  alpha1(i,j) = aire(i+1/4,j-1/4)/ aire(i,j)        
+c
+c    N.B .  Pour plus de details, voir s-pg  ...  iniconst ...
+c
+c
+c
+c   alpha4 .         . alpha1    . alpha4
+c    (i,j)             (i,j)       (i+1,j)
+c
+c             P .        U .          . P
+c           (i,j)       (i,j)         (i+1,j)
+c
+c   alpha3 .         . alpha2    .alpha3 
+c    (i,j)              (i,j)     (i+1,j)
+c
+c             V .        Z .          . V
+c           (i,j)
+c
+c   alpha4 .         . alpha1    .alpha4
+c   (i,j+1)            (i,j+1)   (i+1,j+1) 
+c
+c             P .        U .          . P
+c          (i,j+1)                    (i+1,j+1)
+c
+c
+c
+c
+c                       On  a :
+c
+c    pbarx(i,j) = Pext(i  ,j) * ( alpha1(i  ,j) + alpha2(i,j))      +
+c                 Pext(i+1,j) * ( alpha3(i+1,j) + alpha4(i+1,j) )
+c     localise  au point  ... U (i,j) ...
+c
+c    pbary(i,j) = Pext(i,j  ) * ( alpha2(i,j  ) + alpha3(i,j  )     +
+c                 Pext(i,j+1) * ( alpha1(i,j+1) + alpha4(i,j+1)  
+c     localise  au point  ... V (i,j) ...
+c
+c  pbarxy(i,j)= Pext(i,j) *alpha2(i,j) + Pext(i+1,j) *alpha3(i+1,j) +
+c               Pext(i,j+1)*alpha1(i,j+1)+ Pext(i+1,j+1)*alpha4(i+1,j+1)
+c     localise  au point  ... Z (i,j) ...
+c
+c
+c
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      REAL ps( ip1jmp1 ), psexbarxy ( ip1jm ), pext( ip1jmp1 )
+
+      INTEGER  l, ij
+      EXTERNAL SCOPY
+c
+
+      DO ij = 1, ip1jmp1
+       pext(ij) = ps(ij) * aire(ij)
+      ENDDO
+
+
+      DO     5     ij = 1, ip1jm - 1
+      psexbarxy( ij ) = pext(ij)*alpha2(ij) + pext(ij+1)*alpha3(ij+1) +
+     *   pext(ij+iip1)*alpha1(ij+iip1) + pext(ij+iip2)*alpha4(ij+iip2)
+   5  CONTINUE
+
+
+c    ....  correction pour     psexbarxy( iip1,j )  ........
+
+CDIR$ IVDEP
+
+      DO 7 ij = iip1, ip1jm, iip1
+      psexbarxy( ij ) = psexbarxy( ij - iim )
+   7  CONTINUE
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/ran1.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/ran1.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/ran1.F	(revision 1644)
@@ -0,0 +1,31 @@
+      FUNCTION RAN1(IDUM)
+      DIMENSION R(97)
+      save r
+      save iff,ix1,ix2,ix3
+      PARAMETER (M1=259200,IA1=7141,IC1=54773,RM1=3.8580247E-6)
+      PARAMETER (M2=134456,IA2=8121,IC2=28411,RM2=7.4373773E-6)
+      PARAMETER (M3=243000,IA3=4561,IC3=51349)
+      DATA IFF /0/
+      IF (IDUM.LT.0.OR.IFF.EQ.0) THEN
+        IFF=1
+        IX1=MOD(IC1-IDUM,M1)
+        IX1=MOD(IA1*IX1+IC1,M1)
+        IX2=MOD(IX1,M2)
+        IX1=MOD(IA1*IX1+IC1,M1)
+        IX3=MOD(IX1,M3)
+        DO 11 J=1,97
+          IX1=MOD(IA1*IX1+IC1,M1)
+          IX2=MOD(IA2*IX2+IC2,M2)
+          R(J)=(FLOAT(IX1)+FLOAT(IX2)*RM2)*RM1
+11      CONTINUE
+        IDUM=1
+      ENDIF
+      IX1=MOD(IA1*IX1+IC1,M1)
+      IX2=MOD(IA2*IX2+IC2,M2)
+      IX3=MOD(IA3*IX3+IC3,M3)
+      J=1+(97*IX3)/M3
+      IF(J.GT.97.OR.J.LT.1)PAUSE
+      RAN1=R(J)
+      R(J)=(FLOAT(IX1)+FLOAT(IX2)*RM2)*RM1
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/rotat.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/rotat.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/rotat.F	(revision 1644)
@@ -0,0 +1,55 @@
+      SUBROUTINE rotat (klevel, x, y, rot )
+c
+c     Auteur : P.Le Van 
+c**************************************************************
+c.  calcule le rotationnel
+c     a tous les niveaux d'1 vecteur de comp. x et y ..
+c       x  et  y etant des composantes  covariantes  ...
+c********************************************************************
+c   klevel, x  et y   sont des arguments d'entree pour le s-prog
+c        rot          est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c   .....  variables en arguments  ......
+c
+      INTEGER klevel
+      REAL rot( ip1jm,klevel )
+      REAL x( ip1jmp1,klevel ), y( ip1jm,klevel )
+c
+c  ...   variables  locales  ...
+c
+      INTEGER  l, ij
+c
+c
+      DO  10 l = 1,klevel
+c
+        DO   ij = 1, ip1jm - 1
+         rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   +
+     *                   x(ij +iip1, l )  -  x( ij,l )  
+        ENDDO
+c
+c    .... correction pour rot( iip1,j,l)  ....
+c    ....   rot(iip1,j,l)= rot(1,j,l) ...
+CDIR$ IVDEP
+        DO  ij = iip1, ip1jm, iip1
+         rot( ij,l ) = rot( ij -iim,l )
+        ENDDO
+c
+  10  CONTINUE
+
+ccc        CALL filtreg( rot, jjm, klevel, 2, 2, .FALSE., 1 )
+      
+        DO l = 1, klevel
+          DO ij = 1, ip1jm
+           rot(ij,l) = rot(ij,l) * unsairez(ij)
+          ENDDO
+        ENDDO
+c
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/rotat_nfil.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/rotat_nfil.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/rotat_nfil.F	(revision 1644)
@@ -0,0 +1,46 @@
+      SUBROUTINE rotat_nfil (klevel, x, y, rot )
+c
+c    Auteur :   P.Le Van 
+c**************************************************************
+c.          Calcule le rotationnel  non filtre   ,
+c      a tous les niveaux d'1 vecteur de comp. x et y ..
+c       x  et  y etant des composantes  covariantes  ...
+c********************************************************************
+c   klevel, x  et y   sont des arguments d'entree pour le s-prog
+c        rot          est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c   .....  variables en arguments  ......
+c
+      INTEGER klevel
+      REAL rot( ip1jm,klevel )
+      REAL x( ip1jmp1,klevel ), y( ip1jm,klevel )
+c
+c  ...   variables  locales  ...
+c
+      INTEGER  l, ij
+c
+c
+      DO  10 l = 1,klevel
+c
+        DO   ij = 1, ip1jm - 1
+         rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   +
+     *                   x(ij +iip1, l )  -  x( ij,l )  
+        ENDDO
+c
+c    .... correction pour rot( iip1,j,l)  ....
+c    ....   rot(iip1,j,l)= rot(1,j,l) ...
+CDIR$ IVDEP
+        DO  ij = iip1, ip1jm, iip1
+         rot( ij,l ) = rot( ij -iim,l )
+        ENDDO
+c
+  10  CONTINUE
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/rotatf.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/rotatf.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/rotatf.F	(revision 1644)
@@ -0,0 +1,55 @@
+      SUBROUTINE rotatf (klevel, x, y, rot )
+c
+c     Auteur : P.Le Van 
+c**************************************************************
+c.  calcule le rotationnel
+c     a tous les niveaux d'1 vecteur de comp. x et y ..
+c       x  et  y etant des composantes  covariantes  ...
+c********************************************************************
+c   klevel, x  et y   sont des arguments d'entree pour le s-prog
+c        rot          est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c   .....  variables en arguments  ......
+c
+      INTEGER klevel
+      REAL rot( ip1jm,klevel )
+      REAL x( ip1jmp1,klevel ), y( ip1jm,klevel )
+c
+c  ...   variables  locales  ...
+c
+      INTEGER  l, ij
+c
+c
+      DO  10 l = 1,klevel
+c
+        DO   ij = 1, ip1jm - 1
+         rot( ij,l )  =    y( ij+1 , l )  -  y( ij,l )   +
+     *                   x(ij +iip1, l )  -  x( ij,l )  
+        ENDDO
+c
+c    .... correction pour rot( iip1,j,l)  ....
+c    ....   rot(iip1,j,l)= rot(1,j,l) ...
+CDIR$ IVDEP
+        DO  ij = iip1, ip1jm, iip1
+         rot( ij,l ) = rot( ij -iim,l )
+        ENDDO
+c
+  10  CONTINUE
+
+        CALL filtreg( rot, jjm, klevel, 2, 2, .FALSE., 1 )
+      
+        DO l = 1, klevel
+          DO ij = 1, ip1jm
+           rot(ij,l) = rot(ij,l) * unsairez(ij)
+          ENDDO
+        ENDDO
+c
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/rotatst.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/rotatst.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/rotatst.F	(revision 1644)
@@ -0,0 +1,40 @@
+      SUBROUTINE rotatst (klevel,x, y, rot )
+c
+c  P. Le Van
+c
+c    *****************************************************************
+c     .. calcule le rotationnel a tous les niveaux d'1 vecteur de comp. x et y ..
+c         x  et  y etant des composantes  covariantes  .....
+c    *****************************************************************
+c        x  et y     sont des arguments d'entree pour le s-prog
+c        rot          est  un argument  de sortie pour le s-prog
+c
+      IMPLICIT NONE
+c
+      INTEGER klevel
+#include "dimensions.h"
+#include "paramet.h"
+
+      REAL rot( ip1jm,klevel )
+      REAL x( ip1jmp1,klevel ), y( ip1jm,klevel )
+      INTEGER  l, ij
+c
+c
+      DO 5 l = 1,klevel
+c
+      DO 1 ij = 1, ip1jm - 1
+      rot( ij,l )  =  (  y( ij+1 , l )  -  y( ij,l )   +
+     *                 x(ij +iip1, l )  -  x( ij,l )  )
+   1  CONTINUE
+c
+c    .... correction pour rot( iip1,j,l)  ....
+c
+c    ....   rot(iip1,j,l)= rot(1,j,l) ...
+CDIR$ IVDEP
+      DO 2 ij = iip1, ip1jm, iip1
+      rot( ij,l ) = rot( ij -iim,l )
+   2  CONTINUE
+c
+   5  CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/serre_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/serre_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/serre_mod.F90	(revision 1644)
@@ -0,0 +1,8 @@
+MODULE serre_mod
+
+IMPLICIT NONE  
+
+      REAL clon,clat,transx,transy,alphax,alphay,pxo,pyo,              &
+     &  grossismx, grossismy, dzoomx, dzoomy,taux,tauy
+
+END MODULE serre_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/sortvarc.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/sortvarc.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/sortvarc.F	(revision 1644)
@@ -0,0 +1,166 @@
+      SUBROUTINE sortvarc
+     $(itau,ucov,teta,ps,masse,pk,phis,vorpot,phi,bern,dp,time ,
+     $ vcov )
+
+      USE comconst_mod, ONLY: daysec,dtvr,rad,g,omeg
+      USE temps_mod, ONLY: day_ini
+      USE ener_mod, ONLY: etot,ptot,ztot,stot,ang,
+     .			etot0,ptot0,ztot0,stot0,ang0,
+     .			rmsdpdt,rmsv
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:    P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   sortie des variables de controle
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      INTEGER itau
+      REAL ucov(ip1jmp1,llm),teta(ip1jmp1,llm),masse(ip1jmp1,llm)
+      REAL vcov(ip1jm,llm)
+      REAL ps(ip1jmp1),phis(ip1jmp1)
+      REAL vorpot(ip1jm,llm)
+      REAL phi(ip1jmp1,llm),bern(ip1jmp1,llm)
+      REAL dp(ip1jmp1)
+      REAL time
+      REAL pk(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      REAL vor(ip1jm),bernf(ip1jmp1,llm),ztotl(llm)
+      REAL etotl(llm),stotl(llm),rmsvl(llm),angl(llm),ge(ip1jmp1)
+      REAL cosphi(ip1jm),omegcosp(ip1jm)
+      REAL dtvrs1j,rjour,heure,radsg,radomeg
+      REAL rday, massebxy(ip1jm,llm)
+      INTEGER  l, ij, imjmp1
+
+      EXTERNAL  filtreg, massbarxy
+c     EXTERNAL FLUSH
+      EXTERNAL   SSUM, SCOPY 
+      REAL       SSUM
+
+c-----------------------------------------------------------------------
+
+       dtvrs1j   = dtvr/daysec
+       rjour     = FLOAT( INT( itau * dtvrs1j ))
+       heure     = ( itau*dtvrs1j-rjour ) * 24.
+       imjmp1    = iim * jjp1
+       IF(ABS(heure - 24.).LE.0.0001 ) heure = 0.
+c
+       CALL massbarxy ( masse, massebxy )
+
+c   .....  Calcul  de  rmsdpdt  .....
+
+       CALL multipl(ip1jmp1,dp,dp,ge)
+
+       rmsdpdt = SSUM(ip1jmp1,ge,1) - SSUM(jjp1,ge,iip1)
+c
+       rmsdpdt = daysec* 1.e-2 * SQRT(rmsdpdt/imjmp1) 
+
+       CALL SCOPY( ijp1llm,bern,1,bernf,1 )
+       CALL filtreg(bernf,jjp1,llm,-2,2,.TRUE.,1)
+
+c   .....  Calcul du moment  angulaire   .....
+
+       radsg    = rad /g
+       radomeg  = rad * omeg
+c
+       DO ij=iip2,ip1jm
+          cosphi( ij ) = COS(rlatu((ij-1)/iip1+1))
+          omegcosp(ij) = radomeg   * cosphi(ij)
+       ENDDO
+
+c  ...  Calcul  de l'energie,de l'enstrophie,de l'entropie et de rmsv  .
+
+       DO l=1,llm
+          DO ij = 1,ip1jm
+             vor(ij)=vorpot(ij,l)*vorpot(ij,l)*massebxy(ij,l)
+          ENDDO
+          ztotl(l)=(SSUM(ip1jm,vor,1)-SSUM(jjm,vor,iip1))
+
+          DO ij = 1,ip1jmp1
+             ge(ij)= masse(ij,l)*(phis(ij)+teta(ij,l)*pk(ij,l)  +
+     s        bernf(ij,l)-phi(ij,l))
+          ENDDO
+          etotl(l) = SSUM(ip1jmp1,ge,1) - SSUM(jjp1,ge,iip1)
+
+          DO   ij   = 1, ip1jmp1
+             ge(ij) = masse(ij,l)*teta(ij,l)
+          ENDDO
+          stotl(l)= SSUM(ip1jmp1,ge,1) - SSUM(jjp1,ge,iip1)
+
+          DO ij=1,ip1jmp1
+             ge(ij)=masse(ij,l)*AMAX1(bernf(ij,l)-phi(ij,l),0.)
+          ENDDO
+          rmsvl(l)=2.*(SSUM(ip1jmp1,ge,1)-SSUM(jjp1,ge,iip1))
+
+          DO ij =iip2,ip1jm
+             ge(ij)=(ucov(ij,l)/cu(ij)+omegcosp(ij))*masse(ij,l) *
+     *               cosphi(ij)
+          ENDDO
+          angl(l) = radsg *
+     s    (SSUM(ip1jm-iip1,ge(iip2),1)-SSUM(jjm-1,ge(iip2),iip1))
+      ENDDO
+
+          DO ij=1,ip1jmp1
+            ge(ij)= ps(ij)*aire(ij)
+          ENDDO
+      ptot  = SSUM(ip1jmp1,ge,1)-SSUM(jjp1,ge,iip1)
+      etot  = SSUM(     llm, etotl, 1 )
+      ztot  = SSUM(     llm, ztotl, 1 )
+      stot  = SSUM(     llm, stotl, 1 )
+      rmsv  = SSUM(     llm, rmsvl, 1 )
+      ang   = SSUM(     llm,  angl, 1 )
+
+      rday = FLOAT(INT ( day_ini + time ))
+c
+      IF(ptot0.eq.0.)  THEN
+         PRINT 3500, itau, rday, heure,time
+         PRINT*,'WARNING!!! On recalcule les valeurs initiales de :'
+         PRINT*,'ptot,rmsdpdt,etot,ztot,stot,rmsv,ang'
+         PRINT *, ptot,rmsdpdt,etot,ztot,stot,rmsv,ang
+         etot0 = etot
+         ptot0 = ptot
+         ztot0 = ztot
+         stot0 = stot
+         ang0  = ang
+      END IF
+
+      etot= etot/etot0
+      rmsv= SQRT(rmsv/ptot)
+      ptot= ptot/ptot0
+      ztot= ztot/ztot0
+      stot= stot/stot0
+      ang = ang /ang0
+
+
+      PRINT 3500, itau, rday, heure, time
+      PRINT 4000, ptot,rmsdpdt,etot,ztot,stot,rmsv,ang
+
+      RETURN
+
+3500   FORMAT('0',10(1h*),4x,'pas',i7,5x,'jour',f5.0,'heure',f5.1,4x 
+     *   ,'date',f10.5,4x,10(1h*))
+4000   FORMAT(10x,'masse',4x,'rmsdpdt',7x,'energie',2x,'enstrophie'
+     * ,2x,'entropie',3x,'rmsv',4x,'mt.ang'/6x,f10.6,e13.6,5f10.3/
+     * )
+      END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/sortvarc0.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/sortvarc0.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/sortvarc0.F	(revision 1644)
@@ -0,0 +1,141 @@
+      SUBROUTINE sortvarc0
+     $(itau,ucov,teta,ps,masse,pk,phis,vorpot,phi,bern,dp,time ,
+     $ vcov)
+
+      USE comconst_mod, ONLY: dtvr,daysec,rad,g,omeg
+      USE temps_mod, ONLY: day_ini
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0,rmsv,rmsdpdt
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:    P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   sortie des variables de controle
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      INTEGER itau
+      REAL ucov(ip1jmp1,llm),teta(ip1jmp1,llm),masse(ip1jmp1,llm)
+      REAL vcov(ip1jm,llm)
+      REAL ps(ip1jmp1),phis(ip1jmp1)
+      REAL vorpot(ip1jm,llm)
+      REAL phi(ip1jmp1,llm),bern(ip1jmp1,llm)
+      REAL dp(ip1jmp1)
+      REAL time
+      REAL pk(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      REAL vor(ip1jm),bernf(ip1jmp1,llm),ztotl(llm)
+      REAL etotl(llm),stotl(llm),rmsvl(llm),angl(llm),ge(ip1jmp1)
+      REAL cosphi(ip1jm),omegcosp(ip1jm)
+      REAL dtvrs1j,rjour,heure,radsg,radomeg
+      REAL rday, massebxy(ip1jm,llm)
+      INTEGER  l, ij, imjmp1
+
+      EXTERNAL  filtreg, massbarxy
+c     EXTERNAL FLUSH
+      EXTERNAL   SSUM, SCOPY ,ismin,ismax
+      REAL       SSUM
+      integer  ismin,ismax
+
+c-----------------------------------------------------------------------
+
+       dtvrs1j   = dtvr/daysec
+       rjour     = FLOAT( INT( itau * dtvrs1j ))
+       heure     = ( itau*dtvrs1j-rjour ) * 24.
+       imjmp1    = iim * jjp1
+       IF(ABS(heure - 24.).LE.0.0001 ) heure = 0.
+c
+       CALL massbarxy ( masse, massebxy )
+
+c   .....  Calcul  de  rmsdpdt  .....
+
+       CALL multipl(ip1jmp1,dp,dp,ge)
+
+       rmsdpdt = SSUM(ip1jmp1,ge,1) - SSUM(jjp1,ge,iip1)
+c
+       rmsdpdt = daysec* 1.e-2 * SQRT(rmsdpdt/imjmp1) 
+
+       CALL SCOPY( ijp1llm,bern,1,bernf,1 )
+       CALL filtreg(bernf,jjp1,llm,-2,2,.TRUE.,1)
+
+c   .....  Calcul du moment  angulaire   .....
+
+       radsg    = rad /g
+       radomeg  = rad * omeg
+c
+       DO ij=iip2,ip1jm
+          cosphi( ij ) = COS(rlatu((ij-1)/iip1+1))
+          omegcosp(ij) = radomeg   * cosphi(ij)
+       ENDDO
+
+c  ...  Calcul  de l'energie,de l'enstrophie,de l'entropie et de rmsv  .
+
+       DO l=1,llm
+          DO ij = 1,ip1jm
+             vor(ij)=vorpot(ij,l)*vorpot(ij,l)*massebxy(ij,l)
+          ENDDO
+          ztotl(l)=(SSUM(ip1jm,vor,1)-SSUM(jjm,vor,iip1))
+
+          DO ij = 1,ip1jmp1
+             ge(ij)= masse(ij,l)*(phis(ij)+teta(ij,l)*pk(ij,l)  +
+     s        bernf(ij,l)-phi(ij,l))
+          ENDDO
+          etotl(l) = SSUM(ip1jmp1,ge,1) - SSUM(jjp1,ge,iip1)
+
+          DO   ij   = 1, ip1jmp1
+             ge(ij) = masse(ij,l)*teta(ij,l)
+          ENDDO
+          stotl(l)= SSUM(ip1jmp1,ge,1) - SSUM(jjp1,ge,iip1)
+
+          DO ij=1,ip1jmp1
+             ge(ij)=masse(ij,l)*AMAX1(bernf(ij,l)-phi(ij,l),0.)
+          ENDDO
+          rmsvl(l)=2.*(SSUM(ip1jmp1,ge,1)-SSUM(jjp1,ge,iip1))
+
+          DO ij =iip2,ip1jm
+             ge(ij)=(ucov(ij,l)/cu(ij)+omegcosp(ij))*masse(ij,l) *
+     *               cosphi(ij)
+          ENDDO
+          angl(l) = radsg *
+     s    (SSUM(ip1jm-iip1,ge(iip2),1)-SSUM(jjm-1,ge(iip2),iip1))
+      ENDDO
+
+          DO ij=1,ip1jmp1
+            ge(ij)= ps(ij)*aire(ij)
+          ENDDO
+      ptot0  = SSUM(ip1jmp1,ge,1)-SSUM(jjp1,ge,iip1)
+      etot0  = SSUM(     llm, etotl, 1 )
+      ztot0  = SSUM(     llm, ztotl, 1 )
+      stot0  = SSUM(     llm, stotl, 1 )
+      rmsv   = SSUM(     llm, rmsvl, 1 )
+      ang0   = SSUM(     llm,  angl, 1 )
+
+      rday = day_ini
+c
+      PRINT 3500, itau, rday, heure, time
+      PRINT *, ptot0,etot0,ztot0,stot0,ang0
+
+3500   FORMAT('0',10(1h*),4x,'pas',i7,5x,'jour',f5.0,'heure',f5.1,4x 
+     *   ,'date',f10.5,4x,10(1h*))
+      RETURN
+      END
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/spline.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/spline.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/spline.F	(revision 1644)
@@ -0,0 +1,76 @@
+      subroutine spline(x,y,n,yp1,ypn,y2)
+     
+c
+     
+c     Routine to set up the interpolating function for a cubic spline
+     
+c     interpolation (see "Numerical Recipes" for details).
+     
+c
+      implicit real (a-h,o-z)
+      implicit integer (i-n)
+     
+      parameter(nllm=4096)
+     
+      dimension x(n),y(n),y2(n),u(nllm)
+     
+c
+c	write(6,*)(x(i),i=1,n)
+c	write(6,*)(y(i),i=1,n)
+     
+      if(yp1.gt.0.99E30) then
+c the lower boundary condition is set
+       y2(1)=0.
+c either to be "natural"
+       u(1)=0.
+     
+      else
+c or else to have a specified first
+       y2(1)=-0.5
+c derivative
+       u(1)=(3./(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1)
+     
+      end if
+     
+      do 11 i=2,n-1
+c decomposition loop of the tridiagonal
+       sig=(x(i)-x(i-1))/(x(i+1)-x(i-1))
+c algorithm. Y2 and U are used
+       p=sig*y2(i-1)+2.
+c for temporary storage of the decompo-
+       y2(i)=(sig-1.)/p
+c sed factors
+       u(i)=(6.*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1))
+     
+     . /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/p
+     
+ 11   continue
+     
+      if(ypn.gt.0.99E30) then
+c the upper boundary condition is set
+       qn=0.
+c either to be "natural"
+       un=0.
+     
+      else
+c or else to have a specified first
+       qn=0.5
+c derivative
+       un=(3./(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1)))
+     
+      end if
+     
+      y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.)
+     
+      do 12 k=n-1,1,-1
+c this is the backsubstitution loop of
+       y2(k)=y2(k)*y2(k+1)+u(k)
+c the tridiagonal algorithm
+ 12   continue
+     
+c
+     
+      return
+     
+      end
+     
Index: /trunk/LMDZ.TITAN/libf/dyn3d/splint.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/splint.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/splint.F	(revision 1644)
@@ -0,0 +1,53 @@
+     
+      SUBROUTINE splint(xa,ya,y2a,n,x,y)
+     
+c
+c     Routine to compute a cubic-spline interpolated value Y given the
+c     value of X, the arrays XA, YA and the 2nd derivative array Y2A
+c     computed by SUBROUTINE SPLINE. See "Numerical Recipes" for details
+c
+     
+      IMPLICIT REAL (a-h,o-z)
+      IMPLICIT INTEGER (i-n)
+      DIMENSION xa(n),ya(n),y2a(n)
+     
+      kl0=1
+     
+      khi=n
+c means of bisection
+ 1    IF(khi-kl0.gt.1) THEN
+     
+       k=(khi+kl0)/2
+     
+       IF(xa(k).gt.x) THEN
+     
+        khi=k
+     
+       ELSE
+     
+        kl0=k
+     
+       END IF
+     
+       GO TO 1
+     
+      END IF
+c KL0 and KHI now bracket the X
+      h=xa(khi)-xa(kl0)
+     
+      IF(h.eq.0.0) STOP
+      a=(xa(khi)-x)/h
+c evaluation of cubic spline polynomial
+      b=(x-xa(kl0))/h
+     
+      y=a*ya(kl0)+b*ya(khi)+((a**3-a)*y2a(kl0)+(b**3-b)*y2a(khi))*(h**2)
+     
+     ./6.
+     
+c
+     
+      RETURN
+     
+      END
+     
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/sponge_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/sponge_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/sponge_mod.F90	(revision 1644)
@@ -0,0 +1,158 @@
+module sponge_mod
+
+USE comvert_mod, ONLY: ap,bp,preff
+
+implicit none
+
+! sponge parameters (set/read via defrun_new.F)
+logical,save :: callsponge  ! do we use a sponge on upper layers
+integer,save :: mode_sponge ! sponge mode
+integer,save :: nsponge ! number of sponge layers 
+real,save :: tetasponge  ! sponge time scale (s) at topmost layer
+
+
+contains
+
+      subroutine sponge(ucov,vcov,h,pext,dt,mode)
+
+! Sponge routine: Quench ucov, vcov and potential temperature near the
+!                 top of the model
+! Depending on 'mode' relaxation of variables is towards:
+! mode = 0 : h -> h_mean , ucov -> 0 , vcov -> 0
+! mode = 1 : h -> h_mean , ucov -> ucov_mean , vcov -> 0
+! mode >= 2 : h -> h_mean , ucov -> ucov_mean , vcov -> vcov_mean
+! Number of layer over which sponge is applied is 'nsponge' (read from def file)
+! Time scale for quenching at top level is given by 'tetasponge' (read from
+! def file) and doubles as level indexes decrease.
+! Quenching is modeled as: A(t)=Am+A0exp(-lambda*t)
+! where Am is the zonal average of the field (or zero), and lambda the inverse
+! of the characteristic quenching/relaxation time scale
+! Thus, assuming Am to be time-independent, field at time t+dt is given by:
+! A(t+dt)=A(t)-(A(t)-Am)*(1-exp(-lambda*t))
+
+
+      implicit none
+#include "dimensions.h"
+#include "paramet.h"
+#include "comdissip.h"
+#include "comgeom2.h"
+
+! Arguments:
+!------------
+      real,intent(inout) :: ucov(iip1,jjp1,llm) ! covariant zonal wind
+      real,intent(inout) :: vcov(iip1,jjm,llm) ! covariant meridional wind
+      real,intent(inout) :: h(iip1,jjp1,llm) ! potential temperature
+      real,intent(in) :: pext(iip1,jjp1) ! extensive pressure
+      real,intent(in) :: dt   ! time step
+      integer,intent(in) :: mode  ! sponge mode
+
+!   Local:
+!   ------
+
+      real,save :: sig_s(llm) !sigma au milieu des couches
+      REAL vm,um,hm,ptot(jjp1)
+      real,save :: cst(llm)
+
+      INTEGER l,i,j
+      integer,save :: l0 ! layer down to which sponge is applied
+
+      real ssum
+
+      real echelle,zkm
+      logical,save :: firstcall=.true.
+
+
+
+      if (firstcall) then
+
+       ! build approximative sigma levels at midlayer
+        do l=1,llm
+          sig_s(l)=((ap(l)+ap(l+1))/preff+bp(l)+bp(l+1))/2.
+        enddo
+
+        l0=llm-nsponge+1
+ 
+        PRINT*
+        print*,'sponge mode',mode
+        print*,'nsponge tetasponge ',nsponge,tetasponge
+        print*,'Coeffs for the sponge layer'
+        print*,'Z (km)     tau      cst'
+        do l=llm,l0,-1
+          ! double time scale with every level, starting from the top
+          cst(l)=1.-exp(-dt/(tetasponge*2**(llm-l)))
+        enddo
+
+        echelle=10.
+        do l=l0,llm
+           zkm=-echelle*log(sig_s(l))
+           print*,zkm,tetasponge*2**(llm-l),cst(l)
+        enddo
+        PRINT*
+
+        firstcall=.false.
+      endif ! of if (firstcall)
+
+!-----------------------------------------------------------------------
+!   compute sponge relaxation:
+!   -------------------------
+
+      do j=1,jjp1
+         ptot(j)=ssum(iim,pext(1,j),1)
+      enddo
+ 
+!   potential temperature
+      do l=l0,llm
+         do j=1,jjp1
+            ! compute zonal average
+            hm=0.
+            do i=1,iim
+               hm=hm+h(i,j,l)*pext(i,j)
+            enddo
+            hm=hm/ptot(j)
+            ! update h()
+            do i=1,iim
+               h(i,j,l)=h(i,j,l)-cst(l)*(h(i,j,l)-hm)
+            enddo
+            h(iip1,j,l)=h(1,j,l)
+         enddo
+      enddo
+
+!   zonal wind
+      do l=l0,llm
+         do j=2,jjm
+            um=0.
+            if(mode.ge.1) then ! compute zonal average
+               do i=1,iim
+                  um=um+0.5*ucov(i,j,l)*(pext(i,j)+pext(i+1,j))/cu(i,j)
+               enddo
+               um=um/ptot(j)
+            endif
+            ! update ucov()
+            do i=1,iim
+               ucov(i,j,l)=ucov(i,j,l)-cst(l)*(ucov(i,j,l)-um*cu(i,j))
+            enddo
+            ucov(iip1,j,l)=ucov(1,j,l)
+         enddo
+      enddo
+
+!  meridional wind
+      do l=l0,llm
+         do j=1,jjm
+            vm=0.
+            if(mode.ge.2) then ! compute zonal average
+               do i=1,iim
+                  vm=vm+vcov(i,j,l)*(pext(i,j)+pext(i,j+1))/cv(i,j)
+               enddo
+               vm=vm/(ptot(j)+ptot(j+1))
+            endif
+            ! update vcov
+            do i=1,iim
+               vcov(i,j,l)=vcov(i,j,l)-cst(l)*(vcov(i,j,l)-vm*cv(i,j))
+            enddo
+            vcov(iip1,j,l)=vcov(1,j,l)
+         enddo
+      enddo
+
+      end subroutine sponge
+      
+end module sponge_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/temps_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/temps_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/temps_mod.F90	(revision 1644)
@@ -0,0 +1,9 @@
+MODULE temps_mod
+
+IMPLICIT NONE  
+
+      INTEGER  itaufin
+      INTEGER*4 day_ini,day_end
+      REAL     dt
+
+END MODULE temps_mod
Index: /trunk/LMDZ.TITAN/libf/dyn3d/test_period.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/test_period.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/test_period.F	(revision 1644)
@@ -0,0 +1,89 @@
+      SUBROUTINE test_period ( ucov, vcov, teta, q, p, phis )
+      
+      USE infotrac, ONLY: nqtot
+      IMPLICIT NONE
+c
+c     Auteur : P. Le Van  
+c    ---------
+c  ....  Cette routine teste la periodicite en longitude des champs   ucov,
+c                           teta, q , p et phis                 .......... 
+c
+c     IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+c
+c    ......  Arguments   ......
+c
+      REAL ucov(ip1jmp1,llm), vcov(ip1jm,llm), teta(ip1jmp1,llm) ,
+     ,      q(ip1jmp1,llm,nqtot), p(ip1jmp1,llmp1), phis(ip1jmp1)
+c
+c   .....  Variables  locales  .....
+c
+      INTEGER ij,l,nq
+c
+      DO l = 1, llm
+         DO ij = 1, ip1jmp1, iip1
+          IF( ucov(ij,l).NE.ucov(ij+iim,l) )  THEN
+          PRINT *,'STOP dans test_period car ---  UCOV  ---  n est pas',  
+     ,  ' periodique en longitude ! '
+          PRINT *,' l,  ij = ', l, ij, ij+iim
+          STOP
+          ENDIF
+          IF( teta(ij,l).NE.teta(ij+iim,l) )  THEN
+          PRINT *,'STOP dans test_period car ---  TETA  ---  n est pas',  
+     ,   ' periodique en longitude ! '
+          PRINT *,' l,  ij = ', l, ij, ij+iim
+          STOP
+          ENDIF
+         ENDDO
+      ENDDO
+
+c
+      DO l = 1, llm
+         DO ij = 1, ip1jm, iip1
+          IF( vcov(ij,l).NE.vcov(ij+iim,l) )  THEN
+          PRINT *,'STOP dans test_period car ---  VCOV  ---  n est pas',  
+     ,   ' periodique en longitude !'
+          PRINT *,' l,  ij = ', l, ij, ij+iim,vcov(ij+iim,l),vcov(ij,l)
+          vcov(ij+iim,l)=vcov(ij,l)
+          STOP
+          ENDIF
+         ENDDO
+      ENDDO
+      
+c
+      DO nq =1, nqtot
+        DO l =1, llm
+          DO ij = 1, ip1jmp1, iip1
+          IF( q(ij,l,nq).NE.q(ij+iim,l,nq) )  THEN
+          PRINT *,'STOP dans test_period car ---  Q  ---  n est pas ',  
+     ,   'periodique en longitude !'
+          PRINT *,' nq , l,  ij, ij+iim = ', nq, l, ij, ij+iim
+        PRINT *,'q(ij,l,nq) q(ij+iim,l,nq) ',q(ij,l,nq),q(ij+iim,l,nq)
+          STOP
+          ENDIF
+          ENDDO
+        ENDDO
+      ENDDO
+c
+       DO l = 1, llm
+         DO ij = 1, ip1jmp1, iip1
+          IF( p(ij,l).NE.p(ij+iim,l) )  THEN
+          PRINT *,'STOP dans test_period car ---  P  ---  n est pas',  
+     ,    ' periodique en longitude !'
+          PRINT *,' l ij = ',l, ij, ij+iim
+          STOP
+          ENDIF
+          IF( phis(ij).NE.phis(ij+iim) )  THEN
+          PRINT *,'STOP dans test_period car ---  PHIS  ---  n est pas',  
+     ,   ' periodique en longitude !  l, IJ = ', l, ij,ij+iim
+          PRINT *,' ij = ', ij, ij+iim
+          STOP
+          ENDIF
+         ENDDO
+       ENDDO
+c
+c
+         RETURN
+         END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/tourpot.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/tourpot.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/tourpot.F	(revision 1644)
@@ -0,0 +1,78 @@
+      SUBROUTINE tourpot ( vcov, ucov, massebxy, vorpot )
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  P. Le Van
+c   -------
+c
+c   Objet:
+c   ------
+c
+c    *******************************************************************
+c    .........      calcul du tourbillon potentiel             .........
+c    *******************************************************************
+c
+c     vcov,ucov,fext et pbarxyfl sont des argum. d'entree pour le s-pg .
+c             vorpot            est  un argum.de sortie pour le s-pg .
+c
+c=======================================================================
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+      REAL  rot( ip1jm,llm )
+      REAL vcov( ip1jm,llm ),ucov( ip1jmp1,llm )
+      REAL massebxy( ip1jm,llm ),vorpot( ip1jm,llm )
+
+      INTEGER l, ij
+
+      EXTERNAL filtreg
+
+
+
+c  ... vorpot = ( Filtre( d(vcov)/dx - d(ucov)/dy ) + fext ) /psbarxy ..
+
+
+
+c    ........  Calcul du rotationnel du vent V  puis filtrage  ........
+
+      DO 5 l = 1,llm
+
+      DO 2 ij = 1, ip1jm - 1
+      rot( ij,l ) = vcov(ij+1,l)-vcov(ij,l)+ucov(ij+iip1,l)-ucov(ij,l)
+   2  CONTINUE
+
+c    ....  correction pour  rot( iip1,j,l )  .....
+c    ....     rot(iip1,j,l) = rot(1,j,l)    .....
+
+CDIR$ IVDEP
+
+      DO 3 ij = iip1, ip1jm, iip1
+      rot( ij,l ) = rot( ij -iim, l )
+   3  CONTINUE
+
+   5  CONTINUE
+
+
+      CALL filtreg( rot, jjm, llm, 2, 1, .FALSE., 1 )
+
+
+      DO 10 l = 1, llm
+
+      DO 6 ij = 1, ip1jm - 1
+      vorpot( ij,l ) = ( rot(ij,l) + fext(ij) ) / massebxy(ij,l)
+   6  CONTINUE
+
+c    ..... correction pour  vorpot( iip1,j,l)  .....
+c    ....   vorpot(iip1,j,l)= vorpot(1,j,l) ....
+CDIR$ IVDEP
+      DO 8 ij = iip1, ip1jm, iip1
+      vorpot( ij,l ) = vorpot( ij -iim,l )
+   8  CONTINUE
+
+  10  CONTINUE
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/traceur.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/traceur.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/traceur.F	(revision 1644)
@@ -0,0 +1,80 @@
+      SUBROUTINE traceur (iq,iadv,q,teta,pk,w, pbaru, pbarv,dq )
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  F.Forget / A.Armengaud
+c   -------
+c
+c   ....  Modif  P.Le Van  ,  29/04/97  et 01/06/98    ....
+c
+c   ********************************************************************
+c   Transport des traceurs (dont l'humidite q(1)) par differents shemas
+c   ********************************************************************
+c     iq,q,pbaru et pbarv sont des arguments d'entree  pour le s-pg ....
+c     dq 	       sont des arguments de sortie pour le s-pg ....
+c
+c     iadv = 1 :  Schema de transport type "humidite specifique  LMD"
+c                 (shema amont (horiz),moy arithmetique (vertic))
+c
+c     iadv = 2  :  Shema amont
+c
+c
+c     iadv = 0  : Indice montrant que q n'est pas vraiment un 
+c                traceur, mais une variable pronostique attachee
+c                (par exemple : une pente du shemas de pente)
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+
+c   Arguments:
+c   ----------
+      INTEGER iq,iadv(iq) 
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL q( ip1jmp1,llm,iq), dq( ip1jmp1,llm,iq)
+      REAL w(ip1jmp1,llm),teta(ip1jmp1,llm),pk(ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      LOGICAL     qsat
+      PARAMETER ( qsat = .TRUE. )
+
+c
+cc ******     Si  iadv(iq) =  2   et   qsat = .TRUE.  ,   
+cc        ,  on choisit  le shema  amont avec le q sature   ********
+c
+
+      EXTERNAL adv_h2o, amont, amont_qsat
+
+
+       IF( iadv(iq).GT.2 )  THEN
+         PRINT *,' Erreur dans le choix de iadv  pour la routine 
+     *  traceur .  Corrigez . '
+         STOP
+       ENDIF
+
+c   ----------------------------------------------------------------
+c   Schema de transport type "humidite specifique  LMD" 
+c   (shema amont (horiz),moy arithmetique (vertic))
+c   ----------------------------------------------------------------
+         IF (iadv(iq).EQ.1) THEN
+              CALL adv_h2o (iq,iq,q,w, pbaru, pbarv,dq)       
+c   ----------------------------------------------------------------
+c   Shema amont (dans les 3 dimensions)
+c   ----------------------------------------------------------------
+         ELSE IF (iadv(iq).EQ.2) THEN
+           IF( qsat )   THEN
+              CALL amont_qsat ( iq,iq,q,teta,pk,w, pbaru, pbarv,dq )
+           ELSE
+              CALL amont      ( iq,iq,q,        w, pbaru, pbarv,dq )
+           ENDIF
+c   ----------------------------------------------------------------
+
+         ENDIF
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/tracstoke.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/tracstoke.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/tracstoke.h	(revision 1644)
@@ -0,0 +1,2 @@
+      common /tracstoke/istdyn,istphy,unittrac
+      integer istdyn,istphy,unittrac
Index: /trunk/LMDZ.TITAN/libf/dyn3d/tracvl.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/tracvl.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/tracvl.F	(revision 1644)
@@ -0,0 +1,130 @@
+      SUBROUTINE tracvl(numvanle,iapp_tracvl,nq,pbaru,pbarv ,
+     *                    p, masse , q, iapptrac, iadv1, teta, pk  )
+c
+c     Auteur :  F. Hourdin
+c
+c
+ccc   ..   Modif. P. Le Van  ( 20/12/97 )  ...
+c                 F. Codron     (10/99)
+
+c
+      USE comconst_mod, ONLY: dtvr
+
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c     .... Arguments  ....
+c
+      INTEGER numvanle, nq, iapp_tracvl, iapptrac, iadv1
+
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
+      REAL q(ip1jmp1,llm,nq),masse(ip1jmp1,llm)
+      REAL p( ip1jmp1,llmp1 ),teta(ip1jmp1,llm)
+      REAL pk(ip1jmp1,llm)
+
+c     ....  var. locales  .....
+c
+      REAL pbaruc(ip1jmp1,llm),pbarvc(ip1jm,llm)
+      REAL massem(ip1jmp1,llm),zdp(ip1jmp1)
+
+      REAL pbarug(ip1jmp1,llm),pbarvg(ip1jm,llm),wg(ip1jmp1,llm)
+
+
+      INTEGER iadvtr, numvan
+      INTEGER ij,l,iq
+      REAL zdpmin, zdpmax
+      EXTERNAL  minmax
+      SAVE iadvtr, massem, pbaruc, pbarvc, numvan
+      DATA iadvtr/0/
+
+      numvan = numvanle
+
+      IF(iadvtr.EQ.0) THEN
+         CALL initial0(ijp1llm,pbaruc)
+         CALL initial0(ijmllm,pbarvc)
+      ENDIF
+
+c   accumulation des flux de masse horizontaux
+      DO l=1,llm
+         DO ij = 1,ip1jmp1
+            pbaruc(ij,l) = pbaruc(ij,l) + pbaru(ij,l)
+         ENDDO
+         DO ij = 1,ip1jm
+            pbarvc(ij,l) = pbarvc(ij,l) + pbarv(ij,l)
+         ENDDO
+      ENDDO
+
+c   selection de la masse instantannee des mailles avant le transport.
+      IF(iadvtr.EQ.0) THEN
+
+         CALL SCOPY(ip1jmp1*llm,masse,1,massem,1)
+ccc         CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 )
+c
+      ENDIF
+
+      iadvtr   = iadvtr+1
+      iapptrac = iadvtr
+
+
+c   Test pour savoir si on advecte a ce pas de temps
+      IF ( iadvtr.EQ.iapp_tracvl ) THEN
+!      print*,'WARNING: ALL TRACER ADVECTION HALTED IN TRACVL.F'
+!         if(2.eq.1)then
+
+
+cc   ..  Modif P.Le Van  ( 20/12/97 )  ....
+cc
+
+c   traitement des flux de masse avant advection.
+c     1. calcul de w
+c     2. groupement des mailles pres du pole.
+
+        CALL groupe( massem, pbaruc,pbarvc, pbarug,pbarvg,wg )
+
+
+c  test sur l'eventuelle creation de valeurs negatives de la masse
+         DO l=1,llm-1
+            DO ij = iip2+1,ip1jm
+              zdp(ij) = pbarug(ij-1,l) - pbarug(ij,l)
+     s                  - pbarvg(ij-iip1,l) + pbarvg(ij,l)
+     s                  + wg(ij,l+1) - wg(ij,l)
+            ENDDO
+            CALL SCOPY( jjm -1 ,zdp(iip1+iip1),iip1,zdp(iip2),iip1 )
+            DO ij = iip2,ip1jm
+               zdp(ij)= zdp(ij)*dtvr/ massem(ij,l) 
+            ENDDO 
+
+
+            CALL minmax ( ip1jm-iip1, zdp(iip2), zdpmin,zdpmax )
+
+            IF(MAX(ABS(zdpmin),ABS(zdpmax)).GT.0.5) THEN
+            PRINT*,'WARNING DP/P l=',l,'  MIN:',zdpmin,
+     s        '   MAX:', zdpmax
+            ENDIF
+
+         ENDDO
+
+c   Advection proprement dite.
+c
+c   test sur iadv1 pour le schema de vapeur d'eau
+c
+         IF (numvanle.EQ.1.AND.iadv1.EQ.4) THEN
+           CALL vlspltqs( q(1,1,1), 2., massem, wg ,
+     *                 pbarug,pbarvg,dtvr,p,pk,teta )
+           numvan = 2
+         ENDIF
+
+         DO iq = numvan, nq
+          CALL vlsplt( q(1,1,iq), 2. ,massem,wg,pbarug,pbarvg,dtvr )
+         ENDDO
+         iadvtr=0
+
+c   on reinitialise a zero les flux de masse cumules.
+
+      ENDIF ! if iadvtr.EQ.iapp_tracvl
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/vanleer.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/vanleer.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/vanleer.F	(revision 1644)
@@ -0,0 +1,72 @@
+      SUBROUTINE vanleer(numvanle,iapp_tracvl,nq,q,pbaru,pbarv ,
+     *                     p ,masse, dq ,  iadv1, teta, pk      )
+c
+      USE comconst_mod, ONLY: dtvr
+
+      IMPLICIT NONE
+c
+c     Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron  
+c
+c=======================================================================
+c
+c       Shema de  Van Leer
+c       Version simplifiée pour Mars
+c       (L'original bugue a cause des histoires d'eau terrestre !!)
+c       FF 2003
+c
+c=======================================================================
+
+
+#include "dimensions.h"
+#include "paramet.h"
+
+c   Arguments:
+c   ----------
+      INTEGER nq, numvanle, iapp_tracvl, iadv1 
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm),masse(ip1jmp1,llm)
+      REAL p( ip1jmp1,llmp1),q( ip1jmp1,llm,nq),dq( ip1jmp1,llm,nq )
+      REAL teta( ip1jmp1,llm),pk( ip1jmp1,llm)
+c  ..................................................................
+c
+c   Local:
+c   ------
+
+!      EXTERNAL  tracvl,minmaxq, qminimum
+      INTEGER ij,l, iq, iapptrac
+      REAL finmasse(ip1jmp1,llm), dtvrtrac
+cc
+
+        CALL SCOPY( nq * ijp1llm, q, 1, dq, 1 )
+
+c   advection
+
+      CALL tracvl( numvanle,iapp_tracvl,nq,pbaru,pbarv,p , masse,q  ,
+     *                      iapptrac, iadv1, teta ,pk              )
+
+cc     ....  Calcul  de deltap  qu'on stocke dans finmasse   ...
+c
+          DO l = 1, llm
+           DO ij = 1, ip1jmp1
+             finmasse(ij,l) =  p(ij,l) - p(ij,l+1) 
+           ENDDO
+          ENDDO
+
+          CALL SCOPY   ( ip1jmp1*llm, masse, 1, finmasse,       1 )
+          CALL filtreg ( finmasse ,  jjp1,  llm, -2, 2, .TRUE., 1 )
+c
+c   *****  Calcul de dq pour l'eau , pour le passer a la physique ******
+
+          dtvrtrac = iapp_tracvl * dtvr
+c
+           DO iq = 1 , nq ! modif special mars : 2 devient nq
+            DO l = 1 , llm
+             DO ij = 1,ip1jmp1
+             dq(ij,l,iq) = ( q(ij,l,iq) - dq(ij,l,iq) ) * finmasse(ij,l)
+     *                               /  dtvrtrac
+             ENDDO
+            ENDDO
+           ENDDO
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/vitvert.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/vitvert.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/vitvert.F	(revision 1644)
@@ -0,0 +1,50 @@
+      SUBROUTINE vitvert ( convm , w )
+c
+      USE comvert_mod, ONLY: bp
+
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteurs:  P. Le Van , F. Hourdin .
+c   -------
+c
+c   Objet:
+c   ------
+c
+c    *******************************************************************
+c  .... calcul de la vitesse verticale aux niveaux sigma  ....
+c    *******************************************************************
+c     convm   est un argument  d'entree pour le s-pg  ......
+c       w     est un argument de sortie pour le s-pg  ......
+c
+c    la vitesse verticale est orientee de  haut en bas .
+c    au sol, au niveau sigma(1),   w(i,j,1) = 0.
+c    au sommet, au niveau sigma(llm+1) , la vit.verticale est aussi
+c    egale a 0. et n'est pas stockee dans le tableau w  .
+c
+c
+c=======================================================================
+
+#include "dimensions.h"
+#include "paramet.h"
+
+      REAL w(ip1jmp1,llm),convm(ip1jmp1,llm)
+      INTEGER   l, ij
+
+
+
+      DO 2  l = 1,llmm1
+
+      DO 1 ij = 1,ip1jmp1
+      w( ij, l+1 ) = convm( ij, l+1 ) - bp(l+1) * convm( ij, 1 )
+   1  CONTINUE
+
+   2  CONTINUE
+
+      DO 5 ij  = 1,ip1jmp1
+      w(ij,1)  = 0.
+5     CONTINUE
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dyn3d/vlsplt.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/vlsplt.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/vlsplt.F	(revision 1644)
@@ -0,0 +1,877 @@
+      SUBROUTINE vlsplt(q,pente_max,masse,w,pbaru,pbarv,pdt)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " .
+c    ********************************************************************
+c     q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c
+c   pente_max facteur de limitation des pentes: 2 en general
+c                                               0 pour un schema amont
+c   pbaru,pbarv,w flux de masse en u ,v ,w
+c   pdt pas de temps
+c
+c   --------------------------------------------------------------------
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+
+c
+c   Arguments:
+c   ----------
+      REAL masse(ip1jmp1,llm),pente_max
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL q(ip1jmp1,llm)
+      REAL w(ip1jmp1,llm),pdt
+c
+c      Local 
+c   ---------
+c
+      INTEGER ij,l
+c
+      REAL zm(ip1jmp1,llm)
+      REAL mu(ip1jmp1,llm)
+      REAL mv(ip1jm,llm)
+      REAL mw(ip1jmp1,llm+1)
+      REAL zq(ip1jmp1,llm)
+      REAL temps1,temps2,temps3
+      REAL zzpbar, zzw
+      LOGICAL testcpu
+      SAVE testcpu
+      SAVE temps1,temps2,temps3
+
+      REAL qmin,qmax
+      DATA qmin,qmax/0.,1.e33/
+      DATA testcpu/.false./
+      DATA temps1,temps2,temps3/0.,0.,0./
+
+c      PRINT*,'Debut vlsplt version debug sans vly'
+
+        zzpbar = 0.5 * pdt
+        zzw    = pdt
+      DO l=1,llm
+        DO ij = iip2,ip1jm
+            mu(ij,l)=pbaru(ij,l) * zzpbar
+         ENDDO
+         DO ij=1,ip1jm
+            mv(ij,l)=pbarv(ij,l) * zzpbar
+         ENDDO
+         DO ij=1,ip1jmp1
+            mw(ij,l)=w(ij,l) * zzw
+         ENDDO
+      ENDDO
+
+      DO ij=1,ip1jmp1
+         mw(ij,llm+1)=0.
+      ENDDO
+
+      CALL SCOPY(ijp1llm,q,1,zq,1)
+      CALL SCOPY(ijp1llm,masse,1,zm,1)
+
+c      call minmaxq(zq,qmin,qmax,'avant vlx     ')
+      call vlx(zq,pente_max,zm,mu)
+
+
+c     call minmaxq(zq,qmin,qmax,'avant vly     ')
+
+      call vly(zq,pente_max,zm,mv)
+
+
+c      call minmaxq(zq,qmin,qmax,'avant vlz     ')
+
+      call vlz(zq,pente_max,zm,mw)
+
+
+c     call minmaxq(zq,qmin,qmax,'avant vly     ')
+c     call minmaxq(zm,qmin,qmax,'M avant vly     ')
+
+      call vly(zq,pente_max,zm,mv)
+
+
+c     call minmaxq(zq,qmin,qmax,'avant vlx     ')
+c     call minmaxq(zm,qmin,qmax,'M avant vlx     ')
+
+      call vlx(zq,pente_max,zm,mu)
+
+c     call minmaxq(zq,qmin,qmax,'apres vlx     ')
+c     call minmaxq(zm,qmin,qmax,'M apres vlx     ')
+
+
+      DO l=1,llm
+         DO ij=1,ip1jmp1
+           q(ij,l)=zq(ij,l)
+         ENDDO
+         DO ij=1,ip1jm+1,iip1
+            q(ij+iim,l)=q(ij,l)
+         ENDDO
+      ENDDO
+
+      RETURN
+      END
+      SUBROUTINE vlx(q,pente_max,masse,u_m)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " .
+c    ********************************************************************
+c     nq,iq,q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c
+c
+c   --------------------------------------------------------------------
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+c
+c
+c   Arguments:
+c   ----------
+      REAL masse(ip1jmp1,llm),pente_max
+      REAL u_m( ip1jmp1,llm )
+      REAL q(ip1jmp1,llm)
+c
+c      Local 
+c   ---------
+c
+      INTEGER ij,l,j,i,iju,ijq,indu(ip1jmp1),niju
+      INTEGER n0,iadvplus(ip1jmp1,llm),nl(llm)
+c
+      REAL new_m,zu_m,zdum(ip1jmp1,llm)
+      REAL dxq(ip1jmp1,llm),dxqu(ip1jmp1)
+      REAL zz(ip1jmp1)
+      REAL adxqu(ip1jmp1),dxqmax(ip1jmp1,llm)
+      REAL u_mq(ip1jmp1,llm)
+
+      Logical first,testcpu
+      SAVE first,testcpu
+
+      REAL      SSUM
+      EXTERNAL  SSUM
+      REAL temps1,temps2,temps3,temps4,temps5
+      SAVE temps1,temps2,temps3,temps4,temps5
+
+
+      DATA first,testcpu/.true.,.false./
+
+      IF(first) THEN
+         temps1=0.
+         temps2=0.
+         temps3=0.
+         temps4=0.
+         temps5=0.
+         first=.false.
+      ENDIF
+
+c   calcul de la pente a droite et a gauche de la maille
+
+
+      IF (pente_max.gt.-1.e-5) THEN
+c     IF (pente_max.gt.10) THEN
+
+c   calcul des pentes avec limitation, Van Leer scheme I:
+c   -----------------------------------------------------
+
+c   calcul de la pente aux points u
+         DO l = 1, llm
+            DO ij=iip2,ip1jm-1
+               dxqu(ij)=q(ij+1,l)-q(ij,l)
+c              IF(u_m(ij,l).lt.0.) stop'limx n admet pas les U<0'
+c              sigu(ij)=u_m(ij,l)/masse(ij,l)
+            ENDDO
+            DO ij=iip1+iip1,ip1jm,iip1
+               dxqu(ij)=dxqu(ij-iim)
+c              sigu(ij)=sigu(ij-iim)
+            ENDDO
+
+            DO ij=iip2,ip1jm
+               adxqu(ij)=abs(dxqu(ij))
+            ENDDO
+
+c   calcul de la pente maximum dans la maille en valeur absolue
+
+            DO ij=iip2+1,ip1jm
+               dxqmax(ij,l)=pente_max*
+     ,      min(adxqu(ij-1),adxqu(ij))
+c limitation subtile
+c    ,      min(adxqu(ij-1)/sigu(ij-1),adxqu(ij)/(1.-sigu(ij)))
+          
+
+            ENDDO
+
+            DO ij=iip1+iip1,ip1jm,iip1
+               dxqmax(ij-iim,l)=dxqmax(ij,l)
+            ENDDO
+
+            DO ij=iip2+1,ip1jm
+#ifdef CRAY
+               dxq(ij,l)=
+     ,         cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
+#else
+               IF(dxqu(ij-1)*dxqu(ij).gt.0) THEN
+                  dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
+               ELSE
+c   extremum local
+                  dxq(ij,l)=0.
+               ENDIF
+#endif
+               dxq(ij,l)=0.5*dxq(ij,l)
+               dxq(ij,l)=
+     ,         sign(min(abs(dxq(ij,l)),dxqmax(ij,l)),dxq(ij,l))
+            ENDDO
+
+         ENDDO ! l=1,llm
+
+      ELSE ! (pente_max.lt.-1.e-5)
+
+c   Pentes produits:
+c   ----------------
+
+         DO l = 1, llm
+            DO ij=iip2,ip1jm-1
+               dxqu(ij)=q(ij+1,l)-q(ij,l)
+            ENDDO
+            DO ij=iip1+iip1,ip1jm,iip1
+               dxqu(ij)=dxqu(ij-iim)
+            ENDDO
+
+            DO ij=iip2+1,ip1jm
+               zz(ij)=dxqu(ij-1)*dxqu(ij)
+               zz(ij)=zz(ij)+zz(ij)
+               IF(zz(ij).gt.0) THEN
+                  dxq(ij,l)=zz(ij)/(dxqu(ij-1)+dxqu(ij))
+               ELSE
+c   extremum local
+                  dxq(ij,l)=0.
+               ENDIF
+            ENDDO
+
+         ENDDO
+
+      ENDIF ! (pente_max.lt.-1.e-5)
+
+c   bouclage de la pente en iip1:
+c   -----------------------------
+
+      DO l=1,llm
+         DO ij=iip1+iip1,ip1jm,iip1
+            dxq(ij-iim,l)=dxq(ij,l)
+         ENDDO
+
+         DO ij=1,ip1jmp1
+            iadvplus(ij,l)=0
+         ENDDO
+
+      ENDDO
+
+
+c   calcul des flux a gauche et a droite
+
+#ifdef CRAY
+
+      DO l=1,llm
+       DO ij=iip2,ip1jm-1
+          zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l),
+     ,                     1.+u_m(ij,l)/masse(ij+1,l),
+     ,                     u_m(ij,l))
+          zdum(ij,l)=0.5*zdum(ij,l)
+          u_mq(ij,l)=cvmgp(
+     ,                q(ij,l)+zdum(ij,l)*dxq(ij,l),
+     ,                q(ij+1,l)-zdum(ij,l)*dxq(ij+1,l),
+     ,                u_m(ij,l))
+          u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
+       ENDDO
+      ENDDO
+#else
+c   on cumule le flux correspondant a toutes les mailles dont la masse
+c   au travers de la paroi pENDant le pas de temps.
+      DO l=1,llm
+       DO ij=iip2,ip1jm-1
+          IF (u_m(ij,l).gt.0.) THEN
+             zdum(ij,l)=1.-u_m(ij,l)/masse(ij,l)
+             u_mq(ij,l)=u_m(ij,l)*(q(ij,l)+0.5*zdum(ij,l)*dxq(ij,l))
+          ELSE
+             zdum(ij,l)=1.+u_m(ij,l)/masse(ij+1,l)
+             u_mq(ij,l)=u_m(ij,l)*(q(ij+1,l)-0.5*zdum(ij,l)*dxq(ij+1,l))
+          ENDIF
+       ENDDO
+      ENDDO
+#endif
+
+
+c   detection des points ou on advecte plus que la masse de la
+c   maille
+      DO l=1,llm
+         DO ij=iip2,ip1jm-1
+            IF(zdum(ij,l).lt.0) THEN
+               iadvplus(ij,l)=1
+               u_mq(ij,l)=0.
+            ENDIF
+         ENDDO
+      ENDDO
+      DO l=1,llm
+       DO ij=iip1+iip1,ip1jm,iip1
+          iadvplus(ij,l)=iadvplus(ij-iim,l)
+       ENDDO
+      ENDDO
+
+
+
+c   traitement special pour le cas ou on advecte en longitude plus que le
+c   contenu de la maille.
+c   cette partie est mal vectorisee.
+
+c  calcul du nombre de maille sur lequel on advecte plus que la maille.
+
+      n0=0
+      DO l=1,llm
+         nl(l)=0
+         DO ij=iip2,ip1jm
+            nl(l)=nl(l)+iadvplus(ij,l)
+         ENDDO
+         n0=n0+nl(l)
+      ENDDO
+
+      IF(n0.gt.1) THEN
+ccc      PRINT*,'Nombre de points pour lesquels on advect plus que le'
+ccc     &       ,'contenu de la maille : ',n0
+
+         DO l=1,llm
+            IF(nl(l).gt.0) THEN
+               iju=0
+c   indicage des mailles concernees par le traitement special
+               DO ij=iip2,ip1jm
+                  IF(iadvplus(ij,l).eq.1.and.mod(ij,iip1).ne.0) THEN
+                     iju=iju+1
+                     indu(iju)=ij
+                  ENDIF
+               ENDDO
+               niju=iju
+c              PRINT*,'niju,nl',niju,nl(l)
+
+c  traitement des mailles
+               DO iju=1,niju
+                  ij=indu(iju)
+                  j=(ij-1)/iip1+1
+                  zu_m=u_m(ij,l)
+                  u_mq(ij,l)=0.
+                  IF(zu_m.gt.0.) THEN
+                     ijq=ij
+                     i=ijq-(j-1)*iip1
+c   accumulation pour les mailles completements advectees
+                     do while(zu_m.gt.masse(ijq,l))
+                        u_mq(ij,l)=u_mq(ij,l)+q(ijq,l)*masse(ijq,l)
+                        zu_m=zu_m-masse(ijq,l)
+                        i=mod(i-2+iim,iim)+1
+                        ijq=(j-1)*iip1+i
+                     ENDDO
+c   ajout de la maille non completement advectee
+                     u_mq(ij,l)=u_mq(ij,l)+zu_m*
+     &               (q(ijq,l)+0.5*(1.-zu_m/masse(ijq,l))*dxq(ijq,l))
+                  ELSE
+                     ijq=ij+1
+                     i=ijq-(j-1)*iip1
+c   accumulation pour les mailles completements advectees
+                     do while(-zu_m.gt.masse(ijq,l))
+                        u_mq(ij,l)=u_mq(ij,l)-q(ijq,l)*masse(ijq,l)
+                        zu_m=zu_m+masse(ijq,l)
+                        i=mod(i,iim)+1
+                        ijq=(j-1)*iip1+i
+                     ENDDO
+c   ajout de la maille non completement advectee
+                     u_mq(ij,l)=u_mq(ij,l)+zu_m*(q(ijq,l)-
+     &               0.5*(1.+zu_m/masse(ijq,l))*dxq(ijq,l))
+                  ENDIF
+               ENDDO
+            ENDIF
+         ENDDO
+      ENDIF  ! n0.gt.0 
+
+
+
+c   bouclage en latitude
+
+      DO l=1,llm
+        DO ij=iip1+iip1,ip1jm,iip1
+           u_mq(ij,l)=u_mq(ij-iim,l)
+        ENDDO
+      ENDDO
+
+
+c   calcul des tENDances
+
+      DO l=1,llm
+         DO ij=iip2+1,ip1jm
+            new_m=masse(ij,l)+u_m(ij-1,l)-u_m(ij,l)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+
+     &      u_mq(ij-1,l)-u_mq(ij,l))
+     &      /new_m
+            masse(ij,l)=new_m
+         ENDDO
+c   ModIF Fred 22 03 96 correction d'un bug (les scopy ci-dessous)
+         DO ij=iip1+iip1,ip1jm,iip1
+            q(ij-iim,l)=q(ij,l)
+            masse(ij-iim,l)=masse(ij,l)
+         ENDDO
+      ENDDO
+
+c     CALL SCOPY((jjm-1)*llm,q(iip1+iip1,1),iip1,q(iip2,1),iip1)
+c     CALL SCOPY((jjm-1)*llm,masse(iip1+iip1,1),iip1,masse(iip2,1),iip1)
+
+
+      RETURN
+      END
+      SUBROUTINE vly(q,pente_max,masse,masse_adv_v)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " .
+c    ********************************************************************
+c     q,masse_adv_v,w sont des arguments d'entree  pour le s-pg ....
+c     dq 	       sont des arguments de sortie pour le s-pg ....
+c
+c     SPECIAL MARS :  on ajoute un test ("max") pour eviter les division
+c     par des "dyq" trop faible (special compilateur SUN) 27/11/2003 F. Forget
+
+      USE comconst_mod, ONLY: pi
+
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c
+c   Arguments:
+c   ----------
+      REAL masse(ip1jmp1,llm),pente_max
+      REAL masse_adv_v( ip1jm,llm)
+      REAL q(ip1jmp1,llm)
+c
+c      Local 
+c   ---------
+c
+      INTEGER i,ij,l
+c
+      REAL airej2,airejjm,airescb(iim),airesch(iim)
+      REAL dyq(ip1jmp1,llm),dyqv(ip1jm)
+      REAL adyqv(ip1jm),dyqmax(ip1jmp1)
+      REAL qbyv(ip1jm,llm)
+
+      REAL qpns,qpsn,dyn1,dys1,dyn2,dys2,newmasse,fn,fs
+c     REAL newq,oldmasse
+      Logical first,testcpu
+      REAL temps0,temps1,temps2,temps3,temps4,temps5
+      SAVE temps0,temps1,temps2,temps3,temps4,temps5
+      SAVE first,testcpu
+
+      REAL convpn,convps,convmpn,convmps
+      REAL sinlon(iip1),sinlondlon(iip1)
+      REAL coslon(iip1),coslondlon(iip1)
+      SAVE sinlon,coslon,sinlondlon,coslondlon
+      SAVE airej2,airejjm
+c
+c
+      REAL      SSUM
+      EXTERNAL  SSUM
+
+      DATA first,testcpu/.true.,.false./
+      DATA temps0,temps1,temps2,temps3,temps4,temps5/0.,0.,0.,0.,0.,0./
+
+      IF(first) THEN
+         PRINT*,'Shema  Amont nouveau  appele dans  Vanleer   '
+         first=.false.
+         do i=2,iip1
+            coslon(i)=cos(rlonv(i))
+            sinlon(i)=sin(rlonv(i))
+            coslondlon(i)=coslon(i)*(rlonu(i)-rlonu(i-1))/pi
+            sinlondlon(i)=sinlon(i)*(rlonu(i)-rlonu(i-1))/pi
+         ENDDO
+         coslon(1)=coslon(iip1)
+         coslondlon(1)=coslondlon(iip1)
+         sinlon(1)=sinlon(iip1)
+         sinlondlon(1)=sinlondlon(iip1)
+         airej2 = SSUM( iim, aire(iip2), 1 )
+         airejjm= SSUM( iim, aire(ip1jm -iim), 1 ) 
+      ENDIF
+
+c
+
+
+      DO l = 1, llm
+c
+c   --------------------------------
+c      CALCUL EN LATITUDE
+c   --------------------------------
+
+c   On commence par calculer la valeur du traceur moyenne sur le premier cercle
+c   de latitude autour du pole (qpns pour le pole nord et qpsn pour
+c    le pole nord) qui sera utilisee pour evaluer les pentes au pole.
+
+      DO i = 1, iim
+      airescb(i) = aire(i+ iip1) * q(i+ iip1,l)
+      airesch(i) = aire(i+ ip1jm- iip1) * q(i+ ip1jm- iip1,l)
+      ENDDO
+      qpns   = SSUM( iim,  airescb ,1 ) / airej2
+      qpsn   = SSUM( iim,  airesch ,1 ) / airejjm
+
+c   calcul des pentes aux points v
+
+      DO ij=1,ip1jm
+         dyqv(ij)=q(ij,l)-q(ij+iip1,l)
+         adyqv(ij)=abs(dyqv(ij))
+      ENDDO
+
+c   calcul des pentes aux points scalaires
+
+      DO ij=iip2,ip1jm
+         dyq(ij,l)=.5*(dyqv(ij-iip1)+dyqv(ij))
+         dyqmax(ij)=min(adyqv(ij-iip1),adyqv(ij))
+         dyqmax(ij)=pente_max*dyqmax(ij)
+      ENDDO
+
+c   calcul des pentes aux poles
+
+      DO ij=1,iip1
+         dyq(ij,l)=qpns-q(ij+iip1,l)
+         dyq(ip1jm+ij,l)=q(ip1jm+ij-iip1,l)-qpsn
+      ENDDO
+
+c   filtrage de la derivee
+      dyn1=0.
+      dys1=0.
+      dyn2=0.
+      dys2=0.
+      DO ij=1,iim
+         dyn1=dyn1+sinlondlon(ij)*dyq(ij,l)
+         dys1=dys1+sinlondlon(ij)*dyq(ip1jm+ij,l)
+         dyn2=dyn2+coslondlon(ij)*dyq(ij,l)
+         dys2=dys2+coslondlon(ij)*dyq(ip1jm+ij,l)
+      ENDDO
+      DO ij=1,iip1
+         dyq(ij,l)=dyn1*sinlon(ij)+dyn2*coslon(ij)
+         dyq(ip1jm+ij,l)=dys1*sinlon(ij)+dys2*coslon(ij)
+      ENDDO
+
+c   calcul des pentes limites aux poles
+
+      fn=1.
+      fs=1.
+      DO ij=1,iim
+         IF(pente_max*adyqv(ij).lt.abs(dyq(ij,l))) THEN
+            fn=min(pente_max*adyqv(ij)/ max(abs(dyq(ij,l)),1.E-30),fn)
+         ENDIF
+      IF(pente_max*adyqv(ij+ip1jm-iip1).lt.abs(dyq(ij+ip1jm,l))) THEN
+         fs= min(pente_max*adyqv(ij+ip1jm-iip1) 
+     &              / max(abs(dyq(ij+ip1jm,l)),1.E-30) ,fs)
+         ENDIF
+      ENDDO
+      DO ij=1,iip1
+         dyq(ij,l)=fn*dyq(ij,l)
+         dyq(ip1jm+ij,l)=fs*dyq(ip1jm+ij,l)
+      ENDDO
+
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C  En memoire de dIFferents tests sur la 
+C  limitation des pentes aux poles.
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C     PRINT*,dyq(1)
+C     PRINT*,dyqv(iip1+1)
+C     apn=abs(dyq(1)/dyqv(iip1+1))
+C     PRINT*,dyq(ip1jm+1)
+C     PRINT*,dyqv(ip1jm-iip1+1)
+C     aps=abs(dyq(ip1jm+1)/dyqv(ip1jm-iip1+1))
+C     DO ij=2,iim
+C        apn=amax1(abs(dyq(ij)/dyqv(ij)),apn)
+C        aps=amax1(abs(dyq(ip1jm+ij)/dyqv(ip1jm-iip1+ij)),aps)
+C     ENDDO
+C     apn=min(pente_max/apn,1.)
+C     aps=min(pente_max/aps,1.)
+C
+C
+C   cas ou on a un extremum au pole
+C
+C     IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
+C    &   apn=0.
+C     IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
+C    &   dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
+C    &   aps=0.
+C
+C   limitation des pentes aux poles
+C     DO ij=1,iip1
+C        dyq(ij)=apn*dyq(ij)
+C        dyq(ip1jm+ij)=aps*dyq(ip1jm+ij)
+C     ENDDO
+C
+C   test
+C      DO ij=1,iip1
+C         dyq(iip1+ij)=0.
+C         dyq(ip1jm+ij-iip1)=0.
+C      ENDDO
+C      DO ij=1,ip1jmp1
+C         dyq(ij)=dyq(ij)*cos(rlatu((ij-1)/iip1+1))
+C      ENDDO
+C
+C changement 10 07 96
+C     IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
+C    &   THEN
+C        DO ij=1,iip1
+C           dyqmax(ij)=0.
+C        ENDDO
+C     ELSE
+C        DO ij=1,iip1
+C           dyqmax(ij)=pente_max*abs(dyqv(ij))
+C        ENDDO
+C     ENDIF
+C
+C     IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
+C    & dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
+C    &THEN
+C        DO ij=ip1jm+1,ip1jmp1
+C           dyqmax(ij)=0.
+C        ENDDO
+C     ELSE
+C        DO ij=ip1jm+1,ip1jmp1
+C           dyqmax(ij)=pente_max*abs(dyqv(ij-iip1))
+C        ENDDO
+C     ENDIF
+C   fin changement 10 07 96
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+
+c   calcul des pentes limitees
+
+      DO ij=iip2,ip1jm
+         IF(dyqv(ij)*dyqv(ij-iip1).gt.0.) THEN
+            dyq(ij,l)=sign(min(abs(dyq(ij,l)),dyqmax(ij)),dyq(ij,l))
+         ELSE
+            dyq(ij,l)=0.
+         ENDIF
+      ENDDO
+
+      ENDDO
+
+      DO l=1,llm
+       DO ij=1,ip1jm
+          IF(masse_adv_v(ij,l).gt.0) THEN
+              qbyv(ij,l)=q(ij+iip1,l)+dyq(ij+iip1,l)*
+     ,                   0.5*(1.-masse_adv_v(ij,l)/masse(ij+iip1,l))
+          ELSE
+              qbyv(ij,l)=q(ij,l)-dyq(ij,l)*
+     ,                   0.5*(1.+masse_adv_v(ij,l)/masse(ij,l))
+          ENDIF
+          qbyv(ij,l)=masse_adv_v(ij,l)*qbyv(ij,l)
+       ENDDO
+      ENDDO
+
+
+      DO l=1,llm
+         DO ij=iip2,ip1jm
+            newmasse=masse(ij,l)
+     &      +masse_adv_v(ij,l)-masse_adv_v(ij-iip1,l)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+qbyv(ij,l)-qbyv(ij-iip1,l))
+     &         /newmasse
+            masse(ij,l)=newmasse
+         ENDDO
+c.-. ancienne version
+         convpn=SSUM(iim,qbyv(1,l),1)/apoln
+         convmpn=ssum(iim,masse_adv_v(1,l),1)/apoln
+         DO ij = 1,iip1
+            newmasse=masse(ij,l)+convmpn*aire(ij)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+convpn*aire(ij))/
+     &               newmasse
+            masse(ij,l)=newmasse
+         ENDDO
+         convps=-SSUM(iim,qbyv(ip1jm-iim,l),1)/apols
+         convmps=-ssum(iim,masse_adv_v(ip1jm-iim,l),1)/apols
+         DO ij = ip1jm+1,ip1jmp1
+            newmasse=masse(ij,l)+convmps*aire(ij)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+convps*aire(ij))/
+     &               newmasse
+            masse(ij,l)=newmasse
+         ENDDO
+c.-. fin ancienne version
+
+c._. nouvelle version
+c        convpn=SSUM(iim,qbyv(1,l),1)
+c        convmpn=ssum(iim,masse_adv_v(1,l),1)
+c        oldmasse=ssum(iim,masse(1,l),1)
+c        newmasse=oldmasse+convmpn
+c        newq=(q(1,l)*oldmasse+convpn)/newmasse
+c        newmasse=newmasse/apoln
+c        DO ij = 1,iip1
+c           q(ij,l)=newq
+c           masse(ij,l)=newmasse*aire(ij)
+c        ENDDO
+c        convps=-SSUM(iim,qbyv(ip1jm-iim,l),1)
+c        convmps=-ssum(iim,masse_adv_v(ip1jm-iim,l),1)
+c        oldmasse=ssum(iim,masse(ip1jm-iim,l),1)
+c        newmasse=oldmasse+convmps
+c        newq=(q(ip1jmp1,l)*oldmasse+convps)/newmasse
+c        newmasse=newmasse/apols
+c        DO ij = ip1jm+1,ip1jmp1
+c           q(ij,l)=newq
+c           masse(ij,l)=newmasse*aire(ij)
+c        ENDDO
+c._. fin nouvelle version
+      ENDDO
+
+      RETURN
+      END
+      SUBROUTINE vlz(q,pente_max,masse,w)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " .
+c    ********************************************************************
+c    q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c     dq 	       sont des arguments de sortie pour le s-pg ....
+c
+c
+c   --------------------------------------------------------------------
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+c
+c
+c   Arguments:
+c   ----------
+      REAL masse(ip1jmp1,llm),pente_max
+      REAL q(ip1jmp1,llm)
+      REAL w(ip1jmp1,llm+1)
+c
+c      Local 
+c   ---------
+c
+      INTEGER i,ij,l,j,ii
+c
+      REAL wq(ip1jmp1,llm+1),newmasse
+
+      REAL dzq(ip1jmp1,llm),dzqw(ip1jmp1,llm),adzqw(ip1jmp1,llm),dzqmax
+      REAL sigw
+
+      LOGICAL testcpu
+      SAVE testcpu
+
+      REAL temps0,temps1,temps2,temps3,temps4,temps5,second
+      SAVE temps0,temps1,temps2,temps3,temps4,temps5
+      REAL      SSUM
+      EXTERNAL  SSUM, convflu
+      EXTERNAL filtreg
+
+      DATA testcpu/.false./
+      DATA temps0,temps1,temps2,temps3,temps4,temps5/0.,0.,0.,0.,0.,0./
+
+c    On oriente tout dans le sens de la pression c'est a dire dans le
+c    sens de W
+
+#ifdef BIDON
+      IF(testcpu) THEN
+         temps0=second(0.)
+      ENDIF
+#endif
+      DO l=2,llm
+         DO ij=1,ip1jmp1
+            dzqw(ij,l)=q(ij,l-1)-q(ij,l)
+            adzqw(ij,l)=abs(dzqw(ij,l))
+         ENDDO
+      ENDDO
+
+      DO l=2,llm-1
+         DO ij=1,ip1jmp1
+#ifdef CRAY
+            dzq(ij,l)=0.5*
+     ,      cvmgp(dzqw(ij,l)+dzqw(ij,l+1),0.,dzqw(ij,l)*dzqw(ij,l+1))
+#else
+            IF(dzqw(ij,l)*dzqw(ij,l+1).gt.0.) THEN
+                dzq(ij,l)=0.5*(dzqw(ij,l)+dzqw(ij,l+1))
+            ELSE
+                dzq(ij,l)=0.
+            ENDIF
+#endif
+            dzqmax=pente_max*min(adzqw(ij,l),adzqw(ij,l+1))
+            dzq(ij,l)=sign(min(abs(dzq(ij,l)),dzqmax),dzq(ij,l))
+         ENDDO
+      ENDDO
+
+      DO ij=1,ip1jmp1
+         dzq(ij,1)=0.
+         dzq(ij,llm)=0.
+      ENDDO
+
+#ifdef BIDON
+      IF(testcpu) THEN
+         temps1=temps1+second(0.)-temps0
+      ENDIF
+#endif
+c ---------------------------------------------------------------
+c   .... calcul des termes d'advection verticale  .......
+c ---------------------------------------------------------------
+
+c calcul de  - d( q   * w )/ d(sigma)    qu'on ajoute a  dq pour calculer dq
+
+       DO l = 1,llm-1
+         do  ij = 1,ip1jmp1
+          IF(w(ij,l+1).gt.0.) THEN
+             sigw=w(ij,l+1)/masse(ij,l+1)
+             wq(ij,l+1)=w(ij,l+1)*(q(ij,l+1)+0.5*(1.-sigw)*dzq(ij,l+1))
+          ELSE
+             sigw=w(ij,l+1)/masse(ij,l)
+             wq(ij,l+1)=w(ij,l+1)*(q(ij,l)-0.5*(1.+sigw)*dzq(ij,l))
+          ENDIF
+         ENDDO
+       ENDDO
+
+       DO ij=1,ip1jmp1
+          wq(ij,llm+1)=0.
+          wq(ij,1)=0.
+       ENDDO
+
+      DO l=1,llm
+         DO ij=1,ip1jmp1
+            newmasse=masse(ij,l)+w(ij,l+1)-w(ij,l)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+wq(ij,l+1)-wq(ij,l))
+     &         /newmasse
+            masse(ij,l)=newmasse
+         ENDDO
+      ENDDO
+
+
+      RETURN
+      END
+      SUBROUTINE minmaxq(zq,qmin,qmax,comment)
+
+#include "dimensions.h"
+#include "paramet.h"
+
+      CHARACTER*(*) comment
+      real qmin,qmax
+      real zq(ip1jmp1,llm)
+
+      INTEGER jadrs(ip1jmp1), jbad, k, i
+
+      DO k = 1, llm
+         jbad = 0
+         DO i = 1, ip1jmp1
+         IF (zq(i,k).GT.qmax .OR. zq(i,k).LT.qmin) THEN
+            jbad = jbad + 1
+            jadrs(jbad) = i
+         ENDIF
+         ENDDO
+         IF (jbad.GT.0) THEN
+         PRINT*, comment
+         DO i = 1, jbad
+cc            PRINT*, "i,k,zq=", jadrs(i),k,zq(jadrs(i),k)
+         ENDDO
+         ENDIF
+      ENDDO
+
+      return
+      end
+
+
+
Index: /trunk/LMDZ.TITAN/libf/dyn3d/vlspltqs.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dyn3d/vlspltqs.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dyn3d/vlspltqs.F	(revision 1644)
@@ -0,0 +1,770 @@
+       SUBROUTINE vlspltqs ( q,pente_max,masse,w,pbaru,pbarv,pdt,
+     ,                                  p,pk,teta                 )
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget, F.Codron 
+c
+c    ********************************************************************
+c          Shema  d'advection " pseudo amont " .
+c      + test sur humidite specifique: Q advecte< Qsat aval
+c                   (F. Codron, 10/99)
+c    ********************************************************************
+c     q,pbaru,pbarv,w sont des arguments d'entree  pour le s-pg ....
+c
+c     pente_max facteur de limitation des pentes: 2 en general
+c                                                0 pour un schema amont
+c     pbaru,pbarv,w flux de masse en u ,v ,w
+c     pdt pas de temps
+c
+c     teta temperature potentielle, p pression aux interfaces,
+c     pk exner au milieu des couches necessaire pour calculer Qsat
+c   --------------------------------------------------------------------
+      USE comconst_mod, ONLY: cpp
+
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+
+c
+c   Arguments:
+c   ----------
+      REAL masse(ip1jmp1,llm),pente_max
+      REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm)
+      REAL q(ip1jmp1,llm)
+      REAL w(ip1jmp1,llm),pdt
+      REAL p(ip1jmp1,llmp1),teta(ip1jmp1,llm),pk(ip1jmp1,llm)
+c
+c      Local 
+c   ---------
+c
+      INTEGER i,ij,l,j,ii
+c
+      REAL qsat(ip1jmp1,llm)
+      REAL zm(ip1jmp1,llm)
+      REAL mu(ip1jmp1,llm)
+      REAL mv(ip1jm,llm)
+      REAL mw(ip1jmp1,llm+1)
+      REAL zq(ip1jmp1,llm)
+      REAL temps1,temps2,temps3
+      REAL zzpbar, zzw
+      LOGICAL testcpu
+      SAVE testcpu
+      SAVE temps1,temps2,temps3
+
+      REAL qmin,qmax
+      DATA qmin,qmax/0.,1.e33/
+      DATA testcpu/.false./
+      DATA temps1,temps2,temps3/0.,0.,0./
+
+c--pour rapport de melange saturant--
+
+      REAL rtt,retv,r2es,r3les,r3ies,r4les,r4ies,play
+      REAL ptarg,pdelarg,foeew,zdelta
+      REAL tempe(ip1jmp1)
+
+c    fonction psat(T)
+
+       FOEEW ( PTARG,PDELARG ) = EXP (
+     *          (R3LES*(1.-PDELARG)+R3IES*PDELARG) * (PTARG-RTT)
+     * / (PTARG-(R4LES*(1.-PDELARG)+R4IES*PDELARG)) )
+
+        r2es  = 380.11733 
+        r3les = 17.269
+        r3ies = 21.875
+        r4les = 35.86
+        r4ies = 7.66
+        retv = 0.6077667
+        rtt  = 273.16
+
+c-- Calcul de Qsat en chaque point
+c-- approximation: au milieu des couches play(l)=(p(l)+p(l+1))/2
+c   pour eviter une exponentielle.
+        DO l = 1, llm
+         DO ij = 1, ip1jmp1
+          tempe(ij) = teta(ij,l) * pk(ij,l) /cpp
+         ENDDO
+         DO ij = 1, ip1jmp1
+          zdelta = MAX( 0., SIGN(1., rtt - tempe(ij)) )
+          play   = 0.5*(p(ij,l)+p(ij,l+1))
+          qsat(ij,l) = MIN(0.5, r2es* FOEEW(tempe(ij),zdelta) / play )
+          qsat(ij,l) = qsat(ij,l) / ( 1. - retv * qsat(ij,l) )
+         ENDDO
+        ENDDO
+
+
+c      PRINT*,'Debut vlsplt version debug sans vlyqs'
+
+        zzpbar = 0.5 * pdt
+        zzw    = pdt
+      DO l=1,llm
+        DO ij = iip2,ip1jm
+            mu(ij,l)=pbaru(ij,l) * zzpbar
+         ENDDO
+         DO ij=1,ip1jm
+            mv(ij,l)=pbarv(ij,l) * zzpbar
+         ENDDO
+         DO ij=1,ip1jmp1
+            mw(ij,l)=w(ij,l) * zzw
+         ENDDO
+      ENDDO
+
+      DO ij=1,ip1jmp1
+         mw(ij,llm+1)=0.
+      ENDDO
+
+      CALL SCOPY(ijp1llm,q,1,zq,1)
+      CALL SCOPY(ijp1llm,masse,1,zm,1)
+
+c      call minmaxq(zq,qmin,qmax,'avant vlxqs     ')
+      call vlxqs(zq,pente_max,zm,mu,qsat)
+
+
+c     call minmaxq(zq,qmin,qmax,'avant vlyqs     ')
+
+      call vlyqs(zq,pente_max,zm,mv,qsat)
+
+
+c      call minmaxq(zq,qmin,qmax,'avant vlz     ')
+
+      call vlz(zq,pente_max,zm,mw)
+
+
+c     call minmaxq(zq,qmin,qmax,'avant vlyqs     ')
+c     call minmaxq(zm,qmin,qmax,'M avant vlyqs     ')
+
+      call vlyqs(zq,pente_max,zm,mv,qsat)
+
+
+c     call minmaxq(zq,qmin,qmax,'avant vlxqs     ')
+c     call minmaxq(zm,qmin,qmax,'M avant vlxqs     ')
+
+      call vlxqs(zq,pente_max,zm,mu,qsat)
+
+c     call minmaxq(zq,qmin,qmax,'apres vlxqs     ')
+c     call minmaxq(zm,qmin,qmax,'M apres vlxqs     ')
+
+
+      DO l=1,llm
+         DO ij=1,ip1jmp1
+           q(ij,l)=zq(ij,l)
+         ENDDO
+         DO ij=1,ip1jm+1,iip1
+            q(ij+iim,l)=q(ij,l)
+         ENDDO
+      ENDDO
+
+      RETURN
+      END
+      SUBROUTINE vlxqs(q,pente_max,masse,u_m,qsat)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " .
+c    ********************************************************************
+c
+c   --------------------------------------------------------------------
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+c
+c
+c   Arguments:
+c   ----------
+      REAL masse(ip1jmp1,llm),pente_max
+      REAL u_m( ip1jmp1,llm )
+      REAL q(ip1jmp1,llm)
+      REAL qsat(ip1jmp1,llm)
+c
+c      Local 
+c   ---------
+c
+      INTEGER ij,l,j,i,iju,ijq,indu(ip1jmp1),niju
+      INTEGER n0,iadvplus(ip1jmp1,llm),nl(llm)
+c
+      REAL new_m,zu_m,zdum(ip1jmp1,llm)
+      REAL dxq(ip1jmp1,llm),dxqu(ip1jmp1)
+      REAL zz(ip1jmp1)
+      REAL adxqu(ip1jmp1),dxqmax(ip1jmp1,llm)
+      REAL u_mq(ip1jmp1,llm)
+
+      Logical first,testcpu
+      SAVE first,testcpu
+
+      REAL      SSUM
+      EXTERNAL  SSUM
+      REAL temps0,temps1,temps2,temps3,temps4,temps5
+      SAVE temps0,temps1,temps2,temps3,temps4,temps5
+
+
+      DATA first,testcpu/.true.,.false./
+
+      IF(first) THEN
+         temps1=0.
+         temps2=0.
+         temps3=0.
+         temps4=0.
+         temps5=0.
+         first=.false.
+      ENDIF
+
+c   calcul de la pente a droite et a gauche de la maille
+
+
+      IF (pente_max.gt.-1.e-5) THEN
+c     IF (pente_max.gt.10) THEN
+
+c   calcul des pentes avec limitation, Van Leer scheme I:
+c   -----------------------------------------------------
+
+c   calcul de la pente aux points u
+         DO l = 1, llm
+            DO ij=iip2,ip1jm-1
+               dxqu(ij)=q(ij+1,l)-q(ij,l)
+c              IF(u_m(ij,l).lt.0.) stop'limx n admet pas les U<0'
+c              sigu(ij)=u_m(ij,l)/masse(ij,l)
+            ENDDO
+            DO ij=iip1+iip1,ip1jm,iip1
+               dxqu(ij)=dxqu(ij-iim)
+c              sigu(ij)=sigu(ij-iim)
+            ENDDO
+
+            DO ij=iip2,ip1jm
+               adxqu(ij)=abs(dxqu(ij))
+            ENDDO
+
+c   calcul de la pente maximum dans la maille en valeur absolue
+
+            DO ij=iip2+1,ip1jm
+               dxqmax(ij,l)=pente_max*
+     ,      min(adxqu(ij-1),adxqu(ij))
+c limitation subtile
+c    ,      min(adxqu(ij-1)/sigu(ij-1),adxqu(ij)/(1.-sigu(ij)))
+          
+
+            ENDDO
+
+            DO ij=iip1+iip1,ip1jm,iip1
+               dxqmax(ij-iim,l)=dxqmax(ij,l)
+            ENDDO
+
+            DO ij=iip2+1,ip1jm
+#ifdef CRAY
+               dxq(ij,l)=
+     ,         cvmgp(dxqu(ij-1)+dxqu(ij),0.,dxqu(ij-1)*dxqu(ij))
+#else
+               IF(dxqu(ij-1)*dxqu(ij).gt.0) THEN
+                  dxq(ij,l)=dxqu(ij-1)+dxqu(ij)
+               ELSE
+c   extremum local
+                  dxq(ij,l)=0.
+               ENDIF
+#endif
+               dxq(ij,l)=0.5*dxq(ij,l)
+               dxq(ij,l)=
+     ,         sign(min(abs(dxq(ij,l)),dxqmax(ij,l)),dxq(ij,l))
+            ENDDO
+
+         ENDDO ! l=1,llm
+
+      ELSE ! (pente_max.lt.-1.e-5)
+
+c   Pentes produits:
+c   ----------------
+
+         DO l = 1, llm
+            DO ij=iip2,ip1jm-1
+               dxqu(ij)=q(ij+1,l)-q(ij,l)
+            ENDDO
+            DO ij=iip1+iip1,ip1jm,iip1
+               dxqu(ij)=dxqu(ij-iim)
+            ENDDO
+
+            DO ij=iip2+1,ip1jm
+               zz(ij)=dxqu(ij-1)*dxqu(ij)
+               zz(ij)=zz(ij)+zz(ij)
+               IF(zz(ij).gt.0) THEN
+                  dxq(ij,l)=zz(ij)/(dxqu(ij-1)+dxqu(ij))
+               ELSE
+c   extremum local
+                  dxq(ij,l)=0.
+               ENDIF
+            ENDDO
+
+         ENDDO
+
+      ENDIF ! (pente_max.lt.-1.e-5)
+
+c   bouclage de la pente en iip1:
+c   -----------------------------
+
+      DO l=1,llm
+         DO ij=iip1+iip1,ip1jm,iip1
+            dxq(ij-iim,l)=dxq(ij,l)
+         ENDDO
+
+         DO ij=1,ip1jmp1
+            iadvplus(ij,l)=0
+         ENDDO
+
+      ENDDO
+
+
+c   calcul des flux a gauche et a droite
+
+#ifdef CRAY
+c--pas encore modification sur Qsat
+      DO l=1,llm
+       DO ij=iip2,ip1jm-1
+          zdum(ij,l)=cvmgp(1.-u_m(ij,l)/masse(ij,l),
+     ,                     1.+u_m(ij,l)/masse(ij+1,l),
+     ,                     u_m(ij,l))
+          zdum(ij,l)=0.5*zdum(ij,l)
+          u_mq(ij,l)=cvmgp(
+     ,                q(ij,l)+zdum(ij,l)*dxq(ij,l),
+     ,                q(ij+1,l)-zdum(ij,l)*dxq(ij+1,l),
+     ,                u_m(ij,l))
+          u_mq(ij,l)=u_m(ij,l)*u_mq(ij,l)
+       ENDDO
+      ENDDO
+#else
+c   on cumule le flux correspondant a toutes les mailles dont la masse
+c   au travers de la paroi pENDant le pas de temps.
+c   le rapport de melange de l'air advecte est min(q_vanleer, Qsat_downwind)
+      DO l=1,llm
+       DO ij=iip2,ip1jm-1
+          IF (u_m(ij,l).gt.0.) THEN
+             zdum(ij,l)=1.-u_m(ij,l)/masse(ij,l)
+             u_mq(ij,l)=u_m(ij,l)*
+     $         min(q(ij,l)+0.5*zdum(ij,l)*dxq(ij,l),qsat(ij+1,l))
+          ELSE
+             zdum(ij,l)=1.+u_m(ij,l)/masse(ij+1,l)
+             u_mq(ij,l)=u_m(ij,l)*
+     $         min(q(ij+1,l)-0.5*zdum(ij,l)*dxq(ij+1,l),qsat(ij,l))
+          ENDIF
+       ENDDO
+      ENDDO
+#endif
+
+
+c   detection des points ou on advecte plus que la masse de la
+c   maille
+      DO l=1,llm
+         DO ij=iip2,ip1jm-1
+            IF(zdum(ij,l).lt.0) THEN
+               iadvplus(ij,l)=1
+               u_mq(ij,l)=0.
+            ENDIF
+         ENDDO
+      ENDDO
+      DO l=1,llm
+       DO ij=iip1+iip1,ip1jm,iip1
+          iadvplus(ij,l)=iadvplus(ij-iim,l)
+       ENDDO
+      ENDDO
+
+
+
+c   traitement special pour le cas ou on advecte en longitude plus que le
+c   contenu de la maille.
+c   cette partie est mal vectorisee.
+
+c   pas d'influence de la pression saturante (pour l'instant)
+
+c  calcul du nombre de maille sur lequel on advecte plus que la maille.
+
+      n0=0
+      DO l=1,llm
+         nl(l)=0
+         DO ij=iip2,ip1jm
+            nl(l)=nl(l)+iadvplus(ij,l)
+         ENDDO
+         n0=n0+nl(l)
+      ENDDO
+
+      IF(n0.gt.1) THEN
+ccc      PRINT*,'Nombre de points pour lesquels on advect plus que le'
+ccc     &       ,'contenu de la maille : ',n0
+
+         DO l=1,llm
+            IF(nl(l).gt.0) THEN
+               iju=0
+c   indicage des mailles concernees par le traitement special
+               DO ij=iip2,ip1jm
+                  IF(iadvplus(ij,l).eq.1.and.mod(ij,iip1).ne.0) THEN
+                     iju=iju+1
+                     indu(iju)=ij
+                  ENDIF
+               ENDDO
+               niju=iju
+c              PRINT*,'niju,nl',niju,nl(l)
+
+c  traitement des mailles
+               DO iju=1,niju
+                  ij=indu(iju)
+                  j=(ij-1)/iip1+1
+                  zu_m=u_m(ij,l)
+                  u_mq(ij,l)=0.
+                  IF(zu_m.gt.0.) THEN
+                     ijq=ij
+                     i=ijq-(j-1)*iip1
+c   accumulation pour les mailles completements advectees
+                     do while(zu_m.gt.masse(ijq,l))
+                        u_mq(ij,l)=u_mq(ij,l)+q(ijq,l)*masse(ijq,l)
+                        zu_m=zu_m-masse(ijq,l)
+                        i=mod(i-2+iim,iim)+1
+                        ijq=(j-1)*iip1+i
+                     ENDDO
+c   ajout de la maille non completement advectee
+                     u_mq(ij,l)=u_mq(ij,l)+zu_m*
+     &               (q(ijq,l)+0.5*(1.-zu_m/masse(ijq,l))*dxq(ijq,l))
+                  ELSE
+                     ijq=ij+1
+                     i=ijq-(j-1)*iip1
+c   accumulation pour les mailles completements advectees
+                     do while(-zu_m.gt.masse(ijq,l))
+                        u_mq(ij,l)=u_mq(ij,l)-q(ijq,l)*masse(ijq,l)
+                        zu_m=zu_m+masse(ijq,l)
+                        i=mod(i,iim)+1
+                        ijq=(j-1)*iip1+i
+                     ENDDO
+c   ajout de la maille non completement advectee
+                     u_mq(ij,l)=u_mq(ij,l)+zu_m*(q(ijq,l)-
+     &               0.5*(1.+zu_m/masse(ijq,l))*dxq(ijq,l))
+                  ENDIF
+               ENDDO
+            ENDIF
+         ENDDO
+      ENDIF  ! n0.gt.0 
+
+
+
+c   bouclage en latitude
+
+      DO l=1,llm
+        DO ij=iip1+iip1,ip1jm,iip1
+           u_mq(ij,l)=u_mq(ij-iim,l)
+        ENDDO
+      ENDDO
+
+
+c   calcul des tendances
+
+      DO l=1,llm
+         DO ij=iip2+1,ip1jm
+            new_m=masse(ij,l)+u_m(ij-1,l)-u_m(ij,l)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+
+     &      u_mq(ij-1,l)-u_mq(ij,l))
+     &      /new_m
+            masse(ij,l)=new_m
+         ENDDO
+c   Modif Fred 22 03 96 correction d'un bug (les scopy ci-dessous)
+         DO ij=iip1+iip1,ip1jm,iip1
+            q(ij-iim,l)=q(ij,l)
+            masse(ij-iim,l)=masse(ij,l)
+         ENDDO
+      ENDDO
+
+c     CALL SCOPY((jjm-1)*llm,q(iip1+iip1,1),iip1,q(iip2,1),iip1)
+c     CALL SCOPY((jjm-1)*llm,masse(iip1+iip1,1),iip1,masse(iip2,1),iip1)
+
+
+      RETURN
+      END
+      SUBROUTINE vlyqs(q,pente_max,masse,masse_adv_v,qsat)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " .
+c    ********************************************************************
+c     q,masse_adv_v,w sont des arguments d'entree  pour le s-pg ....
+c     qsat 	       est   un argument de sortie pour le s-pg ....
+c
+c
+c   --------------------------------------------------------------------
+      USE comconst_mod, ONLY: pi
+
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+c
+c
+c   Arguments:
+c   ----------
+      REAL masse(ip1jmp1,llm),pente_max
+      REAL masse_adv_v( ip1jm,llm)
+      REAL q(ip1jmp1,llm)
+      REAL qsat(ip1jmp1,llm)
+c
+c      Local 
+c   ---------
+c
+      INTEGER i,ij,l
+c
+      REAL airej2,airejjm,airescb(iim),airesch(iim)
+      REAL dyq(ip1jmp1,llm),dyqv(ip1jm)
+      REAL adyqv(ip1jm),dyqmax(ip1jmp1)
+      REAL qbyv(ip1jm,llm)
+
+      REAL qpns,qpsn,dyn1,dys1,dyn2,dys2,newmasse,fn,fs
+c     REAL newq,oldmasse
+      Logical first,testcpu
+      REAL temps0,temps1,temps2,temps3,temps4,temps5
+      SAVE temps0,temps1,temps2,temps3,temps4,temps5
+      SAVE first,testcpu
+
+      REAL convpn,convps,convmpn,convmps
+      REAL sinlon(iip1),sinlondlon(iip1)
+      REAL coslon(iip1),coslondlon(iip1)
+      SAVE sinlon,coslon,sinlondlon,coslondlon
+      SAVE airej2,airejjm
+c
+c
+      REAL      SSUM
+      EXTERNAL  SSUM
+
+      DATA first,testcpu/.true.,.false./
+      DATA temps0,temps1,temps2,temps3,temps4,temps5/0.,0.,0.,0.,0.,0./
+
+      IF(first) THEN
+         PRINT*,'Shema  Amont nouveau  appele dans  Vanleer   '
+         first=.false.
+         do i=2,iip1
+            coslon(i)=cos(rlonv(i))
+            sinlon(i)=sin(rlonv(i))
+            coslondlon(i)=coslon(i)*(rlonu(i)-rlonu(i-1))/pi
+            sinlondlon(i)=sinlon(i)*(rlonu(i)-rlonu(i-1))/pi
+         ENDDO
+         coslon(1)=coslon(iip1)
+         coslondlon(1)=coslondlon(iip1)
+         sinlon(1)=sinlon(iip1)
+         sinlondlon(1)=sinlondlon(iip1)
+         airej2 = SSUM( iim, aire(iip2), 1 )
+         airejjm= SSUM( iim, aire(ip1jm -iim), 1 ) 
+      ENDIF
+
+c
+
+
+      DO l = 1, llm
+c
+c   --------------------------------
+c      CALCUL EN LATITUDE
+c   --------------------------------
+
+c   On commence par calculer la valeur du traceur moyenne sur le premier cercle
+c   de latitude autour du pole (qpns pour le pole nord et qpsn pour
+c    le pole nord) qui sera utilisee pour evaluer les pentes au pole.
+
+      DO i = 1, iim
+      airescb(i) = aire(i+ iip1) * q(i+ iip1,l)
+      airesch(i) = aire(i+ ip1jm- iip1) * q(i+ ip1jm- iip1,l)
+      ENDDO
+      qpns   = SSUM( iim,  airescb ,1 ) / airej2
+      qpsn   = SSUM( iim,  airesch ,1 ) / airejjm
+
+c   calcul des pentes aux points v
+
+      DO ij=1,ip1jm
+         dyqv(ij)=q(ij,l)-q(ij+iip1,l)
+         adyqv(ij)=abs(dyqv(ij))
+      ENDDO
+
+c   calcul des pentes aux points scalaires
+
+      DO ij=iip2,ip1jm
+         dyq(ij,l)=.5*(dyqv(ij-iip1)+dyqv(ij))
+         dyqmax(ij)=min(adyqv(ij-iip1),adyqv(ij))
+         dyqmax(ij)=pente_max*dyqmax(ij)
+      ENDDO
+
+c   calcul des pentes aux poles
+
+      DO ij=1,iip1
+         dyq(ij,l)=qpns-q(ij+iip1,l)
+         dyq(ip1jm+ij,l)=q(ip1jm+ij-iip1,l)-qpsn
+      ENDDO
+
+c   filtrage de la derivee
+      dyn1=0.
+      dys1=0.
+      dyn2=0.
+      dys2=0.
+      DO ij=1,iim
+         dyn1=dyn1+sinlondlon(ij)*dyq(ij,l)
+         dys1=dys1+sinlondlon(ij)*dyq(ip1jm+ij,l)
+         dyn2=dyn2+coslondlon(ij)*dyq(ij,l)
+         dys2=dys2+coslondlon(ij)*dyq(ip1jm+ij,l)
+      ENDDO
+      DO ij=1,iip1
+         dyq(ij,l)=dyn1*sinlon(ij)+dyn2*coslon(ij)
+         dyq(ip1jm+ij,l)=dys1*sinlon(ij)+dys2*coslon(ij)
+      ENDDO
+
+c   calcul des pentes limites aux poles
+
+      fn=1.
+      fs=1.
+      DO ij=1,iim
+         IF(pente_max*adyqv(ij).lt.abs(dyq(ij,l))) THEN
+            fn=min(pente_max*adyqv(ij)/abs(dyq(ij,l)),fn)
+         ENDIF
+      IF(pente_max*adyqv(ij+ip1jm-iip1).lt.abs(dyq(ij+ip1jm,l))) THEN
+         fs=min(pente_max*adyqv(ij+ip1jm-iip1)/abs(dyq(ij+ip1jm,l)),fs)
+         ENDIF
+      ENDDO
+      DO ij=1,iip1
+         dyq(ij,l)=fn*dyq(ij,l)
+         dyq(ip1jm+ij,l)=fs*dyq(ip1jm+ij,l)
+      ENDDO
+
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C  En memoire de dIFferents tests sur la 
+C  limitation des pentes aux poles.
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C     PRINT*,dyq(1)
+C     PRINT*,dyqv(iip1+1)
+C     apn=abs(dyq(1)/dyqv(iip1+1))
+C     PRINT*,dyq(ip1jm+1)
+C     PRINT*,dyqv(ip1jm-iip1+1)
+C     aps=abs(dyq(ip1jm+1)/dyqv(ip1jm-iip1+1))
+C     DO ij=2,iim
+C        apn=amax1(abs(dyq(ij)/dyqv(ij)),apn)
+C        aps=amax1(abs(dyq(ip1jm+ij)/dyqv(ip1jm-iip1+ij)),aps)
+C     ENDDO
+C     apn=min(pente_max/apn,1.)
+C     aps=min(pente_max/aps,1.)
+C
+C
+C   cas ou on a un extremum au pole
+C
+C     IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
+C    &   apn=0.
+C     IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
+C    &   dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
+C    &   aps=0.
+C
+C   limitation des pentes aux poles
+C     DO ij=1,iip1
+C        dyq(ij)=apn*dyq(ij)
+C        dyq(ip1jm+ij)=aps*dyq(ip1jm+ij)
+C     ENDDO
+C
+C   test
+C      DO ij=1,iip1
+C         dyq(iip1+ij)=0.
+C         dyq(ip1jm+ij-iip1)=0.
+C      ENDDO
+C      DO ij=1,ip1jmp1
+C         dyq(ij)=dyq(ij)*cos(rlatu((ij-1)/iip1+1))
+C      ENDDO
+C
+C changement 10 07 96
+C     IF(dyqv(ismin(iim,dyqv,1))*dyqv(ismax(iim,dyqv,1)).le.0.)
+C    &   THEN
+C        DO ij=1,iip1
+C           dyqmax(ij)=0.
+C        ENDDO
+C     ELSE
+C        DO ij=1,iip1
+C           dyqmax(ij)=pente_max*abs(dyqv(ij))
+C        ENDDO
+C     ENDIF
+C
+C     IF(dyqv(ismax(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1)*
+C    & dyqv(ismin(iim,dyqv(ip1jm-iip1+1),1)+ip1jm-iip1+1).le.0.)
+C    &THEN
+C        DO ij=ip1jm+1,ip1jmp1
+C           dyqmax(ij)=0.
+C        ENDDO
+C     ELSE
+C        DO ij=ip1jm+1,ip1jmp1
+C           dyqmax(ij)=pente_max*abs(dyqv(ij-iip1))
+C        ENDDO
+C     ENDIF
+C   fin changement 10 07 96
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+
+c   calcul des pentes limitees
+
+      DO ij=iip2,ip1jm
+         IF(dyqv(ij)*dyqv(ij-iip1).gt.0.) THEN
+            dyq(ij,l)=sign(min(abs(dyq(ij,l)),dyqmax(ij)),dyq(ij,l))
+         ELSE
+            dyq(ij,l)=0.
+         ENDIF
+      ENDDO
+
+      ENDDO
+
+      DO l=1,llm
+       DO ij=1,ip1jm
+         IF( masse_adv_v(ij,l).GT.0. ) THEN
+           qbyv(ij,l)= MIN( qsat(ij+iip1,l), q(ij+iip1,l )  +
+     ,      dyq(ij+iip1,l)*0.5*(1.-masse_adv_v(ij,l)/masse(ij+iip1,l)))
+         ELSE
+              qbyv(ij,l)= MIN( qsat(ij,l), q(ij,l) - dyq(ij,l) *
+     ,                   0.5*(1.+masse_adv_v(ij,l)/masse(ij,l)) )
+         ENDIF
+          qbyv(ij,l) = masse_adv_v(ij,l)*qbyv(ij,l)
+       ENDDO
+      ENDDO
+
+
+      DO l=1,llm
+         DO ij=iip2,ip1jm
+            newmasse=masse(ij,l)
+     &      +masse_adv_v(ij,l)-masse_adv_v(ij-iip1,l)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+qbyv(ij,l)-qbyv(ij-iip1,l))
+     &         /newmasse
+            masse(ij,l)=newmasse
+         ENDDO
+c.-. ancienne version
+         convpn=SSUM(iim,qbyv(1,l),1)/apoln
+         convmpn=ssum(iim,masse_adv_v(1,l),1)/apoln
+         DO ij = 1,iip1
+            newmasse=masse(ij,l)+convmpn*aire(ij)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+convpn*aire(ij))/
+     &               newmasse
+            masse(ij,l)=newmasse
+         ENDDO
+         convps  = -SSUM(iim,qbyv(ip1jm-iim,l),1)/apols
+         convmps = -SSUM(iim,masse_adv_v(ip1jm-iim,l),1)/apols
+         DO ij = ip1jm+1,ip1jmp1
+            newmasse=masse(ij,l)+convmps*aire(ij)
+            q(ij,l)=(q(ij,l)*masse(ij,l)+convps*aire(ij))/
+     &               newmasse
+            masse(ij,l)=newmasse
+         ENDDO
+c.-. fin ancienne version
+
+c._. nouvelle version
+c        convpn=SSUM(iim,qbyv(1,l),1)
+c        convmpn=ssum(iim,masse_adv_v(1,l),1)
+c        oldmasse=ssum(iim,masse(1,l),1)
+c        newmasse=oldmasse+convmpn
+c        newq=(q(1,l)*oldmasse+convpn)/newmasse
+c        newmasse=newmasse/apoln
+c        DO ij = 1,iip1
+c           q(ij,l)=newq
+c           masse(ij,l)=newmasse*aire(ij)
+c        ENDDO
+c        convps=-SSUM(iim,qbyv(ip1jm-iim,l),1)
+c        convmps=-ssum(iim,masse_adv_v(ip1jm-iim,l),1)
+c        oldmasse=ssum(iim,masse(ip1jm-iim,l),1)
+c        newmasse=oldmasse+convmps
+c        newq=(q(ip1jmp1,l)*oldmasse+convps)/newmasse
+c        newmasse=newmasse/apols
+c        DO ij = ip1jm+1,ip1jmp1
+c           q(ij,l)=newq
+c           masse(ij,l)=newmasse*aire(ij)
+c        ENDDO
+c._. fin nouvelle version
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/calfis.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/calfis.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/calfis.F	(revision 1644)
@@ -0,0 +1,563 @@
+      SUBROUTINE calfis(nq, lafin, rdayvrai,rday_ecri, heure,
+     $            pucov,pvcov,pteta,pq,pmasse,pps,pp,ppk,pphis,pphi,
+     $            pducov,pdvcov,pdteta,pdq,pw,
+     $            pdufi,pdvfi,pdhfi,pdqfi,pdpsfi )
+c
+c    Auteur :  P. Le Van, F. Hourdin 
+c   .........
+      USE infotrac, ONLY: tname, nqtot
+      USE comvert_mod, ONLY: preff
+      USE comconst_mod, ONLY: dtphys,kappa,cpp,pi
+      USE physiq_mod, ONLY: physiq
+
+      IMPLICIT NONE
+c=======================================================================
+c
+c   1. rearrangement des tableaux et transformation
+c      variables dynamiques  >  variables physiques
+c   2. calcul des termes physiques
+c   3. retransformation des tendances physiques en tendances dynamiques
+c
+c   remarques:
+c   ----------
+c
+c    - les vents sont donnes dans la physique par leurs composantes 
+c      naturelles.
+c    - la variable thermodynamique de la physique est une variable
+c      intensive :   T 
+c      pour la dynamique on prend    T * ( preff / p(l) ) **kappa
+c    - les deux seules variables dependant de la geometrie necessaires
+c      pour la physique sont la latitude pour le rayonnement et 
+c      l'aire de la maille quand on veut integrer une grandeur 
+c      horizontalement.
+c    - les points de la physique sont les points scalaires de la 
+c      la dynamique; numerotation:
+c          1 pour le pole nord
+c          (jjm-1)*iim pour l'interieur du domaine
+c          ngridmx pour le pole sud
+c      ---> ngridmx=2+(jjm-1)*iim
+c
+c     Input :
+c     -------
+c       ecritphy        frequence d'ecriture (en jours)de histphy
+c       pucov           covariant zonal velocity
+c       pvcov           covariant meridional velocity 
+c       pteta           potential temperature
+c       pps             surface pressure
+c       pmasse          masse d'air dans chaque maille
+c       pts             surface temperature  (K)
+c       pw              flux vertical (kg/s)
+c
+c    Output :
+c    --------
+c        pdufi          tendency for the natural zonal velocity (ms-1)
+c        pdvfi          tendency for the natural meridional velocity 
+c        pdhfi          tendency for the potential temperature
+c        pdtsfi         tendency for the surface temperature
+c
+c=======================================================================
+c
+c-----------------------------------------------------------------------
+c
+c    0.  Declarations :
+c    ------------------
+
+#include "dimensions.h"
+#include "paramet.h"
+
+      INTEGER ngridmx,nq
+      PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm   )
+
+#include "comgeom2.h"
+!#include "control.h"
+
+!#include "advtrac.h"
+!! this is to get tnom (tracers name)
+
+c    Arguments :
+c    -----------
+      LOGICAL  lafin
+      REAL heure
+
+      REAL pvcov(iip1,jjm,llm)
+      REAL pucov(iip1,jjp1,llm)
+      REAL pteta(iip1,jjp1,llm)
+      REAL pmasse(iip1,jjp1,llm)
+      REAL pq(iip1,jjp1,llm,nqtot)
+      REAL pphis(iip1,jjp1)
+      REAL pphi(iip1,jjp1,llm)
+c
+      REAL pdvcov(iip1,jjm,llm)
+      REAL pducov(iip1,jjp1,llm)
+      REAL pdteta(iip1,jjp1,llm)
+      REAL pdq(iip1,jjp1,llm,nqtot)
+c
+      REAL pw(iip1,jjp1,llm)
+c
+      REAL pps(iip1,jjp1)
+      REAL pp(iip1,jjp1,llmp1)
+      REAL ppk(iip1,jjp1,llm)
+c
+      REAL pdvfi(iip1,jjm,llm)
+      REAL pdufi(iip1,jjp1,llm)
+      REAL pdhfi(iip1,jjp1,llm)
+      REAL pdqfi(iip1,jjp1,llm,nqtot)
+      REAL pdpsfi(iip1,jjp1)
+
+c    Local variables :
+c    -----------------
+
+      INTEGER i,j,l,ig0,ig,iq
+      REAL zpsrf(ngridmx)
+      REAL zplev(ngridmx,llm+1),zplay(ngridmx,llm)
+      REAL zphi(ngridmx,llm),zphis(ngridmx)
+c
+      REAL zufi(ngridmx,llm), zvfi(ngridmx,llm)
+      REAL ztfi(ngridmx,llm),zqfi(ngridmx,llm,nqtot)
+c
+!      REAL zvervel(ngridmx,llm)
+      REAL flxwfi(ngridmx,llm) ! vertical mass flux (kg/s) on physics grid
+c
+      REAL zdufi(ngridmx,llm),zdvfi(ngridmx,llm)
+      REAL zdtfi(ngridmx,llm),zdqfi(ngridmx,llm,nqtot)
+      REAL zdpsrf(ngridmx)
+c
+      REAL zsin(iim),zcos(iim),z1(iim)
+      REAL zsinbis(iim),zcosbis(iim),z1bis(iim)
+      REAL unskap, pksurcp
+c
+      
+      EXTERNAL gr_dyn_fi,gr_fi_dyn
+      REAL SSUM
+      EXTERNAL SSUM
+
+      REAL latfi(ngridmx),lonfi(ngridmx)
+      REAL airefi(ngridmx)
+      SAVE latfi, lonfi, airefi
+
+      LOGICAL firstcal, debut
+      DATA firstcal/.true./
+      SAVE firstcal,debut
+      REAL rdayvrai,rday_ecri
+c
+c-----------------------------------------------------------------------
+c
+c    1. Initialisations :
+c    --------------------
+c
+
+
+      IF (ngridmx.NE.2+(jjm-1)*iim) THEN
+         PRINT*,'STOP dans calfis'
+         PRINT*,'La dimension ngridmx doit etre egale a 2 + (jjm-1)*iim'
+         PRINT*,'  ngridmx  jjm   iim   '
+         PRINT*,ngridmx,jjm,iim
+         STOP
+      ENDIF
+
+c-----------------------------------------------------------------------
+c   latitude, longitude et aires des mailles pour la physique:
+c   ----------------------------------------------------------
+
+c
+      IF ( firstcal )  THEN
+          debut = .TRUE.
+      ELSE
+          debut = .FALSE.
+      ENDIF
+
+c
+!      IF (firstcal) THEN
+!         latfi(1)=rlatu(1)
+!         lonfi(1)=0.
+!         DO j=2,jjm
+!            DO i=1,iim
+!               latfi((j-2)*iim+1+i)= rlatu(j)
+!               lonfi((j-2)*iim+1+i)= rlonv(i)
+!            ENDDO
+!         ENDDO
+!         latfi(ngridmx)= rlatu(jjp1)
+!         lonfi(ngridmx)= 0.
+!
+!         ! build airefi(), mesh area on physics grid
+!         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
+!         ! Poles are single points on physics grid
+!         airefi(1)=airefi(1)*iim
+!         airefi(ngridmx)=airefi(ngridmx)*iim
+!
+!         CALL inifis(ngridmx,llm,day_ini,daysec,dtphys,
+!     .                latfi,lonfi,airefi,rad,g,r,cpp)
+!      ENDIF
+
+c
+c-----------------------------------------------------------------------
+c   40. transformation des variables dynamiques en variables physiques:
+c   ---------------------------------------------------------------
+
+c   41. pressions au sol (en Pascals)
+c   ----------------------------------
+
+       
+      zpsrf(1) = pps(1,1)
+
+      ig0  = 2
+      DO j = 2,jjm
+         CALL SCOPY( iim,pps(1,j),1,zpsrf(ig0), 1 )
+         ig0 = ig0+iim
+      ENDDO
+
+      zpsrf(ngridmx) = pps(1,jjp1)
+
+
+c   42. pression intercouches :
+c
+c   -----------------------------------------------------------------
+c     .... zplev  definis aux (llm +1) interfaces des couches  ....
+c     .... zplay  definis aux (  llm )    milieux des couches  .... 
+c   -----------------------------------------------------------------
+
+c    ...    Exner = cp * ( p(l) / preff ) ** kappa     ....
+c
+       unskap   = 1./ kappa
+c
+      DO l = 1, llmp1
+        zplev( 1,l ) = pp(1,1,l)
+        ig0 = 2
+          DO j = 2, jjm
+             DO i =1, iim
+              zplev( ig0,l ) = pp(i,j,l)
+              ig0 = ig0 +1
+             ENDDO
+          ENDDO
+        zplev( ngridmx,l ) = pp(1,jjp1,l)
+      ENDDO
+c
+c
+
+c   43. temperature naturelle (en K) et pressions milieux couches .
+c   ---------------------------------------------------------------
+
+      DO l=1,llm
+
+         pksurcp     =  ppk(1,1,l) / cpp
+         zplay(1,l)  =  preff * pksurcp ** unskap
+         ztfi(1,l)   =  pteta(1,1,l) *  pksurcp
+         ig0         =  2
+
+         DO j = 2, jjm
+            DO i = 1, iim
+              pksurcp        = ppk(i,j,l) / cpp
+              zplay(ig0,l)   = preff * pksurcp ** unskap
+              ztfi(ig0,l)    = pteta(i,j,l)  * pksurcp
+              ig0            = ig0 + 1
+            ENDDO
+         ENDDO
+
+         pksurcp       = ppk(1,jjp1,l) / cpp
+         zplay(ig0,l)  = preff * pksurcp ** unskap
+         ztfi (ig0,l)  = pteta(1,jjp1,l)  * pksurcp
+
+      ENDDO
+
+      DO l=1, llm
+        DO ig=1,ngridmx
+             if (ztfi(ig,l).lt.15) then
+                  write(*,*) 'New Temperature below 15 K !!! '
+	              write(*,*) 'Stop in calfis.F '
+	              write(*,*) 'ig=', ig, ' l=', l
+                      write(*,*) 'ztfi(ig,l)=',ztfi(ig,l)
+                  stop
+             end if
+        ENDDO
+      ENDDO
+
+
+
+c   43.bis Taceurs (en kg/kg)
+c   --------------------------
+      DO iq=1,nqtot
+         DO l=1,llm
+            zqfi(1,l,iq) = pq(1,1,l,iq)
+            ig0          = 2
+            DO j=2,jjm
+               DO i = 1, iim
+                  zqfi(ig0,l,iq)  = pq(i,j,l,iq)
+                  ig0             = ig0 + 1
+               ENDDO
+            ENDDO
+            zqfi(ig0,l,iq) = pq(1,jjp1,l,iq)
+         ENDDO
+      ENDDO
+
+c   Geopotentiel calcule par rapport a la surface locale:
+c   -----------------------------------------------------
+
+      CALL gr_dyn_fi(llm,iip1,jjp1,ngridmx,pphi,zphi)
+      CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,pphis,zphis)
+      DO l=1,llm
+         DO ig=1,ngridmx
+            zphi(ig,l)=zphi(ig,l)-zphis(ig)
+         ENDDO
+      ENDDO
+
+c   Calcul de la vitesse  verticale (m/s) pour diagnostique 
+c   -------------------------------
+c     pw est en kg/s
+c On interpole "lineairement" la temperature entre les couches(FF,10/95)
+
+!      DO ig=1,ngridmx
+!         zvervel(ig,1)=0.
+!      END DO
+!      DO l=2,llm
+!        zvervel(1,l)=(pw(1,1,l)/apoln)
+!     &  * r *0.5*(ztfi(1,l)+ztfi(1,l-1)) /zplev(1,l)              
+!        ig0=2
+!       DO j=2,jjm
+!           DO i = 1, iim
+!              zvervel(ig0,l) = pw(i,j,l) * unsaire(i,j)
+!     &        * r *0.5*(ztfi(ig0,l)+ztfi(ig0,l-1)) /zplev(ig0,l)              
+!              ig0 = ig0 + 1
+!           ENDDO
+!       ENDDO
+!        zvervel(ig0,l)=(pw(1,jjp1,l)/apols)
+!     &  * r *0.5*(ztfi(ig0,l)+ztfi(ig0,l-1)) /zplev(ig0,l)              
+!      ENDDO
+
+c    .........  Reindexation : calcul de zvervel au MILIEU des couches
+!       DO l=1,llm-1
+!	      DO ig=1,ngridmx
+!		     zvervel(ig,l) = 0.5*(zvervel(ig,l)+zvervel(ig,l+1))
+!          END DO 
+!       END DO 
+c      (dans la couche llm, on garde la valeur à la limite inférieure llm)
+
+! vertical mass flux
+      ! tranfer values from dynamics grid to physics grid:
+      CALL gr_dyn_fi(llm,iip1,jjp1,ngridmx,pw,flxwfi)
+      ! but mass flux is an extensive variable, so take the sum at the poles
+      DO l=1,llm
+        flxwfi(1,l)=sum(pw(1:iim,1,l))
+        flxwfi(ngridmx,l)=sum(pw(1:iim,jjp1,l))
+      ENDDO
+
+c   45. champ u:
+c   ------------
+
+      DO l=1,llm
+         DO j=2,jjm
+            ig0 = 1+(j-2)*iim
+            zufi(ig0+1,l)= 0.5 * 
+     $      ( pucov(iim,j,l)/cu(iim,j) + pucov(1,j,l)/cu(1,j) )
+            DO i=2,iim
+               zufi(ig0+i,l)= 0.5 *
+     $         ( pucov(i-1,j,l)/cu(i-1,j) + pucov(i,j,l)/cu(i,j) )
+            ENDDO
+        ENDDO
+      ENDDO
+
+
+c   46.champ v:
+c   -----------
+
+      DO l=1,llm
+         DO j=2,jjm
+            ig0=1+(j-2)*iim
+            DO i=1,iim
+               zvfi(ig0+i,l)= 0.5 *
+     $         ( pvcov(i,j-1,l)/cv(i,j-1) + pvcov(i,j,l)/cv(i,j) )
+            ENDDO
+         ENDDO
+      ENDDO
+
+
+c   47. champs de vents aux pole nord   
+c   ------------------------------
+c        U = 1 / pi  *  integrale [ v * cos(long) * d long ]
+c        V = 1 / pi  *  integrale [ v * sin(long) * d long ]
+
+      DO l=1,llm
+
+         z1(1)   =(rlonu(1)-rlonu(iim)+2.*pi)*pvcov(1,1,l)/cv(1,1)
+         z1bis(1)=(rlonu(1)-rlonu(iim)+2.*pi)*pdvcov(1,1,l)/cv(1,1)
+         DO i=2,iim
+            z1(i)   =(rlonu(i)-rlonu(i-1))*pvcov(i,1,l)/cv(i,1)
+            z1bis(i)=(rlonu(i)-rlonu(i-1))*pdvcov(i,1,l)/cv(i,1)
+         ENDDO
+
+         DO i=1,iim
+            zcos(i)   = COS(rlonv(i))*z1(i)
+            zcosbis(i)= COS(rlonv(i))*z1bis(i)
+            zsin(i)   = SIN(rlonv(i))*z1(i)
+            zsinbis(i)= SIN(rlonv(i))*z1bis(i)
+         ENDDO
+
+         zufi(1,l)  = SSUM(iim,zcos,1)/pi
+         zvfi(1,l)  = SSUM(iim,zsin,1)/pi
+
+      ENDDO
+
+
+c   48. champs de vents aux pole sud:
+c   ---------------------------------
+c        U = 1 / pi  *  integrale [ v * cos(long) * d long ]
+c        V = 1 / pi  *  integrale [ v * sin(long) * d long ]
+
+      DO l=1,llm
+
+         z1(1)   =(rlonu(1)-rlonu(iim)+2.*pi)*pvcov(1,jjm,l)/cv(1,jjm)
+         z1bis(1)=(rlonu(1)-rlonu(iim)+2.*pi)*pdvcov(1,jjm,l)/cv(1,jjm)
+         DO i=2,iim
+            z1(i)   =(rlonu(i)-rlonu(i-1))*pvcov(i,jjm,l)/cv(i,jjm)
+            z1bis(i)=(rlonu(i)-rlonu(i-1))*pdvcov(i,jjm,l)/cv(i,jjm)
+      ENDDO
+
+         DO i=1,iim
+            zcos(i)    = COS(rlonv(i))*z1(i)
+            zcosbis(i) = COS(rlonv(i))*z1bis(i)
+            zsin(i)    = SIN(rlonv(i))*z1(i)
+            zsinbis(i) = SIN(rlonv(i))*z1bis(i)
+      ENDDO
+
+         zufi(ngridmx,l)  = SSUM(iim,zcos,1)/pi
+         zvfi(ngridmx,l)  = SSUM(iim,zsin,1)/pi
+
+      ENDDO
+
+c-----------------------------------------------------------------------
+c   Appel de la physique:
+c   ---------------------
+
+
+      CALL physiq (ngridmx,llm,nq,
+     .     tname,
+     ,     debut,lafin,
+     ,     rday_ecri,heure,dtphys,
+     ,     zplev,zplay,zphi,
+     ,     zufi, zvfi,ztfi, zqfi,  
+!     ,     zvervel,
+     ,     flxwfi,
+C - sorties
+     s     zdufi, zdvfi, zdtfi, zdqfi,zdpsrf)
+
+
+c-----------------------------------------------------------------------
+c   transformation des tendances physiques en tendances dynamiques:
+c   ---------------------------------------------------------------
+
+c  tendance sur la pression :
+c  -----------------------------------
+
+      CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,zdpsrf,pdpsfi)
+c
+ccc     CALL multipl(ip1jmp1,aire,pdpsfi,pdpsfi)
+
+c   62. enthalpie potentielle
+c   ---------------------
+
+      DO l=1,llm
+
+         DO i=1,iip1
+          pdhfi(i,1,l)    = cpp *  zdtfi(1,l)      / ppk(i, 1  ,l)
+          pdhfi(i,jjp1,l) = cpp *  zdtfi(ngridmx,l)/ ppk(i,jjp1,l)
+         ENDDO
+
+         DO j=2,jjm
+            ig0=1+(j-2)*iim
+            DO i=1,iim
+               pdhfi(i,j,l) = cpp * zdtfi(ig0+i,l) / ppk(i,j,l)
+            ENDDO
+               pdhfi(iip1,j,l) =  pdhfi(1,j,l)
+         ENDDO
+
+      ENDDO
+
+
+c   62. traceurs
+c   ---------------------
+
+      DO iq=1,nqtot
+         DO l=1,llm
+            DO i=1,iip1
+               pdqfi(i,1,l,iq)    = zdqfi(1,l,iq)
+               pdqfi(i,jjp1,l,iq) = zdqfi(ngridmx,l,iq)
+            ENDDO
+            DO j=2,jjm
+               ig0=1+(j-2)*iim
+               DO i=1,iim
+                  pdqfi(i,j,l,iq) = zdqfi(ig0+i,l,iq)
+               ENDDO
+               pdqfi(iip1,j,l,iq) = pdqfi(1,j,l,iq)
+            ENDDO
+         ENDDO
+      ENDDO
+
+c   65. champ u:
+c   ------------
+
+      DO l=1,llm
+
+         DO i=1,iip1
+            pdufi(i,1,l)    = 0.
+            pdufi(i,jjp1,l) = 0.
+         ENDDO
+
+         DO j=2,jjm
+            ig0=1+(j-2)*iim
+            DO i=1,iim-1
+               pdufi(i,j,l)=
+     $         0.5*(zdufi(ig0+i,l)+zdufi(ig0+i+1,l))*cu(i,j)
+            ENDDO
+            pdufi(iim,j,l)=
+     $      0.5*(zdufi(ig0+1,l)+zdufi(ig0+iim,l))*cu(iim,j)
+            pdufi(iip1,j,l)=pdufi(1,j,l)
+         ENDDO
+
+      ENDDO
+
+
+c   67. champ v:
+c   ------------
+
+      DO l=1,llm
+
+         DO j=2,jjm-1
+            ig0=1+(j-2)*iim
+            DO i=1,iim
+               pdvfi(i,j,l)=
+     $         0.5*(zdvfi(ig0+i,l)+zdvfi(ig0+i+iim,l))*cv(i,j)
+            ENDDO
+            pdvfi(iip1,j,l) = pdvfi(1,j,l)
+         ENDDO
+      ENDDO
+
+
+c   68. champ v pres des poles:
+c   ---------------------------
+c      v = U * cos(long) + V * SIN(long)
+
+      DO l=1,llm
+
+         DO i=1,iim
+            pdvfi(i,1,l)=
+     $      zdufi(1,l)*COS(rlonv(i))+zdvfi(1,l)*SIN(rlonv(i))
+            pdvfi(i,jjm,l)=zdufi(ngridmx,l)*COS(rlonv(i))
+     $      +zdvfi(ngridmx,l)*SIN(rlonv(i))
+            pdvfi(i,1,l)=
+     $      0.5*(pdvfi(i,1,l)+zdvfi(i+1,l))*cv(i,1)
+            pdvfi(i,jjm,l)=
+     $      0.5*(pdvfi(i,jjm,l)+zdvfi(ngridmx-iip1+i,l))*cv(i,jjm)
+          ENDDO
+
+         pdvfi(iip1,1,l)  = pdvfi(1,1,l)
+         pdvfi(iip1,jjm,l)= pdvfi(1,jjm,l)
+
+      ENDDO
+
+c-----------------------------------------------------------------------
+
+700   CONTINUE
+
+      firstcal = .FALSE.
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/gr_dyn_fi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/gr_dyn_fi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/gr_dyn_fi.F	(revision 1644)
@@ -0,0 +1,37 @@
+      SUBROUTINE gr_dyn_fi(nfield,im,jm,ngrid,pdyn,pfi)
+
+      IMPLICIT NONE
+c=======================================================================
+c   passage d'un champ de la grille scalaire a la grille physique
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c   declarations:
+c   -------------
+
+      INTEGER im,jm,ngrid,nfield
+      REAL pdyn(im,jm,nfield)
+      REAL pfi(ngrid,nfield)
+
+      INTEGER j,ifield,ig
+      EXTERNAL SCOPY
+
+c-----------------------------------------------------------------------
+c   calcul:
+c   -------
+
+      IF(ngrid.NE.2+(jm-2)*(im-1)) STOP 'probleme de dim'
+c   traitement des poles
+      CALL SCOPY(nfield,pdyn,im*jm,pfi,ngrid)
+      CALL SCOPY(nfield,pdyn(1,jm,1),im*jm,pfi(ngrid,1),ngrid)
+
+c   traitement des point normaux
+      DO ifield=1,nfield
+         DO j=2,jm-1
+            ig=2+(j-2)*(im-1)
+            CALL SCOPY(im-1,pdyn(1,j,ifield),1,pfi(ig,ifield),1)
+         ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/gr_fi_dyn.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/gr_fi_dyn.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/gr_fi_dyn.F	(revision 1644)
@@ -0,0 +1,38 @@
+      SUBROUTINE gr_fi_dyn(nfield,ngrid,im,jm,pfi,pdyn)
+      IMPLICIT NONE
+c=======================================================================
+c   passage d'un champ de la grille scalaire a la grille physique
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c   declarations:
+c   -------------
+
+      INTEGER im,jm,ngrid,nfield
+      REAL pdyn(im,jm,nfield)
+      REAL pfi(ngrid,nfield)
+
+      INTEGER i,j,ifield,ig
+      EXTERNAL SCOPY
+
+c-----------------------------------------------------------------------
+c   calcul:
+c   -------
+
+      DO ifield=1,nfield
+c   traitement des poles
+         DO i=1,im
+            pdyn(i,1,ifield)=pfi(1,ifield)
+            pdyn(i,jm,ifield)=pfi(ngrid,ifield)
+         ENDDO
+
+c   traitement des point normaux
+         DO j=2,jm-1
+	    ig=2+(j-2)*(im-1)
+            CALL SCOPY(im-1,pfi(ig,ifield),1,pdyn(1,j,ifield),1)
+	    pdyn(im,j,ifield)=pdyn(1,j,ifield)
+         ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/inigeomphy_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/inigeomphy_mod.F90	(revision 1644)
@@ -0,0 +1,227 @@
+MODULE inigeomphy_mod
+
+CONTAINS
+
+SUBROUTINE inigeomphy(iim,jjm,nlayer, &
+                     nbp, communicator, &
+                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv)
+  USE mod_grid_phy_lmdz, ONLY: klon_glo,  & ! number of atmospheric columns (on full grid)
+                               regular_lonlat, &  ! regular longitude-latitude grid type
+                               nbp_lon, nbp_lat, nbp_lev
+  USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid)
+                                klon_omp_begin, & ! start index of local omp subgrid
+                                klon_omp_end, & ! end index of local omp subgrid
+                                klon_mpi_begin ! start indes of columns (on local mpi grid)
+  USE geometry_mod, ONLY : init_geometry
+  USE physics_distribution_mod, ONLY : init_physics_distribution
+  USE regular_lonlat_mod, ONLY : init_regular_lonlat, &
+                                 east, west, north, south, &
+                                 north_east, north_west, &
+                                 south_west, south_east
+  USE mod_interface_dyn_phys, ONLY :  init_interface_dyn_phys
+  USE nrtype, ONLY: pi
+  USE comvert_mod, ONLY: preff, ap, bp, aps, bps, presnivs, &
+                         scaleheight, pseudoalt
+  USE vertical_layers_mod, ONLY: init_vertical_layers
+  IMPLICIT NONE
+
+  ! =======================================================================
+  ! Initialisation of the physical constants and some positional and
+  ! geometrical arrays for the physics
+  ! =======================================================================
+
+  include "iniprint.h"
+
+  INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers
+  INTEGER, INTENT (IN) :: iim ! number of atmospheric columns along longitudes
+  INTEGER, INTENT (IN) :: jjm ! number of atompsheric columns along latitudes
+  INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process
+  INTEGER, INTENT(IN) :: communicator ! MPI communicator
+  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
+  REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid
+  REAL, INTENT (IN) :: rlonv(iim+1) ! longitudes of the physics grid
+  REAL, INTENT (IN) :: rlonu(iim+1) ! longitude boundaries of the physics grid
+  REAL, INTENT (IN) :: aire(iim+1,jjm+1) ! area of the dynamics grid (m2)
+  REAL, INTENT (IN) :: cu((iim+1)*(jjm+1)) ! cu coeff. (u_covariant = cu * u)
+  REAL, INTENT (IN) :: cv((iim+1)*jjm) ! cv coeff. (v_covariant = cv * v)
+
+  INTEGER :: ibegin, iend, offset
+  INTEGER :: i,j,k
+  CHARACTER (LEN=20) :: modname = 'iniphysiq'
+  CHARACTER (LEN=80) :: abort_message
+  REAL :: total_area_phy, total_area_dyn
+
+  ! boundaries, on global grid
+  REAL,ALLOCATABLE :: boundslon_reg(:,:)
+  REAL,ALLOCATABLE :: boundslat_reg(:,:)
+
+  ! global array, on full physics grid:
+  REAL,ALLOCATABLE :: latfi_glo(:)
+  REAL,ALLOCATABLE :: lonfi_glo(:)
+  REAL,ALLOCATABLE :: cufi_glo(:)
+  REAL,ALLOCATABLE :: cvfi_glo(:)
+  REAL,ALLOCATABLE :: airefi_glo(:)
+  REAL,ALLOCATABLE :: boundslonfi_glo(:,:)
+  REAL,ALLOCATABLE :: boundslatfi_glo(:,:)
+
+  ! local arrays, on given MPI/OpenMP domain:
+  REAL,ALLOCATABLE,SAVE :: latfi(:)
+  REAL,ALLOCATABLE,SAVE :: lonfi(:)
+  REAL,ALLOCATABLE,SAVE :: cufi(:)
+  REAL,ALLOCATABLE,SAVE :: cvfi(:)
+  REAL,ALLOCATABLE,SAVE :: airefi(:)
+  REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:)
+  REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:)
+!$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi)
+
+  ! Initialize Physics distibution and parameters and interface with dynamics
+  IF (iim*jjm>1) THEN ! general 3D case
+    CALL init_physics_distribution(regular_lonlat,4, &
+                                 nbp,iim,jjm+1,nlayer,communicator)
+  ELSE ! For 1D model
+    CALL init_physics_distribution(regular_lonlat,4, &
+                                 1,1,1,nlayer,communicator)
+  ENDIF
+  CALL init_interface_dyn_phys
+  
+  ! init regular global longitude-latitude grid points and boundaries
+  ALLOCATE(boundslon_reg(iim,2))
+  ALLOCATE(boundslat_reg(jjm+1,2))
+  
+  DO i=1,iim
+   boundslon_reg(i,east)=rlonu(i) 
+   boundslon_reg(i,west)=rlonu(i+1) 
+  ENDDO
+
+  boundslat_reg(1,north)= PI/2 
+  boundslat_reg(1,south)= rlatv(1)
+  DO j=2,jjm
+   boundslat_reg(j,north)=rlatv(j-1) 
+   boundslat_reg(j,south)=rlatv(j) 
+  ENDDO
+  boundslat_reg(jjm+1,north)= rlatv(jjm) 
+  boundslat_reg(jjm+1,south)= -PI/2
+
+  ! Write values in module regular_lonlat_mod
+  CALL init_regular_lonlat(iim,jjm+1, rlonv(1:iim), rlatu, &
+                           boundslon_reg, boundslat_reg)
+
+  ! Generate global arrays on full physics grid
+  ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo))
+  ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
+  ALLOCATE(airefi_glo(klon_glo))
+  ALLOCATE(boundslonfi_glo(klon_glo,4))
+  ALLOCATE(boundslatfi_glo(klon_glo,4))
+
+  IF (klon_glo>1) THEN ! general case
+    ! North pole
+    latfi_glo(1)=rlatu(1)
+    lonfi_glo(1)=0.
+    cufi_glo(1) = cu(1)
+    cvfi_glo(1) = cv(1)
+    boundslonfi_glo(1,north_east)=0
+    boundslatfi_glo(1,north_east)=PI/2
+    boundslonfi_glo(1,north_west)=2*PI
+    boundslatfi_glo(1,north_west)=PI/2
+    boundslonfi_glo(1,south_west)=2*PI
+    boundslatfi_glo(1,south_west)=rlatv(1)
+    boundslonfi_glo(1,south_east)=0
+    boundslatfi_glo(1,south_east)=rlatv(1)
+    DO j=2,jjm
+      DO i=1,iim
+        k=(j-2)*iim+1+i
+        latfi_glo(k)= rlatu(j)
+        lonfi_glo(k)= rlonv(i)
+        cufi_glo(k) = cu((j-1)*(iim+1)+i)
+        cvfi_glo(k) = cv((j-1)*(iim+1)+i)
+        boundslonfi_glo(k,north_east)=rlonu(i)
+        boundslatfi_glo(k,north_east)=rlatv(j-1)
+        boundslonfi_glo(k,north_west)=rlonu(i+1)
+        boundslatfi_glo(k,north_west)=rlatv(j-1)
+        boundslonfi_glo(k,south_west)=rlonu(i+1)
+        boundslatfi_glo(k,south_west)=rlatv(j)
+        boundslonfi_glo(k,south_east)=rlonu(i)
+        boundslatfi_glo(k,south_east)=rlatv(j)
+      ENDDO
+    ENDDO
+    ! South pole
+    latfi_glo(klon_glo)= rlatu(jjm+1)
+    lonfi_glo(klon_glo)= 0.
+    cufi_glo(klon_glo) = cu((iim+1)*jjm+1)
+    cvfi_glo(klon_glo) = cv((iim+1)*jjm-iim)
+    boundslonfi_glo(klon_glo,north_east)= 0
+    boundslatfi_glo(klon_glo,north_east)= rlatv(jjm)
+    boundslonfi_glo(klon_glo,north_west)= 2*PI
+    boundslatfi_glo(klon_glo,north_west)= rlatv(jjm)
+    boundslonfi_glo(klon_glo,south_west)= 2*PI
+    boundslatfi_glo(klon_glo,south_west)= -PI/2
+    boundslonfi_glo(klon_glo,south_east)= 0
+    boundslatfi_glo(klon_glo,south_east)= -Pi/2
+
+    ! build airefi(), mesh area on physics grid
+    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi_glo)
+    ! Poles are single points on physics grid
+    airefi_glo(1)=sum(aire(1:iim,1))
+    airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1))
+
+    ! Sanity check: do total planet area match between physics and dynamics?
+    total_area_dyn=sum(aire(1:iim,1:jjm+1))
+    total_area_phy=sum(airefi_glo(1:klon_glo))
+    IF (total_area_dyn/=total_area_phy) THEN
+      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
+      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
+      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
+      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
+        ! stop here if the relative difference is more than 0.001%
+        abort_message = 'planet total surface discrepancy'
+        CALL abort_gcm(modname, abort_message, 1)
+      ENDIF
+    ENDIF
+  ELSE ! klon_glo==1, running the 1D model
+    ! just copy over input values
+    latfi_glo(1)=rlatu(1)
+    lonfi_glo(1)=rlonv(1)
+    cufi_glo(1)=cu(1)
+    cvfi_glo(1)=cv(1)
+    airefi_glo(1)=aire(1,1)
+    boundslonfi_glo(1,north_east)=rlonu(1)
+    boundslatfi_glo(1,north_east)=PI/2
+    boundslonfi_glo(1,north_west)=rlonu(2)
+    boundslatfi_glo(1,north_west)=PI/2
+    boundslonfi_glo(1,south_west)=rlonu(2)
+    boundslatfi_glo(1,south_west)=rlatv(1)
+    boundslonfi_glo(1,south_east)=rlonu(1)
+    boundslatfi_glo(1,south_east)=rlatv(1)
+  ENDIF ! of IF (klon_glo>1)
+
+!$OMP PARALLEL 
+  ! Now generate local lon/lat/cu/cv/area/bounds arrays
+  ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
+  ALLOCATE(airefi(klon_omp))
+  ALLOCATE(boundslonfi(klon_omp,4))
+  ALLOCATE(boundslatfi(klon_omp,4))
+!  CALL initcomgeomphy
+
+  offset = klon_mpi_begin - 1
+  airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
+  boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
+  boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
+
+  ! copy over local grid longitudes and latitudes
+  CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
+                     airefi,cufi,cvfi)
+
+  ! copy over preff , ap(), bp(), etc 
+  CALL init_vertical_layers(nlayer,preff,scaleheight, &
+                            ap,bp,aps,bps,presnivs,pseudoalt)
+
+!$OMP END PARALLEL
+
+
+END SUBROUTINE inigeomphy
+
+END MODULE inigeomphy_mod
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/mod_interface_dyn_phys.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/mod_interface_dyn_phys.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/mod_interface_dyn_phys.F90	(revision 1644)
@@ -0,0 +1,62 @@
+! 
+! $Id: mod_interface_dyn_phys.F90 2351 2015-08-25 15:14:59Z emillour $
+!
+MODULE mod_interface_dyn_phys
+  INTEGER,SAVE,dimension(:),allocatable :: index_i
+  INTEGER,SAVE,dimension(:),allocatable :: index_j
+  
+  
+CONTAINS
+  
+#ifdef CPP_PARA
+! Interface with parallel physics,
+  SUBROUTINE Init_interface_dyn_phys
+    USE mod_phys_lmdz_mpi_data
+    IMPLICIT NONE
+    include 'dimensions.h'    
+    
+    INTEGER :: i,j,k
+    
+    ALLOCATE(index_i(klon_mpi))
+    ALLOCATE(index_j(klon_mpi))
+    
+    k=1
+    IF (is_north_pole) THEN
+      index_i(k)=1
+      index_j(k)=1
+      k=2
+    ELSE
+      DO i=ii_begin,iim
+	index_i(k)=i
+	index_j(k)=jj_begin
+	k=k+1
+       ENDDO
+    ENDIF
+    
+    DO j=jj_begin+1,jj_end-1
+      DO i=1,iim
+	index_i(k)=i
+	index_j(k)=j
+	k=k+1
+      ENDDO
+    ENDDO
+    
+    IF (is_south_pole) THEN
+      index_i(k)=1
+      index_j(k)=jj_end
+    ELSE
+      DO i=1,ii_end
+	index_i(k)=i
+	index_j(k)=jj_end
+	k=k+1
+       ENDDO
+    ENDIF
+  
+  END SUBROUTINE Init_interface_dyn_phys 
+#else
+  SUBROUTINE Init_interface_dyn_phys
+  ! dummy routine for seq case
+  END SUBROUTINE Init_interface_dyn_phys 
+#endif
+! of #ifdef CPP_PARA
+END MODULE mod_interface_dyn_phys
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/caldyn0.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/caldyn0.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/caldyn0.F	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/caldyn0.F
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/callphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/callphysiq_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/callphysiq_mod.F90	(revision 1644)
@@ -0,0 +1,95 @@
+!
+! $Id: $
+!
+MODULE callphysiq_mod
+
+IMPLICIT NONE
+
+CONTAINS
+
+SUBROUTINE call_physiq(klon,llm,nqtot,tname,                              &
+                       debut_split,lafin_split,                           &
+                       jD_cur,jH_cur_split,zdt_split,                     &
+                       zplev_omp,zplay_omp,                               &
+                       zpk_omp,zphi_omp,zphis_omp,                        &
+                       presnivs_omp,                                      &
+                       zufi_omp,zvfi_omp,zrfi_omp,ztfi_omp,zqfi_omp,      &
+                       flxwfi_omp,pducov,                                 &
+                       zdufi_omp,zdvfi_omp,zdtfi_omp,zdqfi_omp,zdpsrf_omp)
+
+  USE control_mod, ONLY: planet_type
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+  USE physiq_mod, ONLY: physiq
+  IMPLICIT NONE
+
+  INTEGER,INTENT(IN) :: klon ! (local) number of atmospheric columns
+  INTEGER,INTENT(IN) :: llm  ! number of atmospheric layers
+  INTEGER,INTENT(IN) :: nqtot ! number of tracers
+  CHARACTER(len=*),INTENT(IN) :: tname(nqtot) ! tracer names
+  LOGICAL,INTENT(IN) :: debut_split ! .true. if very first call to physics
+  LOGICAL,INTENT(IN) :: lafin_split ! .true. if last call to physics
+  REAL,INTENT(IN) :: JD_cur ! Julian day
+  REAL,INTENT(IN) :: JH_cur_split ! Julian hour (fraction of day)
+  REAL,INTENT(IN) :: zdt_split ! time step over which the physics are evaluated
+  REAL,INTENT(IN) :: zplev_omp(klon,llm+1) ! interlayer pressure (Pa)
+  REAL,INTENT(IN) :: zplay_omp(klon,llm) ! mid-layer pressure (Pa)
+  REAL,INTENT(IN) :: zpk_omp(klon,llm)
+  REAL,INTENT(IN) :: zphi_omp(klon,llm) ! geopotential at midlayer
+  REAL,INTENT(IN) :: zphis_omp(klon) ! surface geopotential
+  REAL,INTENT(IN) :: presnivs_omp(llm) ! approximate pressure of atm. layers
+  REAL,INTENT(IN) :: zufi_omp(klon,llm) ! zonal wind (m/s)
+  REAL,INTENT(IN) :: zvfi_omp(klon,llm) ! meridional wind (m/s)
+  REAL,INTENT(IN) :: zrfi_omp(klon,llm) ! relative wind vorticity, in s-1
+  REAL,INTENT(IN) :: ztfi_omp(klon,llm) ! temperature (K)
+  REAL,INTENT(IN) :: zqfi_omp(klon,llm,nqtot) ! tracers (*/kg of air)
+  REAL,INTENT(IN) :: flxwfi_omp(klon,llm) ! Vertical mass flux on lower mesh interfaces (kg/s) 
+  REAL,INTENT(IN) :: pducov(nbp_lon+1,nbp_lat,llm) ! dynamical tendency on ucov
+  ! tendencies (in */s) from the physics:
+  REAL,INTENT(OUT) :: zdufi_omp(klon,llm) ! tendency on zonal winds
+  REAL,INTENT(OUT) :: zdvfi_omp(klon,llm) ! tendency on meridional winds
+  REAL,INTENT(OUT) :: zdtfi_omp(klon,llm) ! tendency on temperature
+  REAL,INTENT(OUT) :: zdqfi_omp(klon,llm,nqtot) ! tendency on tracers
+  REAL,INTENT(OUT) :: zdpsrf_omp(klon) ! tendency on surface pressure
+
+  ! Local variables
+  CHARACTER(len=11) :: modname="call_physiq"
+  LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+
+! Sanity check on physics package type
+  IF (firstcall) THEN
+    IF (planet_type.ne."titan") THEN
+      CALL abort_gcm(modname,"wrong planet_type for this physics package",1)
+    ENDIF
+    firstcall=.false.
+  ENDIF
+
+
+! Call physics package with required inputs/outputs
+  CALL physiq(klon,           & ! ngrid
+              llm,            & ! nlayer
+              nqtot,          & ! nq
+              tname,          & ! nametrac
+              debut_split,    & ! firstcall
+              lafin_split,    & ! lastcall
+              jD_cur,         & ! pday
+              jH_cur_split,   & ! ptime
+              zdt_split,      & ! ptimestep
+              zplev_omp,      & ! pplev
+              zplay_omp,      & ! pplay
+              zphi_omp,       & ! pphi
+              zufi_omp,       & ! pu
+              zvfi_omp,       & ! pv
+              ztfi_omp,       & ! pt
+              zqfi_omp,       & ! pq
+              flxwfi_omp,     & ! flxw
+              zdufi_omp,      & ! pdu
+              zdvfi_omp,      & ! pdv
+              zdtfi_omp,      & ! pdt
+              zdqfi_omp,      & ! pdq
+              zdpsrf_omp)       ! pdpsrf
+
+
+END SUBROUTINE call_physiq
+
+END MODULE callphysiq_mod
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/datareadnc.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/datareadnc.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/datareadnc.F	(revision 1644)
@@ -0,0 +1,292 @@
+c=======================================================================
+      SUBROUTINE datareadnc(relief,filename,phisinit,alb,ith,
+     .                    zmea,zstd,zsig,zgam,zthe)
+c=======================================================================
+c
+c
+c   Author: F. Hourdin      01/1997
+c   -------
+c
+c   Object: To read data from Martian surface to use in a GCM
+c   ------                from NetCDF file "surface.nc"
+c
+c
+c   Arguments:
+c   ----------
+c
+c     Inputs:
+c     ------
+c
+c     Outputs:
+c     --------
+c
+c=======================================================================
+c   donnees ALBEDO, INERTIE THERMIQUE, RELIEF:
+c
+c       Ces donnees sont au format NetCDF dans le fichier "surface.nc"
+c
+c   360 valeurs en longitude (de -179.5 a 179.5)
+c   180 valeurs en latitudes (de 89.5 a -89.5)
+c
+c   Pour les passer au format de la grille, on utilise "interp_horiz.F"
+c
+c   Il faut donc que ces donnees soient au format grille scalaire
+c               (imold+1 jmold+1)
+c       avec passage des coordonnees de la "boite" (rlonu, rlatv)
+c
+c   On prend imd (d pour donnees!) 
+c           imd = 360 avec copie de la 1ere valeur sur la imd+1 
+c                   (rlonud de -179 a -181)
+c           jmd = 179 
+c                   (rlatvd de 89 a -89)
+c=======================================================================
+
+      use datafile_mod, only: datadir, surfdir
+! to use  'getin'
+      USE ioipsl_getincom 
+      USE comconst_mod, ONLY: g,pi
+      implicit none
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "netcdf.inc"
+
+c=======================================================================
+c   Declarations:
+C=======================================================================
+
+      INTEGER    imd,jmd,imdp1,jmdp1
+      parameter    (imd=360,jmd=179,imdp1=361,jmdp1=180)
+
+      INTEGER    iimp1
+      parameter    (iimp1=iim+1-1/iim)
+
+      character(len=3),intent(inout) :: relief*3
+      character(len=*),intent(in) :: filename ! surface.nc file
+      real,intent(out) :: phisinit(iimp1*jjp1) ! surface geopotential
+      real,intent(out) :: alb(iimp1*jjp1) ! albedo
+      real,intent(out) :: ith(iimp1*jjp1) ! thermal inertia
+      real,intent(out) :: zmea(imdp1*jmdp1)
+      real,intent(out) :: zstd(imdp1*jmdp1)
+      real,intent(out) :: zsig(imdp1*jmdp1)
+      real,intent(out) :: zgam(imdp1*jmdp1)
+      real,intent(out) :: zthe(imdp1*jmdp1)
+      
+      REAL        zdata(imd*jmdp1)
+      REAL        zdataS(imdp1*jmdp1)
+      REAL        pfield(iimp1*jjp1)
+
+      INTEGER   ierr
+
+      INTEGER   unit,nvarid
+
+      INTEGER    i,j,k
+
+      INTEGER klatdat,ngridmixgdat
+      PARAMETER (klatdat=180,ngridmixgdat=360)
+
+c    on passe une grille en rlonu rlatv et im+1 jm a interp_horiz)
+
+      REAL longitude(imd),latitude(jmdp1) ! Pour lecture des donnees
+      REAL rlonud(imdp1),rlatvd(jmd)
+
+      CHARACTER*20 string
+      DIMENSION string(4)
+!#include "fxyprim.h"
+
+      pi=2.*ASIN(1.)
+
+c=======================================================================
+c    rlonud, rlatvd
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c    Lecture NetCDF des donnees latitude et longitude
+c-----------------------------------------------------------------------
+      ierr = NF_OPEN (trim(datadir)//'/'//trim(surfdir)//'/'//
+     &                trim(adjustl(filename)),
+     &                NF_NOWRITE,unit)
+      IF (ierr.NE.NF_NOERR) THEN
+        ! In ye old days this file was stored in datadir;
+        ! let's be retro-compatible
+        ierr = NF_OPEN (trim(datadir)//'/'//
+     &                trim(adjustl(filename)),
+     &                NF_NOWRITE,unit)
+        
+      ENDIF
+      IF (ierr.NE.NF_NOERR) THEN
+        write(*,*)'Error : cannot open file '//trim(filename)
+        write(*,*)'(in phystd/datareadnc.F)'
+        write(*,*)'It should be in :',trim(datadir),'/',trim(surfdir)
+        write(*,*)'Check that your path to datagcm:',trim(datadir)
+        write(*,*)' is correct. You can change it in callphys.def with:'
+        write(*,*)' datadir = /absolute/path/to/datagcm'
+        write(*,*)'If necessary surface.nc (and other datafiles)'
+        write(*,*)' can be obtained online on:'
+        write(*,*)' http://www.lmd.jussieu.fr/~lmdz/planets/'//
+     &             'LMDZ.GENERIC/datagcm/'
+        STOP
+      ENDIF
+
+c
+c Lecture des latitudes (coordonnees):
+c
+      ierr = NF_INQ_VARID (unit, "latitude", nvarid)
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(unit, nvarid, latitude)
+#else
+      ierr = NF_GET_VAR_REAL(unit, nvarid, latitude)
+#endif
+c
+c Lecture des longitudes (coordonnees):
+c
+      ierr = NF_INQ_VARID (unit, "longitude", nvarid)
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(unit, nvarid, longitude)
+#else
+      ierr = NF_GET_VAR_REAL(unit, nvarid, longitude)
+#endif
+
+c-----------------------------------------------------------------------
+c    Passage au format boites scalaires
+c-----------------------------------------------------------------------
+
+c-----------------------------------------------------------------------
+c       longitude(imd)        -->      rlonud(imdp1) 
+c-----------------------------------------------------------------------
+
+c Passage en coordonnees boites scalaires et en radian
+      do i=1,imd 
+          rlonud(i)=(longitude(i)+.5)*pi/180.
+      enddo
+
+c Repetition de la valeur im+1
+      rlonud(imdp1)=rlonud(1) + 2*pi
+
+c-----------------------------------------------------------------------
+c        latitude(jmdp1)         -->        rlonvd(jmd)
+c-----------------------------------------------------------------------
+
+c Passage en coordonnees boites scalaires et en radian
+      do j=1,jmd 
+          rlatvd(j)=(latitude(j)-.5)*pi/180.
+      enddo
+
+c=======================================================================
+c   lecture NetCDF de albedo, thermal, relief, zdtm (pour francois Lott)
+c=======================================================================
+
+      string(1) = 'albedo'
+      string(2) = 'thermal'
+      if (relief.ne.'pla') then
+        write(*,*) ' La topographie est celle de MOLA'
+        relief = 'MOL'
+          string(3) = 'z'//relief
+      else
+          string(3) = 'zMOL'  ! pour qu''il lise qqchose sur le fichier
+                            ! remise a 0 derriere
+      endif
+      string(4) = 'zMOL'    ! lecture pour calcul topog. sous-maille
+ 
+
+      DO k=1,4
+          write(*,*) 'string',k,string(k)
+          
+c-----------------------------------------------------------------------
+c    initialisation
+c-----------------------------------------------------------------------
+      pfield(1:iimp1*jjp1)=0
+      zdata(1:imd*jmdp1)=0
+      zdataS(1:iimp1*jjp1)=0
+
+c-----------------------------------------------------------------------
+c    Lecture NetCDF  
+c-----------------------------------------------------------------------
+
+      ierr = NF_INQ_VARID (unit, string(k), nvarid)
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(unit, nvarid, zdata)
+#else
+      ierr = NF_GET_VAR_REAL(unit, nvarid, zdata)
+#endif
+
+c-----------------------------------------------------------------------
+c        Cas particulier "Francois Lott" ( k=4 ) (relief sous-maille)
+c-----------------------------------------------------------------------
+      if (k.eq.4) then
+
+          zdata(:)=1000.*zdata(:)
+          longitude(:)=(pi/180.)*longitude(:)
+          latitude(:)=(pi/180.)*latitude(:)
+
+          call grid_noro1(360, 180, longitude, latitude, zdata,
+     .         iim, jjp1, rlonv, rlatu, zmea,zstd,zsig,zgam,zthe)
+
+          !CALL dump2d(iip1,jjp1,zmea,'zmea')
+          !CALL dump2d(iip1,jjp1,zstd,'zstd')
+          !CALL dump2d(iip1,jjp1,zsig,'zsig')
+          !CALL dump2d(iip1,jjp1,zgam,'zgam')
+          !CALL dump2d(iip1,jjp1,zthe,'zthe')
+
+      endif
+
+c-----------------------------------------------------------------------
+c   Passage de zdata en grille (imdp1 jmdp1)
+c-----------------------------------------------------------------------
+      do j=1,jmdp1
+          do i=1,imd
+              zdataS(i+imdp1*(j-1)) = zdata(i+ngridmixgdat*(j-1))
+          enddo
+          zdataS(imdp1+imdp1*(j-1)) = zdata(1+ngridmixgdat*(j-1))
+      enddo
+
+c-----------------------------------------------------------------------
+c    Interpolation
+c-----------------------------------------------------------------------
+      call interp_horiz(zdataS,pfield,imd,jmd,
+     .    iim, jjm,1,rlonud,rlatvd,rlonu,rlatv) 
+
+c-----------------------------------------------------------------------
+c    Periodicite    
+c-----------------------------------------------------------------------
+
+      do j=1,jjp1
+         pfield(iimp1*j) =  pfield(1+iimp1*(j-1))
+      enddo 
+ 
+c-----------------------------------------------------------------------
+c    Sauvegarde des champs    
+c-----------------------------------------------------------------------
+
+      if (k.eq.1) then                    ! albedo
+         do i=1,iimp1*jjp1
+              alb(i) = pfield(i)
+          enddo
+      elseif (k.eq.2) then                ! thermal
+         do i=1,iimp1*jjp1
+              ith(i) = pfield(i)
+          enddo
+      elseif (k.eq.3) then                ! relief
+        if (relief.eq.'pla') then
+             phisinit(1:iimp1*jjp1)=0
+        else
+             phisinit(1:iimp1*jjp1)=pfield(1:iimp1*jjp1)
+        endif
+      endif
+
+      ENDDO
+
+c-----------------------------------------------------------------------
+c    Traitement Phisinit
+c-----------------------------------------------------------------------
+
+      phisinit(1:iimp1*jjp1)=1000.*phisinit(1:iimp1*jjp1)
+      !CALL dump2d(iimp1,jjp1,phisinit,'Altitude en m')
+      phisinit(:)=g*phisinit(:)
+
+c-----------------------------------------------------------------------
+c    FIN
+c-----------------------------------------------------------------------
+
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/defrun_new.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/defrun_new.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/defrun_new.F	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/defrun_new.F
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/exner_hyb.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/exner_hyb.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/exner_hyb.F	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/exner_hyb.F
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/grid_noro1.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/grid_noro1.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/grid_noro1.F	(revision 1644)
@@ -0,0 +1,425 @@
+      SUBROUTINE grid_noro1(imdep, jmdep, xdata, ydata, entree,
+     .                 imar, jmar, x, y, zmea,zstd,zsig,zgam,zthe)
+c=======================================================================
+c (F. Lott) (voir aussi z.x. Li, A. Harzallah et L. Fairhead)
+c
+c      Calcul des parametres de l'orographie sous-maille necessaires
+c      au nouveau shema de representation des montagnes meso-echelles
+c      dans le modele.  Les points sont mis sur une grille rectangulaire
+c      pseudo-physique.  Typiquement, il y a iim+1 latitudes incluant
+c      le pole nord et le pole sud.  Il y a jjm+1 longitudes, y compris
+c      aux poles.  Aux poles les champs peuvent ont une valeurs repetee
+c      jjm+1 fois.....  La valeur du champs en jjm+1 (jmar) est celle
+c      en j=1.  
+c      Les parametres a,b,c,d representent les limites de la region
+c      de point de grille correspondant a un point decrit precedemment.
+c      Les moyennes sur ces regions des valeurs calculees a partir de
+c      l'USN, sont ponderees par un poids, fonction de la surface
+c      occuppe par ces donnees a l'interieure de la grille du modele.
+c      Dans la plupart des cas ce poid est le rapport entre la surface
+c      de la region de point de grille USN et la surface de la region
+c      de point de grille du modele.
+c       
+c
+c           (c)
+c        ----d-----
+c        | . . . .|
+c        |        |
+c     (b)a . * . .b(a)
+c        |        |
+c        | . . . .|
+c        ----c-----
+c           (d)
+C=======================================================================
+c INPUT:
+c        imdep, jmdep: dimensions X et Y pour depart
+c        xdata, ydata: coordonnees X et Y pour depart
+c        entree: champ d'entree a transformer
+c        dans ce programme, on assume que les donnees sont les altitudes
+c        de l'USNavy: imdep=iusn=2160, jmdep=jusn=1080.
+c OUTPUT:
+c        imar, jmar: dimensions X et Y d'arrivee
+c        x, y: coordonnees X et Y d'arrivee
+c        les champs de sorties sont sur une grille physique:
+c             zmea:  orographie moyenne
+c             zstd:  deviation standard de l'orographie sous-maille
+c             zsig:  pente de l'orographie sous-maille 
+c             zgam:  anisotropy de l'orographie sous maille
+c             zthe:  orientation de l'axe oriente dans la direction
+c                    de plus grande pente de l'orographie sous maille
+C=======================================================================
+c     IMPLICIT INTEGER (I,J)
+c     IMPLICIT REAL(X,Z) 
+
+       USE comconst_mod, ONLY: rad
+
+       implicit none
+       integer iusn,jusn,iext
+       parameter(iusn=360,jusn=180,iext=40)
+c!-*-      include 'param1'
+c!-*-      include 'comcstfi.h'
+#include "dimensions.h"
+c!-*-
+c!-*-      parameter(iim=cols,jjm=rows)
+      REAL xusn(iusn+2*iext),yusn(jusn+2)	
+      REAL zusn(iusn+2*iext,jusn+2),zusnfi(iusn+2*iext,jusn+2)
+
+c   modif declarations pour implicit none
+      real zmeanor,zmeasud,zstdnor,zstdsud,zsignor
+      real zsigsud,zweinor,zweisud
+      real xk,xl,xm,xw,xp,xq
+      real zmaxmea,zmaxstd,zmaxsig,zmaxgam,zmaxthe,zminthe
+      real zbordnor,zbordsud,zbordest,zbordoue,xpi
+      real zdeltax,zdeltay,zlenx,zleny,weighx,weighy,xincr
+      integer i,j,ii,jj,ideltax,ihalph
+
+      INTEGER imdep, jmdep
+      REAL xdata(imdep),ydata(jmdep) 
+      REAL entree(imdep,jmdep)
+c
+      INTEGER imar, jmar
+  
+      REAL ztz(iim+1,jjm+1),zxtzx(iim+1,jjm+1)
+      REAL zytzy(iim+1,jjm+1),zxtzy(iim+1,jjm+1)
+      REAL zxtzxusn(iusn+2*iext,jusn+2),zytzyusn(iusn+2*iext,jusn+2)
+      REAL zxtzyusn(iusn+2*iext,jusn+2)
+      REAL weight(iim+1,jjm+1)
+      REAL x(imar+1),y(jmar)
+      REAL zmea(imar+1,jmar),zstd(imar+1,jmar)
+      REAL zsig(imar+1,jmar),zgam(imar+1,jmar),zthe(imar+1,jmar)
+c
+      REAL a(2200),b(2200),c(1100),d(1100)
+c
+c  quelques constantes:
+c
+      print *,' parametres de l orographie a l echelle sous maille' 
+      print*,'rad =',rad
+      print*,'Long et lat entree'
+      print*,(x(i),i=1,imar+1)
+      print*,(y(j),j=1,jmar)
+       print*,'Long et lat donnees'
+      print*,(xdata(i),i=1,imdep)
+      print*,(ydata(j),j=1,jmdep)
+
+      xpi=acos(-1.)
+      zdeltay=2.*xpi/float(jusn)*rad
+c
+c  quelques tests de dimensions:
+c    
+      IF (imar.GT.2200 .OR. jmar.GT.1100) THEN
+         PRINT*, 'imar ou jmar trop grand', imar, jmar
+         CALL ABORT
+      ENDIF
+
+      IF(imdep.ne.iusn.or.jmdep.ne.jusn)then
+         print *,' imdep ou jmdep mal dimensionnes:',imdep,jmdep
+         call abort
+      ENDIF
+
+      IF(imar+1.gt.iim+1.or.jmar.gt.jjm+1)THEN
+        print *,' imar ou jmar mal dimensionnes:',imar,jmar
+        call abort
+      ENDIF
+c
+C  Extension de la base de donnee de l'USN pour faciliter
+C  les calculs ulterieurs:
+c
+      DO j=1,jusn
+        yusn(j+1)=ydata(j)
+      DO i=1,iusn
+        zusn(i+iext,j+1)=entree(i,j)
+        xusn(i+iext)=xdata(i)
+      ENDDO
+      DO i=1,iext
+        zusn(i,j+1)=entree(iusn-iext+i,j)
+        xusn(i)=xdata(iusn-iext+i)-2.*xpi
+        zusn(iusn+iext+i,j+1)=entree(i,j)
+        xusn(iusn+iext+i)=xdata(i)+2.*xpi
+      ENDDO
+      ENDDO
+
+        yusn(1)=ydata(1)+(ydata(1)-ydata(2))
+        yusn(jusn+2)=ydata(jusn)+(ydata(jusn)-ydata(jusn-1))
+       DO i=1,iusn/2+iext
+        zusn(i,1)=zusn(i+iusn/2,2)
+        zusn(i+iusn/2+iext,1)=zusn(i,2)
+        zusn(i,jusn+2)=zusn(i+iusn/2,jusn+1)
+        zusn(i+iusn/2+iext,jusn+2)=zusn(i,jusn+1)
+       ENDDO
+c
+c  Calcul d'une orographie filtree aux hautes latitudes
+c  pour permettre des calculs plus isotropiques sur la pente
+c  des montagnes
+c
+       DO i=1,IUSN+2*iext
+       DO J=1,JUSN+2
+          zusnfi(i,j)=0.0
+       ENDDO
+       ENDDO
+
+      DO j=1,jusn
+            ideltax=1./cos(yusn(j+1))
+            ideltax=min(iusn/2-1,ideltax)
+            IF(MOD(IDELTAX,2).EQ.0)THEN
+              IDELTAX=IDELTAX+1
+            ENDIF
+            IHALPH=(IDELTAX-1)/2 
+c           print *,' ideltax=',ideltax
+         IF(ideltax.eq.1)THEN
+            DO i=1,iusn
+               zusnfi(i+iext,j+1)=entree(i,j)
+            ENDDO   
+         ELSE
+            DO i=1,ihalph
+               DO ii=1,i+ihalph
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)+entree(ii,j)
+               ENDDO
+               DO ii=ihalph-i,0,-1
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)+entree(iusn-ii,j)
+               ENDDO  
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)/float(ideltax)
+            ENDDO   
+            DO i=iusn-ihalph+1,iusn
+               DO ii = i-ihalph,iusn
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)+entree(ii,j)
+               ENDDO 
+               DO ii = 1,ihalph+i-iusn
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)+entree(ii,j)
+               ENDDO
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)/float(ideltax)
+            ENDDO
+            DO i=ihalph+1,iusn-ihalph
+               DO ii=-ihalph,ihalph
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)+entree(i+ii,j)
+               ENDDO
+               zusnfi(i+iext,j+1)=zusnfi(i+iext,j+1)/float(ideltax)
+            ENDDO
+         ENDIF
+            DO i=1,iext
+               zusnfi(i,j+1)=zusnfi(iusn-iext+i,j+1)
+               zusnfi(i+iusn+iext,j+1)=zusnfi(i,j+1)
+            ENDDO
+      ENDDO
+c  
+c Calculer les limites des zones des nouveaux points
+c
+      a(1) = x(1) - (x(2)-x(1))/2.0
+      b(1) = (x(1)+x(2))/2.0
+      DO i = 2, imar-1
+         a(i) = b(i-1)
+         b(i) = (x(i)+x(i+1))/2.0
+      ENDDO
+      a(imar) = b(imar-1)
+      b(imar) = x(imar) + (x(imar)-x(imar-1))/2.0
+
+      c(1) = y(1) - (y(2)-y(1))/2.0
+      d(1) = (y(1)+y(2))/2.0
+      DO j = 2, jmar-1
+         c(j) = d(j-1)
+         d(j) = (y(j)+y(j+1))/2.0
+      ENDDO
+      c(jmar) = d(jmar-1)
+      d(jmar) = y(jmar) + (y(jmar)-y(jmar-1))/2.0
+c
+c      quelques initialisations:
+      print*,'OKM1'
+c
+      DO i = 1, imar
+      DO j = 1, jmar
+         weight(i,j) = 0.0
+         zxtzx(i,j) = 0.0
+         zytzy(i,j) = 0.0
+         zxtzy(i,j) = 0.0
+         ztz(i,j) = 0.0
+         zmea(i,j) = 0.0
+         zstd(i,j)=0.0
+      ENDDO
+      ENDDO
+c
+c  calculs des correlations de pentes sur la grille de l'USN.
+c
+         DO j = 2,jusn+1 
+         DO i = 1, iusn+2*iext
+            zytzyusn(i,j)=0.0
+            zxtzxusn(i,j)=0.0
+            zxtzyusn(i,j)=0.0
+         ENDDO
+         ENDDO
+
+
+         DO j = 2,jusn+1 
+            zdeltax=zdeltay*cos(yusn(j))
+         DO i = 2, iusn+2*iext-1
+            zytzyusn(i,j)=(zusn(i,j+1)-zusn(i,j-1))**2/zdeltay**2
+            zxtzxusn(i,j)=(zusnfi(i+1,j)-zusnfi(i-1,j))**2/zdeltax**2
+            zxtzyusn(i,j)=(zusn(i,j+1)-zusn(i,j-1))/zdeltay
+     *                   *(zusnfi(i+1,j)-zusnfi(i-1,j))/zdeltax
+         ENDDO
+
+         ENDDO
+
+ 
+
+      print*,'OK0'
+c
+c  sommations des differentes quantites definies precedemment
+c  sur une grille du modele.
+c 
+      zleny=xpi/float(jusn)*rad
+      xincr=xpi/2./float(jusn)
+       DO ii = 1, imar
+       DO jj = 1, jmar
+c        PRINT *,' iteration ii jj:',ii,jj
+         DO j = 2,jusn+1 
+c         DO j = 3,jusn 
+            zlenx=zleny*cos(yusn(j))
+            zdeltax=zdeltay*cos(yusn(j))
+            zbordnor=(c(jj)-yusn(j)+xincr)*rad
+            zbordsud=(yusn(j)-d(jj)+xincr)*rad
+            weighy=amax1(0.,
+     *             amin1(zbordnor,zbordsud,zleny))
+         IF(weighy.ne.0)THEN
+         DO i = 2, iusn+2*iext-1
+            zbordest=(xusn(i)-a(ii)+xincr)*rad*cos(yusn(j))
+            zbordoue=(b(ii)+xincr-xusn(i))*rad*cos(yusn(j))
+            weighx=amax1(0.,
+     *             amin1(zbordest,zbordoue,zlenx))
+            IF(weighx.ne.0)THEN
+            weight(ii,jj)=weight(ii,jj)+weighx*weighy
+            zxtzx(ii,jj)=zxtzx(ii,jj)+zxtzxusn(i,j)*weighx*weighy
+            zytzy(ii,jj)=zytzy(ii,jj)+zytzyusn(i,j)*weighx*weighy
+            zxtzy(ii,jj)=zxtzy(ii,jj)+zxtzyusn(i,j)*weighx*weighy
+            ztz(ii,jj)  =ztz(ii,jj)  +zusn(i,j)*zusn(i,j)*weighx*weighy
+            zmea(ii,jj) =zmea(ii,jj)+zusn(i,j)*weighx*weighy
+            ENDIF
+         ENDDO
+         ENDIF
+         ENDDO
+       ENDDO
+       ENDDO
+c
+c  calculs des differents parametres necessaires au programme
+c  de parametrisation de l'orographie a l'echelle moyenne:
+c
+      zmaxmea=0.
+      zmaxstd=0.
+      zmaxsig=0.
+      zmaxgam=0.
+      zmaxthe=0.
+      zminthe=0.
+c     print 100,' '
+c100  format(1X,A1,'II JJ',4X,'H',8X,'SD',8X,'SI',3X,'GA',3X,'TH') 
+       print*,'OK1'
+       DO ii = 1, imar
+       DO jj = 1, jmar
+c       print*,'ok0'
+         IF (weight(ii,jj) .NE. 0.0) THEN
+c  Orography moyenne:
+c         print*,'ok1'
+           zmea (ii,jj)=zmea (ii,jj)/weight(ii,jj)
+           zxtzx(ii,jj)=zxtzx(ii,jj)/weight(ii,jj)
+           zytzy(ii,jj)=zytzy(ii,jj)/weight(ii,jj)
+           zxtzy(ii,jj)=zxtzy(ii,jj)/weight(ii,jj)
+           ztz(ii,jj)  =ztz(ii,jj)/weight(ii,jj)
+c         print*,'ok2'
+c  Deviation standard:
+           zstd(ii,jj)=sqrt(amax1(0.,ztz(ii,jj)-zmea(ii,jj)**2))
+c  Coefficients K, L et M:
+           xk=(zxtzx(ii,jj)+zytzy(ii,jj))/2.
+           xl=(zxtzx(ii,jj)-zytzy(ii,jj))/2.
+           xm=zxtzy(ii,jj)
+           xp=xk-sqrt(xl**2+xm**2)
+           xq=xk+sqrt(xl**2+xm**2)
+           xw=1.e-8
+           if(xp.le.xw) xp=0.
+           if(xq.le.xw) xq=xw
+           if(abs(xm).le.xw) xm=xw*sign(1.,xm)
+c          print*,'ok3'
+c pente: 
+           zsig(ii,jj)=sqrt(xq)
+c           zsig(ii,jj)=sqrt(2.*xk)
+c isotropy:
+           zgam(ii,jj)=xp/xq
+c angle theta:
+           zthe(ii,jj)=57.29577951*atan2(xm,xl)/2.
+
+c          print 101,ii,jj,
+c    *           zmea(ii,jj),zstd(ii,jj),zsig(ii,jj),zgam(ii,jj),
+c    *           zthe(ii,jj)
+c101  format(1x,2(1x,i2),2(1x,f7.1),1x,f7.4,2x,f4.2,1x,f5.1)     
+c          print*,'ok4'
+         ELSE
+c           PRINT*, 'probleme,ii,jj=', ii,jj
+c          print*,'ok1b'
+         ENDIF
+      zmaxmea=amax1(zmea(ii,jj),zmaxmea)
+c         print*,'oka'
+      zmaxstd=amax1(zstd(ii,jj),zmaxstd)
+c         print*,'okb'
+      zmaxsig=amax1(zsig(ii,jj),zmaxsig)
+c         print*,'okc'
+      zmaxgam=amax1(zgam(ii,jj),zmaxgam)
+c         print*,'okd'
+      zmaxthe=amax1(zthe(ii,jj),zmaxthe)
+c         print*,'oke'
+      zminthe=amin1(zthe(ii,jj),zminthe)
+c      print*,'ok5'
+       ENDDO
+       ENDDO
+
+      print *,'  MEAN ORO:',zmaxmea
+	  print *,'  ST. DEV.:',zmaxstd
+      print *,'  PENTE:',zmaxsig
+      print *,' ANISOTROP:',zmaxgam
+      print *,'  ANGLE:',zminthe,zmaxthe	
+      
+C
+c  On passe ce donnees sur la grille dite physique....(?)
+c  On met gamma et theta a 1. et 0. aux poles ou ces quantites
+c  n'ont pas vraiment de sens
+c
+      DO jj=1,jmar
+      zmea(imar+1,jj)=zmea(1,jj)
+      zstd(imar+1,jj)=zstd(1,jj)
+      zsig(imar+1,jj)=zsig(1,jj)
+      zgam(imar+1,jj)=zgam(1,jj)
+      zthe(imar+1,jj)=zthe(1,jj)
+      ENDDO
+
+
+      zmeanor=0.0
+      zmeasud=0.0
+      zstdnor=0.0
+      zstdsud=0.0
+      zsignor=0.0
+      zsigsud=0.0
+      zweinor=0.0
+      zweisud=0.0
+
+      DO ii=1,imar
+      zweinor=zweinor+              weight(ii,   1)
+      zweisud=zweisud+              weight(ii,jmar)
+      zmeanor=zmeanor+zmea(ii,   1)*weight(ii,   1)
+      zmeasud=zmeasud+zmea(ii,jmar)*weight(ii,jmar)
+      zstdnor=zstdnor+zstd(ii,   1)*weight(ii,   1)
+      zstdsud=zstdsud+zstd(ii,jmar)*weight(ii,jmar)
+      zsignor=zsignor+zsig(ii,   1)*weight(ii,   1)
+      zsigsud=zsigsud+zsig(ii,jmar)*weight(ii,jmar)
+      ENDDO
+
+      DO ii=1,imar+1
+      zmea(ii,   1)=zmeanor/zweinor
+      zmea(ii,jmar)=zmeasud/zweisud
+      zstd(ii,   1)=zstdnor/zweinor
+      zstd(ii,jmar)=zstdsud/zweisud
+      zsig(ii,   1)=zsignor/zweinor
+      zsig(ii,jmar)=zsigsud/zweisud
+      zgam(ii,   1)=1.
+      zgam(ii,jmar)=1.
+      zthe(ii,   1)=0.
+      zthe(ii,jmar)=0.
+      ENDDO
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/ini_archive.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/ini_archive.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/ini_archive.F	(revision 1644)
@@ -0,0 +1,529 @@
+c=======================================================================
+      subroutine ini_archive(nid,idayref,phis,ith,tab_cntrl_fi,
+     &                       tab_cntrl_dyn)
+c=======================================================================
+c
+c
+c   Date:    01/1997
+c   ----
+c
+c   Objet:  ecriture de l'entete du fichier "start_archive"
+c   -----
+c
+c	 Proche de iniwrite.F
+c
+c	 On ajoute dans le tableau "tab_cntrl" (dynamique), a partir de 51, 
+c	 les valeurs de tab_cntrl_fi (les 38 parametres de controle physiques
+c	 du RUN + ptotal et cotoicetotal)
+c
+c			tab_cntrl(50+l)=tab_cntrl_fi(l)
+c
+c   Arguments:
+c   ---------
+c
+c	Inputs:
+c   ------
+c
+c       nid            unite logique du fichier "start_archive"
+c       idayref        Valeur du jour initial a mettre dans
+c                      l'entete du fichier "start_archive"
+c       phis           geopotentiel au sol
+c       ith            soil thermal inertia
+c       tab_cntrl_fi   tableau des param physiques
+c
+
+c=======================================================================
+
+      USE comsoil_h
+      USE slab_ice_h, only: noceanmx
+!      use control_mod
+      USE comvert_mod, ONLY: ap,bp,aps,bps,presnivs,pseudoalt
+      USE comconst_mod, ONLY: daysec,dtvr,rad,omeg,g,kappa,pi
+      implicit none
+
+#include "dimensions.h"
+!#include "dimphys.h"
+#include "paramet.h"
+#include "comgeom.h"
+!#include "control.h"
+
+#include "netcdf.inc"
+
+c-----------------------------------------------------------------------
+c   Declarations
+c-----------------------------------------------------------------------
+
+c   Local:
+c   ------
+      INTEGER	length,l
+      parameter (length = 100)
+      REAL		tab_cntrl(length) ! tableau des parametres du run
+      INTEGER	loop
+      INTEGER	ierr, setvdim, putvdim, putdat, setname,cluvdb
+      INTEGER	setdim
+      INTEGER	ind1,indlast
+
+c   Arguments:
+c   ----------
+      INTEGER*4	idayref
+      REAL		phis(ip1jmp1)
+      real ith(ip1jmp1,nsoilmx)
+      REAL		tab_cntrl_fi(length)
+      REAL tab_cntrl_dyn(length)
+
+!Mars --------Ajouts-----------
+c   Variables locales pour NetCDF:
+c
+      INTEGER dims2(2), dims3(3) !, dims4(4)
+      INTEGER idim_index
+      INTEGER idim_rlonu, idim_rlonv, idim_rlatu, idim_rlatv
+      INTEGER idim_llmp1,idim_llm
+      INTEGER idim_tim
+      INTEGER idim_nsoilmx ! "subsurface_layers" dimension ID #
+      INTEGER idim_noceanmx ! "ocean_layers" dimension ID #
+      INTEGER nid,nvarid
+      real sig_s(llm),s(llm)
+
+      pi  = 2. * ASIN(1.)
+
+
+c-----------------------------------------------------------------------
+c   Remplissage du tableau des parametres de controle du RUN  (dynamique)
+c-----------------------------------------------------------------------
+
+      DO l=1,length
+         tab_cntrl(l)=0.
+      ENDDO
+      
+      tab_cntrl(1:50)=tab_cntrl_dyn(1:50)
+
+ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+!      tab_cntrl(1)  = FLOAT(iim) ! nombre de points en longitude
+!      tab_cntrl(2)  = FLOAT(jjm) ! nombre de points en latitude
+!      tab_cntrl(3)  = FLOAT(llm) ! nombre de couches
+!      tab_cntrl(4)  = FLOAT(idayref) ! jour 0
+!      tab_cntrl(5)  = rad ! rayon de mars(m) ~3397200
+!      tab_cntrl(6)  = omeg ! vitesse de rotation (rad.s-1)
+!      tab_cntrl(7)  = g   ! gravite (m.s-2) ~3.72
+!      tab_cntrl(8)  = cpp 
+!      tab_cntrl(8)  = 43.49 !mars temporaire Masse molaire de l''atm (g.mol-1) ~43.49
+!      tab_cntrl(9)  = kappa ! = r/cp  ~0.256793 (=rcp dans physique)
+!      tab_cntrl(10) = daysec ! duree du sol (s)  ~88775
+!      tab_cntrl(11) = dtvr ! pas de temps de la dynamique (s)
+!      tab_cntrl(12) = etot0 ! energie totale    !
+!      tab_cntrl(13) = ptot0 ! pression totalei   !    variables
+!      tab_cntrl(14) = ztot0 ! enstrophie totale   !  de controle
+!      tab_cntrl(15) = stot0 ! enthalpie totale   !    globales
+!      tab_cntrl(16) = ang0 ! moment cinetique  !
+!      tab_cntrl(17) = pa
+!      tab_cntrl(18) = preff
+
+c    .....    parametres  pour le zoom      ......   
+
+!      tab_cntrl(19)  = clon ! longitude en degres du centre du zoom
+!      tab_cntrl(20)  = clat ! latitude en degres du centre du zoom
+!      tab_cntrl(21)  = grossismx ! facteur de grossissement du zoom,selon longitude
+!      tab_cntrl(22)  = grossismy ! facteur de grossissement du zoom ,selon latitude
+
+!      IF ( fxyhypb )   THEN
+!       tab_cntrl(23) = 1.
+!       tab_cntrl(24) = dzoomx ! extension en longitude  de la zone du zoom
+!       tab_cntrl(25) = dzoomy ! extension en latitude  de la zone du zoom
+!      ELSE
+!       tab_cntrl(23) = 0.
+!       tab_cntrl(24) = dzoomx ! extension en longitude  de la zone du zoom
+!       tab_cntrl(25) = dzoomy ! extension en latitude  de la zone du zoom
+!       tab_cntrl(26) = 0.
+!       IF ( ysinus)  tab_cntrl(26) = 1.
+!      ENDIF
+
+c-----------------------------------------------------------------------
+c   Copie du tableau des parametres de controle du RUN  (physique)
+c		dans le tableau tab_cntrl
+c-----------------------------------------------------------------------
+
+      DO l=1,50
+         tab_cntrl(50+l)=tab_cntrl_fi(l)
+      ENDDO
+
+c=======================================================================
+c	Ecriture NetCDF de l''entete du fichier "start_archive"
+c=======================================================================
+
+c
+c Preciser quelques attributs globaux:
+c
+      ierr = NF_PUT_ATT_TEXT (nid, NF_GLOBAL, "title", 21,
+     &                       "Fichier start_archive")
+c
+c Definir les dimensions du fichiers:
+c
+c     CHAMPS AJOUTES POUR LA VISUALISATION T,ps, etc... avec Grads ou ferret:
+      ierr = NF_DEF_DIM (nid, "latitude", jjp1, idim_rlatu)
+      ierr = NF_DEF_DIM (nid, "longitude", iip1, idim_rlonv)
+      ierr = NF_DEF_DIM (nid, "altitude", llm, idim_llm)
+      ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoilmx,idim_nsoilmx)
+      ierr = NF_DEF_DIM (nid,"ocean_layers",noceanmx,idim_noceanmx)
+
+      ierr = NF_DEF_DIM (nid,"index", length, idim_index)
+      ierr = NF_DEF_DIM (nid,"rlonu", iip1, idim_rlonu)
+      ierr = NF_DEF_DIM (nid,"rlatv", jjm, idim_rlatv)
+      ierr = NF_DEF_DIM (nid,"interlayer", llmp1, idim_llmp1)
+      ierr = NF_DEF_DIM (nid,"Time", NF_UNLIMITED, idim_tim)
+
+c
+      ierr = NF_ENDDEF(nid) ! sortir du mode de definition
+
+c-----------------------------------------------------------------------
+c  Ecriture du tableau des parametres du run
+c-----------------------------------------------------------------------
+
+      call def_var(nid,"Time","Time","days since 00:00:00",1,
+     .            idim_tim,nvarid,ierr)
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"controle",NF_DOUBLE,1,idim_index,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"controle",NF_FLOAT,1,idim_index,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Parametres de controle")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture des longitudes et latitudes
+c-----------------------------------------------------------------------
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_DOUBLE,1,idim_rlonu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonu",NF_FLOAT,1,idim_rlonu,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_DOUBLE,1,idim_rlatu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatu",NF_FLOAT,1,idim_rlatu,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_DOUBLE,1,idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlonv",NF_FLOAT,1,idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 23,
+     .                       "Longitudes des points V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_DOUBLE,1,idim_rlatv,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"rlatv",NF_FLOAT,1,idim_rlatv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Latitudes des points V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture des niveaux verticaux
+c-----------------------------------------------------------------------
+
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"ap",NF_DOUBLE,1,idim_llmp1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"ap",NF_FLOAT,1,idim_llmp1,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 32,
+     .                       "Coef A: niveaux pression hybride")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
+#endif
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"bp",NF_DOUBLE,1,idim_llmp1,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"bp",NF_FLOAT,1,idim_llmp1,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 35,
+     .                       "Coefficient B niveaux sigma hybride")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bp)
+#endif
+c
+c ----------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"aps",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"aps",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 36,
+     .      "Coef AS: hybrid pressure in midlayers")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aps)
+#endif
+c
+c ----------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"bps",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"bps",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 30,
+     .      "Coef BS: hybrid sigma midlayers")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bps)
+#endif
+c
+c ----------------------
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_DOUBLE,1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"presnivs",NF_FLOAT,1,idim_llm,nvarid)
+#endif
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,presnivs)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,presnivs)
+#endif
+c ------------------------------------------------------------------
+c  Variable uniquement pour visualisation avec Grads ou Ferret
+c ------------------------------------------------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"latitude",NF_DOUBLE,1,idim_rlatu,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"latitude",NF_FLOAT,1,idim_rlatu,nvarid)
+#endif
+      ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "North latitude")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatu/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatu/pi*180)
+#endif
+c----------------------
+       ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "East longitude")
+      ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonv/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonv/pi*180)
+#endif
+c--------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1,
+     .       idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1,
+     .       idim_llm,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",10,"pseudo-alt")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up")
+
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt)
+#endif
+
+!-------------------------------
+! (soil) depth variable mlayer() (known from comsoil.h)
+!-------------------------------
+      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
+      ! define variable
+#ifdef NC_DOUBLE
+      ierr=NF_DEF_VAR(nid,"soildepth",NF_DOUBLE,1,idim_nsoilmx,nvarid)
+#else
+      ierr=NF_DEF_VAR(nid,"soildepth",NF_FLOAT,1,idim_nsoilmx,nvarid)
+#endif
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 20,
+     .                        "Soil mid-layer depth")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",1,"m")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"positive",4,"down")
+      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
+      ! write variable
+#ifdef NC_DOUBLE
+      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,mlayer)
+#else
+      ierr=NF_PUT_VAR_REAL (nid,nvarid,mlayer)
+#endif
+
+!---------------------
+! soil thermal inertia
+!---------------------
+      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
+      dims3(1)=idim_rlonv
+      dims3(2)=idim_rlatu
+      dims3(3)=idim_nsoilmx
+      ! define variable
+#ifdef NC_DOUBLE
+      ierr=NF_DEF_VAR(nid,"inertiedat",NF_DOUBLE,3,dims3,nvarid)
+#else
+      ierr=NF_DEF_VAR(nid,"inertiedat",NF_FLOAT,3,dims3,nvarid)
+#endif
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 20,
+     &                        "Soil thermal inertia")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",15,
+     &                        "J.s-1/2.m-2.K-1")
+      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
+      ! write variable
+#ifdef NC_DOUBLE
+      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,ith)
+#else
+      ierr=NF_PUT_VAR_REAL (nid,nvarid,ith)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture aire et coefficients de passage cov. <-> contra. <--> naturel
+c-----------------------------------------------------------------------
+
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonu
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cu",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cu",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour U")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
+#endif
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatv
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"cv",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"cv",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 29,
+     .                       "Coefficient de passage pour V")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
+#endif
+c
+c Aire de chaque maille:
+c
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"aire",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"aire",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 22,
+     .                       "Aires de chaque maille")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aire)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aire)
+#endif
+
+c-----------------------------------------------------------------------
+c  Ecriture du geopentiel au sol
+c-----------------------------------------------------------------------
+
+      ierr = NF_REDEF (nid)
+      dims2(1) = idim_rlonv
+      dims2(2) = idim_rlatu
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_DOUBLE,2,dims2,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"phisinit",NF_FLOAT,2,dims2,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 19,
+     .                       "Geopotentiel au sol")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,phis)
+#endif
+
+      PRINT*,'ini_archive: iim,jjm,llm,idayref',iim,jjm,llm,idayref
+      PRINT*,'ini_archive: rad,omeg,g,mugaz,kappa',
+     s rad,omeg,g,tab_cntrl_fi(8),kappa
+      PRINT*,'ini_archive: daysec,dtvr',daysec,dtvr
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/iniphysiq_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/iniphysiq_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/iniphysiq_mod.F90	(revision 1644)
@@ -0,0 +1,99 @@
+MODULE iniphysiq_mod
+
+CONTAINS
+
+subroutine iniphysiq(ii,jj,nlayer, &
+                     nbp, communicator, &
+                     punjours, pdayref,ptimestep, &
+                     rlatudyn,rlatvdyn,rlonudyn,rlonvdyn, &
+                     airedyn,cudyn,cvdyn, &
+                     prad,pg,pr,pcpp,iflag_phys)
+
+use control_mod, only: nday 
+use surf_heat_transp_mod, only: ini_surf_heat_transp
+use infotrac, only : nqtot ! number of advected tracers
+use planete_mod, only: ini_planete_mod
+USE comvert_mod, ONLY: ap,bp,preff
+use inifis_mod, only: inifis
+use ioipsl_getin_p_mod, only: getin_p
+
+use inigeomphy_mod, only: inigeomphy
+use geometry_mod, only: cell_area, & ! physics grid area (m2)
+                        longitude, & ! longitudes (rad)
+                        latitude ! latitudes (rad)
+! necessary to get klon_omp
+USE mod_phys_lmdz_para, ONLY: klon_omp ! number of columns (on local omp grid)
+USE dimphy, ONLY: init_dimphy
+
+implicit none
+include "dimensions.h"
+include "paramet.h"
+include "comgeom.h"
+include "iniprint.h"
+
+real,intent(in) :: prad ! radius of the planet (m)
+real,intent(in) :: pg ! gravitational acceleration (m/s2)
+real,intent(in) :: pr ! ! reduced gas constant R/mu
+real,intent(in) :: pcpp ! specific heat Cp
+real,intent(in) :: punjours ! length (in s) of a standard day
+integer,intent(in) :: nlayer ! number of atmospheric layers
+integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes
+integer,intent(in) :: jj  ! number of atompsheric columns along latitudes
+integer,intent(in) :: nbp ! number of physics columns for this MPI process
+integer,intent(in) :: communicator ! MPI communicator
+real,intent(in) :: rlatudyn(jj+1) ! latitudes of the physics grid
+real,intent(in) :: rlatvdyn(jj) ! latitude boundaries of the physics grid
+real,intent(in) :: rlonvdyn(ii+1) ! longitudes of the physics grid
+real,intent(in) :: rlonudyn(ii+1) ! longitude boundaries of the physics grid
+real,intent(in) :: airedyn(ii+1,jj+1) ! area of the dynamics grid (m2)
+real,intent(in) :: cudyn((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
+real,intent(in) :: cvdyn((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
+integer,intent(in) :: pdayref ! reference day of for the simulation
+real,intent(in) :: ptimestep !physics time step (s)
+integer,intent(in) :: iflag_phys ! type of physics to be called
+
+logical :: ok_slab_ocean
+
+  ! the common part for all planetary physics
+  !------------------------------------------
+  ! --> initialize physics distribution, global fields and geometry
+  ! (i.e. things in phy_common or dynphy_lonlat)
+  CALL inigeomphy(ii,jj,nlayer, &
+               nbp, communicator, &
+               rlatudyn,rlatvdyn, &
+               rlonudyn,rlonvdyn, &
+               airedyn,cudyn,cvdyn)
+
+  ! the distinct part for all planetary physics (ie. things in phystd)
+  !------------------------------------------
+
+!$OMP PARALLEL
+
+! copy some fundamental parameters to physics
+! and do some initializations
+
+! Initialize dimphy module
+call init_dimphy(klon_omp,nlayer)
+
+! copy over preff , ap() and bp() 
+call ini_planete_mod(nlayer,preff,ap,bp)
+
+! for slab ocean, copy over some arrays
+ok_slab_ocean=.false. ! default value
+call getin_p("ok_slab_ocean",ok_slab_ocean)
+if (ok_slab_ocean) then
+  call ini_surf_heat_transp(ip1jm,ip1jmp1,unsairez,fext,unsaire, &
+                            cu,cuvsurcv,cv,cvusurcu,aire,apoln,apols, &
+                            aireu,airev)
+endif
+
+call inifis(klon_omp,nlayer,nqtot,pdayref,punjours,nday,ptimestep, &
+            latitude,longitude,cell_area,prad,pg,pr,pcpp)
+
+
+!$OMP END PARALLEL
+
+end subroutine iniphysiq
+
+
+END MODULE iniphysiq_mod
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/interp_vert.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/interp_vert.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/interp_vert.F	(revision 1644)
@@ -0,0 +1,70 @@
+c******************************************************
+      SUBROUTINE   interp_vert(varo,varn,lmo,lmn,apso,bpso,
+     &             aps,bps,ps,Nhoriz)
+c
+c interpolation lineaire pour passer
+c a une nouvelle discretisation verticale pour
+c les variables de GCM
+c Francois Forget (01/1995)
+c Modif pour coordonnees hybrides FF (03/2003)
+c**********************************************************
+
+      IMPLICIT NONE
+
+c   Declarations:
+c ==============
+c
+c  ARGUMENTS
+c  """""""""
+
+       integer lmo ! dimensions ancienne couches (input)
+       integer lmn ! dimensions nouvelle couches (input)
+
+       real apso(lmo),bpso(lmo)! anciennes coord hybrides midlayer (input)
+       real aps(lmn), bps(lmn)! nouvelles coord hybrides (midlayer) (input)
+
+       integer Nhoriz ! nombre de point horizontale (input)
+       real ps(nhoriz) !pression de surface (input)
+
+       real varo(Nhoriz,lmo) ! var dans l''ancienne grille (input)
+       real varn(Nhoriz,lmn) ! var dans la nouvelle grille (output)
+
+c Autres variables
+c """"""""""""""""
+       integer n, ln ,lo 
+       real coef
+       REAL sigmo(lmo) ! niveau sigma des variables dans les anciennes coord
+       REAL sigmn(lmn) ! niveau sigma des variables dans les nouvelles coord
+
+c run
+c ====
+
+      do n=1,Nhoriz
+        do ln=1,lmn
+            sigmn(ln)=aps(ln)/ps(n)+bps(ln)
+        end do
+        do lo=1,lmo
+            sigmo(lo)=apso(lo)/ps(n)+bpso(lo)
+        end do
+
+        do ln=1,lmn
+           if (sigmn(ln).ge.sigmo(1))then
+             varn(n,ln) =  varo(n,1)  
+           else if (sigmn(ln).le.sigmo(lmo)) then
+             varn(n,ln) =  varo(n,lmo)
+           else
+              do lo =1,lmo-1 
+                if ( (sigmn(ln).le.sigmo(lo)).and.
+     &             (sigmn(ln).gt.sigmo(lo+1)) )then
+                  coef = (sigmn(ln)-sigmo(lo))/(sigmo(lo+1)-sigmo(lo))
+                   varn(n,ln)=varo(n,lo) +coef*(varo(n,lo+1)-varo(n,lo))
+                end if
+              end do           
+           end if
+         end do
+
+      end do
+
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/lect_start_archive.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/lect_start_archive.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/lect_start_archive.F	(revision 1644)
@@ -0,0 +1,1492 @@
+      SUBROUTINE lect_start_archive(ngrid,nlayer,
+     &     date,tsurf,tsoil,emis,q2,
+     &     t,ucov,vcov,ps,h,phisold_newgrid,
+     &     q,qsurf,surfith,nid,
+     &     rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+
+!      USE surfdat_h
+      USE comsoil_h, ONLY: nsoilmx, layer, mlayer, volcapa, inertiedat
+      USE tracer_h, ONLY: igcm_co2_ice
+      USE infotrac, ONLY: tname, nqtot
+      USE slab_ice_h, ONLY: noceanmx
+!      USE control_mod
+! to use  'getin'
+      USE callkeys_mod, ONLY: ok_slab_ocean
+      USE comvert_mod, ONLY: ap,bp,aps,bps,preff
+      USE comconst_mod, ONLY: kappa,g,pi
+
+c=======================================================================
+c
+c
+c   Auteur:    05/1997 , 12/2003 : coord hybride  FF
+c   ------
+c
+c
+c   Objet:     Lecture des variables d'un fichier "start_archive"
+c              Plus besoin de régler ancienne valeurs grace
+c              a l'allocation dynamique de memoire (Yann Wanherdrick)
+c
+c
+c
+c=======================================================================
+
+      implicit none
+
+#include "dimensions.h"
+!#include "dimphys.h"
+!#include "planete.h"
+#include "paramet.h"
+#include "comgeom2.h"
+!#include "control.h"
+#include "netcdf.inc"
+!#include"advtrac.h"
+c=======================================================================
+c   Declarations
+c=======================================================================
+
+      INTEGER,INTENT(IN) :: ngrid, nlayer
+
+c Old variables dimensions (from file)
+c------------------------------------
+      INTEGER   imold,jmold,lmold,nsoilold,nqold
+
+
+c Variables pour les lectures des fichiers "ini" 
+c--------------------------------------------------
+!      INTEGER sizei,
+      integer timelen,dimid
+!      INTEGER length
+!      parameter (length = 100)
+      INTEGER tab0
+      INTEGER isoil,iq,iqmax
+      CHARACTER*2   str2
+
+!      REAL dimfirst(4) ! tableau contenant les 1ers elements des dimensions
+
+!      REAL dimlast(4) ! tableau contenant les derniers elements des dimensions
+
+!      REAL dimcycl(4) ! tableau contenant les periodes des dimensions
+!      CHARACTER*120 dimsource
+!      CHARACTER*16 dimname
+!      CHARACTER*80 dimtitle
+!      CHARACTER*40 dimunits
+!      INTEGER   dimtype
+
+!      INTEGER dimord(4)  ! tableau contenant l''ordre
+!      data dimord /1,2,3,4/ ! de sortie des dimensions
+
+!      INTEGER vardim(4)
+      REAL date
+      INTEGER   memo
+!      character (len=50) :: tmpname
+
+c Variable histoire 
+c------------------
+      REAL vcov(iip1,jjm,llm),ucov(iip1,jjp1,llm) ! vents covariants
+      REAL h(iip1,jjp1,llm),ps(iip1,jjp1)
+      REAL q(iip1,jjp1,llm,nqtot),qtot(iip1,jjp1,llm)
+
+c autre variables dynamique nouvelle grille
+c------------------------------------------
+
+c!-*-
+!      integer klatdat,klongdat
+!      PARAMETER (klatdat=180,klongdat=360)
+
+c Physique sur grille scalaire 
+c----------------------------
+
+c variable physique
+c------------------
+      REAL tsurf(ngrid) ! surface temperature
+      REAL tsoil(ngrid,nsoilmx) ! soil temperature
+      REAL co2ice(ngrid) ! CO2 ice layer
+      REAL emis(ngrid)
+      REAL q2(ngrid,llm+1),qsurf(ngrid,nqtot)
+      REAL tslab(ngrid,noceanmx)
+      REAL rnat(ngrid),pctsrf_sic(ngrid)
+      REAL tsea_ice(ngrid),sea_ice(ngrid)
+c     REAL phisfi(ngrid)
+
+      INTEGER i,j,l
+      INTEGER nid,nvarid
+c     REAL year_day,periheli,aphelie,peri_day
+c     REAL obliquit,z0,emin_turb,lmixmin
+c     REAL emissiv,emisice(2),albedice(2)
+c     REAL iceradius(2) , dtemisice(2)
+
+      integer ierr
+      integer, dimension(4) :: start,count
+
+c Variable nouvelle grille naturelle au point scalaire
+c------------------------------------------------------
+      real us(iip1,jjp1,llm),vs(iip1,jjp1,llm)
+      REAL phisold_newgrid(iip1,jjp1)
+      REAL t(iip1,jjp1,llm)
+      real tsurfS(iip1,jjp1),tsoilS(iip1,jjp1,nsoilmx)
+      real inertiedatS(iip1,jjp1,nsoilmx)
+      real co2iceS(iip1,jjp1)
+      real emisS(iip1,jjp1)
+      REAL q2S(iip1,jjp1,llm+1),qsurfS(iip1,jjp1,nqtot)
+      real tslabS(iip1,jjp1,noceanmx)
+      real pctsrf_sicS(iip1,jjp1),tsea_iceS(iip1,jjp1)
+      real rnatS(iip1,jjp1), sea_iceS(iip1,jjp1)
+
+      real ptotal, co2icetotal
+
+c Var intermediaires : vent naturel, mais pas coord scalaire
+c-----------------------------------------------------------
+      real vnat(iip1,jjm,llm),unat(iip1,jjp1,llm)
+
+
+c Variable de l'ancienne grille 
+c---------------------------------------------------------
+
+      real, dimension(:), allocatable :: timelist
+      real, dimension(:), allocatable :: rlonuold, rlatvold
+      real, dimension(:), allocatable :: rlonvold, rlatuold
+      real, dimension(:), allocatable :: apsold,bpsold
+      real, dimension(:), allocatable :: mlayerold
+      real, dimension(:,:,:), allocatable :: uold,vold,told,q2old
+      real, dimension(:,:,:), allocatable :: tsoilold,qsurfold
+      real, dimension(:,:,:),allocatable :: tsoiloldnew
+! tsoiloldnew: old soil values, but along new subterranean grid
+      real, dimension(:,:,:), allocatable :: inertiedatold
+! inertiedatoldnew: old inertia values, but along new subterranean grid
+      real, dimension(:,:,:), allocatable :: inertiedatoldnew
+      real, dimension(:,:), allocatable :: psold,phisold
+      real, dimension(:,:), allocatable :: co2iceold
+      real, dimension(:,:), allocatable :: tsurfold
+      real, dimension(:,:), allocatable :: emisold
+      real, dimension(:,:,:,:), allocatable :: qold
+      real, dimension(:,:,:), allocatable :: tslabold
+      real, dimension(:,:), allocatable :: rnatold,pctsrf_sicold
+      real, dimension(:,:), allocatable :: tsea_iceold,sea_iceold
+
+
+      real tab_cntrl(100)
+
+      real ptotalold, co2icetotalold
+
+      logical :: olddepthdef=.false. ! flag
+! olddepthdef=.true. if soil depths are in 'old' (unspecified) format
+      logical :: depthinterpol=.false. ! flag
+! depthinterpol=.true. if interpolation will be requiered
+      logical :: therminertia_3D=.true. ! flag
+! therminertia_3D=.true. if thermal inertia is 3D and read from datafile
+c Variable intermediaires iutilise pour l'extrapolation verticale 
+c----------------------------------------------------------------
+      real, dimension(:,:,:), allocatable :: var,varp1 
+      real, dimension(:), allocatable :: oldgrid, oldval
+      real, dimension(:), allocatable :: newval
+
+      real surfith(iip1,jjp1) ! surface thermal inertia
+      ! surface thermal inertia at old horizontal grid resolution
+      real, dimension(:,:), allocatable :: surfithold 
+
+      character(len=30) :: txt ! to store some text
+
+c=======================================================================
+
+! 0. Preliminary stuff
+
+
+
+!-----------------------------------------------------------------------
+! 1. Read data dimensions (i.e. size and length)
+!-----------------------------------------------------------------------
+
+! 1.2 Read the various dimension lengths of data in file 
+
+      ierr= NF_INQ_DIMID(nid,"Time",dimid)
+      if (ierr.ne.NF_NOERR) then
+         ierr= NF_INQ_DIMID(nid,"temps",dimid)
+      endif
+      ierr= NF_INQ_DIMLEN(nid,dimid,timelen)
+
+      ierr= NF_INQ_DIMID(nid,"latitude",dimid)
+      if (ierr.ne.NF_NOERR) then
+         ierr= NF_INQ_DIMID(nid,"rlatu",dimid)
+      endif
+      ierr= NF_INQ_DIMLEN(nid,dimid,jmold)
+      jmold=jmold-1
+
+      ierr= NF_INQ_DIMID(nid,"longitude",dimid)
+      if (ierr.ne.NF_NOERR) then
+         ierr= NF_INQ_DIMID(nid,"rlonv",dimid)
+      endif
+      ierr= NF_INQ_DIMLEN(nid,dimid,imold)
+      imold=imold-1
+
+      ierr= NF_INQ_DIMID(nid,"altitude",dimid)
+      if (ierr.ne.NF_NOERR) then
+         ierr= NF_INQ_DIMID(nid,"sig_s",dimid)
+      endif
+      ierr= NF_INQ_DIMLEN(nid,dimid,lmold)
+
+      nqold=0
+      do
+         write(str2,'(i2.2)') nqold+1
+         ierr= NF_INQ_VARID(nid,'q'//str2,dimid)
+!        write(*,*) 'q'//str2
+         if (ierr.eq.NF_NOERR) then
+            nqold=nqold+1
+         else
+            exit
+         endif
+      enddo
+
+! 1.2.1 find out the # of subsurface_layers
+      nsoilold=0 !dummy initialisation
+      ierr=NF_INQ_DIMID(nid,"subsurface_layers",dimid)
+      if (ierr.eq.NF_NOERR) then
+        ierr=NF_INQ_DIMLEN(nid,dimid,nsoilold)
+	if (ierr.ne.NF_NOERR) then
+	 write(*,*)'lec_start_archive: ',
+     &              'Failed reading subsurface_layers length'
+	endif
+      else
+        write(*,*)"lec_start_archive: did not find subsurface_layers"
+      endif
+
+      if (nsoilold.eq.0) then ! 'old' archive format;
+      ! must use Tg//str2 fields to compute nsoilold
+      write(*,*)"lec_start_archive: building nsoilold from Tg fields"
+        do
+	 write(str2,'(i2.2)') nsoilold+1
+	 ierr=NF_INQ_VARID(nid,'Tg'//str2,dimid)
+	 if (ierr.eq.NF_NOERR) then
+	  nsoilold=nsoilold+1
+	 else
+	  exit
+	 endif
+	enddo
+      endif
+
+
+      if (nsoilold.ne.nsoilmx) then ! interpolation will be required
+        depthinterpol=.true.
+      endif
+
+! 1.3 Report dimensions
+      
+      write(*,*) "Start_archive dimensions:"
+      write(*,*) "longitude: ",imold
+      write(*,*) "latitude: ",jmold
+      write(*,*) "altitude: ",lmold
+      write(*,*) "tracers: ",nqold
+      write(*,*) "subsurface_layers: ",nsoilold
+      if (depthinterpol) then
+      write(*,*) " => Warning, nsoilmx= ",nsoilmx
+      write(*,*) '    which implies that you want subterranean interpola
+     &tion.'
+      write(*,*) '  Otherwise, set nsoilmx -in dimphys.h- to: ',nsoilold
+      endif
+      write(*,*) "time lenght: ",timelen
+      write(*,*) 
+
+!-----------------------------------------------------------------------
+! 2. Allocate arrays to store datasets
+!-----------------------------------------------------------------------
+
+      allocate(timelist(timelen))
+      allocate(rlonuold(imold+1), rlatvold(jmold))
+      allocate(rlonvold(imold+1), rlatuold(jmold+1))
+      allocate (apsold(lmold),bpsold(lmold))
+      allocate(uold(imold+1,jmold+1,lmold))
+      allocate(vold(imold+1,jmold+1,lmold))
+      allocate(told(imold+1,jmold+1,lmold))
+      allocate(psold(imold+1,jmold+1))
+      allocate(phisold(imold+1,jmold+1))
+      allocate(qold(imold+1,jmold+1,lmold,nqtot))
+      allocate(co2iceold(imold+1,jmold+1))
+      allocate(tsurfold(imold+1,jmold+1))
+      allocate(emisold(imold+1,jmold+1))
+      allocate(q2old(imold+1,jmold+1,lmold+1))
+!      allocate(tsoilold(imold+1,jmold+1,nsoilmx))
+      allocate(tsoilold(imold+1,jmold+1,nsoilold))
+      allocate(tsoiloldnew(imold+1,jmold+1,nsoilmx))
+      allocate(inertiedatold(imold+1,jmold+1,nsoilold)) ! soil thermal inertia
+      allocate(inertiedatoldnew(imold+1,jmold+1,nsoilmx))
+      ! surface thermal inertia at old horizontal grid resolution
+      allocate(surfithold(imold+1,jmold+1))
+      allocate(mlayerold(nsoilold))
+      allocate(qsurfold(imold+1,jmold+1,nqtot))
+      allocate(tslabold(imold+1,jmold+1,noceanmx))
+      allocate(rnatold(imold+1,jmold+1))
+      allocate(pctsrf_sicold(imold+1,jmold+1))
+      allocate(tsea_iceold(imold+1,jmold+1))
+      allocate(sea_iceold(imold+1,jmold+1))
+
+      allocate(var (imold+1,jmold+1,llm))
+      allocate(varp1 (imold+1,jmold+1,llm+1))
+
+      write(*,*) 'q2',ngrid,llm+1
+      write(*,*) 'q2S',iip1,jjp1,llm+1
+      write(*,*) 'q2old',imold+1,jmold+1,lmold+1
+
+!-----------------------------------------------------------------------
+! 3. Read time-independent data
+!-----------------------------------------------------------------------
+
+C-----------------------------------------------------------------------
+c 3.1. Lecture du tableau des parametres du run 
+c     (pour  la lecture ulterieure de "ptotalold" et "co2icetotalold")
+c-----------------------------------------------------------------------
+c
+      ierr = NF_INQ_VARID (nid, "controle", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "Lect_start_archive: champ <controle> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echoue pour <controle>"
+         CALL abort
+      ENDIF
+c
+      tab0 = 50
+
+c-----------------------------------------------------------------------
+c 3.2 Lecture des longitudes et latitudes
+c-----------------------------------------------------------------------
+c
+      ierr = NF_INQ_VARID (nid, "rlonv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <rlonv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonvold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonvold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <rlonv>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "rlatu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <rlatu> est absent"
+         CALL abort
+      ENDIF 
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatuold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatuold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <rlatu>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "rlonu", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <rlonu> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlonuold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlonuold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <rlonu>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "rlatv", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <rlatv> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, rlatvold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, rlatvold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <rlatv>"
+         CALL abort
+      ENDIF
+c
+
+c-----------------------------------------------------------------------
+c 3.3. Lecture des niveaux verticaux
+c-----------------------------------------------------------------------
+c
+      ierr = NF_INQ_VARID (nid, "aps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <aps> est absent"
+         apsold=0
+         PRINT*, "<aps> set to 0"
+      ELSE
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid, nvarid, apsold)
+#else
+         ierr = NF_GET_VAR_REAL(nid, nvarid, apsold)
+#endif
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "lect_start_archive: Lecture echouee pour <aps>"
+         ENDIF
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "bps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <bps> est absent"
+         PRINT*, "It must be an old start_archive, lets look for sig_s"
+         ierr = NF_INQ_VARID (nid, "sig_s", nvarid)
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "Nothing to do..."
+            CALL abort
+         ENDIF
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, bpsold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, bpsold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <bps>"
+         CALL abort
+      END IF
+
+c-----------------------------------------------------------------------
+c 3.4 Read Soil layers depths
+c-----------------------------------------------------------------------
+     
+      ierr=NF_INQ_VARID(nid,"soildepth",nvarid)
+      if (ierr.ne.NF_NOERR) then
+       write(*,*)'lect_start_archive: Could not find <soildepth>'
+       write(*,*)' => Assuming this is an archive in old format'
+       olddepthdef=.true.
+       depthinterpol=.true.
+       ! this is how soil depth was defined in ye old days
+	do isoil=1,nsoilold
+	  mlayerold(isoil)=sqrt(887.75/3.14)*((2.**(isoil-0.5))-1.)
+	enddo
+      else
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid,nvarid,mlayerold)
+#else
+        ierr = NF_GET_VAR_REAL(nid,nvarid,mlayerold)
+#endif
+       if (ierr .NE. NF_NOERR) then
+         PRINT*, "lect_start_archive: Failed reading <soildepth>"
+         CALL abort
+       endif
+
+      endif !of if(ierr.ne.NF_NOERR)
+
+      ! Read (or build) mlayer()
+      if (depthinterpol) then
+       ! Build (default) new soil depths (mlayer(:) is in comsoil.h),
+       ! as in soil_settings.F
+       write(*,*)' => Building default soil depths'
+       do isoil=0,nsoilmx-1
+         mlayer(isoil)=2.e-4*(2.**(isoil-0.5))
+       enddo
+       write(*,*)' => mlayer: ',mlayer
+       ! Also build (default) new soil interlayer depth layer(:)
+       do isoil=1,nsoilmx
+         layer(isoil)=sqrt(mlayer(0)*mlayer(1))*
+     &                      ((mlayer(1)/mlayer(0))**(isoil-1))
+       enddo
+       write(*,*)' =>  layer: ',layer
+      else ! read mlayer() from file
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid,nvarid,mlayer)
+#else
+        ierr = NF_GET_VAR_REAL(nid,nvarid,mlayer)
+#endif
+       if (ierr .NE. NF_NOERR) then
+         PRINT*, "lect_start_archive: Failed reading <soildepth>"
+         CALL abort
+       endif
+      endif ! of if (depthinterpol)
+
+c-----------------------------------------------------------------------
+c 3.5 Read Soil thermal inertia
+c-----------------------------------------------------------------------
+
+      ierr=NF_INQ_VARID(nid,"inertiedat",nvarid)
+      if (ierr.ne.NF_NOERR) then
+       write(*,*)'lect_start_archive: Could not find <inertiedat>'
+       write(*,*)' => Assuming this is an archive in old format'
+       therminertia_3D=.false.
+       write(*,*)' => Thermal inertia will be read from reference file'
+       volcapa=1.e6
+       write(*,*)'    and soil volumetric heat capacity is set to ',
+     &           volcapa
+      else
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid,nvarid,inertiedatold)
+#else
+        ierr = NF_GET_VAR_REAL(nid,nvarid,inertiedatold)
+#endif
+       if (ierr .NE. NF_NOERR) then
+         PRINT*, "lect_start_archive: Failed reading <inertiedat>"
+         CALL abort
+       endif
+      endif
+
+c-----------------------------------------------------------------------
+c 3.6 Lecture geopotentiel au sol
+c-----------------------------------------------------------------------
+c
+      ierr = NF_INQ_VARID (nid, "phisinit", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <phisinit> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, phisold)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, phisold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <phisinit>"
+         CALL abort
+      ENDIF
+
+C-----------------------------------------------------------------------
+c   lecture de "ptotalold" et "co2icetotalold"
+c-----------------------------------------------------------------------
+      ptotalold = tab_cntrl(tab0+49)
+      co2icetotalold = tab_cntrl(tab0+50)
+ 
+c-----------------------------------------------------------------------
+c 4. Lecture du temps et choix
+c-----------------------------------------------------------------------
+ 
+c  lecture du temps
+c
+      ierr = NF_INQ_DIMID (nid, "Time", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         ierr = NF_INQ_DIMID (nid, "temps", nvarid)
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "lect_start_archive: Le champ <Time> est absent"
+            CALL abort
+         endif
+      ENDIF
+
+      ierr = NF_INQ_VARID (nid, "Time", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         ierr = NF_INQ_VARID (nid, "temps", nvarid)
+      endif 
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VAR_DOUBLE(nid, nvarid, timelist)
+#else
+      ierr = NF_GET_VAR_REAL(nid, nvarid, timelist)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <Time>"
+         CALL abort
+      ENDIF
+c
+      write(*,*)
+      write(*,*)
+      write(*,*) 'Differentes dates des etats initiaux stockes:'
+      write(*,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+      pi=2.*ASIN(1.)
+      do i=1,timelen
+c       call solarlong(timelist(i),sollong(i))
+c       sollong(i) = sollong(i)*180./pi
+        write(*,*) 'etat initial au jour martien' ,int(timelist(i))
+c       write(*,6) nint(timelist(i)),nint(mod(timelist(i),669)),
+c    .    sollong(i)
+      end do
+
+   6  FORMAT(i7,i7,f9.3)
+ 
+      write(*,*)
+      write(*,*) 'Choix de la date'
+ 123  read(*,*,iostat=ierr) date
+      if(ierr.ne.0) goto 123
+      memo = 0
+      do i=1,timelen
+        if (date.eq.int(timelist(i))) then
+            memo = i
+        endif
+      end do
+ 
+      if (memo.eq.0) then
+        write(*,*)
+        write(*,*)
+        write(*,*) 'He alors... Y sait pas lire !?!'
+        write(*,*)
+        write(*,*) 'Differentes dates des etats initiaux stockes:'
+        write(*,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+        do i=1,timelen
+          write(*,*) 'etat initial au jour martien' ,nint(timelist(i))
+c         write(*,6) nint(timelist(i)),nint(mod(timelist(i),669))
+        end do
+        goto 123
+      endif
+
+!-----------------------------------------------------------------------
+! 5. Read (time-dependent) data from datafile
+!-----------------------------------------------------------------------
+
+
+c-----------------------------------------------------------------------
+c 5.1 Lecture des champs 2D (co2ice, emis,ps,tsurf,Tg[10], qsurf)
+c-----------------------------------------------------------------------
+ 
+      start=(/1,1,memo,0/)
+      count=(/imold+1,jmold+1,1,0/)
+       
+! CO2ice is now in qsurf(igcm_co2_ice) ...
+!      ierr = NF_INQ_VARID (nid, "co2ice", nvarid)
+!      IF (ierr .NE. NF_NOERR) THEN
+!         PRINT*, "lect_start_archive: Le champ <co2ice> est absent"
+!         CALL abort
+!      ENDIF
+!#ifdef NC_DOUBLE
+!      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,co2iceold)
+!#else
+!      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,co2iceold)
+!#endif
+!      IF (ierr .NE. NF_NOERR) THEN
+!         PRINT*, "lect_start_archive: Lecture echouee pour <co2ice>"
+!         PRINT*, NF_STRERROR(ierr)
+!         CALL abort
+!      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "emis", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <emis> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,emisold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,emisold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <emis>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "ps", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <ps> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,psold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,psold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <ps>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "tsurf", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <tsurf> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,tsurfold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,tsurfold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <tsurf>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "q2surf", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <q2surf> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,q2old)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,q2old)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <q2surf>"
+         CALL abort
+      ENDIF
+c
+cc Slab ocean
+      if(ok_slab_ocean) then
+      start=(/1,1,1,memo/)
+      count=(/imold+1,jmold+1,noceanmx,1/)
+
+       ierr=NF_INQ_VARID(nid,"tslab",nvarid)
+       IF (ierr.ne.NF_NOERR) then
+          PRINT*,"lect_start_archive: Cannot find <tslab>"
+       ENDIF
+#ifdef NC_DOUBLE
+      ierr=NF_GET_VARA_DOUBLE(nid,nvarid,start,count,tslabold)
+#else
+      ierr=NF_GET_VARA_REAL(nid,nvarid,start,count,tslabold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <tslab>"
+      ENDIF
+
+
+c
+      start=(/1,1,memo,0/)
+      count=(/imold+1,jmold+1,1,0/)
+
+      ierr = NF_INQ_VARID (nid, "rnat", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <rnat> est absent"
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,rnatold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,rnatold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <rnat>"
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "pctsrf_sic", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <pctsrf_sic> est absent"
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,pctsrf_sicold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,pctsrf_sicold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <pctsrf_sic>"
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "tsea_ice", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <tsea_ice> est absent"
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,tsea_iceold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,tsea_iceold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <tsea_ice>"
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid, "sea_ice", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <sea_ice> est absent"
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,sea_iceold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,sea_iceold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <sea_ice>"
+      ENDIF
+  
+      ENDIF! ok_slab_ocean
+c
+      write(*,*)"lect_start_archive: rlonuold:"
+     &           ,rlonuold," rlatvold:",rlatvold
+      write(*,*)
+
+! Surface tracers:      
+      do iq=1,nqtot
+        ! initialize all surface tracers to zero
+        call initial0((jmold+1)*(imold+1), qsurfold(1,1,iq))
+      enddo
+
+
+!      print*,'tname=',tname
+!      print*,'nid',nid
+!      print*,'nvarid',nvarid
+!      stop
+
+      DO iq=1,nqtot
+          txt=trim(tname(iq))//"_surf"
+          if (txt.eq."h2o_vap") then
+            ! There is no surface tracer for h2o_vap;
+            ! "h2o_ice" should be loaded instead
+            txt="h2o_ice_surf"
+            write(*,*) 'lect_start_archive: loading surface tracer',
+     &                     ' h2o_ice instead of h2o_vap'
+          endif
+
+        
+        write(*,*) "lect_start_archive: loading tracer ",trim(txt)
+        ierr = NF_INQ_VARID (nid,txt,nvarid)
+        IF (ierr .NE. NF_NOERR) THEN
+          PRINT*, "lect_start_archive: ",
+     &              " Tracer <",trim(txt),"> not found"
+
+!          print*,'RDW has added hack to let me continue...'
+!          CALL abort
+        ENDIF
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,
+     &          qsurfold(1,1,iq))
+#else
+        ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,
+     &          qsurfold(1,1,iq))
+#endif
+        IF (ierr .NE. NF_NOERR) THEN
+          PRINT*, "lect_start_archive: ",
+     &             " Failed loading <",trim(txt),">"
+          write (*,*) trim(txt),'    is set to 0'
+!          call initial0((jmold+1)*(imold+1), qsurfold(1,1,iq))
+        ENDIF
+
+      ENDDO ! of DO iq=1,nqtot
+
+
+!-----------------------------------------------------------------------
+! 5.2 Read 3D subterranean fields
+!-----------------------------------------------------------------------
+
+      start=(/1,1,1,memo/)
+      count=(/imold+1,jmold+1,nsoilold,1/)
+!
+! Read soil temperatures
+!
+      if (olddepthdef) then ! tsoil stored using the 'old format'
+         start=(/1,1,memo,0/)
+         count=(/imold+1,jmold+1,1,0/) ! because the "Tg" are 2D datasets
+       do isoil=1,nsoilold
+         write(str2,'(i2.2)') isoil
+c
+         ierr = NF_INQ_VARID (nid, "Tg"//str2, nvarid)
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "lect_start_archive: ",
+     &              "Field <","Tg"//str2,"> not found"
+            CALL abort
+         ENDIF
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,
+     &          tsoilold(1,1,isoil))
+#else
+         ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,
+     &          tsoilold(1,1,isoil))
+#endif
+         IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "lect_start_archive: ",
+     &            "Failed reading <","Tg"//str2,">"
+            CALL abort
+         ENDIF
+c
+       enddo ! of do isoil=1,nsoilold
+      
+      ! reset 'start' and 'count' to "3D" behaviour
+      start=(/1,1,1,memo/)
+      count=(/imold+1,jmold+1,nsoilold,1/)
+      
+      else
+       write(*,*) "lect_start_archive: loading tsoil "
+       ierr=NF_INQ_VARID(nid,"tsoil",nvarid)
+       if (ierr.ne.NF_NOERR) then
+        write(*,*)"lect_start_archive: Cannot find <tsoil>"
+	call abort
+       else
+#ifdef NC_DOUBLE
+      ierr=NF_GET_VARA_DOUBLE(nid,nvarid,start,count,tsoilold)
+#else
+      ierr=NF_GET_VARA_REAL(nid,nvarid,start,count,tsoilold)
+#endif
+       endif ! of if (ierr.ne.NF_NOERR)
+       
+      endif ! of if (olddepthdef)
+
+!
+! Read soil thermal inertias
+!
+!      if (.not.olddepthdef) then ! no thermal inertia data in "old" archives
+!       ierr=NF_INQ_VARID(nid,"inertiedat",nvarid)
+!       if (ierr.ne.NF_NOERR) then
+!        write(*,*)"lect_start_archive: Cannot find <inertiedat>"
+!	call abort
+!       else
+!#ifdef NC_DOUBLE
+!      ierr=NF_GET_VARA_DOUBLE(nid,nvarid,start,count,inertiedatold)
+!#else
+!      ierr=NF_GET_VARA_REAL(nid,nvarid,start,count,inertiedatold)
+!#endif
+!       endif ! of if (ierr.ne.NF_NOERR)
+!      endif
+
+c-----------------------------------------------------------------------
+c 5.3	Lecture des champs 3D (t,u,v, q2atm,q)
+c-----------------------------------------------------------------------
+
+      start=(/1,1,1,memo/)
+      count=(/imold+1,jmold+1,lmold,1/)
+
+c
+      ierr = NF_INQ_VARID (nid,"temp", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <temp> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid, start, count, told)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid, start, count, told)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <temp>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid,"u", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <u> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,uold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,uold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <u>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid,"v", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <v> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,vold)
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,vold)
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <v>"
+         CALL abort
+      ENDIF
+c
+      ierr = NF_INQ_VARID (nid,"q2atm", nvarid)
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Le champ <q2atm> est absent"
+         CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid, nvarid,start,count,q2old(1,1,2))
+#else
+      ierr = NF_GET_VARA_REAL(nid, nvarid,start,count,q2old(1,1,2))
+#endif
+      IF (ierr .NE. NF_NOERR) THEN
+         PRINT*, "lect_start_archive: Lecture echouee pour <q2atm>"
+         CALL abort
+      ENDIF
+c
+
+! Tracers:      
+      do iq=1,nqtot
+         call initial0((jmold+1)*(imold+1)*lmold,qold(1,1,1,iq) )
+      enddo
+
+      DO iq=1,nqtot
+        txt=tname(iq)
+        write(*,*)"lect_start_archive: loading tracer ",trim(txt)
+        ierr = NF_INQ_VARID (nid,txt,nvarid)
+        IF (ierr .NE. NF_NOERR) THEN
+            PRINT*, "lect_start_archive: ",
+     &              " Tracer <",trim(txt),"> not found"
+!            CALL abort
+        ENDIF
+#ifdef NC_DOUBLE
+        ierr=NF_GET_VARA_DOUBLE(nid,nvarid,start,count,qold(1,1,1,iq))
+#else
+        ierr=NF_GET_VARA_REAL(nid,nvarid,start,count,qold(1,1,1,iq))
+#endif
+        IF (ierr .NE. NF_NOERR) THEN
+          PRINT*, "lect_start_archive: ",
+     &             "  Failed loading <",trim(txt),">"
+          write (*,*) trim(txt),'      set to 1.E-30'
+          do l=1,lmold
+            do j=1,jmold+1
+              do i=1,imold+1
+                 qold(i,j,l,iq)=1.e-30
+              end do
+            end do
+          end do
+        ENDIF
+
+      ENDDO ! of DO iq=1,nqtot
+
+
+!=======================================================================
+! 6. Interpolation from old grid to new grid
+!=======================================================================
+
+c=======================================================================
+c   INTERPOLATION DANS LA NOUVELLE GRILLE et initialisation des variables
+c=======================================================================
+c  Interpolation horizontale puis passage dans la grille physique pour 
+c  les variables physique 
+c  Interpolation verticale puis horizontale pour chaque variable 3D
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c 6.1	Variable 2d :
+c-----------------------------------------------------------------------
+c Relief 
+      call interp_horiz (phisold,phisold_newgrid,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+
+! CO2 ice is now in qsurf(igcm_co2_ice)
+!      call interp_horiz (co2iceold,co2ices,imold,jmold,iim,jjm,1,
+!     &                   rlonuold,rlatvold,rlonu,rlatv)
+
+c Temperature de surface
+      call interp_horiz (tsurfold,tsurfs,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tsurfs,tsurf)
+c     write(44,*) 'tsurf', tsurf
+
+c Temperature du sous-sol
+!      call interp_horiz(tsoilold,tsoils,
+!     &                  imold,jmold,iim,jjm,nsoilmx,
+!     &                   rlonuold,rlatvold,rlonu,rlatv)
+!      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoils,tsoil)
+c     write(45,*) 'tsoil',tsoil
+
+c Emissivite de la surface
+      call interp_horiz (emisold,emiss,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,emiss,emis)
+c     write(46,*) 'emis',emis
+
+
+
+c-----------------------------------------------------------------------
+c 6.1.2	Traitement special de la pression au sol :
+c-----------------------------------------------------------------------
+
+c  Extrapolation la pression dans la nouvelle grille
+      call interp_horiz(psold,ps,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+
+c-----------------------------------------------------------------------
+c	On assure la conservation de la masse de l'atmosphere + calottes
+c-----------------------------------------------------------------------
+
+      ptotal =  0.
+      DO j=1,jjp1
+         DO i=1,iim
+            ptotal=ptotal+ps(i,j)*aire(i,j)/g
+         END DO
+      END DO
+      co2icetotal = 0.
+      if (igcm_co2_ice.ne.0) then
+        ! recast surface CO2 ice on new grid
+        call interp_horiz(qsurfold(1,1,igcm_co2_ice),
+     &                  qsurfs(1,1,igcm_co2_ice),
+     &                  imold,jmold,iim,jjm,1,
+     &                  rlonuold,rlatvold,rlonu,rlatv)
+       DO j=1,jjp1
+         DO i=1,iim
+           !co2icetotal = co2icetotal + co2iceS(i,j)*aire(i,j)
+           co2icetotal=co2icetotal+qsurfS(i,j,igcm_co2_ice)*aire(i,j)
+         END DO
+       END DO
+      else
+        write(*,*) "Warning: No co2_ice surface tracer"
+      endif
+
+      write(*,*)
+      write(*,*)'Ancienne grille: masse de l atm :',ptotalold
+      write(*,*)'Nouvelle grille: masse de l atm :',ptotal
+      write (*,*) 'Ratio new atm./ old atm =', ptotal/ptotalold 
+      write(*,*)
+      write(*,*)'Ancienne grille: masse de la glace CO2:',co2icetotalold
+      write(*,*)'Nouvelle grille: masse de la glace CO2:',co2icetotal
+      if (co2icetotalold.ne.0.) then
+      write(*,*)'Ratio new ice./old ice =',co2icetotal/co2icetotalold
+      endif
+      write(*,*)
+
+
+      DO j=1,jjp1
+         DO i=1,iip1
+            ps(i,j)=ps(i,j) * ptotalold/ptotal
+         END DO
+      END DO
+
+      if ( co2icetotalold.gt.0.) then 
+!         DO j=1,jjp1
+!            DO i=1,iip1
+!               co2iceS(i,j)=co2iceS(i,j) * co2icetotalold/co2icetotal
+!            END DO
+!         END DO
+        write(*,*) "Not enforcing conservation of surface CO2 ice"
+        write(*,*) " (should be OK when CO2 ice is a tracer)"
+      end if
+
+c-----------------------------------------------------------------------
+c 6.2 Subterranean 3d variables:
+c-----------------------------------------------------------------------
+
+c-----------------------------------------------------------------------
+c 6.2.1 Thermal Inertia
+c       Note: recall that inertiedat is a common in "comsoil.h"
+c-----------------------------------------------------------------------
+
+      ! depth-wise interpolation, if required
+      if (depthinterpol.and.(.not.olddepthdef)) then
+        allocate(oldval(nsoilold))
+	allocate(newval(nsoilmx))
+        write(*,*)'lect_start_archive: WARNING: vertical interpolation o
+     &f soil thermal inertia; might be wiser to reset it.'
+        write(*,*)
+       
+        do i=1,imold+1
+         do j=1,jmold+1
+	   !copy old values
+	   oldval(1:nsoilold)=inertiedatold(i,j,1:nsoilold)
+	   !interpolate
+	   call interp_line(mlayerold,oldval,nsoilold,
+     &                     mlayer,newval,nsoilmx)
+           !copy interpolated values
+           inertiedatoldnew(i,j,1:nsoilmx)=newval(1:nsoilmx)
+	 enddo
+        enddo
+        ! cleanup
+	deallocate(oldval)
+	deallocate(newval)
+      endif !of if (depthinterpol)
+
+      if (therminertia_3D) then
+        ! We have inertiedatold
+       if((imold.ne.iim).or.(jmold.ne.jjm)) then
+       write(*,*)'lect_start_archive: WARNING: horizontal interpolation 
+     &of thermal inertia; might be better to reset it.'
+       write(*,*)
+       endif
+       
+        ! Do horizontal interpolation
+	if (depthinterpol) then
+	  call interp_horiz(inertiedatoldnew,inertiedatS,
+     &                  imold,jmold,iim,jjm,nsoilmx,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+	else
+          call interp_horiz(inertiedatold,inertiedatS,
+     &                  imold,jmold,iim,jjm,nsoilold,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+        endif ! of if (depthinterpol)
+
+      else ! no 3D thermal inertia data
+       write(*,*)'lect_start_archive: using reference surface inertia'
+        ! Use surface inertia (and extend it to all depths)
+        do i=1,nsoilmx
+         inertiedatS(1:iip1,1:jjp1,i)=surfith(1:iip1,1:jjp1)
+        enddo
+	! Build an old resolution surface thermal inertia
+	! (will be needed for tsoil interpolation)
+	call interp_horiz(surfith,surfithold,
+     &                    iim,jjm,imold,jmold,1,
+     &                    rlonu,rlatv,rlonuold,rlatvold)
+      endif
+
+
+      ! Reshape inertiedatS to scalar grid as inertiedat
+      call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,
+     &                  inertiedatS,inertiedat)
+      
+c-----------------------------------------------------------------------
+c 6.2.2 Soil temperature
+c-----------------------------------------------------------------------
+!      write(*,*) 'Soil'
+
+      !print*,'Problem in lect_start_archive interpolating'
+      !print*,'to new resolution!!'
+
+      ! Recast temperatures along soil depth, if necessary
+      if (olddepthdef) then
+        allocate(oldgrid(nsoilold+1))
+        allocate(oldval(nsoilold+1))
+	allocate(newval(nsoilmx))
+        do i=1,imold+1
+	 do j=1,jmold+1
+
+            !if(i.gt.iip1 .or. j.gt.jjp1)then
+               !print*,'Problem in lect_start_archive interpolating'
+               !print*,'to new resolution!!'
+               !call abort
+            !endif
+
+	   ! copy values
+	   oldval(1)=tsurfold(i,j)
+!	   oldval(1)=tsurfS(i,j)
+	   oldval(2:nsoilold+1)=tsoilold(i,j,1:nsoilold)
+	   ! build vertical coordinate
+	   oldgrid(1)=0. ! ground
+	   oldgrid(2:nsoilold+1)=mlayerold(1:nsoilold)*
+     &                (surfithold(i,j)/1.e6)
+          ! Note; at this stage, we impose volcapa=1.e6 above
+	  ! since volcapa isn't set in old soil definitions
+
+	  ! interpolate
+	  call interp_line(oldgrid,oldval,nsoilold+1,
+     &                     mlayer,newval,nsoilmx)
+	 ! copy result in tsoilold
+	 tsoiloldnew(i,j,1:nsoilmx)=newval(1:nsoilmx)
+	 enddo
+	enddo
+        ! cleanup
+	deallocate(oldgrid)
+	deallocate(oldval)
+	deallocate(newval)
+
+      else
+       if (depthinterpol) then ! if vertical interpolation is required
+        allocate(oldgrid(nsoilold+1))
+        allocate(oldval(nsoilold+1))
+	allocate(newval(nsoilmx))
+        ! build vertical coordinate
+	oldgrid(1)=0. ! ground
+	oldgrid(2:nsoilold+1)=mlayerold(1:nsoilold)
+        do i=1,imold+1
+	 do j=1,jmold+1
+	   ! copy values
+	   oldval(1)=tsurfold(i,j)
+!	   oldval(1)=tsurfS(i,j)
+	   oldval(2:nsoilold+1)=tsoilold(i,j,1:nsoilold)
+	  ! interpolate
+	  call interp_line(oldgrid,oldval,nsoilold+1,
+     &                     mlayer,newval,nsoilmx)
+	 ! copy result in tsoilold
+	 tsoiloldnew(i,j,1:nsoilmx)=newval(1:nsoilmx)
+	 enddo
+	enddo
+!	write(*,*)'tsoiloldnew(1,1,1):',tsoiloldnew(1,1,1)
+        ! cleanup
+	deallocate(oldgrid)
+	deallocate(oldval)
+	deallocate(newval)
+       
+       else
+        tsoiloldnew(:,:,:)=tsoilold(:,:,:)
+       endif ! of if (depthinterpol)
+      endif ! of if (olddepthdef)
+
+      ! Do the horizontal interpolation
+       call interp_horiz(tsoiloldnew,tsoilS,
+     &                  imold,jmold,iim,jjm,nsoilmx,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+
+      ! Reshape tsoilS to scalar grid as tsoil
+       call gr_dyn_fi (nsoilmx,iim+1,jjm+1,ngrid,tsoilS,tsoil)
+
+c-----------------------------------------------------------------------
+c 6.3   Slab Ocean :
+c-----------------------------------------------------------------------
+      call interp_horiz (tslabold,tslabs,imold,jmold,iim,jjm,noceanmx,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (noceanmx,iim+1,jjm+1,ngrid,tslabs,tslab)
+
+      call interp_horiz (rnatold,rnats,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,rnats,rnat)
+
+      call interp_horiz (pctsrf_sicold,pctsrf_sics,imold,jmold,iim,
+     &                   jjm,1,rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,pctsrf_sics,pctsrf_sic)
+
+      call interp_horiz (tsea_iceold,tsea_ices,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,tsea_ices,tsea_ice)
+
+      call interp_horiz (sea_iceold,sea_ices,imold,jmold,iim,jjm,1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,sea_ices,sea_ice)
+
+c-----------------------------------------------------------------------
+c 6.4 Variable 3d :
+c-----------------------------------------------------------------------
+      
+c temperatures atmospheriques
+      write (*,*) 'lect_start_archive: told ', told (1,jmold+1,1)  ! INFO
+      call interp_vert
+     &    (told,var,lmold,llm,apsold,bpsold,aps,bps,
+     &     psold,(imold+1)*(jmold+1))
+      write (*,*) 'lect_start_archive: var ', var (1,jmold+1,1)  ! INFO
+      call interp_horiz(var,t,imold,jmold,iim,jjm,llm,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      write (*,*) 'lect_start_archive: t ', t(1,jjp1,1)  ! INFO
+
+c q2 : pbl wind variance
+      write (*,*) 'lect_start_archive: q2old ', q2old (1,2,1)  ! INFO
+      call interp_vert (q2old,varp1,lmold+1,llm+1,
+     &     apsold,bpsold,ap,bp,psold,(imold+1)*(jmold+1))
+      write (*,*) 'lect_start_archive: varp1 ', varp1 (1,2,1)  ! INFO
+      call interp_horiz(varp1,q2s,imold,jmold,iim,jjm,llm+1,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      write (*,*) 'lect_start_archive: q2s ', q2s (1,2,1)  ! INFO
+      call gr_dyn_fi (llm+1,iim+1,jjm+1,ngrid,q2s,q2)
+      write (*,*) 'lect_start_archive: q2 ', q2 (1,2)  ! INFO
+c     write(47,*) 'q2',q2
+
+c calcul des champ de vent; passage en vent covariant
+      write (*,*) 'lect_start_archive: uold ', uold (1,2,1)  ! INFO
+      call interp_vert
+     & (uold,var,lmold,llm,apsold,bpsold,aps,bps,
+     &  psold,(imold+1)*(jmold+1))
+      write (*,*) 'lect_start_archive: var ', var (1,2,1)  ! INFO
+      call interp_horiz(var,us,imold,jmold,iim,jjm,llm,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      write (*,*) 'lect_start_archive: us ', us (1,2,1)   ! INFO
+
+      call interp_vert
+     & (vold,var,lmold,llm,
+     &  apsold,bpsold,aps,bps,psold,(imold+1)*(jmold+1))
+      call interp_horiz(var,vs,imold,jmold,iim,jjm,llm,
+     &                   rlonuold,rlatvold,rlonu,rlatv)
+      call scal_wind(us,vs,unat,vnat)
+      write (*,*) 'lect_start_archive: unat ', unat (1,2,1)    ! INFO
+      do l=1,llm
+        do j = 1, jjp1
+          do i=1,iip1
+            ucov( i,j,l ) = unat( i,j,l ) * cu(i,j)
+c           ucov( i,j,l ) = 0
+          end do
+        end do
+      end do 
+      write (*,*) 'lect_start_archive: ucov ', ucov (1,2,1)  ! INFO
+c     write(48,*) 'ucov',ucov
+      do l=1,llm
+        do j = 1, jjm
+          do i=1,iim
+            vcov( i,j,l ) = vnat( i,j,l ) * cv(i,j)
+c           vcov( i,j,l ) = 0
+          end do
+          vcov( iip1,j,l ) = vcov( 1,j,l )
+        end do
+      end do
+c     write(49,*) 'ucov',vcov
+
+      if (nqtot .gt. 0) then
+c traceurs surface
+      do iq = 1, nqtot
+            call interp_horiz(qsurfold(1,1,iq) ,qsurfs(1,1,iq),
+     &                  imold,jmold,iim,jjm,1,
+     &                  rlonuold,rlatvold,rlonu,rlatv)
+      enddo
+
+      call gr_dyn_fi (nqtot,iim+1,jjm+1,ngrid,qsurfs,qsurf)
+
+c traceurs 3D
+      do  iq = 1, nqtot
+            call interp_vert(qold(1,1,1,iq),var,lmold,llm,
+     &        apsold,bpsold,aps,bps,psold,(imold+1)*(jmold+1))
+            call interp_horiz(var,q(1,1,1,iq),imold,jmold,iim,jjm,llm,
+     &                  rlonuold,rlatvold,rlonu,rlatv)
+      enddo
+cccccccccccccccccccccccccccccc      
+c  make sure that sum of q = 1      
+c dominent species is = 1 - sum(all other species)      
+cccccccccccccccccccccccccccccc      
+c      iqmax=1
+c      
+c      if (nqold.gt.10) then
+c       do l=1,llm
+c        do j=1,jjp1
+c          do i=1,iip1
+c           do iq=1,nqold
+c            if (q(i,j,l,iq).gt.q(i,j,l,iqmax)) then
+c              iqmax=iq
+c            endif
+c           enddo
+c           q(i,j,l,iqmax)=1.
+c           qtot(i,j,l)=0
+c           do iq=1,nqold
+c            if (iq.ne.iqmax) then        
+c              q(i,j,l,iqmax)=q(i,j,l,iqmax)-q(i,j,l,iq)        
+c            endif
+c           enddo !iq
+c           do iq=1,nqold
+c            qtot(i,j,l)=qtot(i,j,l)+q(i,j,l,iq)
+c            if (i.eq.1.and.j.eq.1.and.l.Eq.1) write(*,*)' qtot(i,j,l)',
+c     $    qtot(i,j,l)
+c           enddo !iq
+c          enddo !i   
+c         enddo !j   
+c       enddo !l  
+c      endif
+ccccccccccccccccccccccccccccccc
+
+c     Periodicite :
+      do  iq = 1, nqtot
+         do l=1, llm
+            do j = 1, jjp1
+               q(iip1,j,l,iq) = q(1,j,l,iq)
+            end do
+         end do
+      enddo
+      
+!      call gr_dyn_fi (1,iim+1,jjm+1,ngrid,co2ices,co2ice)
+! no need to transfer "co2ice" any more; it is in qsurf(igcm_co2_ice)
+
+      endif !! if nqtot .ne. 0
+
+c-----------------------------------------------------------------------
+c   Initialisation  h:	(passage de t -> h)
+c-----------------------------------------------------------------------
+
+      DO l=1,llm
+         DO j=1,jjp1
+            DO i=1,iim
+               h(i,j,l) = t(i,j,l)*((ps(i,j)/preff)**kappa)
+            END DO
+            h(iip1,j,l) =  h(1,j,l)
+         END DO
+      END DO
+
+
+c***********************************************************************
+c***********************************************************************
+c     Fin subroutine lecture ini
+c***********************************************************************
+c***********************************************************************
+
+      deallocate(timelist)
+      deallocate(rlonuold, rlatvold)
+      deallocate(rlonvold, rlatuold)
+      deallocate(apsold,bpsold)
+      deallocate(uold)
+      deallocate(vold)
+      deallocate(told)
+      deallocate(psold)
+      deallocate(phisold)
+      deallocate(qold)
+      deallocate(co2iceold)
+      deallocate(tsurfold)
+      deallocate(emisold)
+      deallocate(q2old)
+      deallocate(tsoilold)
+      deallocate(tsoiloldnew)
+      deallocate(inertiedatold)
+      deallocate(inertiedatoldnew)
+      deallocate(surfithold)
+      deallocate(mlayerold)
+      deallocate(qsurfold)
+      deallocate(var,varp1)
+      deallocate(tslabold)
+      deallocate(rnatold)
+      deallocate(pctsrf_sicold)
+      deallocate(tsea_iceold)
+      deallocate(sea_iceold)
+
+!      write(*,*)'lect_start_archive: END'
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/newstart.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/newstart.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/newstart.F	(revision 1644)
@@ -0,0 +1,1667 @@
+C======================================================================
+      PROGRAM newstart
+c=======================================================================
+c
+c
+c   Auteur:   Christophe Hourdin/Francois Forget/Yann Wanherdrick
+c   ------
+c             Derniere modif : 12/03
+c
+c
+c   Objet:  Create or modify the initial state for the LMD Mars GCM
+c   -----           (fichiers NetCDF start et startfi)
+c
+c
+c=======================================================================
+
+      use mod_phys_lmdz_para, only: is_parallel, is_sequential,
+     &                              is_mpi_root, is_omp_root,
+     &                              is_master
+      use infotrac, only: infotrac_init, nqtot, tname
+      USE tracer_h, ONLY: igcm_co2_ice, igcm_h2o_vap, igcm_h2o_ice
+      USE comsoil_h, ONLY: nsoilmx, layer, mlayer, inertiedat
+      USE surfdat_h, ONLY: phisfi, albedodat,
+     &                     zmea, zstd, zsig, zgam, zthe
+      use datafile_mod, only: datadir, surfdir
+      use ioipsl_getin_p_mod, only: getin_p
+      use control_mod, only: day_step, iphysiq, anneeref, planet_type
+      use phyredem, only: physdem0, physdem1
+      use iostart, only: open_startphy
+      use slab_ice_h, only:noceanmx
+      use filtreg_mod, only: inifilr
+      USE mod_const_mpi, ONLY: COMM_LMDZ
+      USE comvert_mod, ONLY: ap,bp,aps,bps,pa,preff
+      USE comconst_mod, ONLY: lllm,daysec,dtvr,dtphys,cpp,kappa,
+     .                        rad,omeg,g,r,pi
+      USE serre_mod, ONLY: alphax
+      USE temps_mod, ONLY: day_ini
+      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      use iniphysiq_mod, only: iniphysiq
+      implicit none
+
+      include "dimensions.h"
+      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) 
+      include "paramet.h"
+      include "comgeom2.h"
+      include "comdissnew.h"
+      include "netcdf.inc"
+
+c=======================================================================
+c   Declarations
+c=======================================================================
+
+c Variables dimension du fichier "start_archive"
+c------------------------------------
+      CHARACTER        relief*3
+
+
+c Variables pour les lectures NetCDF des fichiers "start_archive" 
+c--------------------------------------------------
+      INTEGER nid_dyn, nid_fi,nid,nvarid
+      INTEGER length
+      parameter (length = 100)
+      INTEGER tab0
+      INTEGER   NB_ETATMAX
+      parameter (NB_ETATMAX = 100)
+
+      REAL  date
+      REAL p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec
+
+c Variable histoire 
+c------------------
+      REAL vcov(iip1,jjm,llm),ucov(iip1,jjp1,llm) ! vents covariants
+      REAL phis(iip1,jjp1)
+      REAL,ALLOCATABLE :: q(:,:,:,:)               ! champs advectes
+
+c autre variables dynamique nouvelle grille
+c------------------------------------------
+      REAL pks(iip1,jjp1)
+      REAL w(iip1,jjp1,llm+1)
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
+!      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
+!      REAL dh(ip1jmp1,llm),dp(ip1jmp1)
+      REAL phi(iip1,jjp1,llm)
+
+      integer klatdat,klongdat
+      PARAMETER (klatdat=180,klongdat=360)
+
+c Physique sur grille scalaire 
+c----------------------------
+      real zmeaS(iip1,jjp1),zstdS(iip1,jjp1)
+      real zsigS(iip1,jjp1),zgamS(iip1,jjp1),ztheS(iip1,jjp1)
+
+c variable physique
+c------------------
+      REAL tsurf(ngridmx)        ! surface temperature
+      REAL,ALLOCATABLE :: tsoil(:,:) ! soil temperature
+!      REAL co2ice(ngridmx)        ! CO2 ice layer
+      REAL emis(ngridmx)        ! surface emissivity
+      real emisread             ! added by RW
+      REAL,ALLOCATABLE :: qsurf(:,:)
+      REAL q2(ngridmx,llm+1)
+!      REAL rnaturfi(ngridmx)
+      real alb(iip1,jjp1),albfi(ngridmx) ! albedos
+      real,ALLOCATABLE :: ith(:,:,:),ithfi(:,:) ! thermal inertia (3D)
+      real surfith(iip1,jjp1),surfithfi(ngridmx) ! surface thermal inertia (2D)
+      REAL latfi(ngridmx),lonfi(ngridmx),airefi(ngridmx)
+
+      INTEGER i,j,l,isoil,ig,idum
+      real mugaz ! molar mass of the atmosphere
+
+      integer ierr 
+
+      REAL rnat(ngridmx)
+      REAL,ALLOCATABLE :: tslab(:,:) ! slab ocean temperature
+      REAL pctsrf_sic(ngridmx) ! sea ice cover
+      REAL tsea_ice(ngridmx) ! temperature sea_ice
+      REAL sea_ice(ngridmx) ! mass of sea ice (kg/m2)
+
+c Variables on the new grid along scalar points 
+c------------------------------------------------------
+!      REAL p(iip1,jjp1)
+      REAL t(iip1,jjp1,llm)
+      REAL tset(iip1,jjp1,llm)
+      real phisold_newgrid(iip1,jjp1)
+      REAL :: teta(iip1, jjp1, llm)
+      REAL :: pk(iip1,jjp1,llm)
+      REAL :: pkf(iip1,jjp1,llm)
+      REAL :: ps(iip1, jjp1)
+      REAL :: masse(iip1,jjp1,llm)
+      REAL :: xpn,xps,xppn(iim),xpps(iim)
+      REAL :: p3d(iip1, jjp1, llm+1)
+      REAL :: beta(iip1,jjp1,llm)
+!      REAL dteta(ip1jmp1,llm)
+
+c Variable de l'ancienne grille 
+c------------------------------
+      real time
+      real tab_cntrl(100)
+      real tab_cntrl_bis(100)
+
+c variables diverses
+c-------------------
+      real choix_1,pp
+      character*80      fichnom
+      character*250  filestring
+      integer Lmodif,iq
+      character modif*20
+      real z_reel(iip1,jjp1)
+      real tsud,albsud,alb_bb,ith_bb,Tiso,Tabove
+      real ptoto,pcap,patm,airetot,ptotn,patmn,psea
+!      real ssum
+      character*1 yes
+      logical :: flagtset=.false. ,  flagps0=.false.
+      real val, val2, val3, val4 ! to store temporary variables
+      real :: iceith=2000 ! thermal inertia of subterranean ice
+
+      INTEGER :: itau
+      
+      character(len=20) :: txt ! to store some text
+      character(len=50) :: surfacefile ! "surface.nc" (or equivalent file)
+      character(len=150) :: longline
+      integer :: count
+      real :: profile(llm+1) ! to store an atmospheric profile + surface value
+
+!     added by BC for equilibrium temperature startup
+      real teque
+
+!     added by BC for cloud fraction setup
+      REAL hice(ngridmx),cloudfrac(ngridmx,llm)
+      REAL totalfrac(ngridmx)
+
+
+!     added by RW for nuketharsis
+      real fact1
+      real fact2
+
+
+c sortie visu pour les champs dynamiques
+c---------------------------------------
+!      INTEGER :: visuid
+!      real :: time_step,t_ops,t_wrt
+!      CHARACTER*80 :: visu_file
+
+      cpp    = 0.
+      preff  = 0.
+      pa     = 0. ! to ensure disaster rather than minor error if we don`t
+                  ! make deliberate choice of these values elsewhere.
+
+      planet_type="titan"
+
+! initialize "serial/parallel" related stuff
+! (required because we call tabfi() below, before calling iniphysiq)
+      is_sequential=.true.
+      is_parallel=.false.
+      is_mpi_root=.true.
+      is_omp_root=.true.
+      is_master=.true.
+      
+! Load tracer number and names:
+      call infotrac_init
+! allocate arrays
+      allocate(q(iip1,jjp1,llm,nqtot))
+      allocate(qsurf(ngridmx,nqtot))
+      
+! get value of nsoilmx and allocate corresponding arrays
+      ! a default value of nsoilmx is set in comsoil_h
+      call getin_p("nsoilmx",nsoilmx)
+      
+      allocate(tsoil(ngridmx,nsoilmx))
+      allocate(ith(iip1,jjp1,nsoilmx),ithfi(ngridmx,nsoilmx))
+      allocate(tslab(ngridmx,nsoilmx))
+      
+c=======================================================================
+c   Choice of the start file(s) to use
+c=======================================================================
+      write(*,*) 'From which kind of files do you want to create new',
+     .  'start and startfi files'
+      write(*,*) '    0 - from a file start_archive'
+      write(*,*) '    1 - from files start and startfi'
+ 
+c-----------------------------------------------------------------------
+c   Open file(s) to modify (start or start_archive)
+c-----------------------------------------------------------------------
+
+      DO
+         read(*,*,iostat=ierr) choix_1
+         if ((choix_1 /= 0).OR.(choix_1 /=1)) EXIT
+      ENDDO
+
+c     Open start_archive
+c     ~~~~~~~~~~~~~~~~~~~~~~~~~~
+      if (choix_1.eq.0) then
+
+        write(*,*) 'Creating start files from:'
+        write(*,*) './start_archive.nc'
+        write(*,*)
+        fichnom = 'start_archive.nc'
+        ierr = NF_OPEN (fichnom, NF_NOWRITE,nid)
+        IF (ierr.NE.NF_NOERR) THEN
+          write(6,*)' Problem opening file:',fichnom
+          write(6,*)' ierr = ', ierr
+          CALL ABORT
+        ENDIF
+        tab0 = 50 
+        Lmodif = 1
+
+c     OR open start and startfi files
+c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+      else
+        write(*,*) 'Creating start files from:'
+        write(*,*) './start.nc and ./startfi.nc'
+        write(*,*)
+        fichnom = 'start.nc'
+        ierr = NF_OPEN (fichnom, NF_NOWRITE,nid_dyn)
+        IF (ierr.NE.NF_NOERR) THEN
+          write(6,*)' Problem opening file:',fichnom
+          write(6,*)' ierr = ', ierr
+          CALL ABORT
+        ENDIF
+ 
+        fichnom = 'startfi.nc'
+        ierr = NF_OPEN (fichnom, NF_NOWRITE,nid_fi)
+        IF (ierr.NE.NF_NOERR) THEN
+          write(6,*)' Problem opening file:',fichnom
+          write(6,*)' ierr = ', ierr
+          CALL ABORT
+        ENDIF
+
+        tab0 = 0 
+        Lmodif = 0
+
+      endif
+
+
+c=======================================================================
+c  INITIALISATIONS DIVERSES
+c=======================================================================
+
+! Initialize global tracer indexes (stored in tracer.h)
+! ... this has to be done before phyetat0
+      call initracer(ngridmx,nqtot,tname)
+
+! Take care of arrays in common modules
+      ! ALLOCATE ARRAYS in surfdat_h (if not already done, e.g. when using start_archive)
+      IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(ngridmx))
+      IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(ngridmx))
+      IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(ngridmx))
+      IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(ngridmx))
+      IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(ngridmx))
+      IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(ngridmx))
+      IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(ngridmx))
+
+c-----------------------------------------------------------------------
+c Lecture du tableau des parametres du run (pour la dynamique)
+c-----------------------------------------------------------------------
+      if (choix_1.eq.0) then
+
+        write(*,*) 'reading tab_cntrl START_ARCHIVE'
+c
+        ierr = NF_INQ_VARID (nid, "controle", nvarid)
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid, nvarid, tab_cntrl)
+#else
+        ierr = NF_GET_VAR_REAL(nid, nvarid, tab_cntrl)
+#endif
+c
+      else if (choix_1.eq.1) then
+
+        write(*,*) 'reading tab_cntrl START'
+c
+        ierr = NF_INQ_VARID (nid_dyn, "controle", nvarid)
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid_dyn, nvarid, tab_cntrl)
+#else
+        ierr = NF_GET_VAR_REAL(nid_dyn, nvarid, tab_cntrl)
+#endif
+c
+        write(*,*) 'reading tab_cntrl STARTFI'
+c
+        ierr = NF_INQ_VARID (nid_fi, "controle", nvarid)
+#ifdef NC_DOUBLE
+        ierr = NF_GET_VAR_DOUBLE(nid_fi, nvarid, tab_cntrl_bis)
+#else
+        ierr = NF_GET_VAR_REAL(nid_fi, nvarid, tab_cntrl_bis)
+#endif
+c
+        do i=1,50
+          tab_cntrl(i+50)=tab_cntrl_bis(i)
+        enddo
+        write(*,*) 'printing tab_cntrl', tab_cntrl
+        do i=1,100
+          write(*,*) i,tab_cntrl(i)
+        enddo
+        
+        write(*,*) 'Reading file START'
+        fichnom = 'start.nc'
+        CALL dynetat0(fichnom,vcov,ucov,teta,q,masse,
+     .       ps,phis,time)
+
+        CALL iniconst
+        CALL inigeom
+
+! Initialize the physics
+         CALL iniphysiq(iim,jjm,llm,
+     &                  (jjm-1)*iim+2,comm_lmdz,
+     &                  daysec,day_ini,dtphys,
+     &                  rlatu,rlatv,rlonu,rlonv,
+     &                  aire,cu,cv,rad,g,r,cpp,
+     &                  1)
+
+        ! Lmodif set to 0 to disable modifications possibility in phyeta0                           
+        Lmodif=0
+        write(*,*) 'Reading file STARTFI'
+        fichnom = 'startfi.nc'
+        CALL phyetat0 (ngridmx,llm,fichnom,tab0,Lmodif,nsoilmx,
+     .        nqtot,day_ini,time,
+     .        tsurf,tsoil,emis,q2,qsurf,   !) ! temporary modif by RDW
+     .        cloudfrac,totalfrac,hice,rnat,pctsrf_sic,tslab,tsea_ice,
+     .        sea_ice)
+
+        ! copy albedo and soil thermal inertia on (local) physics grid
+        do i=1,ngridmx
+          albfi(i) = albedodat(i)
+          do j=1,nsoilmx
+           ithfi(i,j) = inertiedat(i,j)
+          enddo
+        ! build a surfithfi(:) using 1st layer of ithfi(:), which might
+        ! be needed later on if reinitializing soil thermal inertia
+          surfithfi(i)=ithfi(i,1)
+        enddo
+        ! also copy albedo and soil thermal inertia on (local) dynamics grid
+        ! so that options below can manipulate either (but must then ensure
+        ! to correctly recast things on physics grid)
+        call gr_fi_dyn(1,ngridmx,iip1,jjp1,albfi,alb)
+        call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,ithfi,ith)
+        call gr_fi_dyn(1,ngridmx,iip1,jjp1,surfithfi,surfith)
+      
+      endif
+c-----------------------------------------------------------------------
+c                Initialisation des constantes dynamique
+c-----------------------------------------------------------------------
+
+      kappa = tab_cntrl(9) 
+      etot0 = tab_cntrl(12)
+      ptot0 = tab_cntrl(13)
+      ztot0 = tab_cntrl(14)
+      stot0 = tab_cntrl(15)
+      ang0 = tab_cntrl(16)
+      write(*,*) "Newstart: kappa,etot0,ptot0,ztot0,stot0,ang0"
+      write(*,*) kappa,etot0,ptot0,ztot0,stot0,ang0
+
+      ! for vertical coordinate
+      preff=tab_cntrl(18) ! reference surface pressure
+      pa=tab_cntrl(17)  ! reference pressure at which coord is purely pressure
+      !NB: in start_archive files tab_cntrl(17)=tab_cntrl(18)=0
+      write(*,*) "Newstart: preff=",preff," pa=",pa
+      yes=' '
+      do while ((yes.ne.'y').and.(yes.ne.'n'))
+        write(*,*) "Change the values of preff and pa? (y/n)"
+        read(*,fmt='(a)') yes
+      end do
+      if (yes.eq.'y') then
+        write(*,*)"New value of reference surface pressure preff?"
+        write(*,*)"   (for Mars, typically preff=610)"
+        read(*,*) preff
+        write(*,*)"New value of reference pressure pa for purely"
+        write(*,*)"pressure levels (for hybrid coordinates)?"
+        write(*,*)"   (for Mars, typically pa=20)"
+        read(*,*) pa
+      endif
+c-----------------------------------------------------------------------
+c   Lecture du tab_cntrl et initialisation des constantes physiques
+c  - pour start:  Lmodif = 0 => pas de modifications possibles
+c                  (modif dans le tabfi de readfi + loin)
+c  - pour start_archive:  Lmodif = 1 => modifications possibles
+c-----------------------------------------------------------------------
+      if (choix_1.eq.0) then
+         ! tabfi requires that input file be first opened by open_startphy(fichnom)
+         fichnom = 'start_archive.nc'
+         call open_startphy(fichnom)
+         call tabfi (ngridmx,nid,Lmodif,tab0,day_ini,lllm,p_rad,
+     .            p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
+      else if (choix_1.eq.1) then
+         fichnom = 'startfi.nc'
+         call open_startphy(fichnom)
+         Lmodif=1 ! Lmodif set to 1 to allow modifications in phyeta0                           
+         call tabfi (ngridmx,nid_fi,Lmodif,tab0,day_ini,lllm,p_rad,
+     .            p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
+      endif
+
+      if (p_omeg .eq. -9999.) then
+        p_omeg = 8.*atan(1.)/p_daysec
+        print*,"new value of omega",p_omeg
+      endif
+
+      rad = p_rad
+      omeg = p_omeg
+      g = p_g
+      cpp = p_cpp
+      mugaz = p_mugaz
+      daysec = p_daysec
+
+      if (p_omeg .eq. -9999.) then
+        p_omeg = 8.*atan(1.)/p_daysec
+        print*,"new value of omega",p_omeg
+      endif
+
+      kappa = 8.314*1000./(p_mugaz*p_cpp) ! added by RDW
+
+c=======================================================================
+c  INITIALISATIONS DIVERSES
+c=======================================================================
+! Load parameters from run.def file
+      CALL defrun_new( 99, .TRUE. )
+! Initialize dynamics geometry and co. (which, when using start.nc may 
+! have changed because of modifications (tabi, preff, pa) above)
+      CALL iniconst 
+      CALL inigeom
+      idum=-1
+      idum=0
+
+! Initialize the physics for start_archive only
+      IF (choix_1.eq.0) THEN
+         CALL iniphysiq(iim,jjm,llm,
+     &                  (jjm-1)*iim+2,comm_lmdz,
+     &                  daysec,day_ini,dtphys,
+     &                  rlatu,rlatv,rlonu,rlonv,
+     &                  aire,cu,cv,rad,g,r,cpp,
+     &                  1)
+      ENDIF
+
+c=======================================================================
+c   lecture topographie, albedo, inertie thermique, relief sous-maille
+c=======================================================================
+
+      if (choix_1.eq.0) then  ! for start_archive files, 
+                              ! where an external "surface.nc" file is needed
+
+c do while((relief(1:3).ne.'mol').AND.(relief(1:3).ne.'pla'))
+c       write(*,*)
+c       write(*,*) 'choix du relief (mola,pla)'
+c       write(*,*) '(Topographie MGS MOLA, plat)'
+c       read(*,fmt='(a3)') relief
+        relief="mola"
+c     enddo
+
+!    First get the correct value of datadir, if not already done:
+        ! default 'datadir' is set in "datafile_mod"
+        call getin_p("datadir",datadir)
+        write(*,*) 'Available surface data files are:'
+        filestring='ls '//trim(datadir)//'/'//
+     &                    trim(surfdir)//' | grep .nc'
+        call system(filestring)
+        ! but in ye old days these files were in datadir, so scan it as well
+        ! for the sake of retro-compatibility
+        filestring='ls '//trim(datadir)//'/'//' | grep .nc'
+        call system(filestring)
+
+        write(*,*) ''
+        write(*,*) 'Please choose the relevant file',
+     &  ' (e.g. "surface_mars.nc")'
+        write(*,*) ' or "none" to not use any (and set planetary'
+        write(*,*) '  albedo and surface thermal inertia)'
+        read(*,fmt='(a50)') surfacefile
+
+        if (surfacefile.ne."none") then
+
+          CALL datareadnc(relief,surfacefile,phis,alb,surfith,
+     &          zmeaS,zstdS,zsigS,zgamS,ztheS)
+        else
+        ! specific case when not using a "surface.nc" file
+          phis(:,:)=0
+          zmeaS(:,:)=0
+          zstdS(:,:)=0
+          zsigS(:,:)=0
+          zgamS(:,:)=0
+          ztheS(:,:)=0
+          
+          write(*,*) "Enter value of albedo of the bare ground:"
+          read(*,*) alb(1,1)
+          alb(:,:)=alb(1,1)
+          
+          write(*,*) "Enter value of thermal inertia of soil:"
+          read(*,*) surfith(1,1)
+          surfith(:,:)=surfith(1,1)
+        
+        endif ! of if (surfacefile.ne."none")
+
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,surfith,surfithfi)
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,zmeaS,zmea)
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,zstdS,zstd)
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,zsigS,zsig)
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,zgamS,zgam)
+        CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,ztheS,zthe)
+
+      endif ! of if (choix_1.eq.0)
+
+
+c=======================================================================
+c  Lecture des fichiers (start ou start_archive)
+c=======================================================================
+
+      if (choix_1.eq.0) then
+
+        write(*,*) 'Reading file START_ARCHIVE'
+        CALL lect_start_archive(ngridmx,llm,
+     &   date,tsurf,tsoil,emis,q2,
+     &   t,ucov,vcov,ps,teta,phisold_newgrid,q,qsurf,
+     &   surfith,nid,
+     &   rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+        write(*,*) "OK, read start_archive file"
+        ! copy soil thermal inertia
+        ithfi(:,:)=inertiedat(:,:)
+        
+        ierr= NF_CLOSE(nid)
+
+      else if (choix_1.eq.1) then 
+         !do nothing, start and startfi have already been read
+      else 
+        CALL exit(1)
+      endif
+
+      dtvr   = daysec/FLOAT(day_step)
+      dtphys   = dtvr * FLOAT(iphysiq)
+
+c=======================================================================
+c 
+c=======================================================================
+
+      do ! infinite loop on list of changes
+
+      write(*,*)
+      write(*,*)
+      write(*,*) 'List of possible changes :'
+      write(*,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+      write(*,*)
+      write(*,*) 'flat : no topography ("aquaplanet")'
+      write(*,*) 'set_ps_to_preff : used if changing preff with topo'
+      write(*,*) 'nuketharsis : no Tharsis bulge'
+      write(*,*) 'bilball : uniform albedo and thermal inertia'
+      write(*,*) 'coldspole : cold subsurface and high albedo at S.pole'
+      write(*,*) 'qname : change tracer name'
+      write(*,*) 't=profile  : read temperature profile in profile.in'
+      write(*,*) 'q=0 : ALL tracer =zero'
+      write(*,*) 'q=x : give a specific uniform value to one tracer'
+      write(*,*) 'q=profile    : specify a profile for a tracer'
+!      write(*,*) 'ini_q : tracers initialisation for chemistry, water an
+!     $d ice   '
+!      write(*,*) 'ini_q-H2O : tracers initialisation for chemistry and 
+!     $ice '
+!      write(*,*) 'ini_q-iceH2O : tracers initialisation for chemistry on
+!     $ly '
+      write(*,*) 'noglacier : Remove tropical H2O ice if |lat|<45'
+      write(*,*) 'watercapn : H20 ice on permanent N polar cap '
+      write(*,*) 'watercaps : H20 ice on permanent S polar cap '
+      write(*,*) 'noacglac  : H2O ice across Noachis Terra'
+      write(*,*) 'oborealis : H2O ice across Vastitas Borealis'
+      write(*,*) 'iceball   : Thick ice layer all over surface'
+      write(*,*) 'supercontinent: Create a continent of given Ab and TI'
+      write(*,*) 'wetstart  : start with a wet atmosphere'
+      write(*,*) 'isotherm  : Isothermal Temperatures, wind set to zero'
+      write(*,*) 'radequi   : Earth-like radiative equilibrium temperature
+     $ profile (lat-alt) and winds set to zero'
+      write(*,*) 'coldstart : Start X K above the CO2 frost point and 
+     $set wind to zero (assumes 100% CO2)'
+      write(*,*) 'co2ice=0 : remove CO2 polar cap'
+      write(*,*) 'ptot : change total pressure'
+      write(*,*) 'emis : change surface emissivity'
+      write(*,*) 'therm_ini_s : Set soil thermal inertia to reference sur
+     &face values'
+      write(*,*) 'slab_ocean_0 : initialisation of slab 
+     $ocean variables'
+
+        write(*,*)
+        write(*,*) 'Change to perform ?'
+        write(*,*) '   (enter keyword or return to end)'
+        write(*,*)
+
+        read(*,fmt='(a20)') modif
+        if (modif(1:1) .eq. ' ')then
+         exit ! exit loop on changes
+        endif
+
+        write(*,*)
+        write(*,*) trim(modif) , ' : '
+
+c       'flat : no topography ("aquaplanet")'
+c       -------------------------------------
+        if (trim(modif) .eq. 'flat') then
+c         set topo to zero 
+          z_reel(1:iip1,1:jjp1)=0
+          phis(1:iip1,1:jjp1)=g*z_reel(1:iip1,1:jjp1)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
+          write(*,*) 'topography set to zero.'
+          write(*,*) 'WARNING : the subgrid topography parameters',
+     &    ' were not set to zero ! => set calllott to F'                    
+
+c        Choice of surface pressure
+         yes=' '
+         do while ((yes.ne.'y').and.(yes.ne.'n'))
+            write(*,*) 'Do you wish to choose homogeneous surface',
+     &                 'pressure (y) or let newstart interpolate ',
+     &                 ' the previous field  (n)?'
+             read(*,fmt='(a)') yes
+         end do
+         if (yes.eq.'y') then
+           flagps0=.true.
+           write(*,*) 'New value for ps (Pa) ?'
+ 201       read(*,*,iostat=ierr) patm
+            if(ierr.ne.0) goto 201
+            write(*,*) patm
+            if (patm.eq.-9999.) then
+              patm = preff
+              write(*,*) "we set patm = preff", preff
+            endif
+             write(*,*)
+             write(*,*) ' new ps everywhere (Pa) = ', patm
+             write(*,*)
+             do j=1,jjp1
+               do i=1,iip1
+                 ps(i,j)=patm
+               enddo
+             enddo
+         end if
+
+c       'set_ps_to_preff' : used if changing preff with topo  
+c       ----------------------------------------------------
+        else if (trim(modif) .eq. 'set_ps_to_preff') then
+          do j=1,jjp1
+           do i=1,iip1
+             ps(i,j)=preff
+           enddo
+          enddo
+
+c       'nuketharsis : no tharsis bulge for Early Mars'
+c       ---------------------------------------------
+        else if (trim(modif) .eq. 'nuketharsis') then
+
+           DO j=1,jjp1        
+              DO i=1,iim
+                 ig=1+(j-2)*iim +i
+                 if(j.eq.1) ig=1
+                 if(j.eq.jjp1) ig=ngridmx
+
+                 fact1=(((rlonv(i)*180./pi)+100)**2 + 
+     &                (rlatu(j)*180./pi)**2)/65**2 
+                 fact2=exp( -fact1**2.5 )
+
+                 phis(i,j) = phis(i,j) - (phis(i,j)+4000.*g)*fact2
+
+!                 if(phis(i,j).gt.2500.*g)then
+!                    if(rlatu(j)*180./pi.gt.-80.)then ! avoid chopping south polar cap
+!                       phis(i,j)=2500.*g
+!                    endif
+!                 endif
+
+              ENDDO
+           ENDDO
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
+
+
+c       bilball : uniform albedo, thermal inertia
+c       -----------------------------------------
+        else if (trim(modif) .eq. 'bilball') then
+          write(*,*) 'constante albedo and iner.therm:'
+          write(*,*) 'New value for albedo (ex: 0.25) ?'
+ 101      read(*,*,iostat=ierr) alb_bb
+          if(ierr.ne.0) goto 101
+          write(*,*)
+          write(*,*) ' uniform albedo (new value):',alb_bb
+          write(*,*)
+
+          write(*,*) 'New value for thermal inertia (eg: 247) ?'
+ 102      read(*,*,iostat=ierr) ith_bb
+          if(ierr.ne.0) goto 102
+          write(*,*) 'uniform thermal inertia (new value):',ith_bb
+          DO j=1,jjp1
+             DO i=1,iip1
+                alb(i,j) = alb_bb        ! albedo
+                do isoil=1,nsoilmx
+                  ith(i,j,isoil) = ith_bb        ! thermal inertia
+                enddo
+             END DO
+          END DO
+!          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+
+c       coldspole : sous-sol de la calotte sud toujours froid
+c       -----------------------------------------------------
+        else if (trim(modif) .eq. 'coldspole') then
+          write(*,*)'new value for the subsurface temperature',
+     &   ' beneath the permanent southern polar cap ? (eg: 141 K)'
+ 103      read(*,*,iostat=ierr) tsud
+          if(ierr.ne.0) goto 103
+          write(*,*)
+          write(*,*) ' new value of the subsurface temperature:',tsud
+c         nouvelle temperature sous la calotte permanente
+          do l=2,nsoilmx
+               tsoil(ngridmx,l) =  tsud
+          end do
+
+
+          write(*,*)'new value for the albedo',
+     &   'of the permanent southern polar cap ? (eg: 0.75)'
+ 104      read(*,*,iostat=ierr) albsud
+          if(ierr.ne.0) goto 104
+          write(*,*)
+
+c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+c         Option 1:  only the albedo of the pole is modified :    
+          albfi(ngridmx)=albsud
+          write(*,*) 'ig=',ngridmx,'   albedo perennial cap ',
+     &    albfi(ngridmx)
+
+c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+c          Option 2 A haute resolution : coordonnee de la vrai calotte ~    
+c           DO j=1,jjp1
+c             DO i=1,iip1
+c                ig=1+(j-2)*iim +i
+c                if(j.eq.1) ig=1
+c                if(j.eq.jjp1) ig=ngridmx
+c                if ((rlatu(j)*180./pi.lt.-84.).and.
+c     &            (rlatu(j)*180./pi.gt.-91.).and.
+c     &            (rlonv(i)*180./pi.gt.-91.).and.
+c     &            (rlonv(i)*180./pi.lt.0.))         then
+cc    albedo de la calotte permanente fixe a albsud
+c                   alb(i,j)=albsud
+c                   write(*,*) 'lat=',rlatu(j)*180./pi,
+c     &                      ' lon=',rlonv(i)*180./pi
+cc     fin de la condition sur les limites de la calotte permanente
+c                end if
+c             ENDDO
+c          ENDDO
+c      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+c         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+
+
+c       ptot : Modification of the total pressure: ice + current atmosphere 
+c       -------------------------------------------------------------------
+        else if (trim(modif).eq.'ptot') then
+
+          ! check if we have a co2_ice surface tracer:
+          if (igcm_co2_ice.eq.0) then
+            write(*,*) " No surface CO2 ice !"
+            write(*,*) " only atmospheric pressure will be considered!"
+          endif
+c         calcul de la pression totale glace + atm actuelle
+          patm=0.
+          airetot=0.
+          pcap=0.
+          DO j=1,jjp1
+             DO i=1,iim
+                ig=1+(j-2)*iim +i
+                if(j.eq.1) ig=1
+                if(j.eq.jjp1) ig=ngridmx
+                patm = patm + ps(i,j)*aire(i,j)
+                airetot= airetot + aire(i,j)
+                if (igcm_co2_ice.ne.0) then
+                  !pcap = pcap + aire(i,j)*co2ice(ig)*g
+                  pcap = pcap + aire(i,j)*qsurf(ig,igcm_co2_ice)*g
+                endif
+             ENDDO
+          ENDDO
+          ptoto = pcap + patm
+
+          print*,'Current total pressure at surface (co2 ice + atm) ',
+     &       ptoto/airetot
+
+          print*,'new value?'
+          read(*,*) ptotn
+          ptotn=ptotn*airetot
+          patmn=ptotn-pcap
+          print*,'ptoto,patm,ptotn,patmn'
+          print*,ptoto,patm,ptotn,patmn
+          print*,'Mult. factor for pressure (atm only)', patmn/patm
+          do j=1,jjp1
+             do i=1,iip1
+                ps(i,j)=ps(i,j)*patmn/patm
+             enddo
+          enddo
+
+
+
+c        Correction pour la conservation des traceurs
+         yes=' '
+         do while ((yes.ne.'y').and.(yes.ne.'n'))
+            write(*,*) 'Do you wish to conserve tracer total mass (y)',
+     &              ' or tracer mixing ratio (n) ?'
+             read(*,fmt='(a)') yes
+         end do
+
+         if (yes.eq.'y') then
+           write(*,*) 'OK : conservation of tracer total mass'
+           DO iq =1, nqtot
+             DO l=1,llm
+               DO j=1,jjp1
+                  DO i=1,iip1
+                    q(i,j,l,iq)=q(i,j,l,iq)*patm/patmn
+                  ENDDO
+               ENDDO
+             ENDDO
+           ENDDO
+          else
+            write(*,*) 'OK : conservation of tracer mixing ratio'
+          end if
+
+c        Correction pour la pression au niveau de la mer
+         yes=' '
+         do while ((yes.ne.'y').and.(yes.ne.'n'))
+            write(*,*) 'Do you wish fix pressure at sea level (y)',
+     &              ' or not (n) ?'
+             read(*,fmt='(a)') yes
+         end do
+
+         if (yes.eq.'y') then
+           write(*,*) 'Value?'
+                read(*,*,iostat=ierr) psea
+             DO i=1,iip1
+               DO j=1,jjp1
+                    ps(i,j)=psea
+
+                  ENDDO
+               ENDDO
+                write(*,*) 'psea=',psea
+          else
+            write(*,*) 'no'
+          end if
+
+
+c       emis : change surface emissivity (added by RW)
+c       ----------------------------------------------
+        else if (trim(modif).eq.'emis') then
+
+           print*,'new value?'
+           read(*,*) emisread
+
+           do i=1,ngridmx
+              emis(i)=emisread
+           enddo
+
+c       qname : change tracer name
+c       --------------------------
+        else if (trim(modif).eq.'qname') then
+         yes='y'
+         do while (yes.eq.'y')
+          write(*,*) 'Which tracer name do you want to change ?'
+          do iq=1,nqtot
+            write(*,'(i3,a3,a20)')iq,' : ',trim(tname(iq))
+          enddo
+          write(*,'(a35,i3)')
+     &            '(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.nqtot)) then
+            write(*,*)'Change tracer name ',trim(tname(iq)),' to ?'
+            read(*,*) txt
+            tname(iq)=txt
+            write(*,*)'Do you want to change another tracer name (y/n)?'
+            read(*,'(a)') yes 
+          else
+! inapropiate value of iq; quit this option
+            yes='n'
+          endif ! of if ((iq.ge.1).and.(iq.le.nqtot))
+         enddo ! of do while (yes.ne.'y')
+
+c       q=0 : set tracers to zero
+c       -------------------------
+        else if (trim(modif).eq.'q=0') then
+c          mise a 0 des q (traceurs)
+          write(*,*) 'Tracers set to 0 (1.E-30 in fact)'
+           DO iq =1, nqtot
+             DO l=1,llm
+               DO j=1,jjp1
+                  DO i=1,iip1
+                    q(i,j,l,iq)=1.e-30
+                  ENDDO
+               ENDDO
+             ENDDO
+           ENDDO
+
+c          set surface tracers to zero
+           DO iq =1, nqtot
+             DO ig=1,ngridmx
+                 qsurf(ig,iq)=0.
+             ENDDO
+           ENDDO
+
+c       q=x : initialise tracer manually 
+c       --------------------------------
+        else if (trim(modif).eq.'q=x') then
+             write(*,*) 'Which tracer do you want to modify ?'
+             do iq=1,nqtot
+               write(*,*)iq,' : ',trim(tname(iq))
+             enddo
+             write(*,*) '(choose between 1 and ',nqtot,')'
+             read(*,*) iq 
+             write(*,*)'mixing ratio of tracer ',trim(tname(iq)),
+     &                 ' ? (kg/kg)'
+             read(*,*) val
+             DO l=1,llm
+               DO j=1,jjp1
+                  DO i=1,iip1
+                    q(i,j,l,iq)=val
+                  ENDDO
+               ENDDO
+             ENDDO
+             write(*,*) 'SURFACE value of tracer ',trim(tname(iq)),
+     &                   ' ? (kg/m2)'
+             read(*,*) val
+             DO ig=1,ngridmx
+                 qsurf(ig,iq)=val
+             ENDDO
+
+c       t=profile : initialize temperature with a given profile
+c       -------------------------------------------------------
+        else if (trim(modif) .eq. 't=profile') then
+             write(*,*) 'Temperature profile from ASCII file'
+             write(*,*) "'profile.in' e.g. 1D output"
+             write(*,*) "(one value per line in file; starting with"
+             write(*,*) "surface value, the 1st atmospheric layer"
+             write(*,*) "followed by 2nd, etc. up to top of atmosphere)"
+             txt="profile.in"
+             open(33,file=trim(txt),status='old',form='formatted',
+     &            iostat=ierr)
+             if (ierr.eq.0) then
+               ! OK, found file 'profile_...', load the profile
+               do l=1,llm+1
+                 read(33,*,iostat=ierr) profile(l)
+                 write(*,*) profile(l)
+                 if (ierr.ne.0) then ! something went wrong
+                   exit ! quit loop
+                 endif
+               enddo
+               if (ierr.eq.0) then
+                 tsurf(1:ngridmx)=profile(1)
+                 tsoil(1:ngridmx,1:nsoilmx)=profile(1)
+                 do l=1,llm
+                   Tset(1:iip1,1:jjp1,l)=profile(l+1)
+                   flagtset=.true.
+                 enddo
+                 ucov(1:iip1,1:jjp1,1:llm)=0.
+                 vcov(1:iip1,1:jjm,1:llm)=0.
+                 q2(1:ngridmx,1:llm+1)=0.
+               else
+                 write(*,*)'problem reading file ',trim(txt),' !'
+                 write(*,*)'No modifications to temperature'
+               endif
+             else
+               write(*,*)'Could not find file ',trim(txt),' !'
+               write(*,*)'No modifications to temperature'
+             endif
+
+c       q=profile : initialize tracer with a given profile
+c       --------------------------------------------------
+        else if (trim(modif) .eq. 'q=profile') then
+             write(*,*) 'Tracer profile will be sought in ASCII file'
+             write(*,*) "'profile_tracer' where 'tracer' is tracer name"
+             write(*,*) "(one value per line in file; starting with"
+             write(*,*) "surface value, the 1st atmospheric layer"
+             write(*,*) "followed by 2nd, etc. up to top of atmosphere)"
+             write(*,*) 'Which tracer do you want to set?'
+             do iq=1,nqtot
+               write(*,*)iq,' : ',trim(tname(iq))
+             enddo
+             write(*,*) '(choose between 1 and ',nqtot,')'
+             read(*,*) iq 
+             if ((iq.lt.1).or.(iq.gt.nqtot)) then
+               ! wrong value for iq, go back to menu
+               write(*,*) "wrong input value:",iq
+               cycle
+             endif
+             ! look for input file 'profile_tracer'
+             txt="profile_"//trim(tname(iq))
+             open(41,file=trim(txt),status='old',form='formatted',
+     &            iostat=ierr)
+             if (ierr.eq.0) then
+               ! OK, found file 'profile_...', load the profile
+               do l=1,llm+1
+                 read(41,*,iostat=ierr) profile(l)
+                 if (ierr.ne.0) then ! something went wrong
+                   exit ! quit loop
+                 endif
+               enddo
+               if (ierr.eq.0) then
+                 ! initialize tracer values
+                 qsurf(:,iq)=profile(1)
+                 do l=1,llm
+                   q(:,:,l,iq)=profile(l+1)
+                 enddo
+                 write(*,*)'OK, tracer ',trim(tname(iq)),' initialized '
+     &                    ,'using values from file ',trim(txt)
+               else
+                 write(*,*)'problem reading file ',trim(txt),' !'
+                 write(*,*)'No modifications to tracer ',trim(tname(iq))
+               endif
+             else
+               write(*,*)'Could not find file ',trim(txt),' !'
+               write(*,*)'No modifications to tracer ',trim(tname(iq))
+             endif
+             
+
+c      wetstart : wet atmosphere with a north to south gradient
+c      --------------------------------------------------------
+       else if (trim(modif) .eq. 'wetstart') then
+        ! check that there is indeed a water vapor tracer
+        if (igcm_h2o_vap.eq.0) then
+          write(*,*) "No water vapour tracer! Can't use this option"
+          stop
+        endif
+          DO l=1,llm
+            DO j=1,jjp1
+              DO i=1,iip1
+                q(i,j,l,igcm_h2o_vap)=150.e-6 * (rlatu(j)+pi/2.) / pi
+              ENDDO
+            ENDDO
+          ENDDO
+
+         write(*,*) 'Water mass mixing ratio at north pole='
+     *               ,q(1,1,1,igcm_h2o_vap)
+         write(*,*) '---------------------------south pole='
+     *               ,q(1,jjp1,1,igcm_h2o_vap)
+
+c      noglacier : remove tropical water ice (to initialize high res sim)
+c      --------------------------------------------------
+        else if (trim(modif) .eq. 'noglacier') then
+           if (igcm_h2o_ice.eq.0) then
+             write(*,*) "No water ice tracer! Can't use this option"
+             stop
+           endif
+           do ig=1,ngridmx
+             j=(ig-2)/iim +2
+              if(ig.eq.1) j=1
+              write(*,*) 'OK: remove surface ice for |lat|<45'
+              if (abs(rlatu(j)*180./pi).lt.45.) then
+                   qsurf(ig,igcm_h2o_ice)=0.
+              end if
+           end do
+
+
+c      watercapn : H20 ice on permanent northern cap
+c      --------------------------------------------------
+        else if (trim(modif) .eq. 'watercapn') then
+           if (igcm_h2o_ice.eq.0) then
+             write(*,*) "No water ice tracer! Can't use this option"
+             stop
+           endif
+
+           DO j=1,jjp1        
+              DO i=1,iim
+                 ig=1+(j-2)*iim +i
+                 if(j.eq.1) ig=1
+                 if(j.eq.jjp1) ig=ngridmx
+
+                 if (rlatu(j)*180./pi.gt.80.) then
+                    qsurf(ig,igcm_h2o_ice)=3.4e3
+                    !do isoil=1,nsoilmx
+                    !   ith(i,j,isoil) = 18000. ! thermal inertia
+                    !enddo
+                   write(*,*)'     ==> Ice mesh North boundary (deg)= ',
+     &                   rlatv(j-1)*180./pi
+                 end if
+              ENDDO
+           ENDDO
+           CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+
+c$$$           do ig=1,ngridmx
+c$$$             j=(ig-2)/iim +2
+c$$$              if(ig.eq.1) j=1
+c$$$              if (rlatu(j)*180./pi.gt.80.) then
+c$$$
+c$$$                   qsurf(ig,igcm_h2o_ice)=1.e5
+c$$$                   qsurf(ig,igcm_h2o_vap)=0.0!1.e5
+c$$$
+c$$$                   write(*,*) 'ig=',ig,'    H2O ice mass (kg/m2)= ',
+c$$$     &              qsurf(ig,igcm_h2o_ice)
+c$$$
+c$$$                   write(*,*)'     ==> Ice mesh South boundary (deg)= ',
+c$$$     &              rlatv(j)*180./pi
+c$$$                end if
+c$$$           enddo
+
+c      watercaps : H20 ice on permanent southern cap
+c      -------------------------------------------------
+        else if (trim(modif) .eq. 'watercaps') then
+           if (igcm_h2o_ice.eq.0) then
+              write(*,*) "No water ice tracer! Can't use this option"
+              stop
+           endif
+
+           DO j=1,jjp1        
+              DO i=1,iim
+                 ig=1+(j-2)*iim +i
+                 if(j.eq.1) ig=1
+                 if(j.eq.jjp1) ig=ngridmx
+
+                 if (rlatu(j)*180./pi.lt.-80.) then
+                    qsurf(ig,igcm_h2o_ice)=3.4e3
+                    !do isoil=1,nsoilmx
+                    !   ith(i,j,isoil) = 18000. ! thermal inertia
+                    !enddo
+                   write(*,*)'     ==> Ice mesh South boundary (deg)= ',
+     &                   rlatv(j-1)*180./pi
+                 end if
+              ENDDO
+           ENDDO
+           CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+
+c$$$           do ig=1,ngridmx
+c$$$               j=(ig-2)/iim +2
+c$$$               if(ig.eq.1) j=1
+c$$$               if (rlatu(j)*180./pi.lt.-80.) then
+c$$$                  qsurf(ig,igcm_h2o_ice)=1.e5
+c$$$                  qsurf(ig,igcm_h2o_vap)=0.0 !1.e5
+c$$$
+c$$$                  write(*,*) 'ig=',ig,'   H2O ice mass (kg/m2)= ',
+c$$$     &                 qsurf(ig,igcm_h2o_ice)
+c$$$                  write(*,*)'     ==> Ice mesh North boundary (deg)= ',
+c$$$     &                 rlatv(j-1)*180./pi
+c$$$               end if
+c$$$           enddo
+
+
+c       noacglac : H2O ice across highest terrain
+c       --------------------------------------------
+        else if (trim(modif) .eq. 'noacglac') then
+           if (igcm_h2o_ice.eq.0) then
+             write(*,*) "No water ice tracer! Can't use this option"
+             stop
+           endif
+          DO j=1,jjp1        
+             DO i=1,iim
+                ig=1+(j-2)*iim +i
+                if(j.eq.1) ig=1
+                if(j.eq.jjp1) ig=ngridmx
+
+                if(phis(i,j).gt.1000.*g)then
+                    alb(i,j) = 0.5 ! snow value
+                    do isoil=1,nsoilmx
+                       ith(i,j,isoil) = 18000. ! thermal inertia
+                       ! this leads to rnat set to 'ocean' in physiq.F90
+                       ! actually no, because it is soil not surface
+                    enddo
+                endif
+             ENDDO
+          ENDDO
+          CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
+
+
+
+c       oborealis : H2O oceans across Vastitas Borealis
+c       -----------------------------------------------
+        else if (trim(modif) .eq. 'oborealis') then
+           if (igcm_h2o_ice.eq.0) then
+             write(*,*) "No water ice tracer! Can't use this option"
+             stop
+           endif
+          DO j=1,jjp1        
+             DO i=1,iim
+                ig=1+(j-2)*iim +i
+                if(j.eq.1) ig=1
+                if(j.eq.jjp1) ig=ngridmx
+
+                if(phis(i,j).lt.-4000.*g)then
+!                if( (phis(i,j).lt.-4000.*g)
+!     &               .and. (rlatu(j)*180./pi.lt.0.) )then ! south hemisphere only
+!                    phis(i,j)=-8000.0*g ! proper ocean
+                    phis(i,j)=-4000.0*g ! scanty ocean
+
+                    alb(i,j) = 0.07 ! oceanic value
+                    do isoil=1,nsoilmx
+                       ith(i,j,isoil) = 18000. ! thermal inertia
+                       ! this leads to rnat set to 'ocean' in physiq.F90
+                       ! actually no, because it is soil not surface
+                    enddo
+                endif
+             ENDDO
+          ENDDO
+          CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
+
+c       iborealis : H2O ice in Northern plains
+c       --------------------------------------
+        else if (trim(modif) .eq. 'iborealis') then
+           if (igcm_h2o_ice.eq.0) then
+             write(*,*) "No water ice tracer! Can't use this option"
+             stop
+           endif
+          DO j=1,jjp1        
+             DO i=1,iim
+                ig=1+(j-2)*iim +i
+                if(j.eq.1) ig=1
+                if(j.eq.jjp1) ig=ngridmx
+
+                if(phis(i,j).lt.-4000.*g)then
+                   !qsurf(ig,igcm_h2o_ice)=1.e3
+                   qsurf(ig,igcm_h2o_ice)=241.4 ! to make total 33 kg m^-2
+                endif
+             ENDDO
+          ENDDO
+          CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
+
+
+c       oceanball : H2O liquid everywhere
+c       ----------------------------
+        else if (trim(modif) .eq. 'oceanball') then
+           if (igcm_h2o_ice.eq.0) then
+             write(*,*) "No water ice tracer! Can't use this option"
+             stop
+           endif
+          DO j=1,jjp1        
+             DO i=1,iim
+                ig=1+(j-2)*iim +i
+                if(j.eq.1) ig=1
+                if(j.eq.jjp1) ig=ngridmx
+
+                qsurf(ig,igcm_h2o_vap)=0.0    ! for ocean, this is infinite source
+                qsurf(ig,igcm_h2o_ice)=0.0
+                alb(i,j) = 0.07 ! ocean value
+
+                do isoil=1,nsoilmx
+                   ith(i,j,isoil) = 18000. ! thermal inertia
+                   !ith(i,j,isoil) = 50. ! extremely low for test
+                   ! this leads to rnat set to 'ocean' in physiq.F90
+                enddo
+
+             ENDDO
+          ENDDO
+          CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,phis,phisfi)
+
+c       iceball : H2O ice everywhere
+c       ----------------------------
+        else if (trim(modif) .eq. 'iceball') then
+           if (igcm_h2o_ice.eq.0) then
+             write(*,*) "No water ice tracer! Can't use this option"
+             stop
+           endif
+          DO j=1,jjp1        
+             DO i=1,iim
+                ig=1+(j-2)*iim +i
+                if(j.eq.1) ig=1
+                if(j.eq.jjp1) ig=ngridmx
+
+                qsurf(ig,igcm_h2o_vap)=-50.    ! for ocean, this is infinite source
+                qsurf(ig,igcm_h2o_ice)=50.     ! == to 0.05 m of oceanic ice
+                alb(i,j) = 0.6 ! ice albedo value
+
+                do isoil=1,nsoilmx
+                   !ith(i,j,isoil) = 18000. ! thermal inertia
+                   ! this leads to rnat set to 'ocean' in physiq.F90
+                enddo
+
+             ENDDO
+          ENDDO
+          CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+
+c       supercontinent : H2O ice everywhere
+c       ----------------------------
+        else if (trim(modif) .eq. 'supercontinent') then
+          write(*,*) 'Minimum longitude (-180,180)'
+          read(*,*) val
+          write(*,*) 'Maximum longitude (-180,180)'
+          read(*,*) val2
+          write(*,*) 'Minimum latitude (-90,90)'
+          read(*,*) val3
+          write(*,*) 'Maximum latitude (-90,90)'
+          read(*,*) val4
+
+          do j=1,jjp1
+            do i=1,iip1
+              ig=1+(j-2)*iim +i
+              if(j.eq.1) ig=1
+              if(j.eq.jjp1) ig=ngridmx
+
+c             Supercontinent:
+              if (((rlatu(j)*180./pi.le.val4).and.
+     &            (rlatu(j)*180./pi.ge.val3).and.
+     &            (rlonv(i)*180./pi.le.val2).and.
+     &            (rlonv(i)*180./pi.ge.val))) then
+
+                rnat(ig)=1.
+                alb(i,j) = 0.3
+                do isoil=1,nsoilmx
+                  ith(i,j,isoil) = 2000.
+                enddo
+c             Ocean:
+              else
+                rnat(ig)=0.
+                alb(i,j) = 0.07
+                do isoil=1,nsoilmx
+                  ith(i,j,isoil) = 18000.
+                enddo
+              end if
+
+            enddo
+          enddo
+          CALL gr_dyn_fi(nsoilmx,iip1,jjp1,ngridmx,ith,ithfi)
+          CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,alb,albfi)
+
+c       isotherm : Isothermal temperatures and no winds
+c       -----------------------------------------------
+        else if (trim(modif) .eq. 'isotherm') then
+
+          write(*,*)'Isothermal temperature of the atmosphere, 
+     &           surface and subsurface'
+          write(*,*) 'Value of this temperature ? :'
+ 203      read(*,*,iostat=ierr) Tiso
+          if(ierr.ne.0) goto 203
+
+          tsurf(1:ngridmx)=Tiso
+          
+          tsoil(1:ngridmx,1:nsoilmx)=Tiso
+          
+          Tset(1:iip1,1:jjp1,1:llm)=Tiso
+          flagtset=.true.
+
+          t(1:iip1,1:jjp1,1:llm)=Tiso
+          !! otherwise hydrost. integrations below
+          !! use the wrong temperature
+          !! -- NB: Tset might be useless
+        
+          ucov(1:iip1,1:jjp1,1:llm)=0
+          vcov(1:iip1,1:jjm,1:llm)=0
+          q2(1:ngridmx,1:llm+1)=0
+
+c       radequi : Radiative equilibrium profile of temperatures and no winds
+c       --------------------------------------------------------------------
+        else if (trim(modif) .eq. 'radequi') then
+
+          write(*,*)'radiative equilibrium temperature profile'       
+
+          do ig=1, ngridmx
+             teque= 335.0-60.0*sin(latfi(ig))*sin(latfi(ig))-
+     &            10.0*cos(latfi(ig))*cos(latfi(ig))
+             tsurf(ig) = MAX(220.0,teque)
+          end do
+          do l=2,nsoilmx
+             do ig=1, ngridmx
+                tsoil(ig,l) = tsurf(ig)
+             end do
+          end do
+          DO j=1,jjp1
+             DO i=1,iim
+                Do l=1,llm
+                   teque=335.-60.0*sin(rlatu(j))*sin(rlatu(j))-
+     &                  10.0*cos(rlatu(j))*cos(rlatu(j))
+                   Tset(i,j,l)=MAX(220.0,teque)
+                end do
+             end do
+          end do
+          flagtset=.true.
+          ucov(1:iip1,1:jjp1,1:llm)=0
+          vcov(1:iip1,1:jjm,1:llm)=0
+          q2(1:ngridmx,1:llm+1)=0
+
+c       coldstart : T set 1K above CO2 frost point and no winds
+c       ------------------------------------------------
+        else if (trim(modif) .eq. 'coldstart') then
+
+          write(*,*)'set temperature of the atmosphere,' 
+     &,'surface and subsurface how many degrees above CO2 frost point?'
+ 204      read(*,*,iostat=ierr) Tabove
+          if(ierr.ne.0) goto 204
+
+            DO j=1,jjp1
+             DO i=1,iim
+                ig=1+(j-2)*iim +i
+                if(j.eq.1) ig=1
+                if(j.eq.jjp1) ig=ngridmx
+            tsurf(ig) = (-3167.8)/(log(.01*ps(i,j))-23.23)+Tabove
+             END DO
+            END DO
+          do l=1,nsoilmx
+            do ig=1, ngridmx
+              tsoil(ig,l) = tsurf(ig)
+            end do
+          end do
+          DO j=1,jjp1
+           DO i=1,iim
+            Do l=1,llm
+               pp = aps(l) +bps(l)*ps(i,j) 
+               Tset(i,j,l)=(-3167.8)/(log(.01*pp)-23.23)+Tabove
+            end do
+           end do
+          end do
+
+          flagtset=.true.
+          ucov(1:iip1,1:jjp1,1:llm)=0
+          vcov(1:iip1,1:jjm,1:llm)=0
+          q2(1:ngridmx,1:llm+1)=0
+
+
+c       co2ice=0 : remove CO2 polar ice caps'
+c       ------------------------------------------------
+        else if (trim(modif) .eq. 'co2ice=0') then
+         ! check that there is indeed a co2_ice tracer ...
+          if (igcm_co2_ice.ne.0) then
+           do ig=1,ngridmx
+              !co2ice(ig)=0
+              qsurf(ig,igcm_co2_ice)=0
+              emis(ig)=emis(ngridmx/2)
+           end do
+          else
+            write(*,*) "Can't remove CO2 ice!! (no co2_ice tracer)"
+          endif
+        
+!       therm_ini_s: (re)-set soil thermal inertia to reference surface values
+!       ----------------------------------------------------------------------
+
+        else if (trim(modif) .eq. 'therm_ini_s') then
+!          write(*,*)"surfithfi(1):",surfithfi(1)
+          do isoil=1,nsoilmx
+            inertiedat(1:ngridmx,isoil)=surfithfi(1:ngridmx)
+          enddo
+          write(*,*)'OK: Soil thermal inertia has been reset to referenc
+     &e surface values'
+!          write(*,*)"inertiedat(1,1):",inertiedat(1,1)
+          ithfi(:,:)=inertiedat(:,:)
+         ! recast ithfi() onto ith()
+         call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,ithfi,ith)
+! Check:
+!         do i=1,iip1
+!           do j=1,jjp1
+!             do isoil=1,nsoilmx
+!               write(77,*) i,j,isoil,"  ",ith(i,j,isoil)
+!             enddo
+!           enddo
+!         enddo
+
+
+
+c       slab_ocean_initialisation
+c       ------------------------------------------------
+        else if (trim(modif) .eq. 'slab_ocean_0') then
+        write(*,*)'OK: initialisation of slab ocean' 
+
+      DO ig=1, ngridmx
+         rnat(ig)=1.
+         tslab(ig,1)=0.
+         tslab(ig,2)=0.
+         tsea_ice(ig)=0.
+         sea_ice(ig)=0.
+         pctsrf_sic(ig)=0.
+         
+         if(ithfi(ig,1).GT.10000.)then
+           rnat(ig)=0.
+           phisfi(ig)=0.
+           tsea_ice(ig)=273.15-1.8
+           tslab(ig,1)=tsurf(ig)
+           tslab(ig,2)=tsurf(ig)!*2./3.+(273.15-1.8)/3.
+          endif
+
+      ENDDO
+          CALL gr_fi_dyn(1,ngridmx,iip1,jjp1,phisfi,phis)
+
+
+
+        else
+          write(*,*) '       Unknown (misspelled?) option!!!'
+        end if ! of if (trim(modif) .eq. '...') elseif ...
+
+
+
+       enddo ! of do ! infinite loop on liste of changes
+
+ 999  continue
+
+ 
+c=======================================================================
+c   Initialisation for cloud fraction and oceanic ice (added by BC 2010)
+c=======================================================================
+      DO ig=1, ngridmx
+         totalfrac(ig)=0.5
+         DO l=1,llm
+            cloudfrac(ig,l)=0.5
+         ENDDO
+! Ehouarn, march 2012: also add some initialisation for hice
+         hice(ig)=0.0
+      ENDDO
+      
+c========================================================
+
+!      DO ig=1,ngridmx
+!         IF(tsurf(ig) .LT. 273.16-1.8) THEN
+!            hice(ig)=(273.16-1.8-tsurf(ig))/(273.16-1.8-240)*1.
+!            hice(ig)=min(hice(ig),1.0)
+!         ENDIF
+!      ENDDO
+
+
+
+
+c=======================================================================
+c   Correct pressure on the new grid (menu 0)
+c=======================================================================
+
+
+      if ((choix_1.eq.0).and.(.not.flagps0)) then
+        r = 1000.*8.31/mugaz
+
+        do j=1,jjp1
+          do i=1,iip1
+             ps(i,j) = ps(i,j) *
+     .            exp((phisold_newgrid(i,j)-phis(i,j)) /
+     .                                  (t(i,j,1) * r))
+          end do
+        end do
+
+c periodicite de ps en longitude
+        do j=1,jjp1
+          ps(1,j) = ps(iip1,j)
+        end do
+      end if
+
+         
+c=======================================================================
+c=======================================================================
+
+c=======================================================================
+c    Initialisation de la physique / ecriture de newstartfi :
+c=======================================================================
+
+
+      CALL inifilr 
+      CALL pression(ip1jmp1, ap, bp, ps, p3d)
+
+c-----------------------------------------------------------------------
+c   Initialisation  pks:
+c-----------------------------------------------------------------------
+
+      CALL exner_hyb(ip1jmp1, ps, p3d, beta, pks, pk, pkf)
+! Calcul de la temperature potentielle teta
+
+      if (flagtset) then
+          DO l=1,llm
+             DO j=1,jjp1
+                DO i=1,iim
+                   teta(i,j,l) = Tset(i,j,l) * cpp/pk(i,j,l)
+                ENDDO
+                teta (iip1,j,l)= teta (1,j,l)
+             ENDDO
+          ENDDO
+      else if (choix_1.eq.0) then
+         DO l=1,llm
+            DO j=1,jjp1
+               DO i=1,iim
+                  teta(i,j,l) = t(i,j,l) * cpp/pk(i,j,l)
+               ENDDO
+               teta (iip1,j,l)= teta (1,j,l)
+            ENDDO
+         ENDDO
+      endif
+
+C Calcul intermediaire
+c
+      if (choix_1.eq.0) then
+         CALL massdair( p3d, masse  )
+c
+         print *,' ALPHAX ',alphax
+
+         DO  l = 1, llm
+           DO  i    = 1, iim
+             xppn(i) = aire( i, 1   ) * masse(  i     ,  1   , l )
+             xpps(i) = aire( i,jjp1 ) * masse(  i     , jjp1 , l )
+           ENDDO
+             xpn      = SUM(xppn)/apoln
+             xps      = SUM(xpps)/apols
+           DO i   = 1, iip1
+             masse(   i   ,   1     ,  l )   = xpn
+             masse(   i   ,   jjp1  ,  l )   = xps
+           ENDDO
+         ENDDO
+      endif
+      phis(iip1,:) = phis(1,:)
+
+      itau=0
+      if (choix_1.eq.0) then
+         day_ini=int(date)
+      endif
+c
+      CALL geopot  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
+
+      CALL caldyn0( itau,ucov,vcov,teta,ps,masse,pk,phis ,
+     *                phi,w, pbaru,pbarv,day_ini+time )
+
+          
+      CALL dynredem0("restart.nc",day_ini,phis)
+      CALL dynredem1("restart.nc",0.0,vcov,ucov,teta,q,masse,ps) 
+C
+C Ecriture etat initial physique
+C
+
+      call physdem0("restartfi.nc",lonfi,latfi,nsoilmx,ngridmx,llm,
+     &              nqtot,dtphys,real(day_ini),0.0,
+     &              airefi,albfi,ithfi,zmea,zstd,zsig,zgam,zthe)
+      call physdem1("restartfi.nc",nsoilmx,ngridmx,llm,nqtot,
+     &                dtphys,real(day_ini),
+     &                tsurf,tsoil,emis,q2,qsurf,
+     &                cloudfrac,totalfrac,hice,
+     &                rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+
+c=======================================================================
+c        Formats 
+c=======================================================================
+
+   1  FORMAT(//10x,'la valeur de im =',i4,2x,'lue sur le fichier de dema
+     *rrage est differente de la valeur parametree iim =',i4//)
+   2  FORMAT(//10x,'la valeur de jm =',i4,2x,'lue sur le fichier de dema
+     *rrage est differente de la valeur parametree jjm =',i4//)
+   3  FORMAT(//10x,'la valeur de lllm =',i4,2x,'lue sur le fichier demar
+     *rage est differente de la valeur parametree llm =',i4//)
+
+      write(*,*) "newstart: All is well that ends well."
+
+      end
+
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/scal_wind.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/scal_wind.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/scal_wind.F	(revision 1644)
@@ -0,0 +1,55 @@
+      SUBROUTINE scal_wind(xus,xvs,xu,xv)
+c=======================================================================
+c
+c
+c   Subject:
+c   ------
+c On passe  les variable xus, xvs  aux points de vent u et v (xu et xv)
+c
+c=======================================================================
+      IMPLICIT NONE
+c-----------------------------------------------------------------------
+c   Declararations:
+c   ---------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      REAL xu(iip1,jjp1,llm),xv(iip1,jjm,llm)
+      REAL xus(iip1,jjp1,llm), xvs (iip1,jjp1,llm)
+
+c   Local:
+c   ------
+
+      INTEGER i,j,l
+
+c-----------------------------------------------------------------------
+
+c   transport zonal:
+c   ----------------
+      DO l=1,llm
+        Do j=1,jjp1
+	      DO i=1,iim
+            xu(i,j,l)=0.5*(xus(i,j,l)+xus(i+1,j,l))
+	      ENDDO
+          xu(iip1,j,l)=xu(1,j,l)
+	    ENDDO
+      ENDDO
+
+
+c   Transport meridien:
+c   -------------------
+      DO l=1,llm
+         DO j=1,jjm
+           do i=1 ,iip1
+	         xv(i,j,l)=.5*(xvs(i,j,l)+xvs(i,j+1,l))
+           end do
+	     ENDDO
+	  ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/start2archive.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/start2archive.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/start2archive.F	(revision 1644)
@@ -0,0 +1,544 @@
+c=======================================================================
+      PROGRAM start2archive
+c=======================================================================
+c
+c
+c   Date:    01/1997
+c   ----
+c
+c
+c   Objet:   Passage des  fichiers netcdf d'etat initial "start" et
+c   -----    "startfi" a un fichier netcdf unique "start_archive" 
+c
+c  "start_archive" est une banque d'etats initiaux:
+c  On peut stocker plusieurs etats initiaux dans un meme fichier "start_archive"
+c    (Veiller dans ce cas avoir un day_ini different pour chacun des start)
+c 
+c
+c
+c=======================================================================
+
+      use infotrac, only: infotrac_init, nqtot, tname
+      USE comsoil_h
+      
+!      USE comgeomfi_h, ONLY: lati, long, area
+!      use control_mod
+!      use comgeomphy, only: initcomgeomphy
+      use slab_ice_h, only: noceanmx
+! to use  'getin'
+      USE ioipsl_getincom
+      USE planete_mod, only: year_day
+      USE mod_const_mpi, ONLY: COMM_LMDZ
+      USE control_mod, only: planet_type
+      USE callkeys_mod, ONLY: ok_slab_ocean
+      use filtreg_mod, only: inifilr
+      USE comvert_mod, ONLY: ap,bp
+      USE comconst_mod, ONLY: daysec,dtphys,rad,g,r,cpp
+      USE temps_mod, ONLY: day_ini
+      USE iniphysiq_mod, ONLY: iniphysiq
+      implicit none
+
+      include "dimensions.h"
+      integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) 
+      include "paramet.h"
+      include "comdissip.h"
+      include "comgeom.h"
+!#include "control.h"
+
+!#include "dimphys.h"
+!#include "planete.h"
+!#include"advtrac.h"
+      include "netcdf.inc"
+c-----------------------------------------------------------------------
+c   Declarations
+c-----------------------------------------------------------------------
+
+c variables dynamiques du GCM
+c -----------------------------
+      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
+      REAL teta(ip1jmp1,llm)                    ! temperature potentielle 
+      REAL,ALLOCATABLE :: q(:,:,:)   ! champs advectes
+      REAL pks(ip1jmp1)                      ! exner (f pour filtre)
+      REAL pk(ip1jmp1,llm)
+      REAL pkf(ip1jmp1,llm)
+      REAL beta(iip1,jjp1,llm)
+      REAL phis(ip1jmp1)                     ! geopotentiel au sol
+      REAL masse(ip1jmp1,llm)                ! masse de l'atmosphere
+      REAL ps(ip1jmp1)                       ! pression au sol
+      REAL p3d(iip1, jjp1, llm+1)            ! pression aux interfaces
+      
+c Variable Physiques (grille physique)
+c ------------------------------------
+      REAL tsurf(ngridmx)        ! Surface temperature
+      REAL,ALLOCATABLE :: tsoil(:,:) ! Soil temperature
+      REAL co2ice(ngridmx)        ! CO2 ice layer
+      REAL q2(ngridmx,llm+1)
+      REAL,ALLOCATABLE :: qsurf(:,:)
+      REAL emis(ngridmx)
+      INTEGER start,length
+      PARAMETER (length = 100)
+      REAL tab_cntrl_fi(length) ! tableau des parametres de startfi
+      REAL tab_cntrl_dyn(length) ! tableau des parametres de start
+      INTEGER*4 day_ini_fi
+
+!     added by FF for cloud fraction setup
+      REAL hice(ngridmx)
+      REAL cloudfrac(ngridmx,llm),totalcloudfrac(ngridmx)
+
+!     added by BC for slab ocean
+      REAL rnat(ngridmx),pctsrf_sic(ngridmx),sea_ice(ngridmx)
+      REAL tslab(ngridmx,noceanmx),tsea_ice(ngridmx)
+
+
+c Variable naturelle / grille scalaire
+c ------------------------------------
+      REAL T(ip1jmp1,llm),us(ip1jmp1,llm),vs(ip1jmp1,llm)
+      REAL tsurfS(ip1jmp1)
+      REAL,ALLOCATABLE :: tsoilS(:,:)
+      REAL,ALLOCATABLE :: ithS(:,:) ! Soil Thermal Inertia
+      REAL co2iceS(ip1jmp1)
+      REAL q2S(ip1jmp1,llm+1)
+      REAL,ALLOCATABLE :: qsurfS(:,:)
+      REAL emisS(ip1jmp1)
+
+!     added by FF for cloud fraction setup
+      REAL hiceS(ip1jmp1)
+      REAL cloudfracS(ip1jmp1,llm),totalcloudfracS(ip1jmp1)
+
+!     added by BC for slab ocean
+      REAL rnatS(ip1jmp1),pctsrf_sicS(ip1jmp1),sea_iceS(ip1jmp1)
+      REAL tslabS(ip1jmp1,noceanmx),tsea_iceS(ip1jmp1)
+
+
+c Variables intermediaires : vent naturel, mais pas coord scalaire
+c----------------------------------------------------------------
+      REAL vn(ip1jm,llm),un(ip1jmp1,llm)
+
+c Autres  variables
+c -----------------
+      LOGICAL startdrs
+      INTEGER Lmodif
+
+      REAL ptotal, co2icetotal
+      REAL timedyn,timefi !fraction du jour dans start, startfi
+      REAL date
+
+      CHARACTER*2 str2
+      CHARACTER*80 fichier 
+      data  fichier /'startfi'/
+
+      INTEGER ij, l,i,j,isoil,iq
+      character*80      fichnom
+      integer :: ierr,ntime
+      integer :: nq,numvanle
+      character(len=30) :: txt ! to store some text
+
+c Netcdf
+c-------
+      integer varid,dimid,timelen 
+      INTEGER nid,nid1
+
+c-----------------------------------------------------------------------
+c   Initialisations 
+c-----------------------------------------------------------------------
+
+      CALL defrun_new(99, .TRUE. )
+
+      planet_type="titan"
+
+c=======================================================================
+c Lecture des donnees
+c=======================================================================
+! Load tracer number and names:
+      call infotrac_init
+
+! allocate arrays:
+      allocate(q(ip1jmp1,llm,nqtot))
+      allocate(qsurf(ngridmx,nqtot))
+      allocate(qsurfS(ip1jmp1,nqtot))
+! other array allocations:
+!      call ini_comsoil_h(ngridmx) ! done via iniphysiq
+
+      fichnom = 'start.nc'
+      CALL dynetat0(fichnom,vcov,ucov,teta,q,masse,
+     .       ps,phis,timedyn)
+
+! load 'controle' array from dynamics start file
+
+       ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1)
+       IF (ierr.NE.NF_NOERR) THEN
+         write(6,*)' Pb d''ouverture du fichier'//trim(fichnom)
+        CALL ABORT
+       ENDIF
+                                                
+      ierr = NF_INQ_VARID (nid1, "controle", varid)
+      IF (ierr .NE. NF_NOERR) THEN
+       PRINT*, "start2archive: Le champ <controle> est absent"
+       CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid1, varid, tab_cntrl_dyn)
+#else
+      ierr = NF_GET_VAR_REAL(nid1, varid, tab_cntrl_dyn)
+#endif
+       IF (ierr .NE. NF_NOERR) THEN
+          PRINT*, "start2archive: Lecture echoue pour <controle>"
+          CALL abort
+       ENDIF
+
+      ierr = NF_CLOSE(nid1)
+
+! Get value of the "subsurface_layers" dimension from physics start file
+      fichnom = 'startfi.nc'
+      ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1)
+       IF (ierr.NE.NF_NOERR) THEN
+         write(6,*)' Pb d''ouverture du fichier'//trim(fichnom)
+        CALL ABORT
+       ENDIF
+      ierr = NF_INQ_DIMID(nid1,"subsurface_layers",varid)
+      IF (ierr .NE. NF_NOERR) THEN
+       PRINT*, "start2archive: No subsurface_layers dimension!!"
+       CALL abort
+      ENDIF
+      ierr = NF_INQ_DIMLEN(nid1,varid,nsoilmx)
+      IF (ierr .NE. NF_NOERR) THEN
+       PRINT*, "start2archive: Failed reading subsurface_layers value!!"
+       CALL abort
+      ENDIF
+      ierr = NF_CLOSE(nid1)
+      
+      ! allocate arrays of nsoilmx size
+      allocate(tsoil(ngridmx,nsoilmx))
+      allocate(tsoilS(ip1jmp1,nsoilmx))
+      allocate(ithS(ip1jmp1,nsoilmx))
+
+c-----------------------------------------------------------------------
+c   Initialisations 
+c-----------------------------------------------------------------------
+
+      CALL defrun_new(99, .FALSE. )
+      call iniconst
+      call inigeom
+      call inifilr
+
+! Initialize the physics
+         CALL iniphysiq(iim,jjm,llm,
+     &                  (jjm-1)*iim+2,comm_lmdz,
+     &                  daysec,day_ini,dtphys,
+     &                  rlatu,rlatv,rlonu,rlonv,
+     &                  aire,cu,cv,rad,g,r,cpp,
+     &                  1)
+
+      fichnom = 'startfi.nc'
+      Lmodif=0
+
+
+      CALL phyetat0 (ngridmx,llm,fichnom,0,Lmodif,nsoilmx,nqtot,
+     .      day_ini_fi,timefi,
+     .      tsurf,tsoil,emis,q2,qsurf,
+!       change FF 05/2011
+     .       cloudfrac,totalcloudfrac,hice,
+!       change BC 05/2014
+     .       rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+
+
+
+
+! load 'controle' array from physics start file
+
+       ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1)
+       IF (ierr.NE.NF_NOERR) THEN
+         write(6,*)' Pb d''ouverture du fichier'//trim(fichnom)
+        CALL ABORT
+       ENDIF
+                                                
+      ierr = NF_INQ_VARID (nid1, "controle", varid)
+      IF (ierr .NE. NF_NOERR) THEN
+       PRINT*, "start2archive: Le champ <controle> est absent"
+       CALL abort
+      ENDIF
+#ifdef NC_DOUBLE
+       ierr = NF_GET_VAR_DOUBLE(nid1, varid, tab_cntrl_fi)
+#else
+      ierr = NF_GET_VAR_REAL(nid1, varid, tab_cntrl_fi)
+#endif
+       IF (ierr .NE. NF_NOERR) THEN
+          PRINT*, "start2archive: Lecture echoue pour <controle>"
+          CALL abort
+       ENDIF
+
+      ierr = NF_CLOSE(nid1)
+
+
+c-----------------------------------------------------------------------
+c Controle de la synchro
+c-----------------------------------------------------------------------
+!mars a voir      if ((day_ini_fi.ne.day_ini).or.(abs(timefi-timedyn).gt.1.e-10)) 
+      if ((day_ini_fi.ne.day_ini)) 
+     &  stop ' Probleme de Synchro entre start et startfi !!!'
+
+
+c *****************************************************************
+c    Option : Reinitialisation des dates dans la premieres annees :
+       do while (day_ini.ge.year_day)
+          day_ini=day_ini-year_day
+       enddo
+c *****************************************************************
+
+      CALL pression(ip1jmp1, ap, bp, ps, p3d)
+      call exner_hyb(ip1jmp1, ps, p3d, beta, pks, pk, pkf)
+
+c=======================================================================
+c Transformation EN VARIABLE NATURELLE / GRILLE SCALAIRE si necessaire
+c=======================================================================
+c  Les variables modeles dependent de la resolution. Il faut donc
+c  eliminer les facteurs responsables de cette dependance
+c  (pour utiliser newstart)
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c Vent   (depend de la resolution horizontale) 
+c-----------------------------------------------------------------------
+c
+c ucov --> un  et  vcov --> vn
+c un --> us  et   vn --> vs
+c
+c-----------------------------------------------------------------------
+
+      call covnat(llm,ucov, vcov, un, vn) 
+      call wind_scal(un,vn,us,vs) 
+
+c-----------------------------------------------------------------------
+c Temperature  (depend de la resolution verticale => de "sigma.def")
+c-----------------------------------------------------------------------
+c
+c h --> T
+c
+c-----------------------------------------------------------------------
+
+      DO l=1,llm
+         DO ij=1,ip1jmp1
+            T(ij,l)=teta(ij,l)*pk(ij,l)/cpp !mars deduit de l'equation dans newstart
+         ENDDO
+      ENDDO
+
+c-----------------------------------------------------------------------
+c Variable physique 
+c-----------------------------------------------------------------------
+c
+c tsurf --> tsurfS
+c co2ice --> co2iceS
+c tsoil --> tsoilS
+c emis --> emisS
+c q2 --> q2S
+c qsurf --> qsurfS
+c
+c-----------------------------------------------------------------------
+
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,tsurf,tsurfS)
+!      call gr_fi_dyn(1,ngridmx,iip1,jjp1,co2ice,co2iceS)
+      call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,tsoil,tsoilS)
+      ! Note: thermal inertia "inertiedat" is in comsoil.h
+      call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,inertiedat,ithS)
+      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(nqtot,ngridmx,iip1,jjp1,qsurf,qsurfS)
+      call gr_fi_dyn(llm,ngridmx,iip1,jjp1,cloudfrac,cloudfracS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,hice,hiceS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,totalcloudfrac,totalcloudfracS)
+
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,rnat,rnatS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,pctsrf_sic,pctsrf_sicS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,tsea_ice,tsea_iceS)
+      call gr_fi_dyn(1,ngridmx,iip1,jjp1,sea_ice,sea_iceS)
+      call gr_fi_dyn(noceanmx,ngridmx,iip1,jjp1,tslab,tslabS)
+
+c=======================================================================
+c Info pour controler
+c=======================================================================
+
+      ptotal =  0.
+      co2icetotal = 0.
+      DO j=1,jjp1
+         DO i=1,iim
+           ptotal=ptotal+aire(i+(iim+1)*(j-1))*ps(i+(iim+1)*(j-1))/g
+!           co2icetotal = co2icetotal + 
+!     &            co2iceS(i+(iim+1)*(j-1))*aire(i+(iim+1)*(j-1))
+         ENDDO
+      ENDDO
+      write(*,*)'Ancienne grille : masse de l''atm :',ptotal
+!      write(*,*)'Ancienne grille : masse de la glace CO2 :',co2icetotal
+
+c-----------------------------------------------------------------------
+c Passage de "ptotal" et "co2icetotal" par tab_cntrl_fi
+c-----------------------------------------------------------------------
+
+      tab_cntrl_fi(49) = ptotal
+      tab_cntrl_fi(50) = co2icetotal
+
+c=======================================================================
+c Ecriture dans le fichier  "start_archive"
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c Ouverture de "start_archive" 
+c-----------------------------------------------------------------------
+
+      ierr = NF_OPEN ('start_archive.nc', NF_WRITE,nid)
+ 
+c-----------------------------------------------------------------------
+c  si "start_archive" n'existe pas:
+c    1_ ouverture
+c    2_ creation de l'entete dynamique ("ini_archive")
+c-----------------------------------------------------------------------
+c ini_archive:
+c On met dans l'entete le tab_cntrl dynamique (1 a 16) 
+c  On y ajoute les valeurs du tab_cntrl_fi (a partir de 51)
+c  En plus les deux valeurs ptotal et co2icetotal (99 et 100)
+c-----------------------------------------------------------------------
+
+      if (ierr.ne.NF_NOERR) then
+         write(*,*)'OK, Could not open file "start_archive.nc"'
+         write(*,*)'So let s create a new "start_archive"'
+         ierr = NF_CREATE('start_archive.nc', NF_CLOBBER, nid)
+         call ini_archive(nid,day_ini,phis,ithS,tab_cntrl_fi,
+     &                                          tab_cntrl_dyn)
+      endif
+
+c-----------------------------------------------------------------------
+c Ecriture de la coordonnee temps (date en jours)
+c-----------------------------------------------------------------------
+
+      date = day_ini
+      ierr= NF_INQ_VARID(nid,"Time",varid)
+      ierr= NF_INQ_DIMID(nid,"Time",dimid)
+      ierr= NF_INQ_DIMLEN(nid,dimid,timelen)
+      ntime=timelen+1
+
+      write(*,*) "******************"
+      write(*,*) "ntime",ntime
+      write(*,*) "******************"
+#ifdef NC_DOUBLE
+      ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
+#else
+      ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
+#endif
+      if (ierr.ne.NF_NOERR) then
+         write(*,*) "time matter ",NF_STRERROR(ierr)
+         stop
+      endif
+
+c-----------------------------------------------------------------------
+c Ecriture des champs  (co2ice,emis,ps,Tsurf,T,u,v,q2,q,qsurf)
+c-----------------------------------------------------------------------
+c ATTENTION: q2 a une couche de plus!!!!
+c    Pour creer un fichier netcdf lisible par grads,
+c    On passe donc une des couches de q2 a part
+c    comme une variable 2D (la couche au sol: "q2surf")
+c    Les lmm autres couches sont nommees "q2atm" (3D) 
+c-----------------------------------------------------------------------
+
+!      call write_archive(nid,ntime,'co2ice','couche de glace co2',
+!     &  'kg/m2',2,co2iceS)
+      call write_archive(nid,ntime,'emis','grd emis',' ',2,emisS)
+      call write_archive(nid,ntime,'ps','Psurf','Pa',2,ps)
+      call write_archive(nid,ntime,'tsurf','surf T','K',2,tsurfS)
+      call write_archive(nid,ntime,'temp','temperature','K',3,t)
+      call write_archive(nid,ntime,'u','Vent zonal','m.s-1',3,us)
+      call write_archive(nid,ntime,'v','Vent merid','m.s-1',3,vs)
+      call write_archive(nid,ntime,'q2surf','wind variance','m2.s-2',2,
+     .              q2S)
+      call write_archive(nid,ntime,'q2atm','wind variance','m2.s-2',3,
+     .              q2S(1,2))
+
+c-----------------------------------------------------------------------
+c Ecriture du champs  q  ( q[1,nqtot] )
+c-----------------------------------------------------------------------
+      do iq=1,nqtot
+        call write_archive(nid,ntime,tname(iq),'tracer','kg/kg',
+     &         3,q(1,1,iq))
+      end do
+c-----------------------------------------------------------------------
+c Ecriture du champs  qsurf  ( qsurf[1,nqtot] )
+c-----------------------------------------------------------------------
+      do iq=1,nqtot
+        txt=trim(tname(iq))//"_surf"
+        call write_archive(nid,ntime,txt,'Tracer on surface',
+     &  'kg.m-2',2,qsurfS(1,iq))
+      enddo
+
+
+c-----------------------------------------------------------------------
+c Ecriture du champs  tsoil  ( Tg[1,10] )
+c-----------------------------------------------------------------------
+c "tsoil" Temperature au sol definie dans 10 couches dans le sol
+c   Les 10 couches sont lues comme 10 champs 
+c  nommees Tg[1,10]
+
+c      do isoil=1,nsoilmx
+c       write(str2,'(i2.2)') isoil
+c       call write_archive(nid,ntime,'Tg'//str2,'Ground Temperature ',
+c     .   'K',2,tsoilS(1,isoil))
+c      enddo
+
+! Write soil temperatures tsoil
+      call write_archive(nid,ntime,'tsoil','Soil temperature',
+     &     'K',-3,tsoilS)
+
+! Write soil thermal inertia
+      call write_archive(nid,ntime,'inertiedat',
+     &     'Soil thermal inertia',
+     &     'J.s-1/2.m-2.K-1',-3,ithS)
+
+! Write (0D) volumetric heat capacity (stored in comsoil.h)
+!      call write_archive(nid,ntime,'volcapa',
+!     &     'Soil volumetric heat capacity',
+!     &     'J.m-3.K-1',0,volcapa)
+! Note: no need to write volcapa, it is stored in "controle" table
+
+c-----------------------------------------------------------------------
+c Ecriture du champs  cloudfrac,hice,totalcloudfrac
+c-----------------------------------------------------------------------
+      call write_archive(nid,ntime,'hice',
+     &         'Height of oceanic ice','m',2,hiceS)
+      call write_archive(nid,ntime,'totalcloudfrac',
+     &        'Total cloud Fraction','',2,totalcloudfracS)
+      call write_archive(nid,ntime,'cloudfrac'
+     &        ,'Cloud fraction','',3,cloudfracS)
+
+c-----------------------------------------------------------------------
+c Slab ocean
+c-----------------------------------------------------------------------
+      OPEN(99,file='callphys.def',status='old',form='formatted'
+     &     ,iostat=ierr)
+      CLOSE(99)
+
+      IF(ierr.EQ.0) THEN
+
+
+         write(*,*) "Use slab-ocean ?"
+         ok_slab_ocean=.false.         ! default value
+         call getin("ok_slab_ocean",ok_slab_ocean)
+         write(*,*) "ok_slab_ocean = ",ok_slab_ocean
+
+      if(ok_slab_ocean) then
+      call write_archive(nid,ntime,'rnat'
+     &        ,'rnat','',2,rnatS)
+      call write_archive(nid,ntime,'pctsrf_sic'
+     &        ,'pctsrf_sic','',2,pctsrf_sicS)
+      call write_archive(nid,ntime,'sea_ice'
+     &        ,'sea_ice','',2,sea_iceS)
+      call write_archive(nid,ntime,'tslab'
+     &        ,'tslab','',-2,tslabS)
+      call write_archive(nid,ntime,'tsea_ice'
+     &        ,'tsea_ice','',2,tsea_iceS)
+      endif !ok_slab_ocean
+      ENDIF
+c-----------------------------------------------------------------------
+c Fin 
+c-----------------------------------------------------------------------
+      ierr=NF_CLOSE(nid)
+
+      write(*,*) "start2archive: All is well that ends well."
+
+      end 
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/wind_scal.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/wind_scal.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/wind_scal.F	(revision 1644)
@@ -0,0 +1,55 @@
+      SUBROUTINE wind_scal(pbaru,pbarv,us,vs)
+c=======================================================================
+c
+c
+c   Subject:
+c   ------
+c   On ramene les flux de masse /vents  aux points scalaires.
+c
+c=======================================================================
+      IMPLICIT NONE
+c-----------------------------------------------------------------------
+c   Declararations:
+c   ---------------
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c   Arguments:
+c   ----------
+
+      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm)
+      REAL us(ip1jmp1,llm), vs (ip1jmp1,llm)
+
+c   Local:
+c   ------
+
+      INTEGER ij,l
+
+c-----------------------------------------------------------------------
+
+c   transport zonal:
+c   ----------------
+      DO l=1,llm
+	 DO ij=2,ip1jmp1
+            us(ij,l)=.5*(pbaru(ij,l)+pbaru(ij-1,l))
+	 ENDDO
+      ENDDO
+      CALL SCOPY(jjp1*llm,us(iip1,1),iip1,us(1,1),iip1)
+
+
+c   Transport meridien:
+c   -------------------
+      DO l=1,llm
+         DO ij=iip2,ip1jm
+	    vs(ij,l)=.5*(pbarv(ij,l)+pbarv(ij-iip1,l))
+	 ENDDO
+	 DO ij=1,iip1
+	    vs(ij,l)=0.
+	    vs(ip1jm+ij,l)=0.
+	 ENDDO
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/write_archive.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/write_archive.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/dynphy_lonlat/phytitan/write_archive.F	(revision 1644)
@@ -0,0 +1,293 @@
+c=======================================================================
+      subroutine write_archive(nid,ntime,nom,titre,unite,dim,px)
+c=======================================================================
+c
+c
+c   Date:    01/1997
+c   ----
+c
+c   Objet:   Ecriture de champs sur grille scalaire (iip1*jjp1)
+c   -----    dans un fichier DRS nomme "start_archive"
+c
+c    Il faut au prealable avoir cree un entete avec un "call ini_archive".
+c    Ces variables peuvent etre 3d (ex: temperature), 2d (ex: temperature
+c    de surface), ou 0d (pour un scalaire qui ne depend que du temps)
+c    (ex: la longitude solaire)
+c
+c
+c   Arguments: 
+c   ----------
+c
+c     Inputs:
+c     ------
+c
+c		  nid      Unite logique du fichier "start_archive"
+c         nom      nom du champ a ecrire dans le fichier "start_archive"
+c         titre    titre de la variable dans le fichier DRS "start_archive"
+c         unite    unite de la variable ....
+c         dim      dimension de la variable a ecrire
+c         px       tableau contenant la variable a ecrire
+c
+c
+c=======================================================================
+
+      use comsoil_h, only: nsoilmx
+      use slab_ice_h, only: noceanmx
+
+      implicit none
+
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+#include "netcdf.inc"
+
+c-----------------------------------------------------------------------
+c	Declarations   
+c-----------------------------------------------------------------------
+
+c Arguments:
+
+      INTEGER nid
+      integer ntime ! time index
+      integer dim 
+      REAL px(iip1,jjp1,llm) 
+
+      CHARACTER*(*) nom, titre, unite
+
+      integer ierr
+
+
+c local
+      integer, dimension(4) :: edges,corner,id
+      integer :: varid,i,j,l
+c-----------------------------------------------------------------------
+c      Ecriture du champs dans le fichier            (3 cas)      
+c-----------------------------------------------------------------------
+
+! For an atmospheric 3D Variable
+!--------------------------------
+        if (dim.eq.3) then
+
+!         Ecriture du champs
+
+! nom de la variable
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! choix du nom des coordonnees
+              ierr= NF_INQ_DIMID(nid,"longitude",id(1))
+              ierr= NF_INQ_DIMID(nid,"latitude",id(2))
+              ierr= NF_INQ_DIMID(nid,"altitude",id(3))
+              ierr= NF_INQ_DIMID(nid,"Time",id(4))
+
+! Creation de la variable si elle n'existait pas
+
+              write (*,*) "====================="
+              write (*,*) "creation de ",nom
+              call def_var(nid,nom,titre,unite,4,id,varid,ierr)
+
+           endif
+
+! mars s'arranger pour qu'il n'y ai plus besoin de ca
+
+c          do l=1,llm
+c             do j=1,jjp1
+c                do i=1,iip1
+c                   pxbis(i,j,l)=px(i,j,llm-l+1)
+c                enddo
+c             enddo
+c          enddo
+           corner(1)=1
+           corner(2)=1
+           corner(3)=1
+           corner(4)=ntime
+
+           edges(1)=iip1
+           edges(2)=jjp1
+           edges(3)=llm
+           edges(4)=1
+#ifdef NC_DOUBLE
+           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,px)
+#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in write_archive"
+              write(*,*) "***** with ",nom," ",nf_STRERROR(ierr)
+              call abort
+           endif
+
+
+! For a subterranean 3D Variable
+!-------------------------------
+
+        else if (dim.eq.-3) then
+	! get variables' ID, if it exists
+	ierr=NF_INQ_VARID(nid,nom,varid)
+	
+	 if (ierr.ne.NF_NOERR) then ! variable not defined yet
+	  ! build related coordinates
+	  ierr=NF_INQ_DIMID(nid,"longitude",id(1))
+	  ierr=NF_INQ_DIMID(nid,"latitude",id(2))
+	  ierr=NF_INQ_DIMID(nid,"subsurface_layers",id(3))
+	  if (ierr.ne.NF_NOERR) then
+	   write(*,*)"write_archive: dimension <subsurface_layers>",
+     &               " is missing !!!"
+	   call abort
+	  endif
+          ierr=NF_INQ_DIMID(nid,"Time",id(4))
+	  
+	  ! define the variable
+	  write(*,*)"====================="
+	  write(*,*)"defining ",nom
+	  call def_var(nid,nom,titre,unite,4,id,varid,ierr)
+	  
+	 endif
+
+        ! build cedges and corners
+        corner(1)=1
+        corner(2)=1
+        corner(3)=1
+        corner(4)=ntime
+
+        edges(1)=iip1
+        edges(2)=jjp1
+        edges(3)=nsoilmx
+        edges(4)=1
+#ifdef NC_DOUBLE
+           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,px)
+#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif
+
+! For a 3D ocean temperature Variable
+!-------------------------------
+
+        else if (dim.eq.-2) then
+        ! get variables' ID, if it exists
+        ierr=NF_INQ_VARID(nid,nom,varid)
+
+         if (ierr.ne.NF_NOERR) then ! variable not defined yet
+          ! build related coordinates
+          ierr=NF_INQ_DIMID(nid,"longitude",id(1))
+          ierr=NF_INQ_DIMID(nid,"latitude",id(2))
+          ierr=NF_INQ_DIMID(nid,"ocean_layers",id(3))
+          if (ierr.ne.NF_NOERR) then
+           write(*,*)"write_archive: dimension <ocean_layers>",
+     &               " is missing !!!"
+           call abort
+          endif
+          ierr=NF_INQ_DIMID(nid,"Time",id(4))
+
+          ! define the variable
+          write(*,*)"====================="
+          write(*,*)"defining ",nom
+          call def_var(nid,nom,titre,unite,4,id,varid,ierr)
+
+         endif
+
+        ! build cedges and corners
+        corner(1)=1
+        corner(2)=1
+        corner(3)=1
+        corner(4)=ntime
+
+        edges(1)=iip1
+        edges(2)=jjp1
+        edges(3)=noceanmx
+        edges(4)=1
+#ifdef NC_DOUBLE
+           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,px)
+#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif
+
+
+
+! For a surface 2D Variable
+!--------------------------
+
+        else if (dim.eq.2) then
+
+!         Ecriture du champs
+
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+!  choix du nom des coordonnees
+              ierr= NF_INQ_DIMID(nid,"longitude",id(1))
+              ierr= NF_INQ_DIMID(nid,"latitude",id(2))
+              ierr= NF_INQ_DIMID(nid,"Time",id(3))
+
+! Creation de la variable si elle n'existait pas
+
+              write (*,*) "====================="
+              write (*,*) "creation de ",nom
+
+              call def_var(nid,nom,titre,unite,3,id,varid,ierr)
+
+           endif
+
+           corner(1)=1
+           corner(2)=1
+           corner(3)=ntime
+           edges(1)=iip1
+           edges(2)=jjp1
+           edges(3)=1
+
+
+#ifdef NC_DOUBLE
+           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px)
+#else         
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif     
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in write_archive"
+              write(*,*) "***** with ",nom,nf_STRERROR(ierr)
+              call abort
+           endif
+
+
+!Cas Variable 0D (scalaire dependant du temps)
+!---------------------------------------------
+
+        else if (dim.eq.0) then
+
+!         Ecriture du champs
+
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+!  choix du nom des coordonnees
+              ierr= NF_INQ_DIMID(nid,"Time",id(1))
+
+! Creation de la variable si elle n'existait pas
+
+              write (*,*) "====================="
+              write (*,*) "creation de ",nom
+
+              call def_var(nid,nom,titre,unite,1,id,varid,ierr)
+
+           endif
+
+           corner(1)=ntime
+           edges(1)=1
+
+#ifdef NC_DOUBLE
+           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,px)
+#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,px)
+#endif
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in write_archive"
+              write(*,*) "***** with ",nom,nf_STRERROR(ierr)
+              call abort
+           endif
+
+        else
+	  write(*,*) "write_archive: dim=",dim," ?!?"
+	  call abort
+        endif ! of if (dim.eq.3) else if (dim.eq.-3) ....
+
+      return
+      end
+
Index: /trunk/LMDZ.TITAN/libf/filtrez/CVS/Entries
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/CVS/Entries	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/CVS/Entries	(revision 1644)
@@ -0,0 +1,10 @@
+/acc.F/1.1.1.1/Mon Nov 22 15:02:04 1999//Trel-1-0-patch
+/coefils.h/1.1.1.1/Mon Nov 22 15:02:05 1999//Trel-1-0-patch
+/eigen.F/1.1.1.1/Mon Nov 22 15:02:05 1999//Trel-1-0-patch
+/eigen_sort.F/1.1.1.1/Mon Nov 22 15:02:05 1999//Trel-1-0-patch
+/filtreg.F/1.2/Thu Mar 29 14:58:49 2001//Trel-1-0-patch
+/inifgn.F/1.1.1.1/Mon Nov 22 15:02:05 1999//Trel-1-0-patch
+/inifilr.F/1.1.1.1/Mon Nov 22 15:02:05 1999//Trel-1-0-patch
+/jacobi.F/1.2/Thu Mar 29 14:58:49 2001//Trel-1-0-patch
+/parafilt.h/1.2/Thu Mar 29 14:58:49 2001//Trel-1-0-patch
+D
Index: /trunk/LMDZ.TITAN/libf/filtrez/CVS/Repository
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/CVS/Repository	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/CVS/Repository	(revision 1644)
@@ -0,0 +1,1 @@
+LMDZ.3.3/libf/filtrez
Index: /trunk/LMDZ.TITAN/libf/filtrez/CVS/Root
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/CVS/Root	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/CVS/Root	(revision 1644)
@@ -0,0 +1,1 @@
+:pserver:lmdzbrowse@piaf.lmd.jussieu.fr:/users/lmdz/cvsroot
Index: /trunk/LMDZ.TITAN/libf/filtrez/CVS/Tag
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/CVS/Tag	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/CVS/Tag	(revision 1644)
@@ -0,0 +1,1 @@
+Trel-1-0-patch
Index: /trunk/LMDZ.TITAN/libf/filtrez/acc.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/acc.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/acc.F	(revision 1644)
@@ -0,0 +1,11 @@
+        subroutine acc(vec,d,im)
+        dimension vec(im,im),d(im)
+        do 10 j=1,im
+        do 9 i=1,im
+ 9	d(i)=vec(i,j)*vec(i,j)
+        sum=ssum(im,d,1)
+        sum=sqrt(sum)
+        do 10 i=1,im
+ 10	vec(i,j)=vec(i,j)/sum
+        return
+        end
Index: /trunk/LMDZ.TITAN/libf/filtrez/coefils.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/coefils.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/coefils.h	(revision 1644)
@@ -0,0 +1,8 @@
+      COMMON/coefils/jfiltnu,jfiltsu,jfiltnv,jfiltsv,sddu(iim),sddv(iim)&
+     & ,unsddu(iim),unsddv(iim),coefilu(iim,jjm),coefilv(iim,jjm),      &
+     & modfrstu(jjm),modfrstv(jjm),eignfnu(iim,iim),eignfnv(iim,iim)    &
+     & ,coefilu2(iim,jjm),coefilv2(iim,jjm)
+!c
+      INTEGER jfiltnu,jfiltsu,jfiltnv,jfiltsv,modfrstu,modfrstv
+      REAL    sddu,sddv,unsddu,unsddv,coefilu,coefilv,eignfnu,eignfnv
+      REAL    coefilu2,coefilv2
Index: /trunk/LMDZ.TITAN/libf/filtrez/eigen.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/eigen.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/eigen.F	(revision 1644)
@@ -0,0 +1,28 @@
+      SUBROUTINE eigen( e,d)
+#include "dimensions.h"
+      dimension e( iim,iim ), d( iim )
+      dimension asm( iim )
+      im=iim
+c
+      DO 48 i = 1,im
+	 asm( i ) = d( im-i+1 )
+ 48   CONTINUE
+      DO 49 i = 1,iim
+	 d( i ) = asm( i )
+ 49   CONTINUE
+c
+c     PRINT 70,d
+ 70   FORMAT(5x,'Valeurs propres',/,8(1x,8f10.4,/),/)
+		print *
+c
+      DO 51 i = 1,im
+	 DO 52 j = 1,im
+            asm( j ) = e( i , im-j+1 )
+ 52      CONTINUE
+	 DO 50 j = 1,im
+	    e( i,j ) = asm( j )
+ 50      CONTINUE
+ 51   CONTINUE
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/filtrez/eigen_sort.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/eigen_sort.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/eigen_sort.F	(revision 1644)
@@ -0,0 +1,29 @@
+          SUBROUTINE eigen_sort(d,v,n,np)
+          INTEGER n,np
+          REAL d(np),v(np,np)
+          INTEGER i,j,k
+          REAL p
+
+       DO i=1,n-1
+          k=i
+          p=d(i)
+        DO j=i+1,n
+           IF(d(j).ge.p) THEN
+            k=j
+            p=d(j)
+           ENDIF
+        ENDDO
+          
+        IF(k.ne.i) THEN
+          d(k)=d(i)
+          d(i)=p
+         DO j=1,n
+          p=v(j,i)
+          v(j,i)=v(j,k)
+          v(j,k)=p
+         ENDDO
+        ENDIF
+       ENDDO
+
+        RETURN
+        END
Index: /trunk/LMDZ.TITAN/libf/filtrez/filtreg.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/filtreg.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/filtreg.F	(revision 1644)
@@ -0,0 +1,297 @@
+      SUBROUTINE filtreg ( champ, nlat, nbniv, ifiltre,iaire,
+     .   griscal ,iter)
+
+      IMPLICIT NONE
+c=======================================================================
+c
+c   Auteur: P. Le Van        07/10/97
+c   ------
+c
+c   Objet: filtre matriciel longitudinal ,avec les matrices precalculees
+c                     pour l'operateur  Filtre    .
+c   ------
+c
+c   Arguments:
+c   ----------
+c
+c      nblat                 nombre de latitudes a filtrer
+c      nbniv                 nombre de niveaux verticaux a filtrer
+c      champ(iip1,nblat,nbniv)  en entree : champ a filtrer
+c                            en sortie : champ filtre
+c      ifiltre               +1  Transformee directe
+c                            -1  Transformee inverse
+c                            +2  Filtre directe
+c                            -2  Filtre inverse
+c
+c      iaire                 1   si champ intensif
+c                            2   si champ extensif (pondere par les aires)
+c
+c      iter                  1   filtre simple
+c
+c=======================================================================
+c
+c
+c                      Variable Intensive
+c                ifiltre = 1     filtre directe
+c                ifiltre =-1     filtre inverse
+c
+c                      Variable Extensive
+c                ifiltre = 2     filtre directe
+c                ifiltre =-2     filtre inverse
+c
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "parafilt.h"
+#include "coefils.h"
+c
+      INTEGER nlat,nbniv,ifiltre,iter
+      INTEGER i,j,l,k
+      INTEGER iim2,immjm
+      INTEGER jdfil1,jdfil2,jffil1,jffil2,jdfil,jffil
+
+      REAL  champ( iip1,nlat,nbniv)
+      REAL matriceun,matriceus,matricevn,matricevs,matrinvn,matrinvs
+      COMMON/matrfil/matriceun(iim,iim,nfilun),matriceus(iim,iim,nfilus)
+     ,             , matricevn(iim,iim,nfilvn),matricevs(iim,iim,nfilvs)
+     ,             ,  matrinvn(iim,iim,nfilun),matrinvs (iim,iim,nfilus)
+      REAL  eignq(iim), sdd1(iim),sdd2(iim)
+      LOGICAL    griscal
+      INTEGER    hemisph, iaire
+c
+
+      IF(ifiltre.EQ.1.or.ifiltre.EQ.-1) 
+     *    STOP'Pas de transformee simple dans cette version'
+
+      IF( iter.EQ. 2 )  THEN
+       PRINT *,' Pas d iteration du filtre dans cette version !'
+     * , ' Utiliser old_filtreg et repasser !'
+           STOP
+      ENDIF
+
+      IF( ifiltre.EQ. -2 .AND..NOT.griscal )     THEN
+       PRINT *,' Cette routine ne calcule le filtre inverse que ',
+     * ' sur la grille des scalaires !'
+           STOP
+      ENDIF
+
+      IF( ifiltre.NE.2 .AND.ifiltre.NE. - 2 )  THEN
+       PRINT *,' Probleme dans filtreg car ifiltre NE 2 et NE -2'
+     *,' corriger et repasser !'
+           STOP
+      ENDIF
+c
+
+      iim2   = iim * iim
+      immjm  = iim * jjm
+c
+c
+      IF( griscal )   THEN
+         IF( nlat. NE. jjp1 )  THEN
+             PRINT  1111
+             STOP
+         ELSE
+c
+             IF( iaire.EQ.1 )  THEN
+                CALL SCOPY(  iim,    sddv, 1,  sdd1, 1 ) 
+                CALL SCOPY(  iim,  unsddv, 1,  sdd2, 1 )
+             ELSE
+                CALL SCOPY(  iim,  unsddv, 1,  sdd1, 1 )
+                CALL SCOPY(  iim,    sddv, 1,  sdd2, 1 )
+             END IF
+c
+             jdfil1 = 2
+             jffil1 = jfiltnu
+             jdfil2 = jfiltsu
+             jffil2 = jjm
+          END IF
+      ELSE
+          IF( nlat.NE.jjm )  THEN
+             PRINT  2222
+             STOP
+          ELSE
+c
+             IF( iaire.EQ.1 )  THEN
+                CALL SCOPY(  iim,    sddu, 1,  sdd1, 1 ) 
+                CALL SCOPY(  iim,  unsddu, 1,  sdd2, 1 )
+             ELSE
+                CALL SCOPY(  iim,  unsddu, 1,  sdd1, 1 )
+                CALL SCOPY(  iim,    sddu, 1,  sdd2, 1 )
+             END IF
+c
+             jdfil1 = 1
+             jffil1 = jfiltnv
+             jdfil2 = jfiltsv
+             jffil2 = jjm
+          END IF
+      END IF
+c
+c
+      DO 100  hemisph = 1, 2
+c
+      IF ( hemisph.EQ.1 )  THEN
+          jdfil = jdfil1
+          jffil = jffil1
+      ELSE
+          jdfil = jdfil2
+          jffil = jffil2
+      END IF
+
+ 
+      DO 50  l = 1, nbniv
+      DO 30  j = jdfil,jffil
+ 
+ 
+      DO  5  i = 1, iim
+      champ(i,j,l) = champ(i,j,l) * sdd1(i)
+   5  CONTINUE
+c
+
+      IF( hemisph. EQ. 1 )      THEN
+
+        IF( ifiltre. EQ. -2 )   THEN
+#ifdef CRAY
+         CALL MXVA( matrinvn(1,1,j), 1, iim, champ(1,j,l), 1, eignq  , 
+     *                             1, iim, iim                         )
+#else
+#ifdef BLAS
+      CALL SGEMV("N", iim,iim, 1.0, matrinvn(1,1,j),iim,
+     .           champ(1,j,l), 1, 0.0, eignq, 1)
+#else
+      DO k = 1, iim
+         eignq(k) = 0.0
+      ENDDO
+      DO k = 1, iim
+      DO i = 1, iim
+         eignq(k) = eignq(k) + matrinvn(k,i,j)*champ(i,j,l)
+      ENDDO
+      ENDDO
+#endif
+#endif
+        ELSE IF ( griscal )     THEN
+#ifdef CRAY
+         CALL MXVA( matriceun(1,1,j), 1, iim, champ(1,j,l), 1, eignq ,
+     *                             1, iim, iim                         )
+#else
+#ifdef BLAS
+      CALL SGEMV("N", iim,iim, 1.0, matriceun(1,1,j),iim,
+     .           champ(1,j,l), 1, 0.0, eignq, 1)
+#else
+      DO k = 1, iim
+         eignq(k) = 0.0
+      ENDDO
+      DO i = 1, iim
+      DO k = 1, iim
+         eignq(k) = eignq(k) + matriceun(k,i,j)*champ(i,j,l)
+      ENDDO
+      ENDDO
+#endif
+#endif
+        ELSE 
+#ifdef CRAY
+         CALL MXVA( matricevn(1,1,j), 1, iim, champ(1,j,l), 1, eignq , 
+     *                             1, iim, iim                         )
+#else
+#ifdef BLAS
+      CALL SGEMV("N", iim,iim, 1.0, matricevn(1,1,j),iim,
+     .           champ(1,j,l), 1, 0.0, eignq, 1)
+#else
+      DO k = 1, iim
+         eignq(k) = 0.0
+      ENDDO
+      DO i = 1, iim
+      DO k = 1, iim
+         eignq(k) = eignq(k) + matricevn(k,i,j)*champ(i,j,l)
+      ENDDO
+      ENDDO
+#endif
+#endif
+        ENDIF
+
+      ELSE
+
+        IF( ifiltre. EQ. -2 )   THEN
+#ifdef CRAY
+         CALL MXVA( matrinvs(1,1,j-jfiltsu+1),  1, iim, champ(1,j,l),1 ,  
+     *                          eignq,  1, iim, iim                    )
+#else
+#ifdef BLAS
+      CALL SGEMV("N", iim,iim, 1.0, matrinvs(1,1,j-jfiltsu+1),iim,
+     .           champ(1,j,l), 1, 0.0, eignq, 1)
+#else
+      DO k = 1, iim
+         eignq(k) = 0.0
+      ENDDO
+      DO i = 1, iim
+      DO k = 1, iim
+         eignq(k) = eignq(k) + matrinvs(k,i,j-jfiltsu+1)*champ(i,j,l)
+      ENDDO
+      ENDDO
+#endif
+#endif
+        ELSE IF ( griscal )     THEN
+#ifdef CRAY
+         CALL MXVA( matriceus(1,1,j-jfiltsu+1), 1, iim, champ(1,j,l),1 , 
+     *                          eignq,  1, iim, iim                    )
+#else
+#ifdef BLAS
+      CALL SGEMV("N", iim,iim, 1.0, matriceus(1,1,j-jfiltsu+1),iim,
+     .           champ(1,j,l), 1, 0.0, eignq, 1)
+#else
+      DO k = 1, iim
+         eignq(k) = 0.0
+      ENDDO
+      DO i = 1, iim
+      DO k = 1, iim
+         eignq(k) = eignq(k) + matriceus(k,i,j-jfiltsu+1)*champ(i,j,l)
+      ENDDO
+      ENDDO
+#endif
+#endif
+        ELSE 
+#ifdef CRAY
+         CALL MXVA( matricevs(1,1,j-jfiltsv+1), 1, iim, champ(1,j,l),1 , 
+     *                          eignq,  1, iim, iim                    )
+#else
+#ifdef BLAS
+      CALL SGEMV("N", iim,iim, 1.0, matricevs(1,1,j-jfiltsv+1),iim,
+     .           champ(1,j,l), 1, 0.0, eignq, 1)
+#else
+      DO k = 1, iim
+         eignq(k) = 0.0
+      ENDDO
+      DO i = 1, iim
+      DO k = 1, iim
+         eignq(k) = eignq(k) + matricevs(k,i,j-jfiltsv+1)*champ(i,j,l)
+      ENDDO
+      ENDDO
+#endif
+#endif
+        ENDIF
+
+      ENDIF
+c
+      IF( ifiltre.EQ. 2 )  THEN
+        DO 15 i = 1, iim
+        champ( i,j,l ) = ( champ(i,j,l) + eignq(i) ) * sdd2(i)
+  15    CONTINUE
+      ELSE
+        DO 16 i=1,iim
+        champ( i,j,l ) = ( champ(i,j,l) - eignq(i) ) * sdd2(i)
+16      CONTINUE
+      ENDIF
+c
+      champ( iip1,j,l ) = champ( 1,j,l )
+c
+  30  CONTINUE
+c
+  50  CONTINUE
+c    
+ 100  CONTINUE
+c
+1111  FORMAT(//20x,'ERREUR dans le dimensionnement du tableau  CHAMP a 
+     *filtrer, sur la grille des scalaires'/)
+2222  FORMAT(//20x,'ERREUR dans le dimensionnement du tableau CHAMP a fi
+     *ltrer, sur la grille de V ou de Z'/)
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/filtrez/filtreg_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/filtreg_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/filtreg_mod.F90	(revision 1644)
@@ -0,0 +1,591 @@
+MODULE filtreg_mod
+
+CONTAINS
+
+      SUBROUTINE inifilr
+!
+!    ... H. Upadhyaya, O.Sharma   ...
+!
+      USE logic_mod, ONLY: fxyhypb,ysinus
+      USE serre_mod, ONLY: alphax
+
+      IMPLICIT NONE
+!
+!     version 3 .....
+
+!     Correction  le 28/10/97    P. Le Van .
+!  -------------------------------------------------------------------
+#include "dimensions.h"
+#include "paramet.h"
+#include "parafilt.h"
+!  -------------------------------------------------------------------
+#include "comgeom.h"
+#include "coefils.h"
+
+      REAL  dlonu(iim),dlatu(jjm)
+      REAL  rlamda( iim ),  eignvl( iim )
+!
+
+      REAL    lamdamax,pi,cof
+      INTEGER i,j,modemax,imx,k,kf,ii
+      REAL dymin,dxmin,colat0
+      REAL eignft(iim,iim), coff
+      REAL matriceun,matriceus,matricevn,matricevs,matrinvn,matrinvs 
+      COMMON/matrfil/matriceun(iim,iim,nfilun),matriceus(iim,iim,nfilus) &
+                   , matricevn(iim,iim,nfilvn),matricevs(iim,iim,nfilvs) &
+                   ,  matrinvn(iim,iim,nfilun),matrinvs (iim,iim,nfilus)
+#ifdef CRAY
+      INTEGER   ISMIN
+      EXTERNAL  ISMIN
+      INTEGER iymin 
+      INTEGER ixmineq
+#endif
+      EXTERNAL  inifgn
+!
+! ------------------------------------------------------------
+!   This routine computes the eigenfunctions of the laplacien
+!   on the stretched grid, and the filtering coefficients
+!      
+!  We designate:
+!   eignfn   eigenfunctions of the discrete laplacien
+!   eigenvl  eigenvalues
+!   jfiltn   indexof the last scalar line filtered in NH
+!   jfilts   index of the first line filtered in SH
+!   modfrst  index of the mode from where modes are filtered
+!   modemax  maximum number of modes ( im )
+!   coefil   filtering coefficients ( lamda_max*cos(rlat)/lamda )
+!   sdd      SQRT( dx )
+!      
+!     the modes are filtered from modfrst to modemax
+      
+!-----------------------------------------------------------
+!
+
+       pi       = 2. * ASIN( 1. )
+
+       DO i = 1,iim
+        dlonu(i) = xprimu( i )
+       ENDDO
+!
+       CALL inifgn(eignvl)
+!
+        print *,' EIGNVL '
+        PRINT 250,eignvl
+250     FORMAT( 1x,5e13.6)
+!
+! compute eigenvalues and eigenfunctions
+!
+!
+!.................................................................
+!
+!  compute the filtering coefficients for scalar lines and 
+!  meridional wind v-lines
+!
+!  we filter all those latitude lines where coefil < 1
+!  NO FILTERING AT POLES
+!
+!  colat0 is to be used  when alpha (stretching coefficient)
+!  is set equal to zero for the regular grid case 
+!
+!    .......   Calcul  de  colat0   .........
+!     .....  colat0 = minimum de ( 0.5, min dy/ min dx )   ...
+!
+!
+      DO 45 j = 1,jjm
+         dlatu( j ) = rlatu( j ) - rlatu( j+1 )
+ 45   CONTINUE
+!
+#ifdef CRAY
+      iymin   = ISMIN( jjm, dlatu, 1 )
+      ixmineq = ISMIN( iim, dlonu, 1 )
+      dymin   = dlatu( iymin )
+      dxmin   = dlonu( ixmineq )
+#else
+      dxmin   =  dlonu(1)
+       DO  i  = 2, iim
+        dxmin = MIN( dxmin,dlonu(i) )
+       ENDDO
+      dymin  = dlatu(1)
+       DO j  = 2, jjm
+        dymin = MIN( dymin,dlatu(j) )
+       ENDDO
+#endif
+!
+!
+      colat0  =  MIN( 0.5, dymin/dxmin )
+!
+      IF( .NOT.fxyhypb.AND.ysinus )  THEN
+           colat0 = 0.6
+!         ...... a revoir  pour  ysinus !   .......
+           alphax = 0.
+      ENDIF
+!
+      PRINT 50, colat0,alphax
+  50  FORMAT(/15x,' Inifilr colat0 alphax ',2e16.7)
+!
+      IF(alphax.EQ.1. )  THEN
+        PRINT *,' Inifilr  alphax doit etre  <  a 1.  Corriger '
+         STOP
+      ENDIF
+!
+      lamdamax = iim / ( pi * colat0 * ( 1. - alphax ) )
+
+!c                        ... Correction  le 28/10/97  ( P.Le Van ) ..
+!
+      DO 71 i = 2,iim
+       rlamda( i ) = lamdamax/ SQRT( ABS( eignvl(i) ) )
+ 71   CONTINUE
+!
+
+      DO 72 j = 1,jjm
+	    DO 73 i = 1,iim
+	    coefilu( i,j )  = 0.0
+	    coefilv( i,j )  = 0.0
+	    coefilu2( i,j ) = 0.0
+	    coefilv2( i,j ) = 0.0
+ 73     CONTINUE
+ 72   CONTINUE
+
+!
+!    ... Determination de jfiltnu,jfiltnv,jfiltsu,jfiltsv ....
+!    .........................................................
+!
+       modemax = iim
+
+!ccc    imx = modemax - 4 * (modemax/iim)
+
+       imx  = iim
+!
+       PRINT *,' TRUNCATION AT ',imx
+!
+      DO 75 j = 2, jjm/2+1
+       cof = COS( rlatu(j) )/ colat0
+	    IF ( cof .LT. 1. ) THEN
+          IF( rlamda(imx) * COS(rlatu(j) ).LT.1. ) jfiltnu= j
+        ENDIF
+
+       cof = COS( rlatu(jjp1-j+1) )/ colat0
+	    IF ( cof .LT. 1. ) THEN
+          IF( rlamda(imx) * COS(rlatu(jjp1-j+1) ).LT.1. ) &
+            jfiltsu= jjp1-j+1
+        ENDIF
+ 75   CONTINUE
+!
+      DO 76 j = 1, jjm/2
+       cof = COS( rlatv(j) )/ colat0
+	    IF ( cof .LT. 1. ) THEN
+          IF( rlamda(imx) * COS(rlatv(j) ).LT.1. ) jfiltnv= j
+        ENDIF
+
+       cof = COS( rlatv(jjm-j+1) )/ colat0
+	    IF ( cof .LT. 1. ) THEN
+          IF( rlamda(imx) * COS(rlatv(jjm-j+1) ).LT.1. ) &
+             jfiltsv= jjm-j+1
+        ENDIF
+ 76   CONTINUE
+!                                 
+
+      IF( jfiltnu.LE.0 .OR. jfiltnu.GT. jjm/2 +1 )  THEN
+        PRINT *,' jfiltnu en dehors des valeurs acceptables ' ,jfiltnu
+        STOP
+      ENDIF
+
+      IF( jfiltsu.LE.0 .OR. jfiltsu.GT.  jjm  +1 )  THEN
+        PRINT *,' jfiltsu en dehors des valeurs acceptables ' ,jfiltsu
+        STOP
+      ENDIF
+
+      IF( jfiltnv.LE.0 .OR. jfiltnv.GT. jjm/2    )  THEN
+        PRINT *,' jfiltnv en dehors des valeurs acceptables ' ,jfiltnv
+        STOP
+      ENDIF
+
+      IF( jfiltsv.LE.0 .OR. jfiltsv.GT.     jjm  )  THEN
+        PRINT *,' jfiltsv en dehors des valeurs acceptables ' ,jfiltsv
+        STOP
+      ENDIF
+
+       PRINT *,' jfiltnv jfiltsv jfiltnu jfiltsu ' , &
+                 jfiltnv,jfiltsv,jfiltnu,jfiltsu
+
+!                                 
+!   ... Determination de coefilu,coefilv,n=modfrstu,modfrstv ....
+!................................................................
+!
+!
+      DO 77 j = 1,jjm
+	  modfrstu( j ) = iim
+	  modfrstv( j ) = iim
+ 77   CONTINUE
+!
+      DO 84 j = 2,jfiltnu
+       DO 81 k = 2,modemax
+	     cof = rlamda(k) * COS( rlatu(j) )
+         IF ( cof .LT. 1. ) GOTO 82
+ 81    CONTINUE
+      GOTO 84
+ 82   modfrstu( j ) = k
+!
+	  kf = modfrstu( j )
+	   DO 83 k = kf , modemax
+        cof = rlamda(k) * COS( rlatu(j) )
+	    coefilu(k,j) = cof - 1.
+	    coefilu2(k,j) = cof*cof - 1.
+ 83    CONTINUE
+ 84   CONTINUE
+!                                 
+!
+      DO 89 j = 1,jfiltnv
+!
+       DO 86 k = 2,modemax
+	    cof = rlamda(k) * COS( rlatv(j) )
+         IF ( cof .LT. 1. ) GOTO 87
+ 86    CONTINUE
+      GOTO 89
+ 87   modfrstv( j ) = k
+!
+	   kf = modfrstv( j )
+	   DO 88 k = kf , modemax
+        cof = rlamda(k) * COS( rlatv(j) )
+	    coefilv(k,j) = cof - 1.
+	    coefilv2(k,j) = cof*cof - 1.
+ 88    CONTINUE
+!
+ 89    CONTINUE
+!
+      DO 94 j = jfiltsu,jjm
+       DO 91 k = 2,modemax
+	    cof = rlamda(k) * COS( rlatu(j) )
+         IF ( cof .LT. 1. ) GOTO 92
+ 91    CONTINUE
+      GOTO 94
+ 92   modfrstu( j ) = k
+!
+        kf = modfrstu( j )
+	 DO 93 k = kf , modemax
+          cof = rlamda(k) * COS( rlatu(j) )
+	  coefilu(k,j) = cof - 1.
+	  coefilu2(k,j) = cof*cof - 1.
+ 93      CONTINUE
+ 94    CONTINUE
+!                                 
+      DO 99 j = jfiltsv,jjm
+       DO 96 k = 2,modemax
+	     cof = rlamda(k) * COS( rlatv(j) )
+         IF ( cof .LT. 1. ) GOTO 97
+ 96    CONTINUE
+      GOTO 99
+ 97   modfrstv( j ) = k
+!
+       kf = modfrstv( j )
+	   DO 98 k = kf , modemax
+        cof = rlamda(k) * COS( rlatv(j) )
+	    coefilv(k,j) = cof - 1.
+	    coefilv2(k,j) = cof*cof - 1.
+ 98    CONTINUE
+ 99   CONTINUE
+!
+
+       IF(jfiltnv.GE.jjm/2 .OR. jfiltnu.GE.jjm/2)THEN
+
+         IF(jfiltnv.EQ.jfiltsv)jfiltsv=1+jfiltnv
+         IF(jfiltnu.EQ.jfiltsu)jfiltsu=1+jfiltnu
+
+          PRINT *,'jfiltnv jfiltsv jfiltnu jfiltsu' , &
+              jfiltnv,jfiltsv,jfiltnu,jfiltsu
+       ENDIF
+
+       PRINT *,'   Modes premiers  v  '
+       PRINT 334,modfrstv
+       PRINT *,'   Modes premiers  u  '
+       PRINT 334,modfrstu
+
+     
+      IF( nfilun.LT. jfiltnu )  THEN
+       PRINT *,' le parametre nfilun utilise pour la matrice ', &
+         ' matriceun  est trop petit ! ' 
+       PRINT *,'Le changer dans parafilt.h et le mettre a  ',jfiltnu
+        PRINT *,' Pour information, nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+               STOP
+      ENDIF
+      IF( nfilun.GT. jfiltnu+ 2 )  THEN
+           PRINT *,' le parametre nfilun utilise pour la matrice ', &
+      ' matriceun est trop grand ! Gachis de memoire ! ' 
+       PRINT *,'Le changer dans parafilt.h et le mettre a  ',jfiltnu
+        PRINT *,' Pour information, nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+!              STOP
+      ENDIF
+      IF( nfilus.LT. jjm - jfiltsu +1 )  THEN
+            PRINT *,' le parametre nfilus utilise pour la matrice ', &
+         ' matriceus  est trop petit !  '
+       PRINT *,' Le changer dans parafilt.h et le mettre a  ', &
+       jjm - jfiltsu + 1
+        PRINT *,' Pour information , nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+               STOP
+      ENDIF
+      IF( nfilus.GT. jjm - jfiltsu + 3 )  THEN
+           PRINT *,' le parametre nfilus utilise pour la matrice ', &
+       ' matriceus  est trop grand ! ' 
+       PRINT *,' Le changer dans parafilt.h et le mettre a  ' , &
+       jjm - jfiltsu + 1
+        PRINT *,' Pour information , nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+!              STOP
+      ENDIF
+      IF( nfilvn.LT. jfiltnv )  THEN
+            PRINT *,' le parametre nfilvn utilise pour la matrice ', &
+         ' matricevn  est trop petit ! '  
+       PRINT *,'Le changer dans parafilt.h et le mettre a  ',jfiltnv
+        PRINT *,' Pour information , nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+               STOP
+      ENDIF
+      IF( nfilvn.GT. jfiltnv+ 2 )  THEN
+           PRINT *,' le parametre nfilvn utilise pour la matrice ', &
+      ' matricevn est trop grand !  Gachis de memoire ! ' 
+       PRINT *,'Le changer dans parafilt.h et le mettre a  ',jfiltnv
+        PRINT *,' Pour information , nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+!              STOP
+      ENDIF
+      IF( nfilvs.LT. jjm - jfiltsv +1 )  THEN
+            PRINT *,' le parametre nfilvs utilise pour la matrice ', &
+         ' matricevs  est trop petit !  Le changer dans parafilt.h '
+       PRINT *,' Le changer dans parafilt.h et le mettre a  ' &
+       , jjm - jfiltsv + 1
+        PRINT *,' Pour information , nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+               STOP
+      ENDIF
+      IF( nfilvs.GT. jjm - jfiltsv + 3 )  THEN
+           PRINT *,' le parametre nfilvs utilise pour la matrice ', &
+       ' matricevs  est trop grand ! Gachis de memoire ! '
+       PRINT *,' Le changer dans parafilt.h et le mettre a  ' &
+         ,  jjm - jfiltsv + 1
+        PRINT *,' Pour information , nfilun,nfilus,nfilvn,nfilvs ' &
+       ,'doivent etre egaux successivement a  ',jfiltnu,jjm-jfiltsu+1 &
+        ,jfiltnv,jjm-jfiltsv+1
+!              STOP
+      ENDIF
+
+!  
+!   ...................................................................
+!
+!   ... Calcul de la matrice filtre 'matriceu'  pour les champs situes
+!                       sur la grille scalaire                 ........
+!   ...................................................................
+!
+        DO j = 2, jfiltnu
+
+         DO i=1,iim
+          coff = coefilu(i,j)
+          IF( i.LT.modfrstu(j) ) coff = 0.
+           DO k=1,iim
+            eignft(i,k) = eignfnv(k,i) * coff
+           ENDDO
+         ENDDO
+#ifdef CRAY
+         CALL MXM( eignfnv,iim,eignft,iim,matriceun(1,1,j),iim )
+#else
+#ifdef BLAS
+         CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
+         eignfnv, iim, eignft, iim, 0.0, matriceun(1,1,j), iim)
+#else
+         DO k = 1, iim
+         DO i = 1, iim
+            matriceun(i,k,j) = 0.0
+            DO ii = 1, iim
+               matriceun(i,k,j) = matriceun(i,k,j) &
+                                + eignfnv(i,ii)*eignft(ii,k)
+            ENDDO
+         ENDDO
+         ENDDO
+#endif
+#endif
+
+        ENDDO
+
+        DO j = jfiltsu, jjm
+
+         DO i=1,iim
+          coff = coefilu(i,j)
+          IF( i.LT.modfrstu(j) ) coff = 0.
+            DO k=1,iim
+             eignft(i,k) = eignfnv(k,i) * coff
+            ENDDO
+         ENDDO
+#ifdef CRAY
+         CALL MXM(eignfnv,iim,eignft,iim,matriceus(1,1,j-jfiltsu+1),iim)
+#else
+#ifdef BLAS
+      CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
+                 eignfnv, iim, eignft, iim, 0.0, &
+                 matriceus(1,1,j-jfiltsu+1), iim)
+#else
+         DO k = 1, iim
+         DO i = 1, iim
+            matriceus(i,k,j-jfiltsu+1) = 0.0
+            DO ii = 1, iim
+               matriceus(i,k,j-jfiltsu+1) = matriceus(i,k,j-jfiltsu+1) &
+                                          + eignfnv(i,ii)*eignft(ii,k)
+            ENDDO
+         ENDDO
+         ENDDO
+#endif
+#endif
+
+        ENDDO
+
+!   ...................................................................
+!
+!   ... Calcul de la matrice filtre 'matricev'  pour les champs situes
+!                       sur la grille   de V ou de Z           ........
+!   ...................................................................
+!
+        DO j = 1, jfiltnv
+
+         DO i = 1, iim
+          coff = coefilv(i,j)
+          IF( i.LT.modfrstv(j) ) coff = 0.
+           DO k = 1, iim
+            eignft(i,k) = eignfnu(k,i) * coff
+           ENDDO
+         ENDDO
+#ifdef CRAY
+          CALL MXM( eignfnu,iim,eignft,iim,matricevn(1,1,j),iim )
+#else
+#ifdef BLAS
+      CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
+           eignfnu, iim, eignft, iim, 0.0, matricevn(1,1,j), iim)
+#else
+         DO k = 1, iim
+         DO i = 1, iim
+            matricevn(i,k,j) = 0.0
+            DO ii = 1, iim
+               matricevn(i,k,j) = matricevn(i,k,j) &
+                                + eignfnu(i,ii)*eignft(ii,k)
+            ENDDO
+         ENDDO
+         ENDDO
+#endif
+#endif
+
+        ENDDO
+
+        DO j = jfiltsv, jjm
+
+         DO i = 1, iim
+          coff = coefilv(i,j)
+          IF( i.LT.modfrstv(j) ) coff = 0.
+            DO k = 1, iim
+             eignft(i,k) = eignfnu(k,i) * coff
+            ENDDO
+         ENDDO
+#ifdef CRAY
+         CALL MXM(eignfnu,iim,eignft,iim,matricevs(1,1,j-jfiltsv+1),iim)
+#else
+#ifdef BLAS
+      CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
+                 eignfnu, iim, eignft, iim, 0.0, &
+                 matricevs(1,1,j-jfiltsv+1), iim)
+#else
+         DO k = 1, iim
+         DO i = 1, iim
+            matricevs(i,k,j-jfiltsv+1) = 0.0
+            DO ii = 1, iim
+               matricevs(i,k,j-jfiltsv+1) = matricevs(i,k,j-jfiltsv+1) &
+                                + eignfnu(i,ii)*eignft(ii,k)
+            ENDDO
+         ENDDO
+         ENDDO
+#endif
+#endif
+
+        ENDDO
+
+!   ...................................................................
+!
+!   ... Calcul de la matrice filtre 'matrinv'  pour les champs situes
+!              sur la grille scalaire , pour le filtre inverse ........
+!   ...................................................................
+!
+        DO j = 2, jfiltnu
+
+         DO i = 1,iim
+          coff = coefilu(i,j)/ ( 1. + coefilu(i,j) )
+          IF( i.LT.modfrstu(j) ) coff = 0.
+           DO k=1,iim
+            eignft(i,k) = eignfnv(k,i) * coff
+           ENDDO
+         ENDDO
+#ifdef CRAY
+          CALL MXM( eignfnv,iim,eignft,iim,matrinvn(1,1,j),iim )
+#else
+#ifdef BLAS
+      CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
+           eignfnv, iim, eignft, iim, 0.0, matrinvn(1,1,j), iim)
+#else
+         DO k = 1, iim
+         DO i = 1, iim
+            matrinvn(i,k,j) = 0.0
+            DO ii = 1, iim
+               matrinvn(i,k,j) = matrinvn(i,k,j) &
+                                + eignfnv(i,ii)*eignft(ii,k)
+            ENDDO
+         ENDDO
+         ENDDO
+#endif
+#endif
+
+        ENDDO
+
+        DO j = jfiltsu, jjm
+
+         DO i = 1,iim
+          coff = coefilu(i,j) / ( 1. + coefilu(i,j) )
+          IF( i.LT.modfrstu(j) ) coff = 0.
+            DO k=1,iim
+             eignft(i,k) = eignfnv(k,i) * coff
+            ENDDO
+         ENDDO
+#ifdef CRAY
+         CALL MXM(eignfnv,iim,eignft,iim,matrinvs(1,1,j-jfiltsu+1),iim)
+#else
+#ifdef BLAS
+      CALL SGEMM ('N', 'N', iim, iim, iim, 1.0, &
+       eignfnv, iim, eignft, iim, 0.0, matrinvs(1,1,j-jfiltsu+1), iim)
+#else
+         DO k = 1, iim
+         DO i = 1, iim
+            matrinvs(i,k,j-jfiltsu+1) = 0.0
+            DO ii = 1, iim
+               matrinvs(i,k,j-jfiltsu+1) = matrinvs(i,k,j-jfiltsu+1) &
+                                + eignfnv(i,ii)*eignft(ii,k)
+            ENDDO
+         ENDDO
+         ENDDO
+#endif
+#endif
+
+        ENDDO
+
+!   ...................................................................
+
+!
+334    FORMAT(1x,24i3)
+755    FORMAT(1x,6f10.3,i3)
+
+       RETURN
+       END SUBROUTINE inifilr
+
+END MODULE  filtreg_mod
Index: /trunk/LMDZ.TITAN/libf/filtrez/inifgn.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/inifgn.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/inifgn.F	(revision 1644)
@@ -0,0 +1,102 @@
+      SUBROUTINE inifgn(dv)
+c  
+c    ...  H.Upadyaya , O.Sharma  ... 
+c
+      IMPLICIT NONE
+c
+#include "dimensions.h"
+#include "paramet.h"
+#include "comgeom.h"
+
+c
+      REAL vec(iim,iim),vec1(iim,iim)
+      REAL dlonu(iim),dlonv(iim)
+      REAL du(iim),dv(iim),d(iim)
+      REAL pi
+      INTEGER i,j,k,imm1,nrot
+C
+#include "coefils.h"
+c
+      EXTERNAL SSUM, acc,eigen,jacobi
+      REAL SSUM
+c
+
+      imm1  = iim -1
+      pi = 2.* ASIN(1.)
+C
+      DO 5 i=1,iim
+       dlonu(i)=  xprimu( i )
+       dlonv(i)=  xprimv( i )
+   5  CONTINUE
+
+      DO 12 i=1,iim
+      sddv(i)   = SQRT(dlonv(i))
+      sddu(i)   = SQRT(dlonu(i))
+      unsddu(i) = 1./sddu(i)
+      unsddv(i) = 1./sddv(i)
+  12  CONTINUE
+C
+      DO 17 j=1,iim
+      DO 17 i=1,iim
+      vec(i,j)     = 0.
+      vec1(i,j)    = 0.
+      eignfnv(i,j) = 0.
+      eignfnu(i,j) = 0.
+  17  CONTINUE
+c
+c
+      eignfnv(1,1)    = -1.
+      eignfnv(iim,1)  =  1.
+      DO 20 i=1,imm1
+      eignfnv(i+1,i+1)= -1.
+      eignfnv(i,i+1)  =  1.
+  20  CONTINUE
+      DO 25 j=1,iim
+      DO 25 i=1,iim
+      eignfnv(i,j) = eignfnv(i,j)/(sddu(i)*sddv(j))
+  25  CONTINUE
+      DO 30 j=1,iim
+      DO 30 i=1,iim
+      eignfnu(i,j) = -eignfnv(j,i)
+  30  CONTINUE
+c
+#ifdef CRAY
+      CALL MXM(eignfnu,iim,eignfnv,iim,vec ,iim)
+      CALL MXM(eignfnv,iim,eignfnu,iim,vec1,iim)
+#else
+      DO j = 1, iim
+      DO i = 1, iim
+        vec (i,j) = 0.0
+        vec1(i,j) = 0.0
+       DO k = 1, iim
+        vec (i,j) = vec(i,j)  + eignfnu(i,k) * eignfnv(k,j)
+        vec1(i,j) = vec1(i,j) + eignfnv(i,k) * eignfnu(k,j)
+       ENDDO
+      ENDDO
+      ENDDO
+#endif
+
+c
+      CALL jacobi(vec,iim,iim,dv,eignfnv,nrot)
+      CALL acc(eignfnv,d,iim)
+      CALL eigen_sort(dv,eignfnv,iim,iim)
+c
+      CALL jacobi(vec1,iim,iim,du,eignfnu,nrot)
+      CALL acc(eignfnu,d,iim)
+      CALL eigen_sort(du,eignfnu,iim,iim)
+
+cc   ancienne version avec appels IMSL
+c
+c     CALL MXM(eignfnu,iim,eignfnv,iim,vec,iim)
+c     CALL MXM(eignfnv,iim,eignfnu,iim,vec1,iim)
+c     CALL EVCSF(iim,vec,iim,dv,eignfnv,iim)
+c     CALL acc(eignfnv,d,iim)
+c     CALL eigen(eignfnv,dv)
+c
+c     CALL EVCSF(iim,vec1,iim,du,eignfnu,iim)
+c     CALL acc(eignfnu,d,iim)
+c     CALL eigen(eignfnu,du)
+
+      RETURN
+      END
+
Index: /trunk/LMDZ.TITAN/libf/filtrez/jacobi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/jacobi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/jacobi.F	(revision 1644)
@@ -0,0 +1,94 @@
+      SUBROUTINE JACOBI(A,N,NP,D,V,NROT)
+      PARAMETER (NMAX=400)
+      DIMENSION A(NP,NP),D(NP),V(NP,NP),B(NMAX),Z(NMAX)
+      IF (n.gt.nmax) THEN
+         print*, 'n, nmax=', n, nmax
+         print*, 'Surdimensionnement insuffisant dans jacobi'
+         CALL abort
+      ENDIF
+      DO 12 IP=1,N
+        DO 11 IQ=1,N
+          V(IP,IQ)=0.
+11      CONTINUE
+        V(IP,IP)=1.
+12    CONTINUE
+      DO 13 IP=1,N
+        B(IP)=A(IP,IP)
+        D(IP)=B(IP)
+        Z(IP)=0.
+13    CONTINUE
+      NROT=0
+      DO 24 I=1,50
+        SM=0.
+        DO 15 IP=1,N-1
+          DO 14 IQ=IP+1,N
+            SM=SM+ABS(A(IP,IQ))
+14        CONTINUE
+15      CONTINUE
+        IF(SM.EQ.0.)RETURN
+        IF(I.LT.4)THEN
+          TRESH=0.2*SM/N**2
+        ELSE
+          TRESH=0.
+        ENDIF
+        DO 22 IP=1,N-1
+          DO 21 IQ=IP+1,N
+            G=100.*ABS(A(IP,IQ))
+            IF((I.GT.4).AND.(ABS(D(IP))+G.EQ.ABS(D(IP)))
+     *         .AND.(ABS(D(IQ))+G.EQ.ABS(D(IQ))))THEN
+              A(IP,IQ)=0.
+            ELSE IF(ABS(A(IP,IQ)).GT.TRESH)THEN
+              H=D(IQ)-D(IP)
+              IF(ABS(H)+G.EQ.ABS(H))THEN
+                T=A(IP,IQ)/H
+              ELSE
+                THETA=0.5*H/A(IP,IQ)
+                T=1./(ABS(THETA)+SQRT(1.+THETA**2))
+                IF(THETA.LT.0.)T=-T
+              ENDIF
+              C=1./SQRT(1+T**2)
+              S=T*C
+              TAU=S/(1.+C)
+              H=T*A(IP,IQ)
+              Z(IP)=Z(IP)-H
+              Z(IQ)=Z(IQ)+H
+              D(IP)=D(IP)-H
+              D(IQ)=D(IQ)+H
+              A(IP,IQ)=0.
+              DO 16 J=1,IP-1
+                G=A(J,IP)
+                H=A(J,IQ)
+                A(J,IP)=G-S*(H+G*TAU)
+                A(J,IQ)=H+S*(G-H*TAU)
+16            CONTINUE
+              DO 17 J=IP+1,IQ-1
+                G=A(IP,J)
+                H=A(J,IQ)
+                A(IP,J)=G-S*(H+G*TAU)
+                A(J,IQ)=H+S*(G-H*TAU)
+17            CONTINUE
+              DO 18 J=IQ+1,N
+                G=A(IP,J)
+                H=A(IQ,J)
+                A(IP,J)=G-S*(H+G*TAU)
+                A(IQ,J)=H+S*(G-H*TAU)
+18            CONTINUE
+              DO 19 J=1,N
+                G=V(J,IP)
+                H=V(J,IQ)
+                V(J,IP)=G-S*(H+G*TAU)
+                V(J,IQ)=H+S*(G-H*TAU)
+19            CONTINUE
+              NROT=NROT+1
+            ENDIF
+21        CONTINUE
+22      CONTINUE
+        DO 23 IP=1,N
+          B(IP)=B(IP)+Z(IP)
+          D(IP)=B(IP)
+          Z(IP)=0.
+23      CONTINUE
+24    CONTINUE
+      STOP '50 iterations should never happen'
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/filtrez/parafilt.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/filtrez/parafilt.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/filtrez/parafilt.h	(revision 1644)
@@ -0,0 +1,40 @@
+        INTEGER nfilun, nfilus, nfilvn, nfilvs
+!
+! 48 32 19 non-zoom:
+!       PARAMETER (nfilun=30,nfilus=30,nfilvn=30,nfilvs=30)
+!        PARAMETER (nfilun=6, nfilus=5, nfilvn=5, nfilvs=5)
+!         PARAMETER (nfilun=15, nfilus=8, nfilvn=14, nfilvs=8)
+!        PARAMETER (nfilun=24, nfilus=23, nfilvn=24, nfilvs=24)
+!maf -debug  PARAMETER (nfilun=2, nfilus=1, nfilvn=2, nfilvs=2)
+!
+!
+! 96 49 11 non-zoom:
+!cc      PARAMETER (nfilun=9, nfilus=8, nfilvn=8, nfilvs=8)
+!
+!
+! 144 73 11 non-zoom:
+!cc      PARAMETER (nfilun=13, nfilus=12, nfilvn=12, nfilvs=12)
+!
+! 192 143 19 non-zoom:
+!             PARAMETER (nfilun=13, nfilus=12, nfilvn=13, nfilvs=13)
+!      PARAMETER (nfilun=15, nfilus=14, nfilvn=14, nfilvs=14) !!NO fxyhyper
+!      PARAMETER (nfilun=18, nfilus=17, nfilvn=17, nfilvs=17) !!NO fxyhyper
+!!        PARAMETER (nfilun=9,nfilus=8,nfilvn=8,nfilvs=8)
+        PARAMETER (nfilun=9,nfilus=9,nfilvn=9,nfilvs=9)
+! 96 72 19 non-zoom:
+!cc      PARAMETER (nfilun=12, nfilus=11, nfilvn=12, nfilvs=12)
+!
+!        PARAMETER ( nfilun=20, nfilus=20, nfilvn=20, nfilvs=20 )
+!       PARAMETER ( nfilun=8, nfilus=7, nfilvn=7, nfilvs=7 )
+!
+!
+!      Ici , on a exagere  les nombres de lignes de latitudes a filtrer .
+!
+!      La premiere fois que  le Gcm  rentrera  dans le Filtre ,
+!
+!      il indiquera  les bonnes valeurs  de  nfilun , nflius, nfilvn  et 
+!
+!      nfilvs  a  mettre .  Il suffira alors de changer ces valeurs dans
+!
+!      Parameter  ci-dessus  et de relancer  le  run .  
+
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.1.1.32.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.1.1.32.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.1.1.32.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.10.48.55.t6
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.10.48.55.t6	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.10.48.55.t6	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.16.13.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.16.13.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.16.13.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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= 12
+      INTEGER, parameter :: jjm=16
+      INTEGER, parameter :: llm=13
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.16.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.16.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.16.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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= 12
+      INTEGER, parameter :: jjm=16
+      INTEGER, parameter :: llm=18
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.12.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.13.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.13.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.13.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=13
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.14.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.14.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.14.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=14
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.15.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.15.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.15.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=15
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.15.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.15.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.15.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=15
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.13.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.13.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.13.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=13
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.15.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.15.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.15.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=15
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.16.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.16.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.16.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=16
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=18
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.20.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.20.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.20.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=20
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.25.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.25.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.25.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=25
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.32.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.32.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.32.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=32
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.4.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.4.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.4.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=4
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.8.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.8.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.12.8.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=12
+      INTEGER, parameter :: llm=8
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.2.4.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.2.4.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.2.4.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=2
+      INTEGER, parameter :: llm=4
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.13.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.13.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.13.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=13
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t15
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t15	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t15	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.25.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.32.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.32.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.32.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.32.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.32.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.24.32.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.32.25.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.32.25.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.32.25.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.32.25.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.32.25.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.32.25.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.16.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=16
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.176.90.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.176.90.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.176.90.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.12.5.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.12.5.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.12.5.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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= 18
+      INTEGER, parameter :: jjm=12
+      INTEGER, parameter :: llm=5
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.12.8.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.12.8.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.12.8.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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= 18
+      INTEGER, parameter :: jjm=12
+      INTEGER, parameter :: llm=8
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=18
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.18.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=18
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.2.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.2.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.2.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=20
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=20
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=2
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.20.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=20
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=22
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=22
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=2
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.22.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=22
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.23.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.23.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.23.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=23
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.24.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.24.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.24.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=24
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t15
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t15	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t15	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t32
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t32	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.25.t32	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.256.180.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.256.180.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.256.180.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.26.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.26.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.26.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=26
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.27.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.27.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.27.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=27
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.28.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.28.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.28.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=28
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.30.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.30.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.30.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=30
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.13.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.13.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.13.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=13
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.13.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.13.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.13.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=13
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=15
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=15
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=2
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.15.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=15
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=18
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.18.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.18.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.18.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=18
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=2
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=20
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=20
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=2
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.20.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=20
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.22.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.22.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.22.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=22
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.22.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.22.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.22.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=22
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=2
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t3
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t3	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.25.t3	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=3
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.26.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.26.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.26.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.32.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.4.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.4.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.4.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=4
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.5.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.5.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.5.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=5
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t13
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t13	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t13	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.50.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t12
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t12	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t12	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t60
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t60	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.24.60.t60	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.34.60.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.34.60.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.34.60.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t15
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t15	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t15	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.32.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.35.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.35.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.35.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=35
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.352.180.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.352.180.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.352.180.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.352.180.36.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.352.180.36.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.352.180.36.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.4.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.4.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.4.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=4
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.5.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.5.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.5.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=5
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t15
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t15	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.50.t15	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.13.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.13.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.13.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=13
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.18.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.18.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.18.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.22.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.22.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.22.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=22
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.24.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.24.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.24.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t-p
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t-p	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t-p	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.25.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t12
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t12	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t12	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t13
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t13	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t13	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t15
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t15	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t15	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t4
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t4	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.32.t4	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.325.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.325.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.325.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t15
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t15	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.50.t15	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.54.t14
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.54.t14	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.54.t14	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.54.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.54.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.64.48.54.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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: /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.72.36.32.t2
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.72.36.32.t2	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.72.36.32.t2	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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.TITAN/libf/grid/dimension/dimensions.8.t1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.8.t1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/dimensions.8.t1	(revision 1644)
@@ -0,0 +1,16 @@
+!-----------------------------------------------------------------------
+!   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=8
+      INTEGER, parameter :: ndm=1
+
+      integer, parameter :: nqmx=1
+
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/makdim
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/makdim	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/makdim	(revision 1644)
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+#nqmx=$1
+#shift
+for i in $* ; do
+   list=$list.$i
+done
+fichdim=dimensions${list}
+#fichdim=dimensions${list}.t${nqmx}
+
+echo $fichdim
+
+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 "you need at least one dimension!"
+         exit
+ fi
+fi
+fi
+
+cat << EOF > $fichdim
+!-----------------------------------------------------------------------
+!   INCLUDE 'dimensions.h'
+!
+!   dimensions.h contains the model dimensions
+!   
+!-----------------------------------------------------------------------
+
+      INTEGER, parameter :: iim=$im
+      INTEGER, parameter :: jjm=$jm
+      INTEGER, parameter :: llm=$lm
+      INTEGER, parameter :: ndm=$ndm
+
+!-----------------------------------------------------------------------
+EOF
+
+else
+ echo "dimensions file already exists!"
+fi
+
+\rm ../dimensions.h
+tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim dimensions.h )
Index: /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.bak
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.bak	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.bak	(revision 1644)
@@ -0,0 +1,63 @@
+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: /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.moi
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.moi	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.moi	(revision 1644)
@@ -0,0 +1,68 @@
+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: /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.n
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.n	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.n	(revision 1644)
@@ -0,0 +1,65 @@
+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: /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.old
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.old	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/makdim.old	(revision 1644)
@@ -0,0 +1,57 @@
+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: /trunk/LMDZ.TITAN/libf/grid/dimension/makdimphy
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/makdimphy	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/makdimphy	(revision 1644)
@@ -0,0 +1,28 @@
+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: /trunk/LMDZ.TITAN/libf/grid/dimension/makntrac
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/makntrac	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/makntrac	(revision 1644)
@@ -0,0 +1,23 @@
+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: /trunk/LMDZ.TITAN/libf/grid/dimension/ntraceur.1
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/ntraceur.1	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/ntraceur.1	(revision 1644)
@@ -0,0 +1,12 @@
+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: /trunk/LMDZ.TITAN/libf/grid/dimension/ntraceur.5
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/dimension/ntraceur.5	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/dimension/ntraceur.5	(revision 1644)
@@ -0,0 +1,12 @@
+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.TITAN/libf/grid/fxy_new.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/fxy_new.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/fxy_new.h	(revision 1644)
@@ -0,0 +1,21 @@
+c--------------------------------------------------------------
+         REAL ripx
+         REAL fx,fxprim,fy,fyprim,ri,rj,bigy
+c
+c....stretching in x...
+c
+        ripx(  ri )= (ri-1.0) *2.*pi/FLOAT(iim) 
+        fx  (  ri )= ripx(ri) + transx  +
+     *         alphax * SIN( ripx(ri)+transx-pxo ) - pi
+        fxprim(ri) = 2.*pi/FLOAT(iim)  *
+     *        ( 1.+ alphax * COS( ripx(ri)+transx-pxo ) )
+
+c....stretching in y...
+c
+        bigy(rj)   = 2.* (FLOAT(jjp1)-rj) *pi/jjm
+        fy(rj)     =  ( bigy(rj) + transy  +
+     *        alphay * SIN( bigy(rj)+transy-pyo ) ) /2.  - pi/2.
+        fyprim(rj) = ( pi/jjm ) * ( 1.+
+     *           alphay * COS( bigy(rj)+transy-pyo ) )
+
+c--------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/fxy_reg.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/fxy_reg.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/fxy_reg.h	(revision 1644)
@@ -0,0 +1,42 @@
+c-----------------------------------------------------------------------
+c INCLUDE 'fxyprim.h'
+c
+c    ................................................................
+c    ................  Fonctions in line  ...........................
+c    ................................................................
+c
+      REAL  fy, fx, fxprim, fyprim
+      REAL  ri, rj
+c
+c
+      fy    ( rj ) =    pi/FLOAT(jjm) * ( 0.5 * FLOAT(jjm) +  1. - rj  )
+      fyprim( rj ) =    pi/FLOAT(jjm)
+
+c     fy(rj)=ASIN(1.+2.*((1.-rj)/FLOAT(jjm)))
+c     fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
+
+      fx    ( ri ) = 2.*pi/FLOAT(iim) * ( ri - 0.5*  FLOAT(iim) - 1. )
+c     fx    ( ri ) = 2.*pi/FLOAT(iim) * ( ri - 0.5* ( FLOAT(iim) + 1.) )
+      fxprim( ri ) = 2.*pi/FLOAT(iim)
+c
+c
+c    La valeur de pi est passee par le common/const/ou /const2/ .
+c    Sinon, il faut la calculer avant d'appeler ces fonctions .
+c
+c   ----------------------------------------------------------------
+c     Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
+c   -----------------------------------------------------------------
+c
+c    .....  ici, on a l'application particuliere suivante   ........
+c
+c                **************************************
+c                **     x = 2. * pi/iim *  X         **
+c                **     y =      pi/jjm *  Y         **
+c                **************************************
+c
+c   ..................................................................
+c   ..................................................................
+c
+c
+c
+c-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/fxy_sin.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/fxy_sin.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/fxy_sin.h	(revision 1644)
@@ -0,0 +1,39 @@
+c-----------------------------------------------------------------------
+c INCLUDE 'fxyprim.h'
+c
+c    ................................................................
+c    ................  Fonctions in line  ...........................
+c    ................................................................
+c
+      REAL  fy, fx, fxprim, fyprim
+      REAL  ri, rj
+c
+c
+      fy(rj)=ASIN(1.+2.*((1.-rj)/FLOAT(jjm)))
+      fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
+
+      fx    ( ri ) = 2.*pi/FLOAT(iim) * ( ri - 0.5*  FLOAT(iim) - 1. )
+c     fx    ( ri ) = 2.*pi/FLOAT(iim) * ( ri - 0.5* ( FLOAT(iim) + 1.) )
+      fxprim( ri ) = 2.*pi/FLOAT(iim)
+c
+c
+c    La valeur de pi est passee par le common/const/ou /const2/ .
+c    Sinon, il faut la calculer avant d'appeler ces fonctions .
+c
+c   ----------------------------------------------------------------
+c     Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
+c   -----------------------------------------------------------------
+c
+c    .....  ici, on a l'application particuliere suivante   ........
+c
+c                **************************************
+c                **     x = 2. * pi/iim *  X         **
+c                **     y =      pi/jjm *  Y         **
+c                **************************************
+c
+c   ..................................................................
+c   ..................................................................
+c
+c
+c
+c-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/grid/fxyprim.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/grid/fxyprim.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/grid/fxyprim.h	(revision 1644)
@@ -0,0 +1,42 @@
+c-----------------------------------------------------------------------
+c INCLUDE 'fxyprim.h'
+c
+c    ................................................................
+c    ................  Fonctions in line  ...........................
+c    ................................................................
+c
+      REAL  fy, fx, fxprim, fyprim
+      REAL  ri, rj
+c
+c
+      fy    ( rj ) =    pi/FLOAT(jjm) * ( 0.5 * FLOAT(jjm) +  1. - rj  )
+      fyprim( rj ) =    pi/FLOAT(jjm)
+
+c     fy(rj)=ASIN(1.+2.*((1.-rj)/FLOAT(jjm)))
+c     fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
+
+      fx    ( ri ) = 2.*pi/FLOAT(iim) * ( ri - 0.5*  FLOAT(iim) - 1. )
+c     fx    ( ri ) = 2.*pi/FLOAT(iim) * ( ri - 0.5* ( FLOAT(iim) + 1.) )
+      fxprim( ri ) = 2.*pi/FLOAT(iim)
+c
+c
+c    La valeur de pi est passee par le common/const/ou /const2/ .
+c    Sinon, il faut la calculer avant d'appeler ces fonctions .
+c
+c   ----------------------------------------------------------------
+c     Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
+c   -----------------------------------------------------------------
+c
+c    .....  ici, on a l'application particuliere suivante   ........
+c
+c                **************************************
+c                **     x = 2. * pi/iim *  X         **
+c                **     y =      pi/jjm *  Y         **
+c                **************************************
+c
+c   ..................................................................
+c   ..................................................................
+c
+c
+c
+c-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/misc/cbrt.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/cbrt.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/cbrt.F	(revision 1644)
@@ -0,0 +1,9 @@
+      FUNCTION cbrt(x)
+      IMPLICIT NONE
+
+      REAL x,cbrt
+
+      cbrt=sign(1.,x)*(abs(x)**(1./3.))
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/misc/cvmgp.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/cvmgp.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/cvmgp.F	(revision 1644)
@@ -0,0 +1,14 @@
+      FUNCTION cvmgp(x1,x2,x3)
+      IMPLICIT NONE
+
+      REAL x1,x2,x3,cvmgp
+
+      IF(x3.ge.0) then 
+        cvmgp=x1
+      ELSE
+        cvmgp=x2
+      ENDIF
+
+      RETURN
+      END
+C
Index: /trunk/LMDZ.TITAN/libf/misc/cvmgt.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/cvmgt.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/cvmgt.F	(revision 1644)
@@ -0,0 +1,15 @@
+      FUNCTION cvmgt(x1,x2,l)
+      IMPLICIT NONE
+
+      REAL x1,x2,cvmgt
+      LOGICAL l
+
+      IF(l) then 
+        cvmgt=x1
+      ELSE
+        cvmgt=x2
+      ENDIF
+
+      RETURN
+      END
+C
Index: /trunk/LMDZ.TITAN/libf/misc/ilsum.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/ilsum.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/ilsum.F	(revision 1644)
@@ -0,0 +1,19 @@
+      FUNCTION ilsum(n, logic, inc)
+c
+      IMPLICIT NONE
+c
+      integer ilsum
+      integer n, inc
+      logical logic((n-1)*inc+1)
+c
+      integer i, in
+c
+      ilsum = 0.
+      in = 1
+      do 10 i = 1, n
+         if (logic(in)) ilsum = ilsum + 1
+         in=in+inc
+10    continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/iniprint.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/iniprint.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/iniprint.h	(revision 1644)
@@ -0,0 +1,11 @@
+!
+! $Id: $
+!
+!
+! handle debug and output levels
+! lunout:    unit of file where outputs will be sent
+!                           (default is 6, standard output)
+! prt_level: level of informative output messages (0 = minimum)
+!
+      INTEGER lunout, prt_level
+      COMMON /comprint/ lunout, prt_level
Index: /trunk/LMDZ.TITAN/libf/misc/ioipsl_errioipsl.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/ioipsl_errioipsl.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/ioipsl_errioipsl.F90	(revision 1644)
@@ -0,0 +1,219 @@
+!
+! $Id$
+!
+! Module/Routines extracted from IOIPSL v2_1_8
+!
+MODULE ioipsl_errioipsl
+!-
+!$Id: errioipsl.f90 386 2008-09-04 08:38:48Z bellier $
+!-
+! This software is governed by the CeCILL license
+! See IOIPSL/IOIPSL_License_CeCILL.txt
+!---------------------------------------------------------------------
+IMPLICIT NONE
+!-
+PRIVATE
+!-
+PUBLIC :: ipslnlf, ipslerr, ipslerr_act, ipslerr_inq, histerr, ipsldbg
+!-
+  INTEGER :: n_l=6, ilv_cur=0, ilv_max=0
+  LOGICAL :: ioipsl_debug=.FALSE., lact_mode=.TRUE.
+!-
+!===
+CONTAINS
+!===
+SUBROUTINE ipslnlf (new_number,old_number)
+!!--------------------------------------------------------------------
+!! The "ipslnlf" routine allows to know and modify
+!! the current logical number for the messages.
+!!
+!! SUBROUTINE ipslnlf (new_number,old_number)
+!!
+!! Optional INPUT argument
+!!
+!! (I) new_number : new logical number of the file
+!!
+!! Optional OUTPUT argument
+!!
+!! (I) old_number : current logical number of the file
+!!--------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,OPTIONAL,INTENT(IN)  :: new_number
+  INTEGER,OPTIONAL,INTENT(OUT) :: old_number
+!---------------------------------------------------------------------
+  IF (PRESENT(old_number)) THEN
+    old_number = n_l
+  ENDIF
+  IF (PRESENT(new_number)) THEN
+    n_l = new_number
+  ENDIF
+!---------------------
+END SUBROUTINE ipslnlf
+!===
+SUBROUTINE ipslerr (plev,pcname,pstr1,pstr2,pstr3)
+!---------------------------------------------------------------------
+!! The "ipslerr" routine
+!! allows to handle the messages to the user.
+!!
+!! INPUT
+!!
+!! plev   : Category of message to be reported to the user
+!!          1 = Note to the user
+!!          2 = Warning to the user
+!!          3 = Fatal error
+!! pcname : Name of subroutine which has called ipslerr
+!! pstr1   
+!! pstr2  : Strings containing the explanations to the user
+!! pstr3
+!---------------------------------------------------------------------
+   IMPLICIT NONE
+!-
+   INTEGER :: plev
+   CHARACTER(LEN=*) :: pcname,pstr1,pstr2,pstr3
+!-
+   CHARACTER(LEN=30),DIMENSION(3) :: pemsg = &
+  &  (/ "NOTE TO THE USER FROM ROUTINE ", &
+  &     "WARNING FROM ROUTINE          ", &
+  &     "FATAL ERROR FROM ROUTINE      " /)
+!---------------------------------------------------------------------
+   IF ( (plev >= 1).AND.(plev <= 3) ) THEN
+     ilv_cur = plev
+     ilv_max = MAX(ilv_max,plev)
+     WRITE(n_l,'(/,A," ",A)') TRIM(pemsg(plev)),TRIM(pcname)
+     WRITE(n_l,'(3(" --> ",A,/))') TRIM(pstr1),TRIM(pstr2),TRIM(pstr3)
+   ENDIF
+   IF ( (plev == 3).AND.lact_mode) THEN
+     STOP 'Fatal error from IOIPSL. See stdout for more details'
+   ENDIF
+!---------------------
+END SUBROUTINE ipslerr
+!===
+SUBROUTINE ipslerr_act (new_mode,old_mode)
+!!--------------------------------------------------------------------
+!! The "ipslerr_act" routine allows to know and modify
+!! the current "action mode" for the error messages,
+!! and reinitialize the error level values.
+!!
+!! SUBROUTINE ipslerr_act (new_mode,old_mode)
+!!
+!! Optional INPUT argument
+!!
+!! (I) new_mode : new error action mode
+!!                .TRUE.  -> STOP     in case of fatal error
+!!                .FALSE. -> CONTINUE in case of fatal error
+!!
+!! Optional OUTPUT argument
+!!
+!! (I) old_mode : current error action mode
+!!--------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  LOGICAL,OPTIONAL,INTENT(IN)  :: new_mode
+  LOGICAL,OPTIONAL,INTENT(OUT) :: old_mode
+!---------------------------------------------------------------------
+  IF (PRESENT(old_mode)) THEN
+    old_mode = lact_mode
+  ENDIF
+  IF (PRESENT(new_mode)) THEN
+    lact_mode = new_mode
+  ENDIF
+  ilv_cur = 0
+  ilv_max = 0
+!-------------------------
+END SUBROUTINE ipslerr_act
+!===
+SUBROUTINE ipslerr_inq (current_level,maximum_level)
+!!--------------------------------------------------------------------
+!! The "ipslerr_inq" routine allows to know
+!! the current level of the error messages
+!! and the maximum level encountered since the
+!! last call to "ipslerr_act".
+!!
+!! SUBROUTINE ipslerr_inq (current_level,maximum_level)
+!!
+!! Optional OUTPUT argument
+!!
+!! (I) current_level : current error level
+!! (I) maximum_level : maximum error level
+!!--------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,OPTIONAL,INTENT(OUT) :: current_level,maximum_level
+!---------------------------------------------------------------------
+  IF (PRESENT(current_level)) THEN
+    current_level = ilv_cur
+  ENDIF
+  IF (PRESENT(maximum_level)) THEN
+    maximum_level = ilv_max
+  ENDIF
+!-------------------------
+END SUBROUTINE ipslerr_inq
+!===
+SUBROUTINE histerr (plev,pcname,pstr1,pstr2,pstr3)
+!---------------------------------------------------------------------
+!- INPUT
+!- plev   : Category of message to be reported to the user
+!-          1 = Note to the user
+!-          2 = Warning to the user
+!-          3 = Fatal error
+!- pcname : Name of subroutine which has called histerr
+!- pstr1   
+!- pstr2  : String containing the explanations to the user
+!- pstr3
+!---------------------------------------------------------------------
+   IMPLICIT NONE
+!-
+   INTEGER :: plev
+   CHARACTER(LEN=*) :: pcname,pstr1,pstr2,pstr3
+!-
+   CHARACTER(LEN=30),DIMENSION(3) :: pemsg = &
+  &  (/ "NOTE TO THE USER FROM ROUTINE ", &
+  &     "WARNING FROM ROUTINE          ", &
+  &     "FATAL ERROR FROM ROUTINE      " /)
+!---------------------------------------------------------------------
+   IF ( (plev >= 1).AND.(plev <= 3) ) THEN
+     WRITE(*,'("     ")')
+     WRITE(*,'(A," ",A)') TRIM(pemsg(plev)),TRIM(pcname)
+     WRITE(*,'(" --> ",A)') pstr1
+     WRITE(*,'(" --> ",A)') pstr2
+     WRITE(*,'(" --> ",A)') pstr3
+   ENDIF
+   IF (plev == 3) THEN
+     STOP 'Fatal error from IOIPSL. See stdout for more details'
+   ENDIF
+!---------------------
+END SUBROUTINE histerr
+!===
+SUBROUTINE ipsldbg (new_status,old_status)
+!!--------------------------------------------------------------------
+!! The "ipsldbg" routine
+!! allows to activate or deactivate the debug,
+!! and to know the current status of the debug.
+!!
+!! SUBROUTINE ipsldbg (new_status,old_status)
+!!
+!! Optional INPUT argument
+!!
+!! (L) new_status : new status of the debug
+!!
+!! Optional OUTPUT argument
+!!
+!! (L) old_status : current status of the debug
+!!--------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  LOGICAL,OPTIONAL,INTENT(IN)  :: new_status
+  LOGICAL,OPTIONAL,INTENT(OUT) :: old_status
+!---------------------------------------------------------------------
+  IF (PRESENT(old_status)) THEN
+    old_status = ioipsl_debug
+  ENDIF
+  IF (PRESENT(new_status)) THEN
+    ioipsl_debug = new_status
+  ENDIF
+!---------------------
+END SUBROUTINE ipsldbg
+!===
+!-------------------
+END MODULE ioipsl_errioipsl
Index: /trunk/LMDZ.TITAN/libf/misc/ioipsl_getincom.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/ioipsl_getincom.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/ioipsl_getincom.F90	(revision 1644)
@@ -0,0 +1,1980 @@
+!
+! $Id$
+!
+! Module/Routines extracted from IOIPSL v2_1_8
+!
+MODULE ioipsl_getincom
+!-
+!$Id: getincom.f90 536 2009-01-30 11:46:27Z bellier $
+!-
+! This software is governed by the CeCILL license
+! See IOIPSL/IOIPSL_License_CeCILL.txt
+!---------------------------------------------------------------------
+USE ioipsl_errioipsl, ONLY : ipslerr
+USE ioipsl_stringop, &
+ &   ONLY : nocomma,cmpblank,strlowercase
+!-
+IMPLICIT NONE
+!-
+PRIVATE
+PUBLIC :: getin, getin_dump
+!-
+INTERFACE getin
+!!--------------------------------------------------------------------
+!! The "getin" routines get a variable.
+!! We first check if we find it in the database
+!! and if not we get it from the run.def file.
+!!
+!! SUBROUTINE getin (target,ret_val)
+!!
+!! INPUT
+!!
+!! (C) target : Name of the variable
+!!
+!! OUTPUT
+!!
+!! (I/R/C/L) ret_val : scalar, vector or matrix that will contain
+!!                     that will contain the (standard)
+!!                     integer/real/character/logical values
+!!--------------------------------------------------------------------
+  MODULE PROCEDURE getinrs, getinr1d, getinr2d, &
+ &                 getinis, getini1d, getini2d, &
+ &                 getincs, getinc1d, getinc2d, &
+ &                 getinls, getinl1d, getinl2d
+END INTERFACE
+!-
+!!--------------------------------------------------------------------
+!! The "getin_dump" routine will dump the content of the database
+!! into a file which has the same format as the run.def file.
+!! The idea is that the user can see which parameters were used
+!! and re-use the file for another run.
+!!
+!!  SUBROUTINE getin_dump (fileprefix)
+!!
+!! OPTIONAL INPUT argument
+!!
+!! (C) fileprefix : allows the user to change the name of the file
+!!                  in which the data will be archived
+!!--------------------------------------------------------------------
+!-
+  INTEGER,PARAMETER :: max_files=100
+  CHARACTER(LEN=100),DIMENSION(max_files),SAVE :: filelist
+  INTEGER,SAVE      :: nbfiles
+!-
+  INTEGER,PARAMETER :: i_txtslab=1000,l_n=30
+  INTEGER,SAVE :: nb_lines,i_txtsize=0
+  CHARACTER(LEN=100),SAVE,ALLOCATABLE,DIMENSION(:) :: fichier
+  CHARACTER(LEN=l_n),SAVE,ALLOCATABLE,DIMENSION(:) :: targetlist
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: fromfile,compline
+!-
+  INTEGER,PARAMETER :: n_d_fmt=5,max_msgs=15
+  CHARACTER(LEN=6),SAVE :: c_i_fmt = '(I5.5)'
+!-
+! The data base of parameters
+!-
+  INTEGER,PARAMETER :: memslabs=200
+  INTEGER,PARAMETER :: compress_lim=20
+!-
+  INTEGER,SAVE :: nb_keys=0
+  INTEGER,SAVE :: keymemsize=0
+!-
+! keystr definition
+! name of a key
+!-
+! keystatus definition
+! keystatus = 1 : Value comes from run.def
+! keystatus = 2 : Default value is used
+! keystatus = 3 : Some vector elements were taken from default
+!-
+! keytype definition
+! keytype = 1 : Integer
+! keytype = 2 : Real
+! keytype = 3 : Character
+! keytype = 4 : Logical
+!-
+  INTEGER,PARAMETER :: k_i=1, k_r=2, k_c=3, k_l=4
+!-
+! Allow compression for keys (only for integer and real)
+! keycompress < 0 : not compressed
+! keycompress > 0 : number of repeat of the value
+!-
+TYPE :: t_key
+  CHARACTER(LEN=l_n) :: keystr
+  INTEGER :: keystatus, keytype, keycompress, &
+ &           keyfromfile, keymemstart, keymemlen
+END TYPE t_key
+!-
+  TYPE(t_key),SAVE,ALLOCATABLE,DIMENSION(:) :: key_tab
+!-
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: i_mem
+  INTEGER,SAVE :: i_memsize=0, i_mempos=0
+  REAL,SAVE,ALLOCATABLE,DIMENSION(:) :: r_mem
+  INTEGER,SAVE :: r_memsize=0, r_mempos=0
+  CHARACTER(LEN=100),SAVE,ALLOCATABLE,DIMENSION(:) :: c_mem
+  INTEGER,SAVE :: c_memsize=0, c_mempos=0
+  LOGICAL,SAVE,ALLOCATABLE,DIMENSION(:) :: l_mem
+  INTEGER,SAVE :: l_memsize=0, l_mempos=0
+!-
+CONTAINS
+!-
+!=== INTEGER INTERFACE
+!-
+SUBROUTINE getinis (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER :: ret_val
+!-
+  INTEGER,DIMENSION(1) :: tmp_ret_val
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  tmp_ret_val(1) = ret_val
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,1,i_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,1,target,i_val=tmp_ret_val)
+  ENDIF
+  ret_val = tmp_ret_val(1)
+!---------------------
+END SUBROUTINE getinis
+!===
+SUBROUTINE getini1d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER,DIMENSION(:) :: ret_val
+!-
+  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
+  ENDIF
+  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
+!----------------------
+END SUBROUTINE getini1d
+!===
+SUBROUTINE getini2d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER,DIMENSION(:,:) :: ret_val
+!-
+  INTEGER,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: jl,jj,ji
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  size_1 = SIZE(ret_val,1)
+  size_2 = SIZE(ret_val,2)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      tmp_ret_val(jl) = ret_val(ji,jj)
+    ENDDO
+  ENDDO
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      ret_val(ji,jj) = tmp_ret_val(jl)
+    ENDDO
+  ENDDO
+!----------------------
+END SUBROUTINE getini2d
+!-
+!=== REAL INTERFACE
+!-
+SUBROUTINE getinrs (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  REAL :: ret_val
+!-
+  REAL,DIMENSION(1) :: tmp_ret_val
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  tmp_ret_val(1) = ret_val
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,1,r_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,1,target,r_val=tmp_ret_val)
+  ENDIF
+  ret_val = tmp_ret_val(1)
+!---------------------
+END SUBROUTINE getinrs
+!===
+SUBROUTINE getinr1d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  REAL,DIMENSION(:) :: ret_val
+!-
+  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
+  ENDIF
+  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
+!----------------------
+END SUBROUTINE getinr1d
+!===
+SUBROUTINE getinr2d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  REAL,DIMENSION(:,:) :: ret_val
+!-
+  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: jl,jj,ji
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  size_1 = SIZE(ret_val,1)
+  size_2 = SIZE(ret_val,2)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      tmp_ret_val(jl) = ret_val(ji,jj)
+    ENDDO
+  ENDDO
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      ret_val(ji,jj) = tmp_ret_val(jl)
+    ENDDO
+  ENDDO
+!----------------------
+END SUBROUTINE getinr2d
+!-
+!=== CHARACTER INTERFACE
+!-
+SUBROUTINE getincs (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*) :: ret_val
+!-
+  CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  tmp_ret_val(1) = ret_val
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,1,c_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,1,target,c_val=tmp_ret_val)
+  ENDIF
+  ret_val = tmp_ret_val(1)
+!---------------------
+END SUBROUTINE getincs
+!===
+SUBROUTINE getinc1d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*),DIMENSION(:) :: ret_val
+!-
+  CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
+  ENDIF
+  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
+!----------------------
+END SUBROUTINE getinc1d
+!===
+SUBROUTINE getinc2d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val
+!-
+  CHARACTER(LEN=100),DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: jl,jj,ji
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  size_1 = SIZE(ret_val,1)
+  size_2 = SIZE(ret_val,2)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      tmp_ret_val(jl) = ret_val(ji,jj)
+    ENDDO
+  ENDDO
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      ret_val(ji,jj) = tmp_ret_val(jl)
+    ENDDO
+  ENDDO
+!----------------------
+END SUBROUTINE getinc2d
+!-
+!=== LOGICAL INTERFACE
+!-
+SUBROUTINE getinls (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  LOGICAL :: ret_val
+!-
+  LOGICAL,DIMENSION(1) :: tmp_ret_val
+  INTEGER :: pos,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  tmp_ret_val(1) = ret_val
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,1,l_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,1,target,l_val=tmp_ret_val)
+  ENDIF
+  ret_val = tmp_ret_val(1)
+!---------------------
+END SUBROUTINE getinls
+!===
+SUBROUTINE getinl1d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  LOGICAL,DIMENSION(:) :: ret_val
+!-
+  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,status=0,fileorig
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+  tmp_ret_val(1:size_of_in) = ret_val(1:size_of_in)
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
+  ENDIF
+  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
+!----------------------
+END SUBROUTINE getinl1d
+!===
+SUBROUTINE getinl2d (target,ret_val)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  LOGICAL,DIMENSION(:,:) :: ret_val
+!-
+  LOGICAL,DIMENSION(:),ALLOCATABLE,SAVE :: tmp_ret_val
+  INTEGER,SAVE :: tmp_ret_size = 0
+  INTEGER :: pos,size_of_in,size_1,size_2,status=0,fileorig
+  INTEGER :: jl,jj,ji
+!---------------------------------------------------------------------
+!-
+! Do we have this target in our database ?
+!-
+  CALL get_findkey (1,target,pos)
+!-
+  size_of_in = SIZE(ret_val)
+  size_1 = SIZE(ret_val,1)
+  size_2 = SIZE(ret_val,2)
+  IF (.NOT.ALLOCATED(tmp_ret_val)) THEN
+    ALLOCATE (tmp_ret_val(size_of_in))
+  ELSE IF (size_of_in > tmp_ret_size) THEN
+    DEALLOCATE (tmp_ret_val)
+    ALLOCATE (tmp_ret_val(size_of_in))
+    tmp_ret_size = size_of_in
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      tmp_ret_val(jl) = ret_val(ji,jj)
+    ENDDO
+  ENDDO
+!-
+  IF (pos < 0) THEN
+!-- Get the information out of the file
+    CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
+!-- Put the data into the database
+    CALL get_wdb &
+ &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
+  ELSE
+!-- Get the value out of the database
+    CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
+  ENDIF
+!-
+  jl=0
+  DO jj=1,size_2
+    DO ji=1,size_1
+      jl=jl+1
+      ret_val(ji,jj) = tmp_ret_val(jl)
+    ENDDO
+  ENDDO
+!----------------------
+END SUBROUTINE getinl2d
+!-
+!=== Generic file/database INTERFACE
+!-
+SUBROUTINE get_fil (target,status,fileorig,i_val,r_val,c_val,l_val)
+!---------------------------------------------------------------------
+!- Subroutine that will extract from the file the values
+!- attributed to the keyword target
+!-
+!- (C) target    : target for which we will look in the file
+!- (I) status    : tells us from where we obtained the data
+!- (I) fileorig  : index of the file from which the key comes
+!- (I) i_val(:)  : INTEGER(nb_to_ret)   values
+!- (R) r_val(:)  : REAL(nb_to_ret)      values
+!- (L) l_val(:)  : LOGICAL(nb_to_ret)   values
+!- (C) c_val(:)  : CHARACTER(nb_to_ret) values
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER,INTENT(OUT) :: status,fileorig
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
+  REAL,DIMENSION(:),OPTIONAL             :: r_val
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
+!-
+  INTEGER :: k_typ,nb_to_ret,it,pos,len_str,status_cnt,io_err
+  CHARACTER(LEN=n_d_fmt)  :: cnt
+  CHARACTER(LEN=80) :: str_READ,str_READ_lower
+  CHARACTER(LEN=9)  :: c_vtyp
+  LOGICAL,DIMENSION(:),ALLOCATABLE :: found
+  LOGICAL :: def_beha,compressed
+  CHARACTER(LEN=10) :: c_fmt
+  INTEGER :: i_cmpval
+  REAL    :: r_cmpval
+  INTEGER :: ipos_tr,ipos_fl
+!---------------------------------------------------------------------
+!-
+! Get the type of the argument
+  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
+  SELECT CASE (k_typ)
+  CASE(k_i)
+    nb_to_ret = SIZE(i_val)
+  CASE(k_r)
+    nb_to_ret = SIZE(r_val)
+  CASE(k_c)
+    nb_to_ret = SIZE(c_val)
+  CASE(k_l)
+    nb_to_ret = SIZE(l_val)
+  CASE DEFAULT
+    CALL ipslerr (3,'get_fil', &
+ &   'Internal error','Unknown type of data',' ')
+  END SELECT
+!-
+! Read the file(s)
+  CALL getin_read
+!-
+! Allocate and initialize the memory we need
+  ALLOCATE(found(nb_to_ret))
+  found(:) = .FALSE.
+!-
+! See what we find in the files read
+  DO it=1,nb_to_ret
+!---
+!-- First try the target as it is
+    CALL get_findkey (2,target,pos)
+!---
+!-- Another try
+!---
+    IF (pos < 0) THEN
+      WRITE(UNIT=cnt,FMT=c_i_fmt) it
+      CALL get_findkey (2,TRIM(target)//'__'//cnt,pos)
+    ENDIF
+!---
+!-- We dont know from which file the target could come.
+!-- Thus by default we attribute it to the first file :
+    fileorig = 1
+!---
+    IF (pos > 0) THEN
+!-----
+      found(it) = .TRUE.
+      fileorig = fromfile(pos)
+!-----
+!---- DECODE
+!-----
+      str_READ = ADJUSTL(fichier(pos))
+      str_READ_lower = str_READ
+      CALL strlowercase (str_READ_lower)
+!-----
+      IF (    (TRIM(str_READ_lower) == 'def')     &
+ &        .OR.(TRIM(str_READ_lower) == 'default') ) THEN
+        def_beha = .TRUE.
+      ELSE
+        def_beha = .FALSE.
+        len_str = LEN_TRIM(str_READ)
+        io_err = 0
+        SELECT CASE (k_typ)
+        CASE(k_i)
+          WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') len_str
+          READ (UNIT=str_READ(1:len_str), &
+ &              FMT=c_fmt,IOSTAT=io_err) i_val(it)
+        CASE(k_r)
+          READ (UNIT=str_READ(1:len_str), &
+ &              FMT=*,IOSTAT=io_err) r_val(it)
+        CASE(k_c)
+          c_val(it) = str_READ(1:len_str)
+        CASE(k_l)
+          ipos_tr = -1
+          ipos_fl = -1
+          ipos_tr = MAX(INDEX(str_READ_lower,'tru'), &
+ &                      INDEX(str_READ_lower,'y'))
+          ipos_fl = MAX(INDEX(str_READ_lower,'fal'), &
+ &                      INDEX(str_READ_lower,'n'))
+          IF (ipos_tr > 0) THEN
+            l_val(it) = .TRUE.
+          ELSE IF (ipos_fl > 0) THEN
+            l_val(it) = .FALSE.
+          ELSE
+            io_err = 100
+          ENDIF
+        END SELECT
+        IF (io_err /= 0) THEN
+          CALL ipslerr (3,'get_fil', &
+ &         'Target '//TRIM(target), &
+ &         'is not of '//TRIM(c_vtyp)//' type',' ')
+        ENDIF
+      ENDIF
+!-----
+      IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN
+!-------
+!------ Is this the value of a compressed field ?
+        compressed = (compline(pos) > 0)
+        IF (compressed) THEN
+          IF (compline(pos) /= nb_to_ret) THEN
+            CALL ipslerr (2,'get_fil', &
+ &           'For key '//TRIM(target)//' we have a compressed field', &
+ &           'which does not have the right size.', &
+ &           'We will try to fix that.')
+          ENDIF
+          IF      (k_typ == k_i) THEN
+            i_cmpval = i_val(it)
+          ELSE IF (k_typ == k_r) THEN
+            r_cmpval = r_val(it)
+          ENDIF
+        ENDIF
+      ENDIF
+    ELSE
+      found(it) = .FALSE.
+      def_beha = .FALSE.
+      compressed = .FALSE.
+    ENDIF
+  ENDDO
+!-
+  IF ( (k_typ == k_i).OR.(k_typ == k_r) ) THEN
+!---
+!-- If this is a compressed field then we will uncompress it
+    IF (compressed) THEN
+      DO it=1,nb_to_ret
+        IF (.NOT.found(it)) THEN
+          IF      (k_typ == k_i) THEN
+            i_val(it) = i_cmpval
+          ELSE IF (k_typ == k_r) THEN
+          ENDIF
+          found(it) = .TRUE.
+        ENDIF
+      ENDDO
+    ENDIF
+  ENDIF
+!-
+! Now we set the status for what we found
+  IF (def_beha) THEN
+    status = 2
+    WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(target)
+  ELSE
+    status_cnt = 0
+    DO it=1,nb_to_ret
+      IF (.NOT.found(it)) THEN
+        status_cnt = status_cnt+1
+        IF      (status_cnt <= max_msgs) THEN
+          WRITE (UNIT=*,FMT='(" USING DEFAULTS : ",A)', &
+ &               ADVANCE='NO') TRIM(target)
+          IF (nb_to_ret > 1) THEN
+            WRITE (UNIT=*,FMT='("__")',ADVANCE='NO')
+            WRITE (UNIT=*,FMT=c_i_fmt,ADVANCE='NO') it
+          ENDIF
+          SELECT CASE (k_typ)
+          CASE(k_i)
+            WRITE (UNIT=*,FMT=*) "=",i_val(it)
+          CASE(k_r)
+            WRITE (UNIT=*,FMT=*) "=",r_val(it)
+          CASE(k_c)
+            WRITE (UNIT=*,FMT=*) "=",c_val(it)
+          CASE(k_l)
+            WRITE (UNIT=*,FMT=*) "=",l_val(it)
+          END SELECT
+        ELSE IF (status_cnt == max_msgs+1) THEN
+          WRITE (UNIT=*,FMT='(" USING DEFAULTS ... ",A)')
+        ENDIF
+      ENDIF
+    ENDDO
+!---
+    IF (status_cnt == 0) THEN
+      status = 1
+    ELSE IF (status_cnt == nb_to_ret) THEN
+      status = 2
+    ELSE
+      status = 3
+    ENDIF
+  ENDIF
+! Deallocate the memory
+  DEALLOCATE(found)
+!---------------------
+END SUBROUTINE get_fil
+!===
+SUBROUTINE get_rdb (pos,size_of_in,target,i_val,r_val,c_val,l_val)
+!---------------------------------------------------------------------
+!- Read the required variable in the database
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: pos,size_of_in
+  CHARACTER(LEN=*) :: target
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
+  REAL,DIMENSION(:),OPTIONAL             :: r_val
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
+!-
+  INTEGER :: k_typ,k_beg,k_end
+  CHARACTER(LEN=9) :: c_vtyp
+!---------------------------------------------------------------------
+!-
+! Get the type of the argument
+  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
+  IF (     (k_typ /= k_i).AND.(k_typ /= k_r) &
+ &    .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN
+    CALL ipslerr (3,'get_rdb', &
+ &   'Internal error','Unknown type of data',' ')
+  ENDIF
+!-
+  IF (key_tab(pos)%keytype /= k_typ) THEN
+    CALL ipslerr (3,'get_rdb', &
+ &   'Wrong data type for keyword '//TRIM(target), &
+ &   '(NOT '//TRIM(c_vtyp)//')',' ')
+  ENDIF
+!-
+  IF (key_tab(pos)%keycompress > 0) THEN
+    IF (    (key_tab(pos)%keycompress /= size_of_in) &
+ &      .OR.(key_tab(pos)%keymemlen /= 1) ) THEN
+      CALL ipslerr (3,'get_rdb', &
+ &     'Wrong compression length','for keyword '//TRIM(target),' ')
+    ELSE
+      SELECT CASE (k_typ)
+      CASE(k_i)
+        i_val(1:size_of_in) = i_mem(key_tab(pos)%keymemstart)
+      CASE(k_r)
+        r_val(1:size_of_in) = r_mem(key_tab(pos)%keymemstart)
+      END SELECT
+    ENDIF
+  ELSE
+    IF (key_tab(pos)%keymemlen /= size_of_in) THEN
+      CALL ipslerr (3,'get_rdb', &
+ &     'Wrong array length','for keyword '//TRIM(target),' ')
+    ELSE
+      k_beg = key_tab(pos)%keymemstart
+      k_end = k_beg+key_tab(pos)%keymemlen-1
+      SELECT CASE (k_typ)
+      CASE(k_i)
+        i_val(1:size_of_in) = i_mem(k_beg:k_end)
+      CASE(k_r)
+        r_val(1:size_of_in) = r_mem(k_beg:k_end)
+      CASE(k_c)
+        c_val(1:size_of_in) = c_mem(k_beg:k_end)
+      CASE(k_l)
+        l_val(1:size_of_in) = l_mem(k_beg:k_end)
+      END SELECT
+    ENDIF
+  ENDIF
+!---------------------
+END SUBROUTINE get_rdb
+!===
+SUBROUTINE get_wdb &
+ &  (target,status,fileorig,size_of_in, &
+ &   i_val,r_val,c_val,l_val)
+!---------------------------------------------------------------------
+!- Write data into the data base
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: target
+  INTEGER :: status,fileorig,size_of_in
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
+  REAL,DIMENSION(:),OPTIONAL             :: r_val
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_val
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
+!-
+  INTEGER :: k_typ
+  CHARACTER(LEN=9) :: c_vtyp
+  INTEGER :: k_mempos,k_memsize,k_beg,k_end
+  LOGICAL :: l_cmp
+!---------------------------------------------------------------------
+!-
+! Get the type of the argument
+  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
+  IF (     (k_typ /= k_i).AND.(k_typ /= k_r) &
+ &    .AND.(k_typ /= k_c).AND.(k_typ /= k_l) )THEN
+    CALL ipslerr (3,'get_wdb', &
+ &   'Internal error','Unknown type of data',' ')
+  ENDIF
+!-
+! First check if we have sufficiant space for the new key
+  IF (nb_keys+1 > keymemsize) THEN
+    CALL getin_allockeys ()
+  ENDIF
+!-
+  SELECT CASE (k_typ)
+  CASE(k_i)
+    k_mempos = i_mempos; k_memsize = i_memsize;
+    l_cmp = (MINVAL(i_val) == MAXVAL(i_val)) &
+ &         .AND.(size_of_in > compress_lim)
+  CASE(k_r)
+    k_mempos = r_mempos; k_memsize = r_memsize;
+    l_cmp = (MINVAL(r_val) == MAXVAL(r_val)) &
+ &         .AND.(size_of_in > compress_lim)
+  CASE(k_c)
+    k_mempos = c_mempos; k_memsize = c_memsize;
+    l_cmp = .FALSE.
+  CASE(k_l)
+    k_mempos = l_mempos; k_memsize = l_memsize;
+    l_cmp = .FALSE.
+  END SELECT
+!-
+! Fill out the items of the data base
+  nb_keys = nb_keys+1
+  key_tab(nb_keys)%keystr = target(1:MIN(LEN_TRIM(target),l_n))
+  key_tab(nb_keys)%keystatus = status
+  key_tab(nb_keys)%keytype = k_typ
+  key_tab(nb_keys)%keyfromfile = fileorig
+  key_tab(nb_keys)%keymemstart = k_mempos+1
+  IF (l_cmp) THEN
+    key_tab(nb_keys)%keycompress = size_of_in
+    key_tab(nb_keys)%keymemlen = 1
+  ELSE
+    key_tab(nb_keys)%keycompress = -1
+    key_tab(nb_keys)%keymemlen = size_of_in
+  ENDIF
+!-
+! Before writing the actual size lets see if we have the space
+  IF (key_tab(nb_keys)%keymemstart+key_tab(nb_keys)%keymemlen &
+ &    > k_memsize) THEN
+    CALL getin_allocmem (k_typ,key_tab(nb_keys)%keymemlen)
+  ENDIF
+!-
+  k_beg = key_tab(nb_keys)%keymemstart
+  k_end = k_beg+key_tab(nb_keys)%keymemlen-1
+  SELECT CASE (k_typ)
+  CASE(k_i)
+    i_mem(k_beg:k_end) = i_val(1:key_tab(nb_keys)%keymemlen)
+    i_mempos = k_end
+  CASE(k_r)
+    r_mem(k_beg:k_end) = r_val(1:key_tab(nb_keys)%keymemlen)
+    r_mempos = k_end
+  CASE(k_c)
+    c_mem(k_beg:k_end) = c_val(1:key_tab(nb_keys)%keymemlen)
+    c_mempos = k_end
+  CASE(k_l)
+    l_mem(k_beg:k_end) = l_val(1:key_tab(nb_keys)%keymemlen)
+    l_mempos = k_end
+  END SELECT
+!---------------------
+END SUBROUTINE get_wdb
+!-
+!===
+!-
+SUBROUTINE getin_read
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,SAVE :: allread=0
+  INTEGER,SAVE :: current
+!---------------------------------------------------------------------
+  IF (allread == 0) THEN
+!-- Allocate a first set of memory.
+    CALL getin_alloctxt ()
+    CALL getin_allockeys ()
+    CALL getin_allocmem (k_i,0)
+    CALL getin_allocmem (k_r,0)
+    CALL getin_allocmem (k_c,0)
+    CALL getin_allocmem (k_l,0)
+!-- Start with reading the files
+    nbfiles = 1
+    filelist(1) = 'run.def'
+    current = 1
+!--
+    DO WHILE (current <= nbfiles)
+      CALL getin_readdef (current)
+      current = current+1
+    ENDDO
+    allread = 1
+    CALL getin_checkcohe ()
+  ENDIF
+!------------------------
+END SUBROUTINE getin_read
+!-
+!===
+!-
+  SUBROUTINE getin_readdef(current)
+!---------------------------------------------------------------------
+!- This subroutine will read the files and only keep the
+!- the relevant information. The information is kept as it
+!- found in the file. The data will be analysed later.
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: current
+!-
+  CHARACTER(LEN=100) :: READ_str,NEW_str,last_key,key_str
+  CHARACTER(LEN=n_d_fmt) :: cnt
+  CHARACTER(LEN=10) :: c_fmt
+  INTEGER :: nb_lastkey
+!-
+  INTEGER :: eof,ptn,len_str,i,it,iund,io_err
+  LOGICAL :: check = .FALSE.
+!---------------------------------------------------------------------
+  eof = 0
+  ptn = 1
+  nb_lastkey = 0
+!-
+  IF (check) THEN
+    WRITE(*,*) 'getin_readdef : Open file ',TRIM(filelist(current))
+  ENDIF
+!-
+  OPEN (UNIT=22,FILE=filelist(current),STATUS="OLD",IOSTAT=io_err)
+  IF (io_err /= 0) THEN
+    CALL ipslerr (2,'getin_readdef', &
+ &  'Could not open file '//TRIM(filelist(current)),' ',' ')
+    RETURN
+  ENDIF
+!-
+  DO WHILE (eof /= 1)
+!---
+    CALL getin_skipafew (22,READ_str,eof,nb_lastkey)
+    len_str = LEN_TRIM(READ_str)
+    ptn = INDEX(READ_str,'=')
+!---
+    IF (ptn > 0) THEN
+!---- Get the target
+      key_str = TRIM(ADJUSTL(READ_str(1:ptn-1)))
+!---- Make sure that a vector keyword has the right length
+      iund = INDEX(key_str,'__')
+      IF (iund > 0) THEN
+        WRITE (UNIT=c_fmt,FMT='("(I",I3.3,")")') &
+ &        LEN_TRIM(key_str)-iund-1
+        READ(UNIT=key_str(iund+2:LEN_TRIM(key_str)), &
+ &           FMT=c_fmt,IOSTAT=io_err) it
+        IF ( (io_err == 0).AND.(it > 0) ) THEN
+          WRITE(UNIT=cnt,FMT=c_i_fmt) it
+          key_str = key_str(1:iund+1)//cnt
+        ELSE
+          CALL ipslerr (3,'getin_readdef', &
+ &         'A very strange key has just been found :', &
+ &         TRIM(key_str),' ')
+        ENDIF
+      ENDIF
+!---- Prepare the content
+      NEW_str = TRIM(ADJUSTL(READ_str(ptn+1:len_str)))
+      CALL nocomma (NEW_str)
+      CALL cmpblank (NEW_str)
+      NEW_str  = TRIM(ADJUSTL(NEW_str))
+      IF (check) THEN
+        WRITE(*,*) &
+ &        '--> getin_readdef : ',TRIM(key_str),' :: ',TRIM(NEW_str)
+      ENDIF
+!---- Decypher the content of NEW_str
+!-
+!---- This has to be a new key word, thus :
+      nb_lastkey = 0
+!----
+      CALL getin_decrypt (current,key_str,NEW_str,last_key,nb_lastkey)
+!----
+    ELSE IF (len_str > 0) THEN
+!---- Prepare the key if we have an old one to which
+!---- we will add the line just read
+      IF (nb_lastkey > 0) THEN
+        iund =  INDEX(last_key,'__')
+        IF (iund > 0) THEN
+!-------- We only continue a keyword, thus it is easy
+          key_str = last_key(1:iund-1)
+        ELSE
+          IF (nb_lastkey /= 1) THEN
+            CALL ipslerr (3,'getin_readdef', &
+ &           'We can not have a scalar keyword', &
+ &           'and a vector content',' ')
+          ENDIF
+!-------- The last keyword needs to be transformed into a vector.
+          WRITE(UNIT=cnt,FMT=c_i_fmt) 1
+          targetlist(nb_lines) = &
+ &         last_key(1:MIN(LEN_TRIM(last_key),l_n-n_d_fmt-2))//'__'//cnt
+          key_str = last_key(1:LEN_TRIM(last_key))
+        ENDIF
+      ENDIF
+!---- Prepare the content
+      NEW_str = TRIM(ADJUSTL(READ_str(1:len_str)))
+      CALL getin_decrypt (current,key_str,NEW_str,last_key,nb_lastkey)
+    ELSE
+!---- If we have an empty line then the keyword finishes
+      nb_lastkey = 0
+      IF (check) THEN
+        WRITE(*,*) 'getin_readdef : Have found an emtpy line '
+      ENDIF
+    ENDIF
+  ENDDO
+!-
+  CLOSE(UNIT=22)
+!-
+  IF (check) THEN
+    OPEN (UNIT=22,file='run.def.test')
+    DO i=1,nb_lines
+      WRITE(UNIT=22,FMT=*) targetlist(i)," : ",fichier(i)
+    ENDDO
+    CLOSE(UNIT=22)
+  ENDIF
+!---------------------------
+END SUBROUTINE getin_readdef
+!-
+!===
+!-
+SUBROUTINE getin_decrypt(current,key_str,NEW_str,last_key,nb_lastkey)
+!---------------------------------------------------------------------
+!- This subroutine is going to decypher the line.
+!- It essentialy checks how many items are included and
+!- it they can be attached to a key.
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+! ARGUMENTS
+!-
+  INTEGER :: current,nb_lastkey
+  CHARACTER(LEN=*) :: key_str,NEW_str,last_key
+!-
+! LOCAL
+!-
+  INTEGER :: len_str,blk,nbve,starpos
+  CHARACTER(LEN=100) :: tmp_str,new_key,mult
+  CHARACTER(LEN=n_d_fmt) :: cnt
+  CHARACTER(LEN=10) :: c_fmt
+!---------------------------------------------------------------------
+  len_str = LEN_TRIM(NEW_str)
+  blk = INDEX(NEW_str(1:len_str),' ')
+  tmp_str = NEW_str(1:len_str)
+!-
+! If the key is a new file then we take it up. Else
+! we save the line and go on.
+!-
+  IF (INDEX(key_str,'INCLUDEDEF') > 0) THEN
+    DO WHILE (blk > 0)
+      IF (nbfiles+1 > max_files) THEN
+        CALL ipslerr (3,'getin_decrypt', &
+ &       'Too many files to include',' ',' ')
+      ENDIF
+!-----
+      nbfiles = nbfiles+1
+      filelist(nbfiles) = tmp_str(1:blk)
+!-----
+      tmp_str = TRIM(ADJUSTL(tmp_str(blk+1:LEN_TRIM(tmp_str))))
+      blk = INDEX(tmp_str(1:LEN_TRIM(tmp_str)),' ')
+    ENDDO
+!---
+    IF (nbfiles+1 > max_files) THEN
+      CALL ipslerr (3,'getin_decrypt', &
+ &     'Too many files to include',' ',' ')
+    ENDIF
+!---
+    nbfiles =  nbfiles+1
+    filelist(nbfiles) = TRIM(ADJUSTL(tmp_str))
+!---
+    last_key = 'INCLUDEDEF'
+    nb_lastkey = 1
+  ELSE
+!-
+!-- We are working on a new line of input
+!-
+    IF (nb_lines+1 > i_txtsize) THEN
+      CALL getin_alloctxt ()
+    ENDIF
+    nb_lines = nb_lines+1
+!-
+!-- First we solve the issue of conpressed information. Once
+!-- this is done all line can be handled in the same way.
+!-
+    starpos = INDEX(NEW_str(1:len_str),'*')
+    IF ( (starpos > 0).AND.(tmp_str(1:1) /= '"') &
+ &                    .AND.(tmp_str(1:1) /= "'") ) THEN
+!-----
+      IF (INDEX(key_str(1:LEN_TRIM(key_str)),'__') > 0) THEN
+        CALL ipslerr (3,'getin_decrypt', &
+ &       'We can not have a compressed field of values', &
+ &       'in a vector notation (TARGET__n).', &
+ &       'The key at fault : '//TRIM(key_str))
+      ENDIF
+!-
+!---- Read the multiplied
+!-
+      mult = TRIM(ADJUSTL(NEW_str(1:starpos-1)))
+!---- Construct the new string and its parameters
+      NEW_str = TRIM(ADJUSTL(NEW_str(starpos+1:len_str)))
+      len_str = LEN_TRIM(NEW_str)
+      blk = INDEX(NEW_str(1:len_str),' ')
+      IF (blk > 1) THEN
+        CALL ipslerr (2,'getin_decrypt', &
+ &       'This is a strange behavior','you could report',' ')
+      ENDIF
+      WRITE (UNIT=c_fmt,FMT='("(I",I5.5,")")') LEN_TRIM(mult)
+      READ(UNIT=mult,FMT=c_fmt) compline(nb_lines)
+!---
+    ELSE
+      compline(nb_lines) = -1
+    ENDIF
+!-
+!-- If there is no space wthin the line then the target is a scalar
+!-- or the element of a properly written vector.
+!-- (ie of the type TARGET__00001)
+!-
+    IF (    (blk <= 1) &
+ &      .OR.(tmp_str(1:1) == '"') &
+ &      .OR.(tmp_str(1:1) == "'") ) THEN
+!-
+      IF (nb_lastkey == 0) THEN
+!------ Save info of current keyword as a scalar
+!------ if it is not a continuation
+        targetlist(nb_lines) = key_str(1:MIN(LEN_TRIM(key_str),l_n))
+        last_key = key_str(1:MIN(LEN_TRIM(key_str),l_n))
+        nb_lastkey = 1
+      ELSE
+!------ We are continuing a vector so the keyword needs
+!------ to get the underscores
+        WRITE(UNIT=cnt,FMT=c_i_fmt) nb_lastkey+1
+        targetlist(nb_lines) = &
+ &        key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
+        last_key = &
+ &        key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
+        nb_lastkey = nb_lastkey+1
+      ENDIF
+!-----
+      fichier(nb_lines) = NEW_str(1:len_str)
+      fromfile(nb_lines) = current
+    ELSE
+!-
+!---- If there are blanks whithin the line then we are dealing
+!---- with a vector and we need to split it in many entries
+!---- with the TARGET__n notation.
+!----
+!---- Test if the targer is not already a vector target !
+!-
+      IF (INDEX(TRIM(key_str),'__') > 0) THEN
+        CALL ipslerr (3,'getin_decrypt', &
+ &       'We have found a mixed vector notation (TARGET__n).', &
+ &       'The key at fault : '//TRIM(key_str),' ')
+      ENDIF
+!-
+      nbve = nb_lastkey
+      nbve = nbve+1
+      WRITE(UNIT=cnt,FMT=c_i_fmt) nbve
+!-
+      DO WHILE (blk > 0)
+!-
+!------ Save the content of target__nbve
+!-
+        fichier(nb_lines) = tmp_str(1:blk)
+        new_key = &
+ &       key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
+        targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n))
+        fromfile(nb_lines) = current
+!-
+        tmp_str = TRIM(ADJUSTL(tmp_str(blk+1:LEN_TRIM(tmp_str))))
+        blk = INDEX(TRIM(tmp_str),' ')
+!-
+        IF (nb_lines+1 > i_txtsize) THEN
+          CALL getin_alloctxt ()
+        ENDIF
+        nb_lines = nb_lines+1
+        nbve = nbve+1
+        WRITE(UNIT=cnt,FMT=c_i_fmt) nbve
+!-
+      ENDDO
+!-
+!---- Save the content of the last target
+!-
+      fichier(nb_lines) = tmp_str(1:LEN_TRIM(tmp_str))
+      new_key = &
+ &      key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
+      targetlist(nb_lines) = new_key(1:MIN(LEN_TRIM(new_key),l_n))
+      fromfile(nb_lines) = current
+!-
+      last_key = &
+ &      key_str(1:MIN(LEN_TRIM(key_str),l_n-n_d_fmt-2))//'__'//cnt
+      nb_lastkey = nbve
+!-
+    ENDIF
+!-
+  ENDIF
+!---------------------------
+END SUBROUTINE getin_decrypt
+!-
+!===
+!-
+SUBROUTINE getin_checkcohe ()
+!---------------------------------------------------------------------
+!- This subroutine checks for redundancies.
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: line,n_k,k
+!---------------------------------------------------------------------
+  DO line=1,nb_lines-1
+!-
+    n_k = 0
+    DO k=line+1,nb_lines
+      IF (TRIM(targetlist(line)) == TRIM(targetlist(k))) THEN
+        n_k = k
+        EXIT
+      ENDIF
+    ENDDO
+!---
+!-- IF we have found it we have a problem to solve.
+!---
+    IF (n_k > 0) THEN
+      WRITE(*,*) 'COUNT : ',n_k
+      WRITE(*,*) &
+ &  'getin_checkcohe : Found a problem on key ',TRIM(targetlist(line))
+      WRITE(*,*) &
+ &  'getin_checkcohe : The following values were encoutered :'
+      WRITE(*,*) &
+ &  '                ',TRIM(targetlist(line)),' == ',fichier(line)
+      WRITE(*,*) &
+ &  '                ',TRIM(targetlist(k)),' == ',fichier(k)
+      WRITE(*,*) &
+ &  'getin_checkcohe : We will keep only the last value'
+      targetlist(line) = ' '
+    ENDIF
+  ENDDO
+!-----------------------------
+END SUBROUTINE getin_checkcohe
+!-
+!===
+!-
+SUBROUTINE getin_skipafew (unit,out_string,eof,nb_lastkey)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: unit,eof,nb_lastkey
+  CHARACTER(LEN=100) :: dummy
+  CHARACTER(LEN=100) :: out_string
+  CHARACTER(LEN=1) :: first
+!---------------------------------------------------------------------
+  first="#"
+  eof = 0
+  out_string = "    "
+!-
+  DO WHILE (first == "#")
+    READ (UNIT=unit,FMT='(A)',ERR=9998,END=7778) dummy
+    dummy = TRIM(ADJUSTL(dummy))
+    first=dummy(1:1)
+    IF (first == "#") THEN
+      nb_lastkey = 0
+    ENDIF
+  ENDDO
+  out_string=dummy
+!-
+  RETURN
+!-
+9998 CONTINUE
+  CALL ipslerr (3,'getin_skipafew','Error while reading file',' ',' ')
+!-
+7778 CONTINUE
+  eof = 1
+!----------------------------
+END SUBROUTINE getin_skipafew
+!-
+!===
+!-
+SUBROUTINE getin_allockeys ()
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  TYPE(t_key),ALLOCATABLE,DIMENSION(:) :: tmp_key_tab
+  CHARACTER(LEN=100),ALLOCATABLE :: tmp_str(:)
+!-
+  INTEGER :: ier
+  CHARACTER(LEN=20) :: c_tmp
+!---------------------------------------------------------------------
+  IF (keymemsize == 0) THEN
+!---
+!-- Nothing exists in memory arrays and it is easy to do.
+!---
+    WRITE (UNIT=c_tmp,FMT=*) memslabs
+    ALLOCATE(key_tab(memslabs),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_allockeys', &
+ &     'Can not allocate key_tab', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+    ENDIF
+    nb_keys = 0
+    keymemsize = memslabs
+    key_tab(:)%keycompress = -1
+!---
+  ELSE
+!---
+!-- There is something already in the memory,
+!-- we need to transfer and reallocate.
+!---
+    WRITE (UNIT=c_tmp,FMT=*) keymemsize
+    ALLOCATE(tmp_key_tab(keymemsize),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_allockeys', &
+ &     'Can not allocate tmp_key_tab', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+    ENDIF
+    WRITE (UNIT=c_tmp,FMT=*) keymemsize+memslabs
+    tmp_key_tab(1:keymemsize) = key_tab(1:keymemsize)
+    DEALLOCATE(key_tab)
+    ALLOCATE(key_tab(keymemsize+memslabs),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_allockeys', &
+ &     'Can not allocate key_tab', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+    ENDIF
+    key_tab(:)%keycompress = -1
+    key_tab(1:keymemsize) = tmp_key_tab(1:keymemsize)
+    DEALLOCATE(tmp_key_tab)
+    keymemsize = keymemsize+memslabs
+  ENDIF
+!-----------------------------
+END SUBROUTINE getin_allockeys
+!-
+!===
+!-
+SUBROUTINE getin_allocmem (type,len_wanted)
+!---------------------------------------------------------------------
+!- Allocate the memory of the data base for all 4 types of memory
+!- INTEGER / REAL / CHARACTER / LOGICAL
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: type,len_wanted
+!-
+  INTEGER,ALLOCATABLE :: tmp_int(:)
+  REAL,ALLOCATABLE :: tmp_real(:)
+  CHARACTER(LEN=100),ALLOCATABLE :: tmp_char(:)
+  LOGICAL,ALLOCATABLE :: tmp_logic(:)
+  INTEGER :: ier
+  CHARACTER(LEN=20) :: c_tmp
+!---------------------------------------------------------------------
+  SELECT CASE (type)
+  CASE(k_i)
+    IF (i_memsize == 0) THEN
+      ALLOCATE(i_mem(memslabs),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      i_memsize=memslabs
+    ELSE
+      ALLOCATE(tmp_int(i_memsize),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) i_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_int', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_int(1:i_memsize) = i_mem(1:i_memsize)
+      DEALLOCATE(i_mem)
+      ALLOCATE(i_mem(i_memsize+MAX(memslabs,len_wanted)),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) i_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'i_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      i_mem(1:i_memsize) = tmp_int(1:i_memsize)
+      i_memsize = i_memsize+MAX(memslabs,len_wanted)
+      DEALLOCATE(tmp_int)
+    ENDIF
+  CASE(k_r)
+    IF (r_memsize == 0) THEN
+      ALLOCATE(r_mem(memslabs),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      r_memsize =  memslabs
+    ELSE
+      ALLOCATE(tmp_real(r_memsize),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) r_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_real', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_real(1:r_memsize) = r_mem(1:r_memsize)
+      DEALLOCATE(r_mem)
+      ALLOCATE(r_mem(r_memsize+MAX(memslabs,len_wanted)),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) r_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'r_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      r_mem(1:r_memsize) = tmp_real(1:r_memsize)
+      r_memsize = r_memsize+MAX(memslabs,len_wanted)
+      DEALLOCATE(tmp_real)
+    ENDIF
+  CASE(k_c)
+    IF (c_memsize == 0) THEN
+      ALLOCATE(c_mem(memslabs),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      c_memsize = memslabs
+    ELSE
+      ALLOCATE(tmp_char(c_memsize),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) c_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_char', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_char(1:c_memsize) = c_mem(1:c_memsize)
+      DEALLOCATE(c_mem)
+      ALLOCATE(c_mem(c_memsize+MAX(memslabs,len_wanted)),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) c_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'c_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      c_mem(1:c_memsize) = tmp_char(1:c_memsize)
+      c_memsize = c_memsize+MAX(memslabs,len_wanted)
+      DEALLOCATE(tmp_char)
+    ENDIF
+  CASE(k_l)
+    IF (l_memsize == 0) THEN
+      ALLOCATE(l_mem(memslabs),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) memslabs
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate db-memory', &
+ &       'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      l_memsize = memslabs
+    ELSE
+      ALLOCATE(tmp_logic(l_memsize),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) l_memsize
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to allocate tmp_logic', &
+ &       'to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      tmp_logic(1:l_memsize) = l_mem(1:l_memsize)
+      DEALLOCATE(l_mem)
+      ALLOCATE(l_mem(l_memsize+MAX(memslabs,len_wanted)),stat=ier)
+      IF (ier /= 0) THEN
+        WRITE (UNIT=c_tmp,FMT=*) l_memsize+MAX(memslabs,len_wanted)
+        CALL ipslerr (3,'getin_allocmem', &
+ &       'Unable to re-allocate db-memory', &
+ &       'l_mem to size '//TRIM(ADJUSTL(c_tmp)),' ')
+      ENDIF
+      l_mem(1:l_memsize) = tmp_logic(1:l_memsize)
+      l_memsize = l_memsize+MAX(memslabs,len_wanted)
+      DEALLOCATE(tmp_logic)
+    ENDIF
+  CASE DEFAULT
+    CALL ipslerr (3,'getin_allocmem','Unknown type of data',' ',' ')
+  END SELECT
+!----------------------------
+END SUBROUTINE getin_allocmem
+!-
+!===
+!-
+SUBROUTINE getin_alloctxt ()
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=100),ALLOCATABLE :: tmp_fic(:)
+  CHARACTER(LEN=l_n),ALLOCATABLE :: tmp_tgl(:)
+  INTEGER,ALLOCATABLE :: tmp_int(:)
+!-
+  INTEGER :: ier
+  CHARACTER(LEN=20) :: c_tmp1,c_tmp2
+!---------------------------------------------------------------------
+  IF (i_txtsize == 0) THEN
+!---
+!-- Nothing exists in memory arrays and it is easy to do.
+!---
+    WRITE (UNIT=c_tmp1,FMT=*) i_txtslab
+    ALLOCATE(fichier(i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate fichier', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp1)),' ')
+    ENDIF
+!---
+    ALLOCATE(targetlist(i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate targetlist', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp1)),' ')
+    ENDIF
+!---
+    ALLOCATE(fromfile(i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate fromfile', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp1)),' ')
+    ENDIF
+!---
+    ALLOCATE(compline(i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate compline', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp1)),' ')
+    ENDIF
+!---
+    nb_lines = 0
+    i_txtsize = i_txtslab
+  ELSE
+!---
+!-- There is something already in the memory,
+!-- we need to transfer and reallocate.
+!---
+    WRITE (UNIT=c_tmp1,FMT=*) i_txtsize
+    WRITE (UNIT=c_tmp2,FMT=*) i_txtsize+i_txtslab
+    ALLOCATE(tmp_fic(i_txtsize),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate tmp_fic', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp1)),' ')
+    ENDIF
+    tmp_fic(1:i_txtsize) = fichier(1:i_txtsize)
+    DEALLOCATE(fichier)
+    ALLOCATE(fichier(i_txtsize+i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate fichier', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp2)),' ')
+    ENDIF
+    fichier(1:i_txtsize) = tmp_fic(1:i_txtsize)
+    DEALLOCATE(tmp_fic)
+!---
+    ALLOCATE(tmp_tgl(i_txtsize),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate tmp_tgl', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp1)),' ')
+    ENDIF
+    tmp_tgl(1:i_txtsize) = targetlist(1:i_txtsize)
+    DEALLOCATE(targetlist)
+    ALLOCATE(targetlist(i_txtsize+i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate targetlist', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp2)),' ')
+    ENDIF
+    targetlist(1:i_txtsize) = tmp_tgl(1:i_txtsize)
+    DEALLOCATE(tmp_tgl)
+!---
+    ALLOCATE(tmp_int(i_txtsize),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate tmp_int', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp1)),' ')
+    ENDIF
+    tmp_int(1:i_txtsize) = fromfile(1:i_txtsize)
+    DEALLOCATE(fromfile)
+    ALLOCATE(fromfile(i_txtsize+i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate fromfile', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp2)),' ')
+    ENDIF
+    fromfile(1:i_txtsize) = tmp_int(1:i_txtsize)
+!---
+    tmp_int(1:i_txtsize) = compline(1:i_txtsize)
+    DEALLOCATE(compline)
+    ALLOCATE(compline(i_txtsize+i_txtslab),stat=ier)
+    IF (ier /= 0) THEN
+      CALL ipslerr (3,'getin_alloctxt', &
+ &     'Can not allocate compline', &
+ &     'to size '//TRIM(ADJUSTL(c_tmp2)),' ')
+    ENDIF
+    compline(1:i_txtsize) = tmp_int(1:i_txtsize)
+    DEALLOCATE(tmp_int)
+!---
+    i_txtsize = i_txtsize+i_txtslab
+  ENDIF
+!----------------------------
+END SUBROUTINE getin_alloctxt
+!-
+!===
+!-
+SUBROUTINE getin_dump (fileprefix)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(*),OPTIONAL :: fileprefix
+!-
+  CHARACTER(LEN=80) :: usedfileprefix
+  INTEGER :: ikey,if,iff,iv
+  CHARACTER(LEN=20) :: c_tmp
+  CHARACTER(LEN=100) :: tmp_str,used_filename
+  LOGICAL :: check = .FALSE.
+!---------------------------------------------------------------------
+  IF (PRESENT(fileprefix)) THEN
+    usedfileprefix = fileprefix(1:MIN(LEN_TRIM(fileprefix),80))
+  ELSE
+    usedfileprefix = "used"
+  ENDIF
+!-
+  DO if=1,nbfiles
+!---
+    used_filename = TRIM(usedfileprefix)//'_'//TRIM(filelist(if))
+    IF (check) THEN
+      WRITE(*,*) &
+ &      'GETIN_DUMP : opens file : ',TRIM(used_filename),' if = ',if
+      WRITE(*,*) 'GETIN_DUMP : NUMBER OF KEYS : ',nb_keys
+    ENDIF
+    OPEN (UNIT=22,FILE=used_filename)
+!---
+!-- If this is the first file we need to add the list
+!-- of file which belong to it
+    IF ( (if == 1).AND.(nbfiles > 1) ) THEN
+      WRITE(22,*) '# '
+      WRITE(22,*) '# This file is linked to the following files :'
+      WRITE(22,*) '# '
+      DO iff=2,nbfiles
+        WRITE(22,*) 'INCLUDEDEF = ',TRIM(filelist(iff))
+      ENDDO
+      WRITE(22,*) '# '
+    ENDIF
+!---
+    DO ikey=1,nb_keys
+!-----
+!---- Is this key from this file ?
+      IF (key_tab(ikey)%keyfromfile == if) THEN
+!-------
+!------ Write some comments
+        WRITE(22,*) '#'
+        SELECT CASE (key_tab(ikey)%keystatus)
+        CASE(1)
+          WRITE(22,*) '# Values of ', &
+ &          TRIM(key_tab(ikey)%keystr),' comes from the run.def.'
+        CASE(2)
+          WRITE(22,*) '# Values of ', &
+ &          TRIM(key_tab(ikey)%keystr),' are all defaults.'
+        CASE(3)
+          WRITE(22,*) '# Values of ', &
+ &          TRIM(key_tab(ikey)%keystr), &
+ &          ' are a mix of run.def and defaults.'
+        CASE DEFAULT
+          WRITE(22,*) '# Dont know from where the value of ', &
+ &          TRIM(key_tab(ikey)%keystr),' comes.'
+        END SELECT
+        WRITE(22,*) '#'
+!-------
+!------ Write the values
+        SELECT CASE (key_tab(ikey)%keytype)
+        CASE(k_i)
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            IF (key_tab(ikey)%keycompress < 0) THEN
+              WRITE(22,*) &
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',i_mem(key_tab(ikey)%keymemstart)
+            ELSE
+              WRITE(22,*) &
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',key_tab(ikey)%keycompress, &
+ &              ' * ',i_mem(key_tab(ikey)%keymemstart)
+            ENDIF
+          ELSE
+            DO iv=0,key_tab(ikey)%keymemlen-1
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              WRITE(22,*) &
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              '__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',i_mem(key_tab(ikey)%keymemstart+iv)
+            ENDDO
+          ENDIF
+        CASE(k_r)
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            IF (key_tab(ikey)%keycompress < 0) THEN
+              WRITE(22,*) &
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',r_mem(key_tab(ikey)%keymemstart)
+            ELSE
+              WRITE(22,*) &
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',key_tab(ikey)%keycompress, &
+                   & ' * ',r_mem(key_tab(ikey)%keymemstart)
+            ENDIF
+          ELSE
+            DO iv=0,key_tab(ikey)%keymemlen-1
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              WRITE(22,*) &
+ &              TRIM(key_tab(ikey)%keystr),'__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',r_mem(key_tab(ikey)%keymemstart+iv)
+            ENDDO
+          ENDIF
+        CASE(k_c)
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            tmp_str = c_mem(key_tab(ikey)%keymemstart)
+            WRITE(22,*) TRIM(key_tab(ikey)%keystr), &
+ &              ' = ',TRIM(tmp_str)
+          ELSE
+            DO iv=0,key_tab(ikey)%keymemlen-1
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              tmp_str = c_mem(key_tab(ikey)%keymemstart+iv)
+              WRITE(22,*) &
+ &              TRIM(key_tab(ikey)%keystr), &
+ &              '__',TRIM(ADJUSTL(c_tmp)), &
+ &              ' = ',TRIM(tmp_str)
+            ENDDO
+          ENDIF
+        CASE(k_l)
+          IF (key_tab(ikey)%keymemlen == 1) THEN
+            IF (l_mem(key_tab(ikey)%keymemstart)) THEN
+              WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = TRUE '
+            ELSE
+              WRITE(22,*) TRIM(key_tab(ikey)%keystr),' = FALSE '
+            ENDIF
+          ELSE
+            DO iv=0,key_tab(ikey)%keymemlen-1
+              WRITE(UNIT=c_tmp,FMT=c_i_fmt) iv+1
+              IF (l_mem(key_tab(ikey)%keymemstart+iv)) THEN
+                WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', &
+ &                          TRIM(ADJUSTL(c_tmp)),' = TRUE '
+              ELSE
+                WRITE(22,*) TRIM(key_tab(ikey)%keystr),'__', &
+ &                          TRIM(ADJUSTL(c_tmp)),' = FALSE '
+              ENDIF
+            ENDDO
+          ENDIF
+        CASE DEFAULT
+          CALL ipslerr (3,'getin_dump', &
+ &         'Unknown type for variable '//TRIM(key_tab(ikey)%keystr), &
+ &         ' ',' ')
+        END SELECT
+      ENDIF
+    ENDDO
+!-
+    CLOSE(UNIT=22)
+!-
+  ENDDO
+!------------------------
+END SUBROUTINE getin_dump
+!===
+SUBROUTINE get_qtyp (k_typ,c_vtyp,i_v,r_v,c_v,l_v)
+!---------------------------------------------------------------------
+!- Returns the type of the argument (mutually exclusive)
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(OUT) :: k_typ
+  CHARACTER(LEN=*),INTENT(OUT) :: c_vtyp
+  INTEGER,DIMENSION(:),OPTIONAL          :: i_v
+  REAL,DIMENSION(:),OPTIONAL             :: r_v
+  LOGICAL,DIMENSION(:),OPTIONAL          :: l_v
+  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_v
+!---------------------------------------------------------------------
+  k_typ = 0
+  IF (COUNT((/PRESENT(i_v),PRESENT(r_v),PRESENT(c_v),PRESENT(l_v)/)) &
+ &    /= 1) THEN
+    CALL ipslerr (3,'get_qtyp', &
+ &   'Invalid number of optional arguments','(/= 1)',' ')
+  ENDIF
+!-
+  IF     (PRESENT(i_v)) THEN
+    k_typ = k_i
+    c_vtyp = 'INTEGER'
+  ELSEIF (PRESENT(r_v)) THEN
+    k_typ = k_r
+    c_vtyp = 'REAL'
+  ELSEIF (PRESENT(c_v)) THEN
+    k_typ = k_c
+    c_vtyp = 'CHARACTER'
+  ELSEIF (PRESENT(l_v)) THEN
+    k_typ = k_l
+    c_vtyp = 'LOGICAL'
+  ENDIF
+!----------------------
+END SUBROUTINE get_qtyp
+!===
+SUBROUTINE get_findkey (i_tab,c_key,pos)
+!---------------------------------------------------------------------
+!- This subroutine looks for a key in a table
+!---------------------------------------------------------------------
+!- INPUT
+!-   i_tab  : 1 -> search in key_tab(1:nb_keys)%keystr
+!-            2 -> search in targetlist(1:nb_lines)
+!-   c_key  : Name of the key we are looking for
+!- OUTPUT
+!-   pos    : -1 if key not found, else value in the table
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER,INTENT(in) :: i_tab
+  CHARACTER(LEN=*),INTENT(in) :: c_key
+  INTEGER,INTENT(out) :: pos
+!-
+  INTEGER :: ikey_max,ikey
+  CHARACTER(LEN=l_n) :: c_q_key
+!---------------------------------------------------------------------
+  pos = -1
+  IF     (i_tab == 1) THEN
+    ikey_max = nb_keys
+  ELSEIF (i_tab == 2) THEN
+    ikey_max = nb_lines
+  ELSE
+    ikey_max = 0
+  ENDIF
+  IF ( ikey_max > 0 ) THEN
+    DO ikey=1,ikey_max
+      IF (i_tab == 1) THEN
+        c_q_key = key_tab(ikey)%keystr
+      ELSE
+        c_q_key = targetlist(ikey)
+      ENDIF
+      IF (TRIM(c_q_key) == TRIM(c_key)) THEN
+        pos = ikey
+        EXIT
+      ENDIF
+    ENDDO
+  ENDIF
+!-------------------------
+END SUBROUTINE get_findkey
+!===
+!------------------
+END MODULE ioipsl_getincom
Index: /trunk/LMDZ.TITAN/libf/misc/ioipsl_stringop.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/ioipsl_stringop.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/ioipsl_stringop.F90	(revision 1644)
@@ -0,0 +1,243 @@
+!
+! $Id$
+!
+! Module/Routines extracted from IOIPSL v2_1_8
+!
+MODULE ioipsl_stringop
+!-
+!$Id: stringop.f90 386 2008-09-04 08:38:48Z bellier $
+!-
+! This software is governed by the CeCILL license
+! See IOIPSL/IOIPSL_License_CeCILL.txt
+!---------------------------------------------------------------------
+!-
+  INTEGER,DIMENSION(30) :: &
+ & prime=(/1,2,3,5,7,11,13,17,19,23,29,31,37,41,43, &
+ & 47,53,59,61,67,71,73,79,83,89,97,101,103,107,109/)
+!-
+!---------------------------------------------------------------------
+CONTAINS
+!=
+SUBROUTINE cmpblank (str)
+!---------------------------------------------------------------------
+!- Compact blanks
+!---------------------------------------------------------------------
+  CHARACTER(LEN=*),INTENT(inout) :: str
+!-
+  INTEGER :: lcc,ipb
+!---------------------------------------------------------------------
+  lcc = LEN_TRIM(str)
+  ipb = 1
+  DO
+    IF (ipb >= lcc)   EXIT
+    IF (str(ipb:ipb+1) == '  ') THEN
+      str(ipb+1:) = str(ipb+2:lcc)
+      lcc = lcc-1
+    ELSE
+      ipb = ipb+1
+    ENDIF
+  ENDDO
+!----------------------
+END SUBROUTINE cmpblank
+!===
+INTEGER FUNCTION cntpos (c_c,l_c,c_r,l_r)
+!---------------------------------------------------------------------
+!- Finds number of occurences of c_r in c_c
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*),INTENT(in) :: c_c
+  INTEGER,INTENT(IN) :: l_c
+  CHARACTER(LEN=*),INTENT(in) :: c_r
+  INTEGER,INTENT(IN) :: l_r
+!-
+  INTEGER :: ipos,indx
+!---------------------------------------------------------------------
+  cntpos = 0
+  ipos   = 1
+  DO
+    indx = INDEX(c_c(ipos:l_c),c_r(1:l_r))
+    IF (indx > 0) THEN
+      cntpos = cntpos+1
+      ipos   = ipos+indx+l_r-1
+    ELSE
+      EXIT
+    ENDIF
+  ENDDO
+!------------------
+END FUNCTION cntpos
+!===
+INTEGER FUNCTION findpos (c_c,l_c,c_r,l_r)
+!---------------------------------------------------------------------
+!- Finds position of c_r in c_c
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*),INTENT(in) :: c_c
+  INTEGER,INTENT(IN) :: l_c
+  CHARACTER(LEN=*),INTENT(in) :: c_r
+  INTEGER,INTENT(IN) :: l_r
+!---------------------------------------------------------------------
+  findpos = INDEX(c_c(1:l_c),c_r(1:l_r))
+  IF (findpos == 0)  findpos=-1
+!-------------------
+END FUNCTION findpos
+!===
+SUBROUTINE find_str (str_tab,str,pos)
+!---------------------------------------------------------------------
+!- This subroutine looks for a string in a table
+!---------------------------------------------------------------------
+!- INPUT
+!-   str_tab  : Table  of strings
+!-   str      : Target we are looking for
+!- OUTPUT
+!-   pos      : -1 if str not found, else value in the table
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*),DIMENSION(:),INTENT(in) :: str_tab
+  CHARACTER(LEN=*),INTENT(in) :: str
+  INTEGER,INTENT(out) :: pos
+!-
+  INTEGER :: nb_str,i
+!---------------------------------------------------------------------
+  pos = -1
+  nb_str=SIZE(str_tab)
+  IF ( nb_str > 0 ) THEN
+    DO i=1,nb_str
+      IF ( TRIM(str_tab(i)) == TRIM(str) ) THEN
+        pos = i
+        EXIT
+      ENDIF
+    ENDDO
+  ENDIF
+!----------------------
+END SUBROUTINE find_str
+!===
+SUBROUTINE nocomma (str)
+!---------------------------------------------------------------------
+!- Replace commas with blanks
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: str
+!-
+  INTEGER :: i
+!---------------------------------------------------------------------
+  DO i=1,LEN_TRIM(str)
+    IF (str(i:i) == ',')   str(i:i) = ' '
+  ENDDO
+!---------------------
+END SUBROUTINE nocomma
+!===
+SUBROUTINE strlowercase (str)
+!---------------------------------------------------------------------
+!- Converts a string into lowercase
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: str
+!-
+  INTEGER :: i,ic
+!---------------------------------------------------------------------
+  DO i=1,LEN_TRIM(str)
+    ic = IACHAR(str(i:i))
+    IF ( (ic >= 65).AND.(ic <= 90) )  str(i:i) = ACHAR(ic+32)
+  ENDDO
+!--------------------------
+END SUBROUTINE strlowercase
+!===
+SUBROUTINE struppercase (str)
+!---------------------------------------------------------------------
+!- Converts a string into uppercase
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: str
+!-
+  INTEGER :: i,ic
+!---------------------------------------------------------------------
+  DO i=1,LEN_TRIM(str)
+    ic = IACHAR(str(i:i))
+    IF ( (ic >= 97).AND.(ic <= 122) )  str(i:i) = ACHAR(ic-32)
+  ENDDO
+!--------------------------
+END SUBROUTINE struppercase
+!===
+SUBROUTINE gensig (str,sig)
+!---------------------------------------------------------------------
+!- Generate a signature from the first 30 characters of the string
+!- This signature is not unique and thus when one looks for the
+!- one needs to also verify the string.
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  CHARACTER(LEN=*) :: str
+  INTEGER          :: sig
+!-
+  INTEGER :: i
+!---------------------------------------------------------------------
+  sig = 0
+  DO i=1,MIN(LEN_TRIM(str),30)
+    sig = sig + prime(i)*IACHAR(str(i:i))
+  ENDDO
+!--------------------
+END SUBROUTINE gensig
+!===
+SUBROUTINE find_sig (nb_sig,str_tab,str,sig_tab,sig,pos)
+!---------------------------------------------------------------------
+!- Find the string signature in a list of signatures
+!---------------------------------------------------------------------
+!- INPUT
+!-   nb_sig      : length of table of signatures
+!-   str_tab     : Table of strings
+!-   str         : Target string we are looking for
+!-   sig_tab     : Table of signatures
+!-   sig         : Target signature we are looking for
+!- OUTPUT
+!-   pos         : -1 if str not found, else value in the table
+!---------------------------------------------------------------------
+  IMPLICIT NONE
+!-
+  INTEGER :: nb_sig
+  CHARACTER(LEN=*),DIMENSION(nb_sig) :: str_tab
+  CHARACTER(LEN=*) :: str
+  INTEGER,DIMENSION(nb_sig) :: sig_tab
+  INTEGER :: sig
+!-
+  INTEGER :: pos
+  INTEGER,DIMENSION(nb_sig) :: loczeros
+!-
+  INTEGER :: il,len
+  INTEGER,DIMENSION(1) :: minpos
+!---------------------------------------------------------------------
+  pos = -1
+  il = LEN_TRIM(str)
+!-
+  IF ( nb_sig > 0 ) THEN
+    loczeros = ABS(sig_tab(1:nb_sig)-sig)
+    IF ( COUNT(loczeros < 1) == 1 ) THEN
+      minpos = MINLOC(loczeros)
+      len = LEN_TRIM(str_tab(minpos(1)))
+      IF (     (INDEX(str_tab(minpos(1)),str(1:il)) > 0) &
+          .AND.(len == il) ) THEN
+        pos = minpos(1)
+      ENDIF
+    ELSE IF ( COUNT(loczeros < 1) > 1 ) THEN
+      DO WHILE (COUNT(loczeros < 1) >= 1 .AND. pos < 0 )
+        minpos = MINLOC(loczeros)
+        len = LEN_TRIM(str_tab(minpos(1)))
+        IF (     (INDEX(str_tab(minpos(1)),str(1:il)) > 0) &
+            .AND.(len == il) ) THEN
+          pos = minpos(1)
+        ELSE
+          loczeros(minpos(1)) = 99999
+        ENDIF
+      ENDDO
+    ENDIF
+  ENDIF
+!-----------------------
+ END SUBROUTINE find_sig
+!===
+!------------------
+END MODULE ioipsl_stringop
Index: /trunk/LMDZ.TITAN/libf/misc/isamax.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/isamax.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/isamax.F	(revision 1644)
@@ -0,0 +1,21 @@
+      function isamax(n,sx,incx)
+c
+      IMPLICIT NONE
+c
+      INTEGER n,i,incx,isamax,ix
+      real sx((n-1)*incx+1),sxmax,abssx
+c
+      ix=1
+      isamax=1
+      sxmax=ABS(sx(1))
+      do 10 i=1,n-1
+         ix=ix+incx
+         abssx=ABS(sx(ix))
+         if(abssx.gt.sxmax) then
+             sxmax=abssx
+             isamax=i+1
+         endif
+10    continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/isitor.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/isitor.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/isitor.F	(revision 1644)
@@ -0,0 +1,64 @@
+
+      SUBROUTINE isitor(filename,writeornot,filenum, files)
+
+C--------------------------------------------------------------------
+C Subroutine qui determine si un fichier doit etre ecrit ou non
+C--------------------------------------------------------------------
+C     ARGUMENTS
+C     +++++++++
+C     filename: CHARACTER*20 
+C               nom du fichier dont on veut savoir si il doit etre ecrit
+C     writeornot: LOGICAL
+C                 Variable de sortie qui est vraie si le champ doit etre ecrit
+C     filenum: INTEGER
+C              nombre de fichier dans la list files
+C     files: CHARACTER*20 files(100)
+C            c'est la liste des fichier qui doivent etre ecrit et dans
+C            lequel on vas voir si filename y est.
+C
+
+
+      IMPLICIT NONE
+      CHARACTER*20 filename, checkname
+      CHARACTER*1 separator
+      LOGICAL writeornot, check
+      INTEGER iletter, ifile
+      INTEGER filenum
+      CHARACTER*20 files(100)
+
+      writeornot = .FALSE.
+      check = .FALSE.
+      separator = '/'
+
+      DO 6565 iletter = 20,1,-1
+
+        IF (filename(iletter:iletter) .EQ. separator) THEN
+
+          checkname = filename(iletter+1:20)
+    
+        ELSE
+        ENDIF
+ 6565 CONTINUE
+
+      IF (check) THEN
+        WRITE(*,*) 'ISITORNOT:: filename=',filename,
+     &             'checkname=',checkname
+      ENDIF
+
+      DO 6767 ifile = 1,filenum
+
+      IF (files(ifile) .EQ. checkname ) THEN
+       
+      writeornot = .TRUE. 
+
+      ENDIF
+
+      IF (check) THEN
+        WRITE(*,*) 'ISITORNOT:: writeornot=',writeornot
+      ENDIF
+
+ 6767 CONTINUE
+
+      RETURN
+      END
+
Index: /trunk/LMDZ.TITAN/libf/misc/ismax.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/ismax.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/ismax.F	(revision 1644)
@@ -0,0 +1,20 @@
+      function ismax(n,sx,incx)
+c
+      IMPLICIT NONE
+c
+      INTEGER n,i,incx,ismax,ix
+      real sx((n-1)*incx+1),sxmax
+c
+      ix=1
+      ismax=1
+      sxmax=sx(1)
+      do 10 i=1,n-1
+      ix=ix+incx
+      if(sx(ix).gt.sxmax) then
+      sxmax=sx(ix)
+      ismax=i+1
+         endif
+10    continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/ismin.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/ismin.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/ismin.F	(revision 1644)
@@ -0,0 +1,20 @@
+      FUNCTION ismin(n,sx,incx)
+c
+      IMPLICIT NONE
+c
+      integer n,i,incx,ismin,ix
+      real sx((n-1)*incx+1),sxmin
+c
+      ix=1
+      ismin=1
+      sxmin=sx(1)
+      DO i=1,n-1
+	 ix=ix+incx
+	 if(sx(ix).lt.sxmin) then
+	     sxmin=sx(ix)
+	     ismin=i+1
+         endif
+      ENDDO
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/mxm.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/mxm.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/mxm.F	(revision 1644)
@@ -0,0 +1,34 @@
+       SUBROUTINE MXM(A,NAR,B,NAC,C,NBC)
+c
+c
+c    Multiplication of matrix A by matrix B ,and result in matrix C
+c
+c
+c      NAR : number of   rows  for matrix  A and  matrix  C
+c      NAC : number of columns for matrix  A and number of rows
+c                              for matrix  B
+c      NBC : number of columns for matrix  B and  matrix  C
+c
+c
+       IMPLICIT NONE
+c
+       INTEGER  NAR,NAC,NBC, I,J,K
+       REAL     A(NAR,NAC), B(NAC,NBC), C(NAR,NBC)
+c
+       DO 10 J = 1,NBC
+       DO 10 I = 1,NAR
+       C(I,J)=0.
+10     CONTINUE
+c
+       DO 50 J = 1,NBC
+       DO 40 I = 1,NAR
+
+       DO 20 K = 1,NAC
+       C(I,J)  = C(I,J) + A(I,K) * B(K,J)
+20     CONTINUE
+
+40     CONTINUE
+50     CONTINUE
+
+       RETURN
+       END
Index: /trunk/LMDZ.TITAN/libf/misc/mxv.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/mxv.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/mxv.F	(revision 1644)
@@ -0,0 +1,20 @@
+      SUBROUTINE MXV(A,NRA,B,NCA,C)
+      IMPLICIT NONE
+
+      INTEGER NRA,NCA
+      REAL A(NRA,NCA), B(NCA), C(NRA)
+
+      INTEGER I,J
+
+c     initialize product
+      DO 100 I = 1, NRA
+         C(I) = 0.
+100   CONTINUE
+c     multiply matrix A and vector B
+      DO 220 J = 1, NCA
+         DO 210 I = 1, NRA
+            C(I) = C(I) + A(I,J)*B(J)
+210     CONTINUE
+220   CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/misc/mxva.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/mxva.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/mxva.F	(revision 1644)
@@ -0,0 +1,25 @@
+      SUBROUTINE MXVA (SA,IAC,IAR,SB,IB,SC,IC,NRA,NCA)
+      IMPLICIT NONE
+
+      INTEGER IAC,IAR,IB,IC,NRA,NCA
+      REAL SA(*), SB(*), SC(*)
+
+      INTEGER I,J
+
+c     initialize product
+      DO 100 I = 1, NRA
+       SC( 1 + (I-1)*IC ) = 0.
+c      ( C(i) := 0. )
+100   CONTINUE
+c     multiply matrix from sa and vector from sb
+      DO 220 J = 1, NCA
+        DO 210 I = 1, NRA
+          SC( 1 + (I-1)*IC )
+     &      = SC( 1 + (I-1)*IC )
+     &        + SA( 1 + (I-1)*IAC + (J-1)*IAR )
+     &          * SB( 1 + (J-1)*IB )
+c         ( C(i) := C(i) + A(i,j)*B(j) )
+210      CONTINUE
+220   CONTINUE
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/misc/nrtype.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/nrtype.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/nrtype.F90	(revision 1644)
@@ -0,0 +1,22 @@
+MODULE nrtype
+
+  implicit none
+
+  integer, parameter:: k8 = selected_real_kind(13)
+
+  ! Frequently used mathematical constants (with precision to spare):
+
+  REAL, PARAMETER :: PI=3.141592653589793238462643383279502884197
+  REAL, PARAMETER :: PIO2=1.57079632679489661923132169163975144209858
+  REAL, PARAMETER :: TWOPI=6.283185307179586476925286766559005768394
+  REAL, PARAMETER :: SQRT2=1.41421356237309504880168872420969807856967
+  REAL, PARAMETER :: EULER=0.5772156649015328606065120900824024310422
+
+  REAL(K8), PARAMETER:: &
+       PI_D = 3.141592653589793238462643383279502884197_k8
+  REAL(K8), PARAMETER:: &
+       PIO2_D=1.57079632679489661923132169163975144209858_k8
+  REAL(K8), PARAMETER:: &
+       TWOPI_D=6.283185307179586476925286766559005768394_k8
+
+END MODULE nrtype
Index: /trunk/LMDZ.TITAN/libf/misc/scopy.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/scopy.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/scopy.F	(revision 1644)
@@ -0,0 +1,17 @@
+      subroutine scopy(n,sx,incx,sy,incy)
+c
+      IMPLICIT NONE
+c
+      integer n,incx,incy,ix,iy,i
+      real sx((n-1)*incx+1),sy((n-1)*incy+1)
+c
+      iy=1
+      ix=1
+      do 10 i=1,n
+         sy(iy)=sx(ix)
+         ix=ix+incx
+         iy=iy+incy
+10    continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/scopyi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/scopyi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/scopyi.F	(revision 1644)
@@ -0,0 +1,17 @@
+      subroutine scopyi(n,sx,incx,sy,incy)
+c
+      IMPLICIT NONE
+c
+      integer n,incx,incy,ix,iy,i
+      integer sx((n-1)*incx+1),sy((n-1)*incy+1)
+c
+      iy=1
+      ix=1
+      do 10 i=1,n
+      sy(iy)=sx(ix)
+         ix=ix+incx
+         iy=iy+incy
+10    continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/sdot.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/sdot.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/sdot.F	(revision 1644)
@@ -0,0 +1,21 @@
+      FUNCTION sdot (n, x,incx, y,incy)
+      IMPLICIT NONE
+c
+      integer n, incx, incy
+      real sdot
+      real x((n-1)*incx+1), y((n-1)*incy+1)
+c
+      integer i, ix, iy
+c
+      sdot = 0.0
+      ix = 1
+      iy = 1
+c
+      do 10 i = 1, n
+         sdot = sdot + x(ix) * y(iy)
+         ix = ix + incx
+         iy = iy + incy
+   10 continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/ssum.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/ssum.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/ssum.F	(revision 1644)
@@ -0,0 +1,16 @@
+      function ssum(n,sx,incx)
+c
+      IMPLICIT NONE
+c
+      integer n,incx,i,ix
+      real ssum,sx((n-1)*incx+1)
+c
+      ssum=0.
+      ix=1
+      do 10 i=1,n
+      ssum=ssum+sx(ix)
+         ix=ix+incx
+10    continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/misc/wheneq.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/misc/wheneq.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/misc/wheneq.F	(revision 1644)
@@ -0,0 +1,23 @@
+      SUBROUTINE wheneq(n,x,incx,target,index,nn)
+      IMPLICIT NONE
+c
+      integer n, incx, nn
+      integer index(n)
+c
+      integer target, x((n-1)*incx+1)
+cccccc      real target, x((n-1)*incx+1)
+c
+      integer i, ix
+c
+      ix = 1
+      nn = 0
+      do 10 i = 1, n
+         if (x(ix).EQ.target) then
+            index(i) = ix
+            nn = nn + 1
+         endif
+         ix = ix + incx
+   10 continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phy_common/geometry_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/geometry_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/geometry_mod.F90	(revision 1644)
@@ -0,0 +1,74 @@
+MODULE geometry_mod
+
+! Store informations concerning the local (to MPI/OpenMP core) geometry
+
+  REAL,SAVE,ALLOCATABLE :: longitude(:) ! longitude of the cell (rad)
+!$OMP THREADPRIVATE(longitude)
+
+  REAL,SAVE,ALLOCATABLE :: latitude(:)! latitude of the cell (rad)
+!$OMP THREADPRIVATE(latitude)
+
+  REAL,SAVE,ALLOCATABLE :: longitude_deg(:) ! longitude of the cell (degree)
+!$OMP THREADPRIVATE(longitude_deg)
+
+  REAL,SAVE,ALLOCATABLE :: latitude_deg(:)! latitude of the cell (degree)
+!$OMP THREADPRIVATE(latitude_deg)
+
+  REAL,SAVE,ALLOCATABLE :: boundslon(:,:)  ! boundaries of the cell (rad)
+!$OMP THREADPRIVATE(boundslon)
+
+  REAL,SAVE,ALLOCATABLE :: boundslat(:,:) ! boundaries of the cell (rad)
+!$OMP THREADPRIVATE(boundslat)
+
+  REAL,SAVE,ALLOCATABLE :: dx(:)      ! resolution of longitude cell (valid only for 2D grid)
+!$OMP THREADPRIVATE(dx)
+  
+  REAL,SAVE,ALLOCATABLE :: dy(:)      ! resolution of latitude cell (valid only for 2D grid)
+!$OMP THREADPRIVATE(dy)
+
+  REAL,SAVE,ALLOCATABLE :: cell_area(:)      ! area of the cell
+!$OMP THREADPRIVATE(cell_area)
+
+
+CONTAINS
+
+  SUBROUTINE init_geometry(klon,longitude_,latitude_, &
+                           boundslon_,boundslat_, &
+                           cell_area_,dx_,dy_)
+  USE mod_grid_phy_lmdz, ONLY: nvertex
+  USE nrtype, ONLY : PI
+  IMPLICIT NONE
+    INTEGER,INTENT(IN) :: klon ! number of columns for this MPI/OpenMP domain
+    REAL,INTENT(IN) :: longitude_(klon)
+    REAL,INTENT(IN) :: latitude_(klon)
+    REAL,INTENT(IN) :: boundslon_(klon,nvertex)
+    REAL,INTENT(IN) :: boundslat_(klon,nvertex)
+    REAL,INTENT(IN) :: cell_area_(klon)
+    REAL,OPTIONAL,INTENT(IN) :: dx_(klon)
+    REAL,OPTIONAL,INTENT(IN) :: dy_(klon)
+    
+    ALLOCATE(longitude(klon))
+    ALLOCATE(latitude(klon))
+    ALLOCATE(longitude_deg(klon))
+    ALLOCATE(latitude_deg(klon))
+    ALLOCATE(boundslon(klon,nvertex))
+    ALLOCATE(boundslat(klon,nvertex))
+    ALLOCATE(cell_area(klon))
+    IF (PRESENT(dx_)) ALLOCATE(dx(klon))
+    IF (PRESENT(dy_))ALLOCATE(dy(klon))
+    
+    longitude(:) = longitude_(:)
+    latitude(:) = latitude_(:)
+    longitude_deg(:) = longitude(:)*180./PI
+    latitude_deg(:) = latitude(:)*180./PI
+    boundslon(:,:) = boundslon_(:,:)
+    boundslat(:,:) = boundslat_(:,:)
+    cell_area(:) = cell_area_(:)
+    IF (PRESENT(dx_)) dx(:) = dx_(:)
+    IF (PRESENT(dy_)) dy(:) = dy_(:)
+    
+  END SUBROUTINE init_geometry
+
+
+END MODULE geometry_mod
+
Index: /trunk/LMDZ.TITAN/libf/phy_common/ioipsl_getin_p_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/ioipsl_getin_p_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/ioipsl_getin_p_mod.F90	(revision 1644)
@@ -0,0 +1,169 @@
+!
+! $Id$
+!
+MODULE ioipsl_getin_p_mod
+! To use getin in a parallel context
+!---------------------------------------------------------------------
+#ifdef CPP_IOIPSL
+USE ioipsl, ONLY: getin
+#else
+USE ioipsl_getincom, ONLY: getin
+#endif
+USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+USE mod_phys_lmdz_omp_data, ONLY :  is_omp_root
+USE mod_phys_lmdz_transfert_para, ONLY : bcast
+!-
+IMPLICIT NONE
+!-
+PRIVATE
+PUBLIC :: getin_p
+!-
+INTERFACE getin_p
+
+  MODULE PROCEDURE getinrs_p, getinr1d_p, getinr2d_p, &
+ &                 getinis_p, getini1d_p, getini2d_p, &
+ &                 getincs_p, 		              &
+ &                 getinls_p, getinl1d_p, getinl2d_p
+END INTERFACE
+!-
+CONTAINS
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!   Definition des getin -> bcast      !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!! -- Les chaines de caracteres -- !!
+  
+  SUBROUTINE getincs_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    CHARACTER(LEN=*),INTENT(INOUT) :: VarOut    
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getincs_p
+
+!! -- Les entiers -- !!
+  
+  SUBROUTINE getinis_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    INTEGER,INTENT(INOUT) :: VarOut    
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getinis_p
+
+  SUBROUTINE getini1d_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    INTEGER,INTENT(INOUT) :: VarOut(:)
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getini1d_p
+
+  SUBROUTINE getini2d_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    INTEGER,INTENT(INOUT) :: VarOut(:,:)
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getini2d_p
+
+!! -- Les flottants -- !!
+  
+  SUBROUTINE getinrs_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    REAL,INTENT(INOUT) :: VarOut
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getinrs_p
+
+  SUBROUTINE getinr1d_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    REAL,INTENT(INOUT) :: VarOut(:)
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getinr1d_p
+
+  SUBROUTINE getinr2d_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    REAL,INTENT(INOUT) :: VarOut(:,:)
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getinr2d_p
+
+!! -- Les Booleens -- !!
+  
+  SUBROUTINE getinls_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    LOGICAL,INTENT(INOUT) :: VarOut
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getinls_p
+
+  SUBROUTINE getinl1d_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    LOGICAL,INTENT(INOUT) :: VarOut(:)
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getinl1d_p
+
+  SUBROUTINE getinl2d_p(VarIn,VarOut)
+    IMPLICIT NONE    
+    CHARACTER(LEN=*),INTENT(IN) :: VarIn
+    LOGICAL,INTENT(INOUT) :: VarOut(:,:)
+
+!$OMP BARRIER
+    IF (is_mpi_root .AND. is_omp_root) THEN
+    	CALL getin(VarIn,VarOut)
+    ENDIF
+    CALL bcast(VarOut)
+  END SUBROUTINE getinl2d_p
+!-
+!-----------------------------
+!-----------------------------
+!-----------------------------
+
+END MODULE ioipsl_getin_p_mod
+
Index: /trunk/LMDZ.TITAN/libf/phy_common/mod_grid_phy_lmdz.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/mod_grid_phy_lmdz.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/mod_grid_phy_lmdz.F90	(revision 1644)
@@ -0,0 +1,468 @@
+!
+!$Id $
+!
+MODULE mod_grid_phy_lmdz
+
+  PUBLIC
+  PRIVATE :: grid1dTo2d_glo_igen, grid1dTo2d_glo_rgen, grid1dTo2d_glo_lgen, &
+             grid2dTo1d_glo_igen, grid2dTo1d_glo_rgen, grid2dTo1d_glo_lgen
+  
+  INTEGER,PARAMETER :: unstructured=0
+  INTEGER,PARAMETER :: regular_lonlat=1
+
+  INTEGER,SAVE :: grid_type
+  INTEGER,SAVE :: nvertex
+  INTEGER,SAVE :: nbp_lon  ! == iim
+  INTEGER,SAVE :: nbp_lat  ! == jjmp1 (or == 1 if running 1D model)
+  INTEGER,SAVE :: nbp_lev  ! == llm
+  INTEGER,SAVE :: klon_glo ! total number of atmospheric columns
+
+  INTERFACE grid1dTo2d_glo
+    MODULE PROCEDURE grid1dTo2d_glo_i,grid1dTo2d_glo_i1,grid1dTo2d_glo_i2,grid1dTo2d_glo_i3, &
+                     grid1dTo2d_glo_r,grid1dTo2d_glo_r1,grid1dTo2d_glo_r2,grid1dTo2d_glo_r3, &
+		     grid1dTo2d_glo_l,grid1dTo2d_glo_l1,grid1dTo2d_glo_l2,grid1dTo2d_glo_l3
+   END INTERFACE 
+
+   INTERFACE grid2dTo1d_glo
+    MODULE PROCEDURE grid2dTo1d_glo_i,grid2dTo1d_glo_i1,grid2dTo1d_glo_i2,grid2dTo1d_glo_i3, &
+                     grid2dTo1d_glo_r,grid2dTo1d_glo_r1,grid2dTo1d_glo_r2,grid2dTo1d_glo_r3, &
+		     grid2dTo1d_glo_l,grid2dTo1d_glo_l1,grid2dTo1d_glo_l2,grid2dTo1d_glo_l3
+   END INTERFACE 
+ 
+CONTAINS
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! SUBROUTINE grid1dTo2d  !!  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+  SUBROUTINE init_grid_phy_lmdz(grid_type_,nvertex_,nbp_lon_,nbp_lat_,nbp_lev_)
+  IMPLICIT NONE
+  INTEGER,INTENT(IN)  :: grid_type_ 
+  INTEGER,INTENT(IN)  :: nvertex_ 
+  INTEGER, INTENT(IN) :: nbp_lon_
+  INTEGER, INTENT(IN) :: nbp_lat_
+  INTEGER, INTENT(IN) :: nbp_lev_
+  
+    grid_type = grid_type_
+    nvertex   = nvertex_
+    nbp_lon   = nbp_lon_
+    nbp_lat   = nbp_lat_
+    nbp_lev   = nbp_lev_
+    
+    IF (nbp_lon*nbp_lat==1) THEN
+      klon_glo=1
+    ELSE    
+      klon_glo=(nbp_lon*nbp_lat)-2*(nbp_lon-1)
+    ENDIF
+  
+  END SUBROUTINE init_grid_phy_lmdz
+  
+  
+  SUBROUTINE grid1dTo2d_glo_i(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_glo_i
+  
+
+  SUBROUTINE grid1dTo2d_glo_i1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_igen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_glo_i1
+
+  SUBROUTINE grid1dTo2d_glo_i2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_glo_i2
+  
+  SUBROUTINE grid1dTo2d_glo_i3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_glo_i3
+
+
+  SUBROUTINE grid1dTo2d_glo_r(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_glo_r
+  
+
+  SUBROUTINE grid1dTo2d_glo_r1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_glo_r1
+
+  SUBROUTINE grid1dTo2d_glo_r2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_glo_r2
+  
+  SUBROUTINE grid1dTo2d_glo_r3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_glo_r3
+  
+  
+  
+  SUBROUTINE grid1dTo2d_glo_l(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_glo_l
+  
+
+  SUBROUTINE grid1dTo2d_glo_l1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_glo_l1
+
+  SUBROUTINE grid1dTo2d_glo_l2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_glo_l2
+  
+  SUBROUTINE grid1dTo2d_glo_l3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_glo_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_glo_l3  
+  
+    SUBROUTINE grid2dTo1d_glo_i(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_glo_i
+  
+
+  SUBROUTINE grid2dTo1d_glo_i1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_igen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_glo_i1
+
+  SUBROUTINE grid2dTo1d_glo_i2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_glo_i2
+  
+  SUBROUTINE grid2dTo1d_glo_i3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_glo_i3
+ 
+
+
+
+  SUBROUTINE grid2dTo1d_glo_r(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_glo_r
+  
+
+  SUBROUTINE grid2dTo1d_glo_r1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_glo_r1
+
+  SUBROUTINE grid2dTo1d_glo_r2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_glo_r2
+  
+  SUBROUTINE grid2dTo1d_glo_r3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_glo_r3
+
+
+
+  SUBROUTINE grid2dTo1d_glo_l(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_glo_l
+  
+
+  SUBROUTINE grid2dTo1d_glo_l1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_glo_l1
+
+  SUBROUTINE grid2dTo1d_glo_l2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_glo_l2
+  
+  SUBROUTINE grid2dTo1d_glo_l3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_glo_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_glo_l3
+
+!---------------------------------------------------------------- 
+!  Generic (private) fonctions
+!---------------------------------------------------------------- 
+  
+  SUBROUTINE grid1dTo2d_glo_igen(VarIn,VarOut,dimsize)
+
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    
+    Offset=nbp_lon
+        
+    DO i=1,dimsize
+      DO ij=1,klon_glo
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    DO i=1,dimsize
+      DO ij=1,nbp_lon
+       VarOut(ij,i)=VarIn(1,i)
+      ENDDO
+    ENDDO
+    
+    
+    DO i=1,dimsize
+      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
+       VarOut(ij,i)=VarIn(klon_glo,i)
+      ENDDO
+    ENDDO
+
+  END SUBROUTINE grid1dTo2d_glo_igen   
+
+
+  SUBROUTINE grid1dTo2d_glo_rgen(VarIn,VarOut,dimsize)
+
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
+    REAL,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+   
+    Offset=nbp_lon
+        
+    DO i=1,dimsize
+      DO ij=1,klon_glo
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    DO i=1,dimsize
+      DO ij=1,nbp_lon
+       VarOut(ij,i)=VarIn(1,i)
+      ENDDO
+    ENDDO
+    
+    
+    DO i=1,dimsize
+      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
+       VarOut(ij,i)=VarIn(klon_glo,i)
+      ENDDO
+    ENDDO
+
+  END SUBROUTINE grid1dTo2d_glo_rgen   
+
+  SUBROUTINE grid1dTo2d_glo_lgen(VarIn,VarOut,dimsize)
+
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN) ,DIMENSION(klon_glo,dimsize)       :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(nbp_lon*nbp_lat,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    Offset=nbp_lon
+        
+    DO i=1,dimsize
+      DO ij=1,klon_glo
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    DO i=1,dimsize
+      DO ij=1,nbp_lon
+       VarOut(ij,i)=VarIn(1,i)
+      ENDDO
+    ENDDO
+    
+    
+    DO i=1,dimsize
+      DO ij=nbp_lon*(nbp_lat-1)+1,nbp_lat*nbp_lon
+       VarOut(ij,i)=VarIn(klon_glo,i)
+      ENDDO
+    ENDDO
+
+  END SUBROUTINE grid1dTo2d_glo_lgen     
+  
+  
+  SUBROUTINE grid2dTo1d_glo_igen(VarIn,VarOut,dimsize)
+
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_glo
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    DO i=1,dimsize
+      VarOut(1,i)=VarIn(1,i)
+    ENDDO
+    
+  END SUBROUTINE grid2dTo1d_glo_igen   
+  
+  SUBROUTINE grid2dTo1d_glo_rgen(VarIn,VarOut,dimsize)
+
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_glo
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    DO i=1,dimsize
+      VarOut(1,i)=VarIn(1,i)
+    ENDDO
+    
+  END SUBROUTINE grid2dTo1d_glo_rgen 
+    
+  SUBROUTINE grid2dTo1d_glo_lgen(VarIn,VarOut,dimsize)
+
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN) ,DIMENSION(nbp_lon*nbp_lat,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_glo,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_glo
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    DO i=1,dimsize
+      VarOut(1,i)=VarIn(1,i)
+    ENDDO
+    
+  END SUBROUTINE grid2dTo1d_glo_lgen   
+
+END MODULE mod_grid_phy_lmdz
Index: /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_mpi_data.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_mpi_data.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_mpi_data.F90	(revision 1644)
@@ -0,0 +1,225 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_mpi_data
+!  USE mod_const_mpi
+  
+  INTEGER,SAVE :: ii_begin
+  INTEGER,SAVE :: ii_end
+  INTEGER,SAVE :: jj_begin
+  INTEGER,SAVE :: jj_end
+  INTEGER,SAVE :: jj_nb
+  INTEGER,SAVE :: ij_begin
+  INTEGER,SAVE :: ij_end
+  INTEGER,SAVE :: ij_nb
+  INTEGER,SAVE :: klon_mpi_begin
+  INTEGER,SAVE :: klon_mpi_end
+  INTEGER,SAVE :: klon_mpi
+  
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_nb
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: jj_para_end
+
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ii_para_end
+
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_nb
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: ij_para_end
+
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_nb
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_begin
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:) :: klon_mpi_para_end 
+
+  
+  INTEGER,SAVE :: mpi_rank
+  INTEGER,SAVE :: mpi_size
+  INTEGER,SAVE :: mpi_master
+!  INTEGER,SAVE :: mpi_root
+  LOGICAL,SAVE :: is_mpi_root
+  LOGICAL,SAVE :: is_using_mpi
+  
+  
+  LOGICAL,SAVE :: is_north_pole
+  LOGICAL,SAVE :: is_south_pole
+  INTEGER,SAVE :: COMM_LMDZ_PHY
+  INTEGER,SAVE :: MPI_REAL_LMDZ   ! MPI_REAL8
+
+CONTAINS
+  
+!  SUBROUTINE Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib)
+  SUBROUTINE init_phys_lmdz_mpi_data(nbp, nbp_lon, nbp_lat, communicator)
+!  USE mod_const_mpi, ONLY : COMM_LMDZ
+  IMPLICIT NONE
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER,INTENT(in) :: nbp
+    INTEGER,INTENT(in) :: nbp_lon
+    INTEGER,INTENT(in) :: nbp_lat
+    INTEGER,INTENT(in) :: communicator
+    
+    INTEGER,ALLOCATABLE :: distrib(:)
+    INTEGER :: ierr
+    INTEGER :: klon_glo
+    INTEGER :: i
+    
+#ifdef CPP_MPI
+    is_using_mpi=.TRUE.
+#else
+    is_using_mpi=.FALSE.
+#endif
+    
+    if ((nbp_lon.eq.1).and.(nbp_lat.eq.1)) then ! running 1D column model
+       klon_glo=1
+    else
+    ! The usual global physics grid: 1 point for each pole and nbp_lon points
+    ! for all other latitudes
+       klon_glo=nbp_lon*(nbp_lat-2)+2
+    endif
+    
+    COMM_LMDZ_PHY=communicator
+
+    IF (is_using_mpi) THEN    
+#ifdef CPP_MPI
+      MPI_REAL_LMDZ=MPI_REAL8
+      CALL MPI_COMM_SIZE(COMM_LMDZ_PHY,mpi_size,ierr)    
+      CALL MPI_COMM_RANK(COMM_LMDZ_PHY,mpi_rank,ierr)
+#endif
+    ELSE
+      mpi_size=1
+      mpi_rank=0
+    ENDIF
+    
+    ALLOCATE(distrib(0:mpi_size-1))
+
+    IF (is_using_mpi) THEN    
+#ifdef CPP_MPI
+    CALL MPI_ALLGATHER(nbp,1,MPI_INTEGER,distrib,1,MPI_INTEGER,COMM_LMDZ_PHY,ierr)
+#endif
+    ELSE
+     distrib(:)=nbp
+    ENDIF
+
+
+    IF (mpi_rank == 0) THEN
+      mpi_master = 0
+      is_mpi_root = .true.
+    ENDIF
+    
+    IF (mpi_rank == 0) THEN 
+      is_north_pole = .TRUE.
+    ELSE
+      is_north_pole = .FALSE.
+    ENDIF
+    
+    IF (mpi_rank == mpi_size-1) THEN
+      is_south_pole = .TRUE.
+    ELSE
+      is_south_pole = .FALSE.
+    ENDIF
+    
+    ALLOCATE(jj_para_nb(0:mpi_size-1))
+    ALLOCATE(jj_para_begin(0:mpi_size-1))
+    ALLOCATE(jj_para_end(0:mpi_size-1))
+    
+    ALLOCATE(ij_para_nb(0:mpi_size-1))
+    ALLOCATE(ij_para_begin(0:mpi_size-1))
+    ALLOCATE(ij_para_end(0:mpi_size-1))
+    
+    ALLOCATE(ii_para_begin(0:mpi_size-1))
+    ALLOCATE(ii_para_end(0:mpi_size-1))
+
+    ALLOCATE(klon_mpi_para_nb(0:mpi_size-1))
+    ALLOCATE(klon_mpi_para_begin(0:mpi_size-1))
+    ALLOCATE(klon_mpi_para_end(0:mpi_size-1))
+  
+      
+    klon_mpi_para_nb(0:mpi_size-1)=distrib(0:mpi_size-1)
+
+    DO i=0,mpi_size-1
+      IF (i==0) THEN 
+        klon_mpi_para_begin(i)=1
+      ELSE 
+        klon_mpi_para_begin(i)=klon_mpi_para_end(i-1)+1
+      ENDIF
+        klon_mpi_para_end(i)=klon_mpi_para_begin(i)+klon_mpi_para_nb(i)-1
+    ENDDO
+
+
+    DO i=0,mpi_size-1
+      
+      IF (i==0) THEN
+        ij_para_begin(i) = 1
+      ELSE
+        ij_para_begin(i) = klon_mpi_para_begin(i)+nbp_lon-1
+      ENDIF
+
+      jj_para_begin(i) = (ij_para_begin(i)-1)/nbp_lon + 1
+      ii_para_begin(i) = MOD(ij_para_begin(i)-1,nbp_lon) + 1
+
+      
+      ij_para_end(i) = klon_mpi_para_end(i)+nbp_lon-1
+      jj_para_end(i) = (ij_para_end(i)-1)/nbp_lon + 1
+      ii_para_end(i) = MOD(ij_para_end(i)-1,nbp_lon) + 1
+
+
+      ij_para_nb(i) = ij_para_end(i)-ij_para_begin(i)+1
+      jj_para_nb(i) = jj_para_end(i)-jj_para_begin(i)+1
+         
+    ENDDO
+  
+    ii_begin = ii_para_begin(mpi_rank)
+    ii_end   = ii_para_end(mpi_rank)
+    jj_begin = jj_para_begin(mpi_rank)
+    jj_end   = jj_para_end(mpi_rank)
+    jj_nb    = jj_para_nb(mpi_rank)
+    ij_begin = ij_para_begin(mpi_rank)
+    ij_end   = ij_para_end(mpi_rank)
+    ij_nb    = ij_para_nb(mpi_rank)
+    klon_mpi_begin = klon_mpi_para_begin(mpi_rank)
+    klon_mpi_end   = klon_mpi_para_end(mpi_rank)
+    klon_mpi       = klon_mpi_para_nb(mpi_rank)
+   
+    CALL Print_module_data
+    
+  END SUBROUTINE Init_phys_lmdz_mpi_data
+
+  SUBROUTINE print_module_data
+!  USE print_control_mod, ONLY: lunout
+  IMPLICIT NONE
+  INCLUDE "iniprint.h" 
+  
+    WRITE(lunout,*) 'ii_begin =', ii_begin
+    WRITE(lunout,*) 'ii_end =', ii_end
+    WRITE(lunout,*) 'jj_begin =',jj_begin
+    WRITE(lunout,*) 'jj_end =', jj_end
+    WRITE(lunout,*) 'jj_nb =', jj_nb
+    WRITE(lunout,*) 'ij_begin =', ij_begin
+    WRITE(lunout,*) 'ij_end =', ij_end
+    WRITE(lunout,*) 'ij_nb =', ij_nb
+    WRITE(lunout,*) 'klon_mpi_begin =', klon_mpi_begin
+    WRITE(lunout,*) 'klon_mpi_end =', klon_mpi_end
+    WRITE(lunout,*) 'klon_mpi =', klon_mpi
+    WRITE(lunout,*) 'jj_para_nb =', jj_para_nb
+    WRITE(lunout,*) 'jj_para_begin =', jj_para_begin
+    WRITE(lunout,*) 'jj_para_end =', jj_para_end
+    WRITE(lunout,*) 'ii_para_begin =', ii_para_begin
+    WRITE(lunout,*) 'ii_para_end =', ii_para_end
+    WRITE(lunout,*) 'ij_para_nb =', ij_para_nb
+    WRITE(lunout,*) 'ij_para_begin =', ij_para_begin
+    WRITE(lunout,*) 'ij_para_end =', ij_para_end
+    WRITE(lunout,*) 'klon_mpi_para_nb =', klon_mpi_para_nb
+    WRITE(lunout,*) 'klon_mpi_para_begin =', klon_mpi_para_begin
+    WRITE(lunout,*) 'klon_mpi_para_end  =', klon_mpi_para_end 
+    WRITE(lunout,*) 'mpi_rank =', mpi_rank
+    WRITE(lunout,*) 'mpi_size =', mpi_size
+    WRITE(lunout,*) 'mpi_master =', mpi_master
+    WRITE(lunout,*) 'is_mpi_root =', is_mpi_root
+    WRITE(lunout,*) 'is_north_pole =', is_north_pole
+    WRITE(lunout,*) 'is_south_pole =', is_south_pole
+    WRITE(lunout,*) 'COMM_LMDZ_PHY =', COMM_LMDZ_PHY
+  
+  END SUBROUTINE print_module_data
+  
+END MODULE mod_phys_lmdz_mpi_data
Index: /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_mpi_transfert.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_mpi_transfert.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_mpi_transfert.F90	(revision 1644)
@@ -0,0 +1,1903 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_mpi_transfert
+
+
+  INTERFACE bcast_mpi
+    MODULE PROCEDURE bcast_mpi_c,                                                     &
+                     bcast_mpi_i,bcast_mpi_i1,bcast_mpi_i2,bcast_mpi_i3,bcast_mpi_i4, &
+                     bcast_mpi_r,bcast_mpi_r1,bcast_mpi_r2,bcast_mpi_r3,bcast_mpi_r4, &
+                     bcast_mpi_l,bcast_mpi_l1,bcast_mpi_l2,bcast_mpi_l3,bcast_mpi_l4
+  END INTERFACE
+
+  INTERFACE scatter_mpi
+    MODULE PROCEDURE scatter_mpi_i,scatter_mpi_i1,scatter_mpi_i2,scatter_mpi_i3, &
+                     scatter_mpi_r,scatter_mpi_r1,scatter_mpi_r2,scatter_mpi_r3, &
+                     scatter_mpi_l,scatter_mpi_l1,scatter_mpi_l2,scatter_mpi_l3
+  END INTERFACE
+
+  
+  INTERFACE gather_mpi
+    MODULE PROCEDURE gather_mpi_i,gather_mpi_i1,gather_mpi_i2,gather_mpi_i3, &
+                     gather_mpi_r,gather_mpi_r1,gather_mpi_r2,gather_mpi_r3, &
+                     gather_mpi_l,gather_mpi_l1,gather_mpi_l2,gather_mpi_l3  
+  END INTERFACE
+  
+  INTERFACE scatter2D_mpi
+    MODULE PROCEDURE scatter2D_mpi_i,scatter2D_mpi_i1,scatter2D_mpi_i2,scatter2D_mpi_i3, &
+                     scatter2D_mpi_r,scatter2D_mpi_r1,scatter2D_mpi_r2,scatter2D_mpi_r3, &
+                     scatter2D_mpi_l,scatter2D_mpi_l1,scatter2D_mpi_l2,scatter2D_mpi_l3
+  END INTERFACE
+
+  INTERFACE gather2D_mpi
+    MODULE PROCEDURE gather2D_mpi_i,gather2D_mpi_i1,gather2D_mpi_i2,gather2D_mpi_i3, &
+                     gather2D_mpi_r,gather2D_mpi_r1,gather2D_mpi_r2,gather2D_mpi_r3, &
+                     gather2D_mpi_l,gather2D_mpi_l1,gather2D_mpi_l2,gather2D_mpi_l3
+  END INTERFACE 
+  
+  INTERFACE reduce_sum_mpi
+    MODULE PROCEDURE reduce_sum_mpi_i,reduce_sum_mpi_i1,reduce_sum_mpi_i2,reduce_sum_mpi_i3,reduce_sum_mpi_i4, &
+                     reduce_sum_mpi_r,reduce_sum_mpi_r1,reduce_sum_mpi_r2,reduce_sum_mpi_r3,reduce_sum_mpi_r4
+  END INTERFACE 
+
+ INTERFACE grid1dTo2d_mpi
+    MODULE PROCEDURE grid1dTo2d_mpi_i,grid1dTo2d_mpi_i1,grid1dTo2d_mpi_i2,grid1dTo2d_mpi_i3, &
+                     grid1dTo2d_mpi_r,grid1dTo2d_mpi_r1,grid1dTo2d_mpi_r2,grid1dTo2d_mpi_r3, &
+                     grid1dTo2d_mpi_l,grid1dTo2d_mpi_l1,grid1dTo2d_mpi_l2,grid1dTo2d_mpi_l3
+ END INTERFACE 
+
+ INTERFACE grid2dTo1d_mpi
+    MODULE PROCEDURE grid2dTo1d_mpi_i,grid2dTo1d_mpi_i1,grid2dTo1d_mpi_i2,grid2dTo1d_mpi_i3, &
+                     grid2dTo1d_mpi_r,grid2dTo1d_mpi_r1,grid2dTo1d_mpi_r2,grid2dTo1d_mpi_r3, &
+                     grid2dTo1d_mpi_l,grid2dTo1d_mpi_l1,grid2dTo1d_mpi_l2,grid2dTo1d_mpi_l3
+ END INTERFACE 
+    
+CONTAINS
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Broadcast --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!! -- Les chaine de charactère -- !!
+
+  SUBROUTINE bcast_mpi_c(var1)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var1
+   
+    CALL bcast_mpi_cgen(Var1,len(Var1))
+
+  END SUBROUTINE bcast_mpi_c
+
+!! -- Les entiers -- !!
+  
+  SUBROUTINE bcast_mpi_i(var)
+  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var
+    
+    INTEGER               :: var_tmp(1)
+    
+    IF (is_mpi_root) var_tmp(1)=var
+    CALL bcast_mpi_igen(Var_tmp,1)
+    var=var_tmp(1)
+    
+  END SUBROUTINE bcast_mpi_i
+
+  SUBROUTINE bcast_mpi_i1(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:)
+
+    CALL bcast_mpi_igen(Var,size(Var))
+    
+  END SUBROUTINE bcast_mpi_i1
+
+  SUBROUTINE bcast_mpi_i2(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:)
+   
+    CALL bcast_mpi_igen(Var,size(Var))
+  
+  END SUBROUTINE bcast_mpi_i2
+
+  SUBROUTINE bcast_mpi_i3(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:)
+   
+    CALL bcast_mpi_igen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_i3
+
+  SUBROUTINE bcast_mpi_i4(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL bcast_mpi_igen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_i4
+
+
+!! -- Les reels -- !!
+
+  SUBROUTINE bcast_mpi_r(var)
+  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var
+    REAL               :: var_tmp(1)
+    
+    IF (is_mpi_root) var_tmp(1)=var
+    CALL bcast_mpi_rgen(Var_tmp,1)
+    var=var_tmp(1)   
+
+  END SUBROUTINE bcast_mpi_r
+
+  SUBROUTINE bcast_mpi_r1(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r1
+
+  SUBROUTINE bcast_mpi_r2(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r2
+
+  SUBROUTINE bcast_mpi_r3(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r3
+
+  SUBROUTINE bcast_mpi_r4(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL bcast_mpi_rgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_r4
+  
+!! -- Les booleans -- !!
+
+  SUBROUTINE bcast_mpi_l(var)
+  USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var
+    LOGICAL               :: var_tmp(1)
+    
+    IF (is_mpi_root) var_tmp(1)=var
+    CALL bcast_mpi_lgen(Var_tmp,1)
+    var=var_tmp(1)   
+
+  END SUBROUTINE bcast_mpi_l
+
+  SUBROUTINE bcast_mpi_l1(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l1
+
+  SUBROUTINE bcast_mpi_l2(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l2
+
+  SUBROUTINE bcast_mpi_l3(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l3
+
+  SUBROUTINE bcast_mpi_l4(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL bcast_mpi_lgen(Var,size(Var))
+
+  END SUBROUTINE bcast_mpi_l4
+  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter_mpi_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL scatter_mpi_igen(VarIn,Varout,1)
+    
+  END SUBROUTINE scatter_mpi_i
+
+  SUBROUTINE scatter_mpi_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2))
+    
+  END SUBROUTINE scatter_mpi_i1
+  
+  SUBROUTINE scatter_mpi_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
+
+  END SUBROUTINE scatter_mpi_i2
+
+  SUBROUTINE scatter_mpi_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL scatter_mpi_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
+  
+  END SUBROUTINE scatter_mpi_i3
+
+
+  SUBROUTINE scatter_mpi_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,1)
+  
+  END SUBROUTINE scatter_mpi_r
+
+  SUBROUTINE scatter_mpi_r1(VarIn, VarOut)
+  USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+  IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2))
+  
+  END SUBROUTINE scatter_mpi_r1
+  
+  SUBROUTINE scatter_mpi_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
+  
+  END SUBROUTINE scatter_mpi_r2
+
+  SUBROUTINE scatter_mpi_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL scatter_mpi_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
+  
+  END SUBROUTINE scatter_mpi_r3
+
+
+  SUBROUTINE scatter_mpi_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,1)
+    
+  END SUBROUTINE scatter_mpi_l
+
+  SUBROUTINE scatter_mpi_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2))
+  
+  END SUBROUTINE scatter_mpi_l1
+  
+  SUBROUTINE scatter_mpi_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3))
+  
+  END SUBROUTINE scatter_mpi_l2
+
+  SUBROUTINE scatter_mpi_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL scatter_mpi_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4))
+  
+  END SUBROUTINE scatter_mpi_l3  
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ 
+!!!!! --> Les entiers
+
+  SUBROUTINE gather_mpi_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE gather_mpi_i
+  
+
+!!!!!
+
+  SUBROUTINE gather_mpi_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2))
+  
+  END SUBROUTINE gather_mpi_i1
+
+!!!!!
+  
+  SUBROUTINE gather_mpi_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
+  
+  END SUBROUTINE gather_mpi_i2
+
+!!!!!
+
+  SUBROUTINE gather_mpi_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL gather_mpi_igen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
+  
+  END SUBROUTINE gather_mpi_i3
+
+!!!!! --> Les reels
+
+  SUBROUTINE gather_mpi_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE gather_mpi_r
+
+!!!!!
+
+  SUBROUTINE gather_mpi_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2))
+  
+  END SUBROUTINE gather_mpi_r1
+
+!!!!!
+  
+  SUBROUTINE gather_mpi_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
+  
+  END SUBROUTINE gather_mpi_r2
+
+!!!!!
+
+  SUBROUTINE gather_mpi_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+      CALL gather_mpi_rgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
+  
+  END SUBROUTINE gather_mpi_r3
+
+!!!!! --> Les booleen
+
+  SUBROUTINE gather_mpi_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+      CALL gather_mpi_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE gather_mpi_l
+
+!!!!!
+
+  SUBROUTINE gather_mpi_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+      CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2))
+  
+  END SUBROUTINE gather_mpi_l1
+
+!!!!!
+  
+  SUBROUTINE gather_mpi_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+      CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3))
+  
+  END SUBROUTINE gather_mpi_l2
+
+!!!!!
+
+  SUBROUTINE gather_mpi_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL gather_mpi_lgen(VarIn,VarOut,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4))
+  
+  END SUBROUTINE gather_mpi_l3
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter2D_mpi_i(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo) :: Var_tmp    
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_i
+
+  SUBROUTINE scatter2D_mpi_i1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    INTEGER,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_i1
+
+  SUBROUTINE scatter2D_mpi_i2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_i2
+  
+  SUBROUTINE scatter2D_mpi_i3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    INTEGER,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter2D_mpi_i3
+
+
+
+  SUBROUTINE scatter2D_mpi_r(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    REAL,DIMENSION(klon_glo) :: Var_tmp    
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_R
+
+
+  SUBROUTINE scatter2D_mpi_r1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_r1
+
+
+  SUBROUTINE scatter2D_mpi_r2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_r2
+  
+  SUBROUTINE scatter2D_mpi_r3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+ 
+  END SUBROUTINE scatter2D_mpi_r3
+  
+  
+  SUBROUTINE scatter2D_mpi_l(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_glo) :: Var_tmp    
+    
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_l
+
+
+  SUBROUTINE scatter2D_mpi_l1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,2)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+  
+  END SUBROUTINE scatter2D_mpi_l1
+
+
+  SUBROUTINE scatter2D_mpi_l2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3)) :: Var_tmp
+  
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_mpi_l2
+  
+  SUBROUTINE scatter2D_mpi_l3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,2),size(VarOut,3),size(VarOut,4)) :: Var_tmp
+
+    CALL grid2dTo1d_glo(VarIn,Var_tmp)
+    CALL scatter_mpi(Var_tmp,VarOut)
+ 
+  END SUBROUTINE scatter2D_mpi_l3
+  
+  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE gather2D_mpi_i(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_glo) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i
+
+  SUBROUTINE gather2D_mpi_i1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i1
+
+  SUBROUTINE gather2D_mpi_i2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i2
+  
+  SUBROUTINE gather2D_mpi_i3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+ 
+    INTEGER,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_i3
+
+
+
+  SUBROUTINE gather2D_mpi_r(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r
+
+  SUBROUTINE gather2D_mpi_r1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r1
+
+  SUBROUTINE gather2D_mpi_r2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r2
+  
+  SUBROUTINE gather2D_mpi_r3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_r3
+
+  
+  
+  SUBROUTINE gather2D_mpi_l(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l
+
+  SUBROUTINE gather2D_mpi_l1(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,3)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l1
+
+  SUBROUTINE gather2D_mpi_l2(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4)) :: Var_tmp
+
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l2
+  
+  SUBROUTINE gather2D_mpi_l3(VarIn, VarOut)
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_glo,size(VarOut,3),SIZE(VarOut,4),SIZE(VarOut,5)) :: Var_tmp
+    
+    CALL gather_mpi(VarIn,Var_tmp)
+    CALL grid1dTo2d_glo(Var_tmp,VarOut)
+
+  END SUBROUTINE gather2D_mpi_l3
+  
+  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des reduce_sum   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE reduce_sum_mpi_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN)  :: VarIn
+    INTEGER,INTENT(OUT) :: VarOut
+    INTEGER             :: VarIn_tmp(1)
+    INTEGER             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn    
+    CALL reduce_sum_mpi_igen(VarIn_tmp,Varout_tmp,1)
+    VarOut=VarOut_tmp(1)
+    
+  END SUBROUTINE reduce_sum_mpi_i
+
+  SUBROUTINE reduce_sum_mpi_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i1
+
+  SUBROUTINE reduce_sum_mpi_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i2
+
+  SUBROUTINE reduce_sum_mpi_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i3
+
+  SUBROUTINE reduce_sum_mpi_i4(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_igen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_i4                  
+  
+  
+  SUBROUTINE reduce_sum_mpi_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN)  :: VarIn
+    REAL,INTENT(OUT) :: VarOut
+    REAL             :: VarIn_tmp(1)
+    REAL             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn    
+    CALL reduce_sum_mpi_rgen(VarIn_tmp,Varout_tmp,1)
+    VarOut=VarOut_tmp(1)
+  
+  END SUBROUTINE reduce_sum_mpi_r
+
+  SUBROUTINE reduce_sum_mpi_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+     
+  END SUBROUTINE reduce_sum_mpi_r1
+
+  SUBROUTINE reduce_sum_mpi_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_r2
+
+  SUBROUTINE reduce_sum_mpi_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_r3
+
+  SUBROUTINE reduce_sum_mpi_r4(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY :  is_mpi_root
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL reduce_sum_mpi_rgen(VarIn,Varout,SIZE(VarIn))
+  
+  END SUBROUTINE reduce_sum_mpi_r4 
+  
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! SUBROUTINE grid1dTo2d  !!  
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+  SUBROUTINE grid1dTo2d_mpi_i(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_mpi_i
+  
+
+  SUBROUTINE grid1dTo2d_mpi_i1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_mpi_i1
+
+  SUBROUTINE grid1dTo2d_mpi_i2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_mpi_i2
+  
+  SUBROUTINE grid1dTo2d_mpi_i3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_igen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_mpi_i3
+
+
+  SUBROUTINE grid1dTo2d_mpi_r(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_mpi_r
+  
+
+  SUBROUTINE grid1dTo2d_mpi_r1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_mpi_r1
+
+  SUBROUTINE grid1dTo2d_mpi_r2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_mpi_r2
+  
+  SUBROUTINE grid1dTo2d_mpi_r3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_rgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_mpi_r3
+  
+  
+  
+  SUBROUTINE grid1dTo2d_mpi_l(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid1dTo2d_mpi_l
+  
+
+  SUBROUTINE grid1dTo2d_mpi_l1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2))
+  
+  END SUBROUTINE grid1dTo2d_mpi_l1
+
+  SUBROUTINE grid1dTo2d_mpi_l2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3))
+  
+  END SUBROUTINE grid1dTo2d_mpi_l2
+  
+  SUBROUTINE grid1dTo2d_mpi_l3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:)     :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:)  :: VarOut
+    
+    CALL grid1dTo2d_mpi_lgen(VarIn,VarOut,size(VarIn,2)*size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid1dTo2d_mpi_l3
+
+
+  SUBROUTINE grid2dTo1d_mpi_i(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_mpi_i
+  
+
+  SUBROUTINE grid2dTo1d_mpi_i1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_mpi_i1
+
+  SUBROUTINE grid2dTo1d_mpi_i2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_mpi_i2
+  
+  SUBROUTINE grid2dTo1d_mpi_i3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_igen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_mpi_i3
+ 
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_r(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_mpi_r
+  
+
+  SUBROUTINE grid2dTo1d_mpi_r1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_mpi_r1
+
+  SUBROUTINE grid2dTo1d_mpi_r2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_mpi_r2
+  
+  SUBROUTINE grid2dTo1d_mpi_r3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_rgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_mpi_r3
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_l(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,1)
+  
+  END SUBROUTINE grid2dTo1d_mpi_l
+  
+
+  SUBROUTINE grid2dTo1d_mpi_l1(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3))
+  
+  END SUBROUTINE grid2dTo1d_mpi_l1
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_l2(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4))
+  
+  END SUBROUTINE grid2dTo1d_mpi_l2
+
+  
+  SUBROUTINE grid2dTo1d_mpi_l3(VarIn,VarOut)  
+  IMPLICIT NONE  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:)  :: VarOut
+    
+    CALL grid2dTo1d_mpi_lgen(VarIn,VarOut,size(VarIn,3)*size(VarIn,4)*size(VarIn,5))
+  
+  END SUBROUTINE grid2dTo1d_mpi_l3
+
+               
+
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! DEFINITION DES FONCTIONS DE TRANSFERT GENERIQUES !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE bcast_mpi_cgen(var,nb)
+    USE mod_phys_lmdz_mpi_data 
+    IMPLICIT NONE
+    
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+    INTEGER,INTENT(IN) :: nb
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+    
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_CHARACTER,mpi_master,COMM_LMDZ_PHY,ierr)
+#endif
+        
+  END SUBROUTINE bcast_mpi_cgen
+
+
+      
+  SUBROUTINE bcast_mpi_igen(var,nb)
+    USE mod_phys_lmdz_mpi_data
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: nb
+    INTEGER,DIMENSION(nb),INTENT(INOUT) :: Var
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_INTEGER,mpi_master,COMM_LMDZ_PHY,ierr)
+#endif
+        
+  END SUBROUTINE bcast_mpi_igen
+
+
+
+  
+  SUBROUTINE bcast_mpi_rgen(var,nb)
+    USE mod_phys_lmdz_mpi_data
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: nb
+    REAL,DIMENSION(nb),INTENT(INOUT) :: Var
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_REAL_LMDZ,mpi_master,COMM_LMDZ_PHY,ierr)
+#endif
+    
+  END SUBROUTINE bcast_mpi_rgen
+  
+
+
+
+  SUBROUTINE bcast_mpi_lgen(var,nb)
+    USE mod_phys_lmdz_mpi_data
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: nb
+    LOGICAL,DIMENSION(nb),INTENT(INOUT) :: Var
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) RETURN
+
+#ifdef CPP_MPI
+    CALL MPI_BCAST(Var,nb,MPI_LOGICAL,mpi_master,COMM_LMDZ_PHY,ierr)
+#endif
+
+  END SUBROUTINE bcast_mpi_lgen
+
+  
+
+  SUBROUTINE scatter_mpi_igen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data 
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+    
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        DO i=1,dimsize
+          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+      
+#ifdef CPP_MPI 
+    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_INTEGER,VarOut,klon_mpi*dimsize,   &
+                      MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
+#endif
+
+  END SUBROUTINE scatter_mpi_igen
+
+  SUBROUTINE scatter_mpi_rgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data 
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+    
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        DO i=1,dimsize
+          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+      
+#ifdef CPP_MPI 
+    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_REAL_LMDZ,VarOut,klon_mpi*dimsize,   &
+                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
+
+#endif
+
+  END SUBROUTINE scatter_mpi_rgen
+
+  
+  SUBROUTINE scatter_mpi_lgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data 
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_glo,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+    
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        DO i=1,dimsize
+          VarTmp(Index:Index+nb-1)=VarIn(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+      
+#ifdef CPP_MPI
+    CALL MPI_SCATTERV(VarTmp,counts,displs,MPI_LOGICAL,VarOut,klon_mpi*dimsize,   &
+                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
+#endif
+
+  END SUBROUTINE scatter_mpi_lgen  
+
+
+
+
+  SUBROUTINE gather_mpi_igen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
+  
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    INTEGER,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        Index=Index+nb*dimsize
+      ENDDO
+     
+    ENDIF
+    
+#ifdef CPP_MPI
+    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_INTEGER,VarTmp,counts,displs,   &
+                     MPI_INTEGER,mpi_master, COMM_LMDZ_PHY,ierr)
+#endif
+
+                          
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        DO i=1,dimsize
+          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE gather_mpi_igen  
+
+  SUBROUTINE gather_mpi_rgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data 
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
+  
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    REAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        Index=Index+nb*dimsize
+      ENDDO
+    ENDIF
+    
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+#ifdef CPP_MPI
+    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_REAL_LMDZ,VarTmp,counts,displs,   &
+                      MPI_REAL_LMDZ,mpi_master, COMM_LMDZ_PHY,ierr)
+#endif
+                          
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        DO i=1,dimsize
+          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE gather_mpi_rgen  
+
+  SUBROUTINE gather_mpi_lgen(VarIn, VarOut, dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_glo,dimsize) :: VarOut
+  
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+
+    INTEGER,DIMENSION(0:mpi_size-1) :: displs
+    INTEGER,DIMENSION(0:mpi_size-1) :: counts
+    LOGICAL,DIMENSION(dimsize*klon_glo) :: VarTmp
+    INTEGER :: nb,i,index,rank
+    INTEGER :: ierr
+    
+    IF (.not.is_using_mpi) THEN
+      VarOut(:,:)=VarIn(:,:)
+      RETURN
+    ENDIF
+
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        displs(rank)=Index-1
+        counts(rank)=nb*dimsize
+        Index=Index+nb*dimsize
+      ENDDO
+    ENDIF
+    
+
+#ifdef CPP_MPI
+    CALL MPI_GATHERV(VarIn,klon_mpi*dimsize,MPI_LOGICAL,VarTmp,counts,displs,   &
+                      MPI_LOGICAL,mpi_master, COMM_LMDZ_PHY,ierr)
+#endif
+                          
+    IF (is_mpi_root) THEN
+      Index=1
+      DO rank=0,mpi_size-1
+        nb=klon_mpi_para_nb(rank)
+        DO i=1,dimsize
+          VarOut(klon_mpi_para_begin(rank):klon_mpi_para_end(rank),i)=VarTmp(Index:Index+nb-1)
+          Index=Index+nb
+        ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE gather_mpi_lgen
+  
+
+
+  SUBROUTINE reduce_sum_mpi_igen(VarIn,VarOut,nb)
+    USE mod_phys_lmdz_mpi_data 
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+   
+    INTEGER,INTENT(IN) :: nb
+    INTEGER,DIMENSION(nb),INTENT(IN) :: VarIn
+    INTEGER,DIMENSION(nb),INTENT(OUT) :: VarOut    
+    INTEGER :: ierr
+   
+    IF (.not.is_using_mpi) THEN
+      VarOut(:)=VarIn(:)
+      RETURN
+    ENDIF
+
+
+#ifdef CPP_MPI
+    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_INTEGER,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
+#endif
+            
+  END SUBROUTINE reduce_sum_mpi_igen
+  
+  SUBROUTINE reduce_sum_mpi_rgen(VarIn,VarOut,nb)
+    USE mod_phys_lmdz_mpi_data 
+    USE mod_grid_phy_lmdz
+
+    IMPLICIT NONE
+
+#ifdef CPP_MPI
+    INCLUDE 'mpif.h'
+#endif
+    
+    INTEGER,INTENT(IN) :: nb
+    REAL,DIMENSION(nb),INTENT(IN) :: VarIn
+    REAL,DIMENSION(nb),INTENT(OUT) :: VarOut    
+    INTEGER :: ierr
+ 
+    IF (.not.is_using_mpi) THEN
+      VarOut(:)=VarIn(:)
+      RETURN
+    ENDIF
+   
+#ifdef CPP_MPI
+    CALL MPI_REDUCE(VarIn,VarOut,nb,MPI_REAL_LMDZ,MPI_SUM,mpi_master,COMM_LMDZ_PHY,ierr)
+#endif
+        
+  END SUBROUTINE reduce_sum_mpi_rgen
+
+
+
+  SUBROUTINE grid1dTo2d_mpi_igen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    
+    VarOut(1:nbp_lon,:)=0
+    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
+    
+    offset=ii_begin
+    IF (is_north_pole) Offset=nbp_lon
+    
+    
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        DO ij=1,nbp_lon
+         VarOut(ij,i)=VarIn(1,i)
+        ENDDO
+      ENDDO
+    ENDIF
+    
+    IF (is_south_pole) THEN 
+      DO i=1,dimsize
+        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
+         VarOut(ij,i)=VarIn(klon_mpi,i)
+        ENDDO
+      ENDDO
+    ENDIF
+
+  END SUBROUTINE grid1dTo2d_mpi_igen   
+
+
+  SUBROUTINE grid1dTo2d_mpi_rgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
+    REAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    
+    VarOut(1:nbp_lon,:)=0
+    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=0
+    
+    offset=ii_begin
+    IF (is_north_pole) Offset=nbp_lon
+    
+    
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        DO ij=1,nbp_lon
+         VarOut(ij,i)=VarIn(1,i)
+        ENDDO
+      ENDDO
+    ENDIF
+    
+    IF (is_south_pole) THEN 
+      DO i=1,dimsize
+        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
+         VarOut(ij,i)=VarIn(klon_mpi,i)
+        ENDDO
+      ENDDO
+    ENDIF
+
+   END SUBROUTINE grid1dTo2d_mpi_rgen   
+
+
+
+  SUBROUTINE grid1dTo2d_mpi_lgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN) ,DIMENSION(klon_mpi,dimsize)       :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(nbp_lon*jj_nb,dimsize)  :: VarOut
+    INTEGER :: i,ij,Offset
+
+    
+    VarOut(1:nbp_lon,:)=.FALSE.
+    VarOut(nbp_lon*(jj_nb-1)+1:nbp_lon*jj_nb,:)=.FALSE.
+    
+    offset=ii_begin
+    IF (is_north_pole) Offset=nbp_lon
+    
+    
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij+offset-1,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+    
+    
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        DO ij=1,nbp_lon
+         VarOut(ij,i)=VarIn(1,i)
+        ENDDO
+      ENDDO
+    ENDIF
+    
+    IF (is_south_pole) THEN 
+      DO i=1,dimsize
+        DO ij=nbp_lon*(jj_nb-1)+1,nbp_lon*jj_nb
+         VarOut(ij,i)=VarIn(klon_mpi,i)
+        ENDDO
+      ENDDO
+    ENDIF
+
+   END SUBROUTINE grid1dTo2d_mpi_lgen   
+
+  
+
+
+  SUBROUTINE grid2dTo1d_mpi_igen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=ii_begin
+    IF (is_north_pole) offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        VarOut(1,i)=VarIn(1,i)
+      ENDDO
+    ENDIF
+    
+    
+  END SUBROUTINE grid2dTo1d_mpi_igen   
+
+
+
+  SUBROUTINE grid2dTo1d_mpi_rgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=ii_begin
+    IF (is_north_pole) offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+         VarOut(1,i)=VarIn(1,i)
+      ENDDO
+    ENDIF
+    
+    
+  END SUBROUTINE grid2dTo1d_mpi_rgen   
+  
+
+  SUBROUTINE grid2dTo1d_mpi_lgen(VarIn,VarOut,dimsize)
+    USE mod_phys_lmdz_mpi_data
+    USE mod_grid_phy_lmdz
+    IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN) ,DIMENSION(nbp_lon*jj_nb,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize)      :: VarOut
+    INTEGER :: i,ij,offset
+
+    offset=ii_begin
+    IF (is_north_pole) offset=nbp_lon
+
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=VarIn(ij+offset-1,i)
+      ENDDO
+    ENDDO
+
+    IF (is_north_pole) THEN 
+      DO i=1,dimsize
+        VarOut(1,i)=VarIn(1,i)
+      ENDDO
+    ENDIF
+    
+    
+  END SUBROUTINE grid2dTo1d_mpi_lgen   
+
+END MODULE mod_phys_lmdz_mpi_transfert
+
Index: /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_omp_data.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_omp_data.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_omp_data.F90	(revision 1644)
@@ -0,0 +1,109 @@
+!
+!$Id: mod_phys_lmdz_omp_data.F90 2326 2015-07-10 12:24:29Z emillour $
+!
+MODULE mod_phys_lmdz_omp_data
+
+  INTEGER,SAVE :: omp_size
+  INTEGER,SAVE :: omp_rank
+  LOGICAL,SAVE :: is_omp_root
+  LOGICAL,SAVE :: is_using_omp
+  
+  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_nb
+  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_begin
+  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_end    
+  
+  INTEGER,SAVE :: klon_omp
+  INTEGER,SAVE :: klon_omp_begin
+  INTEGER,SAVE :: klon_omp_end
+!$OMP  THREADPRIVATE(omp_rank,klon_omp,is_omp_root,klon_omp_begin,klon_omp_end)
+
+CONTAINS
+  
+  SUBROUTINE Init_phys_lmdz_omp_data(klon_mpi)
+    USE dimphy
+    IMPLICIT NONE
+    INTEGER, INTENT(in) :: klon_mpi
+
+    INTEGER :: i
+
+    CHARACTER (LEN=20) :: modname='Init_phys_lmdz_omp_data'
+    CHARACTER (LEN=80) :: abort_message
+
+
+#ifdef CPP_OMP    
+    INTEGER :: OMP_GET_NUM_THREADS
+    EXTERNAL OMP_GET_NUM_THREADS
+    INTEGER :: OMP_GET_THREAD_NUM
+    EXTERNAL OMP_GET_THREAD_NUM
+#endif  
+
+#ifdef CPP_OMP
+!$OMP MASTER
+        is_using_omp=.TRUE.
+        omp_size=OMP_GET_NUM_THREADS()
+!$OMP END MASTER
+        omp_rank=OMP_GET_THREAD_NUM()    
+#else    
+    is_using_omp=.FALSE.
+    omp_size=1
+    omp_rank=0
+#endif
+
+   is_omp_root=.FALSE.
+!$OMP MASTER
+   IF (omp_rank==0) THEN
+     is_omp_root=.TRUE.
+   ELSE
+     abort_message = 'ANORMAL : OMP_MASTER /= 0'
+     CALL abort_gcm (modname,abort_message,1)
+   ENDIF
+!$OMP END MASTER
+
+
+!$OMP MASTER 
+    ALLOCATE(klon_omp_para_nb(0:omp_size-1))
+    ALLOCATE(klon_omp_para_begin(0:omp_size-1))
+    ALLOCATE(klon_omp_para_end(0:omp_size-1))
+    
+    DO i=0,omp_size-1
+      klon_omp_para_nb(i)=klon_mpi/omp_size
+      IF (i<MOD(klon_mpi,omp_size)) klon_omp_para_nb(i)=klon_omp_para_nb(i)+1
+    ENDDO
+    
+    klon_omp_para_begin(0) = 1
+    klon_omp_para_end(0) = klon_omp_para_nb(0)
+    
+    DO i=1,omp_size-1
+      klon_omp_para_begin(i)=klon_omp_para_end(i-1)+1
+      klon_omp_para_end(i)=klon_omp_para_begin(i)+klon_omp_para_nb(i)-1
+    ENDDO
+!$OMP END MASTER
+!$OMP BARRIER
+   
+    klon_omp=klon_omp_para_nb(omp_rank)
+    klon_omp_begin=klon_omp_para_begin(omp_rank)
+    klon_omp_end=klon_omp_para_end(omp_rank)
+    
+    CALL Print_module_data
+    
+  END SUBROUTINE Init_phys_lmdz_omp_data
+
+  SUBROUTINE Print_module_data
+  IMPLICIT NONE
+  INCLUDE "iniprint.h"
+
+!$OMP CRITICAL  
+  WRITE(lunout,*)'--------> TASK ',omp_rank
+  WRITE(lunout,*)'omp_size =',omp_size
+  WRITE(lunout,*)'omp_rank =',omp_rank
+  WRITE(lunout,*)'is_omp_root =',is_omp_root
+  WRITE(lunout,*)'klon_omp_para_nb =',klon_omp_para_nb
+  WRITE(lunout,*)'klon_omp_para_begin =',klon_omp_para_begin
+  WRITE(lunout,*)'klon_omp_para_end =',klon_omp_para_end    
+  WRITE(lunout,*)'klon_omp =',klon_omp
+  WRITE(lunout,*)'klon_omp_begin =',klon_omp_begin
+  WRITE(lunout,*)'klon_omp_end =',klon_omp_end    
+!$OMP END CRITICAL
+
+  END SUBROUTINE Print_module_data
+END MODULE mod_phys_lmdz_omp_data
Index: /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_omp_transfert.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_omp_transfert.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_omp_transfert.F90	(revision 1644)
@@ -0,0 +1,1064 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_omp_transfert
+
+  PRIVATE
+  
+  INTEGER,PARAMETER :: grow_factor=1.5
+  INTEGER,PARAMETER :: size_min=1024
+  
+  CHARACTER(LEN=size_min),SAVE            :: buffer_c
+!  INTEGER,SAVE                            :: size_c=0
+  INTEGER,SAVE,ALLOCATABLE,DIMENSION(:)   :: buffer_i
+  INTEGER,SAVE                            :: size_i=0
+  REAL,SAVE,ALLOCATABLE,DIMENSION(:)      :: buffer_r
+  INTEGER,SAVE                            :: size_r=0
+  LOGICAL,SAVE,ALLOCATABLE,DIMENSION(:)   :: buffer_l
+  INTEGER,SAVE                            :: size_l=0
+
+
+  
+  
+  INTERFACE bcast_omp
+    MODULE PROCEDURE bcast_omp_c,                                                     &
+                     bcast_omp_i,bcast_omp_i1,bcast_omp_i2,bcast_omp_i3,bcast_omp_i4, &
+                     bcast_omp_r,bcast_omp_r1,bcast_omp_r2,bcast_omp_r3,bcast_omp_r4, &
+                     bcast_omp_l,bcast_omp_l1,bcast_omp_l2,bcast_omp_l3,bcast_omp_l4
+  END INTERFACE
+
+  INTERFACE scatter_omp
+    MODULE PROCEDURE scatter_omp_i,scatter_omp_i1,scatter_omp_i2,scatter_omp_i3, &
+                     scatter_omp_r,scatter_omp_r1,scatter_omp_r2,scatter_omp_r3, &
+                     scatter_omp_l,scatter_omp_l1,scatter_omp_l2,scatter_omp_l3
+  END INTERFACE
+
+  
+  INTERFACE gather_omp
+    MODULE PROCEDURE gather_omp_i,gather_omp_i1,gather_omp_i2,gather_omp_i3, &
+                     gather_omp_r,gather_omp_r1,gather_omp_r2,gather_omp_r3, &
+                     gather_omp_l,gather_omp_l1,gather_omp_l2,gather_omp_l3  
+  END INTERFACE
+  
+  
+  INTERFACE reduce_sum_omp
+    MODULE PROCEDURE reduce_sum_omp_i,reduce_sum_omp_i1,reduce_sum_omp_i2,reduce_sum_omp_i3,reduce_sum_omp_i4, &
+                     reduce_sum_omp_r,reduce_sum_omp_r1,reduce_sum_omp_r2,reduce_sum_omp_r3,reduce_sum_omp_r4
+  END INTERFACE 
+
+
+  PUBLIC bcast_omp,scatter_omp,gather_omp,reduce_sum_omp, omp_barrier
+
+CONTAINS
+
+  SUBROUTINE omp_barrier
+  IMPLICIT NONE
+
+!$OMP BARRIER
+
+  END SUBROUTINE omp_barrier
+  
+  SUBROUTINE check_buffer_i(buff_size)
+  IMPLICIT NONE
+  INTEGER :: buff_size
+
+!$OMP BARRIER
+!$OMP MASTER
+    IF (buff_size>size_i) THEN
+      IF (ALLOCATED(buffer_i)) DEALLOCATE(buffer_i)
+      size_i=MAX(size_min,INT(grow_factor*buff_size))
+      ALLOCATE(buffer_i(size_i))
+    ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  END SUBROUTINE check_buffer_i
+  
+  SUBROUTINE check_buffer_r(buff_size)
+  IMPLICIT NONE
+  INTEGER :: buff_size
+
+!$OMP BARRIER
+!$OMP MASTER
+    IF (buff_size>size_r) THEN
+      IF (ALLOCATED(buffer_r)) DEALLOCATE(buffer_r)
+      size_r=MAX(size_min,INT(grow_factor*buff_size))
+      ALLOCATE(buffer_r(size_r))
+    ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  END SUBROUTINE check_buffer_r
+  
+  SUBROUTINE check_buffer_l(buff_size)
+  IMPLICIT NONE
+  INTEGER :: buff_size
+
+!$OMP BARRIER
+!$OMP MASTER
+    IF (buff_size>size_l) THEN
+      IF (ALLOCATED(buffer_l)) DEALLOCATE(buffer_l)
+      size_l=MAX(size_min,INT(grow_factor*buff_size))
+      ALLOCATE(buffer_l(size_l))
+    ENDIF
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  END SUBROUTINE check_buffer_l
+    
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Broadcast --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!! -- Les chaine de charactère -- !!
+
+  SUBROUTINE bcast_omp_c(var)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+    
+    CALL bcast_omp_cgen(Var,len(Var),buffer_c)
+    
+  END SUBROUTINE bcast_omp_c
+
+!! -- Les entiers -- !!
+  
+  SUBROUTINE bcast_omp_i(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var
+    INTEGER :: Var_tmp(1)
+    
+    Var_tmp(1)=Var
+    CALL check_buffer_i(1)
+    CALL bcast_omp_igen(Var_tmp,1,buffer_i)
+    Var=Var_tmp(1)
+
+  END SUBROUTINE bcast_omp_i
+
+
+  SUBROUTINE bcast_omp_i1(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:)
+   
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i1
+
+
+  SUBROUTINE bcast_omp_i2(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:)
+   
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i2
+
+
+  SUBROUTINE bcast_omp_i3(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:)
+
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i3
+
+
+  SUBROUTINE bcast_omp_i4(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL check_buffer_i(size(Var))
+    CALL bcast_omp_igen(Var,size(Var),buffer_i)
+
+  END SUBROUTINE bcast_omp_i4
+
+
+!! -- Les reels -- !!
+
+  SUBROUTINE bcast_omp_r(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var
+    REAL :: Var_tmp(1)
+    
+    Var_tmp(1)=Var
+    CALL check_buffer_r(1)
+    CALL bcast_omp_rgen(Var_tmp,1,buffer_r)
+    Var=Var_tmp(1)
+
+  END SUBROUTINE bcast_omp_r
+
+
+  SUBROUTINE bcast_omp_r1(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:)
+   
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r1
+
+
+  SUBROUTINE bcast_omp_r2(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r2
+
+
+  SUBROUTINE bcast_omp_r3(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:)
+
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r3
+
+
+  SUBROUTINE bcast_omp_r4(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL check_buffer_r(size(Var))
+    CALL bcast_omp_rgen(Var,size(Var),buffer_r)
+
+  END SUBROUTINE bcast_omp_r4
+
+  
+!! -- Les booleans -- !!
+
+  SUBROUTINE bcast_omp_l(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var
+    LOGICAL :: Var_tmp(1)
+    
+    Var_tmp(1)=Var
+    CALL check_buffer_l(1)
+    CALL bcast_omp_lgen(Var_tmp,1,buffer_l)
+    Var=Var_tmp(1)
+
+  END SUBROUTINE bcast_omp_l
+
+
+  SUBROUTINE bcast_omp_l1(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:)
+   
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l1
+
+
+  SUBROUTINE bcast_omp_l2(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:)
+   
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l2
+
+
+  SUBROUTINE bcast_omp_l3(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
+
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l3
+
+
+  SUBROUTINE bcast_omp_l4(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+    CALL check_buffer_l(size(Var))
+    CALL bcast_omp_lgen(Var,size(Var),buffer_l)
+
+  END SUBROUTINE bcast_omp_l4
+
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter_omp_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,1,buffer_i)
+    
+  END SUBROUTINE scatter_omp_i
+
+
+  SUBROUTINE scatter_omp_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2),buffer_i)
+    
+  END SUBROUTINE scatter_omp_i1
+  
+  
+  SUBROUTINE scatter_omp_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_i)
+
+  END SUBROUTINE scatter_omp_i2
+
+
+  SUBROUTINE scatter_omp_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL scatter_omp_igen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_i)
+  
+  END SUBROUTINE scatter_omp_i3
+
+
+
+
+  SUBROUTINE scatter_omp_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,1,buffer_r)
+    
+  END SUBROUTINE scatter_omp_r
+
+
+  SUBROUTINE scatter_omp_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2),buffer_r)
+        
+  END SUBROUTINE scatter_omp_r1
+  
+  
+  SUBROUTINE scatter_omp_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_r)
+
+  END SUBROUTINE scatter_omp_r2
+
+
+  SUBROUTINE scatter_omp_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL scatter_omp_rgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_r)
+  
+  END SUBROUTINE scatter_omp_r3
+  
+
+
+  SUBROUTINE scatter_omp_l(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,1,buffer_l)
+    
+  END SUBROUTINE scatter_omp_l
+
+
+  SUBROUTINE scatter_omp_l1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2),buffer_l)
+    
+  END SUBROUTINE scatter_omp_l1
+  
+  
+  SUBROUTINE scatter_omp_l2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3),buffer_l)
+
+  END SUBROUTINE scatter_omp_l2
+
+
+  SUBROUTINE scatter_omp_l3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarIn))   
+    CALL scatter_omp_lgen(VarIn,Varout,Size(VarOut,2)*Size(VarOut,3)*Size(VarOut,4),buffer_l)
+  
+  END SUBROUTINE scatter_omp_l3  
+  
+
+  SUBROUTINE gather_omp_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,1,buffer_i)
+    
+  END SUBROUTINE gather_omp_i
+
+
+  SUBROUTINE gather_omp_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2),buffer_i)
+    
+  END SUBROUTINE gather_omp_i1
+
+
+  SUBROUTINE gather_omp_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_i)
+          
+  END SUBROUTINE gather_omp_i2
+  
+
+  SUBROUTINE gather_omp_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarOut))   
+    CALL gather_omp_igen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_i)
+    
+  END SUBROUTINE gather_omp_i3
+
+
+
+  SUBROUTINE gather_omp_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_r(size(VarOut))   
+    CALL gather_omp_rgen(VarIn,Varout,1,buffer_r)
+    
+  END SUBROUTINE gather_omp_r
+
+
+  SUBROUTINE gather_omp_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    CALL Check_buffer_r(size(VarOut))   
+    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2),buffer_r)
+        
+  END SUBROUTINE gather_omp_r1
+
+
+  SUBROUTINE gather_omp_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarOut))   
+    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_r)
+    
+  END SUBROUTINE gather_omp_r2
+  
+
+  SUBROUTINE gather_omp_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    CALL Check_buffer_r(size(VarOut))       
+    CALL gather_omp_rgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_r)
+    
+  END SUBROUTINE gather_omp_r3
+
+
+  SUBROUTINE gather_omp_l(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,1,buffer_l)
+    
+  END SUBROUTINE gather_omp_l
+
+
+  SUBROUTINE gather_omp_l1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2),buffer_l)
+    
+  END SUBROUTINE gather_omp_l1
+
+
+  SUBROUTINE gather_omp_l2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3),buffer_l)
+    
+  END SUBROUTINE gather_omp_l2
+  
+
+  SUBROUTINE gather_omp_l3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    CALL Check_buffer_l(size(VarOut))   
+    CALL gather_omp_lgen(VarIn,Varout,Size(VarIn,2)*Size(VarIn,3)*Size(VarIn,4),buffer_l)
+    
+  END SUBROUTINE gather_omp_l3
+
+
+
+
+  SUBROUTINE reduce_sum_omp_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN)  :: VarIn
+    INTEGER,INTENT(OUT) :: VarOut
+    INTEGER             :: VarIn_tmp(1)
+    INTEGER             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn
+    CALL Check_buffer_i(1)   
+    CALL reduce_sum_omp_igen(VarIn_tmp,Varout_tmp,1,buffer_i)
+    VarOut=VarOut_tmp(1)
+    
+  END SUBROUTINE reduce_sum_omp_i
+
+  SUBROUTINE reduce_sum_omp_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+   
+  END SUBROUTINE reduce_sum_omp_i1
+  
+  
+  SUBROUTINE reduce_sum_omp_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+  
+  END SUBROUTINE reduce_sum_omp_i2
+
+
+  SUBROUTINE reduce_sum_omp_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+  
+  END SUBROUTINE reduce_sum_omp_i3
+
+
+  SUBROUTINE reduce_sum_omp_i4(VarIn, VarOut)
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+  
+    CALL Check_buffer_i(size(VarIn))   
+    CALL reduce_sum_omp_igen(VarIn,Varout,Size(VarIn),buffer_i)
+  
+  END SUBROUTINE reduce_sum_omp_i4
+
+
+  SUBROUTINE reduce_sum_omp_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN)  :: VarIn
+    REAL,INTENT(OUT) :: VarOut
+    REAL             :: VarIn_tmp(1)
+    REAL             :: VarOut_tmp(1)
+    
+    VarIn_tmp(1)=VarIn
+    CALL Check_buffer_r(1)   
+    CALL reduce_sum_omp_rgen(VarIn_tmp,Varout_tmp,1,buffer_r)
+    VarOut=VarOut_tmp(1)
+  
+  END SUBROUTINE reduce_sum_omp_r
+
+  SUBROUTINE reduce_sum_omp_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+   
+  END SUBROUTINE reduce_sum_omp_r1
+  
+  
+  SUBROUTINE reduce_sum_omp_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+  
+  END SUBROUTINE reduce_sum_omp_r2
+
+
+  SUBROUTINE reduce_sum_omp_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+  
+  END SUBROUTINE reduce_sum_omp_r3
+
+
+  SUBROUTINE reduce_sum_omp_r4(VarIn, VarOut)
+    IMPLICIT NONE
+
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+  
+    CALL Check_buffer_r(size(VarIn))   
+    CALL reduce_sum_omp_rgen(VarIn,Varout,Size(VarIn),buffer_r)
+  
+  END SUBROUTINE reduce_sum_omp_r4
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!    LES ROUTINES GENERIQUES    !
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE bcast_omp_cgen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+    CHARACTER(LEN=*),INTENT(INOUT) :: Buff
+    INTEGER,INTENT(IN) :: Nb
+    
+    INTEGER :: i
+  
+  !$OMP MASTER
+      Buff=Var
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var=Buff
+    ENDDO
+  !$OMP BARRIER      
+  
+  END SUBROUTINE bcast_omp_cgen
+
+
+      
+  SUBROUTINE bcast_omp_igen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: Nb
+    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Var
+    INTEGER,DIMENSION(Nb),INTENT(INOUT) :: Buff
+
+    INTEGER :: i
+    
+  !$OMP MASTER
+    DO i=1,Nb
+      Buff(i)=Var(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var(i)=Buff(i)
+    ENDDO
+  !$OMP BARRIER        
+
+  END SUBROUTINE bcast_omp_igen
+
+
+  SUBROUTINE bcast_omp_rgen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: Nb
+    REAL,DIMENSION(Nb),INTENT(INOUT) :: Var
+    REAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
+
+    INTEGER :: i
+    
+  !$OMP MASTER
+    DO i=1,Nb
+      Buff(i)=Var(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var(i)=Buff(i)
+    ENDDO
+  !$OMP BARRIER        
+
+  END SUBROUTINE bcast_omp_rgen
+
+  SUBROUTINE bcast_omp_lgen(Var,Nb,Buff)
+  IMPLICIT NONE
+    
+    INTEGER,INTENT(IN) :: Nb
+    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Var
+    LOGICAL,DIMENSION(Nb),INTENT(INOUT) :: Buff
+  
+    INTEGER :: i
+    
+  !$OMP MASTER
+    DO i=1,Nb
+      Buff(i)=Var(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,Nb
+      Var(i)=Buff(i)
+    ENDDO
+  !$OMP BARRIER        
+
+  END SUBROUTINE bcast_omp_lgen
+
+
+  SUBROUTINE scatter_omp_igen(VarIn,VarOut,dimsize,Buff)
+    USE mod_phys_lmdz_omp_data
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+    IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
+    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        Buff(ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+ 
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+ 
+  END SUBROUTINE scatter_omp_igen
+
+
+  SUBROUTINE scatter_omp_rgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
+    REAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        Buff(ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+  END SUBROUTINE scatter_omp_rgen
+
+
+  SUBROUTINE scatter_omp_lgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_mpi,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_omp,dimsize) :: VarOut
+    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+ !$OMP MASTER 
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        Buff(ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        VarOut(ij,i)=Buff(klon_omp_begin-1+ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+  END SUBROUTINE scatter_omp_lgen
+
+
+
+
+
+  SUBROUTINE gather_omp_igen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+    INTEGER,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+  
+  
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=Buff(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+  END SUBROUTINE gather_omp_igen
+
+
+  SUBROUTINE gather_omp_rgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+    REAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=Buff(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+  END SUBROUTINE gather_omp_rgen
+
+
+  SUBROUTINE gather_omp_lgen(VarIn,VarOut,dimsize,Buff)
+  USE mod_phys_lmdz_omp_data
+  USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi 
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    LOGICAL,INTENT(IN),DIMENSION(klon_omp,dimsize) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(klon_mpi,dimsize) :: VarOut
+    LOGICAL,INTENT(INOUT),DIMENSION(klon_mpi,dimsize) :: Buff
+
+    INTEGER :: i,ij
+    
+    DO i=1,dimsize
+      DO ij=1,klon_omp
+        Buff(klon_omp_begin-1+ij,i)=VarIn(ij,i)
+      ENDDO
+    ENDDO
+  !$OMP BARRIER  
+
+
+  !$OMP MASTER
+    DO i=1,dimsize
+      DO ij=1,klon_mpi
+        VarOut(ij,i)=Buff(ij,i)
+      ENDDO
+    ENDDO  
+  !$OMP END MASTER
+  !$OMP BARRIER
+
+  END SUBROUTINE gather_omp_lgen
+
+
+  SUBROUTINE reduce_sum_omp_igen(VarIn,VarOut,dimsize,Buff)
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    INTEGER,INTENT(IN),DIMENSION(dimsize) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(dimsize) :: VarOut
+    INTEGER,INTENT(INOUT),DIMENSION(dimsize) :: Buff
+
+    INTEGER :: i
+
+  !$OMP MASTER
+    Buff(:)=0
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  !$OMP CRITICAL     
+    DO i=1,dimsize
+      Buff(i)=Buff(i)+VarIn(i)
+    ENDDO
+  !$OMP END CRITICAL
+  !$OMP BARRIER  
+  
+  !$OMP MASTER
+    DO i=1,dimsize
+      VarOut(i)=Buff(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  END SUBROUTINE reduce_sum_omp_igen
+
+  SUBROUTINE reduce_sum_omp_rgen(VarIn,VarOut,dimsize,Buff)
+  IMPLICIT NONE
+
+    INTEGER,INTENT(IN) :: dimsize
+    REAL,INTENT(IN),DIMENSION(dimsize) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(dimsize) :: VarOut
+    REAL,INTENT(INOUT),DIMENSION(dimsize) :: Buff
+
+    INTEGER :: i
+
+  !$OMP MASTER
+    Buff(:)=0
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  !$OMP CRITICAL     
+    DO i=1,dimsize
+      Buff(i)=Buff(i)+VarIn(i)
+    ENDDO
+  !$OMP END CRITICAL
+  !$OMP BARRIER  
+  
+  !$OMP MASTER
+    DO i=1,dimsize
+      VarOut(i)=Buff(i)
+    ENDDO
+  !$OMP END MASTER
+  !$OMP BARRIER
+  
+  END SUBROUTINE reduce_sum_omp_rgen
+
+END MODULE mod_phys_lmdz_omp_transfert
Index: /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_para.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_para.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_para.F90	(revision 1644)
@@ -0,0 +1,113 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_para
+  USE mod_phys_lmdz_transfert_para
+  USE mod_phys_lmdz_mpi_data
+  USE mod_phys_lmdz_omp_data
+    
+  INTEGER,SAVE :: klon_loc
+  LOGICAL,SAVE :: is_sequential
+  LOGICAL,SAVE :: is_parallel
+  LOGICAL,SAVE :: is_master
+  
+!$OMP THREADPRIVATE(klon_loc,is_master)
+  
+CONTAINS
+
+  SUBROUTINE Init_phys_lmdz_para(nbp,nbp_lon,nbp_lat,communicator)
+  IMPLICIT NONE
+    INTEGER,INTENT(in) :: nbp
+    INTEGER,INTENT(in) :: nbp_lon
+    INTEGER,INTENT(in) :: nbp_lat
+    INTEGER,INTENT(in) :: communicator
+
+    CALL Init_phys_lmdz_mpi_data(nbp,nbp_lon,nbp_lat,communicator)
+!$OMP PARALLEL
+    CALL Init_phys_lmdz_omp_data(klon_mpi)
+    klon_loc=klon_omp
+    IF (is_mpi_root .AND. is_omp_root) THEN 
+       is_master=.TRUE.
+     ELSE
+       is_master=.FALSE.
+     ENDIF
+     CALL Test_transfert
+!$OMP END PARALLEL    
+     IF (is_using_mpi .OR. is_using_omp) THEN
+       is_sequential=.FALSE.
+       is_parallel=.TRUE.
+     ELSE
+       is_sequential=.TRUE.
+       is_parallel=.FALSE.
+     ENDIF
+      
+  END SUBROUTINE Init_phys_lmdz_para
+
+  SUBROUTINE Test_transfert
+  USE mod_grid_phy_lmdz
+  IMPLICIT NONE
+    INCLUDE "iniprint.h"
+ 
+    REAL :: Test_Field1d_glo(klon_glo,nbp_lev)
+    REAL :: tmp1d_glo(klon_glo,nbp_lev)
+    REAL :: Test_Field2d_glo(nbp_lon,nbp_lat,nbp_lev)
+    REAL :: tmp2d_glo(nbp_lon,nbp_lat,nbp_lev)
+    REAL :: Test_Field1d_loc(klon_loc,nbp_lev)
+    REAL :: Test_Field2d_loc(nbp_lon,jj_nb,nbp_lev)
+    REAL :: CheckSum
+    
+    INTEGER :: i,l
+  
+    Test_Field1d_glo = 0.
+    Test_Field2d_glo = 0.
+    Test_Field1d_loc = 0.
+    Test_Field2d_loc = 0.
+  
+    IF (is_mpi_root) THEN
+!$OMP MASTER
+      DO l=1,nbp_lev
+        DO i=1,klon_glo
+!          Test_Field1d_glo(i,l)=MOD(i,10)+10*(l-1)
+           Test_Field1d_glo(i,l)=1
+        ENDDO
+      ENDDO
+!$OMP END MASTER  
+    ENDIF
+  
+    CALL Scatter(Test_Field1d_glo,Test_Field1d_loc)
+    CALL Gather(Test_Field1d_loc,tmp1d_glo)
+  
+    IF (is_mpi_root) THEN
+!$OMP MASTER  
+      Checksum=sum(Test_Field1d_glo-tmp1d_glo)
+      WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
+!$OMP END MASTER
+    ENDIF
+    
+    CALL grid1dTo2d_glo(Test_Field1d_glo,Test_Field2d_glo)
+    CALL scatter2D(Test_Field2d_glo,Test_Field1d_loc)
+    CALL gather2d(Test_Field1d_loc,Test_Field2d_glo)
+    CALL grid2dTo1d_glo(Test_Field2d_glo,tmp1d_glo)
+
+    IF (is_mpi_root) THEN
+!$OMP MASTER  
+      Checksum=sum(Test_Field1d_glo-tmp1d_glo)
+      WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
+!$OMP END MASTER
+    ENDIF
+
+    CALL bcast(Test_Field1d_glo)
+    CALL reduce_sum(Test_Field1d_glo,tmp1d_glo)
+
+    IF (is_mpi_root) THEN
+!$OMP MASTER  
+      Checksum=sum(Test_Field1d_glo*omp_size*mpi_size-tmp1d_glo)
+      WRITE(lunout,*) "------> Checksum =",Checksum," MUST BE 0"
+!$OMP END MASTER
+    ENDIF
+    
+     
+   END SUBROUTINE Test_transfert
+  
+END MODULE mod_phys_lmdz_para
+    
Index: /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_transfert_para.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_transfert_para.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/mod_phys_lmdz_transfert_para.F90	(revision 1644)
@@ -0,0 +1,1275 @@
+!
+!$Header$
+!
+MODULE mod_phys_lmdz_transfert_para
+
+  USE mod_phys_lmdz_mpi_transfert
+  USE mod_phys_lmdz_omp_transfert 
+
+
+
+  INTERFACE bcast
+    MODULE PROCEDURE bcast_c,                                     &
+                     bcast_i,bcast_i1,bcast_i2,bcast_i3,bcast_i4, &
+                     bcast_r,bcast_r1,bcast_r2,bcast_r3,bcast_r4, &
+		     bcast_l,bcast_l1,bcast_l2,bcast_l3,bcast_l4
+  END INTERFACE
+
+  INTERFACE scatter
+    MODULE PROCEDURE scatter_i,scatter_i1,scatter_i2,scatter_i3, &
+                     scatter_r,scatter_r1,scatter_r2,scatter_r3, &
+		     scatter_l,scatter_l1,scatter_l2,scatter_l3
+  END INTERFACE
+
+  
+  INTERFACE gather
+    MODULE PROCEDURE gather_i,gather_i1,gather_i2,gather_i3, &
+                     gather_r,gather_r1,gather_r2,gather_r3, &
+		     gather_l,gather_l1,gather_l2,gather_l3  
+  END INTERFACE
+  
+  INTERFACE scatter2D
+    MODULE PROCEDURE scatter2D_i,scatter2D_i1,scatter2D_i2,scatter2D_i3, &
+                     scatter2D_r,scatter2D_r1,scatter2D_r2,scatter2D_r3, &
+		     scatter2D_l,scatter2D_l1,scatter2D_l2,scatter2D_l3
+  END INTERFACE
+
+  INTERFACE gather2D
+    MODULE PROCEDURE gather2D_i,gather2D_i1,gather2D_i2,gather2D_i3, &
+                     gather2D_r,gather2D_r1,gather2D_r2,gather2D_r3, &
+		     gather2D_l,gather2D_l1,gather2D_l2,gather2D_l3
+  END INTERFACE 
+  
+  INTERFACE reduce_sum
+    MODULE PROCEDURE reduce_sum_i,reduce_sum_i1,reduce_sum_i2,reduce_sum_i3,reduce_sum_i4, &
+                     reduce_sum_r,reduce_sum_r1,reduce_sum_r2,reduce_sum_r3,reduce_sum_r4
+  END INTERFACE 
+
+   
+CONTAINS
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Broadcast --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!! -- Les chaine de charactère -- !!
+
+  SUBROUTINE bcast_c(var)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(INOUT) :: Var
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_c
+
+!! -- Les entiers -- !!
+  
+  SUBROUTINE bcast_i(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i
+
+  SUBROUTINE bcast_i1(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i1
+
+
+  SUBROUTINE bcast_i2(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i2
+
+
+  SUBROUTINE bcast_i3(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i3
+
+
+  SUBROUTINE bcast_i4(var)
+  IMPLICIT NONE
+    INTEGER,INTENT(INOUT) :: Var(:,:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_i4
+
+ 
+!! -- Les reels -- !!
+  
+  SUBROUTINE bcast_r(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var
+
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r
+
+  SUBROUTINE bcast_r1(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r1
+
+
+  SUBROUTINE bcast_r2(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r2
+
+
+  SUBROUTINE bcast_r3(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r3
+
+
+  SUBROUTINE bcast_r4(var)
+  IMPLICIT NONE
+    REAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_r4 
+
+
+!! -- Les booleens -- !!
+  
+  SUBROUTINE bcast_l(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l
+
+  SUBROUTINE bcast_l1(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l1
+
+
+  SUBROUTINE bcast_l2(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l2
+
+
+  SUBROUTINE bcast_l3(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l3
+
+
+  SUBROUTINE bcast_l4(var)
+  IMPLICIT NONE
+    LOGICAL,INTENT(INOUT) :: Var(:,:,:,:)
+   
+!$OMP MASTER
+    CALL bcast_mpi(Var)
+!$OMP END MASTER
+    CALL bcast_omp(Var)
+    
+  END SUBROUTINE bcast_l4
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE scatter_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi) :: Var_tmp
+    
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_i
+
+
+  SUBROUTINE scatter_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_i1
+
+
+  SUBROUTINE scatter_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_i2
+
+
+  SUBROUTINE scatter_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter_i3
+
+
+  SUBROUTINE scatter_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi) :: Var_tmp
+    
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_r
+
+
+  SUBROUTINE scatter_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_r1
+
+
+  SUBROUTINE scatter_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_r2
+
+
+  SUBROUTINE scatter_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter_r3
+  
+  
+
+  SUBROUTINE scatter_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi) :: Var_tmp
+    
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_l
+
+
+  SUBROUTINE scatter_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_l1
+
+
+  SUBROUTINE scatter_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,Varout)
+    
+  END SUBROUTINE scatter_l2
+
+
+  SUBROUTINE scatter_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(Varout,2),SIZE(Varout,3),SIZE(Varout,4)) :: Var_tmp
+
+!$OMP MASTER
+      CALL scatter_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+      CALL scatter_omp(Var_tmp,VarOut)
+    
+  END SUBROUTINE scatter_l3
+
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ 
+!!!!! --> Les entiers
+
+  SUBROUTINE gather_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,Varout)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i
+
+
+  SUBROUTINE gather_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,Varout)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i1
+
+
+  SUBROUTINE gather_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i2
+
+
+  SUBROUTINE gather_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    INTEGER, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_i3
+
+
+!!!!! --> Les reels
+
+  SUBROUTINE gather_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r
+
+
+  SUBROUTINE gather_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r1
+
+
+  SUBROUTINE gather_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r2
+
+
+  SUBROUTINE gather_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_r3
+
+
+!!!!! --> Les booleens
+
+  SUBROUTINE gather_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l
+
+
+  SUBROUTINE gather_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l1
+
+
+  SUBROUTINE gather_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l2
+
+
+  SUBROUTINE gather_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL, DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+    
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE gather_l3
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Scatter2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+!!!!! --> Les entiers
+
+  SUBROUTINE scatter2D_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i
+
+
+  SUBROUTINE scatter2D_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i1
+  
+
+  SUBROUTINE scatter2D_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i2  
+
+
+  SUBROUTINE scatter2D_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_i3
+  
+
+!!!!! --> Les reels
+
+  SUBROUTINE scatter2D_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r
+
+
+  SUBROUTINE scatter2D_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r1
+  
+
+  SUBROUTINE scatter2D_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r2  
+
+
+  SUBROUTINE scatter2D_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    REAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_r3
+    
+    
+!!!!! --> Les booleens
+
+
+  SUBROUTINE scatter2D_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l
+
+
+  SUBROUTINE scatter2D_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l1
+  
+
+  SUBROUTINE scatter2D_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l2  
+
+
+  SUBROUTINE scatter2D_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarOut,2),SIZE(VarOut,3),SIZE(VarOut,4)) :: Var_tmp    
+
+!$OMP MASTER    
+    CALL scatter2D_mpi(VarIn,Var_tmp)
+!$OMP END MASTER
+    CALL scatter_omp(Var_tmp,VarOut)
+
+  END SUBROUTINE scatter2D_l3
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des Gather2D   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!!!!! --> Les entiers
+
+  SUBROUTINE gather2D_i(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i
+  
+
+  SUBROUTINE gather2D_i1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i1
+
+  
+  SUBROUTINE gather2D_i2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i2
+
+
+  SUBROUTINE gather2D_i3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_i3
+
+
+!!!!! --> Les reels
+
+  SUBROUTINE gather2D_r(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r
+  
+
+  SUBROUTINE gather2D_r1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r1
+
+  
+  SUBROUTINE gather2D_r2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r2
+
+
+  SUBROUTINE gather2D_r3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_r3
+  
+
+!!!!! --> Les booleens
+
+  SUBROUTINE gather2D_l(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l
+  
+
+  SUBROUTINE gather2D_l1(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l1
+
+  
+  SUBROUTINE gather2D_l2(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l2
+
+
+  SUBROUTINE gather2D_l3(VarIn, VarOut)
+    USE mod_phys_lmdz_mpi_data, ONLY : klon_mpi
+    IMPLICIT NONE
+  
+    LOGICAL,INTENT(IN),DIMENSION(:,:,:,:) :: VarIn
+    LOGICAL,INTENT(OUT),DIMENSION(:,:,:,:,:) :: VarOut
+    
+    LOGICAL,DIMENSION(klon_mpi,SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4)) :: Var_tmp
+
+    CALL gather_omp(VarIn,Var_tmp)
+!$OMP MASTER
+    CALL gather2D_mpi(Var_tmp,VarOut)
+!$OMP END MASTER    
+
+  END SUBROUTINE gather2D_l3
+  
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Definition des reduce_sum   --> 4D   !!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! Les entiers
+
+  SUBROUTINE reduce_sum_i(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN)  :: VarIn
+    INTEGER,INTENT(OUT) :: VarOut
+    
+    INTEGER             :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i  
+
+
+  SUBROUTINE reduce_sum_i1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn))   :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i1  
+
+
+  SUBROUTINE reduce_sum_i2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2)) :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i2  
+  
+
+  SUBROUTINE reduce_sum_i3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i3  
+
+
+  SUBROUTINE reduce_sum_i4(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    INTEGER,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    INTEGER,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    INTEGER,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_i4  
+
+
+! Les reels
+
+  SUBROUTINE reduce_sum_r(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN)  :: VarIn
+    REAL,INTENT(OUT) :: VarOut
+    
+    REAL             :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r  
+
+
+  SUBROUTINE reduce_sum_r1(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn))   :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r1  
+
+
+  SUBROUTINE reduce_sum_r2(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2)) :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r2  
+  
+
+  SUBROUTINE reduce_sum_r3(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r3  
+
+
+  SUBROUTINE reduce_sum_r4(VarIn, VarOut)
+    IMPLICIT NONE
+  
+    REAL,INTENT(IN),DIMENSION(:,:,:,:)  :: VarIn
+    REAL,INTENT(OUT),DIMENSION(:,:,:,:) :: VarOut
+    
+    REAL,DIMENSION(SIZE(VarIn,1),SIZE(VarIn,2),SIZE(VarIn,3),SIZE(VarIn,4))  :: Var_tmp
+           
+    CALL reduce_sum_omp(VarIn,Var_tmp)
+!$OMP MASTER      
+    CALL reduce_sum_mpi(Var_tmp,VarOut)
+!$OMP END MASTER
+  
+  END SUBROUTINE reduce_sum_r4  
+
+   
+END MODULE mod_phys_lmdz_transfert_para
+
Index: /trunk/LMDZ.TITAN/libf/phy_common/physics_distribution_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/physics_distribution_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/physics_distribution_mod.F90	(revision 1644)
@@ -0,0 +1,71 @@
+!
+!$Id: physics_distribution_mod.F90 2351 2015-08-25 15:14:59Z emillour $
+!
+MODULE physics_distribution_mod
+
+
+CONTAINS
+
+  SUBROUTINE init_physics_distribution(grid_type, nvertex, &
+                                       nbp, nbp_lon, nbp_lat, nbp_lev, &
+                                       communicator)
+  USE mod_phys_lmdz_para, ONLY: init_phys_lmdz_para
+  USE mod_grid_phy_lmdz, ONLY: init_grid_phy_lmdz
+  IMPLICIT NONE
+    INTEGER,INTENT(IN) :: grid_type 
+    INTEGER,INTENT(IN) :: nvertex 
+    INTEGER,INTENT(IN) :: nbp           
+    INTEGER,INTENT(IN) :: nbp_lon
+    INTEGER,INTENT(IN) :: nbp_lat
+    INTEGER,INTENT(IN) :: nbp_lev
+    INTEGER,INTENT(IN) :: communicator
+
+
+    CALL init_grid_phy_lmdz(grid_type,nvertex, nbp_lon,nbp_lat,nbp_lev)
+    CALL init_phys_lmdz_para(nbp,nbp_lon, nbp_lat, communicator)
+
+  END SUBROUTINE init_physics_distribution  
+
+!SUBROUTINE Init_Phys_lmdz(iim,jjp1,llm,nb_proc,distrib)
+!  USE mod_phys_lmdz_para, ONLY: Init_phys_lmdz_para!, klon_omp
+!  USE mod_grid_phy_lmdz, ONLY: Init_grid_phy_lmdz!, nbp_lev
+!  USE dimphy, ONLY : Init_dimphy
+!  USE infotrac_phy, ONLY : type_trac
+!#ifdef REPROBUS
+!  USE CHEM_REP, ONLY : Init_chem_rep_phys
+!#endif
+
+!  IMPLICIT NONE
+  
+!    INTEGER,INTENT(in) :: iim
+!    INTEGER,INTENT(in) :: jjp1
+!    INTEGER,INTENT(in) :: llm
+!    INTEGER,INTENT(in) :: nb_proc
+!    INTEGER,INTENT(in) :: distrib(0:nb_proc-1)
+
+
+!    CALL Init_grid_phy_lmdz(iim,jjp1,llm)
+!    CALL Init_phys_lmdz_para(iim,jjp1,nb_proc,distrib)
+!!$OMP PARALLEL
+!    CALL Init_dimphy(klon_omp,nbp_lev)
+!
+!! Initialization of Reprobus
+!    IF (type_trac == 'repr') THEN
+!#ifdef REPROBUS
+!       CALL Init_chem_rep_phys(klon_omp,nbp_lev)
+!#endif
+!    END IF
+!
+!!$OMP END PARALLEL
+ 
+!END SUBROUTINE Init_Phys_lmdz  
+
+
+
+
+
+
+
+
+END MODULE physics_distribution_mod
+
Index: /trunk/LMDZ.TITAN/libf/phy_common/regular_lonlat_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/regular_lonlat_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/regular_lonlat_mod.F90	(revision 1644)
@@ -0,0 +1,55 @@
+MODULE regular_lonlat_mod
+
+  ! Store information on the global physics grid
+  ! for a regular (longitude-latitude) grid
+  
+  INTEGER, PARAMETER :: north_east=1     ! boundaries of regular lontlat
+  INTEGER, PARAMETER :: north_west=2     ! boundaries of regular lontlat
+  INTEGER, PARAMETER :: south_west=3     ! boundaries of regular lontlat
+  INTEGER, PARAMETER :: south_east=4     ! boundaries of regular lontlat
+  INTEGER, PARAMETER :: east=1           ! boundaries of regular lontlat
+  INTEGER, PARAMETER :: west=2           ! boundaries of regular lontlat
+  INTEGER, PARAMETER :: north=1          ! boundaries of regular lontlat
+  INTEGER, PARAMETER :: south=2          ! boundaries of regular lontlat
+
+! Global definition, shared by all threads
+! Do not set threadprivate directives
+
+  REAL,SAVE,ALLOCATABLE :: lon_reg(:)      ! value of longitude cell (rad)
+
+  REAL,SAVE,ALLOCATABLE :: lat_reg(:)      ! value of longitude cell (rad)
+
+  REAL,SAVE,ALLOCATABLE :: boundslon_reg(:,:)      ! value of boundaries cell (1=>east, 2=>west)(rad)
+
+  REAL,SAVE,ALLOCATABLE :: boundslat_reg(:,:)      ! value of longitude cell (1=>north, 2=>south)(rad)
+
+
+CONTAINS
+  
+  SUBROUTINE init_regular_lonlat(nbp_lon, nbp_lat, lon_reg_, lat_reg_, boundslon_reg_, boundslat_reg_)
+    IMPLICIT NONE
+    INTEGER,INTENT(IN) :: nbp_lon
+    INTEGER,INTENT(IN) :: nbp_lat
+    REAL,   INTENT(IN) :: lon_reg_(nbp_lon)  
+    REAL,   INTENT(IN) :: lat_reg_(nbp_lat) 
+    REAL,   INTENT(IN) :: boundslon_reg_(nbp_lon,2) 
+    REAL,   INTENT(IN) :: boundslat_reg_(nbp_lat,2)  
+
+    
+    ALLOCATE(lon_reg(nbp_lon))
+    lon_reg(:)=lon_reg_(:)
+
+    ALLOCATE(lat_reg(nbp_lat)) 
+    lat_reg(:)=lat_reg_(:)
+
+    ALLOCATE(boundslon_reg(nbp_lon,2)) 
+    boundslon_reg(:,:)=boundslon_reg_(:,:)
+
+    ALLOCATE(boundslat_reg(nbp_lat,2))  
+    boundslat_reg(:,:)=boundslat_reg_(:,:)
+
+  
+  END SUBROUTINE init_regular_lonlat    
+
+END MODULE regular_lonlat_mod
+
Index: /trunk/LMDZ.TITAN/libf/phy_common/vertical_layers_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phy_common/vertical_layers_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phy_common/vertical_layers_mod.F90	(revision 1644)
@@ -0,0 +1,56 @@
+! $Id: $
+
+MODULE vertical_layers_mod
+
+   REAL,SAVE             :: preff  ! reference surface pressure (Pa)
+   REAL,SAVE             :: scaleheight ! atmospheric reference scale height (km)
+   REAL,SAVE,ALLOCATABLE :: ap(:) ! hybrid (pressure contribution) coordinate 
+                                  ! at layer interfaces (Pa)
+   REAL,SAVE,ALLOCATABLE :: bp(:) ! hybrid (sigma contribution) coordinate 
+                                  ! at layer interfaces
+   REAL,SAVE,ALLOCATABLE :: aps(:) ! hybrid (pressure contribution) coordinate 
+                                   ! at mid-layer (Pa)
+   REAL,SAVE,ALLOCATABLE :: bps(:) ! hybrid (sigma contribution) coordinate 
+                                   ! at mid-layer
+   REAL,SAVE,ALLOCATABLE :: presnivs(:) ! reference pressure at mid-layer (Pa),
+                                        ! based on preff, ap and bp
+   REAL,SAVE,ALLOCATABLE :: pseudoalt(:) ! pseudo-altitude of model layers (km),
+                                         ! based on preff and scaleheight
+   
+!$OMP THREADPRIVATE(preff,scaleheight,ap,bp,aps,bps,presnivs,pseudoalt)
+
+
+CONTAINS
+
+  SUBROUTINE init_vertical_layers(nlayer,preff_,scaleheight_,ap_,bp_,&
+                                 aps_,bps_,presnivs_, pseudoalt_)
+    IMPLICIT NONE
+    INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
+    REAL,INTENT(IN)    :: preff_ ! reference surface pressure (Pa)
+    REAL,INTENT(IN)    :: scaleheight_ ! atmospheric scale height (km)
+    REAL,INTENT(IN)    :: ap_(nlayer+1) ! hybrid coordinate at interfaces
+    REAL,INTENT(IN)    :: bp_(nlayer+1) ! hybrid coordinate at interfaces
+    REAL,INTENT(IN)    :: aps_(nlayer) ! hybrid coordinate at mid-layer
+    REAL,INTENT(IN)    :: bps_(nlayer) ! hybrid coordinate at mid-layer
+    REAL,INTENT(IN)    :: presnivs_(nlayer) ! Appproximative pressure of atm. layers (Pa)
+    REAL,INTENT(IN)    :: pseudoalt_(nlayer) ! pseudo-altitude of atm. layers (km)
+  
+    ALLOCATE(ap(nlayer+1))
+    ALLOCATE(bp(nlayer+1))
+    ALLOCATE(aps(nlayer))
+    ALLOCATE(bps(nlayer))
+    ALLOCATE(presnivs(nlayer))
+    ALLOCATE(pseudoalt(nlayer))
+  
+    preff = preff_
+    scaleheight=scaleheight_
+    ap(:) = ap_(:)
+    bp(:) = bp_(:)
+    aps(:) = aps_(:)
+    bps(:) = bps_(:)
+    presnivs(:) = presnivs_(:)
+    pseudoalt(:) = pseudoalt_(:)
+
+  END SUBROUTINE init_vertical_layers
+
+END MODULE vertical_layers_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/aerave.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/aerave.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/aerave.F	(revision 1644)
@@ -0,0 +1,182 @@
+      subroutine aerave( ndata,
+     &     longdata,epdata,omegdata,gdata,          
+     &     longref,epref,temp,nir,longir
+     &     ,epir,omegir,gir,qref )
+
+
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculate mean values of aerosol quantities in each band.
+!     
+!     Authors
+!     ------- 
+!     R. Fournier (1996) 
+!     F. Forget (1996)
+!     
+!     Called by
+!     ---------
+!     suaer_corrk.F90
+!     
+!     Calls
+!     -----
+!     blackl.F
+!     
+!==================================================================
+
+!     
+!     R.Fournier 02/1996 
+!     (modif F.Forget 02/1996)
+!     le spectre est decoupe en "nir" bandes et cette routine calcule
+!     les donnees radiatives moyenne sur chaque bande : l'optimisation
+!     est faite pour une temperature au sol "temp" et une epaisseur
+!     optique de l'atmosphere "epref" a la longueur d'onde "longref"
+!     
+!     dans la version actuelle, les ponderations sont independantes de
+!     l'epaisseur optique : c'est a dire que "omegir", "gir"
+!     et "epir/epre" sont independants de "epref".
+!     en effet les ponderations sont choisies pour une solution exacte
+!     en couche mince et milieu isotherme. 
+!     
+!     entree
+!     
+!     ndata : taille des champs data
+!     longdata,epdata,omegdata,gdata : proprietes radiative de l'aerosol
+!     (longdata longueur d'onde en METRES)
+!     * longref : longueur d'onde a laquelle l'epaisseur optique
+!     est connue
+!     * epref : epaisseur optique a longref
+!     * temp : temperature choisie pour la ponderation (Planck)
+!     * nir : nombre d'intervals dans la discretisation spectrale
+!     du GCM
+!     * longir : longueurs d'onde definissant ces intervals
+!     
+!     sortie
+!     
+!     * epir : epaisseur optique moyenne pour chaque interval
+!     * omegir : "scattering albedo" moyen pour chaque interval
+!     * gir : "assymetry factor" moyen pour chaque interval
+!     * qref : extinction coefficient at reference wavelength
+
+!=======================================================================
+! output
+
+      REAL longref
+      REAL epref
+      REAL temp
+      INTEGER nir
+      REAL*8 longir(nir+1)
+      REAL epir(nir)
+      REAL omegir(nir)
+      REAL gir(nir)
+
+!=======================================================================
+
+      INTEGER iir,nirmx
+      PARAMETER (nirmx=100)
+      INTEGER idata,ndata
+
+      DOUBLE PRECISION tmp1
+      REAL tmp2,tmp3
+
+!=======================================================================
+! input
+
+      REAL emit
+      REAL totalemit(nirmx)
+      REAL longdata(ndata),epdata(ndata)
+     &     ,omegdata(ndata),gdata(ndata)
+      REAL qextcorrdata(ndata)
+      INTEGER ibande,nbande
+      PARAMETER (nbande=1000)
+
+      REAL long,deltalong
+      INTEGER ilong
+      INTEGER i1,i2
+      REAL c1,c2
+      REAL factep,qextcorr,omeg,g,qref
+
+      long=longref
+
+
+!=======================================================================
+!     pre-interpolation
+      ilong=1
+      DO idata=2,ndata
+         IF (long.gt.longdata(idata)) ilong=idata
+      ENDDO
+      i1=ilong
+      i2=ilong+1
+      IF (i2.gt.ndata) i2=ndata
+      IF (long.lt.longdata(1)) i2=1
+      IF (i1.eq.i2) THEN
+         c1=1.E+0
+         c2=0.E+0
+      ELSE
+         c1=(longdata(i2)-long) / (longdata(i2)-longdata(i1))
+         c2=(longdata(i1)-long) / (longdata(i1)-longdata(i2))
+      ENDIF
+
+      qref=c1*epdata(i1)+c2*epdata(i2)
+      factep=qref/epref
+      DO idata=1,ndata
+         qextcorrdata(idata)=epdata(idata)/factep
+      ENDDO
+!=======================================================================
+
+      DO iir=1,nir
+
+         deltalong=(longir(iir+1)-longir(iir)) / nbande
+         totalemit(iir)=0.E+0
+         epir(iir)=0.E+0
+         omegir(iir)=0.E+0
+         gir(iir)=0.E+0
+
+         DO ibande=1,nbande
+
+            long=longir(iir) + (ibande-0.5E+0) * deltalong
+            CALL blackl(DBLE(long),DBLE(temp),tmp1)
+            emit=REAL(tmp1)
+
+!=======================================================================
+!     interpolation
+            ilong=1
+            DO idata=2,ndata
+               IF (long.gt.longdata(idata)) ilong=idata
+            ENDDO
+            i1=ilong
+            i2=ilong+1
+
+            IF (i2.gt.ndata) i2=ndata
+            IF (long.lt.longdata(1)) i2=1
+            IF (i1.eq.i2) THEN
+               c1=1.E+0
+               c2=0.E+0
+            ELSE
+               c1=(longdata(i2)-long) / (longdata(i2)-longdata(i1))
+               c2=(longdata(i1)-long) / (longdata(i1)-longdata(i2))
+            ENDIF
+!=======================================================================
+
+            qextcorr=c1*qextcorrdata(i1)+c2*qextcorrdata(i2)
+            omeg=c1*omegdata(i1)+c2*omegdata(i2)
+            g=c1*gdata(i1)+c2*gdata(i2)
+
+            totalemit(iir)=totalemit(iir)+deltalong*emit
+            epir(iir)=epir(iir)+deltalong*emit*qextcorr
+            omegir(iir)=omegir(iir)+deltalong*emit*omeg*qextcorr
+            gir(iir)=gir(iir)+deltalong*emit*omeg*qextcorr*g
+
+         ENDDO
+
+         gir(iir)=gir(iir)/omegir(iir)
+         omegir(iir)=omegir(iir)/epir(iir)
+         epir(iir)=epir(iir)/totalemit(iir)
+
+      ENDDO
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/aerave_new.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/aerave_new.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/aerave_new.F	(revision 1644)
@@ -0,0 +1,223 @@
+      SUBROUTINE aerave_new ( ndata,
+     & longdata,epdata,omegdata,gdata,          
+     &            longref,epref,temp,nir,longir
+     &            ,epir,omegir,gir,qref,omegaref        )
+
+
+      IMPLICIT NONE
+c.......................................................................
+c
+c R.Fournier 02/1996 
+c (modif F.Forget 02/1996)
+c le spectre est decoupe en "nir" bandes et cette routine calcule
+c les donnees radiatives moyenne sur chaque bande : l'optimisation
+c est faite pour une temperature au sol "temp" et une epaisseur
+c optique de l'atmosphere "epref" a la longueur d'onde "longref"
+c
+c dans la version actuelle, les ponderations sont independantes de
+c l'epaisseur optique : c'est a dire que "omegir", "gir"
+c et "epir/epre" sont independants de "epref".
+c en effet les ponderations sont choisies pour une solution exacte
+c en couche mince et milieu isotherme. 
+c
+c entree
+c
+c    ndata : taille des champs data
+c    longdata,epdata,omegdata,gdata : proprietes radiative de l'aerosol
+c                  (longdata longueur d'onde en METRES)
+c  * longref : longueur d'onde a laquelle l'epaisseur optique
+c              est connue
+c  * epref : epaisseur optique a longref
+c  * temp : temperature choisie pour la ponderation (Planck)
+c  * nir : nombre d'intervals dans la discretisation spectrale
+c           du GCM
+c  * longir : longueurs d'onde definissant ces intervals
+c
+c sortie
+c
+c  * epir : epaisseur optique moyenne pour chaque interval
+c  * omegir : "scattering albedo" moyen pour chaque interval
+c  * gir : "assymetry factor" moyen pour chaque interval
+c  * qref : extinction coefficient at reference wavelength
+c  * omegaref : single scat. albedo at reference wavelength
+c
+c.......................................................................
+c
+      REAL longref
+      REAL epref
+      REAL temp
+      INTEGER nir
+      REAL*8 longir(nir+1)
+      REAL epir(nir)
+      REAL omegir(nir)
+      REAL gir(nir)
+c
+c.......................................................................
+c
+      INTEGER iir,nirmx
+      PARAMETER (nirmx=100)
+      INTEGER idata,ndata
+c
+c.......................................................................
+c
+      REAL emit
+      REAL totalemit(nirmx)
+      REAL longdata(ndata),epdata(ndata)
+     &    ,omegdata(ndata),gdata(ndata)
+      REAL qextcorrdata(ndata)
+      INTEGER ibande,nbande
+      PARAMETER (nbande=1000)
+      REAL long,deltalong
+      INTEGER ilong
+      INTEGER i1,i2
+      REAL c1,c2
+      REAL factep,qextcorr,omeg,g
+      REAL qref,omegaref
+c
+c.......................................................................
+c
+      DOUBLE PRECISION tmp1
+      REAL tmp2,tmp3
+c
+c
+      long=longref
+
+
+      !if(nir.eq.27)then
+      !print*,'long',long
+      !print*,'longdata',longdata
+      !print*,'epdata',epdata
+      !print*,'omegdata',omegdata
+      !print*,'gdata',gdata
+      !print*,'data looks aok!'
+
+      !print*,'ndata=',ndata
+      !print*,'longdata',shape(longdata)
+      !print*,'epdata',shape(epdata)
+      !print*,'omegdata',shape(omegdata)
+      !print*,'gdata',shape(gdata)
+      ! print*,'longref',longref
+      !print*,'epref',epref
+      !print*,'temp',temp
+      !print*,'nir',nir
+      !print*,'longir',longir
+      !print*,'epir',epir
+      !print*,'omegir',gir
+      !print*,'qref',qref
+      !print*,'longir=',longir
+      !stop
+      !endif
+
+
+c********************************************************
+c interpolation
+      ilong=1
+      DO idata=2,ndata
+        IF (long.gt.longdata(idata)) ilong=idata
+      ENDDO
+      i1=ilong
+      i2=ilong+1
+      IF (i2.gt.ndata) i2=ndata
+      IF (long.lt.longdata(1)) i2=1
+      IF (i1.eq.i2) THEN
+        c1=1.E+0
+        c2=0.E+0
+      ELSE
+        c1=(longdata(i2)-long) / (longdata(i2)-longdata(i1))
+        c2=(longdata(i1)-long) / (longdata(i1)-longdata(i2))
+      ENDIF
+c********************************************************
+c
+      qref=c1*epdata(i1)+c2*epdata(i2)
+      omegaref=c1*omegdata(i1)+c2*omegdata(i2)
+      factep=qref/epref
+      DO idata=1,ndata
+        qextcorrdata(idata)=epdata(idata)/factep
+      ENDDO
+c
+c.......................................................................
+c
+      DO iir=1,nir
+c
+c.......................................................................
+c
+        deltalong=(longir(iir+1)-longir(iir)) / nbande
+        totalemit(iir)=0.E+0
+        epir(iir)=0.E+0
+        omegir(iir)=0.E+0
+        gir(iir)=0.E+0
+c
+c.......................................................................
+c
+        DO ibande=1,nbande
+c
+c.......................................................................
+c
+          long=longir(iir) + (ibande-0.5E+0) * deltalong
+          CALL blackl(DBLE(long),DBLE(temp),tmp1)
+          emit=REAL(tmp1)
+c
+c.......................................................................
+c
+c********************************************************
+c interpolation
+      ilong=1
+      DO idata=2,ndata
+        IF (long.gt.longdata(idata)) ilong=idata
+      ENDDO
+      i1=ilong
+      i2=ilong+1
+      IF (i2.gt.ndata) i2=ndata
+      IF (long.lt.longdata(1)) i2=1
+      IF (i1.eq.i2) THEN
+        c1=1.E+0
+        c2=0.E+0
+      ELSE
+        c1=(longdata(i2)-long) / (longdata(i2)-longdata(i1))
+        c2=(longdata(i1)-long) / (longdata(i1)-longdata(i2))
+      ENDIF
+c********************************************************
+c
+          qextcorr=c1*qextcorrdata(i1)+c2*qextcorrdata(i2)
+          omeg=c1*omegdata(i1)+c2*omegdata(i2)
+          g=c1*gdata(i1)+c2*gdata(i2)
+c
+c.......................................................................
+c
+          totalemit(iir)=totalemit(iir)+deltalong*emit
+          epir(iir)=epir(iir)+deltalong*emit*qextcorr
+          omegir(iir)=omegir(iir)+deltalong*emit*omeg*qextcorr
+          gir(iir)=gir(iir)+deltalong*emit*omeg*qextcorr*g
+c
+c.......................................................................
+c
+        ENDDO
+c
+c.......................................................................
+c
+        gir(iir)=gir(iir)/omegir(iir)
+        omegir(iir)=omegir(iir)/epir(iir)
+        epir(iir)=epir(iir)/totalemit(iir)
+c
+c.......................................................................
+c
+      ENDDO
+c
+c......................................................................
+c
+c     Diagnostic de controle si on moyenne sur tout le spectre vis ou IR :
+c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+c     tmp2=0.E+0
+c     DO iir=1,nir
+c       tmp2=tmp2+totalemit(iir)
+c     ENDDO
+c     tmp3=5.67E-8 * temp**4
+c     IF (abs((tmp2-tmp3)/tmp3).gt.0.05E+0) THEN
+c       PRINT *,'!!!! <---> il manque du Planck (voir moyenne.F)'
+c       PRINT *,'somme des bandes :',tmp2,'--- Planck:',tmp3
+c     ENDIF
+c
+c......................................................................
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/aeropacity.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/aeropacity.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/aeropacity.F90	(revision 1644)
@@ -0,0 +1,448 @@
+      Subroutine aeropacity(ngrid,nlayer,nq,pplay,pplev,pq, &
+         aerosol,reffrad,QREFvis3d,QREFir3d,tau_col,cloudfrac,totcloudfrac,clearsky)
+
+       use radinc_h, only : L_TAUMAX,naerkind
+       use aerosol_mod
+       USE tracer_h, only: noms,rho_co2,rho_ice
+       use comcstfi_mod, only: g
+       use callkeys_mod, only: aerofixco2,aerofixh2o,kastprof,cloudlvl,	&
+		CLFvarying,CLFfixval,dusttau,			 	&
+		pres_bottom_tropo,pres_top_tropo,obs_tau_col_tropo,	&
+		pres_bottom_strato,pres_top_strato,obs_tau_col_strato
+                  
+       implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Compute aerosol optical depth in each gridbox.
+!     
+!     Authors
+!     ------- 
+!     F. Forget
+!     F. Montmessin (water ice scheme) 
+!     update J.-B. Madeleine (2008)
+!     dust removal, simplification by Robin Wordsworth (2009)
+!
+!     Input
+!     ----- 
+!     ngrid             Number of horizontal gridpoints
+!     nlayer            Number of layers
+!     nq                Number of tracers
+!     pplev             Pressure (Pa) at each layer boundary
+!     pq                Aerosol mixing ratio
+!     reffrad(ngrid,nlayer,naerkind)         Aerosol effective radius
+!     QREFvis3d(ngrid,nlayer,naerkind) \ 3d extinction coefficients
+!     QREFir3d(ngrid,nlayer,naerkind)  / at reference wavelengths
+!
+!     Output
+!     ------
+!     aerosol            Aerosol optical depth in layer l, grid point ig
+!     tau_col            Total column optical depth at grid point ig
+!
+!=======================================================================
+
+      INTEGER,INTENT(IN) :: ngrid  ! number of atmospheric columns
+      INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
+      INTEGER,INTENT(IN) :: nq     ! number of tracers
+      REAL,INTENT(IN) :: pplay(ngrid,nlayer) ! mid-layer pressure (Pa)
+      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      REAL,INTENT(IN) :: pq(ngrid,nlayer,nq) ! tracers (.../kg_of_air)
+      REAL,INTENT(OUT) :: aerosol(ngrid,nlayer,naerkind) ! aerosol optical depth
+      REAL,INTENT(IN) :: reffrad(ngrid,nlayer,naerkind) ! aerosol effective radius
+      REAL,INTENT(IN) :: QREFvis3d(ngrid,nlayer,naerkind) ! extinction coefficient in the visible
+      REAL,INTENT(IN) :: QREFir3d(ngrid,nlayer,naerkind)
+      REAL,INTENT(OUT):: tau_col(ngrid) !column integrated visible optical depth
+      ! BENJAMIN MODIFS
+      real,intent(in) :: cloudfrac(ngrid,nlayer) ! cloud fraction
+      real,intent(out) :: totcloudfrac(ngrid) ! total cloud fraction
+      logical,intent(in) :: clearsky
+
+      real aerosol0
+
+      INTEGER l,ig,iq,iaer
+
+      LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+      REAL CBRT
+      EXTERNAL CBRT
+
+      INTEGER,SAVE :: i_co2ice=0      ! co2 ice
+      INTEGER,SAVE :: i_h2oice=0      ! water ice
+!$OMP THREADPRIVATE(i_co2ice,i_h2oice)
+      CHARACTER(LEN=20) :: tracername ! to temporarily store text
+
+      ! for fixed dust profiles
+      real topdust, expfactor, zp
+      REAL taudusttmp(ngrid) ! Temporary dust opacity used before scaling
+      REAL tauh2so4tmp(ngrid) ! Temporary h2so4 opacity used before scaling
+
+      real CLFtot
+
+      ! identify tracers
+      IF (firstcall) THEN
+
+        write(*,*) "Tracers found in aeropacity:"
+        do iq=1,nq
+          tracername=noms(iq)
+          if (tracername.eq."co2_ice") then
+            i_co2ice=iq
+          write(*,*) "i_co2ice=",i_co2ice
+
+          endif
+          if (tracername.eq."h2o_ice") then
+            i_h2oice=iq
+            write(*,*) "i_h2oice=",i_h2oice
+          endif
+        enddo
+
+        if (noaero) then
+          print*, "No active aerosols found in aeropacity"
+        else
+          print*, "If you would like to use aerosols, make sure any old"
+          print*, "start files are updated in newstart using the option"
+          print*, "q=0"
+          write(*,*) "Active aerosols found in aeropacity:"
+        endif
+
+        if ((iaero_co2.ne.0).and.(.not.noaero)) then
+          print*, 'iaero_co2=  ',iaero_co2
+        endif
+        if (iaero_h2o.ne.0) then
+          print*,'iaero_h2o=  ',iaero_h2o    
+        endif
+        if (iaero_dust.ne.0) then
+          print*,'iaero_dust= ',iaero_dust
+        endif
+        if (iaero_h2so4.ne.0) then
+          print*,'iaero_h2so4= ',iaero_h2so4
+        endif
+        if (iaero_back2lay.ne.0) then
+          print*,'iaero_back2lay= ',iaero_back2lay
+        endif
+
+        firstcall=.false.
+      ENDIF ! of IF (firstcall)
+
+
+!     ---------------------------------------------------------
+!==================================================================
+!    CO2 ice aerosols
+!==================================================================
+
+      if (iaero_co2.ne.0) then
+           iaer=iaero_co2
+!       1. Initialization
+            aerosol(1:ngrid,1:nlayer,iaer)=0.0
+!       2. Opacity calculation
+            if (noaero) then ! aerosol set to zero
+             aerosol(1:ngrid,1:nlayer,iaer)=0.0
+            elseif (aerofixco2.or.(i_co2ice.eq.0)) then !  CO2 ice cloud prescribed
+               aerosol(1:ngrid,1:nlayer,iaer)=1.e-9
+               !aerosol(1:ngrid,12,iaer)=4.0 ! single cloud layer option
+            else
+               DO ig=1, ngrid
+                  DO l=1,nlayer-1 ! to stop the rad tran bug
+
+                     aerosol0 =                         &
+                          (  0.75 * QREFvis3d(ig,l,iaer) /        &
+                          ( rho_co2 * reffrad(ig,l,iaer) )  ) *   &
+                          ( pq(ig,l,i_co2ice) + 1.E-9 ) *         &
+                          ( pplev(ig,l) - pplev(ig,l+1) ) / g
+                     aerosol0           = max(aerosol0,1.e-9)
+                     aerosol0           = min(aerosol0,L_TAUMAX)
+                     aerosol(ig,l,iaer) = aerosol0
+!                     aerosol(ig,l,iaer) = 0.0
+!                     print*, aerosol(ig,l,iaer)
+!        using cloud fraction
+!                     aerosol(ig,l,iaer) = -log(1 - CLF + CLF*exp(-aerosol0/CLF))
+!                     aerosol(ig,l,iaer) = min(aerosol(ig,l,iaer),L_TAUMAX)
+
+
+                  ENDDO
+               ENDDO
+            end if ! if fixed or varying
+      end if ! if CO2 aerosols   
+!==================================================================
+!     Water ice / liquid 
+!==================================================================
+
+      if (iaero_h2o.ne.0) then 
+           iaer=iaero_h2o
+!       1. Initialization
+            aerosol(1:ngrid,1:nlayer,iaer)=0.0
+!       2. Opacity calculation
+            if (aerofixh2o.or.(i_h2oice.eq.0).or.clearsky) then
+               aerosol(1:ngrid,1:nlayer,iaer) =1.e-9
+
+               ! put cloud at cloudlvl
+               if(kastprof.and.(cloudlvl.ne.0.0))then
+                  ig=1
+                  do l=1,nlayer
+                     if(int(cloudlvl).eq.l)then
+                     !if(cloudlvl.gt.(pplay(ig,l)/pplev(ig,1)))then
+                        print*,'Inserting cloud at level ',l
+                        !aerosol(ig,l,iaer)=10.0
+
+                        rho_ice=920.0
+
+                        ! the Kasting approximation
+                        aerosol(ig,l,iaer) =                      &
+                          (  0.75 * QREFvis3d(ig,l,iaer) /        &
+                          ( rho_ice * reffrad(ig,l,iaer) )  ) *   &
+                          !( pq(ig,l,i_h2oice) + 1.E-9 ) *         &
+                          ( 4.0e-4 + 1.E-9 ) *         &
+                          ( pplev(ig,l) - pplev(ig,l+1) ) / g
+
+
+                        open(115,file='clouds.out',form='formatted')
+                        write(115,*) l,aerosol(ig,l,iaer)
+                        close(115)
+
+                        return
+                     endif
+                  end do
+
+                  call abort
+               endif
+
+            else
+
+               do ig=1, ngrid
+                  do l=1,nlayer-1 ! to stop the rad tran bug
+
+                     aerosol(ig,l,iaer) =                                    & !modification by BC
+                          (  0.75 * QREFvis3d(ig,l,iaer) /        &
+                          ( rho_ice * reffrad(ig,l,iaer) )  ) *   &
+                          !  pq(ig,l,i_h2oice) *                   & !JL I dropped the +1e-9 here to have the same
+                          !( pplev(ig,l) - pplev(ig,l+1) ) / g       !   opacity in the clearsky=true and the 
+                                                                     !   clear=false/pq=0 case
+                          ( pq(ig,l,i_h2oice) + 1.E-9 ) *         & ! Doing this makes the code unstable, so I have restored it (RW)
+                          ( pplev(ig,l) - pplev(ig,l+1) ) / g 
+
+                  enddo
+               enddo
+
+               if(CLFvarying)then
+                  call totalcloudfrac(ngrid,nlayer,nq,cloudfrac,totcloudfrac,pplev,pq,aerosol(1,1,iaer))
+                  do ig=1, ngrid
+                     do l=1,nlayer-1 ! to stop the rad tran bug
+                        CLFtot  = max(totcloudfrac(ig),0.01)
+                        aerosol(ig,l,iaer)=aerosol(ig,l,iaer)/CLFtot
+                        aerosol(ig,l,iaer) = max(aerosol(ig,l,iaer),1.e-9)
+                     enddo
+                  enddo
+               else
+                  do ig=1, ngrid
+                     do l=1,nlayer-1 ! to stop the rad tran bug
+                        CLFtot  = CLFfixval
+                        aerosol(ig,l,iaer)=aerosol(ig,l,iaer)/CLFtot
+                        aerosol(ig,l,iaer) = max(aerosol(ig,l,iaer),1.e-9)
+                     enddo
+                  enddo
+              end if!(CLFvarying)
+            endif !(aerofixed.or.(i_h2oice.eq.0).or.clearsky)
+	      
+      end if ! End if h2o aerosol
+
+!==================================================================
+!             Dust 
+!==================================================================
+      if (iaero_dust.ne.0) then
+          iaer=iaero_dust
+!         1. Initialization 
+          aerosol(1:ngrid,1:nlayer,iaer)=0.0
+          
+          topdust=30.0 ! km  (used to be 10.0 km) LK
+
+!       2. Opacity calculation
+
+!           expfactor=0.
+           DO l=1,nlayer-1
+             DO ig=1,ngrid
+!             Typical mixing ratio profile
+
+                 zp=(pplev(ig,1)/pplay(ig,l))**(70./topdust)
+                 expfactor=max(exp(0.007*(1.-max(zp,1.))),1.e-3)
+
+!             Vertical scaling function
+              aerosol(ig,l,iaer)= (pplev(ig,l)-pplev(ig,l+1)) &
+               *expfactor
+
+
+             ENDDO
+           ENDDO
+
+!          Rescaling each layer to reproduce the choosen (or assimilated)
+!          dust extinction opacity at visible reference wavelength, which
+!          is scaled to the surface pressure pplev(ig,1)
+
+            taudusttmp(1:ngrid)=0.
+              DO l=1,nlayer
+                DO ig=1,ngrid
+                   taudusttmp(ig) = taudusttmp(ig) &
+                          +  aerosol(ig,l,iaer)
+                ENDDO
+              ENDDO
+            DO l=1,nlayer-1
+               DO ig=1,ngrid
+                  aerosol(ig,l,iaer) = max(1E-20, &
+                          dusttau &
+                       *  pplev(ig,1) / pplev(ig,1) &
+                       *  aerosol(ig,l,iaer) &
+                       /  taudusttmp(ig))
+
+              ENDDO
+            ENDDO
+      end if ! If dust aerosol   
+
+!==================================================================
+!           H2SO4 
+!==================================================================
+! added by LK
+      if (iaero_h2so4.ne.0) then
+         iaer=iaero_h2so4
+
+!       1. Initialization
+         aerosol(1:ngrid,1:nlayer,iaer)=0.0
+
+
+!       2. Opacity calculation
+
+!           expfactor=0.
+         DO l=1,nlayer-1
+            DO ig=1,ngrid
+!              Typical mixing ratio profile
+
+               zp=(pplev(ig,1)/pplay(ig,l))**(70./30) !emulating topdust
+               expfactor=max(exp(0.007*(1.-max(zp,1.))),1.e-3)
+
+!             Vertical scaling function
+               aerosol(ig,l,iaer)= (pplev(ig,l)-pplev(ig,l+1))*expfactor
+
+            ENDDO
+         ENDDO
+         tauh2so4tmp(1:ngrid)=0.
+         DO l=1,nlayer
+            DO ig=1,ngrid
+               tauh2so4tmp(ig) = tauh2so4tmp(ig) + aerosol(ig,l,iaer)
+            ENDDO
+         ENDDO
+         DO l=1,nlayer-1
+            DO ig=1,ngrid
+               aerosol(ig,l,iaer) = max(1E-20, &
+                          1 &
+                       *  pplev(ig,1) / pplev(ig,1) &
+                       *  aerosol(ig,l,iaer) &
+                       /  tauh2so4tmp(ig))
+
+            ENDDO
+         ENDDO
+
+! 1/700. is assuming a "sulfurtau" of 1
+! Sulfur aerosol routine to be improved.
+!                     aerosol0 =                         &
+!                          (  0.75 * QREFvis3d(ig,l,iaer) /        &
+!                          ( rho_h2so4 * reffrad(ig,l,iaer) )  ) *   &
+!                          ( pq(ig,l,i_h2so4) + 1.E-9 ) *         &
+!                          ( pplev(ig,l) - pplev(ig,l+1) ) / g
+!                     aerosol0           = max(aerosol0,1.e-9)
+!                     aerosol0           = min(aerosol0,L_TAUMAX)
+!                     aerosol(ig,l,iaer) = aerosol0
+
+!                  ENDDO
+!               ENDDO
+      end if
+ 
+           
+!     ---------------------------------------------------------
+!==================================================================
+!    Two-layer aerosols (unknown composition)
+!    S. Guerlet (2013)
+!==================================================================
+
+      if (iaero_back2lay .ne.0) then
+           iaer=iaero_back2lay
+!       1. Initialization
+            aerosol(1:ngrid,1:nlayer,iaer)=0.0
+!       2. Opacity calculation
+          DO ig=1,ngrid
+           DO l=1,nlayer-1
+             aerosol(ig,l,iaer) = ( pplev(ig,l) - pplev(ig,l+1) )
+             !! 1. below tropospheric layer: no aerosols
+             IF (pplev(ig,l) .gt. pres_bottom_tropo) THEN
+               aerosol(ig,l,iaer) = 0.*aerosol(ig,l,iaer)
+             !! 2. tropo layer
+             ELSEIF (pplev(ig,l) .le. pres_bottom_tropo .and. pplev(ig,l) .ge. pres_top_tropo) THEN
+               aerosol(ig,l,iaer) = obs_tau_col_tropo*aerosol(ig,l,iaer)
+             !! 3. linear transition
+             ELSEIF (pplev(ig,l) .lt. pres_top_tropo .and. pplev(ig,l) .gt. pres_bottom_strato) THEN
+               expfactor=log(obs_tau_col_strato/obs_tau_col_tropo)/log(pres_bottom_strato/pres_top_tropo)
+               aerosol(ig,l,iaer)= obs_tau_col_tropo*((pplev(ig,l)/pres_top_tropo)**expfactor)*aerosol(ig,l,iaer)/1.5
+             !! 4. strato layer
+             ELSEIF (pplev(ig,l) .le. pres_bottom_strato .and. pplev(ig,l) .gt. pres_top_strato) THEN
+               aerosol(ig,l,iaer)= obs_tau_col_strato*aerosol(ig,l,iaer)
+             !! 5. above strato layer: no aerosols
+             ELSEIF (pplev(ig,l) .lt. pres_top_strato) THEN
+               aerosol(ig,l,iaer) = 0.*aerosol(ig,l,iaer)
+             ENDIF
+	   ENDDO
+          ENDDO
+
+ !       3. Re-normalize to observed total column
+         tau_col(:)=0.0
+         DO l=1,nlayer
+          DO ig=1,ngrid
+               tau_col(ig) = tau_col(ig) &
+                     + aerosol(ig,l,iaer)/(obs_tau_col_tropo+obs_tau_col_strato)
+            ENDDO
+         ENDDO
+
+         DO ig=1,ngrid
+           DO l=1,nlayer-1
+                aerosol(ig,l,iaer)=aerosol(ig,l,iaer)/tau_col(ig)
+           ENDDO
+         ENDDO
+
+
+      end if ! if Two-layer aerosols  
+
+
+! --------------------------------------------------------------------------
+! Column integrated visible optical depth in each point (used for diagnostic)
+
+      tau_col(:)=0.0
+      do iaer = 1, naerkind
+         do l=1,nlayer
+            do ig=1,ngrid
+               tau_col(ig) = tau_col(ig) + aerosol(ig,l,iaer)
+            end do
+         end do
+      end do
+
+      do ig=1,ngrid
+         do l=1,nlayer
+            do iaer = 1, naerkind
+               if(aerosol(ig,l,iaer).gt.1.e3)then
+                  print*,'WARNING: aerosol=',aerosol(ig,l,iaer)
+                  print*,'at ig=',ig,',  l=',l,', iaer=',iaer
+                  print*,'QREFvis3d=',QREFvis3d(ig,l,iaer)
+                  print*,'reffrad=',reffrad(ig,l,iaer)
+               endif
+            end do
+         end do
+      end do
+
+      do ig=1,ngrid
+         if(tau_col(ig).gt.1.e3)then
+            print*,'WARNING: tau_col=',tau_col(ig)
+            print*,'at ig=',ig
+            print*,'aerosol=',aerosol(ig,:,:)
+            print*,'QREFvis3d=',QREFvis3d(ig,:,:)
+            print*,'reffrad=',reffrad(ig,:,:)
+         endif
+      end do
+      return
+    end subroutine aeropacity
+      
Index: /trunk/LMDZ.TITAN/libf/phytitan/aeroptproperties.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/aeroptproperties.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/aeroptproperties.F90	(revision 1644)
@@ -0,0 +1,754 @@
+      SUBROUTINE aeroptproperties(ngrid,nlayer,reffrad,nueffrad,   &
+                                  QVISsQREF3d,omegaVIS3d,gVIS3d,   &
+                                  QIRsQREF3d,omegaIR3d,gIR3d,      &
+                                  QREFvis3d,QREFir3d)!,		   &
+!                                  omegaREFvis3d,omegaREFir3d)
+
+      use radinc_h,    only: L_NSPECTI,L_NSPECTV,nsizemax,naerkind
+      use radcommon_h, only: QVISsQREF,omegavis,gvis,QIRsQREF,omegair,gir
+      use radcommon_h, only: qrefvis,qrefir,omegarefvis,omegarefir
+      use radcommon_h, only: radiustab,nsize
+
+      implicit none
+
+!     =============================================================
+!     Aerosol Optical Properties
+!
+!     Description:
+!       Compute the scattering parameters in each grid
+!       box, depending on aerosol grain sizes. Log-normal size
+!       distribution and Gauss-Legendre integration are used.
+
+!     Parameters:
+!       Don't forget to set the value of varyingnueff below; If
+!       the effective variance of the distribution for the given
+!       aerosol is considered homogeneous in the atmosphere, please
+!       set varyingnueff(iaer) to .false. Resulting computational
+!       time will be much better.
+
+!     Authors: J.-B. Madeleine, F. Forget, F. Montmessin
+!     Slightly modified and converted to F90 by R. Wordsworth (2009)
+!     Varying nueff section removed by R. Wordsworth for simplicity
+!     ==============================================================
+
+!     Local variables 
+!     ---------------
+
+
+
+!     =============================================================
+      LOGICAL, PARAMETER :: varyingnueff(naerkind) = .false.
+!     =============================================================
+
+!     Min. and max radius of the interpolation grid (in METERS)
+      REAL, PARAMETER :: refftabmin = 2e-8 !2e-8
+!      REAL, PARAMETER :: refftabmax = 35e-6
+      REAL, PARAMETER :: refftabmax = 1e-3
+!     Log of the min and max variance of the interpolation grid
+      REAL, PARAMETER :: nuefftabmin = -4.6
+      REAL, PARAMETER :: nuefftabmax = 0.
+!     Number of effective radius of the interpolation grid
+      INTEGER, PARAMETER :: refftabsize = 200
+!     Number of effective variances of the interpolation grid
+!      INTEGER, PARAMETER :: nuefftabsize = 100
+      INTEGER, PARAMETER :: nuefftabsize = 1
+!     Interpolation grid indices (reff,nueff)
+      INTEGER :: grid_i,grid_j
+!     Intermediate variable
+      REAL :: var_tmp,var3d_tmp(ngrid,nlayer)
+!     Bilinear interpolation factors
+      REAL :: kx,ky,k1,k2,k3,k4
+!     Size distribution parameters
+      REAL :: sizedistk1,sizedistk2
+!     Pi!
+      REAL,SAVE :: pi
+!$OMP THREADPRIVATE(pi)
+!     Variables used by the Gauss-Legendre integration:
+      INTEGER radius_id,gausind
+      REAL kint
+      REAL drad
+      INTEGER, PARAMETER :: ngau = 10
+      REAL weightgaus(ngau),radgaus(ngau)
+      SAVE weightgaus,radgaus
+!      DATA weightgaus/.2955242247,.2692667193,.2190863625,.1494513491,.0666713443/
+!      DATA radgaus/.1488743389,.4333953941,.6794095682,.8650633666,.9739065285/
+      DATA    radgaus/0.07652652113350,0.22778585114165, &
+                      0.37370608871528,0.51086700195146, &
+                      0.63605368072468,0.74633190646476, &
+                      0.83911697181213,0.91223442826796, &
+                      0.96397192726078,0.99312859919241/
+
+      DATA weightgaus/0.15275338723120,0.14917298659407, &
+                      0.14209610937519,0.13168863843930, &
+                      0.11819453196154,0.10193011980823, &
+                      0.08327674160932,0.06267204829828, &
+                      0.04060142982019,0.01761400714091/
+!$OMP THREADPRIVATE(radgaus,weightgaus)
+!     Indices
+      INTEGER :: i,j,k,l,m,iaer,idomain
+      INTEGER :: ig,lg,chg
+
+!     Local saved variables
+!     ---------------------
+
+!     Radius axis of the interpolation grid
+      REAL,SAVE :: refftab(refftabsize)
+!     Variance axis of the interpolation grid
+      REAL,SAVE :: nuefftab(nuefftabsize)
+!     Volume ratio of the grid
+      REAL,SAVE :: logvratgrid,vratgrid
+!     Grid used to remember which calculation is done
+      LOGICAL,SAVE :: checkgrid(refftabsize,nuefftabsize,naerkind,2) = .false.
+!$OMP THREADPRIVATE(refftab,nuefftab,logvratgrid,vratgrid,checkgrid)
+!     Optical properties of the grid (VISIBLE)
+      REAL,SAVE :: qsqrefVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
+      REAL,SAVE :: qextVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
+      REAL,SAVE :: qscatVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
+      REAL,SAVE :: omegVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
+      REAL,SAVE :: gVISgrid(refftabsize,nuefftabsize,L_NSPECTV,naerkind)
+!$OMP THREADPRIVATE(qsqrefVISgrid,qextVISgrid,qscatVISgrid,omegVISgrid,gVISgrid)
+!     Optical properties of the grid (INFRARED)
+      REAL,SAVE :: qsqrefIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
+      REAL,SAVE :: qextIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
+      REAL,SAVE :: qscatIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
+      REAL,SAVE :: omegIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
+      REAL,SAVE :: gIRgrid(refftabsize,nuefftabsize,L_NSPECTI,naerkind)
+!$OMP THREADPRIVATE(qsqrefIRgrid,qextIRgrid,qscatIRgrid,omegIRgrid,gIRgrid)
+!     Optical properties of the grid (REFERENCE WAVELENGTHS)
+      REAL,SAVE :: qrefVISgrid(refftabsize,nuefftabsize,naerkind)
+      REAL,SAVE :: qscatrefVISgrid(refftabsize,nuefftabsize,naerkind)
+      REAL,SAVE :: qrefIRgrid(refftabsize,nuefftabsize,naerkind)
+      REAL,SAVE :: qscatrefIRgrid(refftabsize,nuefftabsize,naerkind)
+      REAL,SAVE :: omegrefVISgrid(refftabsize,nuefftabsize,naerkind)
+      REAL,SAVE :: omegrefIRgrid(refftabsize,nuefftabsize,naerkind)
+!$OMP THREADPRIVATE(qrefVISgrid,qscatrefVISgrid,qrefIRgrid,qscatrefIRgrid,omegrefVISgrid,&
+	!$OMP omegrefIRgrid)
+!     Firstcall
+      LOGICAL,SAVE :: firstcall = .true.
+!$OMP THREADPRIVATE(firstcall)
+!     Variables used by the Gauss-Legendre integration:
+      REAL,SAVE :: normd(refftabsize,nuefftabsize,naerkind,2)
+      REAL,SAVE :: dista(refftabsize,nuefftabsize,naerkind,2,ngau)
+      REAL,SAVE :: distb(refftabsize,nuefftabsize,naerkind,2,ngau)
+!$OMP THREADPRIVATE(normd,dista,distb)
+
+      REAL,SAVE :: radGAUSa(ngau,naerkind,2)
+      REAL,SAVE :: radGAUSb(ngau,naerkind,2)
+!$OMP THREADPRIVATE(radGAUSa,radGAUSb)
+
+      REAL,SAVE :: qsqrefVISa(L_NSPECTV,ngau,naerkind)
+      REAL,SAVE :: qrefVISa(ngau,naerkind)
+      REAL,SAVE :: qsqrefVISb(L_NSPECTV,ngau,naerkind)
+      REAL,SAVE :: qrefVISb(ngau,naerkind)
+      REAL,SAVE :: omegVISa(L_NSPECTV,ngau,naerkind)
+      REAL,SAVE :: omegrefVISa(ngau,naerkind)
+      REAL,SAVE :: omegVISb(L_NSPECTV,ngau,naerkind)
+      REAL,SAVE :: omegrefVISb(ngau,naerkind)
+      REAL,SAVE :: gVISa(L_NSPECTV,ngau,naerkind)
+      REAL,SAVE :: gVISb(L_NSPECTV,ngau,naerkind)
+!$OMP THREADPRIVATE(qsqrefVISa,qrefVISa,qsqrefVISb,qrefVISb,omegVISa, &
+	!$OMP omegrefVISa,omegVISb,omegrefVISb,gVISa,gVISb)
+
+      REAL,SAVE :: qsqrefIRa(L_NSPECTI,ngau,naerkind)
+      REAL,SAVE :: qrefIRa(ngau,naerkind)
+      REAL,SAVE :: qsqrefIRb(L_NSPECTI,ngau,naerkind)
+      REAL,SAVE :: qrefIRb(ngau,naerkind)
+      REAL,SAVE :: omegIRa(L_NSPECTI,ngau,naerkind)
+      REAL,SAVE :: omegrefIRa(ngau,naerkind)
+      REAL,SAVE :: omegIRb(L_NSPECTI,ngau,naerkind)
+      REAL,SAVE :: omegrefIRb(ngau,naerkind)
+      REAL,SAVE :: gIRa(L_NSPECTI,ngau,naerkind)
+      REAL,SAVE :: gIRb(L_NSPECTI,ngau,naerkind)
+!$OMP THREADPRIVATE(qsqrefIRa,qrefIRa,qsqrefIRb,qrefIRb,omegIRa,omegrefIRa,&
+	!$OMP omegIRb,omegrefIRb,gIRa,gIRb)
+
+      REAL :: radiusm
+      REAL :: radiusr
+
+!     Inputs
+!     ------
+
+      INTEGER :: ngrid,nlayer
+!     Aerosol effective radius used for radiative transfer (meter)
+      REAL,INTENT(IN) :: reffrad(ngrid,nlayer,naerkind)
+!     Aerosol effective variance used for radiative transfer (n.u.)
+      REAL,INTENT(IN) :: nueffrad(ngrid,nlayer,naerkind)
+
+!     Outputs
+!     -------
+
+      REAL,INTENT(OUT) :: QVISsQREF3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL,INTENT(OUT) :: omegaVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL,INTENT(OUT) :: gVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+
+      REAL,INTENT(OUT) :: QIRsQREF3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL,INTENT(OUT) :: omegaIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL,INTENT(OUT) :: gIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+
+      REAL,INTENT(OUT) :: QREFvis3d(ngrid,nlayer,naerkind)
+      REAL,INTENT(OUT) :: QREFir3d(ngrid,nlayer,naerkind)
+
+      REAL :: omegaREFvis3d(ngrid,nlayer,naerkind)
+      REAL :: omegaREFir3d(ngrid,nlayer,naerkind)
+
+      DO iaer = 1, naerkind ! Loop on aerosol kind
+        IF ( (nsize(iaer,1).EQ.1).AND.(nsize(iaer,2).EQ.1) ) THEN
+!==================================================================
+!       If there is one single particle size, optical
+!         properties of the considered aerosol are homogeneous
+          DO lg = 1, nlayer
+            DO ig = 1, ngrid
+              DO chg = 1, L_NSPECTV
+                QVISsQREF3d(ig,lg,chg,iaer)=QVISsQREF(chg,iaer,1)
+                omegaVIS3d(ig,lg,chg,iaer)=omegaVIS(chg,iaer,1)
+                gVIS3d(ig,lg,chg,iaer)=gVIS(chg,iaer,1)
+              ENDDO
+              DO chg = 1, L_NSPECTI
+                QIRsQREF3d(ig,lg,chg,iaer)=QIRsQREF(chg,iaer,1)
+                omegaIR3d(ig,lg,chg,iaer)=omegaIR(chg,iaer,1)
+                gIR3d(ig,lg,chg,iaer)=gIR(chg,iaer,1)
+              ENDDO
+              QREFvis3d(ig,lg,iaer)=QREFvis(iaer,1)
+              QREFir3d(ig,lg,iaer)=QREFir(iaer,1)
+              omegaREFvis3d(ig,lg,iaer)=omegaREFvis(iaer,1)
+              omegaREFir3d(ig,lg,iaer)=omegaREFir(iaer,1)
+            ENDDO
+          ENDDO
+
+
+          if (firstcall) then
+             print*,'Optical prop. of the aerosol are homogenous for:'
+             print*,'iaer = ',iaer
+          endif
+
+        ELSE ! Varying effective radius and variance
+      DO idomain = 1, 2 ! Loop on visible or infrared channel
+!==================================================================
+!     1. Creating the effective radius and variance grid
+!     --------------------------------------------------
+      IF (firstcall) THEN
+
+!       1.1 Pi!
+        pi = 2. * asin(1.e0)
+
+!       1.2 Effective radius
+        refftab(1)    = refftabmin
+        refftab(refftabsize) = refftabmax
+
+        logvratgrid = log(refftabmax/refftabmin) / float(refftabsize-1)*3.
+        vratgrid = exp(logvratgrid)
+
+        do i = 2, refftabsize-1
+          refftab(i) = refftab(i-1)*vratgrid**(1./3.)
+        enddo
+
+!       1.3 Effective variance
+        if(nuefftabsize.eq.1)then ! addded by RDW
+           print*,'Warning: no variance range in aeroptproperties'
+           nuefftab(1)=0.2
+        else
+           do i = 0, nuefftabsize-1
+              nuefftab(i+1) = exp( nuefftabmin + i*(nuefftabmax-nuefftabmin)/(nuefftabsize-1) )
+           enddo
+        endif
+
+        firstcall = .false.
+      ENDIF
+
+!       1.4 Radius middle point and range for Gauss integration
+        radiusm=0.5*(radiustab(iaer,idomain,nsize(iaer,idomain)) + radiustab(iaer,idomain,1))
+        radiusr=0.5*(radiustab(iaer,idomain,nsize(iaer,idomain)) - radiustab(iaer,idomain,1))
+
+!       1.5 Interpolating data at the Gauss quadrature points:
+        DO gausind=1,ngau
+          drad=radiusr*radgaus(gausind)
+          radGAUSa(gausind,iaer,idomain)=radiusm-drad
+
+          radius_id=minloc(abs(radiustab(iaer,idomain,:) - (radiusm-drad)),DIM=1)
+          IF ((radiustab(iaer,idomain,radius_id) - (radiusm-drad)).GT.0) THEN
+            radius_id=radius_id-1
+          ENDIF
+          IF (radius_id.GE.nsize(iaer,idomain)) THEN
+            radius_id=nsize(iaer,idomain)-1
+            kint = 1.
+          ELSEIF (radius_id.LT.1) THEN
+            radius_id=1
+            kint = 0.
+          ELSE
+          kint = ( (radiusm-drad) -				&
+                   radiustab(iaer,idomain,radius_id) ) /	&
+                 ( radiustab(iaer,idomain,radius_id+1) -	&
+                   radiustab(iaer,idomain,radius_id) )
+          ENDIF
+          IF (idomain.EQ.1) THEN ! VISIBLE DOMAIN -----------------
+            DO m=1,L_NSPECTV
+               qsqrefVISa(m,gausind,iaer)=                      &
+                    (1-kint)*QVISsQREF(m,iaer,radius_id) +      &
+                    kint*QVISsQREF(m,iaer,radius_id+1)
+            omegVISa(m,gausind,iaer)=                           &
+                    (1-kint)*omegaVIS(m,iaer,radius_id) +       &
+                    kint*omegaVIS(m,iaer,radius_id+1)
+            gVISa(m,gausind,iaer)=                              &
+                    (1-kint)*gVIS(m,iaer,radius_id) +           &
+                    kint*gVIS(m,iaer,radius_id+1)
+            ENDDO
+            qrefVISa(gausind,iaer)=                             &
+                    (1-kint)*QREFvis(iaer,radius_id) +          &
+                    kint*QREFvis(iaer,radius_id+1)
+            omegrefVISa(gausind,iaer)=                          &
+                    (1-kint)*omegaREFvis(iaer,radius_id) +      &
+                    kint*omegaREFvis(iaer,radius_id+1)
+          ELSE ! INFRARED DOMAIN ----------------------------------
+            DO m=1,L_NSPECTI
+            qsqrefIRa(m,gausind,iaer)=                          &
+                    (1-kint)*QIRsQREF(m,iaer,radius_id) +       &
+                    kint*QIRsQREF(m,iaer,radius_id+1)
+            omegIRa(m,gausind,iaer)=                            &
+                    (1-kint)*omegaIR(m,iaer,radius_id) +        &
+                    kint*omegaIR(m,iaer,radius_id+1)
+            gIRa(m,gausind,iaer)=                               &
+                    (1-kint)*gIR(m,iaer,radius_id) +            &
+                    kint*gIR(m,iaer,radius_id+1)
+            ENDDO
+            qrefIRa(gausind,iaer)=                              &
+                    (1-kint)*QREFir(iaer,radius_id) +           &
+                    kint*QREFir(iaer,radius_id+1)
+            omegrefIRa(gausind,iaer)=                           &
+                    (1-kint)*omegaREFir(iaer,radius_id) +       &
+                    kint*omegaREFir(iaer,radius_id+1)
+          ENDIF
+        ENDDO
+
+        DO gausind=1,ngau
+          drad=radiusr*radgaus(gausind)
+          radGAUSb(gausind,iaer,idomain)=radiusm+drad
+
+          radius_id=minloc(abs(radiustab(iaer,idomain,:) -      &
+                               (radiusm+drad)),DIM=1)
+          IF ((radiustab(iaer,idomain,radius_id) -              &
+               (radiusm+drad)).GT.0) THEN
+            radius_id=radius_id-1
+          ENDIF
+          IF (radius_id.GE.nsize(iaer,idomain)) THEN
+            radius_id=nsize(iaer,idomain)-1
+            kint = 1.
+          ELSEIF (radius_id.LT.1) THEN
+            radius_id=1
+            kint = 0.
+          ELSE
+            kint = ( (radiusm+drad) -                           &
+                     radiustab(iaer,idomain,radius_id) ) /      &
+                   ( radiustab(iaer,idomain,radius_id+1) -      &
+                     radiustab(iaer,idomain,radius_id) )
+          ENDIF
+          IF (idomain.EQ.1) THEN ! VISIBLE DOMAIN -----------------
+            DO m=1,L_NSPECTV
+            qsqrefVISb(m,gausind,iaer)=                         &
+                    (1-kint)*QVISsQREF(m,iaer,radius_id) +      &
+                    kint*QVISsQREF(m,iaer,radius_id+1)    
+            omegVISb(m,gausind,iaer)=                           &
+                    (1-kint)*omegaVIS(m,iaer,radius_id) +       &
+                    kint*omegaVIS(m,iaer,radius_id+1)
+            gVISb(m,gausind,iaer)=                              &
+                    (1-kint)*gVIS(m,iaer,radius_id) +           &
+                    kint*gVIS(m,iaer,radius_id+1)
+            ENDDO
+            qrefVISb(gausind,iaer)=                             &
+                    (1-kint)*QREFvis(iaer,radius_id) +          &
+                    kint*QREFvis(iaer,radius_id+1)
+            omegrefVISb(gausind,iaer)=                          &
+                    (1-kint)*omegaREFvis(iaer,radius_id) +      &
+                    kint*omegaREFvis(iaer,radius_id+1)
+          ELSE ! INFRARED DOMAIN ----------------------------------
+            DO m=1,L_NSPECTI
+            qsqrefIRb(m,gausind,iaer)=                          &
+                    (1-kint)*QIRsQREF(m,iaer,radius_id) +       &
+                    kint*QIRsQREF(m,iaer,radius_id+1)
+            omegIRb(m,gausind,iaer)=                            &
+                    (1-kint)*omegaIR(m,iaer,radius_id) +        &
+                    kint*omegaIR(m,iaer,radius_id+1)
+            gIRb(m,gausind,iaer)=                               &
+                    (1-kint)*gIR(m,iaer,radius_id) +            &
+                    kint*gIR(m,iaer,radius_id+1)
+            ENDDO
+            qrefIRb(gausind,iaer)=                              &
+                    (1-kint)*QREFir(iaer,radius_id) +           &
+                    kint*QREFir(iaer,radius_id+1)
+            omegrefIRb(gausind,iaer)=                           &
+                    (1-kint)*omegaREFir(iaer,radius_id) +       &
+                    kint*omegaREFir(iaer,radius_id+1)
+          ENDIF
+        ENDDO
+
+!==================================================================
+! CONSTANT NUEFF FROM HERE
+!==================================================================
+
+!     2. Compute the scattering parameters using linear
+!       interpolation over grain sizes and constant nueff
+!     ---------------------------------------------------
+
+      DO lg = 1,nlayer
+        DO ig = 1, ngrid
+!         2.1 Effective radius index and kx calculation
+          var_tmp=reffrad(ig,lg,iaer)/refftabmin
+          var_tmp=log(var_tmp)*3.
+          var_tmp=var_tmp/logvratgrid+1.
+          grid_i=floor(var_tmp)
+          IF (grid_i.GE.refftabsize) THEN
+!           WRITE(*,*) 'Warning: particle size in grid box #'
+!           WRITE(*,*) ig,' is too large to be used by the '
+!           WRITE(*,*) 'radiative transfer; please extend the '
+!           WRITE(*,*) 'interpolation grid to larger grain sizes.'
+            grid_i=refftabsize-1
+            kx = 1.
+          ELSEIF (grid_i.LT.1) THEN
+!           WRITE(*,*) 'Warning: particle size in grid box #'
+!           WRITE(*,*) ig,' is too small to be used by the '
+!           WRITE(*,*) 'radiative transfer; please extend the '
+!           WRITE(*,*) 'interpolation grid to smaller grain sizes.'
+            grid_i=1
+            kx = 0.
+          ELSE
+            kx = ( reffrad(ig,lg,iaer)-refftab(grid_i) ) /            &
+                 ( refftab(grid_i+1)-refftab(grid_i) )
+          ENDIF
+!         2.3 Integration
+          DO j=grid_i,grid_i+1
+!             2.3.1 Check if the calculation has been done
+              IF (.NOT.checkgrid(j,1,iaer,idomain)) THEN
+!               2.3.2 Log-normal dist., r_g and sigma_g are defined
+!                 in [hansen_1974], "Light scattering in planetary
+!                 atmospheres", Space Science Reviews 16 527-610.
+!                 Here, sizedistk1=r_g and sizedistk2=sigma_g^2
+                sizedistk2 = log(1.+nueffrad(1,1,iaer))
+                sizedistk1 = exp(2.5*sizedistk2)
+                sizedistk1 = refftab(j) / sizedistk1
+
+                normd(j,1,iaer,idomain) = 1e-30
+                DO gausind=1,ngau
+                  drad=radiusr*radgaus(gausind)
+                  dista(j,1,iaer,idomain,gausind) = LOG((radiusm-drad)/sizedistk1)
+                  dista(j,1,iaer,idomain,gausind) =                   &
+                    EXP(-dista(j,1,iaer,idomain,gausind) *            &
+                    dista(j,1,iaer,idomain,gausind) *                 &
+                    0.5e0/sizedistk2)/(radiusm-drad)                  
+                  dista(j,1,iaer,idomain,gausind) =                   &
+                    dista(j,1,iaer,idomain,gausind) /                 &
+                    (sqrt(2e0*pi*sizedistk2))
+
+                  distb(j,1,iaer,idomain,gausind) = LOG((radiusm+drad)/sizedistk1)
+                  distb(j,1,iaer,idomain,gausind) =                   &
+                    EXP(-distb(j,1,iaer,idomain,gausind) *            &
+                    distb(j,1,iaer,idomain,gausind) *                 &
+                    0.5e0/sizedistk2)/(radiusm+drad)
+                  distb(j,1,iaer,idomain,gausind) =                   &
+                    distb(j,1,iaer,idomain,gausind) /                 &
+                    (sqrt(2e0*pi*sizedistk2))
+
+                  normd(j,1,iaer,idomain)=normd(j,1,iaer,idomain) +   &
+                    weightgaus(gausind) *                             &
+                    (                                                 &
+                    distb(j,1,iaer,idomain,gausind) * pi *            &
+                    radGAUSb(gausind,iaer,idomain) *                  &
+                    radGAUSb(gausind,iaer,idomain) +                  &
+                    dista(j,1,iaer,idomain,gausind) * pi *            &
+                    radGAUSa(gausind,iaer,idomain) *                  &
+                    radGAUSa(gausind,iaer,idomain)                    &
+                    )
+                ENDDO
+                IF (idomain.EQ.1) THEN ! VISIBLE DOMAIN -----------
+!                 2.3.3.vis Initialization
+                  qsqrefVISgrid(j,1,:,iaer)=0.
+                  qextVISgrid(j,1,:,iaer)=0.
+                  qscatVISgrid(j,1,:,iaer)=0.
+                  omegVISgrid(j,1,:,iaer)=0.
+                  gVISgrid(j,1,:,iaer)=0.
+                  qrefVISgrid(j,1,iaer)=0.
+                  qscatrefVISgrid(j,1,iaer)=0.
+                  omegrefVISgrid(j,1,iaer)=0.
+
+                  DO gausind=1,ngau
+                    DO m=1,L_NSPECTV
+!                     Convolution:
+                      qextVISgrid(j,1,m,iaer) =              &
+                        qextVISgrid(j,1,m,iaer) +            & 
+                        weightgaus(gausind) *                &
+                        (                                    &
+                        qsqrefVISb(m,gausind,iaer) *         &
+                        qrefVISb(gausind,iaer) *             &
+                        pi*radGAUSb(gausind,iaer,idomain) *  &
+                        radGAUSb(gausind,iaer,idomain) *     &
+                        distb(j,1,iaer,idomain,gausind) +    &
+                        qsqrefVISa(m,gausind,iaer) *         &
+                        qrefVISa(gausind,iaer) *             &
+                        pi*radGAUSa(gausind,iaer,idomain) *  &
+                        radGAUSa(gausind,iaer,idomain) *     &
+                        dista(j,1,iaer,idomain,gausind)      &
+                        )
+                      qscatVISgrid(j,1,m,iaer) =             &
+                        qscatVISgrid(j,1,m,iaer) +           &
+                        weightgaus(gausind) *                &
+                        (                                    &
+                        omegVISb(m,gausind,iaer) *           &
+                        qsqrefVISb(m,gausind,iaer) *         &
+                        qrefVISb(gausind,iaer) *             &
+                        pi*radGAUSb(gausind,iaer,idomain) *  &
+                        radGAUSb(gausind,iaer,idomain) *     &
+                        distb(j,1,iaer,idomain,gausind) +    &
+                        omegVISa(m,gausind,iaer) *           &
+                        qsqrefVISa(m,gausind,iaer) *         &
+                        qrefVISa(gausind,iaer) *             &
+                        pi*radGAUSa(gausind,iaer,idomain) *  &
+                        radGAUSa(gausind,iaer,idomain) *     &
+                        dista(j,1,iaer,idomain,gausind)      &
+                        )
+                      gVISgrid(j,1,m,iaer) =                 &
+                        gVISgrid(j,1,m,iaer) +               &
+                        weightgaus(gausind) *                &
+                        (                                    &
+                        omegVISb(m,gausind,iaer) *           &
+                        qsqrefVISb(m,gausind,iaer) *         &
+                        qrefVISb(gausind,iaer) *             &
+                        gVISb(m,gausind,iaer) *              &
+                        pi*radGAUSb(gausind,iaer,idomain) *  &
+                        radGAUSb(gausind,iaer,idomain) *     &
+                        distb(j,1,iaer,idomain,gausind) +    &
+                        omegVISa(m,gausind,iaer) *           &
+                        qsqrefVISa(m,gausind,iaer) *         &
+                        qrefVISa(gausind,iaer) *             &
+                        gVISa(m,gausind,iaer) *              &
+                        pi*radGAUSa(gausind,iaer,idomain) *  &
+                        radGAUSa(gausind,iaer,idomain) *     &
+                        dista(j,1,iaer,idomain,gausind)      &
+                        )
+                    ENDDO
+                    qrefVISgrid(j,1,iaer) =                  &
+                      qrefVISgrid(j,1,iaer) +                &
+                      weightgaus(gausind) *                  &
+                      (                                      &
+                      qrefVISb(gausind,iaer) *               &
+                      pi*radGAUSb(gausind,iaer,idomain) *    &
+                      radGAUSb(gausind,iaer,idomain) *       &
+                      distb(j,1,iaer,idomain,gausind) +      &
+                      qrefVISa(gausind,iaer) *               &
+                      pi*radGAUSa(gausind,iaer,idomain) *    &
+                      radGAUSa(gausind,iaer,idomain) *       &
+                      dista(j,1,iaer,idomain,gausind)        &
+                      )
+                    qscatrefVISgrid(j,1,iaer) =              &
+                      qscatrefVISgrid(j,1,iaer) +            &
+                      weightgaus(gausind) *                  &
+                      (                                      &
+                      omegrefVISb(gausind,iaer) *            &
+                      qrefVISb(gausind,iaer) *               & 
+                      pi*radGAUSb(gausind,iaer,idomain) *    &
+                      radGAUSb(gausind,iaer,idomain) *       &
+                      distb(j,1,iaer,idomain,gausind) +      &
+                      omegrefVISa(gausind,iaer) *            &
+                      qrefVISa(gausind,iaer) *               &
+                      pi*radGAUSa(gausind,iaer,idomain) *    &
+                      radGAUSa(gausind,iaer,idomain) *       &
+                      dista(j,1,iaer,idomain,gausind)        &
+                      )
+                  ENDDO
+
+                  qrefVISgrid(j,1,iaer)=qrefVISgrid(j,1,iaer) /          &
+                                normd(j,1,iaer,idomain)       
+                  qscatrefVISgrid(j,1,iaer)=qscatrefVISgrid(j,1,iaer) /  &
+                                normd(j,1,iaer,idomain)
+                  omegrefVISgrid(j,1,iaer)=qscatrefVISgrid(j,1,iaer) /   &
+                               qrefVISgrid(j,1,iaer)
+                  DO m=1,L_NSPECTV
+                    qextVISgrid(j,1,m,iaer)=qextVISgrid(j,1,m,iaer) /    &
+                                normd(j,1,iaer,idomain)
+                    qscatVISgrid(j,1,m,iaer)=qscatVISgrid(j,1,m,iaer) /  &
+                                normd(j,1,iaer,idomain)
+                    gVISgrid(j,1,m,iaer)=gVISgrid(j,1,m,iaer) /          &
+                                qscatVISgrid(j,1,m,iaer) /               &
+                                normd(j,1,iaer,idomain)
+
+                    qsqrefVISgrid(j,1,m,iaer)=qextVISgrid(j,1,m,iaer) /  &
+                                qrefVISgrid(j,1,iaer)
+                    omegVISgrid(j,1,m,iaer)=qscatVISgrid(j,1,m,iaer) /   &
+                                qextVISgrid(j,1,m,iaer)
+                  ENDDO
+                ELSE                   ! INFRARED DOMAIN ----------
+!                 2.3.3.ir Initialization
+                  qsqrefIRgrid(j,1,:,iaer)=0.
+                  qextIRgrid(j,1,:,iaer)=0.
+                  qscatIRgrid(j,1,:,iaer)=0.
+                  omegIRgrid(j,1,:,iaer)=0.
+                  gIRgrid(j,1,:,iaer)=0.
+                  qrefIRgrid(j,1,iaer)=0.
+                  qscatrefIRgrid(j,1,iaer)=0.
+                  omegrefIRgrid(j,1,iaer)=0.
+
+                  DO gausind=1,ngau
+                    DO m=1,L_NSPECTI
+!                     Convolution:
+                      qextIRgrid(j,1,m,iaer) =                  &
+                        qextIRgrid(j,1,m,iaer) +                &
+                        weightgaus(gausind) *                   &
+                        (                                       &
+                        qsqrefIRb(m,gausind,iaer) *             &
+                        qrefVISb(gausind,iaer) *                &
+                        pi*radGAUSb(gausind,iaer,idomain) *     &
+                        radGAUSb(gausind,iaer,idomain) *        &
+                        distb(j,1,iaer,idomain,gausind) +       &
+                        qsqrefIRa(m,gausind,iaer) *             &
+                        qrefVISa(gausind,iaer) *                &
+                        pi*radGAUSa(gausind,iaer,idomain) *     &
+                        radGAUSa(gausind,iaer,idomain) *        &
+                        dista(j,1,iaer,idomain,gausind)         &
+                        )
+                      qscatIRgrid(j,1,m,iaer) =                 &
+                        qscatIRgrid(j,1,m,iaer) +               &
+                        weightgaus(gausind) *                   &
+                        (                                       &
+                        omegIRb(m,gausind,iaer) *               &
+                        qsqrefIRb(m,gausind,iaer) *             &
+                        qrefVISb(gausind,iaer) *                &
+                        pi*radGAUSb(gausind,iaer,idomain) *     &
+                        radGAUSb(gausind,iaer,idomain) *        &
+                        distb(j,1,iaer,idomain,gausind) +       &
+                        omegIRa(m,gausind,iaer) *               &
+                        qsqrefIRa(m,gausind,iaer) *             &
+                        qrefVISa(gausind,iaer) *                &
+                        pi*radGAUSa(gausind,iaer,idomain) *     &
+                        radGAUSa(gausind,iaer,idomain) *        &
+                        dista(j,1,iaer,idomain,gausind)         &
+                        )
+                      gIRgrid(j,1,m,iaer) =                     &
+                        gIRgrid(j,1,m,iaer) +                   &
+                        weightgaus(gausind) *                   &
+                        (                                       &
+                        omegIRb(m,gausind,iaer) *               &
+                        qsqrefIRb(m,gausind,iaer) *             &
+                        qrefVISb(gausind,iaer) *                &
+                        gIRb(m,gausind,iaer) *                  &
+                        pi*radGAUSb(gausind,iaer,idomain) *     &
+                        radGAUSb(gausind,iaer,idomain) *        &
+                        distb(j,1,iaer,idomain,gausind) +       &
+                        omegIRa(m,gausind,iaer) *               &
+                        qsqrefIRa(m,gausind,iaer) *             &
+                        qrefVISa(gausind,iaer) *                &
+                        gIRa(m,gausind,iaer) *                  &
+                        pi*radGAUSa(gausind,iaer,idomain) *     &
+                        radGAUSa(gausind,iaer,idomain) *        &
+                        dista(j,1,iaer,idomain,gausind)         &
+                        )
+                    ENDDO
+                    qrefIRgrid(j,1,iaer) =                      &
+                      qrefIRgrid(j,1,iaer) +                    &
+                      weightgaus(gausind) *                     &
+                      (                                         &
+                      qrefIRb(gausind,iaer) *                   &
+                      pi*radGAUSb(gausind,iaer,idomain) *       &
+                      radGAUSb(gausind,iaer,idomain) *          &
+                      distb(j,1,iaer,idomain,gausind) +         &
+                      qrefIRa(gausind,iaer) *                   &
+                      pi*radGAUSa(gausind,iaer,idomain) *       &
+                      radGAUSa(gausind,iaer,idomain) *          &
+                      dista(j,1,iaer,idomain,gausind)           &
+                      )
+                    qscatrefIRgrid(j,1,iaer) =                  &
+                      qscatrefIRgrid(j,1,iaer) +                &
+                      weightgaus(gausind) *                     &
+                      (                                         &
+                      omegrefIRb(gausind,iaer) *                &
+                      qrefIRb(gausind,iaer) *                   &
+                      pi*radGAUSb(gausind,iaer,idomain) *       &
+                      radGAUSb(gausind,iaer,idomain) *          &
+                      distb(j,1,iaer,idomain,gausind) +         &
+                      omegrefIRa(gausind,iaer) *                &
+                      qrefIRa(gausind,iaer) *                   &
+                      pi*radGAUSa(gausind,iaer,idomain) *       &
+                      radGAUSa(gausind,iaer,idomain) *          &
+                      dista(j,1,iaer,idomain,gausind)           &
+                      )
+                  ENDDO
+ 
+                  qrefIRgrid(j,1,iaer)=qrefIRgrid(j,1,iaer) /          &
+                                normd(j,1,iaer,idomain)
+                  qscatrefIRgrid(j,1,iaer)=qscatrefIRgrid(j,1,iaer) /  &
+                                normd(j,1,iaer,idomain)
+                  omegrefIRgrid(j,1,iaer)=qscatrefIRgrid(j,1,iaer) /   &
+                               qrefIRgrid(j,1,iaer)
+                  DO m=1,L_NSPECTI
+                    qextIRgrid(j,1,m,iaer)=qextIRgrid(j,1,m,iaer) /    &
+                                normd(j,1,iaer,idomain)
+                    qscatIRgrid(j,1,m,iaer)=qscatIRgrid(j,1,m,iaer) /  &
+                                normd(j,1,iaer,idomain)
+                    gIRgrid(j,1,m,iaer)=gIRgrid(j,1,m,iaer) /          &
+                                qscatIRgrid(j,1,m,iaer) /              &
+                                normd(j,1,iaer,idomain)
+
+                    qsqrefIRgrid(j,1,m,iaer)=qextIRgrid(j,1,m,iaer) /  &
+                                qrefVISgrid(j,1,iaer)
+                    omegIRgrid(j,1,m,iaer)=qscatIRgrid(j,1,m,iaer) /   &
+                                qextIRgrid(j,1,m,iaer)
+                  ENDDO
+                ENDIF                  ! --------------------------
+                checkgrid(j,1,iaer,idomain) = .true.
+              ENDIF !checkgrid
+          ENDDO !grid_i
+!         2.4 Linear interpolation
+          k1 = (1-kx)
+          k2 = kx
+          IF (idomain.EQ.1) THEN ! VISIBLE ------------------------
+          DO m=1,L_NSPECTV
+             QVISsQREF3d(ig,lg,m,iaer) =                           &
+                        k1*qsqrefVISgrid(grid_i,1,m,iaer) +        &
+                        k2*qsqrefVISgrid(grid_i+1,1,m,iaer)
+            omegaVIS3d(ig,lg,m,iaer) =                             &
+                        k1*omegVISgrid(grid_i,1,m,iaer) +          &
+                        k2*omegVISgrid(grid_i+1,1,m,iaer)
+            gVIS3d(ig,lg,m,iaer) =                                 &
+                        k1*gVISgrid(grid_i,1,m,iaer) +             &
+                        k2*gVISgrid(grid_i+1,1,m,iaer)
+          ENDDO !L_NSPECTV
+          QREFvis3d(ig,lg,iaer) =                                  &
+                        k1*qrefVISgrid(grid_i,1,iaer) +            &
+                        k2*qrefVISgrid(grid_i+1,1,iaer)
+          omegaREFvis3d(ig,lg,iaer) =                              &
+                        k1*omegrefVISgrid(grid_i,1,iaer) +         &
+                        k2*omegrefVISgrid(grid_i+1,1,iaer)
+          ELSE                   ! INFRARED -----------------------
+          DO m=1,L_NSPECTI
+            QIRsQREF3d(ig,lg,m,iaer) =                             &
+                        k1*qsqrefIRgrid(grid_i,1,m,iaer) +         &
+                        k2*qsqrefIRgrid(grid_i+1,1,m,iaer)
+            omegaIR3d(ig,lg,m,iaer) =                              &
+                        k1*omegIRgrid(grid_i,1,m,iaer) +           &
+                        k2*omegIRgrid(grid_i+1,1,m,iaer) 
+            gIR3d(ig,lg,m,iaer) =                                  & 
+                        k1*gIRgrid(grid_i,1,m,iaer) +              &
+                        k2*gIRgrid(grid_i+1,1,m,iaer)
+          ENDDO !L_NSPECTI
+          QREFir3d(ig,lg,iaer) =                                   &
+                        k1*qrefIRgrid(grid_i,1,iaer) +             &
+                        k2*qrefIRgrid(grid_i+1,1,iaer)
+          omegaREFir3d(ig,lg,iaer) =                               &
+                        k1*omegrefIRgrid(grid_i,1,iaer) +          &
+                        k2*omegrefIRgrid(grid_i+1,1,iaer)
+          ENDIF                  ! --------------------------------
+        ENDDO !nlayer
+      ENDDO !ngrid
+
+!==================================================================
+
+
+
+      ENDDO ! idomain
+
+      ENDIF ! nsize = 1
+
+      ENDDO ! iaer (loop on aerosol kind)
+
+      RETURN
+    END SUBROUTINE aeroptproperties
+
+
+
+      
Index: /trunk/LMDZ.TITAN/libf/phytitan/aerosol_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/aerosol_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/aerosol_mod.F90	(revision 1644)
@@ -0,0 +1,22 @@
+!==================================================================
+module aerosol_mod
+implicit none
+save
+!==================================================================
+
+!  aerosol indexes: these are initialized to be 0 if the
+!                 corresponding aerosol was not activated in callphys.def
+!                 -- otherwise a value is given in iniaerosol
+      integer :: iaero_co2 = 0 
+      integer :: iaero_h2o = 0
+      integer :: iaero_dust = 0
+      integer :: iaero_h2so4 = 0
+      logical :: noaero = .false.
+
+! two-layer simple aerosol model
+      integer :: iaero_back2lay = 0
+!$OMP THREADPRIVATE(iaero_co2,iaero_h2o,iaero_dust,iaero_h2so4,noaero,iaero_back2lay)
+      
+!==================================================================
+end module aerosol_mod
+!==================================================================
Index: /trunk/LMDZ.TITAN/libf/phytitan/albedo_calcv.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/albedo_calcv.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/albedo_calcv.F90	(revision 1644)
@@ -0,0 +1,47 @@
+      SUBROUTINE spectral_albedo_calc(albedo_snow_SPECTV)
+
+
+      use callkeys_mod, only : albedosnow
+      use radinc_h, only : L_NSPECTV
+      use radcommon_h, only: BWNV
+
+      IMPLICIT NONE
+      
+      
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+!!!!!!!!!
+!
+!   Spectral Albedo Loading ...
+!
+!!!!!!!!!
+!
+! - Snow Albedo. Added by MT (10/2015)
+!
+! What has to be added next : Spectral albedo of CO2 ice, of oceans, ...
+!    
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+      REAL albedo_snow_SPECTV(L_NSPECTV) ! Snow spectral albedo.
+      REAL lambda_temp(L_NSPECTV)        ! Visible band wavelengths.
+      INTEGER nw
+
+
+      DO nw=1,L_NSPECTV
+      
+         ! Corresponding Middle-Band Wavelength Number Calculation.
+         lambda_temp(nw)=0.5*(10000.0/BWNV(nw)+10000.0/BWNV(nw+1))
+	 
+         ! Spectral Snow Albedo Calculation.
+	 call albedo_snow_calc(lambda_temp(nw),        &
+	                      albedo_snow_SPECTV(nw),  & 
+	                      albedosnow)
+         
+      ENDDO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/albedo_snow_calc.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/albedo_snow_calc.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/albedo_snow_calc.F90	(revision 1644)
@@ -0,0 +1,49 @@
+      subroutine albedo_snow_calc(lambda,albedo,A_sw)
+
+      real lambda_sw
+      real lambda_lw
+      real A_sw
+      real A_lw
+      real albedo
+      real lambda
+      
+      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      !!!!! Routine written by Martin TURBET (July 2015)
+      !!!!!
+      !!!!! Albedo expression derived from Yoshi et al. and Warren et al. articles.
+      !!!!!
+      !!
+      !! Short Wave Snow Albedo 'A_sw' (at 0.5 microns) must be chosen in callphys.def file.
+      !! 
+      !!!!!
+      !!!!!
+      !! Some Calibration Informations :
+      !!!!!
+      !!!!!
+      !!
+      !! 1. For Pure Snow, A_sw (at 0.5 microns) should be equal to ~0.95
+      !!    -> This gives an equivalent integrated snow albedo of ~0.73 for the Sun.
+      !!
+      !! 2. For Dusty Snow, A_sw (at 0.5 microns) should be equal to ~0.50.
+      !!    -> This gives an equivalent integrated snow albedo of ~0.39 for the Sun.
+      !!
+      !! 3. For 'Realistic' Snow, A_sw (at 0.5 microns) should be equal to ~0.645.
+      !!    -> This gives an equivalent integrated snow albedo of ~0.50 for the Sun.
+      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+      A_lw=5.0D-2
+      lambda_sw=9.0D-1
+      lambda_lw=1.4
+      
+      if (lambda .le. lambda_sw) then
+         albedo=A_sw
+      else if (lambda .ge. lambda_lw) then
+         albedo=A_lw
+      else if ( (lambda .gt. lambda_sw) .and. &
+             (lambda .lt. lambda_lw) ) then
+         albedo=A_sw-(lambda-lambda_sw)*(A_sw-A_lw) &
+           /(lambda_lw-lambda_sw)  
+      end if
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/ave_stelspec.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/ave_stelspec.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/ave_stelspec.F90	(revision 1644)
@@ -0,0 +1,190 @@
+      subroutine ave_stelspec(STELLAR)
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Average the chosen high resolution stellar spectrum over the
+!     visible bands in the model.
+!     
+!     Authors
+!     ------- 
+!     Robin Wordsworth (2010).
+!     Generalized to very late spectral types (and Brown dwarfs) Jeremy Leconte (2012)
+!
+!     Called by
+!     ---------
+!     setspv.F
+!     
+!     Calls
+!     -----
+!     none
+!     
+!==================================================================
+
+      use radinc_h, only: L_NSPECTV
+      use radcommon_h, only: BWNV, DWNV, tstellar
+      use datafile_mod, only: datadir
+      use callkeys_mod, only: stelbbody,stelTbb,startype
+
+      implicit none
+
+      real*8 STELLAR(L_NSPECTV)
+!      integer startype 
+
+      integer Nfine
+      integer,parameter :: Nfineband=200
+      integer ifine,band
+
+      real,allocatable,save :: lam(:),stel_f(:) 	!read by master
+      real lamm,lamp
+      real dl
+
+      character(len=100)  :: file_id,file_id_lam
+      character(len=200) :: file_path,file_path_lam
+
+      real lam_temp
+      double precision stel_temp
+      
+      integer :: ios ! file opening/reading status
+
+      STELLAR(:)=0.0
+
+      print*,'enter ave_stellspec'
+      if(stelbbody)then
+         tstellar=stelTbb
+	 Nfine=L_NSPECTV*Nfineband
+	 do band=1,L_NSPECTV
+	    lamm=10000.0/BWNV(band+1)
+	    lamp=10000.0/BWNV(band)
+	    dl=(lamp-lamm)/(Nfineband)
+	    do ifine=1,Nfineband
+	       lam_temp=lamm+(lamp-lamm)*(ifine-1.)/(Nfineband)
+               call blackl(dble(lam_temp*1e-6),dble(tstellar),stel_temp)
+	       STELLAR(band)=STELLAR(band)+stel_temp*dl
+	    enddo	    
+	 end do
+         STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV))
+      else
+         ! load high resolution stellar data
+         Select Case(startype)
+	   Case(1)
+            file_id='/stellar_spectra/sol.txt'
+            tstellar=5800.
+            file_id_lam='/stellar_spectra/lam.txt'
+            Nfine=5000
+	   Case(2)
+            file_id='/stellar_spectra/gl581.txt'
+            tstellar=3200.
+            file_id_lam='/stellar_spectra/lam.txt'
+            Nfine=5000
+	   Case(3)
+            file_id='/stellar_spectra/adleo.txt'
+            tstellar=3200.
+            file_id_lam='/stellar_spectra/lam.txt'
+            Nfine=5000
+	   Case(4)
+            file_id='/stellar_spectra/gj644.txt'
+            print*,'Find out tstellar before using this star!'
+            call abort
+            file_id_lam='/stellar_spectra/lam.txt'
+            Nfine=5000
+	   Case(5)
+            file_id='/stellar_spectra/hd128167.txt'
+            tstellar=6700. ! Segura et al. (2003)
+            file_id_lam='/stellar_spectra/lam.txt'
+            Nfine=5000
+	   Case(6)
+            file_id='/stellar_spectra/BD_Teff-1600K.txt'
+            tstellar=1600. 
+            file_id_lam='/stellar_spectra/lamBD.txt'
+            Nfine=5000
+	   Case(7)
+            file_id='/stellar_spectra/BD_Teff-1000K.txt'
+            tstellar=1000. 
+            file_id_lam='/stellar_spectra/lamBD.txt'
+            Nfine=5000
+	   Case(8)
+            file_id='/stellar_spectra/Flux_K5_Teff4700_logg4.5_Met-0.5_BTsettle.dat'
+            tstellar=4700. 
+            file_id_lam='/stellar_spectra/lambda_K5_Teff4700_logg4.5_Met-0.5_BTsettle.dat'
+            Nfine=3986
+           Case(9)
+            file_id='/stellar_spectra/Flux_M7_Teff2550_logg3.0_Met-0.0.dat'
+            tstellar=2550. 
+            file_id_lam='/stellar_spectra/lambda_M7_Teff2550_logg3.0_Met-0.0.dat'
+            Nfine=5000
+	   Case Default
+            print*,'Error: unknown star type chosen'
+            call abort
+         End Select
+
+!$OMP MASTER
+	 allocate(lam(Nfine),stel_f(Nfine))
+
+         file_path_lam=TRIM(datadir)//TRIM(file_id_lam)
+         open(110,file=file_path_lam,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from ave_stelspec'
+           write(*,*) 'Data file ',trim(file_id_lam),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a ',trim(file_id_lam),' there.'
+           call abort
+         else
+           do ifine=1,Nfine
+             read(110,*) lam(ifine)
+           enddo
+           close(110)
+         endif
+
+
+         ! load high resolution wavenumber data
+         file_path=TRIM(datadir)//TRIM(file_id)
+         open(111,file=file_path,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from ave_stelspec'
+           write(*,*) 'Data file ',trim(file_id),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a ',trim(file_id),' there.'
+           call abort
+         else
+           do ifine=1,Nfine
+             read(111,*) stel_f(ifine)
+           enddo
+           close(111)
+         endif
+!$OMP END MASTER
+!$OMP BARRIER
+	 
+         ! sum data by band
+         band=1
+	 Do while(lam(1).lt. real(10000.0/BWNV(band+1)))
+	    if (band.gt.L_NSPECTV-1) exit
+            band=band+1
+	 enddo
+	 dl=lam(2)-lam(1)
+         STELLAR(band)=STELLAR(band)+stel_f(1)*dl
+         do ifine = 2,Nfine
+            if(lam(ifine) .gt. real(10000.0/BWNV(band)))then
+               band=band-1
+            endif
+            if(band .lt. 1) exit
+	    dl=lam(ifine)-lam(ifine-1)
+            STELLAR(band)=STELLAR(band)+stel_f(ifine)*dl
+         end do
+	       
+	 
+         STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV))
+!$OMP BARRIER
+!$OMP MASTER
+	 if (allocated(lam)) deallocate(lam)
+	 if (allocated(stel_f)) deallocate(stel_f)
+!$OMP END MASTER
+!$OMP BARRIER         
+      endif
+
+      end subroutine ave_stelspec
Index: /trunk/LMDZ.TITAN/libf/phytitan/bands/makbands
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/bands/makbands	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/bands/makbands	(revision 1644)
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+for i in $* ; do
+   list=$list.$i
+done
+fichdim=bands${list}
+
+if [ ! -f $fichdim ] ; then
+# if the file doesn't exist, we create it
+
+ if [ $# -ge 2 ] ; then
+      NBinfrared=$1
+      NBvisible=$2
+ else
+      echo "you need bands in IR and in the visible"
+      exit
+ fi
+
+cat << EOF > $fichdim
+!-----------------------------------------------------------------------
+!   INCLUDE 'bands.h'
+!
+!   bands.h contains the visible & infrared bands in the model
+!
+!   NBinfrared = L_NSPECTI in the model
+!   NBvisible  = L_NSPECTV in the model
+!-----------------------------------------------------------------------
+
+      INTEGER, parameter :: NBinfrared=$NBinfrared
+      INTEGER, parameter :: NBvisible=$NBvisible
+
+
+!-----------------------------------------------------------------------
+EOF
+
+else
+ echo "bands file already exists!"
+fi
+
+\rm ../bands.h
+tar cf - $fichdim | ( cd .. ; tar xf - ; mv $fichdim bands.h )
Index: /trunk/LMDZ.TITAN/libf/phytitan/bilinear.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/bilinear.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/bilinear.F90	(revision 1644)
@@ -0,0 +1,18 @@
+!-------------------------------------------------------------------------
+subroutine bilinear(f,f11,f21,f12,f22,x,x1,x2,y,y1,y2)  
+! Used for interpolation of continuum data
+
+  implicit none
+
+  real*8 x,y,x1,x2,y1,y2
+  real*8 f,f11,f12,f21,f22,fA,fB
+
+  ! 1st in x-direction
+  fA=f11*(x2-x)/(x2-x1)+f21*(x-x1)/(x2-x1)
+  fB=f12*(x2-x)/(x2-x1)+f22*(x-x1)/(x2-x1)
+
+  ! then in y-direction
+  f=fA*(y2-y)/(y2-y1)+fB*(y-y1)/(y2-y1)
+
+  return
+end subroutine bilinear
Index: /trunk/LMDZ.TITAN/libf/phytitan/bilinearbig.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/bilinearbig.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/bilinearbig.F90	(revision 1644)
@@ -0,0 +1,85 @@
+      subroutine bilinearbig(nX,nY,x_arr,y_arr,f2d_arr,x_in,y_in,f,ind)
+
+!     Necessary for interpolation of continuum data
+!     optimized by A. Spiga 01/2013 
+
+      implicit none
+
+      integer nX,nY,i,j,ind,b
+
+      real*8 x_in,y_in,x1,x2,y1,y2
+      real*8 f,f11,f12,f21,f22,fA,fB
+      real*8 x_arr(nX)
+      real*8 y_arr(nY)
+      real*8 f2d_arr(nX,nY)
+      real*8,save :: x,y
+!$OMP THREADPRIVATE(x,y)
+
+      integer strlen
+      character*100 label
+      label='subroutine bilinear'
+
+
+      x=x_in
+      y=y_in
+
+   !! AS: important to optimize here because the array is quite large
+   !! ... and actually calculations only need to be done once
+   !! IF ind=-9999 we have not calculated yet
+   if ( ind == -9999) then
+      !1st check we're within the wavenumber range
+      if ((x.lt.x_arr(2)).or.(x.gt.x_arr(nX-2))) then
+         ind=-1
+      else
+        i=1
+        x2=x_arr(i)
+        do while ( x2 .le. x )
+          x1=x2
+          i=i+1
+          x2=x_arr(i)
+          ind=i-1
+        end do
+      endif
+   endif
+
+   !! Either we already saw we are out of wavenumber range
+   !! ... and we just have to set f=0 and exit
+   if ( ind == -1) then 
+      f=0.0D+0
+      return
+   !! Or we already determined ind -- so we just proceed
+   else
+      x1=x_arr(ind)
+      x2=x_arr(ind+1)
+   endif
+
+!     ... and for y within the temperature range
+      if ((y.lt.y_arr(1)).or.(y.gt.y_arr(nY))) then
+         write(*,*) 'Warning from bilinearbig routine:'
+         write(*,*) 'Outside continuum temperature range!'
+         if(y.lt.y_arr(1))then
+            y=y_arr(1)+0.01
+         endif
+         if(y.gt.y_arr(nY))then
+            y=y_arr(nY)-0.01
+         endif
+      else
+        j=1
+        y2=y_arr(j)
+        do while ( y2 .le. y )
+          y1=y2
+          j=j+1
+          y2=y_arr(j)
+          b=j-1
+        end do
+      endif
+      
+      f11=f2d_arr(ind,b)
+      f21=f2d_arr(ind+1,b)
+      f12=f2d_arr(ind,b+1)
+      f22=f2d_arr(ind+1,b+1)
+
+      call bilinear(f,f11,f21,f12,f22,x,x1,x2,y,y1,y2)
+
+      return
+    end subroutine bilinearbig
Index: /trunk/LMDZ.TITAN/libf/phytitan/blackl.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/blackl.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/blackl.F	(revision 1644)
@@ -0,0 +1,21 @@
+      subroutine blackl(blalong,blat,blae)
+
+      implicit double precision (a-h,o-z)
+
+      ! physical constants
+      sigma=5.67032D-8
+      pi=datan(1.d0)*4.d0
+      c0=2.9979d+08
+      h=6.6262d-34
+      cbol=1.3806d-23
+      rind=1.d0
+      c=c0/rind
+      c1=h*(c**2)
+      c2=h*c/cbol
+
+
+      blae=2.d0*pi*c1/blalong**5/(dexp(c2/blalong/blat)-1.d0)
+
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/calc_cpp3d.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/calc_cpp3d.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/calc_cpp3d.F90	(revision 1644)
@@ -0,0 +1,29 @@
+      subroutine calc_cpp3d(cppNI,rcpNI,t,p)
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the atmospheric specific heat capacity as a 
+!     function of pressure and temperature (for CO2 gas only)
+!
+!     Authors
+!     ------- 
+!     Robin Wordsworth (2009)
+!
+!==================================================================
+      use comcstfi_mod, only: cpp, r
+      implicit none
+
+      !real cp0, dB2dT2
+      real cppNI      ! specific heat capacity at const. pressure
+      real rcpNI      ! R / specific heat capacity
+      real t
+      real p
+
+      ! dummy function until I decide what to do!
+
+      cppNI  = cpp
+      rcpNI  = R/cppNI
+
+      return
+    end subroutine calc_cpp3d
Index: /trunk/LMDZ.TITAN/libf/phytitan/calc_cpp_mugaz.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/calc_cpp_mugaz.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/calc_cpp_mugaz.F90	(revision 1644)
@@ -0,0 +1,151 @@
+      subroutine calc_cpp_mugaz
+
+!==================================================================
+!     Purpose
+!     -------
+!     Check to see if the atmospheric specific heat capacity and
+!     mean molar mass for the gas mixture defined in gases.def
+!     corresponds to what we're using. If it doesn't, abort run
+!     unless option 'check_cpp_match' is set to false in 
+!     callphys.def.
+!
+!     Authors
+!     ------- 
+!     Robin Wordsworth (2009)
+!     A. Spiga: make the routine OK with latest changes in rcm1d
+!
+!==================================================================
+
+      use gases_h
+      use comcstfi_mod, only: cpp, mugaz
+      use callkeys_mod, only: check_cpp_match,force_cpp
+      implicit none
+
+      real cpp_c   
+      real mugaz_c
+
+      integer igas
+
+      cpp_c   = 0.0
+      mugaz_c = 0.0
+
+
+! compute mugaz
+      do igas=1,ngasmx
+
+         if(igas.eq.vgas)then
+            ! ignore variable gas in cpp calculation
+         else
+            ! all values at 300 K from Engineering Toolbox
+            if(igas.eq.igas_CO2)then
+               mugaz_c = mugaz_c + 44.01*gfrac(igas)
+            elseif(igas.eq.igas_N2)then
+               mugaz_c = mugaz_c + 28.01*gfrac(igas)
+            elseif(igas.eq.igas_H2)then
+               mugaz_c = mugaz_c + 2.01*gfrac(igas)
+            elseif(igas.eq.igas_He)then
+               mugaz_c = mugaz_c + 4.003*gfrac(igas)
+            elseif(igas.eq.igas_H2O)then
+               mugaz_c = mugaz_c + 18.02*gfrac(igas)
+            elseif(igas.eq.igas_SO2)then
+               mugaz_c = mugaz_c + 64.066*gfrac(igas)
+            elseif(igas.eq.igas_H2S)then
+               mugaz_c = mugaz_c + 34.08*gfrac(igas)
+            elseif(igas.eq.igas_CH4)then
+               mugaz_c = mugaz_c + 16.04*gfrac(igas)
+            elseif(igas.eq.igas_NH3)then
+               mugaz_c = mugaz_c + 17.03*gfrac(igas)
+            elseif(igas.eq.igas_C2H6)then 
+               ! C2H6 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=28
+               mugaz_c = mugaz_c + 30.07*gfrac(igas)
+            elseif(igas.eq.igas_C2H2)then
+               ! C2H2 http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=1
+               mugaz_c = mugaz_c + 26.04*gfrac(igas)
+            else
+               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
+               call abort
+            endif
+         endif
+
+      enddo
+
+!compute cpp
+      do igas=1,ngasmx
+
+         if(igas.eq.vgas)then
+            ! ignore variable gas in cpp calculation
+         else
+            ! all values at 300 K from Engineering Toolbox
+            if(igas.eq.igas_CO2)then
+               !cpp_c   = cpp_c   + 0.744*gfrac(igas) ! @ ~210 K (better for
+               !Mars conditions) 
+               cpp_c   = cpp_c   + 0.846*gfrac(igas)*44.01/mugaz_c
+            elseif(igas.eq.igas_N2)then
+               cpp_c   = cpp_c   + 1.040*gfrac(igas)*28.01/mugaz_c
+            elseif(igas.eq.igas_H2)then
+               cpp_c   = cpp_c   + 14.31*gfrac(igas)*2.01/mugaz_c
+            elseif(igas.eq.igas_He)then
+               cpp_c   = cpp_c   + 5.19*gfrac(igas)*4.003/mugaz_c
+            elseif(igas.eq.igas_H2O)then
+               cpp_c   = cpp_c   + 1.864*gfrac(igas)*18.02/mugaz_c
+            elseif(igas.eq.igas_SO2)then
+               cpp_c   = cpp_c   + 0.64*gfrac(igas)*64.066/mugaz_c
+            elseif(igas.eq.igas_H2S)then
+               cpp_c   = cpp_c   + 1.003*gfrac(igas)*34.08/mugaz_c ! from wikipedia...
+            elseif(igas.eq.igas_CH4)then
+               cpp_c   = cpp_c   + 2.226*gfrac(igas)*16.04/mugaz_c
+            elseif(igas.eq.igas_NH3)then
+               cpp_c   = cpp_c   + 2.175*gfrac(igas)*17.03/mugaz_c
+               print*,'WARNING, cpp for NH3 may be for liquid'
+            elseif(igas.eq.igas_C2H6)then
+               ! C2H6
+               ! http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=28
+               cpp_c   = cpp_c   + 1.763*gfrac(igas)*30.07/mugaz_c
+            elseif(igas.eq.igas_C2H2)then
+               ! C2H2
+               ! http://encyclopedia.airliquide.com/Encyclopedia.asp?GasID=1
+               cpp_c   = cpp_c   + 1.575*gfrac(igas)*26.04/mugaz_c
+            else
+               print*,'Error in calc_cpp_mugaz: Gas species not recognised!'
+               call abort
+            endif
+         endif
+
+      enddo
+
+
+
+
+
+      cpp_c = 1000.0*cpp_c
+
+      print*,'Cp in calc_cpp_mugaz is ',cpp_c,'J kg^-1 K^-1'
+      print*,'Mg in calc_cpp_mugaz is ',mugaz_c,'amu'
+      print*,'Predefined Cp in physics is ',cpp,'J kg^-1 K^-1'
+      print*,'Predefined Mg in physics is ',mugaz,'amu'
+
+      if (check_cpp_match) then
+         print*,'REQUEST TO CHECK cpp_match :'
+         if((abs(1.-cpp/cpp_c).gt.1.e-6) .or.  &
+              (abs(1.-mugaz/mugaz_c).gt.1.e-6)) then
+            ! Ehouarn: tolerate a small mismatch between computed/stored values
+            print*,'--> Values do not match!'
+            print*,'    Either adjust cpp / mugaz via newstart to calculated values,'
+            print*,'    or set check_cpp_match to .false. in callphys.def.'
+            stop
+         else
+            print*,'--> OK. Settings match composition.'
+         endif
+      endif
+
+      if (.not.force_cpp) then
+          print*,'*** Setting cpp & mugaz to computations in calc_cpp_mugaz.'
+          mugaz = mugaz_c
+          cpp = cpp_c
+      else
+          print*,'*** Setting cpp & mugaz to predefined values.'
+      endif
+
+
+      return
+    end subroutine calc_cpp_mugaz
Index: /trunk/LMDZ.TITAN/libf/phytitan/calc_rayleigh.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/calc_rayleigh.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/calc_rayleigh.F90	(revision 1644)
@@ -0,0 +1,165 @@
+      subroutine calc_rayleigh
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Average the Rayleigh scattering in each band, weighting the 
+!     average by the blackbody function at temperature tstellar.
+!     Works for an arbitrary mix of gases (currently CO2, N2 and 
+!     H2 are possible).
+!     
+!     Authors
+!     ------- 
+!     Robin Wordsworth (2010)
+!     Jeremy Leconte (2012): Added option for variable gas. Improved water rayleigh (Bucholtz 1995).
+!
+!     Called by
+!     ---------
+!     setspv.F
+!     
+!     Calls
+!     -----
+!     none
+!     
+!==================================================================
+
+      use radinc_h, only: L_NSPECTV
+      use radcommon_h, only: WAVEV, BWNV, DWNV, tstellar, tauray, taurayvar, scalep
+      use gases_h
+      use comcstfi_mod, only: g, mugaz
+
+      implicit none
+
+      real*8 wl
+      integer N,Nfine,ifine,igas
+      parameter(Nfine=500.0)
+      real*8 :: P0 = 9.423D+6   ! Rayleigh scattering reference pressure in pascals.    
+
+      logical typeknown
+      real*8 tauvar,tauvarvar,tausum,tausumvar,tauwei,tauweivar,bwidth,bstart
+      double precision df
+
+      real*8 tauconsti(ngasmx)
+      real*8 tauvari(ngasmx)
+
+      integer icantbewrong
+
+      ! tau0/p0=tau/p (Hansen 1974)
+      ! Then calculate tau0 = (8*pi^3*p_1atm)/(3*N0^2) * 4*delta^2/(g*mugaz*lambda^4)
+      ! where delta=n-1 and N0 is an amagat
+
+      typeknown=.false.
+      do igas=1,ngasmx
+         if(igas.eq.vgas)then
+            print*,'variable gas is ',trim(gnom(igas)),' in Rayleigh scattering '
+	 endif
+	 if((igas/=vgas).and.(gfrac(igas).lt.5.e-2))then
+            print*,'Ignoring ',trim(gnom(igas)),' in Rayleigh scattering '// &
+            'as its mixing ratio is less than 0.05.' 
+            ! ignore variable gas in Rayleigh calculation
+            ! ignore gases of mixing ratio < 0.05 in Rayleigh calculation
+            tauconsti(igas) = 0.0
+         else
+            if(igas.eq.igas_CO2) then
+               tauconsti(igas) = (8.7/g)*1.527*scalep/P0
+            elseif(igas.eq.igas_N2)then
+               tauconsti(igas) = (9.81/g)*8.569E-3*scalep/(P0/93.0)
+            elseif(igas.eq.igas_H2O)then
+!               tauconsti(igas) = (10.0/g)*9.22E-3*scalep/101325.0 
+               tauconsti(igas) = 1.98017E-10/(g*mugaz*100.) 
+            elseif(igas.eq.igas_H2)then
+               tauconsti(igas) = (10.0/g)*0.0241*scalep/101325.0
+               !tauconsti(igas) = (10.0/g)*0.0487*scalep/(101325.0)
+               ! uses n=1.000132 from Optics, Fourth Edition.
+               ! was out by a factor 2!
+            elseif(igas.eq.igas_He)then
+               tauconsti(igas) = (10.0/g)*0.00086*scalep/101325.0
+            else
+               print*,'Error in calc_rayleigh: Gas species not recognised!'
+               call abort
+            endif
+
+            if((gfrac(igas).eq.1.0).and.(vgas.eq.0))then
+               print*,'Rayleigh scattering is for a pure ',trim(gnom(igas)),' atmosphere.'
+               typeknown=.true.
+            endif
+
+         endif
+      enddo
+
+      if(.not.typeknown)then
+         print*,'Rayleigh scattering is for a mixed gas atmosphere.'
+         typeknown=.true.
+      endif
+
+ 
+      do N=1,L_NSPECTV
+         
+         tausum = 0.0
+         tauwei = 0.0
+         tausumvar = 0.0
+         tauweivar = 0.0
+         bstart = 10000.0/BWNV(N+1)
+         bwidth = (10000.0/BWNV(N)) - (10000.0/BWNV(N+1))
+         do ifine=1,Nfine
+            wl=bstart+dble(ifine)*bwidth/Nfine
+
+            tauvar=0.0
+            tauvarvar=0.0
+            do igas=1,ngasmx
+               if((igas/=vgas).and.(gfrac(igas).lt.5.e-2))then
+                  ! ignore variable gas in Rayleigh calculation
+                  ! ignore gases of mixing ratio < 0.05 in Rayleigh calculation
+                  tauvari(igas)   = 0.0
+               else
+                  if(igas.eq.igas_CO2)then
+                     tauvari(igas) = (1.0+0.013/wl**2)/wl**4
+                  elseif(igas.eq.igas_N2)then
+                     tauvari(igas) = (1.0+0.0113/wl**2+0.00013/wl**4)/wl**4
+                  elseif(igas.eq.igas_H2O)then
+!                     tauvari(igas) = 1.0/wl**4 ! to be improved...
+                     tauvari(igas) = (5.7918E6/(2.38E2-1/wl**2)+1.679E5/(57.36E0-1/wl**2))**2/wl**4 
+                  elseif(igas.eq.igas_H2)then
+                     tauvari(igas) = 1.0/wl**4 
+                  elseif(igas.eq.igas_He)then
+                     tauvari(igas) = 1.0/wl**4 
+                  else
+                     print*,'Error in calc_rayleigh: Gas species not recognised!'
+                     call abort
+                  endif
+               endif
+
+               if(igas.eq.vgas) then
+                  tauvarvar=tauvarvar+tauconsti(igas)*tauvari(igas)
+                  tauvar=tauvar+0.0*0.0*gfrac(igas)
+               else
+                  tauvar=tauvar+tauconsti(igas)*tauvari(igas)*gfrac(igas)
+               endif
+
+            enddo
+
+            call blackl(dble(wl*1e-6),dble(tstellar),df)
+            df=df*bwidth/Nfine
+            tauwei=tauwei+df
+            tausum=tausum+tauvar*df
+            tauweivar=tauweivar+df
+            tausumvar=tausumvar+tauvarvar*df
+         
+         enddo
+         TAURAY(N)=tausum/tauwei
+         TAURAYVAR(N)=tausumvar/tauweivar
+         ! we multiply by scalep here (100) because plev, which is used in optcv,
+         ! is in units of mBar, so we need to convert.
+
+      end do
+
+      IF (L_NSPECTV > 6) THEN
+        icantbewrong = L_NSPECTV-6
+        print*,'At 1 atm and lambda = ',WAVEV(icantbewrong),' um'
+        print*,'tau_R = ',TAURAY(icantbewrong)*1013.25
+        print*,'sig_R = ',TAURAY(icantbewrong)*g*mugaz*1.67e-27*100, &
+               'cm^2 molecule^-1'
+      ENDIF
+
+    end subroutine calc_rayleigh
Index: /trunk/LMDZ.TITAN/libf/phytitan/call_rings.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/call_rings.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/call_rings.F90	(revision 1644)
@@ -0,0 +1,69 @@
+subroutine call_rings(ngrid, ptime, pday, diurnal)
+    ! A subroutine to compute the day fraction in case of rings shadowing.
+
+    use radcommon_h, only: eclipse
+    use comsaison_h, only: fract, declin
+    use comcstfi_mod, only: rad, pi
+    use comdiurn_h, only: coslat, sinlat, coslon, sinlon
+    use callkeys_mod, only: flatten
+
+    INTEGER, INTENT(IN) :: ngrid
+    REAL, INTENT(IN) :: ptime ! "universal time", given as fraction of sol (e.g.: 0.5 for noon)
+    REAL, INTENT(IN) :: pday  ! Number of days counted from the North. Spring equinoxe.	
+    LOGICAL, INTENT(IN) :: diurnal
+!    REAL, DIMENSION(:), INTENT(INOUT) :: fract ! day fraction for each point of the planet
+
+!   to compute the daily average of rings shadowing
+    INTEGER, PARAMETER :: nb_hours = 1536 ! set how many times per day are used
+    REAL :: pas
+    INTEGER :: m
+    REAL :: ptime_day ! Universal time in sol fraction 
+    REAL:: tmp_zls,tmp_dist_star, tmp_declin, tmp_right_ascen   ! tmp solar longitude, stellar dist, declin and RA
+    REAL :: ztim1, ztim2, ztim3
+    REAL, DIMENSION(:), ALLOCATABLE :: tmp_fract ! day fraction of the time interval 
+    REAL, DIMENSION(:), ALLOCATABLE :: tmp_mu0 ! equivalent solar angle
+
+!! Eclipse incoming sunlight (e.g. Saturn ring shadowing)
+    ALLOCATE(eclipse(ngrid))
+
+    write(*,*) 'Rings shadow activated'
+        
+    if(diurnal .eqv. .false.) then ! we need to compute the daily average insolation (day fraction) 
+        pas = 1./nb_hours
+        ptime_day = 0.
+        fract(:) = 0.
+        ALLOCATE(tmp_fract(ngrid))
+        ALLOCATE(tmp_mu0(ngrid))
+        tmp_fract(:) = 0.
+        eclipse(:) = 0.
+        tmp_mu0(:) = 0.
+                    
+        do m=1, nb_hours
+            ptime_day = m*pas
+            call stellarlong(pday+ptime_day,tmp_zls)
+            call orbite(tmp_zls,tmp_dist_star,tmp_declin,tmp_right_ascen)
+            
+            ztim1=SIN(tmp_declin)
+            ztim2=COS(tmp_declin)*COS(2.*pi*(pday+ptime_day-.5))
+            ztim3=-COS(tmp_declin)*SIN(2.*pi*(pday+ptime_day-.5))
+
+            call stelang(ngrid,sinlon,coslon,sinlat,coslat,    &
+                        ztim1,ztim2,ztim3,tmp_mu0,tmp_fract, flatten)       
+            call rings(ngrid, tmp_declin, ptime_day, rad, flatten, eclipse)
+            fract(:) = fract(:) + (1.-eclipse(:))*tmp_fract(:) !! fract takes into account the rings shadow and the day/night alternation
+
+        enddo        
+     
+        fract(:) = fract(:)/nb_hours
+
+        DEALLOCATE(tmp_fract)
+        DEALLOCATE(tmp_mu0)
+                 
+     else   ! instant insolation is weighted by the rings shadow 
+            call rings(ngrid, declin, ptime, rad, 0., eclipse)
+            fract(:) = fract(:) * (1.-eclipse)
+    endif
+
+    IF (ALLOCATED(eclipse)) DEALLOCATE(eclipse)
+
+end subroutine call_rings
Index: /trunk/LMDZ.TITAN/libf/phytitan/callcorrk.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/callcorrk.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/callcorrk.F90	(revision 1644)
@@ -0,0 +1,967 @@
+      subroutine callcorrk(ngrid,nlayer,pq,nq,qsurf,           &
+          albedo,albedo_equivalent,emis,mu0,pplev,pplay,pt,    & 
+          tsurf,fract,dist_star,aerosol,muvar,                 &
+          dtlw,dtsw,fluxsurf_lw,                               &
+          fluxsurf_sw,fluxsurfabs_sw,fluxtop_lw,               &
+          fluxabs_sw,fluxtop_dn,                               &
+          OLR_nu,OSR_nu,                                       &
+          tau_col,cloudfrac,totcloudfrac,                      &
+          clearsky,firstcall,lastcall)
+
+      use radinc_h
+      use radcommon_h
+      use watercommon_h
+      use datafile_mod, only: datadir
+      use ioipsl_getin_p_mod, only: getin_p
+      use gases_h
+      use radii_mod, only : su_aer_radii,co2_reffrad,h2o_reffrad,dust_reffrad,h2so4_reffrad,back2lay_reffrad
+      use aerosol_mod, only : iaero_co2,iaero_h2o,iaero_dust,iaero_h2so4, iaero_back2lay
+      USE tracer_h
+      use comcstfi_mod, only: pi, mugaz, cpp
+      use callkeys_mod, only: varactive,diurnal,tracer,water,nosurf,varfixed,satval,        &
+                              kastprof,strictboundcorrk,specOLR,CLFvarying
+
+      implicit none
+
+!==================================================================
+!
+!     Purpose
+!     -------
+!     Solve the radiative transfer using the correlated-k method for
+!     the gaseous absorption and the Toon et al. (1989) method for
+!     scatttering due to aerosols.
+!
+!     Authors
+!     ------- 
+!     Emmanuel 01/2001, Forget 09/2001
+!     Robin Wordsworth (2009)
+!
+!==================================================================
+
+!-----------------------------------------------------------------------
+!     Declaration of the arguments (INPUT - OUTPUT) on the LMD GCM grid
+!     Layer #1 is the layer near the ground. 
+!     Layer #nlayer is the layer at the top.
+!-----------------------------------------------------------------------
+
+
+      ! INPUT
+      INTEGER,INTENT(IN) :: ngrid                  ! Number of atmospheric columns.
+      INTEGER,INTENT(IN) :: nlayer                 ! Number of atmospheric layers.
+      REAL,INTENT(IN) :: pq(ngrid,nlayer,nq)       ! Tracers (kg/kg_of_air).
+      INTEGER,INTENT(IN) :: nq                     ! Number of tracers.
+      REAL,INTENT(IN) :: qsurf(ngrid,nq)           ! Tracers on surface (kg.m-2).
+      REAL,INTENT(IN) :: albedo(ngrid,L_NSPECTV)   ! Spectral Short Wavelengths Albedo. By MT2015
+      REAL,INTENT(IN) :: emis(ngrid)               ! Long Wave emissivity.
+      REAL,INTENT(IN) :: mu0(ngrid)                ! Cosine of sun incident angle.
+      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1)     ! Inter-layer pressure (Pa).
+      REAL,INTENT(IN) :: pplay(ngrid,nlayer)       ! Mid-layer pressure (Pa).
+      REAL,INTENT(IN) :: pt(ngrid,nlayer)          ! Air temperature (K).
+      REAL,INTENT(IN) :: tsurf(ngrid)              ! Surface temperature (K).
+      REAL,INTENT(IN) :: fract(ngrid)              ! Fraction of day.
+      REAL,INTENT(IN) :: dist_star                 ! Distance star-planet (AU).
+      REAL,INTENT(IN) :: muvar(ngrid,nlayer+1)
+      REAL,INTENT(IN) :: cloudfrac(ngrid,nlayer)   ! Fraction of clouds (%).
+      logical,intent(in) :: clearsky
+      logical,intent(in) :: firstcall              ! Signals first call to physics.
+      logical,intent(in) :: lastcall               ! Signals last call to physics.
+      
+      ! OUTPUT
+      REAL,INTENT(OUT) :: aerosol(ngrid,nlayer,naerkind) ! Aerosol tau (kg/kg).
+      REAL,INTENT(OUT) :: dtlw(ngrid,nlayer)             ! Heating rate (K/s) due to LW radiation.
+      REAL,INTENT(OUT) :: dtsw(ngrid,nlayer)             ! Heating rate (K/s) due to SW radiation.
+      REAL,INTENT(OUT) :: fluxsurf_lw(ngrid)             ! Incident LW flux to surf (W/m2).
+      REAL,INTENT(OUT) :: fluxsurf_sw(ngrid)             ! Incident SW flux to surf (W/m2)
+      REAL,INTENT(OUT) :: fluxsurfabs_sw(ngrid)          ! Absorbed SW flux by the surface (W/m2). By MT2015.
+      REAL,INTENT(OUT) :: fluxtop_lw(ngrid)              ! Outgoing LW flux to space (W/m2).
+      REAL,INTENT(OUT) :: fluxabs_sw(ngrid)              ! SW flux absorbed by the planet (W/m2).
+      REAL,INTENT(OUT) :: fluxtop_dn(ngrid)              ! Incident top of atmosphere SW flux (W/m2).
+      REAL,INTENT(OUT) :: OLR_nu(ngrid,L_NSPECTI)        ! Outgoing LW radition in each band (Normalized to the band width (W/m2/cm-1).
+      REAL,INTENT(OUT) :: OSR_nu(ngrid,L_NSPECTV)        ! Outgoing SW radition in each band (Normalized to the band width (W/m2/cm-1).
+      REAL,INTENT(OUT) :: tau_col(ngrid)                 ! Diagnostic from aeropacity.
+      REAL,INTENT(OUT) :: albedo_equivalent(ngrid)       ! Spectrally Integrated Albedo. For Diagnostic. By MT2015
+      REAL,INTENT(OUT) :: totcloudfrac(ngrid)            ! Column Fraction of clouds (%).
+      
+      
+      
+      
+
+      ! Globally varying aerosol optical properties on GCM grid ; not needed everywhere so not in radcommon_h.   
+      REAL :: QVISsQREF3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL :: omegaVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL :: gVIS3d(ngrid,nlayer,L_NSPECTV,naerkind)
+      REAL :: QIRsQREF3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL :: omegaIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+      REAL :: gIR3d(ngrid,nlayer,L_NSPECTI,naerkind)
+
+!      REAL :: omegaREFvis3d(ngrid,nlayer,naerkind)
+!      REAL :: omegaREFir3d(ngrid,nlayer,naerkind) ! not sure of the point of these...
+
+      REAL,ALLOCATABLE,SAVE :: reffrad(:,:,:)  ! aerosol effective radius (m)
+      REAL,ALLOCATABLE,SAVE :: nueffrad(:,:,:) ! aerosol effective variance
+!$OMP THREADPRIVATE(reffrad,nueffrad)
+
+!-----------------------------------------------------------------------
+!     Declaration of the variables required by correlated-k subroutines
+!     Numbered from top to bottom (unlike in the GCM)
+!-----------------------------------------------------------------------
+
+      REAL*8 tmid(L_LEVELS),pmid(L_LEVELS)
+      REAL*8 tlevrad(L_LEVELS),plevrad(L_LEVELS)
+
+      ! Optical values for the optci/cv subroutines
+      REAL*8 stel(L_NSPECTV),stel_fract(L_NSPECTV)
+      REAL*8 dtaui(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+      REAL*8 dtauv(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+      REAL*8 cosbv(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+      REAL*8 cosbi(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+      REAL*8 wbari(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+      REAL*8 wbarv(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+      REAL*8 tauv(L_NLEVRAD,L_NSPECTV,L_NGAUSS)
+      REAL*8 taucumv(L_LEVELS,L_NSPECTV,L_NGAUSS)
+      REAL*8 taucumi(L_LEVELS,L_NSPECTI,L_NGAUSS)
+
+      REAL*8 tauaero(L_LEVELS+1,naerkind)
+      REAL*8 nfluxtopv,nfluxtopi,nfluxtop,fluxtopvdn
+      REAL*8 nfluxoutv_nu(L_NSPECTV)                 ! Outgoing band-resolved VI flux at TOA (W/m2).
+      REAL*8 nfluxtopi_nu(L_NSPECTI)                 ! Net band-resolved IR flux at TOA (W/m2).
+      REAL*8 fluxupi_nu(L_NLAYRAD,L_NSPECTI)         ! For 1D diagnostic.
+      REAL*8 fmneti(L_NLAYRAD),fmnetv(L_NLAYRAD)
+      REAL*8 fluxupv(L_NLAYRAD),fluxupi(L_NLAYRAD)
+      REAL*8 fluxdnv(L_NLAYRAD),fluxdni(L_NLAYRAD)
+      REAL*8 albi,acosz
+      REAL*8 albv(L_NSPECTV)                         ! Spectral Visible Albedo.
+
+      INTEGER ig,l,k,nw,iaer
+
+      real szangle
+      logical global1d
+      save szangle,global1d
+!$OMP THREADPRIVATE(szangle,global1d)
+      real*8 taugsurf(L_NSPECTV,L_NGAUSS-1)
+      real*8 taugsurfi(L_NSPECTI,L_NGAUSS-1)
+      real*8 qvar(L_LEVELS)                    ! Mixing ratio of variable component (mol/mol).
+
+      ! Local aerosol optical properties for each column on RADIATIVE grid.
+      real*8,save,allocatable ::  QXVAER(:,:,:)
+      real*8,save,allocatable ::  QSVAER(:,:,:)
+      real*8,save,allocatable ::  GVAER(:,:,:)
+      real*8,save,allocatable ::  QXIAER(:,:,:)
+      real*8,save,allocatable ::  QSIAER(:,:,:)
+      real*8,save,allocatable ::  GIAER(:,:,:)
+
+      real, dimension(:,:,:), save, allocatable :: QREFvis3d
+      real, dimension(:,:,:), save, allocatable :: QREFir3d
+!$OMP THREADPRIVATE(QXVAER,QSVAER,GVAER,QXIAER,QSIAER,GIAER,QREFvis3d,QREFir3d)
+
+
+      ! Miscellaneous :
+      real*8  temp,temp1,temp2,pweight
+      character(len=10) :: tmp1
+      character(len=10) :: tmp2
+
+      ! For fixed water vapour profiles.
+      integer i_var
+      real RH
+      real*8 pq_temp(nlayer)
+! real(KIND=r8) :: pq_temp(nlayer) ! better F90 way.. DOESNT PORT TO F77!!!
+      real ptemp, Ttemp, qsat
+
+      logical OLRz
+      real*8 NFLUXGNDV_nu(L_NSPECTV)
+
+      ! Included by RW for runaway greenhouse 1D study.
+      real vtmp(nlayer)
+      REAL*8 muvarrad(L_LEVELS)
+      
+      ! Included by MT for albedo calculations.      
+      REAL*8 albedo_temp(L_NSPECTV) ! For equivalent albedo calculation.
+      REAL*8 surface_stellar_flux   ! Stellar flux reaching the surface. Useful for equivalent albedo calculation.
+
+
+!===============================================================
+!           I.a Initialization on first call
+!===============================================================
+
+
+      if(firstcall) then
+
+        ! test on allocated necessary because of CLFvarying (two calls to callcorrk in physiq)
+        if(.not.allocated(QXVAER)) allocate(QXVAER(L_LEVELS+1,L_NSPECTV,naerkind))
+        if(.not.allocated(QSVAER)) allocate(QSVAER(L_LEVELS+1,L_NSPECTV,naerkind))
+        if(.not.allocated(GVAER)) allocate(GVAER(L_LEVELS+1,L_NSPECTV,naerkind))
+        if(.not.allocated(QXIAER)) allocate(QXIAER(L_LEVELS+1,L_NSPECTI,naerkind))
+        if(.not.allocated(QSIAER)) allocate(QSIAER(L_LEVELS+1,L_NSPECTI,naerkind))
+        if(.not.allocated(GIAER)) allocate(GIAER(L_LEVELS+1,L_NSPECTI,naerkind))
+
+         !!! ALLOCATED instances are necessary because of CLFvarying (strategy to call callcorrk twice in physiq...)
+         IF(.not.ALLOCATED(QREFvis3d)) ALLOCATE(QREFvis3d(ngrid,nlayer,naerkind))
+         IF(.not.ALLOCATED(QREFir3d)) ALLOCATE(QREFir3d(ngrid,nlayer,naerkind))
+         ! Effective radius and variance of the aerosols
+         IF(.not.ALLOCATED(reffrad)) allocate(reffrad(ngrid,nlayer,naerkind))
+         IF(.not.ALLOCATED(nueffrad)) allocate(nueffrad(ngrid,nlayer,naerkind))
+
+         call system('rm -f surf_vals_long.out')
+
+         if(naerkind.gt.4)then
+            print*,'Code not general enough to deal with naerkind > 4 yet.'
+            call abort
+         endif
+         call su_aer_radii(ngrid,nlayer,reffrad,nueffrad)
+         
+         
+!--------------------------------------------------
+!             Set up correlated k
+!--------------------------------------------------
+
+
+         print*, "callcorrk: Correlated-k data base folder:",trim(datadir)
+         call getin_p("corrkdir",corrkdir)
+         print*, "corrkdir = ",corrkdir
+         write( tmp1, '(i3)' ) L_NSPECTI
+         write( tmp2, '(i3)' ) L_NSPECTV
+         banddir=trim(adjustl(tmp1))//'x'//trim(adjustl(tmp2))
+         banddir=trim(adjustl(corrkdir))//'/'//trim(adjustl(banddir))
+
+         call setspi            ! Basic infrared properties.
+         call setspv            ! Basic visible properties.
+         call sugas_corrk       ! Set up gaseous absorption properties.
+         call suaer_corrk       ! Set up aerosol optical properties.
+        
+
+         if((igcm_h2o_vap.eq.0) .and. varactive)then
+            print*,'varactive in callcorrk but no h2o_vap tracer.'
+            stop
+         endif
+
+         OLR_nu(:,:) = 0.
+         OSR_nu(:,:) = 0.
+
+         if (ngrid.eq.1) then
+            PRINT*, 'Simulate global averaged conditions ?'
+            global1d = .false. ! default value
+            call getin_p("global1d",global1d)
+            write(*,*) "global1d = ",global1d
+            
+            ! Test of incompatibility : if global1d is true, there should not be any diurnal cycle.
+            if (global1d.and.diurnal) then
+               print*,'if global1d is true, diurnal must be set to false'
+               stop
+            endif
+
+            if (global1d) then
+               PRINT *,'Solar Zenith angle (deg.) ?'
+               PRINT *,'(assumed for averaged solar flux S/4)'
+               szangle=60.0  ! default value
+               call getin_p("szangle",szangle)
+               write(*,*) "szangle = ",szangle
+            endif
+         endif
+
+      end if ! of if (firstcall)
+
+!=======================================================================
+!          I.b  Initialization on every call   
+!=======================================================================
+ 
+      qxvaer(:,:,:)=0.0
+      qsvaer(:,:,:)=0.0
+      gvaer(:,:,:) =0.0
+
+      qxiaer(:,:,:)=0.0
+      qsiaer(:,:,:)=0.0
+      giaer(:,:,:) =0.0
+
+!--------------------------------------------------
+!     Effective radius and variance of the aerosols
+!--------------------------------------------------
+
+      do iaer=1,naerkind
+
+         if ((iaer.eq.iaero_co2).and.tracer.and.(igcm_co2_ice.gt.0)) then ! Treat condensed co2 particles.
+            call co2_reffrad(ngrid,nlayer,nq,pq,reffrad(1,1,iaero_co2))
+            print*,'Max. CO2 ice particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
+            print*,'Min. CO2 ice particle size = ',minval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
+         end if
+         
+         if ((iaer.eq.iaero_h2o).and.water) then ! Treat condensed water particles. To be generalized for other aerosols ...
+            call h2o_reffrad(ngrid,nlayer,pq(1,1,igcm_h2o_ice),pt, &
+                             reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
+            print*,'Max. H2O cloud particle size = ',maxval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
+            print*,'Min. H2O cloud particle size = ',minval(reffrad(1:ngrid,1:nlayer,iaer))/1.e-6,' um'
+         endif
+         
+         if(iaer.eq.iaero_dust)then
+            call dust_reffrad(ngrid,nlayer,reffrad(1,1,iaero_dust))
+            print*,'Dust particle size = ',reffrad(1,1,iaer)/1.e-6,' um'
+         endif
+         
+         if(iaer.eq.iaero_h2so4)then
+            call h2so4_reffrad(ngrid,nlayer,reffrad(1,1,iaero_h2so4))
+            print*,'H2SO4 particle size =',reffrad(1,1,iaer)/1.e-6,' um'
+         endif
+         
+          if(iaer.eq.iaero_back2lay)then
+            call back2lay_reffrad(ngrid,reffrad(1,1,iaero_back2lay),nlayer,pplev)
+         endif
+         
+     end do !iaer=1,naerkind.
+
+
+      ! How much light do we get ?
+      do nw=1,L_NSPECTV
+         stel(nw)=stellarf(nw)/(dist_star**2)
+      end do
+
+      ! Get 3D aerosol optical properties.
+      call aeroptproperties(ngrid,nlayer,reffrad,nueffrad,         &
+           QVISsQREF3d,omegaVIS3d,gVIS3d,                          &
+           QIRsQREF3d,omegaIR3d,gIR3d,                             &
+           QREFvis3d,QREFir3d)                                     
+
+      ! Get aerosol optical depths.
+      call aeropacity(ngrid,nlayer,nq,pplay,pplev,pq,aerosol,      &
+           reffrad,QREFvis3d,QREFir3d,                             & 
+           tau_col,cloudfrac,totcloudfrac,clearsky)                
+          
+
+
+!-----------------------------------------------------------------------    
+      do ig=1,ngrid ! Starting Big Loop over every GCM column
+!-----------------------------------------------------------------------
+
+
+!=======================================================================
+!              II.  Transformation of the GCM variables
+!=======================================================================
+
+
+!-----------------------------------------------------------------------
+!    Aerosol optical properties Qext, Qscat and g.
+!    The transformation in the vertical is the same as for temperature.
+!-----------------------------------------------------------------------
+           
+           
+            do iaer=1,naerkind
+               ! Shortwave.
+               do nw=1,L_NSPECTV 
+               
+                  do l=1,nlayer
+
+                     temp1=QVISsQREF3d(ig,nlayer+1-l,nw,iaer)         &
+                         *QREFvis3d(ig,nlayer+1-l,iaer)
+
+                     temp2=QVISsQREF3d(ig,max(nlayer-l,1),nw,iaer)    &
+                         *QREFvis3d(ig,max(nlayer-l,1),iaer)
+
+                     qxvaer(2*l,nw,iaer)  = temp1
+                     qxvaer(2*l+1,nw,iaer)=(temp1+temp2)/2
+
+                     temp1=temp1*omegavis3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=temp2*omegavis3d(ig,max(nlayer-l,1),nw,iaer)
+
+                     qsvaer(2*l,nw,iaer)  = temp1
+                     qsvaer(2*l+1,nw,iaer)=(temp1+temp2)/2
+
+                     temp1=gvis3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=gvis3d(ig,max(nlayer-l,1),nw,iaer)
+
+                     gvaer(2*l,nw,iaer)  = temp1
+                     gvaer(2*l+1,nw,iaer)=(temp1+temp2)/2
+
+                  end do ! nlayer
+
+                  qxvaer(1,nw,iaer)=qxvaer(2,nw,iaer)
+                  qxvaer(2*nlayer+1,nw,iaer)=0.
+
+                  qsvaer(1,nw,iaer)=qsvaer(2,nw,iaer)
+                  qsvaer(2*nlayer+1,nw,iaer)=0.
+
+                  gvaer(1,nw,iaer)=gvaer(2,nw,iaer)
+                  gvaer(2*nlayer+1,nw,iaer)=0.
+
+               end do ! L_NSPECTV
+             
+               do nw=1,L_NSPECTI
+                  ! Longwave
+                  do l=1,nlayer
+
+                     temp1=QIRsQREF3d(ig,nlayer+1-l,nw,iaer)         &
+                          *QREFir3d(ig,nlayer+1-l,iaer)
+
+                     temp2=QIRsQREF3d(ig,max(nlayer-l,1),nw,iaer)    &
+                          *QREFir3d(ig,max(nlayer-l,1),iaer)
+
+                     qxiaer(2*l,nw,iaer)  = temp1
+                     qxiaer(2*l+1,nw,iaer)=(temp1+temp2)/2
+
+                     temp1=temp1*omegair3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=temp2*omegair3d(ig,max(nlayer-l,1),nw,iaer)
+
+                     qsiaer(2*l,nw,iaer)  = temp1
+                     qsiaer(2*l+1,nw,iaer)=(temp1+temp2)/2
+
+                     temp1=gir3d(ig,nlayer+1-l,nw,iaer)
+                     temp2=gir3d(ig,max(nlayer-l,1),nw,iaer)
+
+                     giaer(2*l,nw,iaer)  = temp1
+                     giaer(2*l+1,nw,iaer)=(temp1+temp2)/2
+
+                  end do ! nlayer
+
+                  qxiaer(1,nw,iaer)=qxiaer(2,nw,iaer)
+                  qxiaer(2*nlayer+1,nw,iaer)=0.
+
+                  qsiaer(1,nw,iaer)=qsiaer(2,nw,iaer)
+                  qsiaer(2*nlayer+1,nw,iaer)=0.
+
+                  giaer(1,nw,iaer)=giaer(2,nw,iaer)
+                  giaer(2*nlayer+1,nw,iaer)=0.
+
+               end do ! L_NSPECTI
+               
+            end do ! naerkind
+
+            ! Test / Correct for freaky s. s. albedo values.
+            do iaer=1,naerkind
+               do k=1,L_LEVELS+1
+
+                  do nw=1,L_NSPECTV
+                     if(qsvaer(k,nw,iaer).gt.1.05*qxvaer(k,nw,iaer))then
+                        print*,'Serious problems with qsvaer values' 
+                        print*,'in callcorrk'
+                        call abort
+                     endif
+                     if(qsvaer(k,nw,iaer).gt.qxvaer(k,nw,iaer))then
+                        qsvaer(k,nw,iaer)=qxvaer(k,nw,iaer)
+                     endif
+                  end do
+
+                  do nw=1,L_NSPECTI 
+                     if(qsiaer(k,nw,iaer).gt.1.05*qxiaer(k,nw,iaer))then
+                        print*,'Serious problems with qsiaer values'
+                        print*,'in callcorrk'
+                        call abort
+                     endif
+                     if(qsiaer(k,nw,iaer).gt.qxiaer(k,nw,iaer))then
+                        qsiaer(k,nw,iaer)=qxiaer(k,nw,iaer)
+                     endif
+                  end do
+
+               end do ! L_LEVELS
+            end do ! naerkind
+
+!-----------------------------------------------------------------------
+!     Aerosol optical depths
+!-----------------------------------------------------------------------
+            
+         do iaer=1,naerkind     ! a bug was here           
+            do k=0,nlayer-1
+               
+               pweight=(pplay(ig,L_NLAYRAD-k)-pplev(ig,L_NLAYRAD-k+1))/   &
+                       (pplev(ig,L_NLAYRAD-k)-pplev(ig,L_NLAYRAD-k+1))
+               temp=aerosol(ig,L_NLAYRAD-k,iaer)/QREFvis3d(ig,L_NLAYRAD-k,iaer)
+               tauaero(2*k+2,iaer)=max(temp*pweight,0.d0)
+               tauaero(2*k+3,iaer)=max(temp-tauaero(2*k+2,iaer),0.d0)
+
+            end do
+            ! boundary conditions
+            tauaero(1,iaer)          = tauaero(2,iaer)
+            tauaero(L_LEVELS+1,iaer) = tauaero(L_LEVELS,iaer)
+            !tauaero(1,iaer)          = 0.
+            !tauaero(L_LEVELS+1,iaer) = 0.
+            
+         end do ! naerkind
+
+         ! Albedo and Emissivity.
+         albi=1-emis(ig)   ! Long Wave.
+         DO nw=1,L_NSPECTV ! Short Wave loop.
+            albv(nw)=albedo(ig,nw)
+         ENDDO
+
+         if (nosurf) then ! Case with no surface.
+            DO nw=1,L_NSPECTV
+               if(albv(nw).gt.0.0) then
+                  print*,'For open lower boundary in callcorrk must'
+                  print*,'have spectral surface band albedos all set to zero!'
+                  call abort
+               endif
+            ENDDO         
+         endif
+
+      if ((ngrid.eq.1).and.(global1d)) then ! Fixed zenith angle 'szangle' in 1D simulations w/ globally-averaged sunlight.
+         acosz = cos(pi*szangle/180.0)
+         print*,'acosz=',acosz,', szangle=',szangle
+      else
+         acosz=mu0(ig) ! Cosine of sun incident angle : 3D simulations or local 1D simulations using latitude.
+      endif
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!! Note by JL13 : In the following, some indices were changed in the interpolations,
+!!!                so that the model results are less dependent on the number of layers !
+!!!
+!!!           ---  The older versions are commented with the comment !JL13index  ---
+!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+!-----------------------------------------------------------------------
+!     Water vapour (to be generalised for other gases eventually ...)
+!-----------------------------------------------------------------------
+      
+      if(varactive)then
+
+         i_var=igcm_h2o_vap
+         do l=1,nlayer
+            qvar(2*l)   = pq(ig,nlayer+1-l,i_var)
+            qvar(2*l+1) = pq(ig,nlayer+1-l,i_var)    
+!JL13index            qvar(2*l+1) = (pq(ig,nlayer+1-l,i_var)+pq(ig,max(nlayer-l,1),i_var))/2    
+!JL13index            ! Average approximation as for temperature...
+         end do
+         qvar(1)=qvar(2)
+
+      elseif(varfixed)then
+
+         do l=1,nlayer ! Here we will assign fixed water vapour profiles globally.
+            RH = satval * ((pplay(ig,l)/pplev(ig,1) - 0.02) / 0.98)
+            if(RH.lt.0.0) RH=0.0
+            
+            ptemp=pplay(ig,l)
+            Ttemp=pt(ig,l)
+            call watersat(Ttemp,ptemp,qsat)
+
+            !pq_temp(l) = qsat      ! fully saturated everywhere
+            pq_temp(l) = RH * qsat ! ~realistic profile (e.g. 80% saturation at ground)
+         end do
+         
+         do l=1,nlayer
+            qvar(2*l)   = pq_temp(nlayer+1-l)
+            qvar(2*l+1) = (pq_temp(nlayer+1-l)+pq_temp(max(nlayer-l,1)))/2
+         end do
+         
+         qvar(1)=qvar(2)
+
+         ! Lowest layer of atmosphere
+         RH = satval * (1 - 0.02) / 0.98
+         if(RH.lt.0.0) RH=0.0
+
+!         ptemp = pplev(ig,1)
+!         Ttemp = tsurf(ig)
+!         call watersat(Ttemp,ptemp,qsat)
+
+         qvar(2*nlayer+1)= RH * qsat ! ~realistic profile (e.g. 80% saturation at ground)
+ 
+      else
+         do k=1,L_LEVELS
+            qvar(k) = 1.0D-7
+         end do
+      end if ! varactive/varfixed
+
+      if(.not.kastprof)then
+         ! IMPORTANT: Now convert from kg/kg to mol/mol.
+         do k=1,L_LEVELS
+            qvar(k) = qvar(k)/(epsi+qvar(k)*(1.-epsi))
+         end do
+      end if
+
+!-----------------------------------------------------------------------
+!     kcm mode only !
+!-----------------------------------------------------------------------
+
+      if(kastprof)then
+
+         ! Initial values equivalent to mugaz.
+         DO l=1,nlayer
+            muvarrad(2*l)   = mugaz
+            muvarrad(2*l+1) = mugaz
+         END DO
+
+         if(ngasmx.gt.1)then
+
+            DO l=1,nlayer
+               muvarrad(2*l)   =  muvar(ig,nlayer+2-l)
+               muvarrad(2*l+1) = (muvar(ig,nlayer+2-l) + &
+                                  muvar(ig,max(nlayer+1-l,1)))/2
+            END DO
+      
+            muvarrad(1) = muvarrad(2)
+            muvarrad(2*nlayer+1) = muvar(ig,1)
+
+            print*,'Recalculating qvar with VARIABLE epsi for kastprof'
+            print*,'Assumes that the variable gas is H2O!!!'
+            print*,'Assumes that there is only one tracer'
+            
+            !i_var=igcm_h2o_vap
+            i_var=1
+            
+            if(nq.gt.1)then
+               print*,'Need 1 tracer only to run kcm1d.e' 
+               stop
+            endif
+            
+            do l=1,nlayer
+               vtmp(l)=pq(ig,l,i_var)/(epsi+pq(ig,l,i_var)*(1.-epsi)) 
+               !vtmp(l)=pq(ig,l,i_var)*muvar(ig,l+1)/mH2O !JL to be changed
+            end do
+
+            do l=1,nlayer
+               qvar(2*l)   = vtmp(nlayer+1-l)
+               qvar(2*l+1) = vtmp(nlayer+1-l)
+!               qvar(2*l+1) = ( vtmp(nlayer+1-l) + vtmp(max(nlayer-l,1)) )/2
+            end do
+            qvar(1)=qvar(2)
+
+            print*,'Warning: reducing qvar in callcorrk.'
+            print*,'Temperature profile no longer consistent ', &
+                   'with saturated H2O. qsat=',satval
+                   
+            do k=1,L_LEVELS
+               qvar(k) = qvar(k)*satval
+            end do
+
+         endif
+      else ! if kastprof
+         DO l=1,nlayer
+            muvarrad(2*l)   = muvar(ig,nlayer+2-l)
+            muvarrad(2*l+1) = (muvar(ig,nlayer+2-l)+muvar(ig,max(nlayer+1-l,1)))/2
+         END DO
+      
+         muvarrad(1) = muvarrad(2)
+         muvarrad(2*nlayer+1)=muvar(ig,1)         
+      endif ! if kastprof
+      
+      ! Keep values inside limits for which we have radiative transfer coefficients !!!
+      if(L_REFVAR.gt.1)then ! (there was a bug here)
+         do k=1,L_LEVELS
+            if(qvar(k).lt.wrefvar(1))then
+               qvar(k)=wrefvar(1)+1.0e-8
+            elseif(qvar(k).gt.wrefvar(L_REFVAR))then
+               qvar(k)=wrefvar(L_REFVAR)-1.0e-8
+            endif
+         end do
+      endif
+
+!-----------------------------------------------------------------------
+!     Pressure and temperature
+!-----------------------------------------------------------------------
+
+      DO l=1,nlayer
+         plevrad(2*l)   = pplay(ig,nlayer+1-l)/scalep
+         plevrad(2*l+1) = pplev(ig,nlayer+1-l)/scalep
+         tlevrad(2*l)   = pt(ig,nlayer+1-l)
+         tlevrad(2*l+1) = (pt(ig,nlayer+1-l)+pt(ig,max(nlayer-l,1)))/2
+      END DO
+      
+      plevrad(1) = 0.
+      plevrad(2) = 0.   !! Trick to have correct calculations of fluxes in gflux(i/v).F, but the pmid levels are not impacted by this change.
+
+      tlevrad(1) = tlevrad(2)
+      tlevrad(2*nlayer+1)=tsurf(ig)
+      
+      pmid(1) = max(pgasmin,0.0001*plevrad(3))
+      pmid(2) =  pmid(1)
+
+      tmid(1) = tlevrad(2)
+      tmid(2) = tmid(1)
+    
+      DO l=1,L_NLAYRAD-1
+         tmid(2*l+1) = tlevrad(2*l+1)
+         tmid(2*l+2) = tlevrad(2*l+1)
+         pmid(2*l+1) = plevrad(2*l+1)
+         pmid(2*l+2) = plevrad(2*l+1)
+      END DO
+      pmid(L_LEVELS) = plevrad(L_LEVELS)
+      tmid(L_LEVELS) = tlevrad(L_LEVELS)
+
+!!Alternative interpolation:
+!         pmid(3) = pmid(1)
+!         pmid(4) = pmid(1) 
+!         tmid(3) = tmid(1)
+!         tmid(4) = tmid(1)
+!      DO l=2,L_NLAYRAD-1
+!         tmid(2*l+1) = tlevrad(2*l)
+!         tmid(2*l+2) = tlevrad(2*l)
+!         pmid(2*l+1) = plevrad(2*l)
+!         pmid(2*l+2) = plevrad(2*l)
+!      END DO
+!      pmid(L_LEVELS) = plevrad(L_LEVELS-1)
+!      tmid(L_LEVELS) = tlevrad(L_LEVELS-1)
+
+      ! Test for out-of-bounds pressure.
+      if(plevrad(3).lt.pgasmin)then
+         print*,'Minimum pressure is outside the radiative'
+         print*,'transfer kmatrix bounds, exiting.'
+         call abort
+      elseif(plevrad(L_LEVELS).gt.pgasmax)then
+         print*,'Maximum pressure is outside the radiative'
+         print*,'transfer kmatrix bounds, exiting.'
+         call abort
+      endif
+
+      ! Test for out-of-bounds temperature.
+      do k=1,L_LEVELS
+         if(tlevrad(k).lt.tgasmin)then
+            print*,'Minimum temperature is outside the radiative'
+            print*,'transfer kmatrix bounds'
+            print*,"k=",k," tlevrad(k)=",tlevrad(k)
+            print*,"tgasmin=",tgasmin
+            if (strictboundcorrk) then
+              call abort
+            else
+              print*,'***********************************************'
+              print*,'we allow model to continue with tlevrad=tgasmin' 
+              print*,'  ... we assume we know what you are doing ... '
+              print*,'  ... but do not let this happen too often ... '
+              print*,'***********************************************'
+              !tlevrad(k)=tgasmin
+            endif
+         elseif(tlevrad(k).gt.tgasmax)then
+            print*,'Maximum temperature is outside the radiative'
+            print*,'transfer kmatrix bounds, exiting.'
+            print*,"k=",k," tlevrad(k)=",tlevrad(k)
+            print*,"tgasmax=",tgasmax
+            if (strictboundcorrk) then
+              call abort
+            else
+              print*,'***********************************************'
+              print*,'we allow model to continue with tlevrad=tgasmax'  
+              print*,'  ... we assume we know what you are doing ... '
+              print*,'  ... but do not let this happen too often ... '
+              print*,'***********************************************'
+              !tlevrad(k)=tgasmax
+            endif
+         endif
+      enddo
+      do k=1,L_NLAYRAD+1
+         if(tmid(k).lt.tgasmin)then
+            print*,'Minimum temperature is outside the radiative'
+            print*,'transfer kmatrix bounds, exiting.'
+            print*,"k=",k," tmid(k)=",tmid(k)
+            print*,"tgasmin=",tgasmin
+            if (strictboundcorrk) then
+              call abort
+            else
+              print*,'***********************************************'
+              print*,'we allow model to continue with tmid=tgasmin'
+              print*,'  ... we assume we know what you are doing ... '
+              print*,'  ... but do not let this happen too often ... '
+              print*,'***********************************************'
+              tmid(k)=tgasmin
+            endif
+         elseif(tmid(k).gt.tgasmax)then
+            print*,'Maximum temperature is outside the radiative'
+            print*,'transfer kmatrix bounds, exiting.'
+            print*,"k=",k," tmid(k)=",tmid(k)
+            print*,"tgasmax=",tgasmax
+            if (strictboundcorrk) then
+              call abort
+            else
+              print*,'***********************************************'
+              print*,'we allow model to continue with tmid=tgasmin'
+              print*,'  ... we assume we know what you are doing ... '
+              print*,'  ... but do not let this happen too often ... '
+              print*,'***********************************************'
+              tmid(k)=tgasmax
+            endif
+         endif
+      enddo
+
+!=======================================================================
+!          III. Calling the main radiative transfer subroutines
+!=======================================================================
+
+
+         Cmk= 0.01 * 1.0 / (glat(ig) * mugaz * 1.672621e-27) ! q_main=1.0 assumed.
+         glat_ig=glat(ig)
+
+!-----------------------------------------------------------------------
+!        Short Wave Part
+!-----------------------------------------------------------------------
+
+         if(fract(ig) .ge. 1.0e-4) then ! Only during daylight.
+            if((ngrid.eq.1).and.(global1d))then
+               do nw=1,L_NSPECTV
+                  stel_fract(nw)= stel(nw)* 0.25 / acosz ! globally averaged = divide by 4, and we correct for solar zenith angle
+               end do
+            else
+               do nw=1,L_NSPECTV
+                  stel_fract(nw)= stel(nw) * fract(ig)
+               end do
+            endif
+            
+            call optcv(dtauv,tauv,taucumv,plevrad,                 &
+                 qxvaer,qsvaer,gvaer,wbarv,cosbv,tauray,tauaero,   &
+                 tmid,pmid,taugsurf,qvar,muvarrad)
+
+            call sfluxv(dtauv,tauv,taucumv,albv,dwnv,wbarv,cosbv,  &
+                 acosz,stel_fract,gweight,                         &
+                 nfluxtopv,fluxtopvdn,nfluxoutv_nu,nfluxgndv_nu,              &
+                 fmnetv,fluxupv,fluxdnv,fzerov,taugsurf)
+
+         else ! During the night, fluxes = 0.
+            nfluxtopv       = 0.0d0
+            fluxtopvdn      = 0.0d0
+            nfluxoutv_nu(:) = 0.0d0
+            nfluxgndv_nu(:) = 0.0d0
+            do l=1,L_NLAYRAD
+               fmnetv(l)=0.0d0
+               fluxupv(l)=0.0d0
+               fluxdnv(l)=0.0d0
+            end do
+         end if
+
+
+         ! Equivalent Albedo Calculation (for OUTPUT). MT2015
+         if(fract(ig) .ge. 1.0e-4) then ! equivalent albedo makes sense only during daylight.       
+            surface_stellar_flux=sum(nfluxgndv_nu(1:L_NSPECTV))      
+            if(surface_stellar_flux .gt. 1.0e-3) then ! equivalent albedo makes sense only if the stellar flux received by the surface is positive.
+               DO nw=1,L_NSPECTV                  
+                  albedo_temp(nw)=albedo(ig,nw)*nfluxgndv_nu(nw)
+               ENDDO
+               albedo_temp(1:L_NSPECTV)=albedo_temp(1:L_NSPECTV)/surface_stellar_flux
+               albedo_equivalent(ig)=sum(albedo_temp(1:L_NSPECTV))
+            else
+               albedo_equivalent(ig)=0.0 ! Spectrally Integrated Albedo not defined for non-irradiated grid points. So we arbitrary set the equivalent albedo to 0.
+            endif
+         else
+            albedo_equivalent(ig)=0.0 ! Spectrally Integrated Albedo not defined for non-irradiated grid points. So we arbitrary set the equivalent albedo to 0.
+         endif
+
+
+!-----------------------------------------------------------------------
+!        Long Wave Part
+!-----------------------------------------------------------------------
+
+         call optci(plevrad,tlevrad,dtaui,taucumi,                  &
+              qxiaer,qsiaer,giaer,cosbi,wbari,tauaero,tmid,pmid,    &
+              taugsurfi,qvar,muvarrad)
+
+         call sfluxi(plevrad,tlevrad,dtaui,taucumi,ubari,albi,      &
+              wnoi,dwni,cosbi,wbari,gweight,nfluxtopi,nfluxtopi_nu, & 
+              fmneti,fluxupi,fluxdni,fluxupi_nu,fzeroi,taugsurfi)
+
+!-----------------------------------------------------------------------
+!     Transformation of the correlated-k code outputs
+!     (into dtlw, dtsw, fluxsurf_lw, fluxsurf_sw, fluxtop_lw, fluxtop_sw)
+
+!     Flux incident at the top of the atmosphere
+         fluxtop_dn(ig)=fluxtopvdn 
+
+         fluxtop_lw(ig)  = real(nfluxtopi)
+         fluxabs_sw(ig)  = real(-nfluxtopv)
+         fluxsurf_lw(ig) = real(fluxdni(L_NLAYRAD))
+         fluxsurf_sw(ig) = real(fluxdnv(L_NLAYRAD))
+         
+!        Flux absorbed by the surface. By MT2015.         
+         fluxsurfabs_sw(ig) = fluxsurf_sw(ig)*(1.-albedo_equivalent(ig))
+
+         if(fluxtop_dn(ig).lt.0.0)then
+            print*,'Achtung! fluxtop_dn has lost the plot!'
+            print*,'fluxtop_dn=',fluxtop_dn(ig)
+            print*,'acosz=',acosz
+            print*,'aerosol=',aerosol(ig,:,:)
+            print*,'temp=   ',pt(ig,:)
+            print*,'pplay=  ',pplay(ig,:)
+            call abort
+         endif
+
+!     Spectral output, for exoplanet observational comparison
+         if(specOLR)then
+            do nw=1,L_NSPECTI 
+               OLR_nu(ig,nw)=nfluxtopi_nu(nw)/DWNI(nw) !JL Normalize to the bandwidth
+            end do
+            do nw=1,L_NSPECTV 
+               !GSR_nu(ig,nw)=nfluxgndv_nu(nw)
+               OSR_nu(ig,nw)=nfluxoutv_nu(nw)/DWNV(nw) !JL Normalize to the bandwidth
+            end do
+         endif
+
+!     Finally, the heating rates
+
+         DO l=2,L_NLAYRAD
+            dtsw(ig,L_NLAYRAD+1-l)=(fmnetv(l)-fmnetv(l-1))  &
+                *glat(ig)/(cpp*scalep*(plevrad(2*l+1)-plevrad(2*l-1)))
+            dtlw(ig,L_NLAYRAD+1-l)=(fmneti(l)-fmneti(l-1))  &
+                *glat(ig)/(cpp*scalep*(plevrad(2*l+1)-plevrad(2*l-1)))
+         END DO      
+
+!     These are values at top of atmosphere
+         dtsw(ig,L_NLAYRAD)=(fmnetv(1)-nfluxtopv)           &
+             *glat(ig)/(cpp*scalep*(plevrad(3)-plevrad(1)))
+         dtlw(ig,L_NLAYRAD)=(fmneti(1)-nfluxtopi)           &
+             *glat(ig)/(cpp*scalep*(plevrad(3)-plevrad(1)))
+
+
+!-----------------------------------------------------------------------    
+      end do ! End of big loop over every GCM column.
+!-----------------------------------------------------------------------
+
+
+
+!-----------------------------------------------------------------------
+!     Additional diagnostics
+!-----------------------------------------------------------------------
+
+      ! IR spectral output, for exoplanet observational comparison
+      if(lastcall.and.(ngrid.eq.1))then  ! could disable the 1D output, they are in the diagfi and diagspec... JL12
+
+         print*,'Saving scalar quantities in surf_vals.out...'
+         print*,'psurf = ', pplev(1,1),' Pa'
+         open(116,file='surf_vals.out')
+         write(116,*) tsurf(1),pplev(1,1),fluxtop_dn(1),         &
+                      real(-nfluxtopv),real(nfluxtopi) 
+         close(116)
+
+
+!          USEFUL COMMENT - Do Not Remove.
+!
+!           if(specOLR)then
+!               open(117,file='OLRnu.out')
+!               do nw=1,L_NSPECTI
+!                  write(117,*) OLR_nu(1,nw)
+!               enddo
+!               close(117)
+!
+!               open(127,file='OSRnu.out')
+!               do nw=1,L_NSPECTV
+!                  write(127,*) OSR_nu(1,nw)
+!               enddo
+!               close(127)
+!           endif
+
+           ! OLR vs altitude: do it as a .txt file.
+         OLRz=.false.
+         if(OLRz)then
+            print*,'saving IR vertical flux for OLRz...'
+            open(118,file='OLRz_plevs.out')
+            open(119,file='OLRz.out')
+            do l=1,L_NLAYRAD
+               write(118,*) plevrad(2*l)
+               do nw=1,L_NSPECTI
+                  write(119,*) fluxupi_nu(l,nw) 
+               enddo
+            enddo 
+            close(118)
+            close(119)
+         endif
+
+      endif
+
+      ! See physiq.F for explanations about CLFvarying. This is temporary.
+      if (lastcall .and. .not.CLFvarying) then
+        IF( ALLOCATED( gasi ) ) DEALLOCATE( gasi )
+        IF( ALLOCATED( gasv ) ) DEALLOCATE( gasv )
+!$OMP BARRIER
+!$OMP MASTER
+        IF( ALLOCATED( pgasref ) ) DEALLOCATE( pgasref )
+        IF( ALLOCATED( tgasref ) ) DEALLOCATE( tgasref )
+        IF( ALLOCATED( wrefvar ) ) DEALLOCATE( wrefvar )
+        IF( ALLOCATED( pfgasref ) ) DEALLOCATE( pfgasref )
+!$OMP END MASTER
+!$OMP BARRIER
+        IF ( ALLOCATED(reffrad)) DEALLOCATE(reffrad)
+        IF ( ALLOCATED(nueffrad)) DEALLOCATE(nueffrad)
+      endif
+
+
+    end subroutine callcorrk
Index: /trunk/LMDZ.TITAN/libf/phytitan/callkeys_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/callkeys_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/callkeys_mod.F90	(revision 1644)
@@ -0,0 +1,107 @@
+MODULE callkeys_mod
+IMPLICIT NONE  
+
+      logical,save :: callrad,corrk,calldifv,UseTurbDiff
+!$OMP THREADPRIVATE(callrad,corrk,calldifv,UseTurbDiff)
+      logical,save :: calladj,co2cond,callsoil
+!$OMP THREADPRIVATE(calladj,co2cond,callsoil)
+      logical,save :: season,diurnal,tlocked,rings_shadow,lwrite
+!$OMP THREADPRIVATE(season,diurnal,tlocked,rings_shadow,lwrite)
+      logical,save :: callstats,calleofdump
+!$OMP THREADPRIVATE(callstats,calleofdump)
+      logical,save :: callgasvis,continuum,H2Ocont_simple,graybody
+!$OMP THREADPRIVATE(callgasvis,continuum,H2Ocont_simple,graybody)
+      logical,save :: strictboundcorrk                                     
+!$OMP THREADPRIVATE(strictboundcorrk)
+
+      logical,save :: enertest
+      logical,save :: nonideal
+      logical,save :: meanOLR
+      logical,save :: specOLR
+      logical,save :: kastprof
+!$OMP THREADPRIVATE(enertest,nonideal,meanOLR,kastprof)
+      logical,save :: newtonian
+      logical,save :: check_cpp_match
+      logical,save :: force_cpp
+      logical,save :: testradtimes
+      logical,save :: rayleigh
+!$OMP THREADPRIVATE(newtonian,check_cpp_match,force_cpp,testradtimes,rayleigh)
+      logical,save :: stelbbody
+      logical,save :: ozone
+      logical,save :: nearco2cond
+      logical,save :: tracer
+      logical,save :: mass_redistrib
+!$OMP THREADPRIVATE(stelbbody,ozone,nearco2cond,tracer,mass_redistrib)
+      logical,save :: varactive
+      logical,save :: varfixed
+      logical,save :: radfixed
+      logical,save :: sedimentation
+!$OMP THREADPRIVATE(varactive,varfixed,radfixed,sedimentation)
+      logical,save :: water,watercond,waterrain
+!$OMP THREADPRIVATE(water,watercond,waterrain)
+      logical,save :: aeroco2,aeroh2o,aeroh2so4,aeroback2lay
+!$OMP THREADPRIVATE(aeroco2,aeroh2o,aeroh2so4,aeroback2lay)
+      logical,save :: aerofixco2,aerofixh2o
+!$OMP THREADPRIVATE(aerofixco2,aerofixh2o)
+      logical,save :: hydrology
+      logical,save :: sourceevol
+      logical,save :: CLFvarying
+      logical,save :: nosurf
+      logical,save :: oblate
+!$OMP THREADPRIVATE(hydrology,sourceevol,CLFvarying,nosurf,oblate)
+      logical,save :: ok_slab_ocean
+      logical,save :: ok_slab_sic
+      logical,save :: ok_slab_heat_transp
+      logical,save :: albedo_spectral_mode
+!$OMP THREADPRIVATE(ok_slab_ocean,ok_slab_sic,ok_slab_heat_transp,albedo_spectral_mode)
+
+      integer,save :: iddist
+      integer,save :: iaervar
+      integer,save :: iradia
+      integer,save :: startype
+!$OMP THREADPRIVATE(iddist,iaervar,iradia,startype)
+
+      real,save :: topdustref
+      real,save :: Nmix_co2
+      real,save :: dusttau
+      real,save :: Fat1AU
+      real,save :: stelTbb
+!$OMP THREADPRIVATE(topdustref,Nmix_co2,dusttau,Fat1AU,stelTbb)
+      real,save :: Tstrat
+      real,save :: tplanet
+      real,save :: obs_tau_col_tropo
+      real,save :: obs_tau_col_strato
+!$OMP THREADPRIVATE(Tstrat,tplanet,obs_tau_col_tropo,obs_tau_col_strato)
+      real,save :: pres_bottom_tropo
+      real,save :: pres_top_tropo
+      real,save :: pres_bottom_strato
+      real,save :: pres_top_strato
+!$OMP THREADPRIVATE(pres_bottom_tropo,pres_top_tropo,pres_bottom_strato,pres_top_strato)
+      real,save :: size_tropo
+      real,save :: size_strato
+      real,save :: satval
+      real,save :: CLFfixval
+      real,save :: n2mixratio
+!$OMP THREADPRIVATE(size_tropo,size_strato,satval,CLFfixval,n2mixratio)
+      real,save :: co2supsat
+      real,save :: pceil
+      real,save :: albedosnow
+      real,save :: albedoco2ice
+      real,save :: maxicethick
+!$OMP THREADPRIVATE(co2supsat,pceil,albedosnow,albedoco2ice,maxicethick)
+      real,save :: Tsaldiff
+      real,save :: tau_relax
+      real,save :: cloudlvl
+      real,save :: icetstep
+      real,save :: intheat
+!$OMP THREADPRIVATE(Tsaldiff,tau_relax,cloudlvl,icetstep,intheat)
+      real,save :: flatten
+      real,save :: Rmean
+      real,save :: J2
+      real,save :: MassPlanet
+!$OMP THREADPRIVATE(flatten,Rmean,J2,MassPlanet)
+
+      logical,save :: iscallphys=.false.!existence of callphys.def
+!$OMP THREADPRIVATE(iscallphys)
+
+END MODULE callkeys_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/callsedim.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/callsedim.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/callsedim.F	(revision 1644)
@@ -0,0 +1,157 @@
+      SUBROUTINE callsedim(ngrid,nlay, ptimestep,
+     &                pplev,zlev, pt, pdt,
+     &                pq, pdqfi, pdqsed,pdqs_sed,nq)
+
+      use radinc_h, only : naerkind
+      use radii_mod, only: h2o_reffrad
+      use aerosol_mod, only : iaero_h2o
+      USE tracer_h, only : igcm_co2_ice,igcm_h2o_ice,radius,rho_q
+      use comcstfi_mod, only: g
+      use callkeys_mod, only : water
+
+      IMPLICIT NONE
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates sedimentation of aerosols depending on their
+!     density and radius.
+!     
+!     Authors
+!     -------
+!     F. Forget (1999)
+!     Tracer generalisation by E. Millour (2009)
+!     
+!==================================================================
+
+c-----------------------------------------------------------------------
+c   declarations:
+c   -------------
+
+c   arguments:
+c   ----------
+
+      integer,intent(in):: ngrid ! number of horizontal grid points
+      integer,intent(in):: nlay  ! number of atmospheric layers
+      real,intent(in):: ptimestep  ! physics time step (s)
+      real,intent(in):: pplev(ngrid,nlay+1) ! pressure at inter-layers (Pa)
+      real,intent(in):: pt(ngrid,nlay)      ! temperature at mid-layer (K)
+      real,intent(in):: pdt(ngrid,nlay) ! tendency on temperature
+      real,intent(in):: zlev(ngrid,nlay+1)  ! altitude at layer boundaries
+      integer,intent(in) :: nq ! number of tracers
+      real,intent(in) :: pq(ngrid,nlay,nq)  ! tracers (kg/kg)
+      real,intent(in) :: pdqfi(ngrid,nlay,nq)  ! tendency on tracers before
+                                               ! sedimentation (kg/kg.s-1)
+      
+      real,intent(out) :: pdqsed(ngrid,nlay,nq) ! tendency due to sedimentation (kg/kg.s-1)
+      real,intent(out) :: pdqs_sed(ngrid,nq)    ! flux at surface (kg.m-2.s-1)
+      
+c   local:
+c   ------
+
+      INTEGER l,ig, iq
+
+      ! for particles with varying radii:
+      real reffrad(ngrid,nlay,naerkind) ! particle radius (m) 
+      real nueffrad(ngrid,nlay,naerkind) ! aerosol effective radius variance
+
+      real zqi(ngrid,nlay,nq) ! to locally store tracers
+      real zt(ngrid,nlay) ! to locally store temperature (K)
+      real masse (ngrid,nlay) ! Layer mass (kg.m-2)
+      real epaisseur (ngrid,nlay) ! Layer thickness (m)
+      real wq(ngrid,nlay+1) ! displaced tracer mass (kg.m-2)
+c      real dens(ngrid,nlay) ! Mean density of the ice part. accounting for dust core
+
+
+      LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+
+c    ** un petit test de coherence
+c       --------------------------
+
+      IF (firstcall) THEN
+        firstcall=.false.
+        ! add some tests on presence of required tracers/aerosols:
+        if (water) then
+          if (igcm_h2o_ice.eq.0) then
+            write(*,*) "callsedim error: water=.true.",
+     &                 " but igcm_h2o_ice=0"
+          stop
+          endif
+          if (iaero_h2o.eq.0) then
+            write(*,*) "callsedim error: water=.true.",
+     &                 " but iaero_ho2=0"
+          stop
+          endif
+        endif
+      ENDIF ! of IF (firstcall)
+      
+!=======================================================================
+!     Preliminary calculation of the layer characteristics
+!     (mass (kg.m-2), thickness (m), etc.
+
+      do  l=1,nlay
+        do ig=1, ngrid
+          masse(ig,l)=(pplev(ig,l) - pplev(ig,l+1)) /g 
+          epaisseur(ig,l)= zlev(ig,l+1) - zlev(ig,l)
+          zt(ig,l)=pt(ig,l)+pdt(ig,l)*ptimestep
+        end do
+      end do
+
+!======================================================================
+! Calculate the transport due to sedimentation for each tracer
+! [This has been rearranged by L. Kerber to allow the sedimentation
+!  of general tracers.]
+ 
+      do iq=1,nq
+       if((radius(iq).gt.1.e-9).and.(iq.ne.igcm_co2_ice)) then   
+!         (no sedim for gases, and co2_ice sedim is done in condense_co2)      
+
+! store locally updated tracers
+
+          do l=1,nlay 
+            do ig=1, ngrid
+              zqi(ig,l,iq)=pq(ig,l,iq)+pdqfi(ig,l,iq)*ptimestep
+            enddo
+          enddo ! of do l=1,nlay
+        
+!======================================================================
+! Sedimentation 
+!======================================================================
+! Water          
+          if (water.and.(iq.eq.igcm_h2o_ice)) then
+            ! compute radii for h2o_ice 
+             call h2o_reffrad(ngrid,nlay,zqi(1,1,igcm_h2o_ice),zt,
+     &                reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
+            ! call sedimentation for h2o_ice
+             call newsedim(ngrid,nlay,ngrid*nlay,ptimestep,
+     &            pplev,masse,epaisseur,zt,reffrad(1,1,iaero_h2o),
+     &            rho_q(iq),zqi(1,1,igcm_h2o_ice),wq)
+
+! General Case
+          else 
+             call newsedim(ngrid,nlay,1,ptimestep,
+     &            pplev,masse,epaisseur,zt,radius(iq),rho_q(iq),
+     &            zqi(1,1,iq),wq)
+          endif
+
+!=======================================================================
+!     Calculate the tendencies
+!======================================================================
+
+          do ig=1,ngrid
+!     Ehouarn: with new way of tracking tracers by name, this is simply
+            pdqs_sed(ig,iq) = wq(ig,1)/ptimestep
+          end do
+
+          DO l = 1, nlay
+            DO ig=1,ngrid
+              pdqsed(ig,l,iq)=(zqi(ig,l,iq)-
+     &        (pq(ig,l,iq) + pdqfi(ig,l,iq)*ptimestep))/ptimestep
+            ENDDO
+          ENDDO
+       endif ! of no gases no co2_ice
+      enddo ! of do iq=1,nq
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/comcstfi_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/comcstfi_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/comcstfi_mod.F90	(revision 1644)
@@ -0,0 +1,15 @@
+MODULE comcstfi_mod
+IMPLICIT NONE
+      
+      REAL,SAVE :: pi ! something like 3.14159
+      REAL,SAVE :: rad ! radius of the planet (m)
+      REAL,SAVE :: g ! gravity (m/s2)
+      REAL,SAVE :: r ! reduced gas constant (r=8.314511/(mugaz/1000.0))
+      REAL,SAVE :: cpp ! Cp of the atmosphere
+      REAL,SAVE :: rcp ! r/cpp
+      REAL,SAVE :: mugaz ! molar mass of the atmosphere (g/mol)
+      REAL,SAVE :: omeg ! planet rotation rate (rad/s)
+      REAL,SAVE :: avocado ! something like 6.022e23
+!$OMP THREADPRIVATE(pi,rad,g,r,cpp,rcp,mugaz,omeg,avocado)
+
+END MODULE comcstfi_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/comdiurn_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/comdiurn_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/comdiurn_h.F90	(revision 1644)
@@ -0,0 +1,10 @@
+
+       module comdiurn_h
+
+       implicit none
+
+       real,allocatable,dimension(:),save :: sinlon, coslon, sinlat, coslat
+!$OMP THREADPRIVATE(sinlon,coslon,sinlat,coslat)
+
+       end module comdiurn_h
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/comg1d_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/comg1d_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/comg1d_mod.F90	(revision 1644)
@@ -0,0 +1,50 @@
+MODULE comg1d_mod
+IMPLICIT NONE  
+
+!.......................................................................
+!  le COMMON pour GRADS-1D
+!  (Utilise pour les sorties format Grads dans la version 1D du modele)
+!
+!  on peut se dire : "on ne sauvera pas plus de 1000 variables ... hein ?"
+!
+      INTEGER g1d_nvarmx
+      PARAMETER(g1d_nvarmx=1000)
+
+!         * g1d_nlayer     ---> nombre de couches verticales
+!         * g1d_nomfich    ---> nom du fichier grads
+!         * g1d_unitfich   ---> code du fichier grads
+!         * g1d_nomctl     ---> nom du fichier ctl
+!         * g1d_unitctl    ---> code du fichier ctl
+!         * g1d_premier    ---> variable logique pour dire si le fichier
+!                               est deja ouvert
+!         * g1d_irec       ---> indice de derniere ecriture
+!         * g1d_nvar       ---> nombre de variables deja definies a la
+!                               derniere ecriture
+!         * g1d_nomvar     ---> noms des vecteurs existants
+!         * g1d_dimvar     ---> taille des vecteurs
+!         * g1d_titrevar   ---> titres des vecteurs
+!         * g1d_tmp1       ---> caractere 
+!         * g1d_tmp2       ---> caractere 
+
+      INTEGER g1d_nlayer
+      CHARACTER*100 g1d_nomfich
+      INTEGER g1d_unitfich
+      CHARACTER*100 g1d_nomctl
+      INTEGER g1d_unitctl
+      LOGICAL g1d_premier
+      LOGICAL g2d_premier
+      INTEGER g1d_irec
+      INTEGER g2d_irec
+      INTEGER g2d_appel
+      INTEGER g1d_nvar
+      CHARACTER*100 g1d_nomvar(0:g1d_nvarmx)
+      INTEGER g1d_dimvar(0:g1d_nvarmx)
+      CHARACTER*100 g1d_titrevar(0:g1d_nvarmx)
+      CHARACTER*100 g1d_tmp1,g1d_tmp2
+
+!     added by RW
+      integer saveG1D
+!
+!.......................................................................
+
+END MODULE comg1d_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/comgeomfi_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/comgeomfi_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/comgeomfi_h.F90	(revision 1644)
@@ -0,0 +1,11 @@
+
+       module comgeomfi_h
+
+       implicit none
+
+       REAL,SAVE :: totarea ! total surface (m2) for this local (MPI/OpenMP) domain
+       REAL,SAVE :: totarea_planet ! total planetary surface (m2)
+!$OMP THREADPRIVATE(totarea,totarea_planet)
+
+       end module comgeomfi_h
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/comsaison_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/comsaison_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/comsaison_h.F90	(revision 1644)
@@ -0,0 +1,13 @@
+
+       module comsaison_h
+
+       implicit none 
+
+       integer isaison
+       logical callsais
+       real dist_star,declin,right_ascen
+
+       real, allocatable, dimension(:) :: mu0,fract
+!$OMP THREADPRIVATE(isaison,callsais,dist_star,declin,mu0,fract)
+
+       end module comsaison_h
Index: /trunk/LMDZ.TITAN/libf/phytitan/comsoil_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/comsoil_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/comsoil_h.F90	(revision 1644)
@@ -0,0 +1,37 @@
+module comsoil_h
+
+implicit none
+! nsoilmx : number of subterranean layers
+!integer, parameter :: nsoilmx = 18 ! for z1=0.0002 m, depth = 18 m => mars case 
+!integer, parameter :: nsoilmx = 13 ! for z1=0.03 m, depth = 104.8 m => earth case
+  integer,save :: nsoilmx = 18 ! default, but may be set in callphys.def
+! Full soil layer depths are set as: layer(k)=lay1_soil*alpha_soil**(k-1) , k=1,nsoil
+! Mid soil layer depths are set as: mlayer(k)=lay1_soil*alpha_soil**(k-1/2) , k=0,nsoil-1 
+  real,save :: lay1_soil=2.e-4 ! depth (m) of first full soil layer (may be set in callphys.def)
+  real,save :: alpha_soil=2 ! coefficient for soil layer thickness (may be set in callphys.def)
+!$OMP THREADPRIVATE(nsoilmx,lay1_soil,alpha_soil)
+
+  real,save,allocatable,dimension(:) :: layer      ! soil layer depths
+  real,save,allocatable,dimension(:) :: mlayer     ! soil mid-layer depths
+  real,save,allocatable,dimension(:,:) :: inertiedat ! soil thermal inertia
+  real,save :: volcapa    ! soil volumetric heat capacity
+       ! NB: volcapa is read fromn control(35) from physicq start file
+       !     in physdem (or set via tabfi, or initialized in
+       !                 soil_settings.F)
+!$OMP THREADPRIVATE(layer,mlayer,inertiedat,volcapa)
+
+contains
+
+  subroutine ini_comsoil_h(ngrid)
+  
+  implicit none
+  integer,intent(in) :: ngrid ! number of atmospheric columns
+  
+    if (.not.allocated(layer)) allocate(layer(nsoilmx)) !soil layer depths
+    if (.not.allocated(mlayer)) allocate(mlayer(0:nsoilmx-1)) ! soil mid-layer depths
+    if (.not.allocated(inertiedat)) allocate(inertiedat(ngrid,nsoilmx)) ! soil thermal inertia
+  
+  end subroutine ini_comsoil_h
+
+end module comsoil_h
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/condense_co2.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/condense_co2.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/condense_co2.F90	(revision 1644)
@@ -0,0 +1,524 @@
+      subroutine condense_co2(ngrid,nlayer,nq,ptimestep, &
+          pcapcal,pplay,pplev,ptsrf,pt,                  &
+          pdt,pdtsrf,pq,pdq,                             &
+          pqsurf,pdqsurfc,albedo,pemisurf,               &
+          albedo_bareground,albedo_co2_ice_SPECTV,       &
+          pdtc,pdtsrfc,pdpsrfc,pdqc)
+
+      use radinc_h, only : L_NSPECTV, naerkind
+      use gases_h, only: gfrac, igas_co2
+      use radii_mod, only : co2_reffrad
+      use aerosol_mod, only : iaero_co2
+      USE surfdat_h, only: emisice, emissiv
+      USE geometry_mod, only: latitude ! in radians
+      USE tracer_h, only: noms, rho_co2
+      use comcstfi_mod, only: g, r, cpp
+
+      implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Condense and/or sublime CO2 ice on the ground and in the atmosphere, and sediment the ice.
+!  
+!     Inputs
+!     ------
+!     ngrid                 Number of vertical columns.
+!     nlayer                Number of vertical layers.
+!     nq                    Number of tracers.
+!     ptimestep             Duration of the physical timestep (s).
+!     pplay(ngrid,nlayer)   Pressure layers (Pa).
+!     pplev(ngrid,nlayer+1) Pressure levels (Pa).
+!     pt(ngrid,nlayer)      Atmospheric Temperatures (K).
+!     ptsrf(ngrid)          Surface temperatures (K).
+!     pq(ngrid,nlayer,nq)   Atmospheric tracers mixing ratios (kg/kg of air).
+!     pqsurf(ngrid,nq)      Surface tracers (kg/m2).
+!     
+!     pdt(ngrid,nlayer)     Time derivative before condensation/sublimation of pt.
+!     pdtsrf(ngrid)         Time derivative before condensation/sublimation of ptsrf.
+!     pdq(ngrid,nlayer,nq)  Time derivative before condensation/sublimation of
+!
+!     albedo_bareground(ngrid)           Albedo of the bare ground.
+!     albedo_co2_ice_SPECTV(L_NSPECTV)   Spectral albedo of CO2 ice.
+!     
+!     Outputs
+!     -------
+!     pdpsrfc(ngrid)          \       Contribution of condensation/sublimation 
+!     pdtc(ngrid,nlayer)       \            to the time derivatives of 
+!     pdtsrfc(ngrid)           /     Surface Pressure, Atmospheric Temperatures,
+!     pdqsurfc(ngrid)         /         Surface Temperatures, Surface Tracers,
+!     pdqc(ngrid,nlayer,nq)  /                and Atmospheric Tracers.*
+!
+!     pemisurf(ngrid)              Emissivity of the surface.
+!     
+!     Both
+!     ----
+!     albedo(ngrid,L_NSPECTV)      Spectral albedo of the surface.
+!
+!     Authors
+!     ------- 
+!     Francois Forget (1996)
+!     Converted to Fortran 90 and slightly modified by R. Wordsworth (2009)
+!     Includes simplifed nucleation by J. Leconte (2011)
+!     
+!==================================================================
+
+!--------------------------
+!        Arguments
+!--------------------------
+
+
+      INTEGER,INTENT(IN) :: ngrid
+      INTEGER,INTENT(IN) :: nlayer
+      INTEGER,INTENT(IN) :: nq
+      REAL,INTENT(IN) :: ptimestep 
+      REAL,INTENT(IN) :: pcapcal(ngrid)
+      REAL,INTENT(IN) :: pplay(ngrid,nlayer)
+      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1)
+      REAL,INTENT(IN) :: ptsrf(ngrid)
+      REAL,INTENT(IN) :: pt(ngrid,nlayer)
+      REAL,INTENT(IN) :: pdt(ngrid,nlayer)
+      REAL,INTENT(IN) :: pdtsrf(ngrid)
+      REAL,INTENT(IN) :: pq(ngrid,nlayer,nq)
+      REAL,INTENT(IN) :: pqsurf(ngrid,nq)
+      REAL,INTENT(IN) :: pdq(ngrid,nlayer,nq)
+      REAL,INTENT(IN) :: albedo_bareground(ngrid)
+      REAL,INTENT(IN) :: albedo_co2_ice_SPECTV(L_NSPECTV)
+      REAL,INTENT(INOUT) :: albedo(ngrid,L_NSPECTV)
+      REAL,INTENT(OUT) :: pemisurf(ngrid)
+      REAL,INTENT(OUT) :: pdtc(ngrid,nlayer)
+      REAL,INTENT(OUT) :: pdtsrfc(ngrid)
+      REAL,INTENT(OUT) :: pdpsrfc(ngrid)
+      REAL,INTENT(OUT) :: pdqc(ngrid,nlayer,nq)
+      REAL,INTENT(OUT) :: pdqsurfc(ngrid)
+
+!------------------------------
+!       Local variables
+!------------------------------
+
+      INTEGER l,ig,icap,ilay,iq,nw,igas,it
+
+      REAL reffrad(ngrid,nlayer) ! Radius (m) of the CO2 ice particles.
+      REAL*8 zt(ngrid,nlayer)    ! Updated Atmospheric Temperatures (K).
+      REAL ztsrf(ngrid)          ! Updated Surface Temperatures (K).
+      REAL zq(ngrid,nlayer,nq)   ! Updated Atmospheric tracers mixing ratios (kg/kg of air).
+      REAL piceco2(ngrid)        ! Updated Surface Tracer (kg/m2).
+      REAL ztcond (ngrid,nlayer) ! Atmospheric Temperatures of condensation of CO2.
+      REAL ztnuc (ngrid,nlayer)  ! Atmospheric Nucleation Temperatures.
+      REAL ztcondsol(ngrid)      ! Temperatures of condensation of CO2 at the surface.
+      REAL zcondices(ngrid)      ! Condensation rate on the ground (kg/m2/s).
+      REAL zfallice(ngrid)       ! Flux of ice falling on the surface (kg/m2/s).
+      REAL Mfallice(ngrid)       ! Total amount of ice fallen to the ground during the timestep (kg/m2).
+      REAL wq(ngrid,nlayer+1)    ! Total amount of ice fallen to the ground during the timestep (kg/m2).
+      REAL subptimestep          ! Duration of the subtimestep (s) for the sedimentation.
+      Integer Ntime              ! Number of subtimesteps.
+      REAL masse (ngrid,nlayer)  ! Mass of atmospheric layers (kg/m2)
+      REAL w(ngrid,nlayer,nq)    !
+      REAL vstokes,reff          !
+      REAL ppco2                 !
+
+
+!------------------------------------------
+!         Saved local variables
+!------------------------------------------
+
+
+      REAL,SAVE :: latcond=5.9e5
+      REAL,SAVE :: ccond
+      REAL,SAVE,ALLOCATABLE,DIMENSION(:) :: emisref
+!$OMP THREADPRIVATE(latcond,ccond,emisref)
+      LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+      INTEGER,SAVE :: i_co2ice=0      ! co2 ice
+!$OMP THREADPRIVATE(i_co2ice)
+      CHARACTER(LEN=20) :: tracername ! to temporarily store text
+
+
+!------------------------------------------------
+!       Initialization at the first call
+!------------------------------------------------
+
+
+      IF (firstcall) THEN
+
+         ALLOCATE(emisref(ngrid))
+         ! Find CO2 ice tracer.
+         do iq=1,nq
+            tracername=noms(iq)
+            if (tracername.eq."co2_ice") then
+               i_co2ice=iq
+            endif
+         enddo
+         
+         write(*,*) "condense_co2: i_co2ice=",i_co2ice       
+
+         if((i_co2ice.lt.1))then
+            print*,'In condens_cloud but no CO2 ice tracer, exiting.'
+            print*,'Still need generalisation to arbitrary species!'
+            stop
+         endif
+
+         ccond=cpp/(g*latcond)
+         print*,'In condens_cloud: ccond=',ccond,' latcond=',latcond
+
+         ! Prepare special treatment if gas is not pure CO2
+         ! if (addn2) then
+         !    m_co2   = 44.01E-3 ! CO2 molecular mass (kg/mol)   
+         !    m_noco2 = 28.02E-3 ! N2 molecular mass (kg/mol)  
+         ! Compute A and B coefficient use to compute
+         ! mean molecular mass Mair defined by
+         ! 1/Mair = q(ico2)/m_co2 + (1-q(ico2))/m_noco2
+         ! 1/Mair = A*q(ico2) + B
+         ! A = (1/m_co2 - 1/m_noco2)
+         ! B = 1/m_noco2
+         ! endif
+
+         ! Minimum CO2 mixing ratio below which mixing occurs with layer above : qco2min =0.75  
+
+           firstcall=.false.
+      ENDIF
+
+
+!------------------------------------------------
+!        Tendencies initially set to 0
+!------------------------------------------------
+
+
+      pdqc(1:ngrid,1:nlayer,1:nq)     = 0.
+      pdtc(1:ngrid,1:nlayer)          = 0.
+      zq(1:ngrid,1:nlayer,1:nq)       = 0.
+      zt(1:ngrid,1:nlayer)            = 0.
+      Mfallice(1:ngrid)               = 0.      
+      zfallice(1:ngrid)               = 0.
+      zcondices(1:ngrid)              = 0.
+      pdtsrfc(1:ngrid)                = 0.
+      pdpsrfc(1:ngrid)                = 0.
+      pdqsurfc(1:ngrid)               = 0.
+
+
+!----------------------------------
+!     Atmospheric condensation
+!----------------------------------
+
+
+!     Compute CO2 Volume mixing ratio
+!     -------------------------------
+!      if (addn2) then
+!         DO l=1,nlayer
+!            DO ig=1,ngrid
+!              qco2=pq(ig,l,ico2)+pdq(ig,l,ico2)*ptimestep
+!              Mean air molecular mass = 1/(q(ico2)/m_co2 + (1-q(ico2))/m_noco2)
+!              mmean=1/(A*qco2 +B)
+!              vmr_co2(ig,l) = qco2*mmean/m_co2 
+!            ENDDO
+!         ENDDO
+!      else
+!         DO l=1,nlayer
+!            DO ig=1,ngrid
+!              vmr_co2(ig,l)=0.5
+!            ENDDO
+!         ENDDO
+!      end if
+
+
+      ! Forecast the atmospheric frost temperature 'ztcond' and nucleation temperature 'ztnuc'.
+      DO l=1,nlayer
+         DO ig=1,ngrid
+            ppco2=gfrac(igas_CO2)*pplay(ig,l)
+            call get_tcond_co2(ppco2,ztcond(ig,l))
+            call get_tnuc_co2(ppco2,ztnuc(ig,l))
+         ENDDO
+      ENDDO
+      
+      ! Initialize zq and zt at the beginning of the sub-timestep loop and qsurf.
+      DO ig=1,ngrid
+         piceco2(ig)=pqsurf(ig,i_co2ice)
+         DO l=1,nlayer
+            zt(ig,l)=pt(ig,l)
+            zq(ig,l,i_co2ice)=pq(ig,l,i_co2ice)
+            IF( zq(ig,l,i_co2ice).lt.-1.e-6 ) THEN
+               print*,'Uh-oh, zq = ',zq(ig,l,i_co2ice),'at ig,l=',ig,l
+               if(l.eq.1)then
+                  print*,'Perhaps the atmosphere is collapsing on surface...?'
+               endif
+            END IF
+         ENDDO
+      ENDDO
+
+      ! Calculate the mass of each atmospheric layer (kg.m-2)
+      do  ilay=1,nlayer
+         DO ig=1,ngrid
+            masse(ig,ilay)=(pplev(ig,ilay) - pplev(ig,ilay+1)) /g
+         end do
+      end do
+
+
+!-----------------------------------------------------------
+!     START CONDENSATION/SEDIMENTATION SUB-TIME LOOP
+!-----------------------------------------------------------
+
+
+      Ntime =  20  ! number of sub-timestep 
+      subptimestep = ptimestep/float(Ntime)           
+
+      ! Add the tendencies from other physical processes at each subtimstep.
+      DO it=1,Ntime
+         DO l=1,nlayer
+            DO ig=1,ngrid
+               zt(ig,l)   = zt(ig,l)   + pdt(ig,l)   * subptimestep
+               zq(ig,l,i_co2ice) = zq(ig,l,i_co2ice) + pdq(ig,l,i_co2ice) * subptimestep
+            END DO
+         END DO
+
+         ! Gravitational sedimentation starts.
+            
+         ! Sedimentation computed from radius computed from q in module radii_mod.
+	 call co2_reffrad(ngrid,nlayer,nq,zq,reffrad)
+	 
+         DO  ilay=1,nlayer
+            DO ig=1,ngrid
+
+               reff = reffrad(ig,ilay)
+
+               call stokes                      &
+                   (pplev(ig,ilay),pt(ig,ilay), &
+                    reff,vstokes,rho_co2)
+
+               !w(ig,ilay,i_co2ice) = 0.0
+               w(ig,ilay,i_co2ice) = vstokes *  subptimestep * &
+                   pplev(ig,ilay)/(r*pt(ig,ilay))
+
+            END DO
+         END DO
+
+         ! Computing q after sedimentation
+         call vlz_fi(ngrid,nlayer,zq(1,1,i_co2ice),2.,masse,w(1,1,i_co2ice),wq)
+
+
+         ! Progressively accumulating the flux to the ground.
+         ! Mfallice is the total amount of ice fallen to the ground.
+         DO ig=1,ngrid
+            Mfallice(ig) =  Mfallice(ig) + wq(ig,i_co2ice)
+         END DO
+
+!----------------------------------------------------------
+!       Condensation / sublimation in the atmosphere
+!----------------------------------------------------------
+!     (MODIFICATIONS FOR EARLY MARS: falling heat neglected, condensation of CO2 into tracer i_co2ice)
+
+
+         DO l=nlayer , 1, -1
+            DO ig=1,ngrid
+               pdtc(ig,l)=0.
+
+               ! ztcond-> ztnuc in test beneath to nucleate only when super saturation occurs(JL 2011)
+               IF ((zt(ig,l).LT.ztnuc(ig,l)).or.(zq(ig,l,i_co2ice).gt.1.E-10)) THEN 
+                  pdtc(ig,l)   = (ztcond(ig,l) - zt(ig,l))/subptimestep
+                  pdqc(ig,l,i_co2ice) = pdtc(ig,l)*ccond*g
+
+                  ! Case when the ice from above sublimes entirely
+                  IF ((zq(ig,l,i_co2ice).lt.-pdqc(ig,l,i_co2ice)*subptimestep) &
+                      .AND. (zq(ig,l,i_co2ice).gt.0)) THEN
+
+                     pdqc(ig,l,i_co2ice) = -zq(ig,l,i_co2ice)/subptimestep
+                     pdtc(ig,l)   =-zq(ig,l,i_co2ice)/(ccond*g*subptimestep)
+
+                  END IF
+
+                  ! Temperature and q after condensation
+                  zt(ig,l)   = zt(ig,l)   + pdtc(ig,l)   * subptimestep
+                  zq(ig,l,i_co2ice) = zq(ig,l,i_co2ice) + pdqc(ig,l,i_co2ice) * subptimestep
+               END IF
+
+            ENDDO
+         ENDDO
+         
+      ENDDO! end of subtimestep loop.
+
+      ! Computing global tendencies after the subtimestep.
+      DO l=1,nlayer
+         DO ig=1,ngrid
+            pdtc(ig,l) = &
+              (zt(ig,l) - (pt(ig,l) + pdt(ig,l)*ptimestep))/ptimestep
+            pdqc(ig,l,i_co2ice) = &
+              (zq(ig,l,i_co2ice)-(pq(ig,l,i_co2ice)+pdq(ig,l,i_co2ice)*ptimestep))/ptimestep
+         END DO
+      END DO
+      DO ig=1,ngrid
+         zfallice(ig) = Mfallice(ig)/ptimestep
+      END DO
+
+
+!-----------------------------------------------------------------------
+!              Condensation/sublimation on the ground
+!-----------------------------------------------------------------------
+
+
+      ! Forecast of ground temperature ztsrf and frost temperature ztcondsol.
+      DO ig=1,ngrid
+         ppco2=gfrac(igas_CO2)*pplay(ig,1)
+         call get_tcond_co2(ppco2,ztcondsol(ig))
+         
+         ztsrf(ig) = ptsrf(ig)
+
+         if((ztsrf(ig).le.ztcondsol(ig)+2.0).and.(ngrid.eq.1))then
+            print*,'CO2 is condensing on the surface in 1D. This atmosphere is doomed.'
+            print*,'T_surf = ',ztsrf,'K'
+            print*,'T_cond = ',ztcondsol,'K'
+            open(116,file='surf_vals.out')
+            write(116,*) 0.0, pplev(1,1), 0.0, 0.0
+            close(116)
+            call abort
+         endif
+
+         ztsrf(ig) = ptsrf(ig) + pdtsrf(ig)*ptimestep
+
+      ENDDO
+     
+      DO ig=1,ngrid
+      
+         IF(ig.GT.ngrid/2+1) THEN
+            icap=2
+         ELSE
+            icap=1
+         ENDIF
+
+         ! Loop over where we have condensation / sublimation
+         IF ((ztsrf(ig) .LT. ztcondsol(ig)) .OR.           &        ! ground condensation
+                    (zfallice(ig).NE.0.) .OR.              &        ! falling snow
+                    ((ztsrf(ig) .GT. ztcondsol(ig)) .AND.  &        ! ground sublimation
+                    ((piceco2(ig)+zfallice(ig)*ptimestep) .NE. 0.))) THEN
+
+
+            ! Condensation or partial sublimation of CO2 ice
+            zcondices(ig)=pcapcal(ig)*(ztcondsol(ig)-ztsrf(ig)) &
+                /(latcond*ptimestep)         
+            pdtsrfc(ig) = (ztcondsol(ig) - ztsrf(ig))/ptimestep
+
+            ! If the entire CO_2 ice layer sublimes
+            ! (including what has just condensed in the atmosphere)
+            IF((piceco2(ig)/ptimestep+zfallice(ig)).LE. &
+                -zcondices(ig))THEN
+               zcondices(ig) = -piceco2(ig)/ptimestep - zfallice(ig)
+               pdtsrfc(ig)=(latcond/pcapcal(ig))*       &
+                   (zcondices(ig))
+            END IF
+
+            ! Changing CO2 ice amount and pressure
+            piceco2(ig)  =  piceco2(ig)   + pdqsurfc(ig)*ptimestep
+            pdqsurfc(ig) =  zcondices(ig) + zfallice(ig)
+            pdpsrfc(ig)  = -pdqsurfc(ig)*g
+
+            IF(ABS(pdpsrfc(ig)*ptimestep).GT.pplev(ig,1)) THEN
+               PRINT*,'STOP in condens in condense_co2'
+               PRINT*,'condensing more than total mass'
+               PRINT*,'Grid point ',ig
+               PRINT*,'Ps = ',pplev(ig,1)
+               PRINT*,'d Ps = ',pdpsrfc(ig)
+               STOP
+            ENDIF
+         END IF
+         
+      ENDDO ! end of ngrid loop.
+
+
+!---------------------------------------------------------------------------------------------
+!     Surface albedo and emissivity of the ground below the snow (emisref)
+!---------------------------------------------------------------------------------------------
+
+
+      DO ig=1,ngrid
+      
+         IF(latitude(ig).LT.0.) THEN
+            icap=2 ! Southern Hemisphere
+         ELSE
+            icap=1 ! Nortnern hemisphere
+         ENDIF
+
+         if(.not.piceco2(ig).ge.0.) THEN
+            if(piceco2(ig).le.-1.e-8) print*,   &
+              'WARNING : in condense_co2cloud: piceco2(',ig,')=', piceco2(ig)
+            piceco2(ig)=0.
+         endif
+         if (piceco2(ig) .gt. 1.) then  ! CO2 Albedo condition changed to ~1 mm coverage. Change by MT2015.
+	    DO nw=1,L_NSPECTV
+               albedo(ig,nw) = albedo_co2_ice_SPECTV(nw)
+	    ENDDO
+            emisref(ig)   = emisice(icap)
+         else
+            DO nw=1,L_NSPECTV
+               albedo(ig,nw) = albedo_bareground(ig) ! Note : If you have some water, it will be taken into account in the "hydrol" routine.
+	    ENDDO
+            emisref(ig)   = emissiv
+            pemisurf(ig)  = emissiv
+         end if
+         
+      END DO
+
+      return
+      
+      end subroutine condense_co2
+
+
+
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+
+
+
+      subroutine get_tcond_co2(p,tcond)  ! Calculates the condensation temperature for CO2
+     
+
+      implicit none
+
+      real p, peff, tcond
+      real, parameter :: ptriple=518000.0
+
+      peff=p
+
+      if(peff.lt.ptriple) then
+         tcond = (-3167.8)/(log(.01*peff)-23.23) ! Fanale's formula.
+      else
+         tcond = 684.2-92.3*log(peff)+4.32*log(peff)**2 ! liquid-vapour transition (based on CRC handbook 2003 data)        
+      endif
+      return
+
+      end subroutine get_tcond_co2
+
+
+
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+!-------------------------------------------------------------------------
+
+
+
+      subroutine get_tnuc_co2(p,tnuc)
+      ! Calculates the nucleation temperature for CO2, based on a simple super saturation criterion. JL 2011.
+
+      use callkeys_mod, only: co2supsat
+
+      implicit none
+
+      real p, peff, tnuc
+      real, parameter :: ptriple=518000.0
+
+      peff=p/co2supsat
+
+      if(peff.lt.ptriple) then
+         tnuc = (-3167.8)/(log(.01*peff)-23.23) ! Fanale's formula
+      else
+         tnuc = 684.2-92.3*log(peff)+4.32*log(peff)**2 
+         ! liquid-vapour transition (based on CRC handbook 2003 data)
+      endif
+      
+      return
+
+      end subroutine get_tnuc_co2
Index: /trunk/LMDZ.TITAN/libf/phytitan/convadj.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/convadj.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/convadj.F	(revision 1644)
@@ -0,0 +1,418 @@
+      subroutine convadj(ngrid,nlay,nq,ptimestep,
+     &                   pplay,pplev,ppopsk,
+     &                   pu,pv,ph,pq,
+     &                   pdufi,pdvfi,pdhfi,pdqfi,
+     &                   pduadj,pdvadj,pdhadj,
+     &                   pdqadj)
+
+      USE tracer_h
+      use comcstfi_mod, only: g
+      use callkeys_mod, only: tracer,water
+
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates dry convective adjustment. If one tracer is CO2,
+!     we take into account the molecular mass variation (e.g. when
+!     CO2 condenses) to trigger convection (F. Forget 01/2005)
+!
+!     Authors
+!     -------
+!     Original author unknown.
+!     Modif. 2005 by F. Forget.
+!     
+!==================================================================
+
+!     ------------
+!     Declarations
+!     ------------
+
+
+!     Arguments
+!     ---------
+
+      INTEGER ngrid,nlay
+      REAL ptimestep
+      REAL ph(ngrid,nlay),pdhfi(ngrid,nlay),pdhadj(ngrid,nlay)
+      REAL pplay(ngrid,nlay),pplev(ngrid,nlay+1),ppopsk(ngrid,nlay)
+      REAL pu(ngrid,nlay),pdufi(ngrid,nlay),pduadj(ngrid,nlay)
+      REAL pv(ngrid,nlay),pdvfi(ngrid,nlay),pdvadj(ngrid,nlay)
+
+!     Tracers
+      integer nq
+      real pq(ngrid,nlay,nq), pdqfi(ngrid,nlay,nq)
+      real pdqadj(ngrid,nlay,nq)
+
+
+!     Local
+!     -----
+
+      INTEGER ig,i,l,l1,l2,jj
+      INTEGER jcnt, jadrs(ngrid)
+
+      REAL sig(nlay+1),sdsig(nlay),dsig(nlay)
+      REAL zu(ngrid,nlay),zv(ngrid,nlay)
+      REAL zh(ngrid,nlay)
+      REAL zu2(ngrid,nlay),zv2(ngrid,nlay)
+      REAL zh2(ngrid,nlay), zhc(ngrid,nlay)
+      REAL zhm,zsm,zdsm,zum,zvm,zalpha,zhmc
+
+!     Tracers
+      INTEGER iq,ico2
+      save ico2
+!$OMP THREADPRIVATE(ico2)
+      REAL zq(ngrid,nlay,nq), zq2(ngrid,nlay,nq)
+      REAL zqm(nq),zqco2m
+      real m_co2, m_noco2, A , B
+      save A, B
+!$OMP THREADPRIVATE(A,B)
+
+      real mtot1, mtot2 , mm1, mm2
+       integer l1ref, l2ref
+      LOGICAL vtest(ngrid),down,firstcall
+      save firstcall
+      data firstcall/.true./
+!$OMP THREADPRIVATE(firstcall)
+
+!     for conservation test
+      real masse,cadjncons
+
+      EXTERNAL SCOPY
+
+!     --------------
+!     Initialisation
+!     --------------
+
+      IF (firstcall) THEN 
+        ico2=0
+        if (tracer) then
+!     Prepare Special treatment if one of the tracers is CO2 gas
+           do iq=1,nq
+             if (noms(iq).eq."co2") then
+                print*,'dont go there'
+                stop
+                ico2=iq
+                m_co2 = 44.01E-3  ! CO2 molecular mass (kg/mol)   
+                m_noco2 = 33.37E-3  ! Non condensible mol mass (kg/mol)   
+!               Compute A and B coefficient use to compute
+!               mean molecular mass Mair defined by
+!               1/Mair = q(ico2)/m_co2 + (1-q(ico2))/m_noco2
+!               1/Mair = A*q(ico2) + B
+                A =(1/m_co2 - 1/m_noco2)
+                B=1/m_noco2
+             end if
+           enddo
+        endif
+        firstcall=.false.
+      ENDIF ! of IF (firstcall)
+
+      DO l=1,nlay
+         DO ig=1,ngrid
+            zh(ig,l)=ph(ig,l)+pdhfi(ig,l)*ptimestep
+            zu(ig,l)=pu(ig,l)+pdufi(ig,l)*ptimestep
+            zv(ig,l)=pv(ig,l)+pdvfi(ig,l)*ptimestep
+         ENDDO
+      ENDDO
+
+      if(tracer) then      
+        DO iq =1, nq
+         DO l=1,nlay
+           DO ig=1,ngrid
+              zq(ig,l,iq)=pq(ig,l,iq)+pdqfi(ig,l,iq)*ptimestep
+           ENDDO
+         ENDDO
+        ENDDO
+      end if
+
+      CALL scopy(ngrid*nlay,zh,1,zh2,1)
+      CALL scopy(ngrid*nlay,zu,1,zu2,1)
+      CALL scopy(ngrid*nlay,zv,1,zv2,1)
+      CALL scopy(ngrid*nlay*nq,zq,1,zq2,1)
+
+!     -----------------------------
+!     Detection of unstable columns
+!     -----------------------------
+!     If ph(above) < ph(below) we set vtest=.true.
+
+      DO ig=1,ngrid
+        vtest(ig)=.false.
+      ENDDO
+
+      if (ico2.ne.0) then
+!     Special case if one of the tracers is CO2 gas
+         DO l=1,nlay
+           DO ig=1,ngrid
+             zhc(ig,l) = zh2(ig,l)*(A*zq2(ig,l,ico2)+B)
+           ENDDO
+         ENDDO
+       else
+          CALL scopy(ngrid*nlay,zh2,1,zhc,1)
+       end if
+
+!     Find out which grid points are convectively unstable
+      DO l=2,nlay
+        DO ig=1,ngrid
+          IF(zhc(ig,l).LT.zhc(ig,l-1)) vtest(ig)=.true.
+        ENDDO
+      ENDDO
+
+!     Make a list of them
+      jcnt=0
+      DO ig=1,ngrid
+         IF(vtest(ig)) THEN
+            jcnt=jcnt+1
+            jadrs(jcnt)=ig
+         ENDIF
+      ENDDO
+
+
+!     ---------------------------------------------------------------
+!     Adjustment of the "jcnt" unstable profiles indicated by "jadrs"
+!     ---------------------------------------------------------------
+
+      DO jj = 1, jcnt   ! loop on every convective grid point
+
+          i = jadrs(jj)
+ 
+!     Calculate sigma in this column
+          DO l=1,nlay+1
+            sig(l)=pplev(i,l)/pplev(i,1)
+        
+          ENDDO
+         DO l=1,nlay
+            dsig(l)=sig(l)-sig(l+1)
+            sdsig(l)=ppopsk(i,l)*dsig(l)
+         ENDDO
+          l2 = 1
+
+!     Test loop upwards on l2
+
+          DO
+            l2 = l2 + 1
+            IF (l2 .GT. nlay) EXIT
+            IF (zhc(i, l2) .LT. zhc(i, l2-1)) THEN
+ 
+!     l2 is the highest level of the unstable column
+ 
+              l1 = l2 - 1
+              l  = l1
+              zsm = sdsig(l2)
+              zdsm = dsig(l2)
+              zhm = zh2(i, l2)
+              if(ico2.ne.0) zqco2m = zq2(i,l2,ico2)
+
+!     Test loop downwards
+
+              DO
+                zsm = zsm + sdsig(l)
+                zdsm = zdsm + dsig(l)
+                zhm = zhm + sdsig(l) * (zh2(i, l) - zhm) / zsm
+                if(ico2.ne.0) then
+                  zqco2m = 
+     &            zqco2m + dsig(l) * (zq2(i,l,ico2) - zqco2m) / zdsm
+                  zhmc = zhm*(A*zqco2m+B)
+                else 
+                  zhmc = zhm
+                end if
+ 
+!     do we have to extend the column downwards?
+ 
+                down = .false.
+                IF (l1 .ne. 1) then    !--  and then
+                  IF (zhmc .lt. zhc(i, l1-1)) then
+                    down = .true.
+                  END IF
+                END IF
+ 
+                ! this could be a problem...
+
+                if (down) then
+ 
+                  l1 = l1 - 1
+                  l  = l1
+ 
+                else
+ 
+!     can we extend the column upwards?
+ 
+                  if (l2 .eq. nlay) exit
+ 
+                  if (zhc(i, l2+1) .ge. zhmc) exit
+
+                  l2 = l2 + 1
+                  l  = l2
+
+                end if
+
+              enddo
+
+!     New constant profile (average value)
+
+
+              zalpha=0.
+              zum=0.
+              zvm=0.
+              do iq=1,nq
+                zqm(iq) = 0.
+              end do
+              DO l = l1, l2
+                if(ico2.ne.0) then
+                  zalpha=zalpha+
+     &            ABS(zhc(i,l)/(A+B*zqco2m) -zhm)*dsig(l)
+                else
+                  zalpha=zalpha+ABS(zh2(i,l)-zhm)*dsig(l)
+                endif
+                zh2(i, l) = zhm
+!     modifs by RDW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                zum=zum+dsig(l)*zu2(i,l)
+                zvm=zvm+dsig(l)*zv2(i,l)
+!                zum=zum+dsig(l)*zu(i,l)
+!                zvm=zvm+dsig(l)*zv(i,l)
+                do iq=1,nq
+                   zqm(iq) = zqm(iq)+dsig(l)*zq2(i,l,iq)
+!                   zqm(iq) = zqm(iq)+dsig(l)*zq(i,l,iq)
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!     to conserve tracers/ KE, we must calculate zum, zvm and zqm using 
+!     the up-to-date column values. If we do not do this, there are cases 
+!     where convection stops at one level and starts at the next where we
+!     can break conservation of stuff (particularly tracers) significantly.
+
+                end do
+              ENDDO
+              zalpha=zalpha/(zhm*(sig(l1)-sig(l2+1)))
+              zum=zum/(sig(l1)-sig(l2+1))
+              zvm=zvm/(sig(l1)-sig(l2+1))
+              do iq=1,nq
+                 zqm(iq) = zqm(iq)/(sig(l1)-sig(l2+1))
+              end do
+
+              IF(zalpha.GT.1.) THEN
+                 zalpha=1.
+              ELSE
+!                IF(zalpha.LT.0.) STOP
+                 IF(zalpha.LT.1.e-4) zalpha=1.e-4
+              ENDIF
+
+              DO l=l1,l2
+                 zu2(i,l)=zu2(i,l)+zalpha*(zum-zu2(i,l))
+                 zv2(i,l)=zv2(i,l)+zalpha*(zvm-zv2(i,l))
+                 do iq=1,nq
+!                  zq2(i,l,iq)=zq2(i,l,iq)+zalpha*(zqm(iq)-zq2(i,l,iq)) 
+                   zq2(i,l,iq)=zqm(iq)
+                 end do
+              ENDDO
+              if (ico2.ne.0) then
+                DO l=l1, l2
+                  zhc(i,l) = zh2(i,l)*(A*zq2(i,l,ico2)+B)
+                ENDDO
+              end if
+
+
+              l2 = l2 + 1
+
+            END IF   ! End of l1 to l2 instability treatment
+                     ! We now continue to test from l2 upwards
+
+          ENDDO   ! End of upwards loop on l2
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!     check conservation
+         cadjncons=0.0
+         if(water)then
+         do l = 1, nlay
+            masse = (pplev(i,l) - pplev(i,l+1))/g
+            iq    = igcm_h2o_vap
+            cadjncons = cadjncons + 
+     &           masse*(zq2(i,l,iq)-zq(i,l,iq))/ptimestep 
+         end do
+         endif
+
+         if(cadjncons.lt.-1.e-6)then
+            print*,'convadj has just crashed...'
+            print*,'i  = ',i
+            print*,'l1 = ',l1
+            print*,'l2 = ',l2
+            print*,'cadjncons        = ',cadjncons
+         do l = 1, nlay
+            print*,'dsig         = ',dsig(l)
+         end do         
+         do l = 1, nlay
+            print*,'dsig         = ',dsig(l)
+         end do
+         do l = 1, nlay
+            print*,'sig         = ',sig(l)
+         end do
+         do l = 1, nlay
+            print*,'pplay(ig,:)         = ',pplay(i,l)
+         end do
+         do l = 1, nlay+1
+            print*,'pplev(ig,:)         = ',pplev(i,l)
+         end do
+         do l = 1, nlay
+            print*,'ph(ig,:)         = ',ph(i,l)
+         end do
+         do l = 1, nlay
+            print*,'ph(ig,:)         = ',ph(i,l)
+         end do
+         do l = 1, nlay
+            print*,'ph(ig,:)         = ',ph(i,l)
+         end do
+         do l = 1, nlay
+            print*,'zh(ig,:)         = ',zh(i,l)
+         end do
+         do l = 1, nlay
+            print*,'zh2(ig,:)        = ',zh2(i,l)
+         end do
+         do l = 1, nlay
+            print*,'zq(ig,:,vap)     = ',zq(i,l,igcm_h2o_vap)
+         end do
+         do l = 1, nlay
+            print*,'zq2(ig,:,vap)    = ',zq2(i,l,igcm_h2o_vap)
+         end do
+            print*,'zqm(vap)         = ',zqm(igcm_h2o_vap)
+            print*,'jadrs=',jadrs
+
+            call abort
+         endif
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+      ENDDO
+
+      DO l=1,nlay
+        DO ig=1,ngrid
+          pdhadj(ig,l)=(zh2(ig,l)-zh(ig,l))/ptimestep
+          pduadj(ig,l)=(zu2(ig,l)-zu(ig,l))/ptimestep
+          pdvadj(ig,l)=(zv2(ig,l)-zv(ig,l))/ptimestep
+        ENDDO
+      ENDDO
+
+      if(tracer) then 
+        do iq=1, nq
+          do  l=1,nlay
+            DO ig=1,ngrid
+              pdqadj(ig,l,iq)=(zq2(ig,l,iq)-zq(ig,l,iq))/ptimestep 
+            end do 
+          end do 
+        end do 
+      end if
+
+
+!     output
+!      if (ngrid.eq.1) then
+!         ig=1
+!         iq =1 
+!         write(*,*)'**** l, pq(ig,l,iq),zq(ig,l,iq),zq2(ig,l,iq)'  
+!         do l=nlay,1,-1
+!           write(*,*) l, pq(ig,l,iq),zq(ig,l,iq),zq2(ig,l,iq)
+!         end do
+!      end if
+
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/cp_neutral.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/cp_neutral.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/cp_neutral.F90	(revision 1644)
@@ -0,0 +1,37 @@
+double precision function cp_neutral(T)
+
+  use gases_h
+
+  implicit none
+
+  ! inputs
+  double precision T
+
+
+  ! this function has been disabled in gradients_kcm.F90 because it doesnt
+  ! work if you have gaseous mixtures. need to decide whether to generalise
+  ! it or simply remove entirely...
+
+  ! Cp_n : cf CO2 dans abe&matsui (1988)
+  !cp_neutral = (22.26+5.981d-2*T-3.501d-5*T**2+7.469d-9*T**3)/m_n
+
+  if(trim(gnom(1)).eq.'N2_')then
+     cp_neutral = 1040.0
+  elseif(trim(gnom(1)).eq.'H2_')then
+     cp_neutral = 14310.0
+  else
+     print*,'Gas not recognised in cp_neutral!'
+     call abort
+  endif
+
+  
+end function cp_neutral
+
+
+
+
+
+
+
+
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/cpdet_phy_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/cpdet_phy_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/cpdet_phy_mod.F90	(revision 1644)
@@ -0,0 +1,108 @@
+MODULE cpdet_phy_mod
+IMPLICIT NONE  
+
+! ADAPTATION GCM POUR CP(T)
+!======================================================================
+! S. Lebonnois, 10/2007:
+!
+! VENUS: Cp(T) = cpp*(T/T0)^nu 
+! avec T0=460. et nu=0.35
+! cpp=RCPD=cp0 = 1000.
+! R/RCPD = RKAPPA
+!
+! La fonction d'Exner reste pk = RCPD*(play/pref)**RKAPPA
+! 
+! T et teta (temperature potentielle) sont liees par:
+! 
+!   integrale[teta a T](cp/T dT) = integrale[pref a p](R/p dp)
+!
+! Dans le cas de l'expression pour Venus, ca donne:
+!
+!   teta**nu = T**nu - nu * T0**nu * ln[ (p/pref)**RKAPPA ]
+! ou
+!   teta**nu = T**nu - nu * T0**nu * ln[pk/RCPD]
+!
+! On passe de T a teta par t2tpot(t,teta,pk)
+! On passe de teta a T par tpot2t(teta,t,pk)
+!
+! Pour DT <-> Dteta, on utilise: dteta = dT *(T/teta)**(nu-1)
+! -> routine dt2dtpot(dt,dteta,t,teta) 
+! (utilisee seulement pour le contregradient)
+!
+!======================================================================
+
+
+      REAL cp0,t0,nu
+!      PARAMETER (cp0 = 1000.) !doit etre egal a cpp (dyn) et RCPD (phy)
+      PARAMETER (cp0 = 800.) !doit etre egal a cpp (dyn) et RCPD (phy)
+!      PARAMETER (t0  = 460.)
+      PARAMETER (t0  = 480.)
+!      PARAMETER (t0  = 300.)
+      PARAMETER (nu  = 0.35)
+!      PARAMETER (nu  = 1.0)
+
+CONTAINS
+
+      FUNCTION cpdet(t)
+      IMPLICIT NONE
+
+      real cpdet,t
+
+      cpdet = cp0*(t/t0)**nu
+
+      RETURN
+      END FUNCTION cpdet
+      
+!======================================================================
+!======================================================================
+
+      SUBROUTINE t2tpot(npoints,yt, yteta, ypk)
+      IMPLICIT NONE
+!======================================================================
+! Arguments:
+!
+! yt   --------input-R- Temperature
+! yteta-------output-R- Temperature potentielle
+! ypk  --------input-R- Fonction d'Exner: RCPD*(pplay/pref)**RKAPPA
+!
+!======================================================================
+
+      INTEGER npoints
+      REAL    yt(npoints), yteta(npoints), ypk(npoints)
+      
+      yteta = yt**nu - nu * t0**nu * log(ypk/cp0)
+      yteta = yteta**(1./nu)
+        
+
+      !yteta = yt/ypk
+
+
+      RETURN
+      END SUBROUTINE t2tpot
+
+!======================================================================
+!======================================================================
+
+      SUBROUTINE tpot2t(npoints,yteta, yt, ypk)
+      IMPLICIT NONE
+!======================================================================
+! Arguments:
+!
+! yteta--------input-R- Temperature potentielle
+! yt   -------output-R- Temperature
+! ypk  --------input-R- Fonction d'Exner: RCPD*(pplay/pref)**RKAPPA
+!
+!======================================================================
+
+      INTEGER npoints
+      REAL yt(npoints), yteta(npoints), ypk(npoints)
+
+      yt = yteta**nu + nu * t0**nu * log(ypk/cp0)
+      yt = yt**(1./nu)
+
+      !yt = yteta*ypk
+
+      RETURN
+      END SUBROUTINE tpot2t
+
+END MODULE cpdet_phy_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/cvmgp.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/cvmgp.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/cvmgp.F	(revision 1644)
@@ -0,0 +1,14 @@
+      FUNCTION cvmgp(x1,x2,x3)
+      IMPLICIT NONE
+
+      REAL x1,x2,x3,cvmgp
+
+      IF(x3.ge.0) then 
+        cvmgp=x1
+      ELSE
+        cvmgp=x2
+      ENDIF
+
+      RETURN
+      END
+C
Index: /trunk/LMDZ.TITAN/libf/phytitan/cvmgt.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/cvmgt.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/cvmgt.F	(revision 1644)
@@ -0,0 +1,15 @@
+      FUNCTION cvmgt(x1,x2,l)
+      IMPLICIT NONE
+
+      REAL x1,x2,cvmgt
+      LOGICAL l
+
+      IF(l) then 
+        cvmgt=x1
+      ELSE
+        cvmgt=x2
+      ENDIF
+
+      RETURN
+      END
+C
Index: /trunk/LMDZ.TITAN/libf/phytitan/datafile_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/datafile_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/datafile_mod.F90	(revision 1644)
@@ -0,0 +1,24 @@
+!-----------------------------------------------------------------------
+      module datafile_mod
+!  Address of the directory containing tables of data needed by the GCM
+      implicit none
+
+      ! Main directory: 'datadir':
+      ! Default for Berserker @ UChicago:
+!      character(len=300) :: datadir='/home/rwordsworth/datagcm'
+      ! Default for Gnome Idataplex:
+!      character(len=300) :: datadir='/san/home/rdword/gcm/datagcm'
+      ! Default for LMD machines:
+      character(len=300),save :: datadir='/u/lmdz/WWW/planets/LMDZ.GENERIC/datagcm'
+!$OMP THREADPRIVATE(datadir)
+      
+      ! Subdirectories of 'datadir':
+      
+      ! surfdir stores planetary topography, albedo, etc. (surface.nc files)
+      character(len=12),parameter :: surfdir="surface_data"
+      
+      ! aerdir stores aerosol properties files (optprop_*dat files)
+      character(LEN=18),parameter :: aerdir="aerosol_properties" 
+
+      end module datafile_mod
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.TITAN/libf/phytitan/def_var.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/def_var.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/def_var.F90	(revision 1644)
@@ -0,0 +1,64 @@
+subroutine def_var(nid,name,title,units,nbdim,dimids,nvarid,ierr)
+
+! This subroutine defines variable 'name' in a (pre-existing and opened)
+! NetCDF file (known from its NetCDF ID 'nid').
+! The number of dimensions 'nbdim' of the variable, as well as the IDs of
+! corresponding dimensions must be set (in array 'dimids').
+! Upon successfull definition of the variable, 'nvarid' contains the
+! NetCDF ID of the variable.
+! The variables' attributes 'title' (Note that 'long_name' would be more
+! appropriate) and 'units' are also set. 
+
+implicit none
+
+#include "netcdf.inc"
+
+integer,intent(in) :: nid ! NetCDF file ID
+character(len=*),intent(in) :: name ! the variable's name
+character(len=*),intent(in) :: title ! 'title' attribute of variable
+character(len=*),intent(in) :: units ! 'units' attribute of variable
+integer,intent(in) :: nbdim ! number of dimensions of the variable
+integer,dimension(nbdim),intent(in) :: dimids ! NetCDF IDs of the dimensions
+                                              ! the variable is defined along
+integer,intent(out) :: nvarid ! NetCDF ID of the variable
+integer,intent(out) :: ierr ! returned NetCDF staus code
+
+! 1. Switch to NetCDF define mode 
+ierr=NF_REDEF(nid)
+
+!print*,'in def_var.F90, dimids='
+!print*,dimids
+
+! 2. Define the variable
+#ifdef NC_DOUBLE
+ierr = NF_DEF_VAR (nid,adjustl(name),NF_DOUBLE,nbdim,dimids,nvarid)
+#else
+ierr = NF_DEF_VAR (nid,adjustl(name),NF_FLOAT,nbdim,dimids,nvarid)
+#endif
+if(ierr/=NF_NOERR) then
+   write(*,*) "def_var: Failed defining variable "//trim(name)
+   write(*,*) NF_STRERROR(ierr)
+   stop ""
+endif
+
+! 3. Write attributes
+ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title",&
+                     len_trim(adjustl(title)),adjustl(title))
+if(ierr/=NF_NOERR) then
+   write(*,*) "def_var: Failed writing title attribute for "//trim(name)
+   write(*,*) NF_STRERROR(ierr)
+   stop ""
+endif
+
+ierr=NF_PUT_ATT_TEXT(nid,nvarid,"units",&
+                     len_trim(adjustl(units)),adjustl(units))
+if(ierr/=NF_NOERR) then
+   write(*,*) "def_var: Failed writing units attribute for "//trim(name)
+   write(*,*) NF_STRERROR(ierr)
+   stop ""
+endif
+
+! 4. Switch out of NetCDF define mode
+ierr = NF_ENDDEF(nid)
+
+end
Index: /trunk/LMDZ.TITAN/libf/phytitan/dimphy.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dimphy.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dimphy.F90	(revision 1644)
@@ -0,0 +1,32 @@
+MODULE dimphy
+  
+  INTEGER,SAVE :: klon   ! number of atmospheric columns (for this OpenMP subgrid)
+  INTEGER,SAVE :: klev   ! number of atmospheric layers, read by master
+  INTEGER,SAVE :: klevp1 ! number of atmospheric layers+1, read by master
+  INTEGER,SAVE :: klevm1 ! number of atmospheric layers-1, read by master
+!  INTEGER,SAVE :: kflev
+
+!$OMP THREADPRIVATE(klon)
+
+CONTAINS
+  
+  SUBROUTINE Init_dimphy(klon0,klev0)
+  IMPLICIT NONE
+  
+    INTEGER, INTENT(in) :: klon0
+    INTEGER, INTENT(in) :: klev0
+    
+    klon=klon0
+    
+!$OMP MASTER 
+    klev=klev0
+    klevp1=klev+1
+    klevm1=klev-1
+!    kflev=klev
+!$OMP END MASTER    
+!$OMP BARRIER
+    
+  END SUBROUTINE Init_dimphy
+
+  
+END MODULE dimphy
Index: /trunk/LMDZ.TITAN/libf/phytitan/dsolver.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dsolver.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dsolver.F	(revision 1644)
@@ -0,0 +1,102 @@
+      SUBROUTINE DSOLVER(NL,GAMA,CP,CM,CPM1,CMM1,E1,E2,E3,E4,BTOP,
+     *                   BSURF,RSF,XK1,XK2)
+
+C  GCM2.0  Feb 2003
+C
+C DOUBLE PRECISION VERSION OF SOLVER
+
+!!      PARAMETER (NMAX=201)
+      IMPLICIT REAL*8  (A-H,O-Z)
+      DIMENSION GAMA(NL),CP(NL),CM(NL),CPM1(NL),CMM1(NL),XK1(NL),
+     *          XK2(NL),E1(NL),E2(NL),E3(NL),E4(NL)
+      DIMENSION AF(2*NL),BF(2*NL),CF(2*NL),DF(2*NL),XK(2*NL)
+C*********************************************************
+C* THIS SUBROUTINE SOLVES FOR THE COEFFICIENTS OF THE    *
+C* TWO STREAM SOLUTION FOR GENERAL BOUNDARY CONDITIONS   *
+C* NO ASSUMPTION OF THE DEPENDENCE ON OPTICAL DEPTH OF   *
+C* C-PLUS OR C-MINUS HAS BEEN MADE.                      *
+C* NL     = NUMBER OF LAYERS IN THE MODEL                *
+C* CP     = C-PLUS EVALUATED AT TAO=0 (TOP)              *
+C* CM     = C-MINUS EVALUATED AT TAO=0 (TOP)             *
+C* CPM1   = C-PLUS  EVALUATED AT TAOSTAR (BOTTOM)        *
+C* CMM1   = C-MINUS EVALUATED AT TAOSTAR (BOTTOM)        *
+C* EP     = EXP(LAMDA*DTAU)                              *
+C* EM     = 1/EP                                         *
+C* E1     = EP + GAMA *EM                                *
+C* E2     = EP - GAMA *EM                                *
+C* E3     = GAMA*EP + EM                                 *
+C* E4     = GAMA*EP - EM                                 *
+C* BTOP   = THE DIFFUSE RADIATION INTO THE MODEL AT TOP  *
+C* BSURF  = THE DIFFUSE RADIATION INTO THE MODEL AT      *
+C*          THE BOTTOM: INCLUDES EMMISION AND REFLECTION *
+C*          OF THE UNATTENUATED PORTION OF THE DIRECT    *
+C*          BEAM. BSTAR+RSF*FO*EXP(-TAOSTAR/U0)          *
+C* RSF    = REFLECTIVITY OF THE SURFACE                  *
+C* XK1    = COEFFICIENT OF THE POSITIVE EXP TERM         *
+C* XK2    = COEFFICIENT OF THE NEGATIVE EXP TERM         *
+C*********************************************************
+
+C======================================================================C
+
+      L=2*NL
+ 
+C     ************MIXED COEFFICENTS**********
+C     THIS VERSION AVOIDS SINGULARITIES ASSOC.
+C     WITH W0=0 BY SOLVING FOR XK1+XK2, AND XK1-XK2.
+
+      AF(1) = 0.0
+      BF(1) = GAMA(1)+1.
+      CF(1) = GAMA(1)-1.
+      DF(1) = BTOP-CMM1(1)
+      N     = 0
+      LM2   = L-2
+
+C     EVEN TERMS
+ 
+      DO I=2,LM2,2
+        N     = N+1
+        AF(I) = (E1(N)+E3(N))*(GAMA(N+1)-1.)       
+        BF(I) = (E2(N)+E4(N))*(GAMA(N+1)-1.)
+        CF(I) = 2.0*(1.-GAMA(N+1)**2)
+        DF(I) = (GAMA(N+1)-1.) * (CPM1(N+1) - CP(N)) +
+     *            (1.-GAMA(N+1))* (CM(N)-CMM1(N+1))
+      END DO
+ 
+      N   = 0
+      LM1 = L-1
+      DO I=3,LM1,2
+        N     = N+1
+        AF(I) = 2.0*(1.-GAMA(N)**2)
+        BF(I) = (E1(N)-E3(N))*(1.+GAMA(N+1))
+        CF(I) = (E1(N)+E3(N))*(GAMA(N+1)-1.)
+        DF(I) = E3(N)*(CPM1(N+1) - CP(N)) + E1(N)*(CM(N) - CMM1(N+1))
+      END DO
+ 
+      AF(L) = E1(NL)-RSF*E3(NL)
+      BF(L) = E2(NL)-RSF*E4(NL)
+      CF(L) = 0.0
+      DF(L) = BSURF-CP(NL)+RSF*CM(NL)
+ 
+      CALL DTRIDGL(L,AF,BF,CF,DF,XK)
+ 
+C     ***UNMIX THE COEFFICIENTS****
+
+      DO 28 N=1,NL
+        XK1(N) = XK(2*N-1)+XK(2*N)
+        XK2(N) = XK(2*N-1)-XK(2*N)
+
+C       NOW TEST TO SEE IF XK2 IS REALLY ZERO TO THE LIMIT OF THE
+C       MACHINE ACCURACY  = 1 .E -30
+C       XK2 IS THE COEFFICEINT OF THE GROWING EXPONENTIAL AND MUST
+C       BE TREATED CAREFULLY
+
+        IF(XK2(N) .EQ. 0.0) GO TO 28
+c        IF (ABS (XK2(N)/XK(2*N-1)) .LT. 1.E-30) XK2(N)=0.0
+
+        IF (ABS (XK2(N)/(XK(2*N-1)+1.e-20)) .LT. 1.E-30) XK2(N)=0.0   ! For debug only (with -Ktrap=fp option)
+
+
+   28 CONTINUE
+ 
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/dtridgl.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dtridgl.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dtridgl.F	(revision 1644)
@@ -0,0 +1,36 @@
+      SUBROUTINE DTRIDGL(L,AF,BF,CF,DF,XK)
+
+C  GCM2.0  Feb 2003
+
+C     DOUBLE PRECISION VERSION OF TRIDGL
+
+!!      PARAMETER (NMAX=201)
+      IMPLICIT REAL*8  (A-H,O-Z)
+      DIMENSION AF(L),BF(L),CF(L),DF(L),XK(L)
+      DIMENSION AS(2*L),DS(2*L)
+
+C*    THIS SUBROUTINE SOLVES A SYSTEM OF TRIDIAGIONAL MATRIX
+C*    EQUATIONS. THE FORM OF THE EQUATIONS ARE:
+C*    A(I)*X(I-1) + B(I)*X(I) + C(I)*X(I+1) = D(I)
+C*    WHERE I=1,L  LESS THAN 103.
+C* ..............REVIEWED -CP........
+
+C======================================================================C
+
+      AS(L) = AF(L)/BF(L)
+      DS(L) = DF(L)/BF(L)
+
+      DO I=2,L
+        X         = 1./(BF(L+1-I) - CF(L+1-I)*AS(L+2-I))
+        AS(L+1-I) = AF(L+1-I)*X
+        DS(L+1-I) = (DF(L+1-I)-CF(L+1-I)*DS(L+2-I))*X
+      END DO
+ 
+      XK(1)=DS(1)
+      DO I=2,L
+        XKB   = XK(I-1)
+        XK(I) = DS(I)-AS(I)*XKB
+      END DO
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/abort_gcm.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/abort_gcm.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/abort_gcm.F	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/abort_gcm.F
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/calcenergy_kcm.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/calcenergy_kcm.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/calcenergy_kcm.F90	(revision 1644)
@@ -0,0 +1,75 @@
+subroutine calcenergy_kcm(nlayer,Tsurf,T,Play,Plev,Qsurf,Q,muvar,Eatmtot)
+
+
+use params_h, only : Rc
+use watercommon_h, only : mH2O
+use comcstfi_mod, only: g, mugaz
+implicit none
+
+!     ----------------------------------------------------------------
+!     Purpose: Calculate total energy of the (steam) atmosphere
+!     Authour: R. Wordsworth (2011)
+!     ----------------------------------------------------------------
+
+
+  ! inputs
+  integer,intent(in) :: nlayer
+  real Tsurf,T(1:nlayer)
+  real Play(1:nlayer),Plev(1:nlayer+1)
+  real Qsurf,Q(1:nlayer)
+  real muvar(1,nlayer+1)
+
+  ! internal
+  integer il
+  real m_n,m_v,cp_n,cp_v,cp_a,Eatmlay
+  real s_c,rho_v,L
+  double precision p_v, s_v, nul
+  real VMR(1:nlayer)
+
+  ! output
+  real Eatmtot
+
+  ! functions
+  double precision cp_neutral
+
+  m_n = mugaz/1000.
+  m_v = mH2O/1000.
+
+
+  do il=1,nlayer
+     VMR(il)=Q(il)*(muvar(1,il+1)/mH2O)
+  end do
+
+
+  Eatmtot = 0.0
+  do il=1,nlayer
+
+
+     cp_n = cp_neutral(dble(T(il)))
+     cp_v = (32.24+1.923d-3*T(il) + 1.055d-5*T(il)**2-3.511d-9*T(il)**3)/m_v
+     ! / by m_v makes it per kg not per mol
+
+     call psat_H2O(dble(T(il)),p_v)
+     p_v   = p_v*1d6
+     rho_v = real(p_v)*m_v/(real(Rc)*T(il))
+
+     call therm(dble(T(il)),dble(rho_v)*1d-3,nul,nul,nul,nul,nul,nul,nul,&
+                nul,nul,nul,s_v,nul)
+
+     s_c = 2.06 * log(T(il)/273.15)
+     s_v = s_v * 1d3
+     s_c = s_c * 1d3
+     L   = (real(s_v)-s_c)*T(il)
+
+     cp_a    = (1-VMR(il))*cp_n + VMR(il)*cp_v 
+     !cp_a    = (1-Q(il))*cp_n + Q(il)*cp_v 
+
+     Eatmlay = ( cp_a*T(il) + L*VMR(il) ) * (Plev(il)-Plev(il+1))/g
+
+     Eatmtot = Eatmtot + Eatmlay 
+  enddo
+
+  print*,'WARNING: E-calc currently assumes H2O saturation!'
+
+end subroutine calcenergy_kcm
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comconst_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comconst_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comconst_mod.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/comconst_mod.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comgeom.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comgeom.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comgeom.h	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/comgeom.h
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comvert_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comvert_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/comvert_mod.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/comvert_mod.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/control_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/control_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/control_mod.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/control_mod.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/disvert.F	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/disvert.F
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/ener_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/ener_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/ener_mod.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/ener_mod.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/gradients_kcm.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/gradients_kcm.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/gradients_kcm.F90	(revision 1644)
@@ -0,0 +1,126 @@
+subroutine gradients_kcm(profil_flag,rho_v,rho_n,T,dTdp,dPvdp,dPndp)
+
+  use params_h
+  use gases_h
+  implicit none
+
+  ! inputs
+  integer profil_flag ! 0 = dry, 1 = moist, 2 = isothermal
+  double precision rho_v,rho_n,T
+
+  ! outputs
+  double precision dTdp,dPndp,dPvdp
+  double precision a_v
+
+  ! internal
+  !double precision cp_n,cp_v
+  double precision cp_v
+
+  double precision press, rho_plus, rho_minus, dVdT, rho_c
+  double precision dlnr,dlna,dpsat,dsv
+  double precision s_minus,s_plus
+  double precision s_v,s_c,L
+  double precision psat_plus,psat_minus,Pn
+  double precision nul
+
+  ! functions
+  double precision cp_neutral
+
+  !cp_n = cp_neutral(T)
+
+  select case(profil_flag)
+  case(2) ! isothermal
+
+     dTdp  = 0.
+     a_v   = rho_v/rho_n ! constant here
+     dPndp = 1/(1d0+m_n/m_v*a_v)
+     dPvdp = 1 - dPndp
+
+  case(1) ! moist
+
+     Pn = rho_n*T*rmn
+
+     if(ngasmx.eq.1)then
+        print*,'Cannot have moist adiabat with one gas...'
+        stop
+     endif
+
+     if(trim(gnom(ngasmx)).eq.'H2O')then
+
+        call psat_H2O(T-2d-1,psat_minus)
+        call psat_H2O(T+2d-1,psat_plus)
+        call psat_H2O(T,press)
+
+        rho_minus = m_v*psat_minus*1d6/(Rc*(T-2d-1))
+        rho_plus  = m_v*psat_plus*1d6/(Rc*(T+2d-1))
+
+        call therm(T-2d-1,rho_minus*1d-3,nul,nul,nul,nul,nul,nul,nul,&
+                   nul,nul,press,s_minus,nul)
+        call therm(T+2d-1,rho_plus*1d-3,nul,nul,nul,nul,nul,nul,nul,&
+                   nul,nul,press,s_plus,nul)
+        s_c = 2.06 * log(T/273.15)
+
+        s_plus  = s_plus  * 1d3
+        s_minus = s_minus * 1d3
+        s_c     = s_c     * 1d3 ! convert to SI
+
+        if(T.lt.280.0)then 
+           dpsat = press*1d6 * ( 1730.63*log(10.) / (T-39.714)**2 )
+        else
+           call tdpsdt(T,dpsat)
+           dpsat = dpsat * 1d6 / T
+        endif
+
+     elseif(trim(gnom(ngasmx)).eq.'NH3')then
+
+        call psat_NH3(T-2d-1,psat_minus)
+        call psat_NH3(T+2d-1,psat_plus)
+        call psat_NH3(T,press)
+
+        rho_minus = m_v*psat_minus*1d6/(Rc*(T-2d-1))
+        rho_plus  = m_v*psat_plus*1d6/(Rc*(T+2d-1))
+
+        call latheat_NH3(T-2d-1,nul,s_minus)
+        call latheat_NH3(T+2d-1,nul,s_plus)
+        call latheat_NH3(T,s_c,nul)
+
+        dpsat = press*1d6 * (-2*1.5609d-4*T + 0.1236)
+
+     endif
+
+     dsv  = (s_plus-s_minus)/4d-1  ! dsv*T = ds / d ln[T]
+     s_v  = (s_plus+s_minus)/2d0
+     dlnr = T/rho_v * (rho_plus-rho_minus)/4d-1  ! d ln[rho_v] / d ln[T]
+
+     if(rho_n/rho_v.lt.1e-5)then
+        dlna = -T*dsv/(s_v-s_c)
+     else
+        a_v  = rho_v/rho_n
+        dlna = (rmn*dlnr - cp_n + rmn - a_v*T*dsv)/(a_v*(s_v-s_c)+rmn)  
+        ! d ln[alpha_v] / d ln[T]
+        ! note cp_n + rmn = cv_n, which is what's required
+     endif
+
+     dTdp  = 1d0 / (dpsat + rho_n*rmn*(1d0 + dlnr - dlna)) ! c.f. Marcq S2.2.2
+     dPvdp = dTdp * dpsat
+     dPndp = 1d0 - dPvdp ! from p = p_v + p_n
+
+  case(0) ! dry
+
+     cp_v=0.0
+     if(trim(gnom(ngasmx)).eq.'H2O')then
+        cp_v = (32.24+1.923d-3*T+1.055d-5*T**2-3.511d-9*T**3)/m_v
+     elseif(trim(gnom(ngasmx)).eq.'NH3')then
+        cp_v = 2.058d3
+     elseif(trim(gnom(ngasmx)).eq.'CH4')then
+        cp_v = 2.226d3
+     endif
+
+     dTdp  = 1/(rho_n*cp_n+rho_v*cp_v)
+     dPndp = 1/(1d0+m_n/m_v*rho_v/rho_n)
+     dPvdp = 1/(1d0+m_v/m_n*rho_n/rho_v)
+      
+  end select
+
+
+end subroutine gradients_kcm
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/infotrac.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/infotrac.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/infotrac.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/infotrac.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/kcm1d.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/kcm1d.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/kcm1d.F90	(revision 1644)
@@ -0,0 +1,375 @@
+program kcm1d
+
+  use infotrac, only: nqtot
+  use radinc_h,      only: NAERKIND
+  use radcommon_h,   only: L_NSPECTI, L_NSPECTV, sigma
+  use watercommon_h, only: mH2O
+  use ioipsl_getincom, only: getin
+  use comsaison_h, only: mu0, fract, dist_star
+  use planete_mod
+  use callkeys_mod, only: check_cpp_match, pceil, tstrat, tracer
+  use inifis_mod, only: inifis
+  use comcstfi_mod
+  implicit none
+
+  !==================================================================
+  !     
+  !     Purpose
+  !     -------
+  !     Run the universal model radiative transfer once in a 1D column.
+  !     Useful for climate evolution studies etc.
+  !     
+  !     It can be compiled with a command like (e.g. for 25 layers):
+  !                                  "makegcm -p std -d 25 kcm1d"
+  !     It requires the files "callphys.def", "gases.def"
+  !     "traceur.def", and "run.def" with a line "INCLUDEDEF=callphys.def"
+  !
+  !     Authors
+  !     -------
+  !     R. Wordsworth
+  !
+  !==================================================================
+
+#include "dimensions.h"
+!#include "dimphys.h"
+
+  ! --------------------------------------------------------------
+  !  Declarations
+  ! --------------------------------------------------------------
+
+  integer nlayer,nlevel,nq
+  integer ilay,ilev,iq,iw,iter
+  real play(llm)     ! Pressure at the middle of the layers [Pa]
+  real zlay(llm)     ! Altitude at middle of the layers [km]
+  real plev(llm+1)   ! Intermediate pressure levels [Pa]
+  real temp(llm)     ! temperature at the middle of the layers [K]
+  real,allocatable :: q(:,:)   ! tracer mixing ratio [kg/kg]
+  real,allocatable :: vmr(:,:) ! tracer mixing ratio [mol/mol]
+  real,allocatable :: qsurf(:)        ! tracer surface budget [kg/kg] ????
+  real psurf,psurf_n,tsurf      
+
+  real emis, albedo
+
+  real muvar(llm+1)
+
+  real dtsw(llm) ! heating rate (K/s) due to SW
+  real dtlw(llm) ! heating rate (K/s) due to LW
+  real fluxsurf_lw   ! incident LW flux to surf (W/m2)
+  real fluxtop_lw    ! outgoing LW flux to space (W/m2)
+  real fluxsurf_sw   ! incident SW flux to surf (W/m2)
+  real fluxabs_sw    ! SW flux absorbed by planet (W/m2)
+  real fluxtop_dn    ! incident top of atmosphere SW flux (W/m2)
+
+  ! not used
+  real reffrad(llm,naerkind)
+  real nueffrad(llm,naerkind)
+  real cloudfrac(llm)
+  real totcloudfrac
+  real tau_col
+
+  real dTstrat
+  real aerosol(llm,naerkind) ! aerosol tau (kg/kg)
+  real OLR_nu(1,L_NSPECTI)
+  real OSR_nu(1,L_NSPECTV)
+  real Eatmtot
+
+  integer ierr
+  logical firstcall,lastcall,global1d
+
+  character*20,allocatable :: nametrac(:)   ! name of the tracer (no need for adv trac common)
+
+  ! --------------
+  ! Initialisation
+  ! --------------
+
+  pi=2.E+0*asin(1.E+0)
+
+  reffrad(:,:)  = 0.0
+  nueffrad(:,:) = 0.0
+  cloudfrac(:)  = 0.0
+  totcloudfrac  = 0.0
+
+
+  nlayer=llm
+  nlevel=nlayer+1
+
+  !! this is defined in comsaison_h
+  ALLOCATE(mu0(1))
+  ALLOCATE(fract(1))
+
+
+
+  !  Load parameters from "run.def" 
+  ! -------------------------------
+
+  ! check if 'kcm1d.def' file is around (otherwise reading parameters
+  ! from callphys.def via getin() routine won't work.)
+  open(90,file='kcm1d.def',status='old',form='formatted',&
+       iostat=ierr)
+  if (ierr.ne.0) then
+     write(*,*) 'Cannot find required file "kcm1d.def"'
+     write(*,*) '  (which should contain some input parameters'
+     write(*,*) '   along with the following line:'
+     write(*,*) '   INCLUDEDEF=callphys.def'
+     write(*,*) '   )'
+     write(*,*) ' ... might as well stop here ...'
+     stop
+  else
+     close(90)
+  endif
+
+! now, run.def is needed anyway. so we create a dummy temporary one
+! for ioipsl to work. if a run.def is already here, stop the
+! program and ask the user to do a bit of cleaning
+  open(90,file='run.def',status='old',form='formatted',& 
+       iostat=ierr)
+  if (ierr.eq.0) then
+     close(90)
+     write(*,*) 'There is already a run.def file.'
+     write(*,*) 'This is not compatible with 1D runs.'
+     write(*,*) 'Please remove the file and restart the run.'
+     write(*,*) 'Runtime parameters are supposed to be in kcm1d.def'
+     stop
+  else
+     call system('touch run.def')
+     call system("echo 'INCLUDEDEF=callphys.def' >> run.def")
+     call system("echo 'INCLUDEDEF=kcm1d.def' >> run.def")
+  endif
+
+  global1d = .false. ! default value
+  call getin("global1d",global1d)
+  if(.not.global1d)then
+     print*,'Error, kcm1d must have global1d=.true. in kcm1d.def!'
+     stop
+  end if
+
+  psurf_n=100000. ! default value for psurf
+  print*,'Dry surface pressure (Pa)?'
+  call getin("psurf",psurf_n)
+  write(*,*) " psurf = ",psurf_n
+
+! OK. now that run.def has been read once -- any variable is in memory.
+! so we can dump the dummy run.def
+  call system("rm -rf run.def")
+
+  tsurf=300.0 ! default value for tsurf
+  print*,'Surface temperature (K)?'
+  call getin("tref",tsurf)
+  write(*,*) " tsurf = ",tsurf
+
+  g=10.0 ! default value for g
+  print*,'Gravity ?'
+  call getin("g",g)
+  write(*,*) " g = ",g
+
+  periastr = 1.0
+  apoastr  = 1.0
+  print*,'Periastron (AU)?'
+  call getin("periastr",periastr)
+  write(*,*) "periastron = ",periastr
+  dist_star = periastr 
+  fract     = 0.5
+  print*,'Apoastron (AU)?'
+  call getin("apoastr",apoastr)
+  write(*,*) "apoastron = ",apoastr
+
+  albedo=0.2 ! default value for albedo
+  print*,'Albedo of bare ground?'
+  call getin("albedo",albedo)
+  write(*,*) " albedo = ",albedo
+
+  emis=1.0 ! default value for emissivity
+  PRINT *,'Emissivity of bare ground ?'
+  call getin("emis",emis)
+  write(*,*) " emis = ",emis
+
+  pceil=100.0 ! Pascals
+  PRINT *,'Ceiling pressure (Pa) ?'
+  call getin("pceil",pceil)
+  write(*,*) " pceil = ", pceil
+
+  mugaz=0.
+  cpp=0.
+
+  check_cpp_match = .false.
+  call getin("check_cpp_match",check_cpp_match)
+  if (check_cpp_match) then
+     print*,"In 1D modeling, check_cpp_match is supposed to be F"
+     print*,"Please correct callphys.def"
+     stop
+  endif
+
+  call su_gases
+  call calc_cpp_mugaz
+
+  call inifis(1,llm,0,1,86400.0,1,1.0,&
+              (/0.0/),(/0.0/),(/1.0/),&
+              rad,g,r,cpp)
+
+  ! Tracer initialisation
+  ! ---------------------
+  if (tracer) then
+     ! load tracer names from file 'traceur.def'
+     open(90,file='traceur.def',status='old',form='formatted',&
+          iostat=ierr)
+     if (ierr.eq.0) then
+        write(*,*) "kcm1d: Reading file traceur.def"
+        ! read number of tracers:
+        read(90,*,iostat=ierr) nq
+        if (ierr.ne.0) then
+           write(*,*) "kcm1d: error reading number of tracers"
+           write(*,*) "   (first line of traceur.def) "
+           stop
+        endif
+        nqtot=nq
+        ! allocate arrays which depend on number of tracers
+        allocate(nametrac(nq))
+        allocate(q(nlayer,nq))
+        allocate(vmr(nlayer,nq))
+        allocate(qsurf(nq))
+
+        do iq=1,nq
+           ! minimal version, just read in the tracer names, 1 per line
+           read(90,*,iostat=ierr) nametrac(iq)
+           if (ierr.ne.0) then
+              write(*,*) 'kcm1d: error reading tracer names...'
+              stop
+           endif
+        enddo !of do iq=1,nq
+     endif
+
+     call initracer(1,nq,nametrac)
+
+  endif
+
+
+  do iq=1,nq
+     do ilay=1,nlayer
+        q(ilay,iq) = 0.
+     enddo
+  enddo
+
+  do iq=1,nq
+     qsurf(iq) = 0.
+  enddo
+
+  firstcall = .true.
+  lastcall  = .false.
+
+  iter    = 1
+  Tstrat  = 150.0
+  dTstrat = 1000.0
+
+  ! ---------
+  ! Run model
+  ! ---------
+  !do
+     psurf = psurf_n
+
+     !    Create vertical profiles
+     call kcmprof_fn(nlayer,psurf,qsurf(1),tsurf,    &
+          tstrat,play,plev,zlay,temp,q(:,1),muvar(1))
+
+     !    Run radiative transfer
+     call callcorrk(1,nlayer,q,nq,qsurf,      &
+          albedo,emis,mu0,plev,play,temp,                    &
+          tsurf,fract,dist_star,aerosol,muvar,         &
+          dtlw,dtsw,fluxsurf_lw,fluxsurf_sw,fluxtop_lw,    &
+          fluxabs_sw,fluxtop_dn,OLR_nu,OSR_nu,reffrad,nueffrad,tau_col,  &
+          cloudfrac,totcloudfrac,.false.,firstcall,lastcall)
+
+     !    Iterate stratospheric temperature
+     print*,'Tstrat = ',Tstrat
+     dTstrat = Tstrat
+     !Tstrat  = Tsurf*(0.2786*(psurf/100000.)**(-1.123))**0.25 
+     ! skin temperature (gray approx.) using analytic pure H2 expression
+     !Tstrat  = (fluxabs_sw/(2*sigma))**0.25 ! skin temperature (gray approx.)
+     Tstrat  = (fluxtop_lw/(2*sigma))**0.25 ! skin temperature (gray approx.)
+     dTstrat = dTstrat-Tstrat
+
+     !if(abs(dTstrat).lt.1.0)then
+     !   print*,'dTstrat = ',dTstrat
+     !   exit
+     !endif
+
+     !iter=iter+1
+     !if(iter.eq.100)then
+     !   print*,'Stratosphere failed to converge after'
+     !   print*,'100 iteration, aborting run.'
+     !   call abort
+     !endif
+
+  !end do
+
+  ! Run radiative transfer one last time to get OLR,OSR
+  firstcall=.false.
+  lastcall=.true.
+  call callcorrk(1,nlayer,q,nq,qsurf,      &
+       albedo,emis,mu0,plev,play,temp,                    &
+       tsurf,fract,dist_star,aerosol,muvar,         &
+       dtlw,dtsw,fluxsurf_lw,fluxsurf_sw,fluxtop_lw,    &
+       fluxabs_sw,fluxtop_dn,OLR_nu,OSR_nu,             &
+       reffrad,nueffrad,tau_col,  &
+       cloudfrac,totcloudfrac,.false.,firstcall,lastcall)
+
+
+  ! Calculate total atmospheric energy
+  Eatmtot=0.0
+  !  call calcenergy_kcm(nlayer,tsurf,temp,play,plev,qsurf,&
+  !     q(:,1),muvar,Eatmtot)
+
+  ! ------------------------
+  ! Save data to ascii files
+  ! ------------------------
+
+  print*,'Saving profiles...'
+  open(115,file='profpres.out',form='formatted')
+  open(116,file='proftemp.out',form='formatted')
+  open(117,file='profztab.out',form='formatted')
+  open(118,file='profqvar.out',form='formatted')
+  open(119,file='profvvar.out',form='formatted')
+
+  write(115,*) psurf
+  write(116,*) tsurf
+  write(117,*) 0.0
+  write(118,*) qsurf(1)
+  write(119,*) qsurf(1)*(muvar(1)/mH2O)
+  do ilay=1,nlayer
+     vmr(ilay,1) = q(ilay,1)*(muvar(ilay+1)/mH2O)
+     write(115,*) play(ilay)
+     write(116,*) temp(ilay)
+     write(117,*) zlay(ilay)
+     write(118,*) q(ilay,1)
+     write(119,*) vmr(ilay,1)
+  enddo
+  close(115)
+  close(116)
+  close(117)
+  close(118)
+  close(119)
+
+  print*, tsurf,psurf,fluxtop_dn,fluxabs_sw,fluxtop_lw 
+
+  print*,'Saving scalars...'
+  open(116,file='surf_vals.out')
+  write(116,*) tsurf,psurf,fluxtop_dn,         &
+       fluxabs_sw,fluxtop_lw 
+  close(116)
+  open(111,file='ene_vals.out')
+  write(111,*) tsurf,psurf,Eatmtot,Tstrat
+  close(111)
+
+  print*,'Saving spectra...'
+  open(117,file='OLRnu.out')
+  do iw=1,L_NSPECTI
+     write(117,*) OLR_nu(1,iw)
+  enddo
+  close(117)
+
+  open(127,file='OSRnu.out')
+  do iw=1,L_NSPECTV
+     write(127,*) OSR_nu(1,iw)
+  enddo
+  close(127)  
+
+end program kcm1d
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/kcmprof_fn.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/kcmprof_fn.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/kcmprof_fn.F90	(revision 1644)
@@ -0,0 +1,389 @@
+subroutine kcmprof_fn(nlayer,psurf_rcm,qsurf_rcm,Tsurf_rcm,Tstra_rcm,P_rcm,Pl_rcm,z_rcm,T_rcm,q_rcm,m_rcm)
+
+use params_h
+use watercommon_h, only : mH2O
+use gases_h
+use comcstfi_mod, only: mugaz, cpp, g
+use callkeys_mod, only: co2cond
+implicit none
+
+!     ----------------------------------------------------------------
+!     Purpose: create profiles of T, rho_v, rho_n, Pv and Pn following 
+!              Kasting 1988
+!     Authour: Adapted from a code by E. Marcq by R. Wordsworth (2011)
+!     ----------------------------------------------------------------
+
+  integer ilay, nlay
+  parameter (nlay=10000) ! number of vertical layers
+
+  ! rcm inputs
+  integer nlayer
+  real Tsurf_rcm,Tstra_rcm
+
+  ! rcm outputs
+  real psurf_rcm,qsurf_rcm
+  real P_rcm(1:nlayer)
+  real Pl_rcm(1:nlayer+1)
+  real z_rcm(1:nlayer)
+  real T_rcm(1:nlayer),q_rcm(1:nlayer)
+  real m_rcm(1:nlayer+1)
+
+  ! rcm for interpolation (should really use log coords?)
+  !double precision p1,p2,pnew,ilay_rcm
+
+  double precision lnp1,lnp2,lnpnew
+  real Dp_rcm, dlogp_rcm
+  integer ilay_rcm,ilev_rcm,ifinal_rcm
+
+  double precision Dz, Dp
+  double precision Ptop, dlogp, Psat_max
+  parameter (Ptop=1.0)                             ! Pressure at TOA [Pa]
+
+  double precision T(1:nlay)                       ! temperature [K]
+  double precision Ztab(1:nlay)                    ! altitude [m]
+  double precision Pv(1:nlay),Pn(1:nlay),P(1:nlay) ! pressure [Pa]
+  double precision rho_v(1:nlay), rho_n(1:nlay)    ! density [kg m^-3]
+  double precision a_v(1:nlay)                     ! = rho_v/rho_n [kg/kg]
+  double precision q_v(1:nlay)                     ! = rho_v/rho_tot [kg/kg]
+  double precision mtot(1:nlay)                    ! = (rho_v+rho_n)/(n_v+n_n) [g/mol]
+
+  integer profil_flag(1:nlay) ! 0 = dry, 1 = moist, 2 = isothermal
+
+  ! inputs
+  double precision Tsurf   ! surface temperature [K]
+  double precision Psurf_v ! surface par. pressure (variable species) [Pa]
+  double precision Psurf_n ! surface par. pressure (incondensible species)[Pa]
+  double precision Ttop    ! stratospheric temperature [K]
+
+  double precision dTdp        ! [K/Pa]
+  double precision dPvdp,dPndp ! [Pa/Pa]
+  double precision psat_v      ! local Psat_H2O value
+  double precision Tcrit       ! Critical temperature [K]
+  double precision rho_vTEMP,rho_nTEMP
+
+  double precision TCO2cond ! for CO2 condensation quasi-hack
+
+  ! variables necessary for steam.f90
+  double precision rhol,rhov,nul
+
+  ! for output
+  double precision vmr
+
+  logical verbose
+  parameter(verbose=.true.)
+
+  logical add_Pvar_to_total
+  parameter(add_Pvar_to_total=.true.)
+
+  ! initialise flags
+  profil_flag(:) = 0
+
+  !-------------------------------
+  ! assign input variables
+  m_n     = dble(mugaz/1000.)
+  cp_n    = cpp
+  ! modify/generalise later??
+
+  Psat_max = 1000000.0 ! maximum vapour pressure [Pa]
+                       ! set huge until further notice 
+
+  if(vgas.lt.1)then
+     if(psat_max.gt.0.0)then
+        print*,'Must have Psat_max=0 if no variable species'
+        psat_max=0.0
+        !stop
+     endif
+     print*, 'Assuming pure atmosphere'
+     m_v   = 1.0
+     tcrit = 1000.0
+  elseif(trim(gnom(vgas)).eq.'H2O')then
+     m_v   = dble(mH2O/1000.)
+     tcrit = 6.47d2
+  elseif(trim(gnom(vgas)).eq.'NH3')then
+     m_v   = 17.031/1000.
+     tcrit = 4.06d2
+  elseif(trim(gnom(vgas)).eq.'CH4')then
+     m_v   = 16.04/1000.
+     tcrit = 1.91d2
+     stop
+  else
+     print*,'Variable gas not recognised!'
+     call abort
+  endif
+
+  rmn     = rc/m_n
+  Ttop    = dble(Tstra_rcm)
+  Tsurf   = dble(Tsurf_rcm)
+
+  psat_v  = psat_max
+  if(vgas.gt.0)then
+     if(trim(gnom(vgas)).eq.'H2O')then
+        call Psat_H2O(tsurf,psat_v)
+     elseif(trim(gnom(vgas)).eq.'NH3')then
+        call Psat_NH3(tsurf,psat_v)
+     endif
+  endif
+
+  ! Moist adiabat unless greater than or equal to psat_max
+  if(psat_v*1d6.lt.psat_max)then
+    Psurf_v = Psat_v*1d6
+    profil_flag(1) = 1
+  else 
+    Psurf_v = psat_max
+    profil_flag(1) = 0
+  endif
+
+  if(add_Pvar_to_total)then
+    Psurf_n = dble(psurf_rcm)
+    psurf_rcm = real(Psurf_n+Psurf_v)
+  else
+    Psurf_n = dble(psurf_rcm) - Psurf_v
+  endif
+
+  ! include relative humidity option
+  !if(satval.lt.1.0)then
+  !   Psurf_v = Psurf_v*satval
+  !   profil_flag(1) = 0     
+  !endif
+
+  if(verbose)then
+     print*,'Psat_v  =',psat_v*1d6
+     print*,'Tsurf   =',Tsurf,' K'
+     print*,'Ttop    =',Ttop,' K'
+     print*,'Psurf_v =',Psurf_v,' Pa'
+     print*,'Psurf_n =',Psurf_n,' Pa'
+     print*,'m_n     =',m_n,' kg/mol'
+     print*,'m_v     =',m_v,' kg/mol'
+     print*,'rc      =',rc
+  endif
+
+  ! define fine pressure grid
+  dlogp_rcm = -(log(psurf_rcm)-log(ptop))/nlayer
+
+  P_rcm(1)  = psurf_rcm*exp(dlogp_rcm)
+  do ilay_rcm=1,nlayer-1
+     P_rcm(ilay_rcm+1) = P_rcm(ilay_rcm)*exp(dlogp_rcm)
+  enddo
+
+  Pl_rcm(1) = psurf_rcm
+  do ilev_rcm=2,nlayer
+     ! log-linear interpolation
+     Pl_rcm(ilev_rcm) = exp( log( P_rcm(ilev_rcm)*P_rcm(ilev_rcm-1) )/2 )
+  enddo
+
+  !-------------------------------
+  ! Layer 1
+  T(1)     = Tsurf
+  Pv(1)    = Psurf_v
+  Pn(1)    = Psurf_n
+  rho_n(1) = m_n*Pn(1)/(Rc*Tsurf)
+  rho_v(1) = m_v*Pv(1)/(Rc*Tsurf)
+  a_v(1)   = rho_v(1)/rho_n(1)
+
+  ! log pressure grid spacing (constant)
+  dlogp = -(log(Pn(1)+Pv(1))-log(ptop))/(nlay-1)
+
+  call gradients_kcm(profil_flag(1),rho_v(1),rho_n(1),Tsurf,dTdp,dPvdp,dPndp)
+  if(verbose)then
+     print*, 'dT/dp ground [K/Pa] =',dTdp
+  endif
+
+  ! initial delta p, delta z
+  Dp = (Pn(1) + Pv(1))*(exp(dlogp) - 1d0)
+  Dz = -Dp/(  g*(rho_n(1) + rho_v(1))  )
+
+  !-------------------------------
+  ! Layer 2
+  T(2)     = tsurf + dTdp*Dp 
+  Pv(2)    = Pv(1) + dPvdp*Dp
+  Pn(2)    = Pn(1) + dPndp*Dp
+  rho_n(2) = m_n*Pn(2)/(Rc*T(2))
+  rho_v(2) = m_v*Pv(2)/(Rc*T(2))
+  a_v(2)   = rho_v(2)/rho_n(2)
+
+  !-------------------------------
+  ! start vertical ascent
+  Ztab(1) = 0.
+  do ilay=2,nlay-1
+
+     ! calculate altitude levels (for diagnostic only)
+     Dz         = -Dp/(  g*(rho_n(ilay) + rho_v(ilay))  )
+     Ztab(ilay) = Dz + Ztab(ilay-1)
+
+     ! 1st assume next layer same as last one
+     profil_flag(ilay) = profil_flag(ilay-1)
+  
+     ! update delta p
+     Dp = (Pn(ilay)+Pv(ilay))*(exp(dlogp) - 1d0)
+
+     ! intial gradients call to calculate temperature at next level
+     call gradients_kcm(profil_flag(ilay),rho_v(ilay),rho_n(ilay),&
+                        T(ilay),dTdp,dPvdp,dPndp)
+
+     T(ilay+1) = T(ilay) + dTdp*Dp
+
+     ! test for moist adiabat at next level
+     psat_v=psat_max
+
+     if(vgas.gt.0)then
+     if(trim(gnom(vgas)).eq.'H2O')then
+        call Psat_H2O(T(ilay+1),psat_v)
+     elseif(trim(gnom(vgas)).eq.'NH3')then
+        call Psat_NH3(T(ilay+1),psat_v)
+     endif
+     endif
+
+     if (psat_v*1d6 .lt. Pv(ilay)+dPvdp*Dp) then
+        profil_flag(ilay)=1
+        call gradients_kcm(profil_flag(ilay),rho_v(ilay),rho_n(ilay),&
+                         T(ilay),dTdp,dPvdp,dPndp)
+     endif
+
+     ! test for stratosphere at next level
+     if (T(ilay+1) .le. Ttop) then
+        profil_flag(ilay)=2
+        T(ilay+1)=Ttop
+     endif
+
+     ! calculate pressures at next level
+     Pn(ilay+1) = Pn(ilay) + dPndp*Dp
+     Pv(ilay+1) = Pv(ilay) + dPvdp*Dp
+
+     if(profil_flag(ilay) .eq. 1)then
+       
+        psat_v=psat_max 
+
+        if(vgas.gt.0)then
+        if(trim(gnom(vgas)).eq.'H2O')then
+           call Psat_H2O(T(ilay+1),psat_v)
+        elseif(trim(gnom(vgas)).eq.'NH3')then
+           call Psat_NH3(T(ilay+1),psat_v)
+        endif
+        endif
+
+        if(Pv(ilay+1) .lt. psat_v*1e6)then
+           Pv(ilay+1)=psat_v*1d6
+        endif
+
+     endif
+
+     ! calculate gas densities at next level (assume ideal)
+     rho_n(ilay+1) = m_n*Pn(ilay+1)/(rc*T(ilay+1)) 
+     select case(profil_flag(ilay)) 
+     case(2) ! isothermal
+        rho_v(ilay+1) = rho_v(ilay)/rho_n(ilay)*rho_n(ilay+1)
+     case(1) ! moist
+
+        ! dont think this is necessary
+        !call psat_est(T(ilay+1),psat_v)
+        ! modify for ammonia!!!
+
+        rho_v(ilay+1) = m_v*psat_v*1d6/(rc*T(ilay+1))
+     case(0) ! dry
+        rho_v(ilay+1) = m_v*Pv(ilay+1)/(rc*T(ilay+1)) 
+     end select
+
+  enddo
+
+  Ztab(nlay)=Ztab(nlay-1)+Dz
+
+  !-------------------------------
+  ! save to kcm1d variables 
+
+  ! surface quantities
+  psurf_rcm = Pn(1) + Pv(1)
+  qsurf_rcm = rho_v(1)/(rho_v(1) + rho_n(1))
+
+  ! create q_v, mtot for saving
+  do ilay=1,nlay
+     mtot(ilay) = 1d3*(rho_v(ilay) + rho_n(ilay)) / &
+                  (rho_v(ilay)/m_v + rho_n(ilay)/m_n)
+     q_v(ilay)  = rho_v(ilay)/(rho_v(ilay) + rho_n(ilay))
+     ! CHECK THIS
+  enddo
+
+
+  ! convert to rcm lower-res grid
+  z_rcm(:) = 0.0
+  T_rcm(:) = 0.0
+  q_rcm(:) = 0.0
+  m_rcm(:) = 0.0
+
+  m_rcm(1) = real( 1d3*(rho_v(1) + rho_n(1)) / &
+                  (rho_v(1)/m_v + rho_n(1)/m_n) )
+
+  ilay_rcm=1
+  do ilay=2,nlay
+
+     if(ilay_rcm.le.nlayer)then
+     ! interpolate rcm variables
+
+        if(Pn(ilay)+Pv(ilay) .lt. P_rcm(ilay_rcm))then
+
+           if(ilay.eq.1)then
+              print*,'Error in create_profils: Psurf here less than Psurf in RCM!'
+              call abort
+           endif
+
+           lnp1   = log(Pn(ilay-1)+Pv(ilay-1))
+           lnp2   = log(Pn(ilay)+Pv(ilay))
+           lnpnew = dble(log(P_rcm(ilay_rcm)))
+
+           z_rcm(ilay_rcm) = real(Ztab(ilay-1)*(lnp2-lnpnew)/(lnp2-lnp1) &
+                             + Ztab(ilay)*(lnpnew-lnp1)/(lnp2-lnp1))
+           T_rcm(ilay_rcm) = real(T(ilay-1)*(lnp2-lnpnew)/(lnp2-lnp1) &
+                             + T(ilay)*(lnpnew-lnp1)/(lnp2-lnp1))
+           q_rcm(ilay_rcm) = real(q_v(ilay-1)*(lnp2-lnpnew)/(lnp2-lnp1) &
+                             + q_v(ilay)*(lnpnew-lnp1)/(lnp2-lnp1))
+
+           m_rcm(ilay_rcm+1) = real(mtot(ilay-1)*(lnp2-lnpnew)/(lnp2-lnp1) &
+                             + mtot(ilay)*(lnpnew-lnp1)/(lnp2-lnp1))
+
+           ilay_rcm = ilay_rcm+1
+        endif
+
+     endif
+  enddo
+
+  ifinal_rcm=ilay_rcm-1
+  if(ifinal_rcm.lt.nlayer)then
+     if(verbose)then
+        print*,'Interpolation in kcmprof stopped at layer',ilay_rcm,'!'
+     endif
+
+     do ilay_rcm=ifinal_rcm+1,nlayer
+
+        z_rcm(ilay_rcm) = z_rcm(ilay_rcm-1)
+        T_rcm(ilay_rcm) = T_rcm(ilay_rcm-1)
+        q_rcm(ilay_rcm) = q_rcm(ilay_rcm-1)
+        m_rcm(ilay_rcm+1) = m_rcm(ilay_rcm)
+
+     enddo
+  endif
+
+  do ilay=2,nlayer
+     if(T_rcm(ilay).lt.Ttop)then
+        T_rcm(ilay)=Ttop
+     endif
+  enddo
+
+!    CO2 condensation 'haircut' of temperature profile if necessary
+  if(co2cond)then
+     print*,'CO2 condensation haircut - assumes CO2-dominated atmosphere!'
+     do ilay=2,nlayer
+        if(P_rcm(ilay).lt.518000.)then
+           TCO2cond = (-3167.8)/(log(.01*P_rcm(ilay))-23.23) ! Fanale's formula
+        else
+           TCO2cond = 684.2-92.3*log(P_rcm(ilay))+4.32*log(P_rcm(ilay))**2 
+           ! liquid-vapour transition (based on CRC handbook 2003 data)
+        endif
+
+        print*,'p=',P_rcm(ilay),', T=',T_rcm(ilay),' Tcond=',TCO2cond
+        if(T_rcm(ilay).lt.TCO2cond)then
+           T_rcm(ilay)=TCO2cond
+        endif
+     enddo
+  endif
+
+  return
+end subroutine kcmprof_fn
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/logic_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/logic_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/logic_mod.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/logic_mod.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_const_mpi.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_const_mpi.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_const_mpi.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/mod_const_mpi.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_interface_dyn_phys.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_interface_dyn_phys.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/mod_interface_dyn_phys.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dynphy_lonlat/mod_interface_dyn_phys.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/paramet.h
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/paramet.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/paramet.h	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/paramet.h
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/phasechange_kcm.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/phasechange_kcm.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/phasechange_kcm.F90	(revision 1644)
@@ -0,0 +1,1286 @@
+!  ----------------------------------------------------------------
+!  Purpose: Thermodynamic data on H2O, NH3
+!  Authour: Adapted from various sources by R. Wordsworth (2011)
+
+
+! ---------------------
+! NH3
+! ---------------------
+subroutine psat_NH3 ( T, p )
+!
+!  PSAT_NH3 makes a rough estimate of the vapor pressure.
+!
+!  Interpolated from www.engineeringtoolbox.com data by RDW 21/09/11 for
+!  temperatures between 223 and 323 K.
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Output, double precision P, the vapor pressure, in MegaPascals.
+!
+
+  implicit none
+
+  double precision p,T
+
+  p=exp(-1.5609d-004*T**2 + 0.1236*T - 9.1530)/1d6
+
+end subroutine psat_NH3
+
+subroutine latheat_NH3 ( T, sc, sv )
+!
+!  PSAT_NH3 makes a rough estimate of the entropies of condensation /
+!  vapourisation.
+! 
+!  Interpolated from www.engineeringtoolbox.com data by RDW 21/09/11 for
+!  temperatures between 223 and 323 K.
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Output, double precision sc, the entropy of condensate, in J kg^-1 K^-1.
+!            double precision sv, the entropy of gas, in J kg^-1 K^-1.
+!
+
+  implicit none
+
+  double precision T,sc,sv
+
+  sv = 0.0492*T**2 - 40.4199*T + 1.2708e+004
+  sc = -0.0215*T**2 + 28.7138*T - 5.5267e+003
+
+  !L = -11.2373*T**2 + 2.5326d+03*T + 1.4099d+06
+
+end subroutine latheat_NH3
+
+
+! ---------------------
+! H2O
+! ---------------------
+
+subroutine base ( t, rho, ab, cvb, dpdrb, dpdtb, gb, hb, pb, sb, ub )
+!
+!*******************************************************************************
+!
+!! BASE calculates quantities associated with the base Helmholtz function.
+!
+!
+!  Discussion:
+!
+!    The equation for the base Helmholtz function AB(T,RHO) is:
+!
+!      AB(T,RHO) = R * T * (
+!        - ln ( 1 - y ) 
+!        - ( beta - 1 ) / ( 1 - y ) 
+!        + ( alpha + beta + 1 ) / ( 2 * ( 1 - y )**2 )
+!        + 4 * y * ( ( Bbar / b ) - gamma ) 
+!        - 0.5 * ( alpha - beta + 3 ) 
+!        + ln ( RHO * R * T / P0 ) )
+!                                                      (Equation 2)
+!   where 
+!
+!     y = b * rho / 4, 
+!     alpha = 11,
+!     beta = 133/3, 
+!     gamma = 7/2, 
+!     P0 = 0.101325 MegaPascals = 1 atm
+!
+!   and
+!
+!     b(T) = b1 * ln(T/T0) + sum(j=0,1,3,5) b(j)*(T0/T)**j  (Equation 3)
+!
+!     Bbar(T) = sum(j=0,1,2,4) B(j)*(T0/T)**j               (Equation 4).
+!
+!   where 
+!
+!     T0=647.073 K and the coefficients b(j) and B(j) are
+!    
+!     j    b(j)                         B(j)
+!    --    -----------                  ----------
+!     0    0.7478629                    1.1278334
+!     1   -0.3540782                   -0.5944001
+!     2    0                           -5.010996
+!     3    0.007159876                  0
+!     4    0                            0.63684256
+!     5   -0.003528426                  0
+!
+!  For the derived quantities, the following relations are used:
+!
+!    Pressure:                  PB      = RHO**2 * dAB/dRHO
+!    Density derivative:        DPDRB   = 2*PB/RHO + RHO**2 * d2AB/dRHO2
+!    Temperature derivative:    DPDTB   = RHO**2 * d2AB/(dRHO dT)
+!    Specific entropy:          SB      = ( UB - AB ) / T
+!    Specific internal energy:  UB      = AB + T * SB
+!    Specific enthalpy:         HB      = UB + PB / RHO
+!    Specific heat capacity
+!      at constant volume:      CVB     = - T * d2AB/dT2
+!    Specific Gibbs function:   GB      = AB + PB / RHO
+!
+!
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!    C A Meyer, R B McClintock, G J Silvestri, R C Spencer,
+!    ASME Steam Tables: Thermodynamic and Transport Properties of Steam,
+!    American Society of Mechanical Engineers, 1967.
+!
+!  Modified:
+!
+!    03 February 2002
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Input, double precision RHO, the density, in G/CM3.
+!
+!    Output, double precision AB, the base value of the Helmholtz function,
+!    in KJ/kg.
+!
+!    Output, double precision CVB, the base value of the isochoric (constant 
+!    volume) heat capacity, in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision DPDRB, the base value of the partial
+!    derivative dP(T,RHO)/dRHO, with T held fixed, in (MegaPascals CM3)/G.
+!
+!    Output, double precision DPDTB, the base value of the partial
+!    derivative dP(T,RHO)/dT, with RHO held fixed, in 
+!    MegaPascals/degrees Kelvin.
+!
+!    Output, double precision GB, the base value of the Gibbs free energy,
+!    in KJ/kg.
+!
+!    Output, double precision HB, the base value of enthalpy, in KJ/kg.
+!
+!    Output, double precision PB, the base pressure, in MegaPascals.
+!
+!    Output, double precision SB, the base value of entropy, 
+!    in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision UB, the base value of internal energy, 
+!    in KJ/kg.
+!
+  implicit none
+!
+  double precision ab
+  double precision, parameter :: alpha = 11.0D+00
+  double precision b1
+  double precision b1t
+  double precision b1tt
+  double precision b2
+  double precision b2t
+  double precision b2tt
+  double precision, parameter :: beta = 44.333333333333D+00
+  double precision cvb
+  double precision dpdrb
+  double precision dpdtb
+  double precision dz
+  double precision dz0
+  double precision, parameter :: gamma = 3.5D+00
+  double precision gascon
+  double precision gb
+  double precision hb
+  double precision, parameter :: p_zero = 0.101325D+00
+  double precision pb
+  double precision rho
+  double precision sb
+  double precision t
+  double precision ub
+  double precision x
+  double precision y
+  double precision z
+  double precision z0
+!
+!  Refuse to handle zero or negative temperatures.
+!
+  if ( t <= 0.0 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'BASE - Fatal error!'
+    write ( *, '(a)' ) '  The input temperature T must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was T = ', t
+    stop
+  end if
+!
+!  Refuse to handle zero or negative density.
+!
+  if ( rho <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'BASE - Fatal error!'
+    write ( *, '(a)' ) '  The input density RHO must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was RHO = ', rho
+    stop
+  end if
+!
+!  Compute auxilliary quantities for Equation 2.
+!
+  call bb ( t, b1, b2, b1t, b2t, b1tt, b2tt )
+
+  y = 0.25D+00 * b1 * rho
+
+  x = 1.0D+00 - y
+!
+!  Evaluate Equation 2.
+!
+  ab =   - log ( 1.0D+00 - y ) &
+         - ( beta - 1.0D+00 ) / ( 1.0D+00 - y ) &
+         + ( alpha + beta + 1.0D+00 ) / ( 2.0D+00 * ( 1.0D+00 - y )**2 ) &
+         + 4.0D+00 * y * ( ( b2 / b1 ) - gamma ) &
+         - 0.5D+00 * ( alpha - beta + 3.0D+00 ) &
+         + log ( rho * gascon() * t / p_zero )
+!
+!  Determine quantities defined in terms of AB.
+!
+  pb = ( 1.0D+00 + alpha * y + beta * y**2 ) / ( 1.0D+00 - y )**3 &
+    + 4.0D+00 * y * ( b2 / b1 - gamma )
+
+  z0 = ( 1.0D+00 + alpha * y + beta * y**2 ) / ( 1.0D+00 - y )**3
+
+  z = z0 + 4.0D+00 * y * ( b2 / b1 - gamma )
+
+  dz0 = ( alpha + 2.0D+00 * beta * y ) / ( 1.0D+00 - y )**3 &
+    + 3.0D+00 * ( 1.0D+00 + alpha * y + beta * y**2 ) / ( 1.0D+00 - y )**4
+
+  dz = dz0 + 4.0D+00 * ( b2 / b1 - gamma )
+
+  gb = ab + pb
+
+  ub = - t * b1t * ( pb - 1.0D+00 - rho * b2 ) / b1 - rho * t * b2t
+
+  hb = pb + ub
+!
+!  An incorrect version of this equation began:
+!
+!    cvb = 2.0D+00 * ub + ( pb - 1.0D+00 ) &
+!
+!  and caused me no end of trouble.  My fault, JVB, 03 February 2002
+!
+  cvb = 2.0D+00 * ub + ( z0 - 1.0D+00 ) &
+    * ( ( t * b1t / b1 )**2 - t**2 * b1tt / b1 ) &
+    - rho * t**2 * ( b2tt - gamma * b1tt ) - ( t * b1t / b1 )**2 * y * dz0
+
+  dpdtb = pb / t + rho * ( 0.25D+00 * ( dz0 + 4.0D+00 * ( b2 / b1 - gamma ) ) &
+    * b1t + b2t - b2 / b1 * b1t )
+
+  sb = ub - ab
+
+  dpdrb = pb + y * ( dz0 + 4.0D+00 * ( b2 / b1 - gamma ) )
+!
+!  Assign dimensions.
+!
+  ab =    gascon() * t       * ab
+  cvb =   gascon()           * cvb
+  dpdrb = gascon() * t       * dpdrb
+  dpdtb = gascon() * t * rho * dpdtb
+  gb =    gascon() * t       * gb
+  hb =    gascon() * t       * hb
+  pb =    gascon() * t * rho * pb
+  sb =    gascon()           * sb
+  ub =    gascon() * t       * ub
+
+  return
+end subroutine base
+
+subroutine bb ( t, b1, b2, b1t, b2t, b1tt, b2tt )
+!
+!*******************************************************************************
+!
+!! BB calculates the B's of equations 3 and 4.  
+!
+!
+!  Discussion:
+!
+!    Here
+!
+!      b(T) = b1 * ln(T/T0) + sum(j=0,1,3,5) b(j)*(T0/T)**j  (Equation 3)
+!
+!      Bbar(T) = sum(j=0,1,2,4) B(j)*(T0/T)**j               (Equation 4).
+!
+!    where 
+!
+!      T0 = 647.073 K 
+!
+!    and the coefficients b(j) and B(j) are
+!    
+!      j    b(j)                         B(j)
+!     --    -----------                  ----------
+!      0    0.7478629                    1.1278334
+!      1   -0.3540782                   -0.5944001
+!      2    0                           -5.010996
+!      3    0.007159876                  0
+!      4    0                            0.63684256
+!      5   -0.003528426                  0
+!
+!
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!    C A Meyer, R B McClintock, G J Silvestri, R C Spencer,
+!    ASME Steam Tables: Thermodynamic and Transport Properties of Steam,
+!    American Society of Mechanical Engineers, 1967.
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Output, double precision B1, the coefficient b from equation 3, 
+!    in CM3/G.
+!
+!    Output, double precision B2, the coefficient Bbar from equation 4, 
+!    in CM3/G.
+!
+!    Output, double precision B1T, the derivative dB1/dT, 
+!    in (CM3)/(G Degrees Kelvin).
+!
+!    Output, double precision B2T, the derivative dB2/dT, 
+!    in (CM3)/(G Degrees Kelvin).
+!
+!    Output, double precision B1TT, the second derivative of B1 with 
+!    respect to T, in (CM3)/(G (Degrees Kelvin)**2 ).
+!
+!    Output, double precision B2TT, the second derivative of B2 with 
+!    respect to T, in (CM3)/(G (Degrees Kelvin)**2 ).
+!
+  implicit none
+!
+  double precision b1
+  double precision b1t
+  double precision b1tt
+  double precision b2
+  double precision b2t
+  double precision b2tt
+  double precision, parameter, dimension ( 10 ) :: bp = (/ &
+    0.7478629D+00,   -0.3540782D+00,    0.0D+00,           0.0D+00, &
+    0.007159876D+00,  0.0D+00,         -0.003528426D+00,   0.0D+00, &
+    0.0D+00,          0.0D+00 /)
+  double precision, parameter, dimension ( 10 ) :: bq = (/ &
+    1.1278334D+00,    0.0D+00,         -0.5944001D+00,   -5.010996D+00, &
+    0.0D+00,          0.63684256D+00,   0.0D+00,          0.0D+00, &
+    0.0D+00,          0.0D+00 /)
+  integer i
+  double precision t
+  double precision, parameter :: t_ref = 647.073D+00
+  double precision v(10)
+!
+!  Refuse to handle zero or negative temperatures.
+!
+  if ( t <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'BB - Fatal error!'
+    write ( *, '(a)' ) '  The input temperature T must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was T = ', t
+    stop
+  end if
+!
+!  Set V(I) = ( T_REF / T )**(I-1).
+!
+  v(1) = 1.0D+00
+  do i = 2, 10
+    v(i) = v(i-1) * t_ref / t
+  end do
+!
+!  Set B1, B1T, B1TT.
+!
+  b1 = bp(1) + bp(2) * log ( 1.0D+00 / v(2) )
+  b1t = bp(2) * v(2) / t_ref
+  b1tt = 0.0D+00
+  do i = 3, 10
+    b1 = b1 + bp(i) * v(i-1)
+    b1t = b1t - dble ( i - 2 ) * bp(i) * v(i-1) / t
+    b1tt = b1tt + bp(i) * dble ( i - 2 )**2 * v(i-1) / t**2
+  end do
+
+  b1tt = b1tt -  ( b1t / t )
+!
+!  Set B2, B2T, B2TT.
+!
+  b2 = bq(1)
+  b2t = 0.0D+00
+  b2tt = 0.0D+00
+  do i = 3, 10
+    b2 = b2 + bq(i) * v(i-1)
+    b2t = b2t - dble ( i - 2 ) * bq(i) * v(i-1) / t
+    b2tt = b2tt + bq(i) * dble ( i - 2 )**2 * v(i-1) / t**2
+  end do
+
+  b2tt = b2tt - ( b2t / t )
+
+  return
+end subroutine bb
+
+
+subroutine ideal ( t, ai, cpi, cvi, gi, hi, si, ui )
+!
+!*******************************************************************************
+!
+!! IDEAL computes ideal gas thermodynamic properties of water.
+!
+!
+!  Discussion:
+!
+!    Values for thermodynamic properties of water in the ideal
+!    gas state were reported by Woolley.  The formula for the ideal gas
+!    term of the Helmholtz function approximates a term by term summation of 
+!    contributions from each of the rotation and vibration states.  
+!    The formula, equation #6 in the reference, is:
+!   
+!    A(ideal)(T) = -R * T * ( 1 + ( C(1)/Tr + C(2) ) * ln(Tr)
+!      + Sum ( 3 <= I <= 18) C(I) * Tr**(I-6)
+!   
+!    where Tr=T/100 K.  The C(i) are tabulated coefficients.  Equation
+!    6 can be used for temperatures below 3000 K, and is accurate to
+!    within the tolerance of the gas constant for 50<=T<=2000 K.
+!     
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Output, double precision AI, the Helmholtz function, in KJ/kg.
+!
+!    Output, double precision CPI, the heat capacity at constant pressure,
+!    in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision CVI, the heat capacity at constant volume,
+!    in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision GI, the Gibbs free energy, in KJ/kg.
+!
+!    Output, double precision HI, the enthalpy, in KJ/kg.
+!
+!    Output, double precision SI, the entropy, in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision UI, the internal energy, in KJ/kg.
+!
+  implicit none
+!
+  double precision ai
+  double precision, parameter, dimension ( 18 ) :: c = (/ &
+   19.730271018D+00,      20.9662681977D+00,     -0.483429455355D+00, &
+    6.05743189245D+00,    22.56023885D+00,       -9.87532442D+00, &
+   -4.3135538513D+00,      0.458155781D+00,      -0.047754901883D+00, &
+    0.0041238460633D+00,  -0.00027929052852D+00,  0.14481695261D-04, &
+   -0.56473658748D-06,     0.16200446D-07,       -0.3303822796D-09, &
+    0.451916067368D-11,   -0.370734122708D-13,    0.137546068238D-15 /)
+  double precision cpi
+  double precision cvi
+  double precision gascon
+  double precision gi
+  double precision hi
+  integer i
+  double precision si
+  double precision t
+  double precision temp
+  double precision tt
+  double precision ui
+!
+!  Refuse to handle zero or negative temperatures.
+!
+  if ( t <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'IDEAL - Fatal error!'
+    write ( *, '(a)' ) '  The input temperature T must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was T = ', t
+    stop
+  end if
+
+  tt = t / 100.0D+00
+
+  gi = - ( c(1) / tt + c(2) ) * log ( tt )
+  do i = 3, 18
+    gi = gi - c(i) * tt**(i-6)
+  end do
+
+  hi = c(2) + c(1) * ( 1.0D+00 - log ( tt ) ) / tt
+  do i = 3, 18
+    hi = hi + dble ( i - 6 ) * c(i) * tt**(i-6)
+  end do
+
+  cpi = c(2) - c(1) / tt
+  do i = 3, 18
+    cpi = cpi + dble ( ( i - 6 ) * ( i - 5 ) ) * c(i) * tt**(i-6)
+  end do
+
+  ai = gi - 1.0D+00
+  ui = hi - 1.0D+00
+  cvi = cpi - 1.0D+00
+  si = hi - gi
+!
+!  Assign dimensions.
+!
+  ai =  gascon() * t * ai
+  cpi = gascon()     * cpi
+  cvi = gascon()     * cvi
+  gi =  gascon() * t * gi
+  hi =  gascon() * t * hi
+  si =  gascon()     * si
+  ui =  gascon() * t * ui
+
+  return
+end subroutine ideal
+
+
+subroutine resid ( t, rho, ar, cvr, dpdrr, dpdtr, gr, hr, pr, sr, ur )
+!
+!*******************************************************************************
+!
+!! RESID calculates residual contributions to thermodynamic quantities.
+!
+!
+!  Discussion:
+!
+!    The residual function consists of 40 terms.  The first 36 are
+!    used in a global least squares fit to experimental data.
+!
+!    Three terms were added that contribute only in the immediate
+!    neighborhood of the critical point 
+!      (tk-5) <= T <= (tk+5) C
+!      0.20   <= rho <= 0.44 g/cm3, 
+!
+!    A single term was added for the region of high pressure and 
+!    low temperature: T < 75 C, P > 300 MPa.
+!
+!    Except in these limited regions, the residual function is
+!    given by the first 36 terms.  The equation is
+!   
+!      A(residual)(rho,T)=
+!        sum(i=1 to 36) (g(i)/k(i)) * (T0/T)**(l(i)) (1-exp(-rho))**(k(i))
+!      + sum(i=37 to 40) g(i)*delta(i)**(k(i))
+!        * exp(-alpha(i)*delta(i)**(k(i)) - beta(i)*tau(i)**2)
+!                                                     (Equation 5)
+!   
+!    where
+!
+!      g(i) are coefficients determined by fits to data,
+!      delta(i) are reduced densities (delta(i)=((rho-rho(i))/rho(i))
+!      tau(i) are reduced temperatures (tau(i)=((T-tau(i))/tau(i))
+!      rho(i) are specified densities.
+!      tau(i) are specified temperatures.
+!      The k(i) and l(i) are specified integers.
+!   
+!  Modified:
+!
+!    22 November 1998
+!
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!    C A Meyer, R B McClintock, G J Silvestri, R C Spencer,
+!    ASME Steam Tables: Thermodynamic and Transport Properties of Steam,
+!    American Society of Mechanical Engineers, 1967.
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Input, double precision RHO, the density, in G/CM3.
+!
+!    Output, double precision AR, the residual contribution to the 
+!    Helmholtz function, in KJ/kg.
+!
+!    Output, double precision CVR, the residual contribution to the 
+!    isochoric (constant volume) heat capacity, in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision DPDRR, the residual contribution to 
+!    the partial derivative dP(T,RHO)/dRHO, with T held fixed, in 
+!    (MegaPascals CM3)/G.
+!
+!    Output, double precision DPDTR, the residual contribution to 
+!    the partial derivative dP(T,RHO)/dT, with RHO held fixed, 
+!    in MegaPascals/degrees Kelvin.
+!
+!    Output, double precision GR, the residual contribution to the Gibbs 
+!    function, in KJ/kg.
+!
+!    Output, double precision HR, the residual contribution to the 
+!    enthalpy, in KJ/kg.
+!
+!    Output, double precision PR, the residual contribution to the pressure, 
+!    in MegaPascals.
+!
+!    Output, double precision SR, the residual contribution to the entropy, 
+!    in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision UR, the residual contribution to the 
+!    internal energy, in KJ/kg.
+!
+  implicit none
+!
+  double precision, parameter, dimension ( 4 ) :: aad = (/ &
+    34.0D+00, 40.0D+00, 30.0D+00, 1050.0D+00 /)
+  double precision, parameter, dimension ( 4 ) :: aat = (/ &
+    20000.0D+00, 20000.0D+00, 40000.0D+00, 25.0D+00 /)
+  double precision, parameter, dimension ( 4 ) :: adz = (/ &
+    0.319D+00, 0.319D+00, 0.319D+00, 1.55D+00 /)
+  double precision ar
+  double precision att
+  double precision, parameter, dimension ( 4 ) ::  atz = (/ &
+    640.0D+00, 640.0D+00, 641.6D+00, 270.0D+00 /)
+  double precision cvr
+  double precision dadt
+  double precision ddz
+  double precision del
+  double precision dex
+  double precision dfdt
+  double precision dpdrr
+  double precision dpdtr
+  double precision e
+  double precision errtol
+  double precision ex0
+  double precision ex1
+  double precision ex2
+  double precision fct
+  double precision, parameter, dimension ( 40 ) :: g = (/ &
+    -530.62968529023D+00,  0.22744901424408D+04, 0.78779333020687D+03, &
+    -69.830527374994D+00,  0.17863832875422D+05,-0.39514731563338D+05, &
+    0.33803884280753D+05, -0.13855050202703D+05,-0.25637436613260D+06, &
+    0.48212575981415D+06, -0.34183016969660D+06, 0.12223156417448D+06, &
+    0.11797433655832D+07, -0.21734810110373D+07, 0.10829952168620D+07, &
+   -0.25441998064049D+06, -0.31377774947767D+07, 0.52911910757704D+07, &
+   -0.13802577177877D+07, -0.25109914369001D+06, 0.46561826115608D+07, &
+   -0.72752773275387D+07,  0.41774246148294D+06, 0.14016358244614D+07, &
+   -0.31555231392127D+07,  0.47929666384584D+07, 0.40912664781209D+06, &
+   -0.13626369388386D+07,  0.69625220862664D+06,-0.10834900096447D+07, &
+   -0.22722827401688D+06,  0.38365486000660D+06, 0.68833257944332D+04, &
+    0.21757245522644D+05, -0.26627944829770D+04,-0.70730418082074D+05, &
+   -0.225D+00, -1.68D+00, 0.055D+00, -93.0D+00 /)
+  double precision gascon
+  double precision gr
+  double precision hr
+  integer i
+  integer, parameter, dimension ( 40 ) :: ii = (/ &
+    0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6, &
+    8,8,8,8,2,2,0,4,2,2,2,4 /)
+  integer j
+  integer, parameter, dimension ( 40 ) :: jj = (/ &
+    2,3,5,7,2,3,5,7,2,3,5,7,2,3,5,7,2,3,5,7,2,3,5,7,2,3,5,7,&
+    2,3,5,7,1,4,4,4,0,2,0,0 /)
+  integer k
+  integer l
+  integer nc
+  double precision pr
+  double precision q10
+  double precision q20
+  double precision q2a
+  double precision q5t
+  double precision qm
+  double precision qp
+  double precision qr(11)
+  double precision qt(10)
+  double precision rho
+  double precision sr
+  double precision, parameter :: s_ref = 7.6180720166752D+00
+  double precision t
+  double precision, parameter :: t_ref = 647.073D+00
+  double precision tau
+  double precision tx
+  double precision, parameter :: u_ref = - 4328.4549774261D+00
+  double precision ur
+  double precision v
+!
+  errtol = sqrt ( epsilon ( errtol ) )
+!
+!  Refuse to handle zero or negative temperatures.
+!
+  if ( t <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'RESID - Fatal error!'
+    write ( *, '(a)' ) '  The input temperature T must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was T = ', t
+    stop
+  end if
+!
+!  Refuse to handle zero or negative density.
+!
+  if ( rho <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'RESID - Fatal error!'
+    write ( *, '(a)' ) '  The input density RHO must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was RHO = ', rho
+    stop
+  end if
+
+  nc = 36
+  dpdrr = 0.0D+00
+  pr = 0.0D+00
+  ar = 0.0D+00
+  dadt = 0.0D+00
+  cvr = 0.0D+00
+  dpdtr = 0.0D+00
+
+  ex0 = - rho
+! ex0 = max ( ex0, - 225.0D+00 )
+! ex0 = min ( ex0, 225.0D+00 )
+  e = exp ( ex0 )
+
+  q10 = rho * rho * e
+  q20 = 1.0D+00 - e
+
+  qr(1) = 0.0D+00
+  qr(2) = q10
+  do i = 2, 10
+    qr(i+1) = qr(i) * q20
+  end do
+
+  v = t_ref / t
+  qt(1) = t / t_ref
+  do i = 2, 10
+    qt(i) = qt(i-1) * v
+  end do
+
+  do i = 1, nc
+
+    k = ii(i) + 1
+    l = jj(i)
+    qp = g(i) * qr(k+1) * qt(l+1)
+    pr = pr + qp
+
+    dpdrr = dpdrr + ( 2.0D+00 / rho - ( 1.0D+00 - e * dble ( k - 1 ) / &
+      ( 1.0D+00 - e ) ) ) * qp
+
+    ar = ar + g(i) * qr(k+2) * qt(l+1) / ( rho**2 * e * dble ( k ) &
+      * gascon ( ) * t )
+
+    dfdt = ( 1.0D+00 - e )**k * dble ( 1 - l ) * qt(l+2) / t_ref / dble ( k )
+
+    dadt = dadt + g(i) * dfdt
+
+    dpdtr = dpdtr + g(i) * dfdt * rho**2 * e * dble ( k ) / ( 1.0D+00 - e )
+
+    cvr = cvr + g(i) * dble ( l ) * dfdt / gascon()
+
+  end do
+
+  qp = 0.0D+00
+  q2a = 0.0D+00
+
+  do j = 37, 40
+
+    k = ii(j)
+    ddz = adz(j-36)
+    del = rho / ddz - 1.0D+00
+
+    if ( abs ( del ) < errtol ) then
+      del = errtol
+    end if
+
+    ex1 = - aad(j-36) * del**k
+!   ex1 = max ( ex1, - 225.0D+00 )
+!   ex1 = min ( ex1, 225.0D+00 )
+    dex = exp ( ex1 ) * del**jj(j)
+
+    att = aat(j-36)
+    tx = atz(j-36)
+    tau = ( t / tx ) - 1.0D+00
+
+    ex2 = - att * tau**2
+!   ex2 = max ( ex2, - 225.0D+00 )
+!   ex2 = min ( ex2, 225.0D+00 )
+    q10 = dex * exp ( ex2 )
+
+    qm = dble ( jj(j) ) / del - dble ( k ) * aad(j-36) * del**(k-1)
+    fct = qm * rho**2 * q10 / ddz
+
+    q5t = fct * ( 2.0D+00 / rho + qm / ddz ) - ( rho / ddz )**2 * q10 * &
+      ( dble ( jj(j) ) / del**2 + dble ( k * ( k - 1 ) ) * aad(j-36) * &
+      del**(k-2) )
+
+    dpdrr = dpdrr + q5t * g(j)
+    qp = qp + g(j) * fct
+    dadt = dadt - 2.0D+00 * g(j) * att * tau * q10 / tx
+    dpdtr = dpdtr - 2.0D+00 * g(j) * att * tau * fct / tx
+
+    q2a = q2a + t * g(j) * att * ( 4.0D+00 * ex2 + 2.0D+00 ) * q10 / tx**2
+
+    ar = ar + q10 * g(j) / ( gascon() * t )
+
+  end do
+
+  cvr = cvr + q2a / gascon()
+  pr = pr + qp
+  sr = - dadt / gascon()
+  ur = ar + sr
+!
+!  Assign dimensions.
+!
+  ar =  gascon() * t *  ar
+  cvr = gascon() *     cvr
+  sr =  gascon() *      sr
+  ur =  gascon() * t *  ur
+!
+!  Adjust energies.
+!
+  ar = ar + gascon ( ) * t * s_ref - gascon ( ) * u_ref
+  sr = sr - gascon ( ) * s_ref
+  ur = ur - gascon ( ) * u_ref
+
+  gr = ar + pr / rho
+  hr = ur + pr / rho
+
+  return
+end subroutine resid
+
+subroutine psat_H2O ( t, p )
+!
+!*******************************************************************************
+!
+!! PSAT_H2O makes a rough estimate of the vapor pressure.
+!
+!
+!  Discussion:
+!
+!    The calculation agrees with tabulated data to within
+!    0.02% for temperature to within a degree or so of the critical
+!    temperature.  The approximate vapor pressure can be refined
+!    by imposing the condition that the Gibbs functions of the vapor
+!    and liquid phases be equal.
+!
+!  Modified:
+!
+!    21 November 1998
+!
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!    C A Meyer, R B McClintock, G J Silvestri, R C Spencer,
+!    ASME Steam Tables: Thermodynamic and Transport Properties of Steam,
+!    American Society of Mechanical Engineers, 1967.
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Output, double precision P, the vapor pressure, in MegaPascals.
+!
+  implicit none
+!
+  double precision, parameter, dimension ( 8 ) :: a = (/ &
+    -7.8889166D+00,   2.5514255D+00,   -6.716169D+00, 33.239495D+00, &
+    -105.38479D+00,   174.35319D+00,  -148.39348D+00, 48.631602D+00 /)
+  double precision b
+  integer i
+  double precision p
+  double precision q
+  double precision t
+  double precision, parameter :: t_ref = 647.25D+00
+  double precision v
+  double precision w
+  double precision z
+!
+!  Refuse to handle zero or negative temperatures.
+!
+  if ( t <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'PSAT_H2O - Fatal error!'
+    write ( *, '(a)' ) '  The input temperature T must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was T = ', t
+    stop
+  end if
+
+  if ( t <= 314.0D+00 ) then
+
+    p = 0.1D+00 * exp ( 6.3573118D+00 - 8858.843D+00 / t &
+      + 607.56335D+00 * t**( -0.6D+00 ) )
+
+  else
+
+    v = t / t_ref
+    w = abs ( 1.0D+00 - v )
+    b = 0.0D+00
+    do i = 1, 8
+      z = i
+      b = b + a(i) * w**( ( z + 1.0D+00 ) / 2.0D+00 )
+    end do
+
+    q = b / v
+    p = 22.093D+00 * exp ( q )
+
+  end if
+
+  return
+end subroutine psat_H2O
+
+
+subroutine tdpsdt ( t, dp )
+!
+!*******************************************************************************
+!
+!! TDPSDT computes the quantity T * dP(Sat)/dT.
+!
+!
+!  Discussion:
+!
+!    Here T is the temperature and P(Sat) is the vapor pressure.  
+!    It is used by TSAT_EST and TSAT.
+!
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!    C A Meyer, R B McClintock, G J Silvestri, R C Spencer,
+!    ASME Steam Tables: Thermodynamic and Transport Properties of Steam,
+!    American Society of Mechanical Engineers, 1967.
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Output, double precision DP, the value T*(dP(Sat)/dT), 
+!    in MegaPascals.
+!
+  implicit none
+!
+  double precision, parameter, dimension ( 8 ) :: a = (/ &
+      -7.8889166D+00,   2.5514255D+00,   -6.716169D+00, 33.239495D+00, &
+    -105.38479D+00,   174.35319D+00,   -148.39348D+00,  48.631602D+00 /)
+  double precision b
+  double precision c
+  double precision dp
+  integer i
+  double precision q
+  double precision t
+  double precision, parameter :: t_ref = 647.25D+00
+  double precision v
+  double precision w
+  double precision y
+  double precision z
+!
+!  Refuse to handle zero or negative temperatures.
+!
+  if ( t <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'TDPSDT - Fatal error!'
+    write ( *, '(a)' ) '  The input temperature T must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was T = ', t
+    stop
+  end if
+
+  v = t / t_ref
+  w = 1.0D+00 - v
+  b = 0.0D+00
+  c = 0.0D+00
+  do i = 1, 8
+    z = dble ( i + 1 ) / 2.0D+00
+    y = a(i) * w**z
+    c = c + ( y / w ) * ( 0.5D+00 - 0.5D+00 * dble ( i ) - 1.0D+00 / v )
+    b = b + y
+  end do
+
+  q = b / v
+  dp = 22.093D+00 * exp ( q ) * c
+
+  return
+end subroutine tdpsdt
+
+
+
+subroutine therm ( t, rho, a, cjth, cjtt, cp, cv, dpdr, dpdt, g, h, p, s, u )
+!
+!*******************************************************************************
+!
+!! THERM calculates thermodynamic functions given temperature and density.
+!
+!
+!  Discussion:
+!
+!    Thermodynamic values were calculated from an analytic equation
+!    that approximates the Helmholtz function (specific Helmholtz
+!    energy) for ordinary water and steam, of the form A=A(rho,T)
+!    where A is the Helmholtz function, rho the density, and T
+!    the absolute (thermodynamic) temperature.  Any thermodynamic
+!    value for any state, liquid, vapor or metastable, may be
+!    calculated by differentiation of this equation in accord with
+!    the first and second laws of thermodynamics.
+! 
+!    The International Association for the Properties of Steam
+!    has provisionally accepted this formulation for the range
+!    273.15 <= T <= 1273.15 degrees Kelvin, where, for 423.15 <= T,
+!    the maximum pressure is Pmax = 1500 MPa = 15000 bar, and for
+!    273.15 <= T < 423.15, the maximum pressure is
+!    Pmax = 100 * (5 + (T-273.15)/15) MPa.
+! 
+!    Close to the critical point, a small region is excluded:
+!    Abs(T-Tk) < 1, abs((rho-rhok)/rhok) < 0.3.
+! 
+!    The equation has a wider useful range, namely, fluid states
+!    of pure, undissociated water and steam defined by
+!    260 <= T <= 2500 K and 0 <= P <= 3000 MPa.
+! 
+!    Thermodynamic property values for specific volume, density,
+!    specific internal energy, specific enthalpy, and specific
+!    entropy of water and steam were tabulated over the range
+!    0 <= t <= 2000 C, 0 <= P <= 3000 MPa.  The reference
+!    state is the liquid at the triple point, for which the
+!    internal energy and entropy have been assigned the value zero.
+!     
+!    Thermodynamic quantities are determined from the Helmholtz function
+!    A(rho,T), which is computed as the sum of three terms:
+!
+!      A(rho,T) = A(base)(rho,T) + A(residual)(rho,T) + A(ideal)(T)
+!                                                       (Equation 1)
+!
+!    Because A(rho,T) is everywhere single valued and analytic,
+!    we can derive closed form relations for all other properties.
+!    In the following, unless otherwise indicated, the independent
+!    variables are temperature T and density RHO, and differentiation
+!    with respect to one variable is to imply that the other is fixed.
+! 
+!    Pressure:                  P       = RHO**2 * dA/dRHO
+!    Density derivative:        dP/dRHO = 2*P/RHO + RHO**2 * d2A/dRHO2
+!    Temperature derivative:    dP/dT   = RHO**2 * d2A/(dRHO dT)
+!    Specific entropy:          S       = - dA/dT
+!    Specific internal energy:  U       = A + T*S
+!    Specific enthalpy:         H       = U + P/RHO
+!    Specific heat capacity
+!      at constant volume:      Cv      = - T * d2A/dT2
+!    Specific Gibbs function:   G       = A + P/RHO
+!    Specific heat capacity
+!      at constant pressure:    Cp      = Cv + (T*(dP/dT)**2)/(RHO**2*dP/dRHO)
+!    Speed of sound:            Omega   = Sqrt ((Cp/Cv) * dP/dRHO)
+!    Second virial coefficient: B       = 1/(2*R*T) * (d2P/dRHO2) (at RHO=0)
+!    Isothermal Joule-Thomson
+!      coefficient:             DeltaT  = (dH/dP) (fixed T) =
+!                                         (1/RHO)-(T*dP/dT)/(RHO**2*dP/dRHO)
+!    Joule-Thomson coefficient: Mu      = (dT/dP) (fixed H) = DeltaT/Cp
+!    Isentropic temperature-
+!      pressure coefficient:    BetaS   = (dT/dP) (fixed S) =
+!                                         (DeltaT - 1/RHO)/Cp
+!   
+!  Modified:
+!
+!    19 November 1998
+!
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!    C A Meyer, R B McClintock, G J Silvestri, R C Spencer,
+!    ASME Steam Tables: Thermodynamic and Transport Properties of Steam,
+!    American Society of Mechanical Engineers, 1967.
+!
+!  Parameters:
+!
+!    Input, double precision T, the temperature, in degrees Kelvin.
+!
+!    Input, double precision RHO, the fluid density, in G/CM3.
+!
+!    Output, double precision A, the Helmholtz function, in KJ/kg.
+!
+!    Output, double precision CJTH, the Joule-Thomson coefficient,
+!    in K/MegaPascals.
+!
+!    Output, double precision CJTT, the isothermal Joule-Thomson coefficient,
+!    in CM3/G.
+!
+!    Output, double precision CP, the isobaric (constant pressure) heat
+!    capacity, in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision CV, the isochoric (constant volume) heat capacity,
+!    in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision DPDR, the partial derivative 
+!    dP(T,RHO)/dRHO, with T held fixed, in MegaPascals*CM3/G.
+!
+!    Output, double precision DPDT, the partial derivative 
+!    dP(T,RHO)/dT, with RHO held fixed, in MegaPascals/degrees Kelvin.
+!
+!    Output, double precision G, the Gibbs free energy, in KJ/kg.
+!
+!    Output, double precision H, the enthalpy, in KJ/kg.
+!
+!    Output, double precision P, the pressure, in MegaPascals.
+!
+!    Output, double precision S, the entropy, in KJ/(kg degrees Kelvin).
+!
+!    Output, double precision U, the internal energy, in KJ/kg.
+!
+  implicit none
+!
+  double precision a
+  double precision ab
+  double precision ai
+  double precision ar
+  double precision cjth
+  double precision cjtt
+  double precision cp
+  double precision cpi
+  double precision cv
+  double precision cvb
+  double precision cvi
+  double precision cvr
+  logical, parameter :: debug = .false.
+!  logical, parameter :: debug = .true.
+  double precision dpdr
+  double precision dpdrb
+  double precision dpdrr
+  double precision dpdt
+  double precision dpdtb
+  double precision dpdtr
+  double precision g
+  double precision gb
+  double precision gi
+  double precision gr
+  double precision h
+  double precision hb
+  double precision hi
+  double precision hr
+  double precision p
+  double precision pb
+  double precision pr
+  double precision rho
+  double precision s
+  double precision sb
+  double precision si
+  double precision sr
+  double precision t
+  double precision u
+  double precision ub
+  double precision ui
+  double precision ur
+!
+!  Refuse to handle zero or negative temperatures.
+!
+  if ( t <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'THERM - Fatal error!'
+    write ( *, '(a)' ) '  The input temperature T must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was T = ', t
+    stop
+  end if
+!
+!  Refuse to handle zero or negative density.
+!
+  if ( rho <= 0.0D+00 ) then
+    write ( *, '(a)' ) ' '
+    write ( *, '(a)' ) 'THERM - Fatal error!'
+    write ( *, '(a)' ) '  The input density RHO must be positive.'
+    write ( *, '(a,g14.6)' ) '  Input value was RHO = ', rho
+    stop
+  end if
+
+  call ideal ( t, ai, cpi, cvi, gi, hi, si, ui )
+
+  call resid ( t, rho, ar, cvr, dpdrr, dpdtr, gr, hr, pr, sr, ur )
+
+  call base ( t, rho, ab, cvb, dpdrb, dpdtb, gb, hb, pb, sb, ub )
+
+  a =       ab +    ar +  ai
+  cv =     cvb +   cvr + cvi
+
+  if ( debug ) then
+    write ( *, * ) ' '
+    write ( *, * ) 'THERM:'
+    write ( *, * ) '  CVB = ', cvb
+    write ( *, * ) '  CVR = ', cvr
+    write ( *, * ) '  CVI = ', cvi
+    write ( *, * ) '  CV  = ', cv
+  end if
+
+
+  dpdr = dpdrb + dpdrr
+  dpdt = dpdtb + dpdtr
+  p =       pb +    pr
+  s =       sb +    sr +  si
+  u =       ub +    ur +  ui
+
+  if ( debug ) then
+    write ( *, * ) ' '
+    write ( *, * ) 'THERM:'
+    write ( *, * ) '  UB = ', ub
+    write ( *, * ) '  UR = ', ur
+    write ( *, * ) '  UI = ', ui
+  end if
+
+  g = a + p / rho
+  h = u + p / rho
+  cp = cv + t * dpdt**2 / ( dpdr * rho**2 )
+  cjtt = 1.0D+00 / rho - t * dpdt / ( dpdr * rho**2 )
+  cjth = - cjtt / cp
+
+  return
+end subroutine therm
+
+function gascon ( )
+!
+!*******************************************************************************
+!
+!! GASCON returns the value of the specific gas constant.
+!
+!
+!  Note:
+!
+!    The specific gas constant R is related to the universal gas
+!    constant R-bar = 8.31441 J/(mol degrees Kelvin) by the molar mass 
+!    M = 18.0152 g/mol:
+!
+!      R = R-bar / M.
+!
+!  Reference:
+!
+!    Lester Haar, John Gallagher and George Kell,
+!    NBS/NRC Steam Tables:
+!    Thermodynamic and Transport Properties and Computer Programs
+!      for Vapor and Liquid States of Water in SI Units,
+!    Hemisphere Publishing Corporation, Washington, 1984,
+!    TJ270.H3
+!
+!    C A Meyer, R B McClintock, G J Silvestri, R C Spencer,
+!    ASME Steam Tables: Thermodynamic and Transport Properties of Steam,
+!    American Society of Mechanical Engineers, 1967.
+!
+!  Parameters:
+!
+!    Output, double precision GASCON, the value of the specific gas 
+!    constant, in J/(g degrees Kelvin).
+!
+  implicit none
+!
+  double precision gascon
+!
+  gascon = 0.461522D+00
+ 
+  return
+end function gascon
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/rcm1d.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/rcm1d.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/rcm1d.F	(revision 1644)
@@ -0,0 +1,996 @@
+      program rcm1d
+
+! to use  'getin'
+      use ioipsl_getincom, only: getin
+      use dimphy, only : init_dimphy
+      use mod_grid_phy_lmdz, only : regular_lonlat
+      use infotrac, only: nqtot, tname
+      use surfdat_h, only: albedodat, phisfi, dryness, watercaptag,
+     &                     zmea, zstd, zsig, zgam, zthe,
+     &                     emissiv, emisice, iceradius,
+     &                     dtemisice
+      use comdiurn_h, only: sinlat, coslat, sinlon, coslon
+      use comsoil_h, only: nsoilmx, layer, mlayer, inertiedat, volcapa
+      use phyredem, only: physdem0,physdem1
+      use geometry_mod, only: init_geometry
+      use slab_ice_h, only: noceanmx
+      use planete_mod, only: apoastr,periastr,year_day,peri_day,
+     &         obliquit,nres,z0,lmixmin,emin_turb,coefvis,coefir,
+     &         timeperi,e_elips,p_elips
+      use comcstfi_mod, only: pi, cpp, rad, g, r,
+     &                        mugaz, rcp, omeg
+      use time_phylmdz_mod, only: daysec, dtphys, day_step, ecritphy,
+     &                            nday, iphysiq
+      use callkeys_mod, only: tracer,check_cpp_match,rings_shadow,
+     &	                      specOLR,water,pceil,ok_slab_ocean
+      USE comvert_mod, ONLY: ap,bp,aps,bps,pa,preff, sig,
+     &                       presnivs,pseudoalt,scaleheight
+      USE vertical_layers_mod, ONLY: init_vertical_layers
+      USE logic_mod, ONLY: hybrid,autozlevs
+      use regular_lonlat_mod, only: init_regular_lonlat
+      use planete_mod, only: ini_planete_mod
+      use physics_distribution_mod, only: init_physics_distribution
+      use regular_lonlat_mod, only: init_regular_lonlat
+      use mod_interface_dyn_phys, only: init_interface_dyn_phys
+      use inifis_mod, only: inifis
+      use physiq_mod, only: physiq
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Run the physics package of the universal model in a 1D column.
+!     
+!     It can be compiled with a command like (e.g. for 25 layers):
+!                                  "makegcm -p std -d 25 rcm1d"
+!     It requires the files "callphys.def", "z2sig.def",
+!     "traceur.def", and "run.def" with a line "INCLUDEDEF=callphys.def"
+!
+!     Authors
+!     -------
+!     Frederic Hourdin
+!     R. Fournier
+!     F. Forget
+!     F. Montmessin (water ice added)
+!     R. Wordsworth
+!     B. Charnay
+!     A. Spiga
+!     J. Leconte (2012)
+!
+!==================================================================
+
+#include "dimensions.h"
+#include "paramet.h"
+!include "dimphys.h"
+#include "netcdf.inc"
+#include "comgeom.h"
+
+c --------------------------------------------------------------
+c  Declarations
+c --------------------------------------------------------------
+c
+      INTEGER unitstart      ! unite d'ecriture de "startfi"
+      INTEGER nlayer,nlevel,nsoil,ndt
+      INTEGER ilayer,ilevel,isoil,idt,iq
+      LOGICAl firstcall,lastcall
+c
+      INTEGER day0          ! date initial (sol ; =0 a Ls=0)
+      REAL day              ! date durant le run
+      REAL time             ! time (0<time<1 ; time=0.5 a midi)
+      REAL play(llm)        ! Pressure at the middle of the layers (Pa)
+      REAL plev(llm+1)      ! intermediate pressure levels (pa)
+      REAL psurf,tsurf(1)      
+      REAL u(llm),v(llm)    ! zonal, meridional wind
+      REAL gru,grv          ! prescribed "geostrophic" background wind
+      REAL temp(llm)        ! temperature at the middle of the layers
+      REAL,ALLOCATABLE :: q(:,:)      ! tracer mixing ratio (e.g. kg/kg)
+      REAL,ALLOCATABLE :: qsurf(:)    ! tracer surface budget (e.g. kg.m-2)
+      REAL,ALLOCATABLE :: tsoil(:)    ! subsurface soil temperature (K)
+!      REAL co2ice               ! co2ice layer (kg.m-2) !not used anymore
+      integer :: i_co2_ice=0     ! tracer index of co2 ice
+      integer :: i_h2o_ice=0     ! tracer index of h2o ice
+      integer :: i_h2o_vap=0     ! tracer index of h2o vapor
+      REAL emis(1)               ! surface layer
+      REAL q2(llm+1)             ! Turbulent Kinetic Energy
+      REAL zlay(llm)             ! altitude estimee dans les couches (km)
+
+c    Physical and dynamical tandencies (e.g.  m.s-2, K/s, Pa/s)
+      REAL du(llm),dv(llm),dtemp(llm)
+      REAL dudyn(llm),dvdyn(llm),dtempdyn(llm)
+      REAL dpsurf(1)    
+      REAL,ALLOCATABLE :: dq(:,:)
+      REAL,ALLOCATABLE :: dqdyn(:,:)
+
+c   Various intermediate variables
+!      INTEGER thermo
+      REAL zls
+      REAL phi(llm),h(llm),s(llm)
+      REAL pks, ptif, w(llm)
+      INTEGER ierr, aslun
+      REAL tmp1(0:llm),tmp2(0:llm)
+      integer :: nq !=1 ! number of tracers
+ 
+      character*2 str2
+      character (len=7) :: str7
+      character(len=44) :: txt
+
+      logical oldcompare, earthhack,saveprofile
+
+!     added by RW for zlay computation
+      real Hscale, Hmax, rho, dz
+
+!     added by RW for autozlevs computation
+      real nu, xx, pMIN, zlev, Htop
+      real logplevs(llm)
+
+!     added by BC
+      REAL cloudfrac(1,llm)
+      REAL hice(1),totcloudfrac(1)
+
+!     added by BC for ocean
+      real rnat(1)
+      REAL tslab(1,noceanmx),tsea_ice(1),sea_ice(1)
+      real pctsrf_sic(1)
+
+
+
+!     added by AS to avoid the use of adv trac common
+      character*20,allocatable :: nametrac(:)   ! name of the tracer (no need for adv trac common)
+
+      real :: latitude(1), longitude(1), cell_area(1)
+
+c=======================================================================
+c INITIALISATION
+c=======================================================================
+! initialize "serial/parallel" related stuff
+!      CALL init_phys_lmdz(iim,jjm+1,llm,1,(/(jjm-1)*iim+2/))
+!      CALL init_phys_lmdz(1,1,llm,1,(/1/))
+!      call initcomgeomphy
+
+      !! those are defined in surfdat_h.F90
+      IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(1))
+      IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(1))
+      IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(1))
+      IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(1))
+      IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(1))
+      IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(1))
+      IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(1))
+      IF (.not. ALLOCATED(dryness)) ALLOCATE(dryness(1))
+      IF (.not. ALLOCATED(watercaptag)) ALLOCATE(watercaptag(1))
+      !! those are defined in comdiurn_h.F90
+      IF (.not.ALLOCATED(sinlat)) ALLOCATE(sinlat(1))
+      IF (.not.ALLOCATED(coslat)) ALLOCATE(coslat(1))
+      IF (.not.ALLOCATED(sinlon)) ALLOCATE(sinlon(1))
+      IF (.not.ALLOCATED(coslon)) ALLOCATE(coslon(1))
+
+      saveprofile=.false.
+      saveprofile=.true.
+
+c ----------------------------------------
+c  Default values  (corresponding to Mars)
+c ----------------------------------------
+
+      pi=2.E+0*asin(1.E+0)
+
+c     Parametres Couche limite et Turbulence 
+c     --------------------------------------
+      z0 =  1.e-2                ! surface roughness (m) ~0.01 
+      emin_turb = 1.e-6          ! energie minimale ~1.e-8
+      lmixmin = 30               ! longueur de melange ~100
+ 
+c     propriete optiques des calottes et emissivite du sol
+c     ----------------------------------------------------
+      emissiv= 0.95              ! Emissivite du sol martien ~.95
+      emisice(1)=0.95            ! Emissivite calotte nord
+      emisice(2)=0.95            ! Emissivite calotte sud  
+
+      iceradius(1) = 100.e-6     ! mean scat radius of CO2 snow (north)
+      iceradius(2) = 100.e-6     ! mean scat radius of CO2 snow (south)
+      dtemisice(1) = 2.          ! time scale for snow metamorphism (north)
+      dtemisice(2) = 2.          ! time scale for snow metamorphism (south
+      hybrid=.false.
+
+c ------------------------------------------------------
+c  Load parameters from "run.def" and "gases.def" 
+c ------------------------------------------------------
+
+! check if 'rcm1d.def' file is around 
+      open(90,file='rcm1d.def',status='old',form='formatted',
+     &     iostat=ierr)
+      if (ierr.ne.0) then
+        write(*,*) 'Cannot find required file "rcm1d.def"'
+        write(*,*) 'which should contain some input parameters'
+        write(*,*) ' ... might as well stop here ...'
+        stop
+      else
+        close(90)
+      endif
+
+! now, run.def is needed anyway. so we create a dummy temporary one
+! for ioipsl to work. if a run.def is already here, stop the
+! program and ask the user to do a bit of cleaning
+      open(90,file='run.def',status='old',form='formatted',
+     &     iostat=ierr)
+      if (ierr.eq.0) then
+        close(90)
+        write(*,*) 'There is already a run.def file.'
+        write(*,*) 'This is not compatible with 1D runs.'
+        write(*,*) 'Please remove the file and restart the run.'
+        write(*,*) 'Runtime parameters are supposed to be in rcm1d.def'
+        stop
+      else
+        call system('touch run.def')
+        call system("echo 'INCLUDEDEF=callphys.def' >> run.def")
+        call system("echo 'INCLUDEDEF=rcm1d.def' >> run.def")
+      endif
+
+! check if we are going to run with or without tracers
+      write(*,*) "Run with or without tracer transport ?"
+      tracer=.false. ! default value
+      call getin("tracer",tracer)
+      write(*,*) " tracer = ",tracer
+
+! OK. now that run.def has been read once -- any variable is in memory.
+! so we can dump the dummy run.def
+!      call system("rm -rf run.def") ! Ehouarn: delay this to after inifis
+
+! while we're at it, check if there is a 'traceur.def' file
+! and preocess it, if necessary. Otherwise initialize tracer names
+      if (tracer) then
+      ! load tracer names from file 'traceur.def'
+        open(90,file='traceur.def',status='old',form='formatted',
+     &       iostat=ierr)
+        if (ierr.eq.0) then
+          write(*,*) "rcm1d: Reading file traceur.def"
+          ! 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(*,*) "rcm1d: error reading number of tracers"
+            write(*,*) "   (first line of traceur.def) "
+            stop
+          endif
+          if (nq>0) then
+            allocate(tname(nq))
+            allocate(q(llm,nq))
+            allocate(qsurf(nq))
+            allocate(dq(llm,nq))
+            allocate(dqdyn(llm,nq))
+          else
+            write(*,*) "rcm1d: Error. You set tracer=.true."
+            write(*,*) "       but # of tracers in traceur.def is ",nq
+            stop
+          endif
+        
+          do iq=1,nq
+          ! minimal version, just read in the tracer names, 1 per line
+            read(90,*,iostat=ierr) tname(iq)
+            if (ierr.ne.0) then
+              write(*,*) 'rcm1d: error reading tracer names...'
+              stop
+            endif
+          enddo !of do iq=1,nq
+! check for co2_ice / h2o_ice tracers:
+         i_co2_ice=0
+         i_h2o_ice=0
+         i_h2o_vap=0
+         do iq=1,nq
+           if (tname(iq)=="co2_ice") then
+             i_co2_ice=iq
+           elseif (tname(iq)=="h2o_ice") then
+             i_h2o_ice=iq
+           elseif (tname(iq)=="h2o_vap") then
+             i_h2o_vap=iq
+           endif
+         enddo
+        else
+          write(*,*) 'Cannot find required file "traceur.def"'
+          write(*,*) ' If you want to run with tracers, I need it'
+          write(*,*) ' ... might as well stop here ...'
+          stop
+        endif
+        close(90)
+
+      else ! of if (tracer)
+        nqtot=0
+        nq=0
+        ! still, make allocations for 1 dummy tracer
+        allocate(tname(1)) 
+        allocate(qsurf(1))
+        allocate(q(llm,1))
+        allocate(dq(llm,1))
+      
+       ! Check that tracer boolean is compliant with number of tracers
+       ! -- otherwise there is an error (and more generally we have to be consistent)
+       if (nq .ge. 1) then
+          write(*,*) "------------------------------"
+          write(*,*) "rcm1d: You set tracer=.false."
+          write(*,*) " But set number of tracers to ",nq
+          write(*,*) " > If you want tracers, set tracer=.true."
+          write(*,*) "------------------------------"
+          stop
+       endif
+      endif ! of if (tracer)
+
+!!! We have to check that check_cpp_match is F for 1D computations
+!!! We think this check is better than make a particular case for 1D in inifis or calc_cpp_mugaz
+      check_cpp_match = .false.
+      call getin("check_cpp_match",check_cpp_match)
+      if (check_cpp_match) then
+          print*,"In 1D modeling, check_cpp_match is supposed to be F"
+          print*,"Please correct callphys.def"
+          stop
+      endif
+
+!!! GEOGRAPHICAL INITIALIZATIONS
+     !!! AREA. useless in 1D
+      cell_area(1)=1.E+0 !JL+EM to have access to the area in the diagfi.nc files.
+     !!! GEOPOTENTIAL. useless in 1D because control by surface pressure
+      phisfi(1)=0.E+0
+     !!! LATITUDE. can be set. 
+      latitude=0 ! default value for latitude
+      PRINT *,'latitude (in degrees) ?'
+      call getin("latitude",latitude)
+      write(*,*) " latitude = ",latitude
+      latitude=latitude*pi/180.E+0
+     !!! LONGITUDE. useless in 1D.
+      longitude=0.E+0
+      longitude=longitude*pi/180.E+0
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!! PLANETARY CONSTANTS !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+      g = -99999.
+      PRINT *,'GRAVITY in m s-2 ?'
+      call getin("g",g)
+      IF (g.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED g IN RCM1D.DEF."
+          STOP
+      ELSE
+          PRINT *,"--> g = ",g
+      ENDIF
+
+      rad = -99999.
+      PRINT *,'PLANETARY RADIUS in m ?'
+      call getin("rad",rad)
+      ! Planetary  radius is needed to compute shadow of the rings
+      IF (rad.eq.-99999. .and. rings_shadow .eqv. .true.) THEN
+          PRINT *,"STOP. I NEED rad IN RCM1D.DEF."
+          STOP
+      ELSE
+          PRINT *,"--> rad = ",rad
+      ENDIF
+
+      daysec = -99999.
+      PRINT *,'LENGTH OF A DAY in s ?'
+      call getin("daysec",daysec)
+      IF (daysec.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED daysec IN RCM1D.DEF."
+          STOP
+      ELSE
+          PRINT *,"--> daysec = ",daysec
+      ENDIF
+      omeg=4.*asin(1.)/(daysec)
+      PRINT *,"OK. FROM THIS I WORKED OUT:"
+      PRINT *,"--> omeg = ",omeg
+
+      year_day = -99999.
+      PRINT *,'LENGTH OF A YEAR in days ?'
+      call getin("year_day",year_day)
+      IF (year_day.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED year_day IN RCM1D.DEF."
+          STOP
+      ELSE 
+          PRINT *,"--> year_day = ",year_day
+      ENDIF
+
+      periastr = -99999.
+      PRINT *,'MIN DIST STAR-PLANET in AU ?'
+      call getin("periastr",periastr)
+      IF (periastr.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED periastr IN RCM1D.DEF."
+          STOP
+      ELSE
+          PRINT *,"--> periastr = ",periastr
+      ENDIF
+
+      apoastr = -99999.
+      PRINT *,'MAX DIST STAR-PLANET in AU ?'
+      call getin("apoastr",apoastr)
+      IF (apoastr.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED apoastr IN RCM1D.DEF."
+          STOP
+      ELSE
+          PRINT *,"--> apoastr = ",apoastr
+      ENDIF
+
+      peri_day = -99999.
+      PRINT *,'DATE OF PERIASTRON in days ?'
+      call getin("peri_day",peri_day)
+      IF (peri_day.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED peri_day IN RCM1D.DEF."
+          STOP
+      ELSE IF (peri_day.gt.year_day) THEN
+          PRINT *,"STOP. peri_day.gt.year_day"
+          STOP
+      ELSE  
+          PRINT *,"--> peri_day = ", peri_day
+      ENDIF 
+
+      obliquit = -99999. 
+      PRINT *,'OBLIQUITY in deg ?'
+      call getin("obliquit",obliquit)
+      IF (obliquit.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED obliquit IN RCM1D.DEF."
+          STOP
+      ELSE
+          PRINT *,"--> obliquit = ",obliquit
+      ENDIF 
+
+      psurf = -99999.
+      PRINT *,'SURFACE PRESSURE in Pa ?'
+      call getin("psurf",psurf)
+      IF (psurf.eq.-99999.) THEN
+          PRINT *,"STOP. I NEED psurf IN RCM1D.DEF."
+          STOP
+      ELSE
+          PRINT *,"--> psurf = ",psurf
+      ENDIF
+      !! we need reference pressures
+      pa=psurf/30.
+      preff=psurf ! these values are not needed in 1D  (are you sure JL12)
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!! END PLANETARY CONSTANTS !!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+c  Date et heure locale du debut du run
+c  ------------------------------------
+c    Date (en sols depuis le solstice de printemps) du debut du run
+      day0 = 0 ! default value for day0
+      write(*,*) 'Initial date (in martian sols ; =0 at Ls=0)?'
+      call getin("day0",day0)
+      day=float(day0)
+      write(*,*) " day0 = ",day0
+c  Heure de demarrage
+      time=0 ! default value for time
+      write(*,*)'Initial local time (in hours, between 0 and 24)?'
+      call getin("time",time)
+      write(*,*)" time = ",time
+      time=time/24.E+0 ! convert time (hours) to fraction of sol
+
+
+c  Discretisation (Definition de la grille et des pas de temps)
+c  --------------
+c
+      nlayer=llm
+      nlevel=nlayer+1
+
+      day_step=48 ! default value for day_step
+      PRINT *,'Number of time steps per sol ?'
+      call getin("day_step",day_step)
+      write(*,*) " day_step = ",day_step
+
+      iphysiq=1 ! in 1D model physics are called evry time step
+      ecritphy=day_step ! default value for ecritphy
+      PRINT *,'Nunber of steps between writediagfi ?'
+      call getin("ecritphy",ecritphy)
+      write(*,*) " ecritphy = ",ecritphy
+
+      ndt=10 ! default value for ndt
+      PRINT *,'Number of sols to run ?'
+      call getin("ndt",ndt)
+      write(*,*) " ndt = ",ndt
+      nday=ndt
+
+      ndt=ndt*day_step     
+      dtphys=daysec/day_step  
+      write(*,*)"-------------------------------------"
+      write(*,*)"-------------------------------------"
+      write(*,*)"--> Physical timestep is ",dtphys
+      write(*,*)"-------------------------------------"
+      write(*,*)"-------------------------------------"
+
+      ! initializations, as with iniphysiq.F90 for the 3D GCM
+      call init_physics_distribution(regular_lonlat,4,
+     &                               1,1,1,nlayer,1)
+      call init_interface_dyn_phys
+      CALL init_regular_lonlat(1,1,longitude,latitude,
+     &                   (/0.,0./),(/0.,0./))
+      call init_geometry(1,longitude,latitude,
+     &                   (/0.,0.,0.,0./),(/0.,0.,0.,0./),
+     &                   cell_area)
+! Ehouarn: init_vertial_layers called later (because disvert not called yet)
+!      call init_vertical_layers(nlayer,preff,scaleheight,
+!     &                      ap,bp,aps,bps,presnivs,pseudoalt)
+      call init_dimphy(1,nlayer) ! Initialize dimphy module
+      call ini_planete_mod(nlayer,preff,ap,bp)
+
+!!! CALL INIFIS
+!!! - read callphys.def
+!!! - calculate sine and cosine of longitude and latitude
+!!! - calculate mugaz and cp 
+!!! NB: some operations are being done dummily in inifis in 1D
+!!! - physical constants: nevermind, things are done allright below
+!!! - physical frequency: nevermind, in inifis this is a simple print
+      cpp=1.d-7 !JL because we divide by cpp in inifis, there may be a more elegant solution
+      CALL inifis(1,llm,nq,day0,daysec,nday,dtphys,
+     .            latitude,longitude,cell_area,rad,g,r,cpp)
+
+      nsoil=nsoilmx
+      allocate(tsoil(nsoilmx))
+      !! those are defined in comsoil_h.F90
+      IF (.not.ALLOCATED(layer)) ALLOCATE(layer(nsoilmx))
+      IF (.not.ALLOCATED(mlayer)) ALLOCATE(mlayer(0:nsoilmx-1))
+      IF (.not.ALLOCATED(inertiedat)) ALLOCATE(inertiedat(1,nsoilmx))
+
+! At this point, both getin() and getin_p() functions have been used,
+! and the run.def file can be removed.
+      call system("rm -rf run.def")
+
+!!! We check everything is OK.
+      PRINT *,"CHECK"
+      PRINT *,"--> mugaz = ",mugaz
+      PRINT *,"--> cpp = ",cpp
+      r = 8.314511E+0 * 1000.E+0 / mugaz
+      rcp = r / cpp
+
+c output spectrum?
+      write(*,*)"Output spectral OLR?"
+      specOLR=.false.
+      call getin("specOLR",specOLR)
+      write(*,*)" specOLR = ",specOLR
+
+c
+c  pour le schema d'ondes de gravite
+c  ---------------------------------
+      zmea(1)=0.E+0
+      zstd(1)=0.E+0
+      zsig(1)=0.E+0
+      zgam(1)=0.E+0
+      zthe(1)=0.E+0
+
+c    Initialisation des traceurs
+c    ---------------------------
+
+      DO iq=1,nq
+        DO ilayer=1,nlayer
+           q(ilayer,iq) = 0.
+        ENDDO
+      ENDDO
+     
+      DO iq=1,nq
+        qsurf(iq) = 0.
+      ENDDO
+      
+      if (tracer) then ! Initialize tracers here. 
+             
+         write(*,*) "rcm1d : initializing tracers profiles"
+
+         do iq=1,nq
+         
+            txt=""
+            write(txt,"(a)") tname(iq)
+            write(*,*)"  tracer:",trim(txt)
+              
+            ! CO2
+            if (txt.eq."co2_ice") then
+               q(:,iq)=0.   ! kg/kg of atmosphere
+               qsurf(iq)=0. ! kg/m2 at the surface               
+               ! Look for a "profile_co2_ice" input file
+               open(91,file='profile_co2_ice',status='old',
+     &         form='formatted',iostat=ierr)
+               if (ierr.eq.0) then
+                  read(91,*) qsurf(iq)
+                  do ilayer=1,nlayer
+                     read(91,*) q(ilayer,iq)
+                  enddo
+               else
+                  write(*,*) "No profile_co2_ice file!"
+               endif
+               close(91)
+            endif ! of if (txt.eq."co2")
+          
+            ! WATER VAPOUR
+            if (txt.eq."h2o_vap") then
+               q(:,iq)=0.   ! kg/kg of atmosphere
+               qsurf(iq)=0. ! kg/m2 at the surface
+               ! Look for a "profile_h2o_vap" input file   
+               open(91,file='profile_h2o_vap',status='old',
+     &         form='formatted',iostat=ierr)
+               if (ierr.eq.0) then
+                  read(91,*) qsurf(iq)
+                  do ilayer=1,nlayer
+                     read(91,*) q(ilayer,iq)
+                  enddo
+               else
+                  write(*,*) "No profile_h2o_vap file!"
+               endif
+               close(91)
+            endif ! of if (txt.eq."h2o_vap")
+            
+            ! WATER ICE
+            if (txt.eq."h2o_ice") then
+               q(:,iq)=0.   ! kg/kg of atmosphere
+               qsurf(iq)=0. ! kg/m2 at the surface
+               ! Look for a "profile_h2o_ice" input file
+               open(91,file='profile_h2o_ice',status='old',
+     &         form='formatted',iostat=ierr)
+               if (ierr.eq.0) then
+                  read(91,*) qsurf(iq)
+                  do ilayer=1,nlayer
+                     read(91,*) q(ilayer,iq)
+                  enddo
+               else
+                  write(*,*) "No profile_h2o_ice file!"
+               endif
+               close(91)
+            endif ! of if (txt.eq."h2o_ice")
+
+         enddo ! of do iq=1,nq
+         
+      endif ! of tracer
+
+c   Initialisation pour prendre en compte les vents en 1-D
+c   ------------------------------------------------------
+      ptif=2.E+0*omeg*sinlat(1)
+ 
+
+c    vent geostrophique
+      gru=10. ! default value for gru
+      PRINT *,'zonal eastward component of the geostrophic wind (m/s) ?'
+      call getin("u",gru)
+      write(*,*) " u = ",gru
+      grv=0. !default value for grv
+      PRINT *,'meridional northward component of the geostrophic',
+     &' wind (m/s) ?'
+      call getin("v",grv)
+      write(*,*) " v = ",grv
+
+! To be clean, also set vertical winds to zero
+      w(1:nlayer)=0
+
+c     Initialisation des vents  au premier pas de temps
+      DO ilayer=1,nlayer
+         u(ilayer)=gru
+         v(ilayer)=grv
+      ENDDO
+
+c     energie cinetique turbulente
+      DO ilevel=1,nlevel
+         q2(ilevel)=0.E+0
+      ENDDO
+
+c  emissivity / surface co2 ice ( + h2o ice??)
+c  -------------------------------------------
+      emis(1)=emissiv ! default value for emissivity
+      PRINT *,'Emissivity of bare ground ?'
+      call getin("emis",emis(1))
+      write(*,*) " emis = ",emis(1)
+      emissiv=emis(1) ! we do this so that condense_co2 sets things to the right
+                   ! value if there is no snow
+
+      if(i_co2_ice.gt.0)then
+         qsurf(i_co2_ice)=0 ! default value for co2ice
+         print*,'Initial CO2 ice on the surface (kg.m-2)'
+         call getin("co2ice",qsurf(i_co2_ice))
+         write(*,*) " co2ice = ",qsurf(i_co2_ice)
+         IF (qsurf(i_co2_ice).ge.1.E+0) THEN
+            ! if we have some CO2 ice on the surface, change emissivity
+            if (latitude(1).ge.0) then ! northern hemisphere
+              emis(1)=emisice(1)
+            else ! southern hemisphere
+              emis(1)=emisice(2)
+            endif
+         ENDIF
+      endif
+
+c  calcul des pressions et altitudes en utilisant les niveaux sigma
+c  ----------------------------------------------------------------
+
+c    Vertical Coordinates
+c    """"""""""""""""""""
+      hybrid=.true.
+      PRINT *,'Hybrid coordinates ?'
+      call getin("hybrid",hybrid)
+      write(*,*) " hybrid = ", hybrid
+
+
+      autozlevs=.false.
+      PRINT *,'Auto-discretise vertical levels ?'
+      call getin("autozlevs",autozlevs)
+      write(*,*) " autozlevs = ", autozlevs
+
+      pceil = psurf / 1000.0 ! Pascals
+      PRINT *,'Ceiling pressure (Pa) ?'
+      call getin("pceil",pceil)
+      write(*,*) " pceil = ", pceil
+
+! Test of incompatibility:
+! if autozlevs used, cannot have hybrid too
+
+      if (autozlevs.and.hybrid) then
+         print*,'Cannot use autozlevs and hybrid together!'
+         call abort
+      endif
+
+      if(autozlevs)then
+            
+         open(91,file="z2sig.def",form='formatted')
+         read(91,*) Hscale
+         DO ilayer=1,nlayer-2
+            read(91,*) Hmax
+         enddo
+         close(91)
+ 
+            
+         print*,'Hmax = ',Hmax,' km'
+         print*,'Auto-shifting Hscale to:'
+!     Hscale = Hmax / log(psurf/100.0)
+         Hscale = Hmax / log(psurf/pceil)
+         print*,'Hscale = ',Hscale,' km'
+         
+! none of this matters if we dont care about zlay
+         
+      endif
+
+      call disvert
+      ! now that disvert has been called, initialize module vertical_layers_mod
+      call init_vertical_layers(nlayer,preff,scaleheight,
+     &                      ap,bp,aps,bps,presnivs,pseudoalt)
+
+         if(.not.autozlevs)then
+            ! we want only the scale height from z2sig, in order to compute zlay
+            open(91,file="z2sig.def",form='formatted')
+            read(91,*) Hscale
+            close(91)
+         endif
+
+!         if(autozlevs)then
+!            open(94,file="Hscale.temp",form='formatted')
+!            read(94,*) Hscale
+!            close(94)
+!         endif
+
+         DO ilevel=1,nlevel
+            plev(ilevel)=ap(ilevel)+psurf*bp(ilevel)
+         ENDDO
+         
+         DO ilayer=1,nlayer
+            play(ilayer)=aps(ilayer)+psurf*bps(ilayer)
+         ENDDO
+         
+
+
+         DO ilayer=1,nlayer
+!     zlay(ilayer)=-300.E+0 *r*log(play(ilayer)/plev(1))
+!     &   /g
+            zlay(ilayer)=-1000.0*Hscale*log(play(ilayer)/plev(1))
+         ENDDO
+
+!      endif
+
+c  profil de temperature au premier appel
+c  --------------------------------------
+      pks=psurf**rcp
+
+c altitude en km dans profile: on divise zlay par 1000
+      tmp1(0)=0.E+0
+      DO ilayer=1,nlayer
+        tmp1(ilayer)=zlay(ilayer)/1000.E+0
+      ENDDO
+      call profile(nlayer+1,tmp1,tmp2)
+
+      tsurf(1)=tmp2(0)
+      DO ilayer=1,nlayer
+        temp(ilayer)=tmp2(ilayer)
+      ENDDO
+      print*,"check"
+      PRINT*,"INPUT SURFACE TEMPERATURE",tsurf(1)
+      PRINT*,"INPUT TEMPERATURE PROFILE",temp
+
+c  Initialisation albedo / inertie du sol
+c  --------------------------------------
+      albedodat(1)=0.2 ! default value for albedodat
+      PRINT *,'Albedo of bare ground ?'
+      call getin("albedo",albedodat(1))
+      write(*,*) " albedo = ",albedodat(1)
+
+      inertiedat(1,1)=400 ! default value for inertiedat
+      PRINT *,'Soil thermal inertia (SI) ?'
+      call getin("inertia",inertiedat(1,1))
+      write(*,*) " inertia = ",inertiedat(1,1)
+
+! Initialize soil properties and temperature
+! ------------------------------------------
+      volcapa=1.e6 ! volumetric heat capacity
+      DO isoil=1,nsoil
+         inertiedat(1,isoil)=inertiedat(1,1) ! soil thermal inertia
+         tsoil(isoil)=tsurf(1)  ! soil temperature
+      ENDDO
+
+! Initialize depths
+! -----------------
+      do isoil=0,nsoil-1
+        mlayer(isoil)=2.e-4*(2.**(isoil-0.5)) ! mid-layer depth
+      enddo
+      do isoil=1,nsoil
+        layer(isoil)=2.e-4*(2.**(isoil-1)) ! layer depth
+      enddo
+
+
+! Initialize slab ocean
+! -----------------
+      rnat=1. ! default value for rnat
+      if(inertiedat(1,1).GE.10000.)then
+         rnat=0.
+      endif
+      if(ok_slab_ocean)then
+      rnat=0.
+      tslab(1,1)=tsurf(1)
+      tslab(1,2)=tsurf(1)
+      tsea_ice=tsurf
+      pctsrf_sic=0.
+      sea_ice=0.
+      endif
+
+
+
+c  Write a "startfi" file
+c  --------------------
+c  This file will be read during the first call to "physiq".
+c  It is needed to transfert physics variables to "physiq"...
+
+      call physdem0("startfi.nc",longitude,latitude,nsoilmx,1,llm,nq,
+     &              dtphys,real(day0),time,cell_area,
+     &              albedodat,inertiedat,zmea,zstd,zsig,zgam,zthe)
+      call physdem1("startfi.nc",nsoilmx,1,llm,nq,
+     &                dtphys,time,
+     &                tsurf,tsoil,emis,q2,qsurf,
+     &                cloudfrac,totcloudfrac,hice, 
+     &                rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+
+c=======================================================================
+c  BOUCLE TEMPORELLE DU MODELE 1D 
+c=======================================================================
+
+      firstcall=.true.
+      lastcall=.false.
+
+      DO idt=1,ndt
+        IF (idt.eq.ndt) then       !test
+         lastcall=.true.
+         call stellarlong(day*1.0,zls)
+!         write(103,*) 'Ls=',zls*180./pi
+!         write(103,*) 'Lat=', latitude(1)*180./pi
+!         write(103,*) 'RunEnd - Atmos. Temp. File'
+!         write(103,*) 'RunEnd - Atmos. Temp. File'
+!         write(104,*) 'Ls=',zls*180./pi
+!         write(104,*) 'Lat=', latitude(1)
+!         write(104,*) 'RunEnd - Atmos. Temp. File'
+        ENDIF
+
+c    calcul du geopotentiel 
+c     ~~~~~~~~~~~~~~~~~~~~~
+
+
+      DO ilayer=1,nlayer
+
+!              if(autozlevs)then
+!                 s(ilayer)=(play(ilayer)/psurf)**rcp
+!              else
+          s(ilayer)=(aps(ilayer)/psurf+bps(ilayer))**rcp
+!              endif
+              !s(ilayer)=(aps(ilayer)/psurf+bps(ilayer))**rcp
+          h(ilayer)=cpp*temp(ilayer)/(pks*s(ilayer))
+       ENDDO
+
+!      DO ilayer=1,nlayer
+!        s(ilayer)=(aps(ilayer)/psurf+bps(ilayer))**rcp
+!        h(ilayer)=cpp*temp(ilayer)/(pks*s(ilayer))
+!      ENDDO
+      phi(1)=pks*h(1)*(1.E+0-s(1))
+      DO ilayer=2,nlayer
+         phi(ilayer)=phi(ilayer-1)+
+     &               pks*(h(ilayer-1)+h(ilayer))*.5E+0
+     &                  *(s(ilayer-1)-s(ilayer))
+
+      ENDDO
+
+c       appel de la physique
+c       --------------------
+
+
+      CALL physiq (1,llm,nq,
+     .     tname,
+     ,     firstcall,lastcall,
+     ,     day,time,dtphys,
+     ,     plev,play,phi,
+     ,     u, v,temp, q,  
+     ,     w,
+C - sorties
+     s     du, dv, dtemp, dq,dpsurf)
+
+
+c       evolution du vent : modele 1D
+c       -----------------------------
+ 
+c       la physique calcule les derivees temporelles de u et v.
+c       on y rajoute betement un effet Coriolis.
+c
+c       DO ilayer=1,nlayer
+c          du(ilayer)=du(ilayer)+ptif*(v(ilayer)-grv)
+c          dv(ilayer)=dv(ilayer)+ptif*(-u(ilayer)+gru)
+c       ENDDO
+
+c       Pour certain test : pas de coriolis a l'equateur
+c       if(latitude(1).eq.0.) then
+          DO ilayer=1,nlayer
+             du(ilayer)=du(ilayer)+ (gru-u(ilayer))/1.e4
+             dv(ilayer)=dv(ilayer)+ (grv-v(ilayer))/1.e4
+          ENDDO
+c       end if
+c      
+c
+c       Calcul du temps au pas de temps suivant
+c       ---------------------------------------
+        firstcall=.false.
+        time=time+dtphys/daysec
+        IF (time.gt.1.E+0) then
+            time=time-1.E+0
+            day=day+1
+        ENDIF
+
+c       calcul des vitesses et temperature au pas de temps suivant
+c       ----------------------------------------------------------
+
+        DO ilayer=1,nlayer
+           u(ilayer)=u(ilayer)+dtphys*du(ilayer)
+           v(ilayer)=v(ilayer)+dtphys*dv(ilayer)
+           temp(ilayer)=temp(ilayer)+dtphys*dtemp(ilayer)
+        ENDDO
+
+c       calcul des pressions au pas de temps suivant
+c       ----------------------------------------------------------
+
+           psurf=psurf+dtphys*dpsurf(1)   ! evolution de la pression de surface
+           DO ilevel=1,nlevel
+              plev(ilevel)=ap(ilevel)+psurf*bp(ilevel)
+           ENDDO
+           DO ilayer=1,nlayer
+                 play(ilayer)=aps(ilayer)+psurf*bps(ilayer)
+           ENDDO
+
+c       calcul traceur au pas de temps suivant
+c       --------------------------------------
+
+        DO iq = 1, nq
+          DO ilayer=1,nlayer
+             q(ilayer,iq)=q(ilayer,iq)+dtphys*dq(ilayer,iq)
+          ENDDO
+        END DO
+
+c    ========================================================
+c    GESTION DES SORTIE
+c    ========================================================
+      if(saveprofile)then
+         OPEN(12,file='profile.out',form='formatted')
+         write(12,*) tsurf
+         DO ilayer=1,llm
+            write(12,*) temp(ilayer) !, play(ilayer) !AS12 only temp so that iprofile=8 can be used
+         ENDDO
+         CLOSE(12)
+      endif
+
+
+      ENDDO   ! fin de la boucle temporelle
+
+      write(*,*) "rcm1d: Everything is cool."
+
+c    ========================================================
+      end                       !rcm1d
+ 
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/serre_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/serre_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/dyn1d/serre_mod.F90	(revision 1644)
@@ -0,0 +1,1 @@
+link ../../dyn3d/serre_mod.F90
Index: /trunk/LMDZ.TITAN/libf/phytitan/evap.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/evap.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/evap.F	(revision 1644)
@@ -0,0 +1,75 @@
+      subroutine evap(ngrid,nlayer,nq,dtime,pt, pq, pdq, pdt,  
+     $     dqevap,dtevap, qevap, tevap) 
+        
+      use watercommon_h 
+      USE tracer_h
+
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Evaporation of all water in the atmopshere.
+!     
+!     Authors
+!     -------
+!     Adapted from the LMDTERRE code by B. Charnay (2010)
+!     Original author Z. X. Li (1993)
+!     
+!==================================================================
+
+      INTEGER ngrid,nlayer,nq
+
+! Arguments:
+      REAL pt(ngrid,nlayer) 
+      REAL pq(ngrid,nlayer,nq) 
+      REAL pdt(ngrid,nlayer) 
+      REAL pdq(ngrid,nlayer,nq) 
+      REAL dqevap(ngrid,nlayer)
+      REAL dtevap(ngrid,nlayer)
+      REAL qevap(ngrid,nlayer,nq)
+      REAL dtime
+ 
+! Local:
+      REAL tevap(ngrid,nlayer) 
+      REAL zlvdcp
+      REAL zlsdcp
+      REAL zdelta
+      INTEGER l,ig
+
+!
+! Re-evaporer l'eau liquide nuageuse
+!
+
+      DO l=1,nlayer
+        DO ig=1,ngrid
+         qevap(ig,l,igcm_h2o_vap)=pq(ig,l,igcm_h2o_vap)	
+     s          	          +pdq(ig,l,igcm_h2o_vap)*dtime
+         qevap(ig,l,igcm_h2o_ice)=pq(ig,l,igcm_h2o_ice)	
+     s                            +pdq(ig,l,igcm_h2o_ice)*dtime
+         tevap(ig,l)=pt(ig,l)+pdt(ig,l)*dtime
+	ENDDO
+      ENDDO
+
+      DO l = 1, nlayer
+      	DO ig = 1, ngrid
+         zlvdcp=RLVTT/RCPD!/(1.0+RVTMP2*qevap(ig,l,igcm_h2o_vap))
+         zlsdcp=RLSTT/RCPD!/(1.0+RVTMP2*qevap(ig,l,igcm_h2o_vap))
+         ! ignoring qevap term creates huge difference when qevap large!!!
+
+         zdelta = MAX(0.,SIGN(1.,T_h2O_ice_liq-tevap(ig,l))) ! what is this?
+                                                  ! for division between water / liquid
+	 dqevap(ig,l) = MAX(0.0,qevap(ig,l,igcm_h2o_ice))/dtime
+         dtevap(ig,l) = - dqevap(ig,l)*RLVTT/RCPD ! exactly as in largescale.F
+!         dtevap(ig,l) = - dqevap(ig,l)	
+!     s                       * (zlvdcp*(1.-zdelta)+zlsdcp*zdelta)
+         qevap(ig,l,igcm_h2o_vap) = qevap(ig,l,igcm_h2o_vap)	
+     s     	                    +dqevap(ig,l)*dtime
+	 qevap(ig,l,igcm_h2o_ice) = 0.0
+         tevap(ig,l) = tevap(ig,l)+dtevap(ig,l)*dtime
+
+      	ENDDO
+      ENDDO
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/forceWCfn.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/forceWCfn.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/forceWCfn.F	(revision 1644)
@@ -0,0 +1,47 @@
+      subroutine forceWCfn(ngrid,nlayer,nq,pplev,pt,dq,dqs)
+
+      USE tracer_h
+      use comcstfi_mod, only: g
+
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Force tracer conservation in a column for a given pair of 
+!     delta q, delta q_s
+!
+!     Authors
+!     ------- 
+!     R. Wordsworth
+!     
+!==================================================================
+
+      INTEGER ngrid,nlayer,nq
+
+      real masse, Wtot, Wdiff
+
+      real pplev(ngrid,nlayer+1)
+      real pt(ngrid)
+
+      real dqs(ngrid,nq) 
+      real dq(ngrid,nlayer,nq)
+
+      integer iq, ig, ilay
+
+      do iq=1,nq 
+        do ig=1,ngrid
+           Wtot = 0.0
+           do ilay=1,nlayer
+              masse = (pplev(ig,ilay) - pplev(ig,ilay+1))/g
+              Wtot  = Wtot + masse*dq(ig,ilay,iq)
+           enddo
+           Wdiff = Wtot + dqs(ig,iq)
+         
+           dqs(ig,iq) = dqs(ig,iq) - Wdiff
+        enddo
+      enddo
+
+      end 
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/gases_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/gases_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/gases_h.F90	(revision 1644)
@@ -0,0 +1,37 @@
+      module gases_h
+
+      implicit none
+
+!======================================================================C
+!
+!     gases_h    
+!
+!     A F90-allocatable version for gases.h -- AS 12/2011
+!
+!======================================================================C
+
+      ! Set and allocated in su_gases.F90
+      integer :: ngasmx
+      integer :: vgas
+      character*20,allocatable,DIMENSION(:) :: gnom ! name of the gas, read by master
+      real,allocatable,DIMENSION(:) :: gfrac
+
+      ! in analogy with tracer.h ...
+      integer :: igas_H2
+      integer :: igas_He
+      integer :: igas_H2O
+      integer :: igas_CO2
+      integer :: igas_CO
+      integer :: igas_N2
+      integer :: igas_O2
+      integer :: igas_SO2
+      integer :: igas_H2S
+      integer :: igas_CH4
+      integer :: igas_NH3
+      integer :: igas_C2H2
+      integer :: igas_C2H6
+!!$OMP THREADPRIVATE(ngasmx,vgas,gnom,gfrac,&
+!	!$OMP igas_H2,igas_He,igas_H2O,igas_CO2,igas_CO,igas_N2,&
+!	!$OMP igas_O2,igas_SO2,igas_H2S,igas_CH4,igas_NH3,igas_C2H2,igas_C2H6)
+
+      end module gases_h
Index: /trunk/LMDZ.TITAN/libf/phytitan/gfluxi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/gfluxi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/gfluxi.F	(revision 1644)
@@ -0,0 +1,223 @@
+      SUBROUTINE GFLUXI(NLL,TLEV,NW,DW,DTAU,TAUCUM,W0,COSBAR,UBARI,
+     *                  RSF,BTOP,BSURF,FTOPUP,FMIDP,FMIDM)
+
+C  THIS SUBROUTINE TAKES THE OPTICAL CONSTANTS AND BOUNDARY CONDITIONS
+C  FOR THE INFRARED FLUX AT ONE WAVELENGTH AND SOLVES FOR THE FLUXES AT
+C  THE LEVELS. THIS VERSION IS SET UP TO WORK WITH LAYER OPTICAL DEPTHS
+C  MEASURED FROM THE TOP OF EACH LAYER.  THE TOP OF EACH LAYER HAS  
+C  OPTICAL DEPTH ZERO.  IN THIS SUB LEVEL N IS ABOVE LAYER N. THAT IS LAYER N
+C  HAS LEVEL N ON TOP AND LEVEL N+1 ON BOTTOM. OPTICAL DEPTH INCREASES
+C  FROM TOP TO BOTTOM. SEE C.P. MCKAY, TGM NOTES.
+C THE TRI-DIAGONAL MATRIX SOLVER IS DSOLVER AND IS DOUBLE PRECISION SO MANY 
+C VARIABLES ARE PASSED AS SINGLE THEN BECOME DOUBLE IN DSOLVER
+C
+C NLL            = NUMBER OF LEVELS (NLAYERS + 1) MUST BE LESS THAT NL (101)
+C TLEV(L_LEVELS) = ARRAY OF TEMPERATURES AT GCM LEVELS
+C WAVEN          = WAVELENGTH FOR THE COMPUTATION
+C DW             = WAVENUMBER INTERVAL
+C DTAU(NLAYER)   = ARRAY OPTICAL DEPTH OF THE LAYERS
+C W0(NLEVEL)     = SINGLE SCATTERING ALBEDO
+C COSBAR(NLEVEL) = ASYMMETRY FACTORS, 0=ISOTROPIC
+C UBARI          = AVERAGE ANGLE, MUST BE EQUAL TO 0.5 IN IR
+C RSF            = SURFACE REFLECTANCE
+C BTOP           = UPPER BOUNDARY CONDITION ON IR INTENSITY (NOT FLUX)
+C BSURF          = SURFACE EMISSION = (1-RSFI)*PLANCK, INTENSITY (NOT FLUX)
+C FP(NLEVEL)     = UPWARD FLUX AT LEVELS
+C FM(NLEVEL)     = DOWNWARD FLUX AT LEVELS
+C FMIDP(NLAYER)  = UPWARD FLUX AT LAYER MIDPOINTS
+C FMIDM(NLAYER)  = DOWNWARD FLUX AT LAYER MIDPOINTS
+C
+C----------------------------------------------------------------------C
+
+      use radinc_h
+      use radcommon_h, only: planckir
+      use comcstfi_mod, only: pi
+
+      implicit none
+
+
+      INTEGER NLL, NLAYER, L, NW, NT, NT2
+      REAL*8  TERM, CPMID, CMMID
+      REAL*8  PLANCK
+      REAL*8  EM,EP
+      REAL*8  COSBAR(L_NLAYRAD), W0(L_NLAYRAD), DTAU(L_NLAYRAD)
+      REAL*8  TAUCUM(L_LEVELS), DTAUK
+      REAL*8  TLEV(L_LEVELS)
+      REAL*8  WAVEN, DW, UBARI, RSF
+      REAL*8  BTOP, BSURF, FMIDP(L_NLAYRAD), FMIDM(L_NLAYRAD)
+      REAL*8  B0(L_NLAYRAD),B1(L_NLAYRAD),ALPHA(L_NLAYRAD)
+      REAL*8  LAMDA(L_NLAYRAD),XK1(L_NLAYRAD),XK2(L_NLAYRAD)
+      REAL*8  GAMA(L_NLAYRAD),CP(L_NLAYRAD),CM(L_NLAYRAD)
+      REAL*8  CPM1(L_NLAYRAD),CMM1(L_NLAYRAD),E1(L_NLAYRAD)
+      REAL*8  E2(L_NLAYRAD),E3(L_NLAYRAD),E4(L_NLAYRAD)
+
+      REAL*8  FTOPUP, FLUXUP, FLUXDN
+
+      real*8 :: TAUMAX = L_TAUMAX 
+
+C======================================================================C
+ 
+C     WE GO WITH THE HEMISPHERIC CONSTANT APPROACH IN THE INFRARED
+ 
+
+      NLAYER = L_NLAYRAD
+
+      DO L=1,L_NLAYRAD-1
+
+!----------------------------------------------------
+! There is a problem when W0 = 1
+!         open(888,file='W0')
+!           if ((W0(L).eq.0.).or.(W0(L).eq.1.)) then
+!             write(888,*) W0(L), L, 'gfluxi'
+!           endif
+! Prevent this with an if statement:
+        if (W0(L).eq.1.D0) then
+           W0(L) = 0.99999D0
+        endif
+!----------------------------------------------------
+
+        ALPHA(L) = SQRT( (1.0D0-W0(L))/(1.0D0-W0(L)*COSBAR(L)) )
+        LAMDA(L) = ALPHA(L)*(1.0D0-W0(L)*COSBAR(L))/UBARI
+
+        NT    = int(TLEV(2*L)*NTfac)   - NTstar+1
+        NT2   = int(TLEV(2*L+2)*NTfac) - NTstar+1
+
+        B1(L) = (PLANCKIR(NW,NT2)-PLANCKIR(NW,NT))/DTAU(L)
+        B0(L) = PLANCKIR(NW,NT)
+      END DO
+
+C     Take care of special lower layer
+
+      L        = L_NLAYRAD
+
+      if (W0(L).eq.1.) then
+          W0(L) = 0.99999D0
+      end if
+
+      ALPHA(L) = SQRT( (1.0D0-W0(L))/(1.0D0-W0(L)*COSBAR(L)) )
+      LAMDA(L) = ALPHA(L)*(1.0D0-W0(L)*COSBAR(L))/UBARI
+
+      ! Tsurf is used for 1st layer source function
+      ! -- same results for most thin atmospheres
+      ! -- and stabilizes integrations
+      NT    = int(TLEV(2*L+1)*NTfac) - NTstar+1
+      !! For deep, opaque, thick first layers (e.g. Saturn)
+      !! what is below works much better, not unstable, ...
+      !! ... and actually fully accurate because 1st layer temp (JL) 
+      !NT    = int(TLEV(2*L)*NTfac) - NTstar+1
+      !! (or this one yields same results
+      !NT    = int( (TLEV(2*L)+TLEV(2*L+1))*0.5*NTfac ) - NTstar+1
+
+      NT2   = int(TLEV(2*L)*NTfac)   - NTstar+1
+      B1(L) = (PLANCKIR(NW,NT)-PLANCKIR(NW,NT2))/DTAU(L)
+      B0(L) = PLANCKIR(NW,NT2)
+
+      DO L=1,L_NLAYRAD
+        GAMA(L) = (1.0D0-ALPHA(L))/(1.0D0+ALPHA(L))
+        TERM    = UBARI/(1.0D0-W0(L)*COSBAR(L))
+
+C       CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE
+C       BOTTOM OF THE LAYER.  THAT IS AT DTAU OPTICAL DEPTH
+
+        CP(L) = B0(L)+B1(L)*DTAU(L) +B1(L)*TERM
+        CM(L) = B0(L)+B1(L)*DTAU(L) -B1(L)*TERM
+
+C       CPM1 AND CMM1 ARE THE CPLUS AND CMINUS TERMS EVALUATED
+C       AT THE TOP OF THE LAYER, THAT IS ZERO OPTICAL DEPTH
+
+        CPM1(L) = B0(L)+B1(L)*TERM
+        CMM1(L) = B0(L)-B1(L)*TERM
+      END DO
+ 
+C     NOW CALCULATE THE EXPONENTIAL TERMS NEEDED
+C     FOR THE TRIDIAGONAL ROTATED LAYERED METHOD
+C     WARNING IF DTAU(J) IS GREATER THAN ABOUT 35 (VAX)
+C     WE CLIP IT TO AVOID OVERFLOW.
+
+      DO L=1,L_NLAYRAD
+
+C       CLIP THE EXPONENTIAL HERE.
+
+        EP    = EXP( MIN((LAMDA(L)*DTAU(L)),TAUMAX))
+        EM    = 1.0D0/EP
+        E1(L) = EP+GAMA(L)*EM
+        E2(L) = EP-GAMA(L)*EM
+        E3(L) = GAMA(L)*EP+EM
+        E4(L) = GAMA(L)*EP-EM
+      END DO
+ 
+c     B81=BTOP  ! RENAME BEFORE CALLING DSOLVER - used to be to set
+c     B82=BSURF ! them to real*8 - but now everything is real*8
+c     R81=RSF   ! so this may not be necessary
+
+C     Double precision tridiagonal solver
+
+      CALL DSOLVER(NLAYER,GAMA,CP,CM,CPM1,CMM1,E1,E2,E3,E4,BTOP,
+     *             BSURF,RSF,XK1,XK2)
+ 
+
+C     NOW WE CALCULATE THE FLUXES AT THE MIDPOINTS OF THE LAYERS.
+ 
+      DO L=1,L_NLAYRAD-1
+        DTAUK = TAUCUM(2*L+1)-TAUCUM(2*L)
+        EP    = EXP(MIN(LAMDA(L)*DTAUK,TAUMAX)) ! CLIPPED EXPONENTIAL 
+        EM    = 1.0D0/EP
+        TERM  = UBARI/(1.D0-W0(L)*COSBAR(L))
+
+C       CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE
+C       BOTTOM OF THE LAYER.  THAT IS AT DTAU  OPTICAL DEPTH
+
+        CPMID    = B0(L)+B1(L)*DTAUK +B1(L)*TERM
+        CMMID    = B0(L)+B1(L)*DTAUK -B1(L)*TERM
+        FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID
+        FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID
+
+C       FOR FLUX WE INTEGRATE OVER THE HEMISPHERE TREATING INTENSITY CONSTANT
+
+        FMIDP(L) = FMIDP(L)*PI
+        FMIDM(L) = FMIDM(L)*PI
+      END DO
+ 
+C     And now, for the special bottom layer
+
+      L    = L_NLAYRAD
+
+      EP   = EXP(MIN((LAMDA(L)*DTAU(L)),TAUMAX)) ! CLIPPED EXPONENTIAL 
+      EM   = 1.0D0/EP
+      TERM = UBARI/(1.D0-W0(L)*COSBAR(L))
+
+C     CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE
+C     BOTTOM OF THE LAYER.  THAT IS AT DTAU  OPTICAL DEPTH
+
+      CPMID    = B0(L)+B1(L)*DTAU(L) +B1(L)*TERM
+      CMMID    = B0(L)+B1(L)*DTAU(L) -B1(L)*TERM
+      FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID
+      FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID
+ 
+C     FOR FLUX WE INTEGRATE OVER THE HEMISPHERE TREATING INTENSITY CONSTANT
+
+      FMIDP(L) = FMIDP(L)*PI
+      FMIDM(L) = FMIDM(L)*PI
+
+C     FLUX AT THE PTOP LEVEL
+
+      EP   = 1.0D0
+      EM   = 1.0D0
+      TERM = UBARI/(1.0D0-W0(1)*COSBAR(1))
+
+C     CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE
+C     BOTTOM OF THE LAYER.  THAT IS AT DTAU  OPTICAL DEPTH
+
+      CPMID  = B0(1)+B1(1)*TERM
+      CMMID  = B0(1)-B1(1)*TERM
+
+      FLUXUP = XK1(1)*EP + GAMA(1)*XK2(1)*EM + CPMID
+      FLUXDN = XK1(1)*EP*GAMA(1) + XK2(1)*EM + CMMID
+ 
+C     FOR FLUX WE INTEGRATE OVER THE HEMISPHERE TREATING INTENSITY CONSTANT
+
+      FTOPUP = (FLUXUP-FLUXDN)*PI
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/gfluxv.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/gfluxv.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/gfluxv.F	(revision 1644)
@@ -0,0 +1,320 @@
+      SUBROUTINE GFLUXV(DTDEL,TDEL,TAUCUMIN,WDEL,CDEL,UBAR0,F0PI,RSF,
+     *                  BTOP,BSURF,FMIDP,FMIDM,DIFFV,FLUXUP,FLUXDN)
+
+
+C  THIS SUBROUTINE TAKES THE OPTICAL CONSTANTS AND BOUNDARY CONDITIONS
+C  FOR THE VISIBLE  FLUX AT ONE WAVELENGTH AND SOLVES FOR THE FLUXES AT
+C  THE LEVELS. THIS VERSION IS SET UP TO WORK WITH LAYER OPTICAL DEPTHS
+C  MEASURED FROM THE TOP OF EACH LAYER.  (DTAU) TOP OF EACH LAYER HAS  
+C  OPTICAL DEPTH TAU(N).IN THIS SUB LEVEL N IS ABOVE LAYER N. THAT IS LAYER N
+C  HAS LEVEL N ON TOP AND LEVEL N+1 ON BOTTOM. OPTICAL DEPTH INCREASES
+C  FROM TOP TO BOTTOM. SEE C.P. MCKAY, TGM NOTES.
+C THIS SUBROUTINE DIFFERS FROM ITS IR COUNTERPART IN THAT HERE WE SOLVE FOR 
+C THE FLUXES DIRECTLY USING THE GENERALIZED NOTATION OF MEADOR AND WEAVOR
+C J.A.S., 37, 630-642, 1980.
+C THE TRI-DIAGONAL MATRIX SOLVER IS DSOLVER AND IS DOUBLE PRECISION SO MANY 
+C VARIABLES ARE PASSED AS SINGLE THEN BECOME DOUBLE IN DSOLVER
+C
+C NLL           = NUMBER OF LEVELS (NAYER + 1) THAT WILL BE SOLVED
+C NAYER         = NUMBER OF LAYERS (NOTE DIFFERENT SPELLING HERE)
+C WAVEN         = WAVELENGTH FOR THE COMPUTATION
+C DTDEL(NLAYER) = ARRAY OPTICAL DEPTH OF THE LAYERS
+C TDEL(NLL)     = ARRAY COLUMN OPTICAL DEPTH AT THE LEVELS
+C WDEL(NLEVEL)  = SINGLE SCATTERING ALBEDO
+C CDEL(NLL)     = ASYMMETRY FACTORS, 0=ISOTROPIC
+C UBARV         = AVERAGE ANGLE, 
+C UBAR0         = SOLAR ZENITH ANGLE
+C F0PI          = INCIDENT SOLAR DIRECT BEAM FLUX
+C RSF           = SURFACE REFLECTANCE
+C BTOP          = UPPER BOUNDARY CONDITION ON DIFFUSE FLUX
+C BSURF         = REFLECTED DIRECT BEAM = (1-RSFI)*F0PI*EDP-TAU/U
+C FP(NLEVEL)    = UPWARD FLUX AT LEVELS
+C FM(NLEVEL)    = DOWNWARD FLUX AT LEVELS
+C FMIDP(NLAYER) = UPWARD FLUX AT LAYER MIDPOINTS
+C FMIDM(NLAYER) = DOWNWARD FLUX AT LAYER MIDPOINTS
+C added Dec 2002
+C DIFFV         = downward diffuse solar flux at the surface
+C 
+!======================================================================!
+
+      use radinc_h
+
+      implicit none
+
+!!      INTEGER NLP
+!!      PARAMETER (NLP=101) ! MUST BE LARGER THAN NLEVEL
+
+      REAL*8 EM, EP
+      REAL*8 W0(L_NLAYRAD), COSBAR(L_NLAYRAD), DTAU(L_NLAYRAD)
+      REAL*8 TAU(L_NLEVRAD), WDEL(L_NLAYRAD), CDEL(L_NLAYRAD)
+      REAL*8 DTDEL(L_NLAYRAD), TDEL(L_NLEVRAD)
+      REAL*8 FMIDP(L_NLAYRAD), FMIDM(L_NLAYRAD)
+      REAL*8 LAMDA(L_NLAYRAD), ALPHA(L_NLAYRAD), XK1(L_NLAYRAD)
+      REAL*8 XK2(L_NLAYRAD),G1(L_NLAYRAD), G2(L_NLAYRAD)
+      REAL*8 G3(L_NLAYRAD), GAMA(L_NLAYRAD),CP(L_NLAYRAD),CM(L_NLAYRAD)
+      REAL*8 CPM1(L_NLAYRAD),CMM1(L_NLAYRAD), E1(L_NLAYRAD)
+      REAL*8 E2(L_NLAYRAD),E3(L_NLAYRAD),E4(L_NLAYRAD),EXPTRM(L_NLAYRAD)
+      REAL*8 FLUXUP, FLUXDN
+      REAL*8 FACTOR, TAUCUMIN(L_LEVELS), TAUCUM(L_LEVELS)
+
+      integer NAYER, L, K
+      real*8  ubar0, f0pi, rsf, btop, bsurf, g4, denom, am, ap
+      real*8  taumax, taumid, cpmid, cmmid
+      real*8  diffv
+
+C======================================================================C
+
+
+
+
+      NAYER  = L_NLAYRAD
+      TAUMAX = L_TAUMAX    !Default is 35.0
+      
+!  Delta-Eddington Scaling
+
+
+      FACTOR    = 1.0D0 - WDEL(1)*CDEL(1)**2
+
+      TAU(1)    = TDEL(1)*FACTOR
+      TAUCUM(1) = 0.0D0
+      TAUCUM(2) = TAUCUMIN(2)*FACTOR
+      TAUCUM(3) = TAUCUM(2) +(TAUCUMIN(3)-TAUCUMIN(2))*FACTOR
+
+
+      DO L=1,L_NLAYRAD-1
+        FACTOR      = 1.0D0 - WDEL(L)*CDEL(L)**2
+        W0(L)       = WDEL(L)*(1.0D0-CDEL(L)**2)/FACTOR
+        COSBAR(L)   = CDEL(L)/(1.0D0+CDEL(L))
+
+        DTAU(L)     = DTDEL(L)*FACTOR
+        TAU(L+1)    = TAU(L)+DTAU(L)
+        K           = 2*(L+1)
+        TAUCUM(K)   = TAU(L+1)
+        TAUCUM(K+1) = TAUCUM(K) + (TAUCUMIN(K+1)-TAUCUMIN(K))*FACTOR
+      END DO
+
+!  Bottom layer
+
+      L             = L_NLAYRAD
+      FACTOR        = 1.0D0 - WDEL(L)*CDEL(L)**2
+      W0(L)         = WDEL(L)*(1.0D0-CDEL(L)**2)/FACTOR
+      COSBAR(L)     = CDEL(L)/(1.0D0+CDEL(L))
+      DTAU(L)       = DTDEL(L)*FACTOR
+      TAU(L+1)      = TAU(L)+DTAU(L)
+      TAUCUM(2*L+1) = TAU(L+1)
+
+      BSURF = RSF*UBAR0*F0PI*EXP(-MIN(TAU(L+1),TAUMAX)/UBAR0)
+      ! new definition of BSURF
+      ! the old one was false because it used tau, not tau'
+      ! tau' includes the contribution to the downward flux
+      ! of the radiation scattered in the forward direction
+
+C     WE GO WITH THE QUADRATURE APPROACH HERE.  THE "SQRT(3)" factors
+C     ARE THE UBARV TERM.
+
+      DO L=1,L_NLAYRAD
+
+        ALPHA(L)=SQRT( (1.0-W0(L))/(1.0-W0(L)*COSBAR(L) ) )
+
+C       SET OF CONSTANTS DETERMINED BY DOM 
+
+!     Quadrature method
+        G1(L)    = (SQRT(3.0)*0.5)*(2.0- W0(L)*(1.0+COSBAR(L)))
+        G2(L)    = (SQRT(3.0)*W0(L)*0.5)*(1.0-COSBAR(L))
+        G3(L)    = 0.5*(1.0-SQRT(3.0)*COSBAR(L)*UBAR0)
+
+!     ----- some other methods... (RDW) ------
+
+!     Eddington method
+!        G1(L)    =  0.25*(7.0 - W0(L)*(4.0 - 3.0*COSBAR(L)))
+!        G2(L)    = -0.25*(1.0 - W0(L)*(4.0 - 3.0*COSBAR(L)))
+!        G3(L)    =  0.25*(2.0 - 3.0*COSBAR(L)*UBAR0)
+
+!     delta-Eddington method
+!        G1(L)    =  (7.0 - 3.0*g^2 - W0(L)*(4.0 + 3.0*g) + W0(L)*g^2*(4*beta0 + 3*g)) / &
+!                             (4* (1 - g^2*()   ))  0.25*(7.0 - W0(L)*(4.0 - 3.0*COSBAR(L)))
+
+!     Hybrid modified Eddington-delta function method
+
+!     ----------------------------------------
+
+c     So they use Quadrature
+c     but the scaling is Eddington?
+
+        LAMDA(L) = SQRT(G1(L)**2 - G2(L)**2)
+        GAMA(L)  = (G1(L)-LAMDA(L))/G2(L)
+      END DO
+
+
+      DO L=1,L_NLAYRAD
+        G4    = 1.0-G3(L)
+        DENOM = LAMDA(L)**2 - 1./UBAR0**2
+ 
+C       THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
+C       THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN 
+C       THE SCATTERING GOES TO ZERO
+C       PREVENT THIS WITH AN IF STATEMENT
+
+        IF ( DENOM .EQ. 0.) THEN
+          DENOM=1.E-10
+        END IF
+
+
+        AM = F0PI*W0(L)*(G4   *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM
+        AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4    )/DENOM
+
+C       CPM1 AND CMM1 ARE THE CPLUS AND CMINUS TERMS EVALUATED
+C       AT THE TOP OF THE LAYER, THAT IS LOWER   OPTICAL DEPTH TAU(L)
+ 
+        CPM1(L) = AP*EXP(-TAU(L)/UBAR0)
+        CMM1(L) = AM*EXP(-TAU(L)/UBAR0)
+
+C       CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE
+C       BOTTOM OF THE LAYER.  THAT IS AT HIGHER OPTICAL DEPTH TAU(L+1)
+
+        CP(L) = AP*EXP(-TAU(L+1)/UBAR0)
+        CM(L) = AM*EXP(-TAU(L+1)/UBAR0)
+
+      END DO
+
+
+ 
+C     NOW CALCULATE THE EXPONENTIAL TERMS NEEDED
+C     FOR THE TRIDIAGONAL ROTATED LAYERED METHOD
+
+      DO L=1,L_NLAYRAD
+        EXPTRM(L) = MIN(TAUMAX,LAMDA(L)*DTAU(L))  ! CLIPPED EXPONENTIAL
+        EP = EXP(EXPTRM(L))
+
+        EM        = 1.0/EP
+        E1(L)     = EP+GAMA(L)*EM
+        E2(L)     = EP-GAMA(L)*EM
+        E3(L)     = GAMA(L)*EP+EM
+        E4(L)     = GAMA(L)*EP-EM
+      END DO
+
+      CALL DSOLVER(NAYER,GAMA,CP,CM,CPM1,CMM1,E1,E2,E3,E4,BTOP,
+     *             BSURF,RSF,XK1,XK2)
+
+C     NOW WE CALCULATE THE FLUXES AT THE MIDPOINTS OF THE LAYERS.
+ 
+      DO L=1,L_NLAYRAD-1
+        EXPTRM(L) = MIN(TAUMAX,LAMDA(L)*(TAUCUM(2*L+1)-TAUCUM(2*L)))
+ 
+        EP = EXP(EXPTRM(L))
+
+        EM    = 1.0/EP
+        G4    = 1.0-G3(L)
+        DENOM = LAMDA(L)**2 - 1./UBAR0**2
+
+C       THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
+C       THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN 
+C       THE SCATTERING GOES TO ZERO
+C       PREVENT THIS WITH A IF STATEMENT
+
+
+        IF ( DENOM .EQ. 0.) THEN
+          DENOM=1.E-10
+        END IF
+
+        AM = F0PI*W0(L)*(G4   *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM
+        AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4    )/DENOM
+
+C       CPMID AND CMMID  ARE THE CPLUS AND CMINUS TERMS EVALUATED
+C       AT THE MIDDLE OF THE LAYER.
+
+        TAUMID   = TAUCUM(2*L+1)
+
+        CPMID = AP*EXP(-TAUMID/UBAR0)
+        CMMID = AM*EXP(-TAUMID/UBAR0)
+
+        FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID
+        FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID
+ 
+C       ADD THE DIRECT FLUX TO THE DOWNWELLING TERM
+
+        FMIDM(L)= FMIDM(L)+UBAR0*F0PI*EXP(-MIN(TAUMID,TAUMAX)/UBAR0)
+   
+      END DO
+ 
+C     FLUX AT THE Ptop layer
+
+      EP    = 1.0
+      EM    = 1.0
+      G4    = 1.0-G3(1)
+      DENOM = LAMDA(1)**2 - 1./UBAR0**2
+
+C     THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
+C     THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN 
+C     THE SCATTERING GOES TO ZERO
+C     PREVENT THIS WITH A IF STATEMENT
+
+      IF ( DENOM .EQ. 0.) THEN
+        DENOM=1.E-10
+      END IF
+
+      AM = F0PI*W0(1)*(G4   *(G1(1)+1./UBAR0) +G2(1)*G3(1) )/DENOM
+      AP = F0PI*W0(1)*(G3(1)*(G1(1)-1./UBAR0) +G2(1)*G4    )/DENOM
+
+C     CPMID AND CMMID  ARE THE CPLUS AND CMINUS TERMS EVALUATED
+C     AT THE MIDDLE OF THE LAYER.
+
+      CPMID  = AP
+      CMMID  = AM
+
+      FLUXUP = XK1(1)*EP + GAMA(1)*XK2(1)*EM + CPMID
+      FLUXDN = XK1(1)*EP*GAMA(1) + XK2(1)*EM + CMMID
+
+C     ADD THE DIRECT FLUX TO THE DOWNWELLING TERM
+
+      fluxdn = fluxdn+UBAR0*F0PI*EXP(-MIN(TAUCUM(1),TAUMAX)/UBAR0)
+
+C     This is for the "special" bottom layer, where we take
+C     DTAU instead of DTAU/2.
+
+      L     = L_NLAYRAD 
+      EXPTRM(L) = MIN(TAUMAX,LAMDA(L)*(TAUCUM(L_LEVELS)-
+     *                                 TAUCUM(L_LEVELS-1)))
+
+      EP    = EXP(EXPTRM(L))
+      EM    = 1.0/EP
+      G4    = 1.0-G3(L)
+      DENOM = LAMDA(L)**2 - 1./UBAR0**2
+
+
+C     THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
+C     THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN 
+C     THE SCATTERING GOES TO ZERO
+C     PREVENT THIS WITH A IF STATEMENT
+
+
+      IF ( DENOM .EQ. 0.) THEN
+        DENOM=1.E-10
+      END IF
+
+      AM = F0PI*W0(L)*(G4   *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM
+      AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4    )/DENOM
+
+C     CPMID AND CMMID  ARE THE CPLUS AND CMINUS TERMS EVALUATED
+C     AT THE MIDDLE OF THE LAYER.
+
+      TAUMID   = MIN(TAUCUM(L_LEVELS),TAUMAX)
+      CPMID    = AP*EXP(-MIN(TAUMID,TAUMAX)/UBAR0)
+      CMMID    = AM*EXP(-MIN(TAUMID,TAUMAX)/UBAR0)
+
+
+      FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID
+      FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID
+
+C  Save the diffuse downward flux for TEMPGR calculations
+
+      DIFFV = FMIDM(L)
+
+
+C     ADD THE DIRECT FLUX TO THE DOWNWELLING TERM
+
+      FMIDM(L)= FMIDM(L)+UBAR0*F0PI*EXP(-MIN(TAUMID,TAUMAX)/UBAR0)
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/hydrol.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/hydrol.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/hydrol.F90	(revision 1644)
@@ -0,0 +1,407 @@
+subroutine hydrol(ngrid,nq,ptimestep,rnat,tsurf,  &
+     qsurf,dqsurf,dqs_hyd,pcapcal,                &
+     albedo,albedo_bareground,                    &
+     albedo_snow_SPECTV,albedo_co2_ice_SPECTV,    &
+     mu0,pdtsurf,pdtsurf_hyd,hice,                &
+     pctsrf_sic,sea_ice)
+
+  use ioipsl_getin_p_mod, only: getin_p
+  use watercommon_h, only: T_h2O_ice_liq, RLFTT, rhowater, mx_eau_sol
+  USE surfdat_h
+  use comdiurn_h
+  USE geometry_mod, only: cell_area
+  USE tracer_h
+  use slab_ice_h
+  use callkeys_mod, only: albedosnow,albedoco2ice,ok_slab_ocean,Tsaldiff,maxicethick,co2cond
+  use radinc_h, only : L_NSPECTV
+
+  implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculate the surface hydrology and albedo changes.
+!     
+!     Authors
+!     ------- 
+!     Adapted from LMDTERRE by B. Charnay (2010). Further 
+!     Modifications by R. Wordsworth (2010).
+!     Spectral albedo by M. Turbet (2015).
+!     
+!     Called by
+!     ---------
+!     physiq.F
+!     
+!     Calls
+!     -----
+!     none
+!
+!     Notes
+!     -----
+!     rnat is terrain type: 0-ocean; 1-continent
+!     
+!==================================================================
+
+      integer ngrid,nq
+
+!     Inputs
+!     ------
+      real snowlayer
+      parameter (snowlayer=33.0)        ! 33 kg/m^2 of snow, equal to a layer of 3.3 cm 
+      real oceantime
+      parameter (oceantime=10*24*3600)
+
+      logical,save :: oceanbulkavg ! relax ocean temperatures to a GLOBAL mean value?
+      logical,save :: activerunoff ! enable simple runoff scheme?
+      logical,save :: oceanalbvary ! ocean albedo varies with the diurnal cycle?
+!$OMP THREADPRIVATE(oceanbulkavg,activerunoff,oceanalbvary)
+
+!     Arguments
+!     ---------
+      real rnat(ngrid) ! I changed this to integer (RW)
+      real,dimension(:),allocatable,save :: runoff
+      real totalrunoff, tsea, oceanarea
+      save oceanarea
+!$OMP THREADPRIVATE(runoff,oceanarea)
+
+      real ptimestep
+      real mu0(ngrid)
+      real qsurf(ngrid,nq), tsurf(ngrid)
+      real dqsurf(ngrid,nq), pdtsurf(ngrid)
+      real hice(ngrid)
+      real albedo(ngrid,L_NSPECTV)
+      real albedo_bareground(ngrid)
+      real albedo_snow_SPECTV(L_NSPECTV)
+      real albedo_co2_ice_SPECTV(L_NSPECTV)
+      real pctsrf_sic(ngrid), sea_ice(ngrid)
+
+      real oceanarea2
+
+!     Output
+!     ------
+      real dqs_hyd(ngrid,nq)
+      real pdtsurf_hyd(ngrid)
+
+!     Local
+!     -----
+      real a,b,E
+      integer ig,iq, nw
+      real fsnoi, subli, fauxo
+      real twater(ngrid)
+      real pcapcal(ngrid)
+      real hicebis(ngrid)
+      real zqsurf(ngrid,nq)
+      real ztsurf(ngrid)
+      real albedo_sic, alb_ice
+      real zfra
+
+      integer, save :: ivap, iliq, iice
+!$OMP THREADPRIVATE(ivap,iliq,iice)
+
+      logical, save :: firstcall
+!$OMP THREADPRIVATE(firstcall)
+
+      data firstcall /.true./
+
+
+      if(firstcall)then
+
+         oceanbulkavg=.false.
+         oceanalbvary=.false.
+         write(*,*)"Activate runnoff into oceans?"
+         activerunoff=.false.
+         call getin_p("activerunoff",activerunoff)
+         write(*,*)" activerunoff = ",activerunoff
+	 
+	 
+	 
+         if (activerunoff) then
+           ALLOCATE(runoff(ngrid))
+           runoff(1:ngrid)=0
+         endif
+
+         ivap=igcm_h2o_vap
+         iliq=igcm_h2o_vap
+         iice=igcm_h2o_ice
+        
+         write(*,*) "hydrol: ivap=",ivap
+         write(*,*) "        iliq=",iliq
+         write(*,*) "        iice=",iice
+
+!     Here's the deal: iice is used in place of igcm_h2o_ice both on the 
+!                      surface and in the atmosphere. ivap is used in
+!                      place of igcm_h2o_vap ONLY in the atmosphere, while
+!                      iliq is used in place of igcm_h2o_vap ONLY on the 
+!                      surface.
+!                      Soon to be extended to the entire water cycle...
+
+!     Total ocean surface area
+         oceanarea=0.
+         do ig=1,ngrid
+            if(nint(rnat(ig)).eq.0)then
+               oceanarea=oceanarea+cell_area(ig)
+            endif
+         enddo
+
+         if(oceanbulkavg.and.(oceanarea.le.0.))then
+            print*,'How are we supposed to average the ocean'
+            print*,'temperature, when there are no oceans?'
+            call abort
+         endif
+
+         if(activerunoff.and.(oceanarea.le.0.))then
+            print*,'You have enabled runoff, but you have no oceans.'
+            print*,'Where did you think the water was going to go?'
+            call abort
+         endif
+         
+         firstcall = .false.
+      endif
+
+!     add physical tendencies already calculated
+!     ------------------------------------------
+
+      do ig=1,ngrid
+         ztsurf(ig) = tsurf(ig) + ptimestep*pdtsurf(ig)
+         pdtsurf_hyd(ig)=0.0
+         do iq=1,nq
+            zqsurf(ig,iq) = qsurf(ig,iq) + ptimestep*dqsurf(ig,iq)
+         enddo    
+      enddo
+ 
+      do ig=1,ngrid
+         do iq=1,nq
+            dqs_hyd(ig,iq) = 0.0
+         enddo
+      enddo
+
+      do ig = 1, ngrid
+
+!     Ocean
+!     -----
+         if(nint(rnat(ig)).eq.0)then
+
+!     re-calculate oceanic albedo
+!            if(diurnal.and.oceanalbvary)then
+!               fauxo      = ( 1.47 - ACOS( mu0(ig) ) )/0.15 ! where does this come from (Benjamin)?
+!               albedo(ig) = 1.1*( .03 + .630/( 1. + fauxo*fauxo))
+!               albedo(ig) = MAX(MIN(albedo(ig),0.60),0.04)
+!            else
+               do nw=1,L_NSPECTV
+                  albedo(ig,nw) = alb_ocean ! For now, alb_ocean is defined in slab_ice_h.F90. Later we could introduce spectral dependency for alb_ocean.
+	       enddo
+!            end if
+
+
+            if(ok_slab_ocean) then
+          
+               zfra = MAX(0.0,MIN(1.0,zqsurf(ig,iice)/45.0))     ! Snow Fraction (Critical height 45kg/m2~15cm)
+               alb_ice=alb_ice_max-(alb_ice_max-alb_ice_min) &   ! Ice Albedo
+               *exp(-sea_ice(ig)/h_alb_ice)
+               ! Albedo final calculation :
+               do nw=1,L_NSPECTV
+                  albedo(ig,nw) = pctsrf_sic(ig)*                                        &
+                                 (albedo_snow_SPECTV(nw)*zfra + alb_ice*(1.0-zfra))      &
+                               + (1.-pctsrf_sic(ig))*alb_ocean
+	       enddo
+
+               ! Oceanic ice height, just for diagnostics
+               hice(ig)    = MIN(10.,sea_ice(ig)/rhowater)
+            else !ok_slab_ocean
+
+
+!     calculate oceanic ice height including the latent heat of ice formation
+!     hice is the height of oceanic ice with a maximum of maxicethick.
+               hice(ig)    = zqsurf(ig,iice)/rhowater ! update hice to include recent snowfall
+
+!              twater(ig)  = tsurf(ig) + ptimestep*zdtsurf(ig) &
+               twater(ig)  = ztsurf(ig) - hice(ig)*RLFTT*rhowater/pcapcal(ig)
+               ! this is temperature water would have if we melted entire ocean ice layer
+               hicebis(ig) = hice(ig)
+               hice(ig)    = 0.
+
+               if(twater(ig) .lt. T_h2O_ice_liq)then
+                  E=min((T_h2O_ice_liq+Tsaldiff-twater(ig))*pcapcal(ig),RLFTT*rhowater*maxicethick)
+                  hice(ig)        = E/(RLFTT*rhowater)
+                  hice(ig)        = max(hice(ig),0.0)
+                  hice(ig)        = min(hice(ig),maxicethick)
+                  pdtsurf_hyd(ig) = (hice(ig) - hicebis(ig))*RLFTT*rhowater/pcapcal(ig)/ptimestep              
+                  do nw=1,L_NSPECTV
+		     albedo(ig,nw) = albedo_snow_SPECTV(nw) ! Albedo of ice has been replaced by albedo of snow here. MT2015.
+	          enddo  
+
+!                 if (zqsurf(ig,iice).ge.snowlayer) then
+!                    albedo(ig) = albedoice
+!                 else
+!                    albedo(ig) = albedoocean &
+!                    + (albedosnow - albedoocean)*zqsurf(ig,iice)/snowlayer
+!                 endif
+
+               else
+
+                  pdtsurf_hyd(ig) = -hicebis(ig)*RLFTT*rhowater/pcapcal(ig)/ptimestep
+                  DO nw=1,L_NSPECTV
+                     albedo(ig,nw) = alb_ocean
+	          ENDDO               
+
+               endif
+
+               zqsurf(ig,iliq) = zqsurf(ig,iliq)-(hice(ig)*rhowater-zqsurf(ig,iice))
+               zqsurf(ig,iice) = hice(ig)*rhowater
+
+            endif!(ok_slab_ocean)
+
+
+!     Continent
+!     ---------
+         elseif (nint(rnat(ig)).eq.1) then
+
+!     melt the snow
+            if(ztsurf(ig).gt.T_h2O_ice_liq)then
+               if(zqsurf(ig,iice).gt.1.0e-8)then
+
+                  a     = (ztsurf(ig)-T_h2O_ice_liq)*pcapcal(ig)/RLFTT
+                  b     = zqsurf(ig,iice)
+                  fsnoi = min(a,b)
+
+                  zqsurf(ig,iice) = zqsurf(ig,iice) - fsnoi
+                  zqsurf(ig,iliq) = zqsurf(ig,iliq) + fsnoi
+
+!                 thermal effects
+                  pdtsurf_hyd(ig) = -fsnoi*RLFTT/pcapcal(ig)/ptimestep  
+
+               endif
+            else
+
+!     freeze the water
+               if(zqsurf(ig,iliq).gt.1.0e-8)then
+
+                  a     = -(ztsurf(ig)-T_h2O_ice_liq)*pcapcal(ig)/RLFTT
+                  b     = zqsurf(ig,iliq)
+                  
+                  fsnoi = min(a,b)
+
+                  zqsurf(ig,iice) = zqsurf(ig,iice) + fsnoi
+                  zqsurf(ig,iliq) = zqsurf(ig,iliq) - fsnoi
+
+!                 thermal effects
+                  pdtsurf_hyd(ig) = +fsnoi*RLFTT/pcapcal(ig)/ptimestep  
+
+               endif
+            endif
+            
+!     deal with runoff
+            if(activerunoff)then
+
+               runoff(ig) = max(zqsurf(ig,iliq) - mx_eau_sol, 0.0)
+               if(ngrid.gt.1)then ! runoff only exists in 3D
+                  if(runoff(ig).ne.0.0)then
+                     zqsurf(ig,iliq) = mx_eau_sol
+!                    runoff is added to ocean at end
+                  endif
+               end if
+
+            endif
+
+!     re-calculate continental albedo
+            DO nw=1,L_NSPECTV
+	       albedo(ig,nw) = albedo_bareground(ig)
+	    ENDDO
+            if (zqsurf(ig,iice).ge.snowlayer) then
+               DO nw=1,L_NSPECTV
+                  albedo(ig,nw) = albedo_snow_SPECTV(nw)
+	       ENDDO
+            else
+               DO nw=1,L_NSPECTV
+                  albedo(ig,nw) = albedo_bareground(ig)                            & 
+                               + (albedo_snow_SPECTV(nw) - albedo_bareground(ig))  &
+                                 *zqsurf(ig,iice)/snowlayer
+	       ENDDO
+            endif
+
+         else
+
+            print*,'Surface type not recognised in hydrol.F!'
+            print*,'Exiting...'
+            call abort
+
+         endif
+
+      end do ! ig=1,ngrid
+
+!     perform crude bulk averaging of temperature in ocean
+!     ----------------------------------------------------
+      if(oceanbulkavg)then
+
+         oceanarea2=0.       
+         DO ig=1,ngrid
+            if((nint(rnat(ig)).eq.0).and.(hice(ig).eq.0.))then
+               oceanarea2=oceanarea2+cell_area(ig)*pcapcal(ig)
+            end if
+         END DO
+       
+         tsea=0.
+         DO ig=1,ngrid
+            if((nint(rnat(ig)).eq.0).and.(hice(ig).eq.0.))then       
+               tsea=tsea+ztsurf(ig)*cell_area(ig)*pcapcal(ig)/oceanarea2
+            end if
+         END DO
+
+         DO ig=1,ngrid
+            if((nint(rnat(ig)).eq.0).and.(hice(ig).eq.0))then
+               pdtsurf_hyd(ig) = pdtsurf_hyd(ig) + (tsea-ztsurf(ig))/oceantime
+            end if
+         END DO
+
+         print*,'Mean ocean temperature               = ',tsea,' K'
+
+      endif
+
+!     shove all the runoff water into the ocean
+!     -----------------------------------------
+      if(activerunoff)then
+
+         totalrunoff=0.
+         do ig=1,ngrid
+            if (nint(rnat(ig)).eq.1) then
+               totalrunoff = totalrunoff + cell_area(ig)*runoff(ig)
+            endif
+         enddo
+         
+         do ig=1,ngrid
+            if (nint(rnat(ig)).eq.0) then
+               zqsurf(ig,iliq) = zqsurf(ig,iliq) + &
+                    totalrunoff/oceanarea
+            endif
+         enddo
+
+      endif         
+
+
+!     Re-add the albedo effects of CO2 ice if necessary
+!     -------------------------------------------------
+      if(co2cond)then
+
+         do ig=1,ngrid
+            if (qsurf(ig,igcm_co2_ice).gt.1.) then ! Condition changed - Need now ~1 mm CO2 ice coverage. MT2015
+	       DO nw=1,L_NSPECTV
+                  albedo(ig,nw) = albedo_co2_ice_SPECTV(nw)
+	       ENDDO
+            endif
+         enddo ! ngrid
+         
+      endif ! co2cond
+
+
+      do ig=1,ngrid ! We calculate here the tracer tendencies. Don't forget that we have to retrieve the dqsurf tendencies we added at the beginning of the routine !
+         dqs_hyd(ig,iliq)=(zqsurf(ig,iliq) - qsurf(ig,iliq))/ptimestep - dqsurf(ig,iliq)
+         dqs_hyd(ig,iice)=(zqsurf(ig,iice) - qsurf(ig,iice))/ptimestep - dqsurf(ig,iice)
+      enddo
+
+      if (activerunoff) then
+        call writediagfi(ngrid,'runoff','Runoff amount',' ',2,runoff)
+      endif
+
+      return
+    end subroutine hydrol
Index: /trunk/LMDZ.TITAN/libf/phytitan/iniaerosol.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/iniaerosol.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/iniaerosol.F	(revision 1644)
@@ -0,0 +1,74 @@
+      SUBROUTINE iniaerosol()
+
+
+      use radinc_h, only: naerkind
+      use aerosol_mod
+      use callkeys_mod, only: aeroco2,aeroh2o,dusttau,aeroh2so4,
+     &		aeroback2lay
+
+      IMPLICIT NONE
+c=======================================================================
+c   subject:
+c   --------
+c   Initialization related to aerosols 
+c   (CO2 aerosols, dust, water, chemical species, ice...)   
+c
+c   author: Laura Kerber, S. Guerlet
+c   ------
+c        
+c=======================================================================
+
+      integer ia
+
+      ia=0
+      if (aeroco2) then
+         ia=ia+1
+         iaero_co2=ia
+      endif
+      write(*,*) '--- CO2 aerosol = ', iaero_co2
+ 
+      if (aeroh2o) then
+         ia=ia+1
+         iaero_h2o=ia
+      endif
+      write(*,*) '--- H2O aerosol = ', iaero_h2o
+
+      if (dusttau.gt.0) then
+         ia=ia+1
+         iaero_dust=ia
+      endif
+      write(*,*) '--- Dust aerosol = ', iaero_dust
+
+      if (aeroh2so4) then
+         ia=ia+1
+         iaero_h2so4=ia
+      endif
+      write(*,*) '--- H2SO4 aerosol = ', iaero_h2so4
+      
+      if (aeroback2lay) then
+         ia=ia+1
+         iaero_back2lay=ia
+      endif
+      write(*,*) '--- Two-layer aerosol = ', iaero_back2lay
+
+      write(*,*) '=== Number of aerosols= ', ia
+      
+! For the zero aerosol case, we currently make a dummy co2 aerosol which is zero everywhere.
+! (See aeropacity.F90 for how this works). A better solution would be to turn off the 
+! aerosol machinery in the no aerosol case, but this would be complicated. LK
+
+      if (ia.eq.0) then  !For the zero aerosol case. 
+         ia = 1
+         noaero = .true.
+         iaero_co2=ia
+      endif
+
+      if (ia.ne.naerkind) then
+          print*, 'Aerosols counted not equal to naerkind'
+          print*, 'Compile with tag -s',ia,'to run'
+          print*, 'or change options in callphys.def'
+          print*, 'Abort in iniaerosol.F'
+          call abort
+      endif
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/inifis_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/inifis_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/inifis_mod.F90	(revision 1644)
@@ -0,0 +1,740 @@
+MODULE inifis_mod
+IMPLICIT NONE
+
+CONTAINS
+
+  SUBROUTINE inifis(ngrid,nlayer,nq, &
+             day_ini,pdaysec,nday,ptimestep, &
+             plat,plon,parea, &
+             prad,pg,pr,pcpp)
+
+  use radinc_h, only: ini_radinc_h, naerkind
+  use radcommon_h, only: ini_radcommon_h
+  use datafile_mod, only: datadir
+  use comdiurn_h, only: sinlat, coslat, sinlon, coslon
+  use comgeomfi_h, only: totarea, totarea_planet
+  use comsoil_h, only: ini_comsoil_h, nsoilmx, lay1_soil, alpha_soil
+  use time_phylmdz_mod, only: ecritphy,day_step,iphysiq, &
+                              init_time, daysec, dtphys
+  use comcstfi_mod, only: rad, cpp, g, r, rcp, &
+                          mugaz, pi, avocado
+  use planete_mod, only: nres
+  use planetwide_mod, only: planetwide_sumval
+  use callkeys_mod
+  use mod_phys_lmdz_para, only : is_parallel
+
+!=======================================================================
+!
+!   purpose:
+!   -------
+!
+!   Initialisation for the physical parametrisations of the LMD 
+!   Generic Model.
+!
+!   author: Frederic Hourdin 15 / 10 /93
+!   -------
+!   modified: Sebastien Lebonnois 11/06/2003 (new callphys.def)
+!             Ehouarn Millour (oct. 2008) tracers are now identified
+!              by their names and may not be contiguously
+!              stored in the q(:,:,:,:) array
+!             E.M. (june 2009) use getin routine to load parameters
+!
+!
+!   arguments:
+!   ----------
+!
+!   input:
+!   ------
+!
+!    ngrid                 Size of the horizontal grid.
+!                          All internal loops are performed on that grid.
+!    nlayer                Number of vertical layers.
+!    pdayref               Day of reference for the simulation
+!    pday                  Number of days counted from the North. Spring
+!                          equinoxe.
+!
+!=======================================================================
+!
+!-----------------------------------------------------------------------
+!   declarations:
+!   -------------
+  use datafile_mod, only: datadir
+  use ioipsl_getin_p_mod, only: getin_p
+  IMPLICIT NONE
+
+
+
+  REAL,INTENT(IN) :: prad,pg,pr,pcpp,pdaysec,ptimestep
+  INTEGER,INTENT(IN) :: nday
+  INTEGER,INTENT(IN) :: ngrid,nlayer,nq
+  REAL,INTENT(IN) :: plat(ngrid),plon(ngrid),parea(ngrid)
+  integer,intent(in) :: day_ini
+  INTEGER ig,ierr
+ 
+  EXTERNAL iniorbit,orbite
+  EXTERNAL SSUM
+  REAL SSUM
+ 
+  ! initialize constants in comcstfi_mod
+  rad=prad
+  cpp=pcpp
+  g=pg
+  r=pr
+  rcp=r/cpp
+  pi=2.*asin(1.)
+  avocado = 6.02214179e23   ! added by RW
+
+  ! Initialize some "temporal and calendar" related variables
+  CALL init_time(day_ini,pdaysec,nday,ptimestep)
+
+  ! read in some parameters from "run.def" for physics,
+  ! or shared between dynamics and physics.
+  call getin_p("ecritphy",ecritphy) ! frequency of outputs in physics,
+                                    ! in dynamical steps
+  call getin_p("day_step",day_step) ! number of dynamical steps per day
+  call getin_p("iphysiq",iphysiq) ! call physics every iphysiq dyn step
+
+! --------------------------------------------------------------
+!  Reading the "callphys.def" file controlling some key options
+! --------------------------------------------------------------
+     
+  ! check that 'callphys.def' file is around
+  OPEN(99,file='callphys.def',status='old',form='formatted',iostat=ierr)
+  CLOSE(99)
+  IF(ierr.EQ.0) iscallphys=.true. !iscallphys initialised as false in callkeys_mod module
+      
+!!!      IF(ierr.EQ.0) THEN
+  IF(iscallphys) THEN
+     PRINT*
+     PRINT*
+     PRINT*,'--------------------------------------------'
+     PRINT*,' inifis: Parametres pour la physique (callphys.def)'
+     PRINT*,'--------------------------------------------'
+
+     write(*,*) "Directory where external input files are:"
+     ! default 'datadir' is set in "datadir_mod"
+     call getin_p("datadir",datadir) ! default path
+     write(*,*) " datadir = ",trim(datadir)
+
+     write(*,*) "Run with or without tracer transport ?"
+     tracer=.false. ! default value
+     call getin_p("tracer",tracer)
+     write(*,*) " tracer = ",tracer
+
+     write(*,*) "Run with or without atm mass update ", &
+            " due to tracer evaporation/condensation?"
+     mass_redistrib=.false. ! default value
+     call getin_p("mass_redistrib",mass_redistrib)
+     write(*,*) " mass_redistrib = ",mass_redistrib
+
+     write(*,*) "Diurnal cycle ?"
+     write(*,*) "(if diurnal=false, diurnal averaged solar heating)"
+     diurnal=.true. ! default value
+     call getin_p("diurnal",diurnal)
+     write(*,*) " diurnal = ",diurnal
+
+     write(*,*) "Seasonal cycle ?"
+     write(*,*) "(if season=false, Ls stays constant, to value ", &
+         "set in 'start'"
+     season=.true. ! default value
+     call getin_p("season",season)
+     write(*,*) " season = ",season
+
+     write(*,*) "Tidally resonant rotation ?"
+     tlocked=.false. ! default value
+     call getin_p("tlocked",tlocked)
+     write(*,*) "tlocked = ",tlocked
+
+     write(*,*) "Saturn ring shadowing ?"
+     rings_shadow = .false.
+     call getin_p("rings_shadow", rings_shadow)
+     write(*,*) "rings_shadow = ", rings_shadow
+         
+     write(*,*) "Compute latitude-dependent gravity field?"
+     oblate = .false.
+     call getin_p("oblate", oblate)
+     write(*,*) "oblate = ", oblate
+
+     write(*,*) "Flattening of the planet (a-b)/a "
+     flatten = 0.0
+     call getin_p("flatten", flatten)
+     write(*,*) "flatten = ", flatten
+         
+
+     write(*,*) "Needed if oblate=.true.: J2"
+     J2 = 0.0
+     call getin_p("J2", J2)
+     write(*,*) "J2 = ", J2
+         
+     write(*,*) "Needed if oblate=.true.: Planet mass (*1e24 kg)"
+     MassPlanet = 0.0
+     call getin_p("MassPlanet", MassPlanet)
+     write(*,*) "MassPlanet = ", MassPlanet         
+
+     write(*,*) "Needed if oblate=.true.: Planet mean radius (m)"
+     Rmean = 0.0
+     call getin_p("Rmean", Rmean)
+     write(*,*) "Rmean = ", Rmean
+         
+! Test of incompatibility:
+! if tlocked, then diurnal should be false
+     if (tlocked.and.diurnal) then
+       print*,'If diurnal=true, we should turn off tlocked.'
+       stop
+     endif
+
+     write(*,*) "Tidal resonance ratio ?"
+     nres=0          ! default value
+     call getin_p("nres",nres)
+     write(*,*) "nres = ",nres
+
+     write(*,*) "Write some extra output to the screen ?"
+     lwrite=.false. ! default value
+     call getin_p("lwrite",lwrite)
+     write(*,*) " lwrite = ",lwrite
+
+     write(*,*) "Save statistics in file stats.nc ?"
+     callstats=.true. ! default value
+     call getin_p("callstats",callstats)
+     write(*,*) " callstats = ",callstats
+
+     write(*,*) "Test energy conservation of model physics ?"
+     enertest=.false. ! default value
+     call getin_p("enertest",enertest)
+     write(*,*) " enertest = ",enertest
+
+     write(*,*) "Check to see if cpp values used match gases.def ?"
+     check_cpp_match=.true. ! default value
+     call getin_p("check_cpp_match",check_cpp_match)
+     write(*,*) " check_cpp_match = ",check_cpp_match
+
+     write(*,*) "call radiative transfer ?"
+     callrad=.true. ! default value
+     call getin_p("callrad",callrad)
+     write(*,*) " callrad = ",callrad
+
+     write(*,*) "call correlated-k radiative transfer ?"
+     corrk=.true. ! default value
+     call getin_p("corrk",corrk)
+     write(*,*) " corrk = ",corrk
+
+     write(*,*) "prohibit calculations outside corrk T grid?"
+     strictboundcorrk=.true. ! default value
+     call getin_p("strictboundcorrk",strictboundcorrk)
+     write(*,*) "strictboundcorrk = ",strictboundcorrk
+
+     write(*,*) "call gaseous absorption in the visible bands?", &
+                    "(matters only if callrad=T)"
+     callgasvis=.false. ! default value
+     call getin_p("callgasvis",callgasvis)
+     write(*,*) " callgasvis = ",callgasvis
+        
+     write(*,*) "call continuum opacities in radiative transfer ?", &
+                    "(matters only if callrad=T)"
+     continuum=.true. ! default value
+     call getin_p("continuum",continuum)
+     write(*,*) " continuum = ",continuum
+
+     write(*,*) "use analytic function for H2O continuum ?"
+     H2Ocont_simple=.false. ! default value
+     call getin_p("H2Ocont_simple",H2Ocont_simple)
+     write(*,*) " H2Ocont_simple = ",H2Ocont_simple
+ 
+     write(*,*) "call turbulent vertical diffusion ?"
+     calldifv=.true. ! default value
+     call getin_p("calldifv",calldifv)
+     write(*,*) " calldifv = ",calldifv
+
+     write(*,*) "use turbdiff instead of vdifc ?"
+     UseTurbDiff=.true. ! default value
+     call getin_p("UseTurbDiff",UseTurbDiff)
+     write(*,*) " UseTurbDiff = ",UseTurbDiff
+
+     write(*,*) "call convective adjustment ?"
+     calladj=.true. ! default value
+     call getin_p("calladj",calladj)
+     write(*,*) " calladj = ",calladj
+
+     write(*,*) "call CO2 condensation ?"
+     co2cond=.false. ! default value
+     call getin_p("co2cond",co2cond)
+     write(*,*) " co2cond = ",co2cond
+! Test of incompatibility
+     if (co2cond.and.(.not.tracer)) then
+        print*,'We need a CO2 ice tracer to condense CO2'
+        call abort
+     endif 
+ 
+     write(*,*) "CO2 supersaturation level ?"
+     co2supsat=1.0 ! default value
+     call getin_p("co2supsat",co2supsat)
+     write(*,*) " co2supsat = ",co2supsat
+
+     write(*,*) "Radiative timescale for Newtonian cooling ?"
+     tau_relax=30. ! default value
+     call getin_p("tau_relax",tau_relax)
+     write(*,*) " tau_relax = ",tau_relax
+     tau_relax=tau_relax*24*3600 ! convert Earth days --> seconds
+
+     write(*,*)"call thermal conduction in the soil ?"
+     callsoil=.true. ! default value
+     call getin_p("callsoil",callsoil)
+     write(*,*) " callsoil = ",callsoil
+         
+     write(*,*)"Rad transfer is computed every iradia", &
+                   " physical timestep"
+     iradia=1 ! default value
+     call getin_p("iradia",iradia)
+     write(*,*)" iradia = ",iradia
+       
+     write(*,*)"Rayleigh scattering ?"
+     rayleigh=.false.
+     call getin_p("rayleigh",rayleigh)
+     write(*,*)" rayleigh = ",rayleigh
+
+     write(*,*) "Use blackbody for stellar spectrum ?"
+     stelbbody=.false. ! default value
+     call getin_p("stelbbody",stelbbody)
+     write(*,*) " stelbbody = ",stelbbody
+
+     write(*,*) "Stellar blackbody temperature ?"
+     stelTbb=5800.0 ! default value
+     call getin_p("stelTbb",stelTbb)
+     write(*,*) " stelTbb = ",stelTbb
+
+     write(*,*)"Output mean OLR in 1D?"
+     meanOLR=.false.
+     call getin_p("meanOLR",meanOLR)
+     write(*,*)" meanOLR = ",meanOLR
+
+     write(*,*)"Output spectral OLR in 3D?"
+     specOLR=.false.
+     call getin_p("specOLR",specOLR)
+     write(*,*)" specOLR = ",specOLR
+
+     write(*,*)"Operate in kastprof mode?"
+     kastprof=.false.
+     call getin_p("kastprof",kastprof)
+     write(*,*)" kastprof = ",kastprof
+
+     write(*,*)"Uniform absorption in radiative transfer?"
+     graybody=.false.
+     call getin_p("graybody",graybody)
+     write(*,*)" graybody = ",graybody
+
+! Soil model
+     write(*,*)"Number of sub-surface layers for soil scheme?"
+     ! default value of nsoilmx set in comsoil_h
+     call getin_p("nsoilmx",nsoilmx)
+     write(*,*)" nsoilmx=",nsoilmx
+     
+     write(*,*)"Thickness of topmost soil layer (m)?"
+     ! default value of lay1_soil set in comsoil_h
+     call getin_p("lay1_soil",lay1_soil)
+     write(*,*)" lay1_soil = ",lay1_soil
+     
+     write(*,*)"Coefficient for soil layer thickness distribution?"
+     ! default value of alpha_soil set in comsoil_h
+     call getin_p("alpha_soil",alpha_soil)
+     write(*,*)" alpha_soil = ",alpha_soil
+
+! Slab Ocean 
+     write(*,*) "Use slab-ocean ?"
+     ok_slab_ocean=.false.         ! default value
+     call getin_p("ok_slab_ocean",ok_slab_ocean)
+     write(*,*) "ok_slab_ocean = ",ok_slab_ocean
+     ! Sanity check: for now slab oncean only works in serial mode
+     if (ok_slab_ocean.and.is_parallel) then
+       write(*,*) " Error: slab ocean should only be used in serial mode!"
+       call abort
+     endif
+
+     write(*,*) "Use slab-sea-ice ?"
+     ok_slab_sic=.true.         ! default value
+     call getin_p("ok_slab_sic",ok_slab_sic)
+     write(*,*) "ok_slab_sic = ",ok_slab_sic
+
+     write(*,*) "Use heat transport for the ocean ?"
+     ok_slab_heat_transp=.true.   ! default value
+     call getin_p("ok_slab_heat_transp",ok_slab_heat_transp)
+     write(*,*) "ok_slab_heat_transp = ",ok_slab_heat_transp
+
+
+
+! Test of incompatibility:
+! if kastprof used, we must be in 1D
+     if (kastprof.and.(ngrid.gt.1)) then
+       print*,'kastprof can only be used in 1D!'
+       call abort
+     endif
+
+     write(*,*)"Stratospheric temperature for kastprof mode?"
+     Tstrat=167.0
+     call getin_p("Tstrat",Tstrat)
+     write(*,*)" Tstrat = ",Tstrat
+
+     write(*,*)"Remove lower boundary?"
+     nosurf=.false.
+     call getin_p("nosurf",nosurf)
+     write(*,*)" nosurf = ",nosurf
+
+! Tests of incompatibility:
+     if (nosurf.and.callsoil) then
+       print*,'nosurf not compatible with soil scheme!'
+       print*,'... got to make a choice!'
+       call abort
+     endif
+
+     write(*,*)"Add an internal heat flux?", &
+                   "... matters only if callsoil=F"
+     intheat=0.
+     call getin_p("intheat",intheat)
+     write(*,*)" intheat = ",intheat
+
+     write(*,*)"Use Newtonian cooling for radiative transfer?"
+     newtonian=.false.
+     call getin_p("newtonian",newtonian)
+     write(*,*)" newtonian = ",newtonian
+
+! Tests of incompatibility:
+     if (newtonian.and.corrk) then
+       print*,'newtonian not compatible with correlated-k!'
+       call abort
+     endif
+     if (newtonian.and.calladj) then
+       print*,'newtonian not compatible with adjustment!'
+       call abort
+     endif
+     if (newtonian.and.calldifv) then
+       print*,'newtonian not compatible with a boundary layer!'
+       call abort
+     endif
+
+     write(*,*)"Test physics timescale in 1D?"
+     testradtimes=.false.
+     call getin_p("testradtimes",testradtimes)
+     write(*,*)" testradtimes = ",testradtimes
+
+! Test of incompatibility:
+! if testradtimes used, we must be in 1D
+     if (testradtimes.and.(ngrid.gt.1)) then
+       print*,'testradtimes can only be used in 1D!'
+       call abort
+     endif
+
+     write(*,*)"Default planetary temperature?"
+     tplanet=215.0
+     call getin_p("tplanet",tplanet)
+     write(*,*)" tplanet = ",tplanet
+
+     write(*,*)"Which star?"
+     startype=1 ! default value = Sol
+     call getin_p("startype",startype)
+     write(*,*)" startype = ",startype
+
+     write(*,*)"Value of stellar flux at 1 AU?"
+     Fat1AU=1356.0 ! default value = Sol today
+     call getin_p("Fat1AU",Fat1AU)
+     write(*,*)" Fat1AU = ",Fat1AU
+
+
+! TRACERS:
+
+     write(*,*)"Varying H2O cloud fraction?"
+     CLFvarying=.false.     ! default value
+     call getin_p("CLFvarying",CLFvarying)
+     write(*,*)" CLFvarying = ",CLFvarying
+
+     write(*,*)"Value of fixed H2O cloud fraction?"
+     CLFfixval=1.0                ! default value
+     call getin_p("CLFfixval",CLFfixval)
+     write(*,*)" CLFfixval = ",CLFfixval
+
+     write(*,*)"fixed radii for Cloud particles?"
+     radfixed=.false. ! default value
+     call getin_p("radfixed",radfixed)
+     write(*,*)" radfixed = ",radfixed
+
+     if(kastprof)then
+        radfixed=.true.
+     endif  
+
+     write(*,*)"Number mixing ratio of CO2 ice particles:"
+     Nmix_co2=1.e6 ! default value
+     call getin_p("Nmix_co2",Nmix_co2)
+     write(*,*)" Nmix_co2 = ",Nmix_co2
+
+!         write(*,*)"Number of radiatively active aerosols:"
+!         naerkind=0. ! default value
+!         call getin_p("naerkind",naerkind)
+!         write(*,*)" naerkind = ",naerkind
+
+     write(*,*)"Opacity of dust (if used):"
+     dusttau=0. ! default value
+     call getin_p("dusttau",dusttau)
+     write(*,*)" dusttau = ",dusttau
+
+     write(*,*)"Radiatively active CO2 aerosols?"
+     aeroco2=.false.     ! default value
+     call getin_p("aeroco2",aeroco2)
+     write(*,*)" aeroco2 = ",aeroco2
+
+     write(*,*)"Fixed CO2 aerosol distribution?"
+     aerofixco2=.false.     ! default value
+     call getin_p("aerofixco2",aerofixco2)
+     write(*,*)" aerofixco2 = ",aerofixco2
+
+     write(*,*)"Radiatively active water ice?"
+     aeroh2o=.false.     ! default value
+     call getin_p("aeroh2o",aeroh2o)
+     write(*,*)" aeroh2o = ",aeroh2o
+
+     write(*,*)"Fixed H2O aerosol distribution?"
+     aerofixh2o=.false.     ! default value
+     call getin_p("aerofixh2o",aerofixh2o)
+     write(*,*)" aerofixh2o = ",aerofixh2o
+
+     write(*,*)"Radiatively active sulfuric acid aersols?"
+     aeroh2so4=.false.     ! default value
+     call getin_p("aeroh2so4",aeroh2so4)
+     write(*,*)" aeroh2so4 = ",aeroh2so4
+	 
+!=================================
+
+     write(*,*)"Radiatively active two-layer aersols?"
+     aeroback2lay=.false.     ! default value
+     call getin_p("aeroback2lay",aeroback2lay)
+     write(*,*)" aeroback2lay = ",aeroback2lay
+
+     write(*,*)"TWOLAY AEROSOL: total optical depth ", &
+                    "in the tropospheric layer (visible)"
+     obs_tau_col_tropo=8.D0
+     call getin_p("obs_tau_col_tropo",obs_tau_col_tropo)
+     write(*,*)" obs_tau_col_tropo = ",obs_tau_col_tropo
+
+     write(*,*)"TWOLAY AEROSOL: total optical depth ", &
+                    "in the stratospheric layer (visible)"
+     obs_tau_col_strato=0.08D0
+     call getin_p("obs_tau_col_strato",obs_tau_col_strato)
+     write(*,*)" obs_tau_col_strato = ",obs_tau_col_strato
+
+     write(*,*)"TWOLAY AEROSOL: pres_bottom_tropo? in pa"
+     pres_bottom_tropo=66000.0
+     call getin_p("pres_bottom_tropo",pres_bottom_tropo)
+     write(*,*)" pres_bottom_tropo = ",pres_bottom_tropo
+
+     write(*,*)"TWOLAY AEROSOL: pres_top_tropo? in pa"
+     pres_top_tropo=18000.0
+     call getin_p("pres_top_tropo",pres_top_tropo)
+     write(*,*)" pres_top_tropo = ",pres_top_tropo
+
+     write(*,*)"TWOLAY AEROSOL: pres_bottom_strato? in pa"
+     pres_bottom_strato=2000.0
+     call getin_p("pres_bottom_strato",pres_bottom_strato)
+     write(*,*)" pres_bottom_strato = ",pres_bottom_strato
+
+     write(*,*)"TWOLAY AEROSOL: pres_top_strato? in pa"
+     pres_top_strato=100.0
+     call getin_p("pres_top_strato",pres_top_strato)
+     write(*,*)" pres_top_strato = ",pres_top_strato
+
+     write(*,*)"TWOLAY AEROSOL: particle size in the ", &
+                    "tropospheric layer, in meters"
+     size_tropo=2.e-6
+     call getin_p("size_tropo",size_tropo)
+     write(*,*)" size_tropo = ",size_tropo
+
+     write(*,*)"TWOLAY AEROSOL: particle size in the ", &
+                    "stratospheric layer, in meters"
+     size_strato=1.e-7
+     call getin_p("size_strato",size_strato)
+     write(*,*)" size_strato = ",size_strato
+
+!=================================
+
+     write(*,*)"Cloud pressure level (with kastprof only):"
+     cloudlvl=0. ! default value
+     call getin_p("cloudlvl",cloudlvl)
+     write(*,*)" cloudlvl = ",cloudlvl
+
+     write(*,*)"Is the variable gas species radiatively active?"
+     Tstrat=167.0
+     varactive=.false.
+     call getin_p("varactive",varactive)
+     write(*,*)" varactive = ",varactive
+
+     write(*,*)"Is the variable gas species distribution set?"
+     varfixed=.false.
+     call getin_p("varfixed",varfixed)
+     write(*,*)" varfixed = ",varfixed
+
+     write(*,*)"What is the saturation % of the variable species?"
+     satval=0.8
+     call getin_p("satval",satval)
+     write(*,*)" satval = ",satval
+
+
+! Test of incompatibility:
+! if varactive, then varfixed should be false
+     if (varactive.and.varfixed) then
+       print*,'if varactive, varfixed must be OFF!'
+       stop
+     endif
+
+     write(*,*) "Gravitationnal sedimentation ?"
+     sedimentation=.false. ! default value
+     call getin_p("sedimentation",sedimentation)
+     write(*,*) " sedimentation = ",sedimentation
+
+     write(*,*) "Compute water cycle ?"
+     water=.false. ! default value
+     call getin_p("water",water)
+     write(*,*) " water = ",water
+         
+! Test of incompatibility:
+! if water is true, there should be at least a tracer
+     if (water.and.(.not.tracer)) then
+        print*,'if water is ON, tracer must be ON too!'
+        stop
+     endif
+
+     write(*,*) "Include water condensation ?"
+     watercond=.false. ! default value
+     call getin_p("watercond",watercond)
+     write(*,*) " watercond = ",watercond
+
+! Test of incompatibility:
+! if watercond is used, then water should be used too
+     if (watercond.and.(.not.water)) then
+        print*,'if watercond is used, water should be used too'
+        stop
+     endif
+
+     write(*,*) "Include water precipitation ?"
+     waterrain=.false. ! default value
+     call getin_p("waterrain",waterrain)
+     write(*,*) " waterrain = ",waterrain
+
+     write(*,*) "Include surface hydrology ?"
+     hydrology=.false. ! default value
+     call getin_p("hydrology",hydrology)
+     write(*,*) " hydrology = ",hydrology
+
+     write(*,*) "Evolve surface water sources ?"
+     sourceevol=.false. ! default value
+     call getin_p("sourceevol",sourceevol)
+     write(*,*) " sourceevol = ",sourceevol
+
+     write(*,*) "Ice evolution timestep ?"
+     icetstep=100.0 ! default value
+     call getin_p("icetstep",icetstep)
+     write(*,*) " icetstep = ",icetstep
+         
+     write(*,*) "Spectral Dependant albedo ?"
+     albedo_spectral_mode=.false. ! default value
+     call getin_p("albedo_spectral_mode",albedo_spectral_mode)
+     write(*,*) " albedo_spectral_mode = ",albedo_spectral_mode
+
+     write(*,*) "Snow albedo ?"
+     write(*,*) "If albedo_spectral_mode=.true., then this "
+     write(*,*) "corresponds to the 0.5 microns snow albedo."
+     albedosnow=0.5         ! default value
+     call getin_p("albedosnow",albedosnow)
+     write(*,*) " albedosnow = ",albedosnow
+         
+     write(*,*) "CO2 ice albedo ?"
+     albedoco2ice=0.5       ! default value
+     call getin_p("albedoco2ice",albedoco2ice)
+     write(*,*) " albedoco2ice = ",albedoco2ice
+
+     write(*,*) "Maximum ice thickness ?"
+     maxicethick=2.0         ! default value
+     call getin_p("maxicethick",maxicethick)
+     write(*,*) " maxicethick = ",maxicethick
+
+     write(*,*) "Freezing point of seawater ?"
+     Tsaldiff=-1.8          ! default value
+     call getin_p("Tsaldiff",Tsaldiff)
+     write(*,*) " Tsaldiff = ",Tsaldiff
+
+     write(*,*) "Does user want to force cpp and mugaz?"
+     force_cpp=.false. ! default value
+     call getin_p("force_cpp",force_cpp)
+     write(*,*) " force_cpp = ",force_cpp
+
+     if (force_cpp) then
+       mugaz = -99999.
+       PRINT *,'MEAN MOLECULAR MASS in g mol-1 ?'
+       call getin_p("mugaz",mugaz)
+       IF (mugaz.eq.-99999.) THEN
+           PRINT *, "mugaz must be set if force_cpp = T"
+           STOP
+       ELSE
+           write(*,*) "mugaz=",mugaz
+       ENDIF
+       cpp = -99999.
+       PRINT *,'SPECIFIC HEAT CAPACITY in J K-1 kg-1 ?'
+       call getin_p("cpp",cpp)
+       IF (cpp.eq.-99999.) THEN
+           PRINT *, "cpp must be set if force_cpp = T"
+           STOP
+       ELSE
+           write(*,*) "cpp=",cpp
+       ENDIF
+!         else
+!           mugaz=8.314*1000./pr
+     endif ! of if (force_cpp)
+     call su_gases
+     call calc_cpp_mugaz
+
+     PRINT*,'--------------------------------------------'
+     PRINT*
+     PRINT*
+  ELSE
+     write(*,*)
+     write(*,*) 'Cannot read file callphys.def. Is it here ?'
+     stop
+  ENDIF ! of IF(iscallphys)
+
+  PRINT*
+  PRINT*,'inifis: daysec',daysec
+  PRINT*
+  PRINT*,'inifis: The radiative transfer is computed:'
+  PRINT*,'           each ',iradia,' physical time-step'
+  PRINT*,'        or each ',iradia*dtphys,' seconds'
+  PRINT*
+
+
+!-----------------------------------------------------------------------
+!     Some more initialization:
+!     ------------------------
+
+  ! Initializations for comgeomfi_h
+  totarea=SSUM(ngrid,parea,1)
+  call planetwide_sumval(parea,totarea_planet)
+
+  !! those are defined in comdiurn_h.F90
+  IF (.not.ALLOCATED(sinlat)) ALLOCATE(sinlat(ngrid))
+  IF (.not.ALLOCATED(coslat)) ALLOCATE(coslat(ngrid))
+  IF (.not.ALLOCATED(sinlon)) ALLOCATE(sinlon(ngrid))
+  IF (.not.ALLOCATED(coslon)) ALLOCATE(coslon(ngrid))
+
+  DO ig=1,ngrid
+     sinlat(ig)=sin(plat(ig))
+     coslat(ig)=cos(plat(ig))
+     sinlon(ig)=sin(plon(ig))
+     coslon(ig)=cos(plon(ig))
+  ENDDO
+
+  ! initialize variables in radinc_h
+  call ini_radinc_h(nlayer)
+ 
+  ! allocate "radcommon_h" arrays
+  call ini_radcommon_h()
+
+  ! allocate "comsoil_h" arrays
+  call ini_comsoil_h(ngrid)
+      
+  END SUBROUTINE inifis
+
+END MODULE inifis_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/iniorbit.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/iniorbit.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/iniorbit.F	(revision 1644)
@@ -0,0 +1,92 @@
+      SUBROUTINE iniorbit
+     $     (papoastr,pperiastr,pyear_day,pperi_day,pobliq)
+      
+      USE planete_mod, only: apoastr, periastr, year_day, obliquit,
+     &                       peri_day, e_elips, p_elips, timeperi
+      use comcstfi_mod, only: pi
+      IMPLICIT NONE
+
+!=======================================================================
+! Initialisation of orbital parameters (stored in planete_h module)
+!=======================================================================
+
+c   Arguments:
+c   ----------
+
+      REAL,INTENT(IN) :: papoastr,pperiastr,pyear_day,pperi_day,pobliq
+
+c   Local:
+c   ------
+
+      REAL zxref,zanom,zz,zx0,zdx
+      INTEGER iter
+
+c-----------------------------------------------------------------------
+
+      pi=2.*asin(1.)
+
+      apoastr =papoastr
+      periastr=pperiastr
+      year_day=pyear_day
+      obliquit=pobliq
+      peri_day=pperi_day
+
+
+      !!!! SPARADRAP TEMPORAIRE !!!!
+      !!!! SPARADRAP TEMPORAIRE !!!!
+      !!!! We hope that all cases are above 25 Mkm [OK with Gliese 581d]
+      IF ( apoastr .gt. 25.) THEN
+        PRINT*,'!!!!! WARNING !!!!!'
+        PRINT*,'!!!!! YOU ARE ABOUT TO WITNESS A DIRT HACK !!!!!'
+        PRINT*,'This must be an old start file.'
+        PRINT*,'The code changed 19/03/2012: we now use AU.'
+        PRINT*,'So I am assuming units are in Mkm here'
+        PRINT*,'and I am performing a conversion towards AU.'
+        periastr = periastr / 149.598 ! Mkm to AU
+        apoastr = apoastr / 149.598 ! Mkm to AU
+      ENDIF
+      !!!! SPARADRAP TEMPORAIRE !!!!
+      !!!! SPARADRAP TEMPORAIRE !!!!
+
+ 
+      PRINT*,'iniorbit: Periastron in AU  ',periastr
+      PRINT*,'iniorbit: Apoastron in AU  ',apoastr 
+      PRINT*,'iniorbit: Obliquity in degrees  :',obliquit
+
+
+      e_elips=(apoastr-periastr)/(periastr+apoastr)
+      p_elips=0.5*(periastr+apoastr)*(1-e_elips*e_elips)
+
+      print*,'iniorbit: e_elips',e_elips
+      print*,'iniorbit: p_elips',p_elips
+
+!-----------------------------------------------------------------------
+! compute polar angle and distance to the Sun:
+! -------------------------------------------------------
+
+!  compute mean anomaly zanom
+
+      zz=(year_day-pperi_day)/year_day
+      zanom=2.*pi*(zz-nint(zz))
+      zxref=abs(zanom)
+      PRINT*,'iniorbit: zanom  ',zanom
+
+!  solve equation  zx0 - e * sin (zx0) = zxref for eccentric anomaly zx0
+!  using Newton method
+
+      zx0=zxref+e_elips*sin(zxref)
+      DO iter=1,100
+         zdx=-(zx0-e_elips*sin(zx0)-zxref)/(1.-e_elips*cos(zx0))
+         if(abs(zdx).le.(1.e-12)) exit
+         zx0=zx0+zdx
+      ENDDO
+
+      zx0=zx0+zdx
+      if(zanom.lt.0.) zx0=-zx0
+      PRINT*,'iniorbit: zx0   ',zx0
+
+      timeperi=2.*atan(sqrt((1.+e_elips)/(1.-e_elips))*tan(zx0/2.))
+      PRINT*,'iniorbit: Perihelion solar long. Ls (deg)=',
+     &       360.-timeperi*180./pi
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/inistats.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/inistats.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/inistats.F	(revision 1644)
@@ -0,0 +1,140 @@
+      subroutine inistats(ierr)
+
+      use statto_mod, only: istats,istime
+      use mod_phys_lmdz_para, only : is_master
+      USE vertical_layers_mod, ONLY: ap,bp,aps,bps,preff,
+     &                               pseudoalt,presnivs
+      USE nrtype, ONLY: pi
+      USE time_phylmdz_mod, ONLY: daysec,dtphys
+      USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
+      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
+      implicit none
+
+      include "netcdf.inc"
+
+      integer,intent(out) :: ierr
+      integer :: nid
+      integer :: l,nsteppd
+      real, dimension(nbp_lev) ::  sig_s
+      real,allocatable :: lon_reg_ext(:) ! extended longitudes
+      integer :: idim_lat,idim_lon,idim_llm,idim_llmp1,idim_time
+      real, dimension(istime) :: lt
+      integer :: nvarid
+
+
+      IF (nbp_lon*nbp_lat==1) THEN
+        ! 1D model
+        ALLOCATE(lon_reg_ext(1))
+      ELSE
+        ! 3D model
+        ALLOCATE(lon_reg_ext(nbp_lon+1))
+      ENDIF
+      
+      write (*,*) 
+      write (*,*) '                        || STATS ||'
+      write (*,*) 
+      write (*,*) 'daysec',daysec
+      write (*,*) 'dtphys',dtphys
+      nsteppd=nint(daysec/dtphys)
+      write (*,*) 'nsteppd=',nsteppd
+      if (abs(float(nsteppd)-daysec/dtphys).gt.1.e-8*daysec)
+     &   stop'Dans Instat:  1jour .ne. n pas physiques'
+
+      if(mod(nsteppd,istime).ne.0)
+     &   stop'Dans Instat:  1jour .ne. n*istime pas physiques'
+
+      istats=nsteppd/istime
+      write (*,*) 'istats=',istats
+      write (*,*) 'Storing ',istime,'times per day'
+      write (*,*) 'thus every ',istats,'physical timestep '
+      write (*,*) 
+
+      do l= 1, nbp_lev
+         sig_s(l)=((ap(l)+ap(l+1))/preff+bp(l)+bp(l+1))/2.
+         pseudoalt(l)=-10.*log(presnivs(l)/preff)   
+      enddo
+      
+      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
+      IF (nbp_lon*nbp_lat/=1) THEN
+        ! In 3D, add extra redundant point (180 degrees,
+        ! since lon_reg starts at -180)
+        lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
+      ENDIF
+
+      if (is_master) then
+      ! only the master needs do this
+
+      ierr = NF_CREATE("stats.nc",IOR(NF_CLOBBER,NF_64BIT_OFFSET),nid)
+      if (ierr.ne.NF_NOERR) then
+         write (*,*) NF_STRERROR(ierr)
+         stop ""
+      endif
+
+      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_lat)
+      IF (nbp_lon*nbp_lat==1) THEN
+        ierr = NF_DEF_DIM (nid, "longitude", 1, idim_lon)
+      ELSE
+        ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_lon)
+      ENDIF
+      ierr = NF_DEF_DIM (nid, "altitude", nbp_lev, idim_llm)
+      ierr = NF_DEF_DIM (nid, "llmp1", nbp_lev+1, idim_llmp1)
+      ierr = NF_DEF_DIM (nid, "Time", NF_UNLIMITED, idim_time)
+
+      ierr = NF_ENDDEF(nid)
+      call def_var_stats(nid,"Time","Time",
+     &            "days since 0000-00-0 00:00:00",1,
+     &            idim_time,nvarid,ierr)
+! Time is initialised later by mkstats subroutine
+
+      call def_var_stats(nid,"latitude","latitude",
+     &            "degrees_north",1,idim_lat,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
+#endif
+      call def_var_stats(nid,"longitude","East longitude",
+     &            "degrees_east",1,idim_lon,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
+#endif
+
+! Niveaux verticaux, aps et bps
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid,"altitude", NF_DOUBLE, 1,idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid,"altitude", NF_FLOAT, 1,idim_llm,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",8,"altitude")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt)
+#endif 
+      call def_var_stats(nid,"aps","hybrid pressure at midlayers"
+     & ," ",1,idim_llm,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aps)
+#endif
+
+      call def_var_stats(nid,"bps","hybrid sigma at midlayers"
+     & ," ",1,idim_llm,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps)
+#else 
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bps)
+#endif
+
+      ierr=NF_CLOSE(nid)
+
+      endif ! of if (is_master)
+      end subroutine inistats
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/initracer.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/initracer.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/initracer.F	(revision 1644)
@@ -0,0 +1,343 @@
+      SUBROUTINE initracer(ngrid,nq,nametrac)
+
+      use surfdat_h
+      USE tracer_h
+      USE callkeys_mod, only: water
+      IMPLICIT NONE
+c=======================================================================
+c   subject:
+c   --------
+c   Initialization related to tracer 
+c   (transported dust, water, chemical species, ice...)
+c
+c   Name of the tracer
+c
+c   Test of dimension :
+c   Initialize COMMON tracer in tracer.h, using tracer names provided
+c   by the argument nametrac
+c
+c   author: F.Forget
+c   ------
+c            Ehouarn Millour (oct. 2008) identify tracers by their names
+c=======================================================================
+
+      integer :: ngrid,nq
+
+!      real qsurf(ngrid,nq)       ! tracer on surface (e.g.  kg.m-2)
+!      real co2ice(ngrid)           ! co2 ice mass on surface (e.g.  kg.m-2)
+      character(len=20) :: txt ! to store some text
+      integer iq,ig,count
+      real r0_lift , reff_lift
+!      logical :: oldnames ! =.true. if old tracer naming convention (q01,...)
+
+      character*20 nametrac(nq)   ! name of the tracer from dynamics
+
+
+c-----------------------------------------------------------------------
+c  radius(nq)      ! aerosol particle radius (m)
+c  rho_q(nq)       ! tracer densities (kg.m-3)
+c  qext(nq)        ! Single Scat. Extinction coeff at 0.67 um
+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
+c  doubleq           ! if method with mass (iq=1) and number(iq=2) mixing ratio
+c  varian            ! Characteristic variance of log-normal distribution
+c-----------------------------------------------------------------------
+
+       nqtot=nq
+       !! we allocate once for all arrays in common in tracer_h.F90
+       !! (supposedly those are not used before call to initracer)
+       IF (.NOT.ALLOCATED(noms)) ALLOCATE(noms(nq))
+       ALLOCATE(mmol(nq))
+       ALLOCATE(radius(nq))
+       ALLOCATE(rho_q(nq))
+       ALLOCATE(qext(nq))
+       ALLOCATE(alpha_lift(nq))
+       ALLOCATE(alpha_devil(nq))
+       ALLOCATE(qextrhor(nq))
+       ALLOCATE(igcm_dustbin(nq))
+       !! initialization
+       alpha_lift(:)=0.
+       alpha_devil(:)=0.
+
+! Initialization: get tracer names from the dynamics and check if we are
+!                 using 'old' tracer convention ('q01',q02',...)
+!                 or new convention (full tracer names)
+      ! check if tracers have 'old' names
+
+! copy tracer names from dynamics
+        do iq=1,nq
+          noms(iq)=nametrac(iq)
+        enddo
+
+
+! Identify tracers by their names: (and set corresponding values of mmol)
+      ! 0. initialize tracer indexes to zero:
+      ! NB: igcm_* indexes are commons in 'tracer.h'
+      do iq=1,nq
+        igcm_dustbin(iq)=0
+      enddo
+      igcm_dust_mass=0
+      igcm_dust_number=0
+      igcm_h2o_vap=0
+      igcm_h2o_ice=0
+      igcm_co2=0
+      igcm_co=0
+      igcm_o=0
+      igcm_o1d=0
+      igcm_o2=0
+      igcm_o3=0
+      igcm_h=0
+      igcm_h2=0
+      igcm_oh=0
+      igcm_ho2=0
+      igcm_h2o2=0
+      igcm_n2=0
+      igcm_ar=0
+      igcm_ar_n2=0
+      igcm_co2_ice=0
+
+      write(*,*) 'initracer: noms() ', noms
+
+
+      !print*,'Setting dustbin = 0 in initracer.F'
+      !dustbin=0
+
+      ! 1. find dust tracers
+      count=0
+!      if (dustbin.gt.0) then
+!        do iq=1,nq
+!          txt=" "
+!          write(txt,'(a4,i2.2)')'dust',count+1   
+!          if (noms(iq).eq.txt) then
+!            count=count+1
+!            igcm_dustbin(count)=iq
+!            mmol(iq)=100.
+!          endif
+!        enddo !do iq=1,nq
+!      endif ! of if (dustbin.gt.0)
+
+
+!      if (doubleq) then
+!        do iq=1,nq
+!          if (noms(iq).eq."dust_mass") then
+!            igcm_dust_mass=iq
+!            count=count+1
+!          endif
+!          if (noms(iq).eq."dust_number") then
+!            igcm_dust_number=iq
+!            count=count+1
+!          endif
+!        enddo
+!      endif ! of if (doubleq)
+      ! 2. find chemistry and water tracers
+      do iq=1,nq
+        if (noms(iq).eq."co2") then
+          igcm_co2=iq
+          mmol(igcm_co2)=44.
+          count=count+1
+!          write(*,*) 'co2: count=',count
+        endif
+        if (noms(iq).eq."co2_ice") then
+          igcm_co2_ice=iq
+          mmol(igcm_co2_ice)=44.
+          count=count+1
+!          write(*,*) 'co2_ice: count=',count
+        endif
+        if (noms(iq).eq."h2o_vap") then
+          igcm_h2o_vap=iq
+          mmol(igcm_h2o_vap)=18.
+          count=count+1
+!          write(*,*) 'h2o_vap: count=',count
+        endif
+        if (noms(iq).eq."h2o_ice") then
+          igcm_h2o_ice=iq
+          mmol(igcm_h2o_ice)=18.
+          count=count+1
+!          write(*,*) 'h2o_ice: count=',count
+        endif
+      enddo ! of do iq=1,nq
+      
+      ! check that we identified all tracers:
+      if (count.ne.nq) then
+        write(*,*) "initracer: found only ",count," tracers"
+        write(*,*) "               expected ",nq
+        do iq=1,count
+          write(*,*)'      ',iq,' ',trim(noms(iq))
+        enddo
+!        stop
+      else
+        write(*,*) "initracer: found all expected tracers, namely:"
+        do iq=1,nq
+          write(*,*)'      ',iq,' ',trim(noms(iq))
+        enddo
+      endif
+
+
+c------------------------------------------------------------
+c     Initialisation tracers ....
+c------------------------------------------------------------
+      call zerophys(nq,rho_q)
+
+      rho_dust=2500.  ! Mars dust density (kg.m-3)
+      rho_ice=920.    ! Water ice density (kg.m-3)
+      rho_co2=1620.   ! CO2 ice density (kg.m-3)
+
+
+
+c$$$      if (doubleq) then
+c$$$c       "doubleq" technique 
+c$$$c       -------------------
+c$$$c      (transport of mass and number mixing ratio)
+c$$$c       iq=1: Q mass mixing ratio, iq=2: N number mixing ratio
+c$$$
+c$$$        if( (nq.lt.2).or.(water.and.(nq.lt.3)) ) then
+c$$$          write(*,*)'initracer: nq is too low : nq=', nq
+c$$$          write(*,*)'water= ',water,' doubleq= ',doubleq   
+c$$$        end if
+c$$$
+c$$$        varian=0.637    ! Characteristic variance    
+c$$$        qext(igcm_dust_mass)=3.04   ! reference extinction at 0.67 um for ref dust
+c$$$        qext(igcm_dust_number)=3.04 ! reference extinction at 0.67 um for ref dust
+c$$$        rho_q(igcm_dust_mass)=rho_dust
+c$$$        rho_q(igcm_dust_number)=rho_dust
+c$$$
+c$$$c       Intermediate calcul for computing geometric mean radius r0
+c$$$c       as a function of mass and number mixing ratio Q and N
+c$$$c       (r0 = (r3n_q * Q/ N)
+c$$$        r3n_q = exp(-4.5*varian**2)*(3./4.)/(pi*rho_dust)
+c$$$
+c$$$c       Intermediate calcul for computing effective radius reff
+c$$$c       from geometric mean radius r0
+c$$$c       (reff = ref_r0 * r0)
+c$$$        ref_r0 = exp(2.5*varian**2)
+c$$$        
+c$$$c       lifted dust :
+c$$$c       '''''''''''
+c$$$        reff_lift = 3.e-6      !  Effective radius of lifted dust (m)
+c$$$        alpha_devil(igcm_dust_mass)=9.e-9   !  dust devil lift mass coeff
+c$$$        alpha_lift(igcm_dust_mass)=3.0e-15  !  Lifted mass coeff
+c$$$
+c$$$        r0_lift = reff_lift/ref_r0
+c$$$        alpha_devil(igcm_dust_number)=r3n_q*
+c$$$     &                        alpha_devil(igcm_dust_mass)/r0_lift**3
+c$$$        alpha_lift(igcm_dust_number)=r3n_q*
+c$$$     &                        alpha_lift(igcm_dust_mass)/r0_lift**3
+c$$$
+c$$$c       Not used:
+c$$$        radius(igcm_dust_mass) = 0.
+c$$$        radius(igcm_dust_number) = 0.
+c$$$
+c$$$      else
+
+
+c$$$       if (dustbin.gt.1) then
+c$$$        print*,'ATTENTION:',
+c$$$     $   ' properties of dust need input in initracer !!!'
+c$$$        stop
+c$$$
+c$$$       else if (dustbin.eq.1) then
+c$$$
+c$$$c       This will be used for 1 dust particle size:
+c$$$c       ------------------------------------------
+c$$$        radius(igcm_dustbin(1))=3.e-6
+c$$$        Qext(igcm_dustbin(1))=3.04
+c$$$        alpha_lift(igcm_dustbin(1))=0.0e-6
+c$$$        alpha_devil(igcm_dustbin(1))=7.65e-9
+c$$$        qextrhor(igcm_dustbin(1))=(3./4.)*Qext(igcm_dustbin(1))
+c$$$     &                         /(rho_dust*radius(igcm_dustbin(1)))
+c$$$        rho_q(igcm_dustbin(1))=rho_dust
+c$$$
+c$$$       endif
+c$$$!      end if    ! (doubleq)
+
+c     Initialization for water vapor
+c     ------------------------------
+      if(water) then
+         radius(igcm_h2o_vap)=0.
+         Qext(igcm_h2o_vap)=0.
+         alpha_lift(igcm_h2o_vap) =0.
+         alpha_devil(igcm_h2o_vap)=0.
+	 qextrhor(igcm_h2o_vap)= 0.
+
+c       "Dryness coefficient" controlling the evaporation and
+c        sublimation from the ground water ice (close to 1)
+c        HERE, the goal is to correct for the fact
+c        that the simulated permanent water ice polar caps
+c        is larger than the actual cap and the atmospheric
+c        opacity not always realistic.
+
+
+!         if(ngrid.eq.1)
+
+
+!     to be modified for BC+ version?
+
+         !! this is defined in surfdat_h.F90
+         IF (.not.ALLOCATED(dryness)) ALLOCATE(dryness(ngrid))
+         IF (.not.ALLOCATED(watercaptag)) ALLOCATE(watercaptag(ngrid))
+
+         do ig=1,ngrid
+           if (ngrid.ne.1) watercaptag(ig)=.false.
+           dryness(ig) = 1.
+         enddo
+
+
+
+
+!         IF (caps) THEN
+c Perennial H20 north cap defined by watercaptag=true (allows surface to be
+c hollowed by sublimation in vdifc).
+!         do ig=1,ngrid
+!           if (lati(ig)*180./pi.gt.84) then
+!             if (ngrid.ne.1) watercaptag(ig)=.true.
+!             dryness(ig) = 1.
+c Use the following cap definition for high spatial resolution (latitudinal bin <= 5 deg)
+c	      if (lati(ig)*180./pi.lt.85.and.long(ig).ge.0) then
+c	        if (ngrid.ne.1) watercaptag(ig)=.true.
+c               dryness(ig) = 1.
+c	      endif
+c             if (lati(ig)*180./pi.ge.85) then
+c               if (ngrid.ne.1) watercaptag(ig)=.true.
+c               dryness(ig) = 1.
+c	      endif
+!           endif  ! (lati>80 deg)
+!         end do ! (ngrid)
+!        ENDIF ! (caps)
+
+!         if(iceparty.and.(nq.ge.2)) then
+
+           radius(igcm_h2o_ice)=3.e-6
+           rho_q(igcm_h2o_ice)=rho_ice
+           Qext(igcm_h2o_ice)=0.
+!           alpha_lift(igcm_h2o_ice) =0.
+!           alpha_devil(igcm_h2o_ice)=0.
+           qextrhor(igcm_h2o_ice)= (3./4.)*Qext(igcm_h2o_ice) 
+     $       / (rho_ice*radius(igcm_h2o_ice))
+
+
+
+!         elseif(iceparty.and.(nq.lt.2)) then
+!            write(*,*) 'nq is too low : nq=', nq
+!            write(*,*) 'water= ',water,' iceparty= ',iceparty
+!         endif
+
+      end if  ! (water)
+
+c     Output for records:
+c     ~~~~~~~~~~~~~~~~~~
+      write(*,*)
+      Write(*,*) '******** initracer : dust transport parameters :'
+      write(*,*) 'alpha_lift = ', alpha_lift
+      write(*,*) 'alpha_devil = ', alpha_devil
+      write(*,*) 'radius  = ', radius
+!      if(doubleq) then
+!        write(*,*) 'reff_lift (um) =  ', reff_lift
+!        write(*,*) 'size distribution variance  = ', varian
+!        write(*,*) 'r3n_q , ref_r0 : ', r3n_q , ref_r0
+!      end if
+      write(*,*) 'Qext  = ', qext 
+      write(*,*)
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/iniwrite.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/iniwrite.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/iniwrite.F	(revision 1644)
@@ -0,0 +1,381 @@
+      SUBROUTINE iniwrite(nid,idayref,phis,area,nbplon,nbplat)
+
+      use comsoil_h, only: mlayer, nsoilmx
+      USE comcstfi_mod, only: g, mugaz, omeg, rad, rcp, pi 
+      USE vertical_layers_mod, ONLY: ap,bp,aps,bps,pseudoalt
+!      USE logic_mod, ONLY: fxyhypb,ysinus
+!      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
+      USE time_phylmdz_mod, ONLY: daysec, dtphys
+!      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
+      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Auteur:  L. Fairhead  ,  P. Le Van, Y. Wanherdrick, F. Forget
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   'Initialize' the diagfi.nc file: write down dimensions as well
+c   as time-independent fields (e.g: geopotential, mesh area, ...)
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+      include "netcdf.inc"
+
+c   Arguments:
+c   ----------
+
+      integer,intent(in) :: nid        ! NetCDF file ID
+      INTEGER*4,intent(in) :: idayref  ! date (initial date for this run)
+      real,intent(in) :: phis(nbplon,nbp_lat) ! surface geopotential
+      real,intent(in) :: area(nbplon,nbp_lat) ! mesh area (m2)
+      integer,intent(in) :: nbplon,nbplat ! sizes of area and phis arrays
+
+c   Local:
+c   ------
+      INTEGER length,l
+      parameter (length = 100)
+      REAL tab_cntrl(length) ! run parameters are stored in this array
+      INTEGER ierr
+      REAl,ALLOCATABLE :: lon_reg_ext(:) ! extended longitudes
+
+      integer :: nvarid,idim_index,idim_rlonv
+      integer :: idim_rlatu,idim_llmp1,idim_llm
+      integer :: idim_nsoilmx ! "subsurface_layers" dimension ID #
+      integer, dimension(2) :: id  
+c-----------------------------------------------------------------------
+
+      IF (nbp_lon*nbp_lat==1) THEN
+        ! 1D model
+        ALLOCATE(lon_reg_ext(1))
+      ELSE
+        ! 3D model
+        ALLOCATE(lon_reg_ext(nbp_lon+1))
+      ENDIF
+
+      DO l=1,length
+         tab_cntrl(l)=0.
+      ENDDO
+      tab_cntrl(1)  = real(nbp_lon)
+      tab_cntrl(2)  = real(nbp_lat-1)
+      tab_cntrl(3)  = real(nbp_lev)
+      tab_cntrl(4)  = real(idayref)
+      tab_cntrl(5)  = rad
+      tab_cntrl(6)  = omeg
+      tab_cntrl(7)  = g
+      tab_cntrl(8)  = mugaz
+      tab_cntrl(9)  = rcp
+      tab_cntrl(10) = daysec
+      tab_cntrl(11) = dtphys
+!      tab_cntrl(12) = etot0
+!      tab_cntrl(13) = ptot0
+!      tab_cntrl(14) = ztot0
+!      tab_cntrl(15) = stot0
+!      tab_cntrl(16) = ang0
+c
+c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
+c         .....        parametres  pour le zoom          ......   
+!      tab_cntrl(17)  = clon
+!      tab_cntrl(18)  = clat
+!      tab_cntrl(19)  = grossismx
+!      tab_cntrl(20)  = grossismy
+c
+c     .....   ajout  le 6/05/97 et le 15/10/97  .......
+c
+!      IF ( fxyhypb )   THEN
+!        tab_cntrl(21) = 1.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!      ELSE
+!        tab_cntrl(21) = 0.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!        tab_cntrl(24) = 0.
+!        IF( ysinus )  tab_cntrl(24) = 1.
+!      ENDIF
+
+c    .........................................................
+
+! Define dimensions
+    
+      ierr = NF_REDEF (nid)
+
+      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
+!      ierr = NF_DEF_DIM (nid, "rlonu", iip1, idim_rlonu)
+      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
+      IF (nbp_lon*nbp_lat==1) THEN
+        ierr = NF_DEF_DIM (nid, "longitude", 1, idim_rlonv)
+      ELSE
+        ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv)
+      ENDIF
+!      ierr = NF_DEF_DIM (nid, "rlatv", jjm, idim_rlatv)
+      ierr = NF_DEF_DIM (nid, "interlayer", (nbp_lev+1), idim_llmp1)
+      ierr = NF_DEF_DIM (nid, "altitude", nbp_lev, idim_llm)
+      ierr = NF_DEF_DIM (nid,"subsurface_layers",nsoilmx,idim_nsoilmx)
+c
+      ierr = NF_ENDDEF(nid)
+
+c  Contol parameters for this run
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, 
+     .       idim_index,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, 
+     .       idim_index,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
+     .                       "Control parameters")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+
+c --------------------------
+c  longitudes and latitudes
+!
+!      ierr = NF_REDEF (nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_DEF_VAR (nid, "rlonu", NF_DOUBLE, 1, idim_rlonu,nvarid)
+!#else
+!      ierr = NF_DEF_VAR (nid, "rlonu", NF_FLOAT, 1, idim_rlonu,nvarid)
+!#endif
+!      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 21,
+!     .                       "Longitudes at u nodes")
+!      ierr = NF_ENDDEF(nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlonu/pi*180)
+!#else
+!      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlonu/pi*180)
+!#endif
+c
+c --------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid, "latitude", NF_DOUBLE, 1, idim_rlatu,nvarid)
+#else
+      ierr =NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim_rlatu,nvarid)
+#endif
+      ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "North latitude")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
+#endif
+c
+c --------------------------
+      
+      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
+      IF (nbp_lon*nbp_lat/=1) THEN
+        ! In 3D, add extra redundant point (180 degrees,
+        ! since lon_reg starts at -180)
+        lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
+      ENDIF
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "East longitude")
+      ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
+#endif
+c
+c --------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "altitude", NF_DOUBLE, 1, 
+     .       idim_llm,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "altitude", NF_FLOAT, 1, 
+     .       idim_llm,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name",10,"pseudo-alt")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'units',2,"km")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,'positive',2,"up")
+
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,pseudoalt)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,pseudoalt)
+#endif
+c
+c --------------------------
+!      ierr = NF_REDEF (nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_DEF_VAR (nid, "rlatv", NF_DOUBLE, 1, idim_rlatv,nvarid)
+!#else
+!      ierr = NF_DEF_VAR (nid, "rlatv", NF_FLOAT, 1, idim_rlatv,nvarid)
+!#endif
+!      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 20,
+!     .                       "Latitudes at v nodes")
+!      ierr = NF_ENDDEF(nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,rlatv/pi*180)
+!#else
+!      ierr = NF_PUT_VAR_REAL (nid,nvarid,rlatv/pi*180)
+!#endif
+c
+c --------------------------
+c  Vertical levels
+      call def_var(nid,"aps","hybrid pressure at midlayers ","Pa",
+     .            1,idim_llm,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,aps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,aps)
+#endif
+
+      call def_var(nid,"bps","hybrid sigma at midlayers"," ",
+     .            1,idim_llm,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bps)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bps)
+#endif
+
+      call def_var(nid,"ap","hybrid pressure at interlayers","Pa",
+     .            1,idim_llmp1,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,ap)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,ap)
+#endif
+
+      call def_var(nid,"bp","hybrid sigma at interlayers"," ",
+     .            1,idim_llmp1,nvarid,ierr)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,bp)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,bp)
+#endif
+
+!-------------------------------
+! (soil) depth variable mlayer() (known from comsoil_h)
+!-------------------------------
+      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
+      ! define variable
+#ifdef NC_DOUBLE
+      ierr=NF_DEF_VAR(nid,"soildepth",NF_DOUBLE,1,idim_nsoilmx,nvarid)
+#else
+      ierr=NF_DEF_VAR(nid,"soildepth",NF_FLOAT,1,idim_nsoilmx,nvarid)
+#endif
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 20,
+     .                        "Soil mid-layer depth")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",1,"m")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"positive",4,"down")
+      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
+      ! write variable
+#ifdef NC_DOUBLE
+      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,mlayer)
+#else
+      ierr=NF_PUT_VAR_REAL (nid,nvarid,mlayer)
+#endif
+
+c
+c --------------------------
+c  Mesh area and conversion coefficients cov. <-> contra. <--> natural
+
+!      id(1)=idim_rlonu
+!      id(2)=idim_rlatu
+c
+!      ierr = NF_REDEF (nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_DEF_VAR (nid, "cu", NF_DOUBLE, 2, id,nvarid)
+!#else
+!      ierr = NF_DEF_VAR (nid, "cu", NF_FLOAT, 2, id,nvarid)
+!#endif
+!      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40,
+!     .             "Conversion coefficients cov <--> natural")
+!      ierr = NF_ENDDEF(nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cu)
+!#else
+!      ierr = NF_PUT_VAR_REAL (nid,nvarid,cu)
+!#endif
+c
+!      id(1)=idim_rlonv
+!      id(2)=idim_rlatv
+c
+c --------------------------
+!      ierr = NF_REDEF (nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_DEF_VAR (nid, "cv", NF_DOUBLE, 2, id,nvarid)
+!#else
+!      ierr = NF_DEF_VAR (nid, "cv", NF_FLOAT, 2, id,nvarid)
+!#endif
+!      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 40,
+!     .             "Conversion coefficients cov <--> natural")
+!      ierr = NF_ENDDEF(nid)
+!#ifdef NC_DOUBLE
+!      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,cv)
+!#else
+!      ierr = NF_PUT_VAR_REAL (nid,nvarid,cv)
+!#endif
+c
+      id(1)=idim_rlonv
+      id(2)=idim_rlatu
+c
+c --------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "aire", NF_DOUBLE, 2, id,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "aire", NF_FLOAT, 2, id,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
+     .                       "Mesh area")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
+#endif
+c
+c  Surface geopotential
+      id(1)=idim_rlonv
+      id(2)=idim_rlatu
+c
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "phisinit", NF_DOUBLE, 2, id,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "phisinit", NF_FLOAT, 2, id,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 27,
+     .                       "Geopotential at the surface")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,phis)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,phis)
+#endif
+c
+
+      write(*,*)'iniwrite: nbp_lon,nbp_lat,nbp_lev,idayref',
+     & nbp_lon,nbp_lat,nbp_lev,idayref
+      write(*,*)'iniwrite: rad,omeg,g,mugaz,rcp',
+     & rad,omeg,g,mugaz,rcp
+      write(*,*)'iniwrite: daysec,dtphys',daysec,dtphys
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/iniwrite_specIR.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/iniwrite_specIR.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/iniwrite_specIR.F	(revision 1644)
@@ -0,0 +1,259 @@
+      SUBROUTINE iniwrite_specIR(nid,idayref,area,nbplon,nbplat)
+
+      use radinc_h, only: L_NSPECTI
+      use radcommon_h, only: WNOI,DWNI
+      use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, pi
+      use time_phylmdz_mod, only: daysec, dtphys
+!      USE logic_mod, ONLY: fxyhypb,ysinus
+!      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
+!      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
+      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
+
+      implicit none
+
+c=======================================================================
+c
+c   Auteur:  L. Fairhead  ,  P. Le Van, Y. Wanherdrick, F. Forget
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   'Initialize' the diagfi_spec.nc file: write down dimensions as well
+c   as time-independent fields (e.g: geopotential, mesh area, ...)
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+      include "netcdf.inc"
+
+c   Arguments:
+c   ----------
+
+      integer,intent(in) :: nid        ! NetCDF file ID
+      INTEGER*4,intent(in) :: idayref  ! date (initial date for this run)
+      real,intent(in) :: area(nbplon,nbplat) ! mesh area (m2)
+      integer,intent(in) :: nbplon,nbplat ! sizes of area
+
+c   Local:
+c   ------
+      INTEGER length,l
+      parameter (length = 100)
+      REAL tab_cntrl(length) ! run parameters are stored in this array
+      INTEGER ierr
+      REAl,ALLOCATABLE :: lon_reg_ext(:) ! extended longitudes
+
+      integer :: nvarid,idim_index,idim_rlonu,idim_rlonv
+      integer :: idim_rlatu,idim_rlatv,idim_llmp1,idim_llm
+ !     integer :: idim_nsoilmx ! "subsurface_layers" dimension ID #
+      integer :: idim_bandsIR ! "IR Wavenumber" dimension ID #
+      integer, dimension(2) :: id  
+
+c-----------------------------------------------------------------------
+
+      IF (nbp_lon*nbp_lat==1) THEN
+        ! 1D model
+        ALLOCATE(lon_reg_ext(1))
+      ELSE
+        ! 3D model
+        ALLOCATE(lon_reg_ext(nbp_lon+1))
+      ENDIF
+
+      DO l=1,length
+         tab_cntrl(l)=0.
+      ENDDO
+      tab_cntrl(1)  = FLOAT(nbp_lon)
+      tab_cntrl(2)  = FLOAT(nbp_lat-1)
+      tab_cntrl(3)  = FLOAT(nbp_lev)
+      tab_cntrl(4)  = FLOAT(idayref)
+      tab_cntrl(5)  = rad
+      tab_cntrl(6)  = omeg
+      tab_cntrl(7)  = g
+      tab_cntrl(8)  = mugaz
+      tab_cntrl(9)  = rcp
+      tab_cntrl(10) = daysec
+      tab_cntrl(11) = dtphys
+!      tab_cntrl(12) = etot0
+!      tab_cntrl(13) = ptot0
+!      tab_cntrl(14) = ztot0
+!      tab_cntrl(15) = stot0
+!      tab_cntrl(16) = ang0
+c
+c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
+c         .....        parametres  pour le zoom          ......   
+!      tab_cntrl(17)  = clon
+!      tab_cntrl(18)  = clat
+!      tab_cntrl(19)  = grossismx
+!      tab_cntrl(20)  = grossismy
+c
+c     .....   ajout  le 6/05/97 et le 15/10/97  .......
+c
+!      IF ( fxyhypb )   THEN
+!        tab_cntrl(21) = 1.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!      ELSE
+!        tab_cntrl(21) = 0.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!        tab_cntrl(24) = 0.
+!        IF( ysinus )  tab_cntrl(24) = 1.
+!      ENDIF
+
+c    .........................................................
+
+! Define dimensions
+    
+      ierr = NF_REDEF (nid)
+
+      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
+      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
+      IF (nbp_lon*nbp_lat==1) THEN
+        ierr = NF_DEF_DIM (nid, "longitude", 1, idim_rlonv)
+      ELSE
+        ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv)
+      ENDIF
+      ierr = NF_DEF_DIM (nid, "IR_Wavenumber",L_NSPECTI,idim_bandsIR)
+
+      ierr = NF_ENDDEF(nid)
+
+c  Contol parameters for this run
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, 
+     .       idim_index,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, 
+     .       idim_index,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
+     .                       "Control parameters")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+
+c --------------------------
+c  longitudes and latitudes
+
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid, "latitude", NF_DOUBLE, 1, idim_rlatu,nvarid)
+#else
+      ierr =NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim_rlatu,nvarid)
+#endif
+      ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "North latitude")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
+#endif
+c
+c --------------------------
+      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
+      !add extra redundant point (180 degrees, since lon_reg starts at -180
+      IF (nbp_lon*nbp_lat/=1) THEN
+        ! In 3D, add extra redundant point (180 degrees,
+        ! since lon_reg starts at -180)
+        lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
+      ENDIF
+      
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "East longitude")
+      ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
+#endif
+c
+
+!-------------------------------
+! Number of bands in the IR
+!-------------------------------
+
+      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
+      ! define variable
+#ifdef NC_DOUBLE
+      ierr=NF_DEF_VAR(nid,"IR_Wavenumber",NF_DOUBLE,1,
+     .                                idim_bandsIR,nvarid)
+#else
+      ierr=NF_DEF_VAR(nid,"IR_Wavenumber",NF_FLOAT,1,
+     .                                idim_bandsIR,nvarid)
+#endif
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 34,
+     .                        "Band mid frequency in the infrared")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",5,"cm^-1")
+      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
+      ! write variable
+#ifdef NC_DOUBLE
+      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,dble(WNOI))
+#else
+      ierr=NF_PUT_VAR_REAL (nid,nvarid,real(WNOI))
+#endif
+
+!-------------------------------
+! Width of bands in the IR
+!-------------------------------
+
+      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
+      ! define variable
+#ifdef NC_DOUBLE
+      ierr=NF_DEF_VAR(nid,"IR_Bandwidth",NF_DOUBLE,1,
+     .                                idim_bandsIR,nvarid)
+#else
+      ierr=NF_DEF_VAR(nid,"IR_Bandwidth",NF_FLOAT,1,
+     .                                idim_bandsIR,nvarid)
+#endif
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 25,
+     .                        "Bandwidth in the infrared")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",5,"cm^-1")
+      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
+      ! write variable
+#ifdef NC_DOUBLE
+      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,dble(DWNI))
+#else
+      ierr=NF_PUT_VAR_REAL (nid,nvarid,real(DWNI))
+#endif
+c
+c --------------------------
+c  Mesh area and conversion coefficients cov. <-> contra. <--> natural
+
+
+      id(1)=idim_rlonv
+      id(2)=idim_rlatu
+c
+c --------------------------
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "aire", NF_DOUBLE, 2, id,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "aire", NF_FLOAT, 2, id,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
+     .                       "Mesh area")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
+#endif
+
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/iniwrite_specVI.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/iniwrite_specVI.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/iniwrite_specVI.F	(revision 1644)
@@ -0,0 +1,260 @@
+      SUBROUTINE iniwrite_specVI(nid,idayref,area,nbplon,nbplat)
+
+      use radinc_h, only: L_NSPECTV
+      use radcommon_h, only: WNOV,DWNV
+      use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, pi
+      use time_phylmdz_mod, only: daysec, dtphys
+!      USE logic_mod, ONLY: fxyhypb,ysinus
+!      USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy
+!      USE ener_mod, ONLY: etot0,ptot0,ztot0,stot0,ang0
+      USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
+      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, nbp_lev
+
+      implicit none
+
+c=======================================================================
+c
+c   Auteur:  L. Fairhead  ,  P. Le Van, Y. Wanherdrick, F. Forget
+c   -------
+c
+c   Objet:
+c   ------
+c
+c   'Initialize' the diagfi_spec.nc file: write down dimensions as well
+c   as time-independent fields (e.g: geopotential, mesh area, ...)
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+      include "netcdf.inc"
+
+c   Arguments:
+c   ----------
+
+      integer,intent(in) :: nid        ! NetCDF file ID
+      INTEGER*4,INTENT(IN) :: idayref  ! date (initial date for this run)
+      real,intent(in) :: area(nbplon,nbplat) ! mesh area (m2)
+      integer,intent(in) :: nbplon,nbplat ! sizes of area
+
+c   Local:
+c   ------
+      INTEGER length,l
+      parameter (length = 100)
+      REAL tab_cntrl(length) ! run parameters are stored in this array
+      INTEGER ierr
+      REAl,ALLOCATABLE :: lon_reg_ext(:) ! extended longitudes
+
+      integer :: nvarid,idim_index,idim_rlonu,idim_rlonv
+      integer :: idim_rlatu,idim_rlatv,idim_llmp1,idim_llm
+ !     integer :: idim_nsoilmx ! "subsurface_layers" dimension ID #
+      integer :: idim_bandsVI ! "VI Wavenumber" dimension ID #
+      integer, dimension(2) :: id  
+
+c-----------------------------------------------------------------------
+
+      IF (nbp_lon*nbp_lat==1) THEN
+        ! 1D model
+        ALLOCATE(lon_reg_ext(1))
+      ELSE
+        ! 3D model
+        ALLOCATE(lon_reg_ext(nbp_lon+1))
+      ENDIF
+
+      DO l=1,length
+         tab_cntrl(l)=0.
+      ENDDO
+      tab_cntrl(1)  = FLOAT(nbp_lon)
+      tab_cntrl(2)  = FLOAT(nbp_lat-1)
+      tab_cntrl(3)  = FLOAT(nbp_lev)
+      tab_cntrl(4)  = FLOAT(idayref)
+      tab_cntrl(5)  = rad
+      tab_cntrl(6)  = omeg
+      tab_cntrl(7)  = g
+      tab_cntrl(8)  = mugaz
+      tab_cntrl(9)  = rcp
+      tab_cntrl(10) = daysec
+      tab_cntrl(11) = dtphys
+!      tab_cntrl(12) = etot0
+!      tab_cntrl(13) = ptot0
+!      tab_cntrl(14) = ztot0
+!      tab_cntrl(15) = stot0
+!      tab_cntrl(16) = ang0
+c
+c    ..........    P.Le Van  ( ajout le 8/04/96 )    .........
+c         .....        parametres  pour le zoom          ......   
+!      tab_cntrl(17)  = clon
+!      tab_cntrl(18)  = clat
+!      tab_cntrl(19)  = grossismx
+!      tab_cntrl(20)  = grossismy
+c
+c     .....   ajout  le 6/05/97 et le 15/10/97  .......
+c
+!      IF ( fxyhypb )   THEN
+!        tab_cntrl(21) = 1.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!      ELSE
+!        tab_cntrl(21) = 0.
+!        tab_cntrl(22) = dzoomx
+!        tab_cntrl(23) = dzoomy
+!        tab_cntrl(24) = 0.
+!        IF( ysinus )  tab_cntrl(24) = 1.
+!      ENDIF
+
+c    .........................................................
+
+! Define dimensions
+    
+      ierr = NF_REDEF (nid)
+
+      ierr = NF_DEF_DIM (nid, "index", length, idim_index)
+      ierr = NF_DEF_DIM (nid, "latitude", nbp_lat, idim_rlatu)
+      IF (nbp_lon*nbp_lat==1) THEN
+        ierr = NF_DEF_DIM (nid, "longitude", 1, idim_rlonv)
+      ELSE
+        ierr = NF_DEF_DIM (nid, "longitude", nbp_lon+1, idim_rlonv)
+      ENDIF
+      ierr = NF_DEF_DIM (nid, "VI_Wavenumber",L_NSPECTV,idim_bandsVI)
+
+      ierr = NF_ENDDEF(nid)
+
+c  Contol parameters for this run
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "controle", NF_DOUBLE, 1, 
+     .       idim_index,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "controle", NF_FLOAT, 1, 
+     .       idim_index,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"title", 18,
+     .                       "Control parameters")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,tab_cntrl)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,tab_cntrl)
+#endif
+
+c --------------------------
+c  longitudes and latitudes
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid, "latitude", NF_DOUBLE, 1, idim_rlatu,nvarid)
+#else
+      ierr =NF_DEF_VAR (nid, "latitude", NF_FLOAT, 1, idim_rlatu,nvarid)
+#endif
+      ierr =NF_PUT_ATT_TEXT(nid,nvarid,'units',13,"degrees_north")
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "North latitude")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lat_reg/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lat_reg/pi*180)
+#endif
+c
+c --------------------------
+      lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
+      !add extra redundant point (180 degrees, since lon_reg starts at -180
+      IF (nbp_lon*nbp_lat/=1) THEN
+        ! In 3D, add extra redundant point (180 degrees,
+        ! since lon_reg starts at -180)
+        lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
+      ENDIF
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr =NF_DEF_VAR(nid,"longitude", NF_DOUBLE, 1, idim_rlonv,nvarid)
+#else
+      ierr = NF_DEF_VAR(nid,"longitude", NF_FLOAT, 1, idim_rlonv,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 14,
+     .      "East longitude")
+      ierr = NF_PUT_ATT_TEXT(nid,nvarid,'units',12,"degrees_east")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,lon_reg_ext/pi*180)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,lon_reg_ext/pi*180)
+#endif
+c
+
+!-------------------------------
+! Number of bands in the IR
+!-------------------------------
+
+      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
+      ! define variable
+#ifdef NC_DOUBLE
+      ierr=NF_DEF_VAR(nid,"VI_Wavenumber",NF_DOUBLE,1,
+     .                                idim_bandsVI,nvarid)
+#else
+      ierr=NF_DEF_VAR(nid,"VI_Wavenumber",NF_FLOAT,1,
+     .                                idim_bandsVI,nvarid)
+#endif
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 33,
+     .                        "Band mid frequency in the visible")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",5,"cm^-1")
+      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
+      ! write variable
+#ifdef NC_DOUBLE
+      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,dble(WNOV))
+#else
+      ierr=NF_PUT_VAR_REAL (nid,nvarid,real(WNOV))
+#endif
+
+c
+!-------------------------------
+! Width of bands in the Visible
+!-------------------------------
+
+      ierr=NF_REDEF (nid) ! Enter NetCDF (re-)define mode
+      ! define variable
+#ifdef NC_DOUBLE
+      ierr=NF_DEF_VAR(nid,"VI_Bandwidth",NF_DOUBLE,1,
+     .                                idim_bandsVI,nvarid)
+#else
+      ierr=NF_DEF_VAR(nid,"VI_Bandwidth",NF_FLOAT,1,
+     .                                idim_bandsVI,nvarid)
+#endif
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"long_name", 24,
+     .                        "Bandwidth in the visible")
+      ierr=NF_PUT_ATT_TEXT (nid,nvarid,"units",5,"cm^-1")
+      ierr=NF_ENDDEF(nid) ! Leave NetCDF define mode
+      ! write variable
+#ifdef NC_DOUBLE
+      ierr=NF_PUT_VAR_DOUBLE (nid,nvarid,dble(DWNV))
+#else
+      ierr=NF_PUT_VAR_REAL (nid,nvarid,real(DWNV))
+#endif
+c
+c --------------------------
+c   Mesh area
+c --------------------------
+
+      id(1)=idim_rlonv
+      id(2)=idim_rlatu
+
+
+      ierr = NF_REDEF (nid)
+#ifdef NC_DOUBLE
+      ierr = NF_DEF_VAR (nid, "aire", NF_DOUBLE, 2, id,nvarid)
+#else
+      ierr = NF_DEF_VAR (nid, "aire", NF_FLOAT, 2, id,nvarid)
+#endif
+      ierr = NF_PUT_ATT_TEXT (nid, nvarid, "title", 9,
+     .                       "Mesh area")
+      ierr = NF_ENDDEF(nid)
+#ifdef NC_DOUBLE
+      ierr = NF_PUT_VAR_DOUBLE (nid,nvarid,area)
+#else
+      ierr = NF_PUT_VAR_REAL (nid,nvarid,area)
+#endif
+
+
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/iniwritesoil.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/iniwritesoil.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/iniwritesoil.F90	(revision 1644)
@@ -0,0 +1,272 @@
+subroutine iniwritesoil(nid,ngrid,inertia,area,nbplon,nbplat)
+
+! initialization routine for 'writediagoil'. Here we create/define
+! dimensions (longitude, latitude, depth and time) and other fixed
+! (time-independent) parameters.
+
+use comsoil_h, only: mlayer, nsoilmx
+USE comcstfi_mod, only: pi
+USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
+use mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+
+implicit none
+
+include"netcdf.inc"
+
+! Arguments:
+integer,intent(in) :: ngrid
+integer,intent(in) :: nid ! NetCDF output file ID
+real,intent(in) :: inertia(nbplon,nbplat,nsoilmx)
+real,intent(in) :: area(nbplon,nbp_lat) ! mesh area (m2)
+integer,intent(in) :: nbplon,nbplat ! sizes of area
+
+! Local variables:
+
+! NetCDF stuff:
+integer :: ierr ! NetCDF routines return code
+integer :: idim_rlatu ! ID of the 'latitude' dimension
+integer :: idim_rlonv ! ID of the 'longitude' dimension
+integer :: idim_depth ! ID of the 'depth' dimension
+integer :: idim_time  ! ID of the 'time' dimension
+integer :: varid ! to store NetCDF ID of a variable
+integer,dimension(3) :: dimids ! to store IDs of dimensions of a variable
+character(len=60) :: text ! to store some text
+real,dimension(nbp_lon+1,nbp_lat,nsoilmx) :: data3 ! to store 3D data
+integer :: i,j,l,ig0
+real,allocatable :: lon_reg_ext(:) ! extended longitudes
+
+
+if (nbp_lon*nbp_lat==1) then
+  ! 1D model
+  allocate(lon_reg_ext(1))
+else
+  ! 3D model
+  allocate(lon_reg_ext(nbp_lon+1))
+endif
+
+! 1. Define the dimensions
+! Switch to NetCDF define mode
+ierr=NF_REDEF(nid)
+
+! Define the dimensions
+if (nbp_lon*nbp_lat==1) then
+  ierr=NF_DEF_DIM(nid,"longitude",1,idim_rlonv)
+else
+  ierr=NF_DEF_DIM(nid,"longitude",nbp_lon+1,idim_rlonv)
+endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define longitude dimension"
+endif
+ierr=NF_DEF_DIM(nid,"latitude",nbp_lat,idim_rlatu)
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define latitude dimension"
+endif
+ierr=NF_DEF_DIM(nid,"depth",nsoilmx,idim_depth)
+! nsoilmx known from comsoil_h
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define depth dimension"
+endif
+ierr=NF_DEF_DIM(nid,"time",NF_UNLIMITED,idim_time)
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define time dimension"
+endif
+
+! Switch out of NetCDF define mode
+ierr=NF_ENDDEF(nid)
+
+! 2. Define (as variables) and write dimensions, as well as their attributes
+! 2.1. Longitude
+ierr=NF_REDEF(nid) ! switch to NetCDF define mode
+
+! Define the variable
+#ifdef NC_DOUBLE
+ierr=NF_DEF_VAR(nid,"longitude",NF_DOUBLE,1,idim_rlonv,varid)
+#else
+ierr=NF_DEF_VAR(nid,"longitude",NF_FLOAT,1,idim_rlonv,varid)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define longitude variable"
+endif
+
+! Longitude attributes
+text="East longitude"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"long_name",len_trim(text),text)
+text="degrees_east"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
+
+lon_reg_ext(1:nbp_lon)=lon_reg(1:nbp_lon)
+if (nbp_lon*nbp_lat/=1) then ! in 3D only:
+  ! add extra redundant point (180 degrees, since lon_reg starts at -180
+  lon_reg_ext(nbp_lon+1)=-lon_reg_ext(1)
+endif
+
+! Write longitude to file
+ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
+! Write
+#ifdef NC_DOUBLE
+ierr=NF_PUT_VAR_DOUBLE(nid,varid,lon_reg_ext*(180./pi))
+#else
+ierr=NF_PUT_VAR_REAL(nid,varid,lon_reg_ext*(180./pi))
+#endif
+! Note: rlonv is known from comgeom.h and pi from comcstfi.h
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not write longitude variable"
+endif
+
+! 2.2. Latitude
+ierr=NF_REDEF(nid) ! switch to NetCDF define mode
+
+! Define the variable
+#ifdef NC_DOUBLE
+ierr=NF_DEF_VAR(nid,"latitude",NF_DOUBLE,1,idim_rlatu,varid)
+#else
+ierr=NF_DEF_VAR(nid,"latitude",NF_FLOAT,1,idim_rlatu,varid)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define latitude variable"
+endif
+
+! Latitude attributes
+text="North latitude"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"long_name",len_trim(text),text)
+text="degrees_north"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
+
+! Write latitude to file
+ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
+! Write
+#ifdef NC_DOUBLE
+ierr=NF_PUT_VAR_DOUBLE(nid,varid,lat_reg*(180./pi))
+#else
+ierr=NF_PUT_VAR_REAL(nid,varid,lat_reg*(180./pi))
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not write longitude variable"
+endif
+
+! 2.3. Depth
+ierr=NF_REDEF(nid) ! switch to NetCDF define mode
+
+! Define the variable
+#ifdef NC_DOUBLE
+ierr=NF_DEF_VAR(nid,"depth",NF_DOUBLE,1,idim_depth,varid)
+#else
+ierr=NF_DEF_VAR(nid,"depth",NF_FLOAT,1,idim_depth,varid)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define depth variable"
+endif
+
+! Depth attributes
+text="Soil mid-layer depth"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"long_name",len_trim(text),text)
+text="m"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
+text="down"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"positive",len_trim(text),text)
+
+! Write depth to file
+ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
+! Write
+#ifdef NC_DOUBLE
+ierr=NF_PUT_VAR_DOUBLE(nid,varid,mlayer)
+#else
+ierr=NF_PUT_VAR_REAL(nid,varid,mlayer)
+#endif
+! Note mlayer(0:nsoilmx-1) known from comsoil_h
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not write depth variable"
+endif
+
+! 2.4. Time
+ierr=NF_REDEF(nid) ! switch to NetCDF define mode
+
+! Define the variable
+#ifdef NC_DOUBLE
+ierr=NF_DEF_VAR(nid,"time",NF_DOUBLE,1,idim_time,varid)
+#else
+ierr=NF_DEF_VAR(nid,"time",NF_FLOAT,1,idim_time,varid)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define depth variable"
+endif
+
+! time attributes
+text="Time"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"long_name",len_trim(text),text)
+text="days since 0000-01-01 00:00:00"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
+
+ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
+! Note no need to write time variable here; it is done in writediagsoil.
+
+! 3. Other variables to be included
+
+! 3.1 mesh area surrounding each horizontal point
+ierr=NF_REDEF(nid) ! switch to NetCDF define mode
+
+! Define the variable
+dimids(1)=idim_rlonv ! ID of the 'longitude' dimension
+dimids(2)=idim_rlatu ! ID of the 'latitude' dimension
+#ifdef NC_DOUBLE
+ierr=NF_DEF_VAR(nid,"area",NF_DOUBLE,2,dimids,varid)
+#else
+ierr=NF_DEF_VAR(nid,"area",NF_FLOAT,2,dimids,varid)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define area variable"
+endif
+
+! Area attributes
+text="Mesh area"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"long_name",len_trim(text),text)
+text="m2"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
+
+! Write area to file
+ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
+! Write
+#ifdef NC_DOUBLE
+ierr=NF_PUT_VAR_DOUBLE(nid,varid,area)
+#else
+ierr=NF_PUT_VAR_REAL(nid,varid,area)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not write area variable"
+endif
+
+! 3.2 Thermal inertia
+ierr=NF_REDEF(nid) ! switch to NetCDF define mode
+
+! Define the variable
+dimids(1)=idim_rlonv ! ID of the 'longitude' dimension
+dimids(2)=idim_rlatu ! ID of the 'latitude' dimension
+dimids(3)=idim_depth ! ID of the 'depth' dimension
+#ifdef NC_DOUBLE
+ierr=NF_DEF_VAR(nid,"th_inertia",NF_DOUBLE,3,dimids,varid)
+#else
+ierr=NF_DEF_VAR(nid,"th_inertia",NF_FLOAT,3,dimids,varid)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not define th_inertia variable"
+endif
+
+! Attributes
+text="Thermal inertia"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"long_name",len_trim(text),text)
+text="J.s-1/2.m-2.K-1"
+ierr=NF_PUT_ATT_TEXT(nid,varid,"units",len_trim(text),text)
+
+! Write data2 to file
+ierr=NF_ENDDEF(nid) ! switch out of NetCDF define mode
+! Write
+#ifdef NC_DOUBLE
+ierr=NF_PUT_VAR_DOUBLE(nid,varid,inertia)
+#else
+ierr=NF_PUT_VAR_REAL(nid,varid,inertia)
+#endif
+if (ierr.ne.NF_NOERR) then
+  write(*,*)"iniwritesoil: Error, could not write th_inertia variable"
+endif
+
+end subroutine iniwritesoil
Index: /trunk/LMDZ.TITAN/libf/phytitan/interp_line.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/interp_line.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/interp_line.F	(revision 1644)
@@ -0,0 +1,55 @@
+      subroutine interp_line(x1,y1,len1,x2,y2,len2)
+      implicit none
+!-----------------------------------------------------------------------
+!
+!  Purpose: Do a series of linear interpolations
+!  Data sets are organized as vectors (see below)
+!  If x2(:), and abscissa at which interpolation is requiered, lies
+!  outside of the interval covered by x1(:), instead of doing an
+!  extrapolation, y2() is set to the value y1() corresponding to
+!  the nearby x1(:) point
+!  
+c-----------------------------------------------------------------------
+!  arguments
+!  ---------
+!  inputs:
+      real x1(len1) ! ordered list of abscissas
+      real y1(len1) ! values at x1(:)
+      integer len1  ! length of x1(:) and y1(:)
+      real x2(len2) !ordered list of abscissas at which interpolation is done
+      integer len2  ! length of x2(:) and y2(:)
+!  outputs:
+      real y2(len2) ! interpolated values
+!-----------------------------------------------------------------------
+
+! local variables:
+      integer i,j
+      
+
+      do i=1,len2
+        ! check if x2(i) lies outside of the interval covered by x1()
+        if(((x2(i).le.x1(1)).and.(x2(i).le.x1(len1))).or.
+     &     ((x2(i).ge.x1(1)).and.(x2(i).ge.x1(len1)))) then
+	  ! set y2(i) to y1(1) or y1(len1)
+	  if (abs(x2(i)-x1(1)).lt.abs(x2(i)-x1(len1))) then
+	    ! x2(i) lies closest to x1(1)
+	    y2(i)=y1(1)
+	  else
+	    ! x2(i) lies closest to x1(len1)
+	    y2(i)=y1(len1)
+	  endif
+
+	else
+        ! find the nearest neigbours and do a linear interpolation
+	 do j=1,len1-1
+          if(((x2(i).ge.x1(j)).and.(x2(i).le.x1(j+1))).or.
+     &       ((x2(i).le.x1(j)).and.(x2(i).ge.x1(j+1)))) then
+	    y2(i)=((x2(i)-x1(j))/(x1(j+1)-x1(j)))*y1(j+1)+
+     &            ((x2(i)-x1(j+1))/(x1(j)-x1(j+1)))*y1(j)
+	  endif
+	 enddo
+	endif
+
+      enddo
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2H2.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2H2.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2H2.F90	(revision 1644)
@@ -0,0 +1,128 @@
+     subroutine interpolateH2H2(wn,temp,pres,abcoef,firstcall,ind)
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates the H2-H2 CIA opacity, using a lookup table from
+!     HITRAN (2011)
+!
+!     Authors
+!     -------
+!     R. Wordsworth (2011)
+!     
+!==================================================================
+
+      use datafile_mod, only: datadir
+
+      implicit none
+
+      ! input
+      double precision wn                 ! wavenumber             (cm^-1)
+      double precision temp               ! temperature            (Kelvin)
+      double precision pres               ! pressure               (Pascals)
+
+      ! output
+      double precision abcoef             ! absorption coefficient (m^-1)
+
+      integer nS,nT
+      parameter(nS=2428)
+      parameter(nT=10)
+
+      double precision, parameter :: losch = 2.6867774e19
+      ! Loschmit's number (molecule cm^-3 at STP) 
+      ! converts cm^5 molecule^-2 --> cm^-1 amagat^-2
+      ! see Richard et al. 2011, JQSRT for details
+
+      double precision amagat
+      double precision wn_arr(nS)
+      double precision temp_arr(nT)
+      double precision abs_arr(nS,nT)
+
+      integer k,iT
+      logical firstcall
+
+      save wn_arr, temp_arr, abs_arr !read by master
+
+      character*100 dt_file
+      integer strlen,ios
+
+      character(LEN=*), parameter :: fmat1 = "(A20,F10.3,F10.3,I7,F7.1,E10.3,F5.3)"
+
+      character*20 bleh
+      double precision blah, Ttemp
+      integer nres
+
+      integer ind
+
+      if(temp.gt.400)then
+         print*,'Your temperatures are too high for this H2-H2 CIA dataset. If you '
+         print*,'really want to run simulations with hydrogen at T > 400 K, contact'
+         print*,'Robin Wordsworth [rwordsworth@uchicago.edu].'
+         stop
+      endif
+
+      amagat = (273.15/temp)*(pres/101325.0)
+
+      if(firstcall)then ! called by sugas_corrk only
+         print*,'----------------------------------------------------'
+         print*,'Initialising H2-H2 continuum from HITRAN database...'
+
+!     1.1 Open the ASCII files
+         dt_file=TRIM(datadir)//'/continuum_data/H2-H2_norm_2011.cia'
+
+!$OMP MASTER
+         open(33,file=dt_file,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from interpolateH2H2'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*) 'Check that your path to datagcm:',trim(datadir)
+           write(*,*) 'is correct. You can change it in callphys.def with:'
+           write(*,*) 'datadir = /absolute/path/to/datagcm'
+           write(*,*) 'Also check that the continuum data continuum_data/H2-H2_norm_2011.cia is there.'
+           call abort
+         else
+
+            do iT=1,nT
+
+               read(33,fmat1) bleh,blah,blah,nres,Ttemp
+               if(nS.ne.nres)then
+                  print*,'Resolution given in file: ',trim(dt_file)
+                  print*,'is ',nres,', which does not match nS.'
+                  print*,'Please adjust nS value in interpolateH2H2.F90'
+                  stop
+               endif
+               temp_arr(iT)=Ttemp
+
+               do k=1,nS
+                  read(33,*) wn_arr(k),abs_arr(k,it)
+               end do
+
+            end do
+      
+         endif
+         close(33)
+!$OMP END MASTER
+!$OMP BARRIER
+
+         print*,'interpolateH2H2: At wavenumber ',wn,' cm^-1'
+         print*,'   temperature ',temp,' K'
+         print*,'   pressure ',pres,' Pa'
+
+      endif
+
+         call bilinearbig(nS,nT,wn_arr,temp_arr,abs_arr,wn,temp,abcoef,ind)
+
+         !print*,'the absorption is ',abcoef,' cm^5 molecule^-2'
+         !print*,'or ',abcoef*losch**2,' cm^-1 amagat^-2'
+
+         abcoef=abcoef*losch**2*100.0*amagat**2 ! convert to m^-1
+
+         !print*,'We have ',amagat,' amagats of H2'
+         !print*,'So the absorption is ',abcoef,' m^-1'
+
+         ! unlike for Rayleigh scattering, we do not currently weight by the BB function
+         ! however our bands are normally thin, so this is no big deal.
+
+      return
+    end subroutine interpolateH2H2
Index: /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2He.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2He.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2He.F90	(revision 1644)
@@ -0,0 +1,132 @@
+     subroutine interpolateH2He(wn,temp,presH2,presHe,abcoef,firstcall,ind)
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates the H2-He CIA opacity, using a lookup table from
+!     HITRAN (2011)
+!
+!     Authors
+!     -------
+!     R. Wordsworth (2011)
+!     
+!==================================================================
+
+      use datafile_mod, only: datadir
+
+      implicit none
+
+      ! input
+      double precision wn                 ! wavenumber             (cm^-1)
+      double precision temp               ! temperature            (Kelvin)
+      double precision presH2             ! H2 partial pressure    (Pascals)
+      double precision presHe             ! He partial pressure    (Pascals)
+
+      ! output
+      double precision abcoef             ! absorption coefficient (m^-1)
+
+      integer nS,nT
+      parameter(nS=2428)
+      parameter(nT=10)
+
+      double precision, parameter :: losch = 2.6867774e19
+      ! Loschmit's number (molecule cm^-3 at STP) 
+      ! converts cm^5 molecule^-2 --> cm^-1 amagat^-2
+      ! see Richard et al. 2011, JQSRT for details
+
+      double precision amagatH2
+      double precision amagatHe
+      double precision wn_arr(nS)
+      double precision temp_arr(nT)
+      double precision abs_arr(nS,nT)
+
+      integer k,iT
+      logical firstcall
+
+      save wn_arr, temp_arr, abs_arr !read by master
+
+      character*100 dt_file
+      integer strlen,ios
+
+      character(LEN=*), parameter :: fmat1 = "(A20,F10.3,F10.3,I7,F7.1,E10.3,F5.3)"
+
+      character*20 bleh
+      double precision blah, Ttemp
+      integer nres
+
+      integer ind
+ 
+      if(temp.gt.400)then
+         print*,'Your temperatures are too high for this H2-He CIA dataset.'
+         print*,'Please run mixed H2-He atmospheres below T = 400 K.'      
+         stop
+      endif
+
+      amagatH2 = (273.15/temp)*(presH2/101325.0)
+      amagatHe = (273.15/temp)*(presHe/101325.0)
+
+      if(firstcall)then ! called by sugas_corrk only
+         print*,'----------------------------------------------------'
+         print*,'Initialising H2-He continuum from HITRAN database...'
+
+!     1.1 Open the ASCII files
+         dt_file=TRIM(datadir)//'/continuum_data/H2-He_norm_2011.cia'
+	 
+!$OMP MASTER
+         open(33,file=dt_file,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from interpolateH2He'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*) 'Check that your path to datagcm:',trim(datadir)
+           write(*,*) 'is correct. You can change it in callphys.def with:'
+           write(*,*) 'datadir = /absolute/path/to/datagcm'
+           write(*,*) 'Also check that the continuum data continuum_data/H2-He_norm_2011.cia is there.'
+           call abort
+         else
+
+            do iT=1,nT
+
+               read(33,fmat1) bleh,blah,blah,nres,Ttemp
+               if(nS.ne.nres)then
+                  print*,'Resolution given in file: ',trim(dt_file)
+                  print*,'is ',nres,', which does not match nS.'
+                  print*,'Please adjust nS value in interpolateH2He.F90'
+                  stop
+               endif
+               temp_arr(iT)=Ttemp
+
+               do k=1,nS
+                  read(33,*) wn_arr(k),abs_arr(k,it)
+               end do
+
+            end do
+      
+         endif
+         close(33)
+!$OMP END MASTER
+!$OMP BARRIER
+
+         print*,'interpolateH2He: At wavenumber ',wn,' cm^-1'
+         print*,'   temperature                 ',temp,' K'
+         print*,'   H2 partial pressure         ',presH2,' Pa'
+         print*,'   and He partial pressure     ',presHe,' Pa'
+
+      endif
+
+         call bilinearbig(nS,nT,wn_arr,temp_arr,abs_arr,wn,temp,abcoef,ind)
+
+         !print*,'the absorption is ',abcoef,' cm^5 molecule^-2'
+         !print*,'or ',abcoef*losch**2,' cm^-1 amagat^-2'
+
+         abcoef=abcoef*losch**2*100.0*amagatH2*amagatHe ! convert to m^-1
+
+         !print*,'We have ',amagatH2,' amagats of H2'
+         !print*,'and     ',amagatHe,' amagats of He'
+         !print*,'So the absorption is ',abcoef,' m^-1'
+
+         ! unlike for Rayleigh scattering, we do not currently weight by the BB function
+         ! however our bands are normally thin, so this is no big deal.
+
+      return
+    end subroutine interpolateH2He
Index: /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2Ocont_CKD.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2Ocont_CKD.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2Ocont_CKD.F90	(revision 1644)
@@ -0,0 +1,170 @@
+     subroutine interpolateH2Ocont_CKD(wn,temp,presS,presF,abcoef,firstcall,ind)
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates the H2O continuum opacity, using a lookup table from
+!     Clough (2005).
+!
+!     Authors
+!     -------
+!     R. Wordsworth (2011)
+!     
+!==================================================================
+
+      use datafile_mod, only: datadir
+      implicit none
+
+      ! input
+      double precision wn                 ! wavenumber             (cm^-1)
+      double precision temp               ! temperature            (Kelvin)
+      double precision presS              ! self-pressure          (Pascals)
+      double precision presF              ! foreign (air) pressure (Pascals)
+
+      ! output
+      double precision abcoef             ! absorption coefficient (m^-1)
+
+      integer nS,nT
+      parameter(nS=1001)
+      parameter(nT=11)
+
+      double precision kB
+      parameter(kB=1.3806488e-23)
+
+      double precision amagatS, amagatF, abcoefS, abcoefF, Nmolec
+      double precision wn_arr(nS)
+      double precision temp_arr(nT)
+      double precision abs_arrS(nS,nT)
+      double precision abs_arrF(nS,nT)
+      double precision data_tmp(nT)
+
+      integer k,ind
+      logical firstcall
+
+      save wn_arr, temp_arr, abs_arrS, abs_arrF !read by master
+
+      character*100 dt_file
+      integer strlen,ios
+
+      amagatS=(273.15/temp)*(presS/101325.0)
+      amagatF=(273.15/temp)*(presF/101325.0)
+
+      if(firstcall)then ! called by sugas_corrk only
+         print*,'----------------------------------------------------'
+         print*,'Initialising H2O continuum from MT_CKD data...'
+
+!     1.1 Open the ASCII files
+
+!$OMP MASTER
+         ! nu array
+         dt_file=TRIM(datadir)//'/continuum_data/H2O_CONT_NU.dat'
+         open(33,file=dt_file,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from interpolateH2O_cont'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2O_CONT_NU.dat there.'
+           call abort
+         else
+            do k=1,nS
+               read(33,*) wn_arr(k)
+            enddo
+         endif
+         close(33)
+
+         ! self broadening
+         dt_file=TRIM(datadir)//'/continuum_data/H2O_CONT_SELF.dat'
+         open(34,file=dt_file,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from interpolateH2O_cont'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2O_CONT_SELF.dat there.'
+           call abort
+         else
+            do k=1,nS
+               read(34,*) data_tmp
+               abs_arrS(k,1:nT)=data_tmp(1:nT)
+            end do
+         endif
+         close(34)
+
+         ! foreign (N2+O2+Ar) broadening
+         dt_file=TRIM(datadir)//'/continuum_data/H2O_CONT_FOREIGN.dat'
+         open(35,file=dt_file,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from interpolateH2O_cont'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2O_CONT_FOREIGN.dat there.'
+           call abort
+         else
+            do k=1,nS
+               read(35,*) data_tmp
+               abs_arrF(k,1:nT)=data_tmp(1:nT)
+            end do
+         endif
+         close(35)
+
+         temp_arr(1)  = 200.
+         temp_arr(2)  = 250.
+         temp_arr(3)  = 300.
+         temp_arr(4)  = 350.
+         temp_arr(5)  = 400.
+         temp_arr(6)  = 450.
+         temp_arr(7)  = 500.
+         temp_arr(8)  = 550.
+         temp_arr(9)  = 600.
+         temp_arr(10) = 650.
+         temp_arr(11) = 700.
+
+         print*,'interpolateH2Ocont: At wavenumber ',wn,' cm^-1'
+         print*,'   temperature ',temp,' K'
+         print*,'   H2O pressure ',presS,' Pa'
+         print*,'   air pressure ',presF,' Pa'
+!$OMP END MASTER
+!$OMP BARRIER
+	 
+      endif
+
+      call bilinearbig(nS,nT,wn_arr,temp_arr,abs_arrS,wn,temp,abcoefS,ind)
+!      print*,'the self absorption is ',abcoefS,' cm^2 molecule^-1'
+
+      call bilinearbig(nS,nT,wn_arr,temp_arr,abs_arrF,wn,temp,abcoefF,ind)
+!      print*,'the foreign absorption is ',abcoefF,' cm^2 molecule^-1'
+
+!      print*,'We have ',amagatS,' amagats of H2O vapour'
+!      print*,'and ',amagatF,' amagats of air'
+
+      abcoef = abcoefS*amagatS + abcoefF*amagatF ! Eq. (15) in Clough (1989)
+      abcoef = abcoef*(presS/(presF+presS))      ! take H2O mixing ratio into account
+                                                    ! abs coeffs are given per molecule of H2O
+
+      Nmolec = (presS+presF)/(kB*temp)           ! assume ideal gas
+!      print*,'Total number of molecules per m^3 is',Nmolec
+
+      abcoef = abcoef*Nmolec/(100.0**2)          ! convert to m^-1
+!      print*,'So the total absorption is ',abcoef,' m^-1'
+!      print*,'And optical depth / km : ',1000.0*abcoef
+
+
+      if(wn.gt.500 .and. wn.lt.1400)then
+      elseif(wn.gt.2100 .and. wn.lt.3000)then
+      else
+         abcoef = 0.0
+      endif
+
+      ! unlike for Rayleigh scattering, we do not currently weight by the BB function
+      ! however our bands are normally thin, so this is no big deal.
+
+
+      return
+    end subroutine interpolateH2Ocont_CKD
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2Ocont_PPC.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2Ocont_PPC.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/interpolateH2Ocont_PPC.F90	(revision 1644)
@@ -0,0 +1,84 @@
+     subroutine interpolateH2Ocont_PPC(wn,temp,presS,presF,abcoef,firstcall)
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates the H2O continuum opacity, using the formulae
+!     provided in Pierrehumbert, PPC (2010). As this is based on
+!     the CKD continuum, it provides a useful check for the 
+!     implementation of the more general interpolateH2Ocont_CKD.F90.
+!
+!     Authors
+!     -------
+!     R. Wordsworth (2012)
+!     
+!==================================================================
+
+      use watercommon_h, only: mH2O
+      use datafile_mod, only: datadir
+      implicit none
+
+      ! input
+      double precision wn                 ! wavenumber             (cm^-1)
+      double precision temp               ! temperature            (Kelvin)
+      double precision presS              ! self-pressure          (Pascals)
+      double precision presF              ! foreign (air) pressure (Pascals)
+
+      ! parameters
+      double precision, parameter :: T0 = 296.0
+      double precision, parameter :: p0 = 1.D+4
+
+      ! variables
+      double precision rho_w, x
+
+      ! output
+      double precision abcoef             ! absorption coefficient (m^-1)
+
+      logical firstcall
+
+      x = wn - 2500.
+
+      if(firstcall)then ! called by sugas_corrk only
+         print*,'----------------------------------------------------'
+         print*,'Testing H2O continuum...'
+
+         print*,'interpolateH2Ocont: At wavenumber ',wn,' cm^-1'
+         print*,'   temperature ',temp,' K'
+         print*,'   H2O pressure ',presS,' Pa'
+
+         rho_w = presS/((8.31446/(mH2O/1000.))*temp)
+
+         if(wn.gt.500 .and. wn.lt.1400)then
+            abcoef = exp(12.167 - 0.050898*wn + 8.3207e-5*wn**2 - 7.0748e-8*wn**3 + 2.3261e-11*wn**4)*(T0/temp)**4.25*(presS/p0)
+         elseif(wn.gt.2100 .and. wn.lt.3000)then
+            abcoef = exp(-6.0055 - 0.0021363*x + 6.4723e-7*x**2 - 1.493e-8*x**3 + 2.5621e-11*x**4 + 7.328e-14*x**5)*(T0/temp)**4.25*(presS/p0)
+         else
+            abcoef = 0.0
+         endif
+         abcoef = abcoef*rho_w
+
+         print*,'The self absorption is ',abcoef,' m^-1'
+         print*,'And optical depth / km : ',1000.0*abcoef
+
+      else
+
+         rho_w = presS/((8.31446/(mH2O/1000.))*temp)
+
+         if(wn.gt.500 .and. wn.lt.1400)then
+            abcoef = exp(12.167 - 0.050898*wn + 8.3207e-5*wn**2 - 7.0748e-8*wn**3 + 2.3261e-11*wn**4)*(T0/temp)**4.25*(presS/p0)
+         elseif(wn.gt.2100 .and. wn.lt.3000)then
+            abcoef = exp(-6.0055 - 0.0021363*x + 6.4723e-7*x**2 - 1.493e-8*x**3 + 2.5621e-11*x**4 + 7.328e-14*x**5)*(T0/temp)**4.25*(presS/p0)
+         else
+            abcoef = 0.0
+         endif
+         abcoef = abcoef*rho_w
+
+         ! unlike for Rayleigh scattering, we do not currently weight by the BB function
+         ! however our bands are normally thin, so this is no big deal.
+
+      endif
+
+      return
+    end subroutine interpolateH2Ocont_PPC
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/interpolateN2H2.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/interpolateN2H2.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/interpolateN2H2.F90	(revision 1644)
@@ -0,0 +1,133 @@
+subroutine interpolateN2H2(wn,temp,presN2,presH2,abcoef,firstcall,ind)
+
+  !==================================================================
+  !     
+  !     Purpose
+  !     -------
+  !     Calculates the N2-H2 CIA opacity, using a lookup table from
+  !     HITRAN (2011)
+  !
+  !     Authors
+  !     -------
+  !     R. Wordsworth (2011)
+  !     
+  !==================================================================
+
+  use datafile_mod, only: datadir
+  implicit none
+
+  ! input
+  double precision wn                 ! wavenumber             (cm^-1)
+  double precision temp               ! temperature            (Kelvin)
+  double precision presN2             ! N2 partial pressure    (Pascals)
+  double precision presH2             ! H2 partial pressure    (Pascals)
+
+  ! output
+  double precision abcoef             ! absorption coefficient (m^-1)
+
+  integer nS,nT
+  parameter(nS=1914)
+  parameter(nT=10)
+
+  double precision, parameter :: losch = 2.6867774e19
+  ! Loschmit's number (molecule cm^-3 at STP) 
+  ! converts cm^5 molecule^-2 --> cm^-1 amagat^-2
+  ! see Richard et al. 2011, JQSRT for details
+
+  double precision amagatN2
+  double precision amagatH2
+  double precision wn_arr(nS)
+  double precision temp_arr(nT)
+  double precision abs_arr(nS,nT)
+
+  integer k,iT
+  logical firstcall
+
+  save wn_arr, temp_arr, abs_arr !read by master
+
+  character*100 dt_file
+  integer strlen,ios
+
+  character(LEN=*), parameter :: fmat1 = "(A20,F10.3,F10.3,I7,F7.1,E10.3,F5.3)"
+
+  character*20 bleh
+  double precision blah, Ttemp
+  integer nres
+  integer ind
+
+  if(temp.gt.400)then
+     print*,'Your temperatures are too high for this N2-H2 CIA dataset.'
+     print*,'Please run mixed N2-H2 atmospheres below T = 400 K.'      
+     stop
+  endif
+
+  amagatN2 = (273.15/temp)*(presN2/101325.0)
+  amagatH2 = (273.15/temp)*(presH2/101325.0)
+
+  if(firstcall)then ! called by sugas_corrk only
+     print*,'----------------------------------------------------'
+     print*,'Initialising N2-H2 continuum from HITRAN database...'
+
+     !     1.1 Open the ASCII files
+     dt_file=TRIM(datadir)//'/continuum_data/N2-H2_2011.cia'
+
+!$OMP MASTER
+     open(33,file=dt_file,form='formatted',status='old',iostat=ios)
+     if (ios.ne.0) then        ! file not found
+        write(*,*) 'Error from interpolateN2H2'
+        write(*,*) 'Data file ',trim(dt_file),' not found.'
+        write(*,*) 'Check that your path to datagcm:',trim(datadir)
+        write(*,*) 'is correct. You can change it in callphys.def with:'
+        write(*,*) 'datadir = /absolute/path/to/datagcm'
+        write(*,*) 'Also check that the continuum data continuum_data/N2-H2_2011.cia is there.'
+        call abort
+     else
+
+        do iT=1,nT
+
+           read(33,fmat1) bleh,blah,blah,nres,Ttemp
+           if(nS.ne.nres)then
+              print*,'Resolution given in file: ',trim(dt_file)
+              print*,'is ',nres,', which does not match nS.'
+              print*,'Please adjust nS value in interpolateN2H2.F90'
+              stop
+           endif
+           temp_arr(iT)=Ttemp
+
+           do k=1,nS
+              read(33,*) wn_arr(k),abs_arr(k,it)
+           end do
+
+        end do
+
+     endif
+     close(33)
+!$OMP END MASTER
+!$OMP BARRIER
+
+     print*,'interpolateN2H2: At wavenumber ',wn,' cm^-1'
+     print*,'   temperature                 ',temp,' K'
+     print*,'   N2 partial pressure         ',presN2,' Pa'
+     print*,'   and H2 partial pressure     ',presH2,' Pa'
+
+  endif
+
+  call bilinearbig(nS,nT,wn_arr,temp_arr,abs_arr,wn,temp,abcoef,ind)
+
+!     print*,'the absorption is ',abcoef,' cm^5 molecule^-2'
+!     print*,'or ',abcoef*losch**2,' cm^-1 amagat^-2'
+
+  abcoef=abcoef*losch**2*100.0*amagatN2*amagatH2 ! convert to m^-1
+
+!     print*,'We have ',amagatN2,' amagats of N2'
+!     print*,'and     ',amagatH2,' amagats of H2'
+!     print*,'So the absorption is ',abcoef,' m^-1'
+
+
+!  unlike for Rayleigh scattering, we do not currently weight by the BB function
+!  however our bands are normally thin, so this is no big deal.
+
+
+  return
+end subroutine interpolateN2H2
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/interpolateN2N2.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/interpolateN2N2.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/interpolateN2N2.F90	(revision 1644)
@@ -0,0 +1,128 @@
+subroutine interpolateN2N2(wn,temp,pres,abcoef,firstcall,ind)
+
+  !==================================================================
+  !     
+  !     Purpose
+  !     -------
+  !     Calculates the N2-N2 CIA opacity, using a lookup table from
+  !     HITRAN (2011)
+  !
+  !     Authors
+  !     -------
+  !     R. Wordsworth (2011)
+  !     
+  !==================================================================
+
+  use datafile_mod, only: datadir
+  implicit none
+
+  ! input
+  double precision wn                 ! wavenumber             (cm^-1)
+  double precision temp               ! temperature            (Kelvin)
+  double precision pres               ! pressure               (Pascals)
+  integer :: ind
+
+  ! output
+  double precision abcoef             ! absorption coefficient (m^-1)
+
+  integer nS,nT
+  parameter(nS=582)
+  parameter(nT=10)
+
+  double precision, parameter :: losch = 2.6867774e19
+  ! Loschmit's number (molecule cm^-3 at STP) 
+  ! converts cm^5 molecule^-2 --> cm^-1 amagat^-2
+  ! see Richard et al. 2011, JQSRT for details
+
+  double precision amagat
+  double precision wn_arr(nS)
+  double precision temp_arr(nT)
+  double precision abs_arr(nS,nT)
+
+  integer k,iT
+  logical firstcall
+
+  save wn_arr, temp_arr, abs_arr !read by master
+
+  character*100 dt_file
+  integer strlen,ios
+
+  character(LEN=*), parameter :: fmat1 = "(A20,F10.3,F10.3,I7,F7.1,E10.3,F5.3)"
+
+  character*20 bleh
+  double precision blah, Ttemp
+  integer nres
+
+
+  if(temp.gt.400)then
+     print*,'Your temperatures are too high for this N2-N2 CIA dataset.'
+     print*,'Currently, HITRAN provides data for this pair in the range 40-400 K.'
+     stop
+  endif
+
+  amagat = (273.15/temp)*(pres/101325.0)
+
+  if(firstcall)then ! called by sugas_corrk only
+     print*,'----------------------------------------------------'
+     print*,'Initialising N2-N2 continuum from HITRAN database...'
+
+     !     1.1 Open the ASCII files
+     dt_file=TRIM(datadir)//'/continuum_data/N2-N2_2011.cia'
+
+!$OMP MASTER
+     open(33,file=dt_file,form='formatted',status='old',iostat=ios)
+     if (ios.ne.0) then        ! file not found
+        write(*,*) 'Error from interpolateN2N2'
+        write(*,*) 'Data file ',trim(dt_file),' not found.'
+        write(*,*) 'Check that your path to datagcm:',trim(datadir)
+        write(*,*) 'is correct. You can change it in callphys.def with:'
+        write(*,*) 'datadir = /absolute/path/to/datagcm'
+        write(*,*) 'Also check that the continuum data continuum_data/N2-N2_norm_2011.cia is there.'
+        call abort
+     else
+
+        do iT=1,nT
+
+           read(33,fmat1) bleh,blah,blah,nres,Ttemp
+           if(nS.ne.nres)then
+              print*,'Resolution given in file: ',trim(dt_file)
+              print*,'is ',nres,', which does not match nS.'
+              print*,'Please adjust nS value in interpolateN2N2.F90'
+              stop
+           endif
+           temp_arr(iT)=Ttemp
+
+           do k=1,nS
+              read(33,*) wn_arr(k),abs_arr(k,it)
+           end do
+
+        end do
+
+     endif
+     close(33)
+!$OMP END MASTER
+!$OMP BARRIER
+
+     print*,'interpolateN2N2: At wavenumber ',wn,' cm^-1'
+     print*,'   temperature ',temp,' K'
+     print*,'   pressure ',pres,' Pa'
+
+  endif
+     call bilinearbig(nS,nT,wn_arr,temp_arr,abs_arr,wn,temp,abcoef,ind)
+
+!     print*,'the absorption is ',abcoef,' cm^5 molecule^-2'
+!     print*,'or ',abcoef*losch**2,' cm^-1 amagat^-2'
+
+     abcoef=abcoef*losch**2*100.0*amagat**2 ! convert to m^-1
+!     abcoef=0.
+
+!     print*,'We have ',amagat,' amagats of N2'
+!     print*,'So the absorption is ',abcoef,' m^-1'
+
+!     unlike for Rayleigh scattering, we do not currently weight by the BB function
+!     however our bands are normally thin, so this is no big deal.
+
+
+  return
+end subroutine interpolateN2N2
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/iostart.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/iostart.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/iostart.F90	(revision 1644)
@@ -0,0 +1,1035 @@
+MODULE iostart
+
+    IMPLICIT NONE
+PRIVATE
+    INTEGER,SAVE :: nid_start ! NetCDF file identifier for startfi.nc file
+    INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file
+!$OMP THREADPRIVATE(nid_start,nid_restart)
+    
+    ! restartfi.nc file dimension identifiers: (see open_restartphy())
+    INTEGER,SAVE :: idim1 ! "index" dimension
+    INTEGER,SAVE :: idim2 ! "physical_points" dimension
+    INTEGER,SAVE :: idim3 ! "subsurface_layers" dimension
+    INTEGER,SAVE :: idim4 ! "nlayer_plus_1" dimension
+    INTEGER,SAVE :: idim5 ! "number_of_advected_fields" dimension
+    INTEGER,SAVE :: idim6 ! "nlayer" dimension
+    INTEGER,SAVE :: idim7 ! "Time" dimension
+    INTEGER,SAVE :: idim8 ! "ocean_layers" dimension
+    INTEGER,SAVE :: timeindex ! current time index (for time-dependent fields)
+!$OMP THREADPRIVATE(idim1,idim2,idim3,idim4,idim5,idim6,idim7,timeindex)
+    INTEGER,PARAMETER :: length=100 ! size of tab_cntrl array
+    
+    INTERFACE get_field
+      MODULE PROCEDURE Get_field_r1,Get_field_r2,Get_field_r3
+    END INTERFACE get_field
+    
+    INTERFACE get_var
+      MODULE PROCEDURE get_var_r0,Get_var_r1,Get_var_r2,Get_var_r3
+    END INTERFACE get_var
+
+    INTERFACE put_field
+      MODULE PROCEDURE put_field_r1,put_field_r2,put_field_r3
+    END INTERFACE put_field
+
+    INTERFACE put_var
+      MODULE PROCEDURE put_var_r0,put_var_r1,put_var_r2,put_var_r3
+    END INTERFACE put_var
+
+    PUBLIC nid_start, length
+    PUBLIC get_field,get_var,put_field,put_var
+    PUBLIC inquire_dimension, inquire_dimension_length
+    PUBLIC inquire_field, inquire_field_ndims
+    PUBLIC open_startphy,close_startphy,open_restartphy,close_restartphy
+    
+CONTAINS
+
+  SUBROUTINE open_startphy(filename)
+  USE netcdf, only: NF90_OPEN, NF90_NOERR, NF90_NOWRITE, nf90_strerror
+  USE mod_phys_lmdz_para, only: is_master, bcast
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: filename
+    INTEGER          :: ierr
+
+    IF (is_master) THEN
+      ierr = NF90_OPEN (filename, NF90_NOWRITE, nid_start)
+      IF (ierr.NE.NF90_NOERR) THEN
+        write(*,*)'open_startphy: problem opening file '//trim(filename)
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+    ENDIF
+    
+    CALL bcast(nid_start) ! tell all procs about nid_start
+  
+  END SUBROUTINE open_startphy
+
+  SUBROUTINE close_startphy
+  USE netcdf, only: NF90_CLOSE
+  USE mod_phys_lmdz_para, only: is_master
+  IMPLICIT NONE
+    INTEGER          :: ierr
+
+    IF (is_master) THEN
+        ierr = NF90_CLOSE (nid_start)
+    ENDIF
+
+  END SUBROUTINE close_startphy
+
+
+  FUNCTION inquire_field(Field_name)
+  ! check if a given field is present in the input file
+  USE netcdf, only: NF90_INQ_VARID, NF90_NOERR
+  USE mod_phys_lmdz_para, only: is_master, bcast
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: Field_name
+    LOGICAL :: inquire_field
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_master) THEN
+      ierr=NF90_INQ_VARID(nid_start,Field_name,varid)
+      IF (ierr==NF90_NOERR) THEN
+        Inquire_field=.TRUE.
+      ELSE
+        Inquire_field=.FALSE.
+      ENDIF
+    ENDIF
+
+    CALL bcast(inquire_field)
+
+  END FUNCTION inquire_field
+
+
+  FUNCTION inquire_field_ndims(Field_name)
+  ! give the number of dimensions of "Field_name" stored in the input file 
+  USE netcdf, only: nf90_inq_varid, nf90_inquire_variable, &
+                    NF90_NOERR, nf90_strerror
+  USE mod_phys_lmdz_para, only: is_master, bcast
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: Field_name
+    INTEGER :: inquire_field_ndims
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_master) THEN
+      ierr=nf90_inq_varid(nid_start,Field_name,varid)
+      ierr=nf90_inquire_variable(nid_start,varid,&
+                                  ndims=inquire_field_ndims)
+      IF (ierr.NE.NF90_NOERR) THEN
+        write(*,*)'inquire_field_ndims: problem obtaining ndims of '&
+                  //trim(field_name)
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+    ENDIF
+
+    CALL bcast(inquire_field_ndims)
+
+  END FUNCTION inquire_field_ndims
+
+
+  FUNCTION inquire_dimension(Field_name)
+  ! check if a given dimension is present in the input file
+  USE netcdf, only: nf90_inq_dimid, NF90_NOERR
+  USE mod_phys_lmdz_para, only: is_master, bcast
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: Field_name
+    LOGICAL :: inquire_dimension
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_master) THEN
+      ierr=NF90_INQ_DIMID(nid_start,Field_name,varid)
+      IF (ierr==NF90_NOERR) THEN
+        Inquire_dimension=.TRUE.
+      ELSE
+        Inquire_dimension=.FALSE.
+      ENDIF
+    ENDIF
+
+    CALL bcast(inquire_dimension)
+
+  END FUNCTION inquire_dimension
+
+  FUNCTION inquire_dimension_length(Field_name)
+  ! give the length of the "Field_name" dimension stored in the input file
+  USE netcdf, only: nf90_inquire_dimension, nf90_inq_dimid, &
+                    NF90_NOERR, nf90_strerror
+  USE mod_phys_lmdz_para, only: is_master, bcast
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: Field_name
+    INTEGER :: inquire_dimension_length
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_master) THEN
+      ierr=nf90_inq_dimid(nid_start,Field_name,varid)
+      ierr=nf90_inquire_dimension(nid_start,varid,&
+                                  len=inquire_dimension_length)
+      IF (ierr.NE.NF90_NOERR) THEN
+        write(*,*)'inquire_field_length: problem obtaining length of '&
+                  //trim(field_name)
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+    ENDIF
+
+    CALL bcast(inquire_dimension_length)
+
+  END FUNCTION inquire_dimension_length
+
+
+
+  SUBROUTINE Get_Field_r1(field_name,field,found,timeindex)
+  ! For a surface field
+  use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
+    REAL,INTENT(INOUT)               :: Field(:)
+    LOGICAL,INTENT(OUT),OPTIONAL   :: found 
+    INTEGER,INTENT(IN),OPTIONAL    :: timeindex ! time index of sought data
+
+    integer :: edges(4), corners(4)
+
+    edges(1)=klon_glo
+    edges(2:4)=1
+    corners(1:4)=1
+    if (PRESENT(timeindex)) then
+      corners(2)=timeindex
+    endif
+
+    IF (PRESENT(found)) THEN
+      CALL Get_field_rgen(field_name,field,1,corners,edges,found)
+    ELSE
+      CALL Get_field_rgen(field_name,field,1,corners,edges)
+    ENDIF
+      
+  END SUBROUTINE Get_Field_r1
+  
+  SUBROUTINE Get_Field_r2(field_name,field,found,timeindex)
+  ! For a "3D" horizontal-vertical field
+  use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
+    REAL,INTENT(INOUT)               :: Field(:,:)
+    LOGICAL,INTENT(OUT),OPTIONAL   :: found 
+    INTEGER,INTENT(IN),OPTIONAL    :: timeindex ! time index of sought data
+
+    integer :: edges(4), corners(4)
+
+    edges(1)=klon_glo
+    edges(2)=size(field,2)
+    edges(3:4)=1
+    corners(1:4)=1
+    if (PRESENT(timeindex)) then
+      corners(3)=timeindex
+    endif
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_field_rgen(field_name,field,size(field,2),&
+                          corners,edges,found)
+    ELSE
+      CALL Get_field_rgen(field_name,field,size(field,2),&
+                          corners,edges)
+    ENDIF
+
+      
+  END SUBROUTINE Get_Field_r2
+  
+  SUBROUTINE Get_Field_r3(field_name,field,found,timeindex)
+  ! for a "4D" field surf/alt/??
+  use mod_grid_phy_lmdz, only: klon_glo ! number of atmospheric columns (full grid)
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN)    :: Field_name
+    REAL,INTENT(INOUT)               :: Field(:,:,:)
+    LOGICAL,INTENT(OUT),OPTIONAL   :: found 
+    INTEGER,INTENT(IN),OPTIONAL    :: timeindex ! time index of sought data
+
+    integer :: edges(4), corners(4)
+
+    edges(1)=klon_glo
+    edges(2)=size(field,2)
+    edges(3)=size(field,3)
+    edges(4)=1
+    corners(1:4)=1
+    if (PRESENT(timeindex)) then
+      corners(4)=timeindex
+    endif
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_field_rgen(field_name,field,size(field,2)*size(field,3),&
+                          corners,edges,found)
+    ELSE
+      CALL Get_field_rgen(field_name,field,size(field,2)*size(field,3),&
+                          corners,edges)
+    ENDIF
+      
+  END SUBROUTINE Get_Field_r3
+  
+  SUBROUTINE Get_field_rgen(field_name,field,field_size, &
+                            corners,edges,found)
+  USE netcdf
+  USE dimphy
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: Field_name
+    INTEGER          :: field_size
+    REAL             :: field(klon,field_size)
+    INTEGER,INTENT(IN) :: corners(4)
+    INTEGER,INTENT(IN) :: edges(4)
+    LOGICAL,OPTIONAL :: found
+    
+    REAL    :: field_glo(klon_glo,field_size)
+    LOGICAL :: tmp_found
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_master) THEN
+  
+      ierr=NF90_INQ_VARID(nid_start,Field_name,varid)
+      
+      IF (ierr==NF90_NOERR) THEN
+        CALL body(field_glo)
+        tmp_found=.TRUE.
+      ELSE
+        tmp_found=.FALSE.
+      ENDIF
+    
+    ENDIF
+    
+    CALL bcast(tmp_found)
+
+    IF (tmp_found) THEN
+      CALL scatter(field_glo,field)
+    ENDIF
+    
+    IF (PRESENT(found)) THEN
+      found=tmp_found
+    ELSE
+      IF (.NOT. tmp_found) THEN
+        PRINT*, 'get_field_rgen: Field <'//field_name//'> not found'
+        CALL abort
+      ENDIF
+    ENDIF
+ 
+    
+    CONTAINS
+     
+     SUBROUTINE body(field_glo)
+       REAL :: field_glo(klon_glo*field_size)
+         ierr=NF90_GET_VAR(nid_start,varid,field_glo,corners,edges)
+         IF (ierr/=NF90_NOERR) THEN
+           ! La variable exist dans le fichier mais la lecture a echouee. 
+           PRINT*, 'get_field_rgen: Failed reading <'//field_name//'>'
+
+!           IF (field_name=='CLWCON' .OR. field_name=='RNEBCON' .OR. field_name=='RATQS') THEN
+!              ! Essaye de lire le variable sur surface uniqument, comme fait avant
+!              field_glo(:)=0.
+!              ierr=NF90_GET_VAR(nid_start,varid,field_glo(1:klon_glo))
+!              IF (ierr/=NF90_NOERR) THEN
+!                 PRINT*, 'phyetat0: Lecture echouee aussi en 2D pour <'//field_name//'>'
+!                 CALL abort
+!              ELSE
+!                 PRINT*, 'phyetat0: La variable <'//field_name//'> lu sur surface seulement'!, selon ancien format, le reste mis a zero'
+!              END IF
+!           ELSE
+              CALL abort
+!           ENDIF
+         ENDIF
+
+     END SUBROUTINE body
+
+  END SUBROUTINE Get_field_rgen
+
+
+  SUBROUTINE get_var_r0(var_name,var,found)
+  ! Get a scalar from input file
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(INOUT)             :: var
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+
+    REAL                         :: varout(1)
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,varout,size(varout),found)
+    ELSE
+      CALL Get_var_rgen(var_name,varout,size(varout))
+    ENDIF
+    var=varout(1)
+ 
+  END SUBROUTINE get_var_r0
+
+  SUBROUTINE get_var_r1(var_name,var,found)
+  ! Get a vector from input file
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(INOUT)             :: var(:)
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,var,size(var),found)
+    ELSE
+      CALL Get_var_rgen(var_name,var,size(var))
+    ENDIF
+  
+  END SUBROUTINE get_var_r1
+
+  SUBROUTINE get_var_r2(var_name,var,found)
+  ! Get a 2D field from input file
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(OUT)             :: var(:,:)
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,var,size(var),found)
+    ELSE
+      CALL Get_var_rgen(var_name,var,size(var))
+    ENDIF
+  
+  END SUBROUTINE get_var_r2
+
+  SUBROUTINE get_var_r3(var_name,var,found)
+  ! Get a 3D field frominput file
+  IMPLICIT NONE  
+    CHARACTER(LEN=*),INTENT(IN)  :: var_name
+    REAL,INTENT(INOUT)             :: var(:,:,:)
+    LOGICAL,OPTIONAL,INTENT(OUT) :: found
+    
+    IF (PRESENT(found)) THEN
+      CALL Get_var_rgen(var_name,var,size(var),found)
+    ELSE
+      CALL Get_var_rgen(var_name,var,size(var))
+    ENDIF
+  
+  END SUBROUTINE get_var_r3
+
+  SUBROUTINE Get_var_rgen(var_name,var,var_size,found)
+  USE netcdf
+  USE dimphy
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  IMPLICIT NONE
+    CHARACTER(LEN=*) :: var_name
+    INTEGER          :: var_size
+    REAL             :: var(var_size)
+    LOGICAL,OPTIONAL :: found
+    
+    LOGICAL :: tmp_found
+    INTEGER :: varid
+    INTEGER :: ierr
+    
+    IF (is_mpi_root .AND. is_omp_root) THEN
+  
+      ierr=NF90_INQ_VARID(nid_start,var_name,varid)
+      
+      IF (ierr==NF90_NOERR) THEN
+        ierr=NF90_GET_VAR(nid_start,varid,var)
+        IF (ierr/=NF90_NOERR) THEN
+          PRINT*, 'phyetat0: Failed loading <'//trim(var_name)//'>'
+          CALL abort
+        ENDIF
+        tmp_found=.TRUE.
+      ELSE
+        tmp_found=.FALSE.
+      ENDIF
+    
+    ENDIF
+    
+    CALL bcast(tmp_found)
+
+    IF (tmp_found) THEN
+      CALL bcast(var)
+    ENDIF
+    
+    IF (PRESENT(found)) THEN
+      found=tmp_found
+    ELSE
+      IF (.NOT. tmp_found) THEN
+        PRINT*, 'phyetat0: Variable <'//trim(var_name)//'> not found'
+        CALL abort
+      ENDIF
+    ENDIF
+
+  END SUBROUTINE Get_var_rgen
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE open_restartphy(filename)
+  USE netcdf, only: NF90_CREATE, NF90_CLOBBER, NF90_64BIT_OFFSET, &
+                    NF90_NOERR, nf90_strerror, &
+                    NF90_PUT_ATT, NF90_GLOBAL, NF90_DEF_DIM, &
+                    NF90_UNLIMITED, NF90_ENDDEF, &
+                    NF90_WRITE, NF90_OPEN
+  USE mod_phys_lmdz_para, only: is_master
+  USE mod_grid_phy_lmdz, only: klon_glo
+  USE dimphy, only: klev, klevp1
+  USE tracer_h, only: nqtot
+  USE comsoil_h, only: nsoilmx
+  USE slab_ice_h, only: noceanmx
+
+  IMPLICIT NONE
+    CHARACTER(LEN=*),INTENT(IN) :: filename
+    INTEGER                     :: ierr
+    LOGICAL,SAVE :: already_created=.false.
+!$OMP THREADPRIVATE(already_created)
+    
+    IF (is_master) THEN
+      if (.not.already_created) then
+        ! At the very first call, create the file
+        ierr=NF90_CREATE(filename,IOR(NF90_CLOBBER,NF90_64BIT_OFFSET), &
+                          nid_restart)
+        IF (ierr/=NF90_NOERR) THEN
+          write(*,*)'open_restartphy: problem creating file '//trim(filename)
+          write(*,*)trim(nf90_strerror(ierr))
+          CALL ABORT
+        ENDIF
+        already_created=.true.
+      else
+        ! Just open the file
+        ierr=NF90_OPEN(filename,NF90_WRITE,nid_restart)
+        IF (ierr/=NF90_NOERR) THEN
+          write(*,*)'open_restartphy: problem opening file '//trim(filename)
+          write(*,*)trim(nf90_strerror(ierr))
+          CALL ABORT
+        ENDIF
+        return
+      endif ! of if (.not.already_created)
+
+      ierr=NF90_PUT_ATT(nid_restart,NF90_GLOBAL,"title",&
+                        "Physics start file")
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem writing title '
+        write(*,*)trim(nf90_strerror(ierr))
+      ENDIF
+
+      ierr=NF90_DEF_DIM(nid_restart,"index",length,idim1)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem defining index dimension '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+      
+      ierr=NF90_DEF_DIM(nid_restart,"physical_points",klon_glo,idim2)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem defining physical_points dimension '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+      
+      ierr=NF90_DEF_DIM(nid_restart,"subsurface_layers",nsoilmx,idim3)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem defining subsurface_layers dimension '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+      
+      ierr=NF90_DEF_DIM(nid_restart,"nlayer_plus_1",klevp1,idim4)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem defining nlayer_plus_1 dimension '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+      
+      if (nqtot>0) then
+        ! only define a tracer dimension if there are tracers
+        ierr=NF90_DEF_DIM(nid_restart,"number_of_advected_fields",nqtot,idim5)
+        IF (ierr/=NF90_NOERR) THEN
+          write(*,*)'open_restartphy: problem defining number_of_advected_fields dimension '
+          write(*,*)trim(nf90_strerror(ierr))
+          CALL ABORT
+        ENDIF
+      endif
+
+      ierr=NF90_DEF_DIM(nid_restart,"nlayer",klev,idim6)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem defining nlayer dimension '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+      
+      ierr=NF90_DEF_DIM(nid_restart,"Time",NF90_UNLIMITED,idim7)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem defining Time dimension '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+
+      ierr=NF90_DEF_DIM(nid_restart,"ocean_layers",noceanmx,idim8)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem defining oceanic layer dimension '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+
+
+      ierr=NF90_ENDDEF(nid_restart)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'open_restartphy: problem ending definition mode '
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+    ENDIF
+
+  END SUBROUTINE open_restartphy
+
+  SUBROUTINE close_restartphy
+  USE netcdf, only: NF90_CLOSE
+  USE mod_phys_lmdz_para, only: is_master
+  IMPLICIT NONE
+    INTEGER          :: ierr
+
+    IF (is_master) THEN
+      ierr = NF90_CLOSE (nid_restart)
+    ENDIF
+ 
+  END SUBROUTINE close_restartphy
+
+  SUBROUTINE put_field_r1(field_name,title,field,time)
+  ! For a surface field
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  REAL,INTENT(IN)                :: field(:)
+  REAL,OPTIONAL,INTENT(IN)       :: time
+  
+  IF (present(time)) THEN
+    ! if timeindex is present, it is a time-dependent variable
+    CALL put_field_rgen(field_name,title,field,1,time)
+  ELSE
+    CALL put_field_rgen(field_name,title,field,1)
+  ENDIF
+  
+  END SUBROUTINE put_field_r1
+
+  SUBROUTINE put_field_r2(field_name,title,field,time)
+  ! For a "3D" horizontal-vertical field
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  REAL,INTENT(IN)                :: field(:,:)
+  REAL,OPTIONAL,INTENT(IN)       :: time
+  
+  IF (present(time)) THEN
+    ! if timeindex is present, it is a time-dependent variable
+    CALL put_field_rgen(field_name,title,field,size(field,2),time)
+  ELSE
+    CALL put_field_rgen(field_name,title,field,size(field,2))
+  ENDIF
+  
+  END SUBROUTINE put_field_r2
+
+  SUBROUTINE put_field_r3(field_name,title,field,time)
+  ! For a "4D" field surf/alt/??
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  REAL,INTENT(IN)                :: field(:,:,:)
+  REAL,OPTIONAL,INTENT(IN)       :: time
+  
+  IF (present(time)) THEN
+    ! if timeindex is present, it is a time-dependent variable
+    CALL put_field_rgen(field_name,title,field,size(field,2)*size(field,3),&
+                        time)
+  ELSE  
+    CALL put_field_rgen(field_name,title,field,size(field,2)*size(field,3))
+  ENDIF
+  
+  END SUBROUTINE put_field_r3
+  
+  SUBROUTINE put_field_rgen(field_name,title,field,field_size,time)
+  USE netcdf
+  USE dimphy
+  USE comsoil_h, only: nsoilmx
+  USE mod_grid_phy_lmdz
+  USE mod_phys_lmdz_para
+  USE slab_ice_h, only: noceanmx
+  IMPLICIT NONE
+  CHARACTER(LEN=*),INTENT(IN)    :: field_name
+  CHARACTER(LEN=*),INTENT(IN)    :: title
+  INTEGER,INTENT(IN)             :: field_size
+  REAL,INTENT(IN)                :: field(klon,field_size)
+  REAL,OPTIONAL,INTENT(IN)       :: time
+  
+  REAL                           :: field_glo(klon_glo,field_size)
+  INTEGER                        :: ierr
+  INTEGER                        :: nvarid
+  INTEGER                        :: idim
+   
+    CALL gather(field,field_glo)
+    
+    IF (is_master) THEN
+
+      IF (field_size==1) THEN
+        ! input is a 1D "surface field" array
+        if (.not.present(time)) then ! for a time-independent field
+          ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                            (/idim2/),nvarid)
+#else
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                            (/idim2/),nvarid)
+#endif
+          if (ierr.ne.NF90_NOERR) then
+            write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+            write(*,*)trim(nf90_strerror(ierr))
+          endif
+          IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+          ierr=NF90_ENDDEF(nid_restart)
+          ierr=NF90_PUT_VAR(nid_restart,nvarid,field_glo)
+        else
+          ! check if the variable has already been defined:
+          ierr=NF90_INQ_VARID(nid_restart,field_name,nvarid)
+          if (ierr/=NF90_NOERR) then ! variable not found, define it
+            ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                              (/idim2,idim7/),nvarid)
+#else
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                              (/idim2,idim7/),nvarid)
+#endif
+            if (ierr.ne.NF90_NOERR) then
+              write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+              write(*,*)trim(nf90_strerror(ierr))
+            endif
+            IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+            ierr=NF90_ENDDEF(nid_restart)
+          endif
+          ! Write the variable
+          ierr=NF90_PUT_VAR(nid_restart,nvarid,field_glo,&
+                            start=(/1,timeindex/))
+        endif ! of if (.not.present(timeindex))
+
+      ELSE IF (field_size==klev) THEN
+        ! input is a 2D "atmospheric field" array
+        if (.not.present(time)) then ! for a time-independent field
+          ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                            (/idim2,idim6/),nvarid)
+#else
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                            (/idim2,idim6/),nvarid)
+#endif
+          if (ierr.ne.NF90_NOERR) then
+            write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+            write(*,*)trim(nf90_strerror(ierr))
+          endif
+          IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+          ierr=NF90_ENDDEF(nid_restart)
+          ierr=NF90_PUT_VAR(nid_restart,nvarid,field_glo)
+        else
+          ! check if the variable has already been defined:
+          ierr=NF90_INQ_VARID(nid_restart,field_name,nvarid)
+          if (ierr/=NF90_NOERR) then ! variable not found, define it
+            ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                              (/idim2,idim6,idim7/),nvarid)
+#else
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                              (/idim2,idim6,idim7/),nvarid)
+#endif
+            if (ierr.ne.NF90_NOERR) then
+              write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+              write(*,*)trim(nf90_strerror(ierr))
+            endif
+            IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+            ierr=NF90_ENDDEF(nid_restart)
+          endif
+          ! Write the variable
+          ierr=NF90_PUT_VAR(nid_restart,nvarid,field_glo,&
+                            start=(/1,1,timeindex/))
+        endif ! of if (.not.present(time))
+
+      ELSE IF (field_size==klevp1) THEN
+        ! input is a 2D "interlayer atmospheric field" array
+        if (.not.present(time)) then ! for a time-independent field
+          ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                            (/idim2,idim4/),nvarid)
+#else
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                            (/idim2,idim4/),nvarid)
+#endif
+          if (ierr.ne.NF90_NOERR) then
+            write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+            write(*,*)trim(nf90_strerror(ierr))
+          endif
+          IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+          ierr = NF90_ENDDEF(nid_restart)
+          ierr = NF90_PUT_VAR(nid_restart,nvarid,field_glo)
+        else
+          ! check if the variable has already been defined:
+          ierr=NF90_INQ_VARID(nid_restart,field_name,nvarid)
+          if (ierr/=NF90_NOERR) then ! variable not found, define it
+            ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                              (/idim2,idim4,idim7/),nvarid)
+#else
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                              (/idim2,idim4,idim7/),nvarid)
+#endif
+            if (ierr.ne.NF90_NOERR) then
+              write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+              write(*,*)trim(nf90_strerror(ierr))
+            endif
+            IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+            ierr=NF90_ENDDEF(nid_restart)
+          endif
+          ! Write the variable
+          ierr=NF90_PUT_VAR(nid_restart,nvarid,field_glo,&
+                            start=(/1,1,timeindex/))
+        endif ! of if (.not.present(timeindex))
+
+      ELSE IF (field_size==nsoilmx) THEN
+        ! input is a 2D "subsurface field" array
+        if (.not.present(time)) then ! for a time-independent field
+          ierr = NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                            (/idim2,idim3/),nvarid)
+#else
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                            (/idim2,idim3/),nvarid)
+#endif
+          if (ierr.ne.NF90_NOERR) then
+            write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+            write(*,*)trim(nf90_strerror(ierr))
+          endif
+          IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+          ierr = NF90_ENDDEF(nid_restart)
+          ierr = NF90_PUT_VAR(nid_restart,nvarid,field_glo)
+        else
+          ! check if the variable has already been defined:
+          ierr=NF90_INQ_VARID(nid_restart,field_name,nvarid)
+          if (ierr/=NF90_NOERR) then ! variable not found, define it
+            ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                              (/idim2,idim3,idim7/),nvarid)
+#else
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                              (/idim2,idim3,idim7/),nvarid)
+#endif
+           if (ierr.ne.NF90_NOERR) then
+              write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+              write(*,*)trim(nf90_strerror(ierr))
+            endif
+            IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+            ierr=NF90_ENDDEF(nid_restart)
+          endif
+          ! Write the variable
+          ierr=NF90_PUT_VAR(nid_restart,nvarid,field_glo,&
+                            start=(/1,1,timeindex/))
+
+        endif ! of if (.not.present(time))
+
+      ELSE IF (field_size==noceanmx) THEN
+        ! input is a 2D "oceanic field" array
+        if (.not.present(time)) then ! for a time-independent field
+          ierr = NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                            (/idim2,idim8/),nvarid)
+#else
+          ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                            (/idim2,idim8/),nvarid)
+#endif
+          if (ierr.ne.NF90_NOERR) then
+            write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+            write(*,*)trim(nf90_strerror(ierr))
+          endif
+          IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+          ierr = NF90_ENDDEF(nid_restart)
+          ierr = NF90_PUT_VAR(nid_restart,nvarid,field_glo)
+        else
+          ! check if the variable has already been defined:
+          ierr=NF90_INQ_VARID(nid_restart,field_name,nvarid)
+          if (ierr/=NF90_NOERR) then ! variable not found, define it
+            ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_DOUBLE,&
+                              (/idim2,idim8,idim7/),nvarid)
+#else
+            ierr=NF90_DEF_VAR(nid_restart,field_name,NF90_FLOAT,&
+                              (/idim2,idim8,idim7/),nvarid)
+#endif
+           if (ierr.ne.NF90_NOERR) then
+              write(*,*)"put_field_rgen error: failed to define "//trim(field_name)
+              write(*,*)trim(nf90_strerror(ierr))
+            endif
+            IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+            ierr=NF90_ENDDEF(nid_restart)
+          endif
+          ! Write the variable
+          ierr=NF90_PUT_VAR(nid_restart,nvarid,field_glo,&
+                            start=(/1,1,timeindex/))
+
+        endif ! of if (.not.present(time))
+
+
+      ELSE
+        PRINT *, "Error phyredem(put_field_rgen) : wrong dimension for ",trim(field_name)
+        write(*,*) "  field_size =",field_size
+        CALL ABORT
+      ENDIF
+
+      ! Check the writting of field to file went OK
+      if (ierr.ne.NF90_NOERR) then
+        write(*,*) " Error phyredem(put_field_rgen) : failed writing ",trim(field_name)
+        write(*,*)trim(nf90_strerror(ierr))
+        call abort
+      endif
+
+    ENDIF ! of IF (is_master)
+    
+  END SUBROUTINE put_field_rgen  
+  
+  SUBROUTINE put_var_r0(var_name,title,var)
+  ! Put a scalar in file
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var
+     REAL                        :: varin(1)
+     
+     varin(1)=var
+     
+     CALL put_var_rgen(var_name,title,varin,size(varin))
+
+  END SUBROUTINE put_var_r0
+
+
+  SUBROUTINE put_var_r1(var_name,title,var)
+  ! Put a vector in file
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var(:)
+     
+     CALL put_var_rgen(var_name,title,var,size(var))
+
+  END SUBROUTINE put_var_r1
+ 
+  SUBROUTINE put_var_r2(var_name,title,var)
+  ! Put a 2D field in file
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var(:,:)
+     
+     CALL put_var_rgen(var_name,title,var,size(var))
+
+  END SUBROUTINE put_var_r2     
+  
+  SUBROUTINE put_var_r3(var_name,title,var)
+  ! Put a 3D field in file
+   IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     REAL,INTENT(IN)             :: var(:,:,:)
+     
+     CALL put_var_rgen(var_name,title,var,size(var))
+
+  END SUBROUTINE put_var_r3
+
+  SUBROUTINE put_var_rgen(var_name,title,var,var_size)
+  USE netcdf, only: NF90_REDEF, NF90_DEF_VAR, NF90_ENDDEF, NF90_PUT_VAR, &
+                    NF90_FLOAT, NF90_DOUBLE, &
+                    NF90_PUT_ATT, NF90_NOERR, nf90_strerror, &
+                    nf90_inq_dimid, nf90_inquire_dimension, NF90_INQ_VARID
+  USE comsoil_h, only: nsoilmx
+  USE mod_phys_lmdz_para, only: is_master
+  USE slab_ice_h, only: noceanmx
+  IMPLICIT NONE
+     CHARACTER(LEN=*),INTENT(IN) :: var_name
+     CHARACTER(LEN=*),INTENT(IN) :: title
+     INTEGER,INTENT(IN)          :: var_size
+     REAL,INTENT(IN)             :: var(var_size)
+     
+     INTEGER :: ierr
+     INTEGER :: nvarid
+     INTEGER :: idim1d
+     logical,save :: firsttime=.true.
+!$OMP THREADPRIVATE(firsttime)
+         
+    IF (is_master) THEN
+
+      IF (var_name=="Time") THEN
+        ! Very specific case of "Time" variable
+        if (firsttime) then
+          ! Create the "Time variable"
+          ierr=NF90_REDEF(nid_restart)
+#ifdef NC_DOUBLE
+          ierr=NF90_DEF_VAR(nid_restart,var_name,NF90_DOUBLE,&
+                            (/idim7/),nvarid)
+#else
+          ierr=NF90_DEF_VAR(nid_restart,var_name,NF90_FLOAT,&
+                            (/idim7/),nvarid)
+#endif
+          IF (LEN_TRIM(title) > 0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+          ierr=NF90_ENDDEF(nid_restart)
+          
+          firsttime=.false.
+        endif
+        ! Append "time" value
+        ! get current length of "Time" dimension
+        ierr=nf90_inq_dimid(nid_restart,var_name,idim1d)
+        ierr=nf90_inquire_dimension(nid_restart,idim1d,len=timeindex)
+        timeindex=timeindex+1
+        ierr=NF90_INQ_VARID(nid_restart,var_name,nvarid)
+        ierr=NF90_PUT_VAR(nid_restart,nvarid,var,&
+                           start=(/timeindex/))
+        IF (ierr/=NF90_NOERR) THEN
+          write(*,*)'put_var_rgen: problem writing Time'
+          write(*,*)trim(nf90_strerror(ierr))
+          CALL ABORT
+        ENDIF
+        return ! nothing left to do
+      ELSEIF (var_size==length) THEN
+        ! We know it is a "controle" kind of 1D array
+        idim1d=idim1
+      ELSEIF (var_size==nsoilmx) THEN
+        ! We know it is an  "mlayer" kind of 1D array
+        idim1d=idim3
+      ELSEIF (var_size==noceanmx) THEN
+        ! We know it is an  "mlayer" kind of 1D array
+        idim1d=idim8
+      ELSE 
+        PRINT *, "put_var_rgen error : wrong dimension"
+        write(*,*) "  var_size =",var_size
+        CALL abort
+
+      ENDIF ! of IF (var_size==length) THEN
+
+      ! Swich to NetCDF define mode
+      ierr=NF90_REDEF (nid_restart)
+      ! Define the variable
+#ifdef NC_DOUBLE
+      ierr=NF90_DEF_VAR(nid_restart,var_name,NF90_DOUBLE,(/idim1d/),nvarid)
+#else
+      ierr=NF90_DEF_VAR(nid_restart,var_name,NF90_FLOAT,(/idim1d/),nvarid)
+#endif
+      ! Add a "title" attribute
+      IF (LEN_TRIM(title)>0) ierr=NF90_PUT_ATT(nid_restart,nvarid,"title",title)
+      ! Swich out of define mode
+      ierr=NF90_ENDDEF(nid_restart)
+      ! Write variable to file
+      ierr=NF90_PUT_VAR(nid_restart,nvarid,var)
+      IF (ierr/=NF90_NOERR) THEN
+        write(*,*)'put_var_rgen: problem writing '//trim(var_name)
+        write(*,*)trim(nf90_strerror(ierr))
+        CALL ABORT
+      ENDIF
+    ENDIF ! of IF (is_master)
+    
+  END SUBROUTINE put_var_rgen     
+
+END MODULE iostart
Index: /trunk/LMDZ.TITAN/libf/phytitan/lagrange.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/lagrange.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/lagrange.F	(revision 1644)
@@ -0,0 +1,30 @@
+      subroutine lagrange(x, xi, yi, ans)
+
+C  Lagrange interpolation - Polynomial interpolation at point x 
+C  xi(1) <= x <= xi(4).  Yi(n) is the functional value at XI(n).
+
+      implicit none
+
+      real*8 x, xi(4), yi(4), ans
+      real*8 fm1, fm2, fm3, fm4
+
+C======================================================================!
+
+      fm1   = x - XI(1)
+      fm2   = x - XI(2)
+      fm3   = x - XI(3)
+      fm4   = x - XI(4)
+
+C  Get the answer at the requested X
+ 
+      ans = fm2*fm3*fm4*YI(1)/
+     *                ((XI(1)-XI(2))*(XI(1)-XI(3))*(XI(1)-XI(4)))  +
+     *      fm1*fm3*fm4*YI(2)/
+     *                ((XI(2)-XI(1))*(XI(2)-XI(3))*(XI(2)-XI(4)))  +
+     *      fm1*fm2*fm4*YI(3)/
+     *                ((XI(3)-XI(1))*(XI(3)-XI(2))*(XI(3)-XI(4)))  +
+     *      fm1*fm2*fm3*YI(4)/
+     *                ((XI(4)-XI(1))*(XI(4)-XI(2))*(XI(4)-XI(3))) 
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/largescale.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/largescale.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/largescale.F90	(revision 1644)
@@ -0,0 +1,171 @@
+      subroutine largescale(ngrid,nlayer,nq,ptimestep, pplev, pplay,    &
+                    pt, pq, pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
+
+
+      use ioipsl_getin_p_mod, only: getin_p
+      use watercommon_h, only : RLVTT, RCPD, RVTMP2,  &
+          T_h2O_ice_clouds,T_h2O_ice_liq,Psat_waterDP,Lcpdqsat_waterDP
+      USE tracer_h
+      IMPLICIT none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates large-scale (stratiform) H2O condensation.
+!     
+!     Authors
+!     -------
+!     Adapted from the LMDTERRE code by R. Wordsworth (2009)
+!     Original author Z. X. Li (1993)
+!     
+!==================================================================
+
+      INTEGER ngrid,nlayer,nq
+
+!     Arguments
+      REAL ptimestep                 ! intervalle du temps (s)
+      REAL pplev(ngrid,nlayer+1) ! pression a inter-couche
+      REAL pplay(ngrid,nlayer)   ! pression au milieu de couche
+      REAL pt(ngrid,nlayer)      ! temperature (K)
+      REAL pq(ngrid,nlayer,nq) ! tracer mixing ratio (kg/kg)
+      REAL pdt(ngrid,nlayer)     ! physical temperature tenedency (K/s)
+      REAL pdq(ngrid,nlayer,nq)! physical tracer tenedency (K/s)
+      REAL pdtlsc(ngrid,nlayer)  ! incrementation de la temperature (K)
+      REAL pdqvaplsc(ngrid,nlayer) ! incrementation de la vapeur d'eau
+      REAL pdqliqlsc(ngrid,nlayer) ! incrementation de l'eau liquide
+      REAL rneb(ngrid,nlayer)    ! fraction nuageuse
+
+
+!     Options du programme
+      REAL, SAVE :: ratqs   ! determine largeur de la distribution de vapeur
+!$OMP THREADPRIVATE(ratqs)
+
+!     Variables locales
+      REAL CBRT
+      EXTERNAL CBRT
+      INTEGER i, k , nn
+      INTEGER,PARAMETER :: nitermax=5000
+      DOUBLE PRECISION,PARAMETER :: alpha=.1,qthreshold=1.d-8
+      ! JL13: if "careful, T<Tmin in psat water" appears often, you may want to stabilise the model by
+      !                   decreasing alpha and increasing nitermax accordingly
+      DOUBLE PRECISION zt(ngrid), zq(ngrid)
+      DOUBLE PRECISION zcond(ngrid),zcond_iter
+      DOUBLE PRECISION zdelq(ngrid)
+      DOUBLE PRECISION zqs(ngrid), zdqs(ngrid)
+      DOUBLE PRECISION local_p,psat_tmp,dlnpsat_tmp,Lcp
+      
+! evaporation calculations
+      REAL dqevap(ngrid,nlayer),dtevap(ngrid,nlayer)     
+      REAL qevap(ngrid,nlayer,nq)
+      REAL tevap(ngrid,nlayer)
+
+      DOUBLE PRECISION zx_q(ngrid)
+      LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+
+
+      IF (firstcall) THEN
+
+	 write(*,*) "value for ratqs? "
+         ratqs=0.2 ! default value
+         call getin_p("ratqs",ratqs)
+         write(*,*) " ratqs = ",ratqs
+
+         firstcall = .false.
+      ENDIF
+
+!     GCM -----> subroutine variables, initialisation of outputs
+
+      pdtlsc(1:ngrid,1:nlayer)  = 0.0
+      pdqvaplsc(1:ngrid,1:nlayer)  = 0.0
+      pdqliqlsc(1:ngrid,1:nlayer) = 0.0
+      rneb(1:ngrid,1:nlayer) = 0.0
+      Lcp=RLVTT/RCPD
+
+
+      ! Evaporate cloud water/ice
+      call evap(ngrid,nlayer,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
+      ! note: we use qevap but not tevap in largescale/moistadj
+            ! otherwise is a big mess
+
+
+!  Boucle verticale (du haut vers le bas)
+   DO k = nlayer, 1, -1
+
+      zt(1:ngrid)=pt(1:ngrid,k)+(pdt(1:ngrid,k)+dtevap(1:ngrid,k))*ptimestep
+      zq(1:ngrid)=qevap(1:ngrid,k,igcm_h2o_vap) !liquid water is included in qevap
+
+!     Calculer la vapeur d'eau saturante et 
+!     determiner la condensation partielle
+      DO i = 1, ngrid
+
+         local_p=pplay(i,k)
+         if(zt(i).le.15.) then
+	    print*,'in lsc',i,k,zt(i)
+!	    zt(i)=15.   ! check too low temperatures
+         endif
+         call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
+ 
+         zdelq(i) = MAX(MIN(ratqs * zq(i),1.-zq(i)),1.d-12)
+	 rneb(i,k) = (zq(i)+zdelq(i)-zqs(i)) / (2.0*zdelq(i))
+	 if (rneb(i,k).lt.0.) then  !no clouds
+
+	    rneb(i,k)=0.
+	    zcond(i)=0.
+
+	 else if ((rneb(i,k).gt.0.99).or.(ratqs.lt.1.e-6)) then    !complete cloud cover, we start without evaporating
+	    rneb(i,k)=1.
+            zt(i)=pt(i,k)+pdt(i,k)*ptimestep
+	    zx_q(i) = pq(i,k,igcm_h2o_vap)+pdq(i,k,igcm_h2o_vap)*ptimestep
+	    dqevap(i,k)=0.
+!           iterative process to stabilize the scheme when large water amounts JL12
+            zcond(i) = 0.0d0
+            Do nn=1,nitermax  
+               call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
+	       call Lcpdqsat_waterDP(zt(i),local_p,psat_tmp,zqs(i),zdqs(i),dlnpsat_tmp)
+               zcond_iter = alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs(i))	   
+                  !zcond can be negative here
+               zx_q(i) = zx_q(i) - zcond_iter
+	       zcond(i) = zcond(i) + zcond_iter
+	       zt(i) = zt(i) + zcond_iter*Lcp
+	       if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
+!	       if (ABS(zcond_iter/alpha).lt.qthreshold) exit
+	       if (nn.eq.nitermax) print*,'itermax in largescale'
+	    End do ! niter
+	    zcond(i)=MAX(zcond(i),-(pq(i,k,igcm_h2o_ice)+pdq(i,k,igcm_h2o_ice)*ptimestep))
+
+	 else   !standard case	    
+
+	    zx_q(i) = (zq(i)+zdelq(i)+zqs(i))/2.0d0 !water vapor in cloudy sky
+!           iterative process to stabilize the scheme when large water amounts JL12
+            zcond(i) = 0.0d0
+            Do nn=1,nitermax  
+	       call Lcpdqsat_waterDP(zt(i),local_p,psat_tmp,zqs(i),zdqs(i),dlnpsat_tmp)
+               zcond_iter = MAX(0.0d0,alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs(i)))	   
+                  !zcond always postive! cannot evaporate clouds!
+                  !this is why we must reevaporate before largescale
+               zx_q(i) = zx_q(i) - zcond_iter
+	       zcond(i) = zcond(i) + zcond_iter
+	       if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
+!	       if (ABS(zcond_iter/alpha).lt.qthreshold) exit
+	       zt(i) = zt(i) + zcond_iter*Lcp*rneb(i,k)
+               call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
+	       if (nn.eq.nitermax) print*,'itermax in largescale'
+	    End do ! niter
+
+	 Endif
+
+         zcond(i) = zcond(i)*rneb(i,k)/ptimestep ! JL12
+
+      ENDDO
+
+!     Tendances de t et q
+         pdqvaplsc(1:ngrid,k)  = dqevap(1:ngrid,k) - zcond(1:ngrid)
+         pdqliqlsc(1:ngrid,k) = - pdqvaplsc(1:ngrid,k)
+         pdtlsc(1:ngrid,k)  = pdqliqlsc(1:ngrid,k)*real(Lcp)
+
+   Enddo ! k= nlayer, 1, -1
+ 
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/mass_redistribution.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/mass_redistribution.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/mass_redistribution.F90	(revision 1644)
@@ -0,0 +1,406 @@
+SUBROUTINE mass_redistribution(ngrid,nlayer,nq,ptimestep,   &
+                       rnat,pcapcal,pplay,pplev,pt,ptsrf,pq,pqs,     &
+		       pu,pv,pdt,pdtsrf,pdq,pdu,pdv,pdmassmr,  &
+		       pdtmr,pdtsrfmr,pdpsrfmr,pdumr,pdvmr,pdqmr,pdqsmr)
+                                                   
+       USE watercommon_h, Only: Tsat_water,RLVTT
+       use surfdat_h
+       use radcommon_h, only: glat
+       USE tracer_h
+       USE planete_mod, only: bp
+       use comcstfi_mod, only: g
+       USE callkeys_mod, ONLY: water
+       
+       IMPLICIT NONE
+!=======================================================================
+!   subject:
+!   --------
+!     Mass and momentum fluxes through sigma levels as the surface pressure is modified are also taken into account
+!
+!   author:   Jeremy Leconte 2012 (from F.Forget 1998)
+!   ------
+!
+!   input:
+!   ----- 
+!    ngrid                 nombre de points de verticales
+!                          (toutes les boucles de la physique sont au
+!                          moins vectorisees sur ngrid)
+!    nlayer                nombre de couches
+!    pplay(ngrid,nlayer)   Pressure levels 
+!    pplev(ngrid,nlayer+1) Pressure levels 
+!    nq                    Number of tracers
+!
+!    pt(ngrid,nlayer)      temperature (en K)
+!    pq(ngrid,nlayer,nq)   tracer specific concentration (kg/kg of air)
+!    pu,pv (ngrid,nlayer)  wind velocity (m/s)
+!
+!                    
+!    pdX                   physical tendency of X before mass redistribution
+!
+!    pdmassmr                air Mass added to the atmosphere in each layer (kg/m2/s)
+!
+!   output:
+!   -------
+!
+!    pdXmr(ngrid)           physical tendency of X after mass redistribution
+!
+!    
+!
+!=======================================================================
+!
+!    0.  Declarations :
+!    ------------------
+
+!-----------------------------------------------------------------------
+!    Arguments :
+!    ---------
+      INTEGER ngrid, nlayer, nq   
+      REAL ptimestep
+      REAL pcapcal(ngrid)
+      INTEGER rnat(ngrid)      
+      REAL pplay(ngrid,nlayer),pplev(ngrid,nlayer+1)
+      REAL pt(ngrid,nlayer),pdt(ngrid,nlayer)
+      REAL ptsrf(ngrid),pdtsrf(ngrid)
+      REAL pdtmr(ngrid,nlayer)
+      REAL pu(ngrid,nlayer) ,  pv(ngrid,nlayer)
+      REAL pdu(ngrid,nlayer) , pdv(ngrid,nlayer)
+      REAL pdmassmr(ngrid,nlayer)
+      REAL pdumr(ngrid,nlayer) , pdvmr(ngrid,nlayer)
+      REAL pq(ngrid,nlayer,nq),pdq(ngrid,nlayer,nq)
+      REAL pqs(ngrid,nq)
+      REAL pdqmr(ngrid,nlayer,nq),pdqsmr(ngrid,nq)
+      REAL pdpsrfmr(ngrid),pdtsrfmr(ngrid)
+!
+!    Local variables :
+!    -----------------
+
+!    Boiling/sublimation
+      REAL Tsat(ngrid),zmassboil(ngrid)
+
+!    vertical reorganization of sigma levels
+      REAL zzu(nlayer),zzv(nlayer)
+      REAL zzq(nlayer,nq),zzt(nlayer)
+!    Dummy variables      
+      INTEGER n,l,ig,iq
+      REAL zdtsig(ngrid,nlayer)
+      REAL zmass(ngrid,nlayer),zzmass(nlayer),w(nlayer+1)
+      REAL zdmass_sum(ngrid,nlayer+1)
+      REAL zmflux(nlayer+1)
+      REAL zq1(nlayer)
+      REAL ztsrf(ngrid)
+      REAL ztm(nlayer+1) 
+      REAL zum(nlayer+1) , zvm(nlayer+1)
+      REAL zqm(nlayer+1,nq),zqm1(nlayer+1)
+      REAL sigma(nlayer+1)
+
+!   local saved variables
+      LOGICAL, SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+
+!----------------------------------------------------------------------
+
+!   Initialisation
+!   --------------
+!
+      IF (firstcall) THEN
+         firstcall=.false.	 
+      ENDIF
+!
+!======================================================================
+!    Calcul of h2o condensation  
+!    ============================================================
+!  
+!    Used variable :
+!       pdmassmr      : air Mass added to the atmosphere in each layer per unit time (kg/m2/s)
+!       zdmass_sum(ngrid,l) : total air mass added to the atm above layer l per unit time (kg/m2/s)
+!
+!
+!     Surface tracer Tendencies set to 0
+!     -------------------------------------
+      pdqsmr(1:ngrid,1:nq)=0.
+
+      ztsrf(1:ngrid) = ptsrf(1:ngrid) + pdtsrf(1:ngrid)*ptimestep
+
+
+      DO ig=1,ngrid
+         zdmass_sum(ig,nlayer+1)=0.
+         DO l = nlayer, 1, -1
+           zmass(ig,l) = (pplev(ig,l)-pplev(ig,l+1))/glat(ig)
+	   zdmass_sum(ig,l)= zdmass_sum(ig,l+1)+pdmassmr(ig,l)
+         END DO
+      END DO
+
+
+      if (water) then
+         do ig=1,ngrid
+	    call Tsat_water(pplev(ig,1)+zdmass_sum(ig,1)*g*ptimestep,Tsat(ig))
+	 enddo
+               call writediagfi(ngrid,'Tsat','saturation temperature at surface','',2,Tsat)
+	 
+         do ig=1,ngrid
+	    if (ztsrf(ig).gt.Tsat(ig)) then
+	       zmassboil(ig)=(ptsrf(ig)-Tsat(ig))*pcapcal(ig)/RLVTT/ptimestep
+	       if ((zmassboil(ig)*ptimestep.gt.pqs(ig,igcm_h2o_vap)).and.(rnat(ig).eq.1)) then
+	          zmassboil(ig)=pqs(ig,igcm_h2o_vap)/ptimestep
+	       endif
+	       zmassboil(ig)=zmassboil(ig)*0.0 !momentary, should be 1. JL12
+               pdqsmr(ig,igcm_h2o_vap)=-zmassboil(ig)
+	       pdtsrfmr(ig)=-zmassboil(ig)*RLVTT/pcapcal(ig)
+	       ztsrf(ig)=ptsrf(ig)+pdtsrfmr(ig)*ptimestep
+	    else
+	       zmassboil(ig)=0.
+	       pdtsrfmr(ig)=0.
+	    endif
+	 enddo
+      endif
+
+!     *************************
+!           UPDATE SURFACE
+!     *************************
+!    Changing pressure at the surface:
+!    """"""""""""""""""""""""""""""""""""
+         
+      pdpsrfmr(1:ngrid) = (zdmass_sum(1:ngrid,1)+zmassboil(1:ngrid))*g
+
+      do ig = 1, ngrid
+        IF(ABS(pdpsrfmr(ig)*ptimestep).GT.pplev(ig,1)) THEN
+         PRINT*,'STOP in condens in mass_redistribution'
+         PRINT*,'condensing more than total mass'
+         PRINT*,'Grid point ',ig
+         PRINT*,'Ps = ',pplev(ig,1)
+         PRINT*,'d Ps = ',pdpsrfmr(ig)*ptimestep
+         STOP
+        ENDIF
+      enddo ! of DO ig=1,ngrid
+
+
+! ***************************************************************
+!  Correction to account for redistribution between sigma or hybrid 
+!  layers when changing surface pressure
+!  zzx quantities have dimension (nlayer) to speed up calculation
+! *************************************************************
+
+      DO ig=1,ngrid
+         zzt(1:nlayer)  = pt(ig,1:nlayer) + pdt(ig,1:nlayer) * ptimestep
+         zzu(1:nlayer)  = pu(ig,1:nlayer) + pdu(ig,1:nlayer) * ptimestep
+         zzv(1:nlayer)  = pv(ig,1:nlayer) + pdv(ig,1:nlayer) * ptimestep
+         zzq(1:nlayer,1:nq)=pq(ig,1:nlayer,1:nq)+pdq(ig,1:nlayer,1:nq)*ptimestep ! must add the water that has fallen???
+
+!  Mass fluxes of air through the sigma levels (kg.m-2.s-1)  (>0 when up)
+!  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+         zmflux(1) = zmassboil(ig)
+         sigma(1)=1
+         DO l=1,nlayer
+           ! Ehouarn: shouldn't we rather compute sigma levels than use bp()?
+!           sigma(l+1)=pplev(ig,l+1)/pplev(ig,1)
+!           zmflux(l+1) = zmflux(l) + pdmassmr(ig,l) - &
+!                        (sigma(l)-sigma(l+1))*(zdmass_sum(ig,1)+zmflux(1))
+!            if (abs(zmflux(l+1)).lt.1E-13.OR.sigma(l+1).eq.0.) zmflux(l+1)=0.
+           ! Ehouarn: but for now leave things as before
+            zmflux(l+1) = zmflux(l) + pdmassmr(ig,l) - (bp(l)-bp(l+1))*(zdmass_sum(ig,1)+zmflux(1))
+! zmflux set to 0 if very low to avoid: top layer is disappearing in v1ld  
+            if (abs(zmflux(l+1)).lt.1E-13.OR.bp(l+1).eq.0.) zmflux(l+1)=0.
+         END DO
+
+! Mass of each layer
+! ------------------ 
+         zzmass(1:nlayer)=zmass(ig,1:nlayer)*(1.+pdpsrfmr(ig)*ptimestep/pplev(ig,1))
+
+
+!  Corresponding fluxes for T,U,V,Q
+!  """"""""""""""""""""""""""""""""
+
+!        averaging operator for TRANSPORT  
+!        """"""""""""""""""""""""""""""""
+!        Value transfert at the surface interface when condensation
+!        sublimation:
+         ztm(1) = ztsrf(ig)
+         zum(1) = 0.  
+         zvm(1) = 0.  
+         zqm(1,1:nq)=0. ! most tracer do not condense !
+         if (water) zqm(1,igcm_h2o_vap)=1. ! flux is 100% h2o at surface
+	 
+!        Van Leer scheme:
+         w(1:nlayer+1)=-zmflux(1:nlayer+1)*ptimestep
+         call vl1d(nlayer,zzt,2.,zzmass,w,ztm) 
+         call vl1d(nlayer,zzu,2.,zzmass,w,zum) 
+         call vl1d(nlayer,zzv,2.,zzmass,w,zvm) 
+         do iq=1,nq
+           zq1(1:nlayer)=zzq(1:nlayer,iq)
+           zqm1(1)=zqm(1,iq)
+!		print*,iq
+!		print*,zq1
+           call vl1d(nlayer,zq1,2.,zzmass,w,zqm1)
+           do l=2,nlayer
+              zzq(l,iq)=zq1(l)
+              zqm(l,iq)=zqm1(l)
+           enddo
+         enddo
+
+!        Surface condensation affects low winds
+         if (zmflux(1).lt.0) then 
+            zum(1)= zzu(1) *  (w(1)/zzmass(1))
+            zvm(1)= zzv(1) *  (w(1)/zzmass(1))
+            if (w(1).gt.zzmass(1)) then ! ensure numerical stability
+               zum(1)= (zzu(1)-zum(2))*zzmass(1)/w(1) + zum(2)
+               zvm(1)= (zzv(1)-zvm(2))*zzmass(1)/w(1) + zvm(2)
+            end if
+         end if
+                    
+         ztm(nlayer+1)= zzt(nlayer) ! should not be used, but... 
+         zum(nlayer+1)= zzu(nlayer)  ! should not be used, but...
+         zvm(nlayer+1)= zzv(nlayer)  ! should not be used, but...
+         zqm(nlayer+1,1:nq)= zzq(nlayer,1:nq)
+ 
+!        Tendencies on T, U, V, Q 
+!        """"""""""""""""""""""""
+         DO l=1,nlayer
+ 
+!           Tendencies on T
+            pdtmr(ig,l) = (1/zzmass(l)) *   &
+		(zmflux(l)*(ztm(l) - zzt(l))-zmflux(l+1)*(ztm(l+1)-zzt(l)))
+		  !JL12 the last term in Newcondens has been set to zero because we are only dealing with redistribution here
+
+!           Tendencies on U
+            pdumr(ig,l)   = (1/zzmass(l)) *( zmflux(l)*(zum(l) - zzu(l)) - zmflux(l+1)*(zum(l+1) - zzu(l)) )
+
+!           Tendencies on V
+            pdvmr(ig,l)   = (1/zzmass(l)) *( zmflux(l)*(zvm(l) - zzv(l)) - zmflux(l+1)*(zvm(l+1) - zzv(l)) )
+
+         END DO
+
+!        Tendencies on Q
+         do iq=1,nq
+            DO l=1,nlayer
+               pdqmr(ig,l,iq)= (1/zzmass(l)) *   &
+		   (zmflux(l)*(zqm(l,iq)-zzq(l,iq))- zmflux(l+1)*(zqm(l+1,iq)-zzq(l,iq)) - pdmassmr(ig,l)*zzq(l,iq))
+            END DO
+         enddo
+
+      END DO  ! loop on ig 
+
+CONTAINS
+
+! *****************************************************************
+      SUBROUTINE vl1d(llm,q,pente_max,zzmass,w,qm)
+!
+!    
+!     Operateur de moyenne inter-couche pour calcul de transport type
+!     Van-Leer " pseudo amont " dans la verticale
+!    q,w sont des arguments d'entree  pour le s-pg ....
+!    masse : masse de la couche Dp/g
+!    w : masse d'atm ``transferee'' a chaque pas de temps (kg.m-2)
+!    pente_max = 2 conseillee
+!
+!
+!   --------------------------------------------------------------------
+      
+      IMPLICIT NONE
+
+!   Arguments:
+!   ----------
+      integer,intent(in) :: llm
+      real zzmass(llm),pente_max
+      REAL q(llm),qm(llm+1)
+      REAL w(llm+1)
+!
+!      Local 
+!   ---------
+!
+      INTEGER l
+!
+      real dzq(llm),dzqw(llm),adzqw(llm),dzqmax
+      real sigw, Mtot, MQtot
+      integer m 
+!     integer ismax,ismin 
+
+
+!    On oriente tout dans le sens de la pression 
+!     W > 0 WHEN DOWN !!!!!!!!!!!!!
+
+      do l=2,llm
+            dzqw(l)=q(l-1)-q(l)
+            adzqw(l)=abs(dzqw(l))
+      enddo
+
+      do l=2,llm-1
+            if(dzqw(l)*dzqw(l+1).gt.0.) then
+                dzq(l)=0.5*(dzqw(l)+dzqw(l+1))
+            else
+                dzq(l)=0.
+            endif
+            dzqmax=pente_max*min(adzqw(l),adzqw(l+1))
+            dzq(l)=sign(min(abs(dzq(l)),dzqmax),dzq(l))
+      enddo
+
+         dzq(1)=0.
+         dzq(llm)=0.
+
+       do l = 1,llm-1
+
+!         Regular scheme (transfered mass < layer mass)
+!         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+          if(w(l+1).gt.0. .and. w(l+1).le.zzmass(l+1)) then
+             sigw=w(l+1)/zzmass(l+1)
+             qm(l+1)=(q(l+1)+0.5*(1.-sigw)*dzq(l+1))
+          else if(w(l+1).le.0. .and. -w(l+1).le.zzmass(l)) then
+             sigw=w(l+1)/zzmass(l)
+             qm(l+1)=(q(l)-0.5*(1.+sigw)*dzq(l))
+
+!         Extended scheme (transfered mass > layer mass)
+!         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+          else if(w(l+1).gt.0.) then
+             m=l+1
+             Mtot = zzmass(m)
+             MQtot = zzmass(m)*q(m)
+             do while ((m.lt.llm).and.(w(l+1).gt.(Mtot+zzmass(m+1))))
+                m=m+1
+                Mtot = Mtot + zzmass(m)
+                MQtot = MQtot + zzmass(m)*q(m)
+             end do
+             if (m.lt.llm) then
+                sigw=(w(l+1)-Mtot)/zzmass(m+1)
+                qm(l+1)= (1/w(l+1))*(MQtot + (w(l+1)-Mtot)*(q(m+1)+0.5*(1.-sigw)*dzq(m+1)) )
+             else
+!                w(l+1) = Mtot
+!                qm(l+1) = Mqtot / Mtot
+                write(*,*) 'top layer is disappearing !',l,Mtot,w(l+1),qm(l+1)
+		print*,zzmass
+ 		print*,w
+		print*,q
+		print*,qm
+               stop
+             end if
+          else      ! if(w(l+1).lt.0) 
+             m = l-1 
+             Mtot = zzmass(m+1)
+             MQtot = zzmass(m+1)*q(m+1)
+             if (m.gt.0) then ! because some compilers will have problems
+                              ! evaluating zzmass(0)
+              do while ((m.gt.0).and.(-w(l+1).gt.(Mtot+zzmass(m))))
+                m=m-1
+                Mtot = Mtot + zzmass(m+1)
+                MQtot = MQtot + zzmass(m+1)*q(m+1)
+                if (m.eq.0) exit
+              end do
+             endif
+             if (m.gt.0) then
+                sigw=(w(l+1)+Mtot)/zzmass(m)
+                qm(l+1)= (-1/w(l+1))*(MQtot + (-w(l+1)-Mtot)*(q(m)-0.5*(1.+sigw)*dzq(m))  )
+             else
+                qm(l+1)= (-1/w(l+1))*(MQtot + (-w(l+1)-Mtot)*qm(1))
+             end if   
+          end if
+       enddo
+
+!     boundary conditions (not used in newcondens !!)
+!         qm(llm+1)=0.
+!         if(w(1).gt.0.) then
+!            qm(1)=q(1)
+!         else 
+!           qm(1)=0.
+!         end if
+
+       END SUBROUTINE vl1d
+
+END SUBROUTINE mass_redistribution
Index: /trunk/LMDZ.TITAN/libf/phytitan/mkstat.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/mkstat.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/mkstat.F90	(revision 1644)
@@ -0,0 +1,197 @@
+subroutine mkstats(ierr)
+
+ 
+!
+!  This program writes a stats.nc file from sums and sums of squares
+!  to means and standard deviations and also writes netcdf style
+!  file so that the data can be viewed easily.  The data file is
+!  overwritten in place.  
+!  SRL  21 May 1996
+!  Yann W. july 2003
+
+use statto_mod, only: istime,count
+use mod_phys_lmdz_para, only : is_master
+use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev, klon_glo
+
+implicit none
+
+include "netcdf.inc"
+
+integer :: ierr,nid,nbvar,i,ndims,lt,nvarid
+integer, dimension(4) :: id,varid,start,size
+integer, dimension(5) :: dimids
+character (len=50) :: name,nameout,units,title
+real,allocatable :: sum3d(:,:,:),square3d(:,:,:),mean3d(:,:,:),sd3d(:,:,:)
+real,allocatable :: sum2d(:,:),square2d(:,:),mean2d(:,:),sd2d(:,:)
+real, dimension(istime) :: time
+real, dimension(nbp_lat) :: lat
+real,allocatable :: lon(:)
+real, dimension(nbp_lev) :: alt
+logical :: lcopy=.true.
+!integer :: latid,lonid,altid,timeid
+integer :: meanid,sdid
+!integer, dimension(4) :: dimout
+
+! Incrementation of count for the last step, which is not done in wstats
+count(istime)=count(istime)+1
+
+if (is_master) then
+! only the master needs do this
+if (klon_glo>1) then
+  allocate(lon(nbp_lon+1))
+  allocate(sum3d(nbp_lon+1,nbp_lat,nbp_lev))
+  allocate(square3d(nbp_lon+1,nbp_lat,nbp_lev))
+  allocate(mean3d(nbp_lon+1,nbp_lat,nbp_lev))
+  allocate(sd3d(nbp_lon+1,nbp_lat,nbp_lev))
+  allocate(sum2d(nbp_lon+1,nbp_lat))
+  allocate(square2d(nbp_lon+1,nbp_lat))
+  allocate(mean2d(nbp_lon+1,nbp_lat))
+  allocate(sd2d(nbp_lon+1,nbp_lat))
+else ! 1D model case
+  allocate(lon(1))
+  allocate(sum3d(1,1,nbp_lev))
+  allocate(square3d(1,1,nbp_lev))
+  allocate(mean3d(1,1,nbp_lev))
+  allocate(sd3d(1,1,nbp_lev))
+  allocate(sum2d(1,1))
+  allocate(square2d(1,1))
+  allocate(mean2d(1,1))
+  allocate(sd2d(1,1))
+endif
+
+ierr = NF_OPEN("stats.nc",NF_WRITE,nid)
+
+! We catch the id of dimensions of the stats file
+
+ierr= NF_INQ_DIMID(nid,"latitude",id(1))
+ierr= NF_INQ_DIMID(nid,"longitude",id(2))
+ierr= NF_INQ_DIMID(nid,"altitude",id(3))
+ierr= NF_INQ_DIMID(nid,"Time",id(4))
+
+ierr= NF_INQ_VARID(nid,"latitude",varid(1))
+ierr= NF_INQ_VARID(nid,"longitude",varid(2))
+ierr= NF_INQ_VARID(nid,"altitude",varid(3))
+ierr= NF_INQ_VARID(nid,"Time",varid(4))
+
+! Time initialisation
+
+do i=1,istime
+   time(i)=i*24./istime
+#ifdef NC_DOUBLE
+   ierr= NF_PUT_VARA_DOUBLE(nid,varid(4),i,1,time(i))
+#else
+   ierr= NF_PUT_VARA_REAL(nid,varid(4),i,1,time(i))
+#endif
+enddo
+
+! We catche the values of the variables
+
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VAR_DOUBLE(nid,varid(1),lat)
+         ierr = NF_GET_VAR_DOUBLE(nid,varid(2),lon)
+         ierr = NF_GET_VAR_DOUBLE(nid,varid(3),alt)
+#else
+         ierr = NF_GET_VAR_REAL(nid,varid(1),lat)
+         ierr = NF_GET_VAR_REAL(nid,varid(2),lon)
+         ierr = NF_GET_VAR_REAL(nid,varid(3),alt)
+#endif
+
+! We catch the number of variables in the stats file
+ierr = NF_INQ_NVARS(nid,nbvar)
+
+! to catche the "real" number of variables (without the "additionnal variables")
+nbvar=(nbvar-4)/2 
+
+do i=1,nbvar
+   varid=(i-1)*2+5
+
+   ! What's the variable's name?
+   ierr=NF_INQ_VARNAME(nid,varid,name)
+   write(*,*) "OK variable ",name
+   ! Its units?
+   units=" "
+   ierr=NF_GET_ATT_TEXT(nid,varid,"units",units)
+   ! Its title?
+   title=" "
+   ierr=NF_GET_ATT_TEXT(nid,varid,"title",title)
+   ! Its number of dimensions?   
+   ierr=NF_INQ_VARNDIMS(nid,varid,ndims)
+   ! Its values?
+
+   if(ndims==4) then ! lat, lon, alt & time
+
+!      dimout(1)=lonid
+!      dimout(2)=latid
+!      dimout(3)=altid
+!      dimout(4)=timeid
+
+      if (klon_glo>1) then ! general case
+        size=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
+      else ! 1D model
+        size=(/1,1,nbp_lev,1/)
+      endif
+      do lt=1,istime
+         start=(/1,1,1,lt/)
+         ! Extraction of the "source" variables
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VARA_DOUBLE(nid,varid,start,size,sum3d)
+         ierr = NF_GET_VARA_DOUBLE(nid,varid+1,start,size,square3d)
+#else
+         ierr = NF_GET_VARA_REAL(nid,varid,start,size,sum3d)
+         ierr = NF_GET_VARA_REAL(nid,varid+1,start,size,square3d)
+#endif
+         ! Calculation of these variables
+         mean3d=sum3d/count(lt)
+         sd3d=sqrt(max(0.,square3d/count(lt)-mean3d**2))
+         ! Writing of the variables
+#ifdef NC_DOUBLE
+         ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,size,mean3d)
+         ierr = NF_PUT_VARA_DOUBLE(nid,varid+1,start,size,sd3d)
+#else
+         ierr = NF_PUT_VARA_REAL(nid,varid,start,size,mean3d)
+         ierr = NF_PUT_VARA_REAL(nid,varid+1,start,size,sd3d)
+#endif
+      enddo
+
+    else if (ndims.eq.3) then
+
+!      dimout(1)=lonid
+!      dimout(2)=latid
+!      dimout(3)=timeid
+
+      if (klon_glo>1) then ! general case
+        size=(/nbp_lon+1,nbp_lat,1,0/)
+      else
+        size=(/1,1,1,0/)
+      endif
+      do lt=1,istime
+         start=(/1,1,lt,0/)
+         ! Extraction of the "source" variables
+#ifdef NC_DOUBLE
+         ierr = NF_GET_VARA_DOUBLE(nid,varid,start,size,sum2d)
+         ierr = NF_GET_VARA_DOUBLE(nid,varid+1,start,size,square2d)
+#else
+         ierr = NF_GET_VARA_REAL(nid,varid,start,size,sum2d)
+         ierr = NF_GET_VARA_REAL(nid,varid+1,start,size,square2d)
+#endif
+         ! Calculation of these variables
+         mean2d=sum2d/count(lt)
+         sd2d=sqrt(max(0.,square2d/count(lt)-mean2d**2))
+         ! Writing of the variables
+#ifdef NC_DOUBLE
+         ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,size,mean2d)
+         ierr = NF_PUT_VARA_DOUBLE(nid,varid+1,start,size,sd2d)
+#else
+         ierr = NF_PUT_VARA_REAL(nid,varid,start,size,mean2d)
+         ierr = NF_PUT_VARA_REAL(nid,varid+1,start,size,sd2d)
+#endif
+      enddo
+
+    endif 
+enddo
+
+ierr= NF_CLOSE(nid)
+
+endif ! of if (is_master)
+
+end
Index: /trunk/LMDZ.TITAN/libf/phytitan/moistadj.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/moistadj.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/moistadj.F90	(revision 1644)
@@ -0,0 +1,330 @@
+subroutine moistadj(ngrid, nlayer, nq, pt, pq, pdq, pplev, pplay, pdtmana, pdqmana, ptimestep, rneb)
+
+  use watercommon_h, only: T_h2O_ice_liq, RLVTT, RCPD, RCPV, Psat_water, Lcpdqsat_water
+  USE tracer_h, only: igcm_h2o_vap, igcm_h2o_ice
+  use comcstfi_mod, only: r
+
+  implicit none
+
+
+!=====================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates moist convective adjustment by the method of Manabe.
+!     
+!     Authors
+!     -------
+!     Adapted from the LMDTERRE code by R. Wordsworth (2010)
+!     Original author Z. X. Li (1993)
+!     
+!=====================================================================
+
+      INTEGER,INTENT(IN) :: ngrid, nlayer, nq
+
+      REAL,INTENT(IN) :: pt(ngrid,nlayer) ! temperature (K)
+      REAL,INTENT(IN) :: pq(ngrid,nlayer,nq) ! tracer (kg/kg)
+      REAL,INTENT(IN) :: pdq(ngrid,nlayer,nq)
+      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      REAL,INTENT(IN) :: pplay(ngrid,nlayer)   ! mid-layer pressure (Pa)
+      REAL,INTENT(IN) :: ptimestep ! physics timestep (s)
+      REAL,INTENT(OUT) :: pdqmana(ngrid,nlayer,nq)  ! tracer tendencies (kg/kg.s-1)
+      REAL,INTENT(OUT) :: pdtmana(ngrid,nlayer) ! temperature increment(K/s)
+      REAL,INTENT(OUT) :: rneb(ngrid,nlayer) ! cloud fraction 
+
+!     local variables
+      REAL zt(ngrid,nlayer)      ! temperature (K)
+      REAL zq(ngrid,nlayer)      ! humidite specifique (kg/kg)
+
+      REAL d_t(ngrid,nlayer)     ! temperature increment
+      REAL d_q(ngrid,nlayer)     ! incrementation pour vapeur d'eau
+      REAL d_ql(ngrid,nlayer)    ! incrementation pour l'eau liquide
+
+!      REAL t_coup
+!      PARAMETER (t_coup=234.0)
+      REAL seuil_vap
+      PARAMETER (seuil_vap=1.0E-10)
+
+!     Local variables
+      INTEGER i, k, iq, nn
+      INTEGER, PARAMETER :: niter = 1
+      INTEGER k1, k1p, k2, k2p
+      LOGICAL itest(ngrid)
+      REAL delta_q(ngrid, nlayer)
+      DOUBLE PRECISION :: cp_new_t(nlayer), v_cptt(ngrid,nlayer)
+      REAL cp_delta_t(nlayer)
+      DOUBLE PRECISION :: v_cptj(nlayer), v_cptjk1, v_ssig
+      REAL v_p, v_t, v_zqs,v_cptt2,v_pratio,v_dlnpsat
+      REAL zqs(ngrid,nlayer), zdqs(ngrid,nlayer),zpsat(ngrid,nlayer),zdlnpsat(ngrid,nlayer)
+      REAL zq1(ngrid), zq2(ngrid)
+      DOUBLE PRECISION :: gamcpdz(ngrid,2:nlayer)
+      DOUBLE PRECISION :: zdp, zdpm
+
+      REAL zsat ! super-saturation
+      REAL zflo ! flotabilite
+
+      DOUBLE PRECISION :: local_q(ngrid,nlayer),local_t(ngrid,nlayer)
+
+      REAL zdelta, zcor, zcvm5
+
+      REAL dEtot, dqtot, masse ! conservation diagnostics
+      real dL1tot, dL2tot
+
+!     Indices of water vapour and water ice tracers
+      INTEGER,SAVE :: i_h2o=0  ! water vapour
+      INTEGER,SAVE :: i_ice=0  ! water ice
+!$OMP THREADPRIVATE(i_h2o,i_ice)
+
+      LOGICAL,SAVE :: firstcall=.TRUE.
+!$OMP THREADPRIVATE(firstcall)
+
+      IF (firstcall) THEN
+
+         i_h2o=igcm_h2o_vap
+         i_ice=igcm_h2o_ice
+        
+         write(*,*) "rain: i_ice=",i_ice
+         write(*,*) "      i_h2o=",i_h2o
+
+         firstcall = .FALSE.
+      ENDIF
+
+!     GCM -----> subroutine variables
+      zq(1:ngrid,1:nlayer)    = pq(1:ngrid,1:nlayer,i_h2o)+ pdq(1:ngrid,1:nlayer,i_h2o)*ptimestep
+      zt(1:ngrid,1:nlayer)    = pt(1:ngrid,1:nlayer)
+      pdqmana(1:ngrid,1:nlayer,1:nq)=0.0
+
+      DO k = 1, nlayer
+       DO i = 1, ngrid
+         if(zq(i,k).lt.0.)then
+            zq(i,k)=0.0
+         endif
+       ENDDO
+      ENDDO
+      
+      local_q(1:ngrid,1:nlayer) = zq(1:ngrid,1:nlayer)
+      local_t(1:ngrid,1:nlayer) = zt(1:ngrid,1:nlayer)
+      rneb(1:ngrid,1:nlayer) = 0.0
+      d_ql(1:ngrid,1:nlayer) = 0.0
+      d_t(1:ngrid,1:nlayer)  = 0.0
+      d_q(1:ngrid,1:nlayer)  = 0.0
+
+!     Calculate v_cptt
+      DO k = 1, nlayer
+         DO i = 1, ngrid
+            v_cptt(i,k) = RCPD * local_t(i,k)
+            v_t = MAX(local_t(i,k),15.)
+            v_p = pplay(i,k)
+
+            call Psat_water(v_t,v_p,zpsat(i,k),zqs(i,k))
+	    call Lcpdqsat_water(v_t,v_p,zpsat(i,k),zqs(i,k),zdqs(i,k),zdlnpsat(i,k))
+         ENDDO
+      ENDDO
+
+!     Calculate Gamma * Cp * dz: (gamma is the critical gradient)
+      DO k = 2, nlayer
+         DO i = 1, ngrid
+            zdp = pplev(i,k)-pplev(i,k+1)
+            zdpm = pplev(i,k-1)-pplev(i,k)
+!            gamcpdz(i,k) = ( ( R/RCPD /(zdpm+zdp) * (v_cptt(i,k-1)*zdpm + v_cptt(i,k)*zdp)          &
+!                +  RLVTT /(zdpm+zdp) * (zqs(i,k-1)*zdpm + zqs(i,k)*zdp) )                           &
+!	        * (pplay(i,k-1)-pplay(i,k)) / pplev(i,k) )                                          &
+!                / (1.0+ (zdqs(i,k-1)*zdpm + zdqs(i,k)*zdp)/(zdpm+zdp) )                    
+! general case where water is not a trace gas (JL13)
+            v_zqs     = (zqs(i,k-1)*zdpm + zqs(i,k)*zdp)/(zdpm+zdp)
+	    v_cptt2   = (v_cptt(i,k-1)*zdpm + v_cptt(i,k)*zdp)/(zdpm+zdp)
+	    v_pratio  = ((1.-zpsat(i,k-1)/pplay(i,k-1))*zdpm + (1.-zpsat(i,k)/pplay(i,k))*zdp)/(zdpm+zdp)
+	    v_dlnpsat = (zdlnpsat(i,k-1)*zdpm + zdlnpsat(i,k)*zdp)/(zdpm+zdp)
+            gamcpdz(i,k) = ( (R/RCPD*v_cptt2*(1.- v_zqs) + RLVTT*v_zqs) * (pplay(i,k-1)-pplay(i,k))/pplev(i,k) )  &
+                / (((1.- v_zqs) + v_zqs * RCPV/RCPD)*v_pratio + v_zqs  * v_dlnpsat)                
+         ENDDO
+      ENDDO
+
+!------------------------------------ modification of unstable profile
+      DO 9999 i = 1, ngrid
+
+      itest(i) = .FALSE.
+
+!        print*,'we in the loop'
+!        stop    
+
+      k1 = 0
+      k2 = 1
+
+  810 CONTINUE ! look for k1, the base of the column
+      k2 = k2 + 1
+      IF (k2 .GT. nlayer) GOTO 9999
+      zflo = v_cptt(i,k2-1) - v_cptt(i,k2) - gamcpdz(i,k2)
+      zsat=(local_q(i,k2-1)-zqs(i,k2-1))*(pplev(i,k2-1)-pplev(i,k2))   &
+         +(local_q(i,k2)-zqs(i,k2))*(pplev(i,k2)-pplev(i,k2+1))
+
+      IF ( zflo.LE.0.0 .OR. zsat.LE.0.0 ) GOTO 810
+      k1 = k2 - 1
+      itest(i) = .TRUE.
+
+  820 CONTINUE !! look for k2, the top of the column
+      IF (k2 .EQ. nlayer) GOTO 821
+      k2p = k2 + 1
+      zsat=zsat+(pplev(i,k2p)-pplev(i,k2p+1))*(local_q(i,k2p)-zqs(i,k2p))
+      zflo = v_cptt(i,k2p-1) - v_cptt(i,k2p) - gamcpdz(i,k2p)
+
+      IF (zflo.LE.0.0 .OR. zsat.LE.0.0) GOTO 821
+      k2 = k2p
+      GOTO 820
+  821 CONTINUE
+
+!------------------------------------------------------ local adjustment
+  830 CONTINUE ! actual adjustment
+    Do nn=1,niter
+      v_cptj(k1) = 0.0
+      zdp = pplev(i,k1)-pplev(i,k1+1)
+      v_cptjk1 = ( (1.0+zdqs(i,k1))*(v_cptt(i,k1)+v_cptj(k1)) + RLVTT*(local_q(i,k1)-zqs(i,k1)) ) * zdp
+      v_ssig = zdp * (1.0+zdqs(i,k1))
+
+      k1p = k1 + 1
+      DO k = k1p, k2
+         zdp = pplev(i,k)-pplev(i,k+1)
+         v_cptj(k) = v_cptj(k-1) + gamcpdz(i,k)
+         v_cptjk1 = v_cptjk1 + zdp * ( (1.0+zdqs(i, k))*(v_cptt(i,k)+v_cptj(k)) + RLVTT*(local_q(i,k)-zqs(i,k)) )        
+         v_ssig = v_ssig + zdp *(1.0+zdqs(i,k))
+      ENDDO
+
+
+      ! this right here is where the adjustment is done???
+      DO k = k1, k2
+         cp_new_t(k) = v_cptjk1/v_ssig - v_cptj(k)
+         cp_delta_t(k) = cp_new_t(k) - v_cptt(i,k)
+         v_cptt(i,k)=cp_new_t(k)
+         local_q(i,k) = zqs(i,k) + zdqs(i,k)*cp_delta_t(k)/RLVTT
+         local_t(i,k) = cp_new_t(k) / RCPD
+
+         v_t = MAX(local_t(i,k),15.)
+         v_p = pplay(i,k)
+         
+         call Psat_water(v_t,v_p,zpsat(i,k),zqs(i,k))
+         call Lcpdqsat_water(v_t,v_p,zpsat(i,k),zqs(i,k),zdqs(i,k),zdlnpsat(i,k))
+
+      ENDDO
+    Enddo ! nn=1,niter
+
+
+!--------------------------------------------------- sounding downwards
+!              -- we refine the prognostic variables in
+!              -- the layer about to be adjusted
+
+!      DO k = k1, k2
+!         v_cptt(i,k) = RCPD * local_t(i,k)
+!         v_t = local_t(i,k)
+!         v_p = pplay(i,k)
+!       
+!         call Psat_water(v_t,v_p,zpsat,zqs(i,k))
+!         call Lcpdqsat_water(v_t,v_p,zpsat,zqs(i,k),zdqs(i,k))
+!      ENDDO
+
+      DO k = 2, nlayer
+         zdpm = pplev(i,k-1) - pplev(i,k)
+         zdp = pplev(i,k) - pplev(i,k+1)
+!         gamcpdz(i,k) = ( ( R/RCPD /(zdpm+zdp) * (v_cptt(i,k-1)*zdpm + v_cptt(i,k)*zdp)          &
+!             +  RLVTT /(zdpm+zdp) * (zqs(i,k-1)*zdpm + zqs(i,k)*zdp) )                           &
+!	      * (pplay(i,k-1)-pplay(i,k)) / pplev(i,k) )                                          &
+!             / (1.0+ (zdqs(i,k-1)*zdpm + zdqs(i,k)*zdp)/(zdpm+zdp) )                    
+! general case where water is not a trace gas (JL13)
+         v_zqs     = (zqs(i,k-1)*zdpm + zqs(i,k)*zdp)/(zdpm+zdp)
+	 v_cptt2   = (v_cptt(i,k-1)*zdpm + v_cptt(i,k)*zdp)/(zdpm+zdp)
+	 v_pratio  = ((1.-zpsat(i,k-1)/pplay(i,k-1))*zdpm + (1.-zpsat(i,k)/pplay(i,k))*zdp)/(zdpm+zdp)
+	 v_dlnpsat = (zdlnpsat(i,k-1)*zdpm + zdlnpsat(i,k)*zdp)/(zdpm+zdp)
+         gamcpdz(i,k) = ( (R/RCPD*v_cptt2*(1.- v_zqs) + RLVTT*v_zqs) * (pplay(i,k-1)-pplay(i,k))/pplev(i,k) )  &
+                / (((1.- v_zqs) + v_zqs * RCPV/RCPD)*v_pratio + v_zqs  * v_dlnpsat)                
+      ENDDO
+
+!     Test to see if we've reached the bottom
+
+      IF (k1 .EQ. 1) GOTO 841 ! yes we have!
+      zflo = v_cptt(i,k1-1) - v_cptt(i,k1) - gamcpdz(i,k1)
+      zsat=(local_q(i,k1-1)-zqs(i,k1-1))*(pplev(i,k1-1)-pplev(i,k1))   &
+        + (local_q(i,k1)-zqs(i,k1))*(pplev(i,k1)-pplev(i,k1+1))
+      IF (zflo.LE.0.0 .OR. zsat.LE.0.0) GOTO 841 ! yes we have!
+
+  840 CONTINUE
+      k1 = k1 - 1
+      IF (k1 .EQ. 1) GOTO 830 ! GOTO 820 (a tester, Z.X.Li, mars 1995)
+      zsat = zsat + (local_q(i,k1-1)-zqs(i,k1-1))               &
+                  *(pplev(i,k1-1)-pplev(i,k1))
+      zflo = v_cptt(i,k1-1) - v_cptt(i,k1) - gamcpdz(i,k1)
+      IF (zflo.GT.0.0 .AND. zsat.GT.0.0) THEN
+         GOTO 840
+      ELSE
+         GOTO 830 ! GOTO 820 (a tester, Z.X.Li, mars 1995)
+      ENDIF
+  841 CONTINUE
+
+      GOTO 810 ! look for other layers higher up
+
+ 9999 CONTINUE ! loop over all the points
+
+!-----------------------------------------------------------------------
+! Determine the cloud fraction (hypothese: la nebulosite a lieu
+! a l'endroit ou la vapeur d'eau est diminuee par l'ajustement):
+
+      DO k = 1, nlayer
+      DO i = 1, ngrid
+         IF (itest(i)) THEN
+         delta_q(i,k) = local_q(i,k) - zq(i,k)
+         IF (delta_q(i,k).LT.0.) rneb(i,k)  = 1.0
+         ENDIF
+      ENDDO
+      ENDDO
+
+! Distribuer l'eau condensee en eau liquide nuageuse (hypothese:
+! l'eau liquide est distribuee aux endroits ou la vapeur d'eau
+! diminue et d'une maniere proportionnelle a cet diminution):
+
+      DO i = 1, ngrid
+         IF (itest(i)) THEN
+         zq1(i) = 0.0
+         zq2(i) = 0.0
+         ENDIF
+      ENDDO
+      DO k = 1, nlayer
+      DO i = 1, ngrid
+         IF (itest(i)) THEN
+         zdp = pplev(i,k)-pplev(i,k+1)
+         zq1(i) = zq1(i) - delta_q(i,k) * zdp
+         zq2(i) = zq2(i) - MIN(0.0, delta_q(i,k)) * zdp
+         ENDIF
+      ENDDO
+      ENDDO
+      DO k = 1, nlayer
+      DO i = 1, ngrid
+         IF (itest(i)) THEN
+           IF (zq2(i).NE.0.0) d_ql(i,k) = - MIN(0.0,delta_q(i,k))*zq1(i)/zq2(i)
+         ENDIF
+      ENDDO
+      ENDDO
+
+      DO k = 1, nlayer
+      DO i = 1, ngrid
+          local_q(i, k) = MAX(local_q(i, k), seuil_vap)
+      ENDDO
+      ENDDO
+
+      DO k = 1, nlayer
+      DO i = 1, ngrid
+         d_t(i,k) = local_t(i,k) - zt(i,k)
+         d_q(i,k) = local_q(i,k) - zq(i,k)
+      ENDDO
+      ENDDO
+
+!     now subroutine -----> GCM variables
+      DO k = 1, nlayer
+         DO i = 1, ngrid
+            
+            pdtmana(i,k)       = d_t(i,k)/ptimestep
+            pdqmana(i,k,i_h2o) = d_q(i,k)/ptimestep
+            pdqmana(i,k,i_ice) = d_ql(i,k)/ptimestep
+         
+         ENDDO
+      ENDDO
+
+
+   END
Index: /trunk/LMDZ.TITAN/libf/phytitan/mucorr.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/mucorr.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/mucorr.F	(revision 1644)
@@ -0,0 +1,113 @@
+      SUBROUTINE mucorr(npts,pdeclin, plat, pmu,pfract,phaut,prad,pflat)
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Calcul of equivalent solar angle and and fraction of day whithout 
+c   diurnal cycle.
+c
+c   parmeters :
+c   -----------
+c
+c      Input :
+c      -------
+c         npts             number of points
+c         pdeclin          solar declinaison
+c         plat(npts)        latitude
+c         phaut            hauteur typique de l'atmosphere
+c         prad             rayon planetaire
+c
+c      Output :
+c      --------
+c         pmu(npts)          equivalent cosinus of the solar angle
+c         pfract(npts)       fractionnal day
+c
+c=======================================================================
+
+c-----------------------------------------------------------------------
+c
+c    0. Declarations :
+c    -----------------
+
+c     Arguments :
+c     -----------
+      INTEGER npts
+      REAL plat(npts),pmu(npts), pfract(npts)
+      REAL phaut,prad,pdeclin, pflat
+c
+c     Local variables :
+c     -----------------
+      INTEGER j
+      REAL pi
+      REAL z,cz,sz,tz,phi,cphi,sphi,tphi
+      REAL ap,a,t,b, tp, rap
+      REAL alph
+
+c-----------------------------------------------------------------------
+
+c----- SG: geometry adapted to a flattened planet (Feb2014)
+
+      pi = 4. * atan(1.0)
+      z = pdeclin
+      cz = cos (z)
+      sz = sin (z)
+      rap = 1./((1.-pflat)**2)
+
+      DO 20 j = 1, npts
+
+         phi = plat(j)
+         cphi = cos(phi)
+         if (cphi.le.1.e-9) cphi=1.e-9
+         sphi = sin(phi)
+         tphi = sphi / cphi
+         b = cphi * cz
+         t = -rap*tphi * sz / cz
+         a = 1.0 - t*t
+         ap = a
+   
+         IF(t.eq.0.) then
+            tp=0.5*pi
+         ELSE
+            IF (a.lt.0.) a = 0.
+            t = sqrt(a) / t
+            IF (t.lt.0.) then
+               tp = -atan (-t) + pi
+            ELSE
+               tp = atan(t)
+            ENDIF
+         ENDIF
+         t = tp
+   
+         pmu(j) = (sphi*sz*t*rap) / pi + b*sin(t)/pi
+         pfract(j) = t / pi
+         IF (ap .lt.0.) then
+            pmu(j) = sphi * sz*rap
+            pfract(j) = 1.0
+         ENDIF
+         IF (pmu(j).le.0.0) pmu(j) = 0.0
+         pmu(j) = pmu(j) / pfract(j)
+         IF (pmu(j).eq.0.) pfract(j) = 0.
+
+         pmu(j)=pmu(j)/SQRT(cphi**2 + (rap**2) * (sphi**2))
+
+   20 CONTINUE
+
+c-----------------------------------------------------------------------
+c   correction de rotondite:
+c   ------------------------
+
+      ! condition added to avoid errors when rad is not set (e.g. 1D runs)
+      IF (prad.ne.0) THEN
+  
+      alph=phaut/prad
+      DO 30 j=1,npts
+c !!!!!!
+ !!!!!!! AS: how generic is this???
+         pmu(j)=sqrt(1224.*pmu(j)*pmu(j)+1.)/35.
+c    $          (sqrt(alph*alph*pmu(j)*pmu(j)+2.*alph+1.)-alph*pmu(j))
+30    CONTINUE
+
+      ENDIF
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/mufract.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/mufract.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/mufract.F	(revision 1644)
@@ -0,0 +1,92 @@
+      SUBROUTINE mufract(jjm,pdecli, plat, pmu, pfract)
+      IMPLICIT NONE
+c
+c=======================================================================
+c
+c   Calcul of equivalent solar angle and and fraction of day without 
+c   diurnal cycle.
+c
+c   parmeters :
+c   -----------
+c
+c      Input :
+c      -------
+c         jjm              number of points
+c         pdecli           solar declinaison
+c         plat(jjm)        latitude
+c
+c      Output :
+c      --------
+c         pmu(jjm)          equivalent cosinus of the solar angle
+c         pfract(jjm)       fractionnal day
+c
+c
+c=======================================================================
+c
+c-----------------------------------------------------------------------
+c
+c    0. Declarations :
+c    -----------------
+c
+c     Arguments :
+c     -----------
+
+      INTEGER jjm
+      REAL plat(jjm),pmu(jjm), pfract(jjm)
+      REAL pdecli
+c
+c     Local variables :
+c     -----------------
+
+      INTEGER j
+      REAL pi
+      REAL z,cz,sz,tz,phi,cphi,sphi,tphi
+      REAL ap,a,t,b
+c
+c=======================================================================
+c
+      pi = 4. * atan(1.0)
+      z = pdecli
+      cz = cos (z*pi/180.)
+      sz = sin (z*pi/180.)
+c
+      DO 20 j = 1, jjm
+c
+         phi = plat(j)
+         cphi = cos(phi)
+         if (cphi.le.1.e-9) cphi=1.e-9
+         sphi = sin(phi)
+         tphi = sphi / cphi
+         b = cphi * cz
+         t = -tphi * sz / cz
+         a = 1.0 - t*t
+         ap = a
+         IF(t.eq.0.) THEN
+            t=0.5*pi
+         ELSE
+            IF (a.lt.0.) a = 0.
+            t = sqrt(a) / t
+            IF (t.lt.0.) THEN
+               t = -atan (-t) + pi
+            ELSE
+               t = atan(t)
+            ENDIF
+         ENDIF
+         pmu(j) = (sphi*sz*t) / pi + b*sin(t)/pi
+         pfract(j) = t / pi
+         IF (ap .lt.0.) THEN
+            pmu(j) = sphi * sz
+            pfract(j) = 1.0
+         ENDIF
+         IF (pmu(j).le.0.0) pmu(j) = 0.0
+         pmu(j) = pmu(j) / pfract(j)
+         IF (pmu(j).eq.0.) pfract(j) = 0.
+c
+   20 CONTINUE
+c
+      RETURN
+      END
+c
+c* end of mufract
+c=======================================================================
+c
Index: /trunk/LMDZ.TITAN/libf/phytitan/multipl.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/multipl.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/multipl.F	(revision 1644)
@@ -0,0 +1,17 @@
+      SUBROUTINE multipl(n,x1,x2,y)
+      IMPLICIT NONE
+c=======================================================================
+c
+c   multiplication de deux vecteurs
+c
+c=======================================================================
+c
+      INTEGER n,i
+      REAL x1(n),x2(n),y(n)
+c
+      DO 10 i=1,n
+         y(i)=x1(i)*x2(i)
+10    CONTINUE
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/newsedim.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/newsedim.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/newsedim.F	(revision 1644)
@@ -0,0 +1,197 @@
+      SUBROUTINE newsedim(ngrid,nlay,naersize,ptimestep,
+     &  pplev,masse,epaisseur,pt,rd,rho,pqi,wq)
+      
+      use comcstfi_mod, only: r, g
+      IMPLICIT NONE
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!      Calculates sedimentation of 1 tracer 
+!      of radius rd (m) and density rho (kg.m-3) 
+!     
+!==================================================================
+
+!-----------------------------------------------------------------------
+!   declarations
+!   ------------
+
+!   arguments
+!   ---------
+
+      integer,intent(in) :: ngrid  ! number of atmospheric columns
+      integer,intent(in) :: nlay  ! number of atmospheric layers
+      integer,intent(in) :: naersize   ! number of particle sizes (1 or number
+                                       ! of grid boxes)
+      real,intent(in) :: ptimestep ! physics time step (s)
+      real,intent(in) :: pplev(ngrid,nlay+1)   ! inter-layer pressures (Pa)
+      real,intent(in) :: pt(ngrid,nlay)    ! mid-layer temperatures (K)
+      real,intent(in) :: masse (ngrid,nlay) ! atmospheric mass (kg)
+      real,intent(in) :: epaisseur (ngrid,nlay)  ! thickness of atm. layers (m)
+      real,intent(in) :: rd(naersize) ! particle radius (m)
+      real,intent(in) :: rho ! particle density (kg.m-3)
+      real,intent(inout) :: pqi(ngrid,nlay)  ! tracer   (e.g. ?/kg)
+      real,intent(out) :: wq(ngrid,nlay+1)  ! flux of tracer during timestep (?/m-2)
+      
+c   local:
+c   ------
+
+      INTEGER l,ig, k, i
+      REAL rfall
+
+      LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+
+c    Traceurs :
+c    ~~~~~~~~ 
+      real traversee (ngrid,nlay)
+      real vstokes(ngrid,nlay)
+      real w(ngrid,nlay)
+      real ptop, dztop, Ep, Stra
+
+
+c    Physical constant
+c    ~~~~~~~~~~~~~~~~~
+c     Gas molecular viscosity (N.s.m-2)
+      real,parameter :: visc=1.e-5       ! CO2
+c     Effective gas molecular radius (m)
+      real,parameter :: molrad=2.2e-10   ! CO2
+
+c     local and saved variable
+      real,save :: a,b
+!$OMP THREADPRIVATE(a,b)
+
+c    ** un petit test de coherence
+c       --------------------------
+
+
+      !print*,'temporary fixed particle rad in newsedim!!'
+
+      IF (firstcall) THEN
+         firstcall=.false.
+
+
+
+!=======================================================================
+!     Preliminary calculations for sedimenation velocity
+
+!       - Constant to compute stokes speed simple formulae
+!        (Vstokes =  b * rho* r**2   avec   b= (2/9) * rho * g / visc
+         b = 2./9. * g / visc
+
+!       - Constant  to compute gas mean free path
+!        l= (T/P)*a, avec a = (  0.707*8.31/(4*pi*molrad**2 * avogadro))
+         a = 0.707*8.31/(4*3.1416* molrad**2  * 6.023e23)
+
+c       - Correction to account for non-spherical shape (Murphy et al.  1990)
+c   (correction = 0.85 for irregular particles, 0.5 for disk shaped particles)
+c        a = a    * 0.85
+
+
+      ENDIF
+
+c-----------------------------------------------------------------------
+c    1. initialisation
+c    -----------------
+
+c     Sedimentation velocity (m/s)
+c     ~~~~~~~~~~~~~~~~~~~~~~
+c     (stokes law corrected for low pressure by the Cunningham
+c     slip-flow correction  according to Rossow (Icarus 36, 1-50, 1978)
+       
+        do  l=1,nlay
+          do ig=1, ngrid
+            if (naersize.eq.1) then 
+              rfall=rd(1)
+            else
+              i=ngrid*(l-1)+ig
+              rfall=rd(i) ! how can this be correct!!?
+            endif  
+
+            vstokes(ig,l) = b * rho * rfall**2 *
+     &      (1 + 1.333* ( a*pt(ig,l)/pplev(ig,l) )/rfall)
+
+c           Layer crossing time (s) :
+            traversee(ig,l)= epaisseur(ig,l)/vstokes(ig,l)
+          end do
+        end do
+
+
+c     Calcul de la masse d'atmosphere correspondant a q transferee
+c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+c     (e.g. on recherche le niveau  en dessous de laquelle le traceur
+c      va traverser le niveau intercouche l : "dztop" est sa hauteur
+c      au dessus de l (m), "ptop" est sa pression (Pa))
+      do  l=1,nlay
+        do ig=1, ngrid
+             
+             dztop = vstokes(ig,l)*  ptimestep 
+             Ep=0
+             k=0
+           w(ig,l) = 0. !! JF+AS ajout initialisation (LK MARS)
+c **************************************************************
+c            Simple Method
+cc             w(ig,l) =
+cc     &       (1- exp(-dztop*g/(r*pt(ig,l))))*pplev(ig,l) / g
+cc             write(*,*) 'OK simple method l,w =', l, w(ig,l)
+cc            write(*,*) 'OK simple method dztop =', dztop
+           w(ig,l) = 1. - exp(-dztop*g/(r*pt(ig,l)))
+             !!! Diagnostic: JF. Fix: AS. Date: 05/11
+             !!! Probleme arrondi avec la quantite ci-dessus
+             !!! ---> vaut 0 pour -dztop*g/(r*pt(ig,l)) trop petit
+             !!! ---> dans ce cas on utilise le developpement limite !
+             !!! ---> exp(-x) = 1 - x lorsque x --> 0 avec une erreur de x^2 / 2  
+
+             IF ( w(ig,l) .eq. 0. ) THEN
+                w(ig,l) = ( dztop*g/(r*pt(ig,l)) ) * pplev(ig,l) / g
+             ELSE
+                w(ig,l) = w(ig,l) * pplev(ig,l) / g
+             ENDIF
+! LK borrowed simple method from Mars model (AS/JF)
+
+!**************************************************************
+cccc         Complex method :
+           if (dztop.gt.epaisseur(ig,l)) then
+cccc            Cas ou on "epuise" la couche l : On calcule le flux
+cccc            Venant de dessus en tenant compte de la variation de Vstokes
+
+               Ep= epaisseur(ig,l)
+               Stra= traversee(ig,l)
+               do while(dztop.gt.Ep.and.l+k+1.le.nlay)
+                 k=k+1
+                 dztop= Ep + vstokes(ig,l+k)*(ptimestep -Stra)
+                 Ep = Ep + epaisseur(ig,l+k)
+                 Stra = Stra + traversee(ig,l+k)
+               enddo 
+               Ep = Ep - epaisseur(ig,l+k)
+!             ptop=pplev(ig,l+k)*exp(-(dztop-Ep)*g/(r*pt(ig,l+k)))
+             ptop=exp(-(dztop-Ep)*g/(r*pt(ig,l+k)))
+	     IF ( ptop .eq. 1. ) THEN
+                !PRINT*, 'newsedim: exposant trop petit ', ig, l
+                ptop=pplev(ig,l+k) * ( 1. - (dztop-Ep)*g/(r*pt(ig,l+k)))
+             ELSE
+                ptop=pplev(ig,l+k) * ptop
+             ENDIF
+
+             w(ig,l) = (pplev(ig,l) - ptop)/g
+
+            endif   !!! complex method
+c
+cc           write(*,*) 'OK new    method l,w =', l, w(ig,l)
+cc           write(*,*) 'OK new    method dztop =', dztop
+cc       if(l.eq.7)write(*,*)'l=7,k,pplev,Ptop',pplev(ig,l),Ptop
+cc       if(l.eq.7)write(*,*)'l=7,dztop,Ep',dztop,Ep
+cc            if(l.eq.6)write(*,*)'l=6,k, w',k, w(1,l)
+cc            if(l.eq.7)write(*,*)'l=7,k, w',k, w(1,l)
+cc            if(l.eq.8)write(*,*)'l=8,k, w',k, w(1,l)
+c **************************************************************
+
+        end do
+      end do
+
+      call vlz_fi(ngrid,nlay,pqi,2.,masse,w,wq)
+c         write(*,*) ' newsed: wq(6), wq(7), q(6)',
+c    &                wq(1,6),wq(1,7),pqi(1,6)
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/newtrelax.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/newtrelax.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/newtrelax.F90	(revision 1644)
@@ -0,0 +1,128 @@
+subroutine newtrelax(ngrid,nlayer,mu0,sinlat,popsk,temp,pplay,pplev,dtrad,firstcall) 
+        
+  use comcstfi_mod, only: rcp, pi
+  use callkeys_mod, only: tau_relax
+  implicit none
+
+#include "netcdf.inc"
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Alternative Newtonian radiative transfer scheme.
+!     
+!     Authors
+!     -------
+!     R. Wordsworth (2010)
+!     
+!==================================================================
+ 
+ 
+  ! Input
+  integer,intent(in) :: ngrid, nlayer
+  logical,intent(in) :: firstcall
+  real,intent(in) :: mu0(ngrid)            ! cosine of sun incident angle
+  real,intent(in) :: sinlat(ngrid)         ! sine of latitude
+  real,intent(in) :: temp(ngrid,nlayer)    ! temperature at each layer (K)
+  real,intent(in) :: pplay(ngrid,nlayer)   ! pressure at each layer (Pa)
+  real,intent(in) :: pplev(ngrid,nlayer+1) ! pressure at each level (Pa)
+  real,intent(in) :: popsk(ngrid,nlayer)   ! pot. T to T converter
+
+  ! Output
+  real,intent(out) :: dtrad(ngrid,nlayer) 
+
+  ! Internal
+  real Trelax_V, Trelax_H
+  real,allocatable,dimension(:,:),save :: Trelax
+!$OMP THREADPRIVATE(Trelax)
+
+  real T_trop ! relaxation temperature at tropopause (K)
+  real T_surf ! relaxation temperature at surface (K)
+  real dT_EP  ! Equator-Pole relaxation temperature difference (K)
+
+  real sig, f_sig, sig_trop
+  integer l,ig
+
+
+  logical tidallocked
+  parameter (tidallocked = .true.)
+
+  ! Setup relaxation temperature  
+  if(firstcall) then
+
+     ALLOCATE(Trelax(ngrid,nlayer))
+
+     print*,'-----------------------------------------------------'
+     print*,'| ATTENTION: You are using a Newtonian cooling scheme'
+     print*,'| for the radiative transfer. This means that ALL'
+     print*,'| other physics subroutines must be switched off.'
+     print*,'-----------------------------------------------------'
+
+     if(tidallocked)then
+        do ig=1,ngrid
+
+           T_surf = 126. + 239.*mu0(ig)
+           T_trop = 140. + 52.*mu0(ig)
+           do l=1,nlayer
+
+              if(mu0(ig).le.0.0)then ! night side
+                 Trelax(ig,l)=0.0
+              else                   ! day side
+                 Trelax(ig,l) = T_surf*popsk(ig,l)
+                 if (Trelax(ig,l).lt.T_trop) Trelax(ig,l) = T_trop
+              endif
+
+           enddo
+        enddo
+
+     else
+
+        T_trop = 200.
+        T_surf = 288.
+        dT_EP  = 70.
+
+        sig_trop=(T_trop/T_surf)**(1./rcp)
+
+        do l=1,nlayer
+           do ig=1,ngrid
+
+              ! vertically varying component
+              Trelax_V = T_surf*popsk(ig,l)
+              if (Trelax_V.lt.T_trop) Trelax_V = T_trop
+              
+              ! horizontally varying component
+              sig = pplay(ig,l)/pplev(ig,1)
+              if(sig.ge.sig_trop)then
+                 f_sig=sin((pi/2)*((sig-sig_trop)/(1-sig_trop)))
+              else
+                 f_sig=0.0
+              endif
+              Trelax_H = -f_sig*dT_EP*(sinlat(ig)**2 - 1./3.)
+              
+              Trelax(ig,l) = Trelax_V + Trelax_H            
+           
+           enddo
+        enddo
+
+     endif
+
+  endif
+
+  ! Calculate radiative forcing
+  do l=1,nlayer
+     do ig=1,ngrid
+        dtrad(ig,l) = -(temp(ig,l) - Trelax(ig,l)) / tau_relax
+        if(temp(ig,l).gt.500.)then ! Trelax(ig,l))then
+           print*,'ig=',ig
+           print*,'l=',l
+           print*,'temp=',temp(ig,l)
+           print*,'Trelax=',Trelax(ig,l)
+        endif
+     enddo
+  enddo
+
+  call writediagfi(ngrid,'Tref','rad forc temp','K',3,Trelax)
+  !call writediagfi(ngrid,'ThetaZ','stellar zenith angle','deg',2,mu0)
+
+end subroutine newtrelax
Index: /trunk/LMDZ.TITAN/libf/phytitan/ocean_slab_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/ocean_slab_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/ocean_slab_mod.F90	(revision 1644)
@@ -0,0 +1,766 @@
+!
+! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ocean_slab_mod.F90,v 1.3 2008-02-04 16:24:28 fairhead Exp $
+!
+MODULE ocean_slab_mod
+!
+! This module is used for both surface ocean and sea-ice when using the slab ocean,
+! "ocean=slab".
+!
+
+
+      use slab_ice_h
+      use watercommon_h, only: T_h2O_ice_liq
+      use surf_heat_transp_mod
+      implicit none
+
+
+
+
+
+  
+  !LOGICAL, PRIVATE, SAVE  :: ok_slab_sic,ok_slab_heaT_h2O_ice_liqBS
+  !!$OMP THREADPRIVATE(ok_slab_sic,ok_slab_heaT_h2O_ice_liqBS)
+  !INTEGER, PRIVATE, SAVE                           :: slab_ekman, slab_cadj
+  !!$OMP THREADPRIVATE(slab_ekman,slab_cadj)
+  INTEGER, PRIVATE, SAVE                           :: lmt_pas, julien, idayvrai
+  !$OMP THREADPRIVATE(lmt_pas,julien,idayvrai)
+  INTEGER, PRIVATE, SAVE                           :: cpl_pas
+  !$OMP THREADPRIVATE(cpl_pas)
+  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE   :: tmp_seaice
+  !$OMP THREADPRIVATE(tmp_seaice)
+  REAL, ALLOCATABLE, DIMENSION(:,:), PRIVATE, SAVE   :: tmp_tslab_loc
+  !$OMP THREADPRIVATE(tmp_tslab_loc)
+  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE   :: slab_bils
+  !$OMP THREADPRIVATE(slab_bils)
+  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE , SAVE  :: lmt_bils
+  !$OMP THREADPRIVATE(lmt_bils)
+  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE :: tmp_pctsrf_slab
+  !$OMP THREADPRIVATE(tmp_pctsrf_slab)
+  REAL, ALLOCATABLE, DIMENSION(:,:), PRIVATE, SAVE   :: tmp_tslab
+  !$OMP THREADPRIVATE(tmp_tslab)
+  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE   :: tmp_radsol
+  !$OMP THREADPRIVATE(tmp_radsol)
+  REAL, ALLOCATABLE, DIMENSION(:,:), PRIVATE, SAVE   :: dt_hdiff
+  !$OMP THREADPRIVATE(dt_hdiff)
+  REAL, ALLOCATABLE, DIMENSION(:,:), PRIVATE, SAVE   :: dt_ekman
+  !$OMP THREADPRIVATE(dt_ekman)
+  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE   :: tmp_flux_o, tmp_flux_g
+  !$OMP THREADPRIVATE(tmp_flux_o,tmp_flux_g)
+  REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE   :: slabh
+  !$OMP THREADPRIVATE(slabh)
+  LOGICAL, PRIVATE, SAVE                           :: check = .FALSE.
+  !$OMP THREADPRIVATE(check)
+
+CONTAINS
+!
+!****************************************************************************************
+!
+  SUBROUTINE ocean_slab_init(ngrid,dtime, tslab_rst, seaice_rst, pctsrf_rst)
+
+      use slab_ice_h
+
+
+
+
+! Input variables
+!****************************************************************************************
+        
+    integer,intent(in) :: ngrid ! number of atmospherci columns
+    REAL, INTENT(IN)                         :: dtime
+! Variables read from restart file
+    REAL, DIMENSION(ngrid,noceanmx), INTENT(IN)  :: tslab_rst         
+    REAL, DIMENSION(ngrid), INTENT(IN)        :: seaice_rst
+    REAL, DIMENSION(ngrid), INTENT(IN) :: pctsrf_rst
+
+
+! Local variables
+!****************************************************************************************
+    INTEGER                :: error
+    CHARACTER (len = 80)   :: abort_message
+    CHARACTER (len = 20)   :: modname = 'ocean_slab_intit'
+
+
+    print*,'************************'
+    print*,'SLAB OCEAN est actif, prenez precautions !'
+    print*,'************************'    
+
+! Lecture des parametres:
+!    CALL getpar('ok_slab_sic',.true.,ok_slab_sic,'glace de mer dans slab')
+!    CALL getpar('slab_ekman',0,slab_ekman,'type transport Ekman pour slab (0=rien)')
+!    CALL getpar('slab_cadj',1,slab_cadj,'type ajustement conv slab 2 couches')
+
+! Allocate variables initialize from restart fields
+      ALLOCATE(tmp_tslab(ngrid,noceanmx), stat = error)
+      IF (error /= 0) THEN
+         abort_message='Pb allocation tmp_tslab'
+         CALL abort_gcm(modname,abort_message,1)
+      ENDIF
+      tmp_tslab(:,:) = tslab_rst(:,:)
+      ALLOCATE(tmp_tslab_loc(ngrid,noceanmx), stat = error)
+      IF (error /= 0) THEN
+         abort_message='Pb allocation tmp_tslab_loc'
+         CALL abort_gcm(modname,abort_message,1)
+      ENDIF
+      tmp_tslab_loc(:,:) = tslab_rst(:,:)
+
+    ALLOCATE(tmp_seaice(ngrid), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation tmp_seaice'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    tmp_seaice(:) = seaice_rst(:)
+
+    ALLOCATE(tmp_pctsrf_slab(ngrid), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation tmp_pctsrf_slab'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    tmp_pctsrf_slab(:) = pctsrf_rst(:)
+    
+! Allocate some other variables internal in module mod_oceanslab
+    ALLOCATE(tmp_radsol(ngrid), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation tmp_radsol'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+
+    ALLOCATE(tmp_flux_o(ngrid), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation tmp_flux_o'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    
+    ALLOCATE(tmp_flux_g(ngrid), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation tmp_flux_g'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+
+! a mettre un slab_bils aussi en force !!!
+    ALLOCATE(slab_bils(ngrid), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation slab_bils'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    slab_bils(:) = 0.0   
+
+    ALLOCATE(dt_hdiff(ngrid,noceanmx), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation dt_hdiff'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    dt_hdiff = 0.0   
+
+    ALLOCATE(dt_ekman(ngrid,noceanmx), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation dt_hdiff'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    dt_ekman = 0.0   
+
+
+    ALLOCATE(lmt_bils(ngrid), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation lmt_bils'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    lmt_bils(:) = 0.0
+
+    ALLOCATE(slabh(noceanmx), stat = error)
+    IF (error /= 0) THEN
+       abort_message='Pb allocation slabh'
+       CALL abort_gcm(modname,abort_message,1)
+    ENDIF
+    slabh(1)=50.
+    IF (noceanmx.GE.2) slabh(2)=150.
+    IF (noceanmx.GE.3) slabh(3)=2800.
+
+
+!       CALL init_masquv
+
+
+
+
+  END SUBROUTINE ocean_slab_init
+!
+!****************************************************************************************
+!
+ 
+!
+!****************************************************************************************
+!
+  SUBROUTINE ocean_slab_ice(dtime, &
+       ngrid, knindex, tsurf, radsol, &
+       precip_snow, snow, evap, &
+       fluxsens,tsurf_new, pctsrf_sic, &
+       taux_slab,tauy_slab,icount)
+
+      use slab_ice_h
+      use callkeys_mod, only: ok_slab_sic
+
+
+! Input arguments  
+!****************************************************************************************
+    INTEGER, INTENT(IN)                     :: ngrid
+    INTEGER, DIMENSION(ngrid), INTENT(IN) :: knindex
+    REAL, INTENT(IN)                        :: dtime
+    REAL, DIMENSION(ngrid), INTENT(IN)    :: tsurf
+    REAL, DIMENSION(ngrid), INTENT(IN)    :: taux_slab
+    REAL, DIMENSION(ngrid), INTENT(IN)    :: tauy_slab
+    REAL, DIMENSION(ngrid), INTENT(IN)    :: evap, fluxsens
+    REAL, DIMENSION(ngrid), INTENT(IN)    :: precip_snow
+    REAL, DIMENSION(ngrid), INTENT(IN)    :: radsol
+    INTEGER, INTENT(IN)                     :: icount
+
+
+!In/Output arguments
+!****************************************************************************************l
+    REAL, DIMENSION(ngrid), INTENT(INOUT)          :: snow
+
+!    REAL, DIMENSION(ngridmx), INTENT(INOUT)          :: agesno
+
+
+! Output arguments
+!****************************************************************************************
+!    REAL, DIMENSION(ngridmx), INTENT(OUT)            :: alb1_new  ! new albedo in visible SW interval
+!    REAL, DIMENSION(ngridmx), INTENT(OUT)            :: alb2_new  ! new albedo in near IR interval
+    REAL, DIMENSION(ngrid), INTENT(OUT)            :: tsurf_new     
+    REAL, DIMENSION(ngrid), INTENT(OUT)            :: pctsrf_sic
+
+! Local variables
+!****************************************************************************************
+    INTEGER                                 :: i
+    REAL, DIMENSION(ngrid)                :: cal, beta, dif_grnd, capsol
+    REAL, DIMENSION(ngrid)                :: alb_neig, alb_ice!, tsurf_temp
+    REAL, DIMENSION(ngrid)                :: soilcap, soilflux
+    REAL, DIMENSION(ngrid)                :: zfra
+    REAL                                    :: snow_evap, fonte 
+    REAL, DIMENSION(ngrid,noceanmx)        :: tslab
+    REAL, DIMENSION(ngrid)                :: seaice,tsea_ice ! glace de mer (kg/m2)
+    REAL, DIMENSION(ngrid)                :: pctsrf_new
+
+
+!*****************************************************************************
+
+
+! Initialization of output variables
+!    alb1_new(:) = 0.0
+
+!******************************************************************************
+! F. Codron: 3 cas 
+! -Glace interactive, quantité seaice : T glace suit modèle simple
+! -Pas de glace: T oce peut descendre en dessous de 0°C sans geler
+!*****************************************************************************
+
+       pctsrf_new(:)=tmp_pctsrf_slab(:)
+       tmp_radsol(:)=radsol(:)
+       tmp_flux_o(:)=fluxsens(:)
+
+    DO i = 1, ngrid
+       tsurf_new(i) = tsurf(knindex(i))
+       seaice(i)=tmp_seaice(knindex(i))
+
+
+
+       IF (pctsrf_new(knindex(i)) < EPSFRA) THEN
+          snow(i) = 0.0
+          tsurf_new(i) = T_h2O_ice_liq - 1.8
+          !IF (soil_model) tsoil(i,:) = T_h2O_ice_liq -1.8
+       ENDIF
+    ENDDO
+    tmp_flux_g(:) = 0.0
+    tsea_ice(:)=T_h2O_ice_liq-1.8
+! Calculs flux glace/mer et glace/air
+    IF (ok_slab_sic) THEN   
+!*********************************
+! Calcul de beta, heat capacity
+!********************************* 
+!    CALL calbeta(dtime, is_sic, knon, snow, qsol, beta, capsol, dif_grnd)
+    
+!    IF ((soil_model)) THEN 
+
+!    ELSE 
+!       dif_grnd = 1.0 / tau_gl
+!       cal = RCPD * calice
+!       WHERE (snow > 0.0) cal = RCPD * calsno 
+!    ENDIF
+!    tsurf_temp = tsurf_new
+!    beta = 1.0
+
+
+! **********************************************
+! Evolution avec glace interactive:
+! *************************************
+!      tsurf_new=tsurf_temp
+      DO i = 1, ngrid
+        IF (pctsrf_new(knindex(i)) .GT. epsfra) THEN
+! *************************************
+! + Calcul Flux entre glace et océan 
+! *************************************
+          tmp_flux_g(knindex(i))=(tsurf_new(i)-(T_h2O_ice_liq-1.8)) &
+            * ice_cond*ice_den/seaice(i)
+
+! ****************************************
+! + Calcul nouvelle température de la glace 
+! ****************************************
+          tsurf_new(i)=tsurf_new(i)+2*(radsol(i)+fluxsens(i) &
+             -tmp_flux_g(knindex(i))) &
+             /(ice_cap*seaice(i))*dtime
+
+! ***************************************
+! + Precip and evaporation of snow and ice
+! ***************************************
+! Add precip
+          IF (precip_snow(i).GT.0.) THEN
+            snow(i)=snow(i)+precip_snow(i)*dtime
+          ENDIF
+! Evaporation 
+          snow_evap=0.
+          IF (evap(i).GT.0.) THEN
+            snow_evap = MIN (snow(i) / dtime, evap(i))
+            snow(i) = snow(i) - snow_evap*dtime
+            snow(i) = MAX(0.0, snow(i))
+            seaice(i)=MAX(0.0,seaice(i)-(evap(i)-snow_evap)*dtime)
+          ENDIF
+        
+! *****************************************
+! + Fonte neige & glace par le haut
+! *****************************************
+! Snow melt
+          IF ((snow(i) > epsfra) .AND. (tsurf_new(i) >= T_h2O_ice_liq)) THEN
+            fonte=MIN(MAX((tsurf_new(i)-T_h2O_ice_liq)*seaice(i) &
+                  /2.*ice_cap/ice_lat,0.0),snow(i))
+            snow(i) = MAX(0.,(snow(i)-fonte))
+            tsurf_new(i)=tsurf_new(i)-fonte*2*ice_lat/(seaice(i)*ice_cap)
+          ENDIF
+          snow(i)=MIN(snow(i),3000.)
+! Ice melt
+          IF ((seaice(i) > epsfra) .AND. (tsurf_new(i) >= T_h2O_ice_liq)) THEN       
+             fonte=seaice(i)*ice_cap*(tsurf_new(i)-T_h2O_ice_liq) &
+                  /(2*ice_lat+ice_cap*1.8)
+             CALL icemelt(fonte,pctsrf_new(knindex(i)),seaice(i))
+             tmp_flux_g(knindex(i))=tmp_flux_g(knindex(i)) &
+                                 +fonte*ice_lat/dtime
+             tsurf_new(i)=T_h2O_ice_liq
+          ENDIF  
+          tmp_seaice(knindex(i))=seaice(i)
+        ENDIF!(pctsrf_new(knindex(i)) .GT. epsfra)
+          tsea_ice(knindex(i))=tsurf_new(i)
+
+      ENDDO
+    ENDIF
+! ******************************************
+! CALL interfoce:
+! cumul/calcul nouvelle T_h2O_ice_liqce
+! fonte/formation de glace en dessous
+! ******************************************   
+    tslab = tmp_tslab
+    
+    CALL interfoce_slab(ngrid, dtime, &
+         tmp_radsol, tmp_flux_o, tmp_flux_g, tmp_pctsrf_slab, &
+         tslab, tsea_ice, pctsrf_new,taux_slab,tauy_slab,icount)
+    
+    tmp_pctsrf_slab(:)=pctsrf_new(:)
+!    tmp_pctsrf_slab(:,is_oce)=1.0-tmp_pctsrf_slab(:) &
+!            -tmp_pctsrf_slab(:,is_lic)-tmp_pctsrf_slab(:,is_ter)
+
+    DO i=1, ngrid
+       tmp_tslab(knindex(i),:)=tslab(knindex(i),:)
+       seaice(i)=tmp_seaice(knindex(i))
+       tsurf_new(i)=tsea_ice(knindex(i))
+
+    ENDDO
+
+! ****************************
+! calcul new albedo
+! ****************************
+! Albedo neige
+!    CALL albsno(klon,knon,dtime,agesno(:),alb_neig(:), precip_snow(:))  
+!    WHERE (snow(1 : knon) .LT. 0.0001) agesno(1 : knon) = 0.
+! Fraction neige (hauteur critique 45kg/m2~15cm)
+!    zfra(1:knon) = MAX(0.0,MIN(1.0,snow(1:knon)/45.0))
+! Albedo glace
+!    IF (ok_slab_sicOBS) THEN
+!       alb_ice=0.6
+!    ELSE
+!       alb_ice(1:knon)=alb_ice_max-(alb_ice_max-alb_ice_min) &
+!         *exp(-seaice(1:knon)/h_alb_ice)
+!    ENDIF
+!Albedo final
+!    alb1_new(1 : knon) = alb_neig(1 : knon) *zfra(1:knon) + & 
+!         alb_ice * (1.0-zfra(1:knon))
+!    alb2_new(:) = alb1_new(:)
+
+        
+! ********************************
+! Return the fraction of sea-ice
+! ********************************
+    pctsrf_sic(:) =  tmp_pctsrf_slab(:)
+
+
+  END SUBROUTINE ocean_slab_ice
+
+
+! 
+!***************************************************************************
+!
+  SUBROUTINE interfoce_slab(ngrid, dtime, &
+       radsol, fluxo, fluxg, pctsrf, &
+       tslab, tsea_ice, pctsrf_slab, &
+       taux_slab, tauy_slab,icount)
+!
+! Cette routine calcule la temperature d'un slab ocean, la glace de mer 
+! et les pourcentages de la maille couverte par l'ocean libre et/ou 
+! la glace de mer pour un "slab" ocean de 50m
+!
+! Conception: Laurent Li
+! Re-ecriture + adaptation LMDZ4: I. Musat
+! Transport, nouveau modèle glace, 2 couches: F.Codron
+!
+! input:
+!   klon         nombre T_h2O_ice_liqtal de points de grille
+!   itap         numero du pas de temps
+!   dtime        pas de temps de la physique (en s)
+!   ijour        jour dans l'annee en cours
+!   radsol       rayonnement net au sol (LW + SW)
+!   fluxo        flux turbulent (sensible + latent) sur les mailles oceaniques 
+!   fluxg        flux de conduction entre la surface de la glace de mer et l'ocean
+!   pctsrf       tableau des pourcentages de surface de chaque maille
+! output: 
+!   tslab        temperature de l'ocean libre
+!   tsea_ice         temperature de la glace (surface)
+!   pctsrf_slab  "pourcentages" (valeurs entre 0. et 1.) surfaces issus du slab
+
+    use slab_ice_h 
+    use callkeys_mod, only: ok_slab_sic,ok_slab_heat_transp
+
+! Input arguments
+!****************************************************************************************
+    INTEGER, INTENT(IN)                       :: ngrid,icount
+!    INTEGER, INTENT(IN)                       :: itap
+    REAL, INTENT(IN)                          :: dtime       ! not used
+!    INTEGER, INTENT(IN)                       :: ijour
+    REAL, DIMENSION(ngrid), INTENT(IN)         :: radsol
+    REAL, DIMENSION(ngrid), INTENT(IN)         :: fluxo
+    REAL, DIMENSION(ngrid), INTENT(IN)         :: fluxg
+    REAL, DIMENSION(ngrid), INTENT(IN)  :: pctsrf
+    REAL, DIMENSION(ngrid), INTENT(IN)  :: taux_slab
+    REAL, DIMENSION(ngrid), INTENT(IN)  :: tauy_slab
+
+! Output arguments
+!****************************************************************************************
+    REAL, DIMENSION(ngrid,noceanmx), INTENT(OUT) :: tslab
+    REAL, DIMENSION(ngrid), INTENT(INOUT)       :: pctsrf_slab
+    REAL, DIMENSION(ngrid), INTENT(INOUT)       :: tsea_ice
+
+! Local variables
+!****************************************************************************************
+    REAL                    :: fonte,t_cadj
+    INTEGER                 :: i,k,kt,kb
+    REAL                    :: zz, za, zb
+    REAL                    :: cyang ! capacite calorifique slab J/(m2 K)
+    REAL, PARAMETER         :: tau_conv=432000. ! temps ajust conv (5 jours)
+    REAL, DIMENSION(ngrid,noceanmx) :: dtdiff_loc,dtekman_loc
+
+
+
+!***************************************************
+! Capacite calorifique de la couche de surface
+    cyang=capcalocean!slabh(1)*4.228e+06
+    cpl_pas=1!4*iradia
+
+!
+! lecture du bilan au sol lmt_bils issu d'une simulation forcee en debut de journee
+!!    julien = MOD(ijour,360)
+!!    IF (ok_slab_heaT_h2O_ice_liqBS .and. (MOD(itap,lmt_pas) .EQ. 1)) THEN  
+!!       ! 1er pas de temps de la journee
+!!       idayvrai = ijour
+!!       CALL condsurf(julien,idayvrai, lmt_bils)
+!!    ENDIF
+
+! ----------------------------------------------
+! A chaque pas de temps: cumul flux de chaleur
+! ----------------------------------------------
+! bilan du flux de chaleur dans l'ocean :
+!
+    DO i = 1, ngrid
+       za = radsol(i) + fluxo(i)
+       zb = fluxg(i)
+!       IF(((1-pctsrf(i)).GT.epsfra).OR. &
+!            (pctsrf(i).GT.epsfra)) THEN
+          slab_bils(i)=slab_bils(i)+(za*(1-pctsrf(i)) &
+               +zb*pctsrf(i))/ cpl_pas
+!       ENDIF
+
+    ENDDO !klon
+
+! ---------------------------------------------
+! T_h2O_ice_liqus les cpl_pas: update de tslab et seaice
+! ---------------------------------------------
+
+    IF (mod(icount-1,cpl_pas).eq.0) THEN !fin de journee
+!
+! ---------------------------------------------
+! Transport de chaleur par circulation
+! Decoupage par pas de temps pour stabilite numérique 
+! (diffusion, schema centre pour advection)
+! ---------------------------------------------
+      dt_hdiff(:,:)=0.
+      dt_ekman(:,:)=0.
+
+      IF (ok_slab_heat_transp) THEN
+!       DO i=1,cpl_pas
+!  Transport diffusif
+!         IF (ok_soil_hdiff) THEN
+             CALL divgrad_phy(ngrid,noceanmx,tmp_tslab_loc,dtdiff_loc)
+             dtdiff_loc=dtdiff_loc*soil_hdiff*50./SUM(slabh)!*100.
+ !           dtdiff_loc(:,1)=dtdiff_loc(:,1)*soil_hdiff*50./SUM(slabh)*0.8
+ !           dtdiff_loc(:,2)=dtdiff_loc(:,2)*soil_hdiff*50./SUM(slabh)*0.2
+             dt_hdiff=dt_hdiff+dtdiff_loc
+             tmp_tslab_loc=tmp_tslab_loc+dtdiff_loc*dtime
+!         END IF
+
+! Calcul  de transport par Ekman
+
+          CALL slab_ekman2(ngrid,taux_slab,tauy_slab,tslab,dtekman_loc)
+
+
+!        END SELECT
+!        IF (slab_ekman.GT.0) THEN
+          do k=1,noceanmx
+            dtekman_loc(:,k)=dtekman_loc(:,k)/(slabh(k)*1000.)!*0.
+          enddo
+          dt_ekman(:,:)=dt_ekman(:,:)+dtekman_loc(:,:)
+          tmp_tslab_loc=tmp_tslab_loc+dtekman_loc*dtime
+!        ENDIF
+!      ENDDO ! time splitting 1,cpl_pas     
+!      IF (slab_ekman.GT.0) THEN
+!	  taux_slab(:)=0.
+!	  tauy_slab(:)=0.
+!      ENDIF
+
+!       print*, 'slab_bils=',slab_bils(1)
+
+
+      ENDIF!(ok_slab_heat_transp)
+
+      DO i = 1, ngrid
+!      IF (((1-pctsrf(i)).GT.epsfra).OR. &
+!             (pctsrf(i).GT.epsfra)) THEN
+! ---------------------------------------------
+! Ajout des flux de chaleur dans l'océan
+! ---------------------------------------
+
+!print*, 'T_h2O_ice_liqcean1=',tmp_tslab_loc(i,1)
+        tmp_tslab_loc(i,1) = tmp_tslab_loc(i,1) + &
+             slab_bils(i)/cyang*dtime*cpl_pas
+
+!print*, 'capcalocean=',capcalocean
+!print*, 'cyang=',cyang
+!print*, 'dT_h2O_ice_liqcean=',slab_bils(i)/cyang*dtime
+!print*, 'T_h2O_ice_liqcean2=',tmp_tslab_loc(i,1)
+
+
+! on remet l'accumulation a 0
+        slab_bils(i) = 0.
+! ---------------------------------------------
+! Glace interactive 
+! ---------------------------------------------
+        IF (ok_slab_sic) THEN
+! Fondre la glace si température > 0. 
+! -----------------------------------
+          IF ((tmp_tslab_loc(i,1).GT.T_h2O_ice_liq-1.8) .AND. (tmp_seaice(i).GT.0.0)) THEN
+            fonte=(tmp_tslab_loc(i,1)-T_h2O_ice_liq+1.8)*cyang &
+                /(ice_lat+ice_cap/2*(T_h2O_ice_liq-1.8-tsea_ice(i)))
+            CALL icemelt(fonte,pctsrf_slab(i),tmp_seaice(i))
+                 tmp_tslab_loc(i,1)=T_h2O_ice_liq-1.8+fonte*ice_lat/cyang
+          ENDIF 
+! fabriquer de la glace si congelation atteinte:
+! ----------------------------------------------
+          IF (tmp_tslab_loc(i,1).LT.(T_h2O_ice_liq-1.8)) THEN
+
+            IF (tmp_seaice(i).LT.h_ice_min) THEN
+! Creation glace nouvelle
+!             IF (pctsrf_slab(i).LT.(epsfra)) THEN
+                 fonte=(T_h2O_ice_liq-1.8-tmp_tslab_loc(i,1))*cyang/ice_lat
+              IF (fonte.GT.h_ice_min*ice_frac_min) THEN
+                tmp_seaice(i)=MIN(h_ice_thin,fonte/ice_frac_min)
+                tmp_seaice(i)=MAX(tmp_seaice(i),fonte/ice_frac_max)
+!             IF (fonte.GT.0) THEN
+!               tmp_seaice(i)=fonte
+                tsea_ice(i)=T_h2O_ice_liq-1.8
+                pctsrf_slab(i)=(1-pctsrf_slab(i))*fonte/tmp_seaice(i)
+!                pctsrf_slab(i)=1.
+                tmp_tslab_loc(i,1)=T_h2O_ice_liq-1.8
+              ENDIF
+            ELSE  
+! glace déjà présente 
+! Augmenter epaisseur
+              fonte=(T_h2O_ice_liq-1.8-tmp_tslab_loc(i,1))*cyang &
+                   /(ice_lat+ice_cap/2*(T_h2O_ice_liq-1.8-tsea_ice(i)))           
+              zz=tmp_seaice(i)
+              tmp_seaice(i)=MAX(zz,MIN(h_ice_thick,fonte+zz))
+! Augmenter couverture (oce libre et h>h_thick) 
+              za=1-pctsrf_slab(i)
+              zb=pctsrf_slab(i)
+              fonte=fonte*za+MAX(0.0,fonte+zz-tmp_seaice(i))*zb
+              pctsrf_slab(i)=MIN(zb+fonte/tmp_seaice(i), &
+                                    (za+zb)*ice_frac_max)
+              fonte=MAX(0.0,fonte-(pctsrf_slab(i)-zb)*tmp_seaice(i))
+! Augmenter epaisseur si couverture complete
+              tmp_seaice(i)=tmp_seaice(i)+fonte/pctsrf_slab(i)
+              tmp_tslab_loc(i,1) = T_h2O_ice_liq-1.8
+            ENDIF ! presence glace
+          ENDIF !congelation
+! vérifier limites de hauteur de glace
+          IF(tmp_seaice(i).GT.h_ice_min) THEN
+            tmp_seaice(i) = MIN(tmp_seaice(i),h_ice_max)
+          ELSE
+            tmp_seaice(i) = 0. 
+            pctsrf_slab(i)=0.
+          ENDIF! (tmp_seaice(i).GT.h_ice_min)
+       
+        ENDIF !(ok_slab_sic) Glace interactive
+! ----------------------------------
+! Ajustement convectif si > 1 layers
+! ----------------------------------
+
+        IF ((noceanmx.GT.1)) THEN
+          DO kt=1,noceanmx-1
+            kb=kt           
+            DO k=kt+1,noceanmx !look for instability
+              IF (tmp_tslab_loc(i,k).GT.tmp_tslab_loc(i,kt)) THEN
+                kb=k
+              ENDIF
+            ENDDO
+            IF (kb.GT.kt) THEN !ajust conv
+!               IF (slab_cadj.EQ.1) THEN
+!             :   t_cadj=SUM(tmp_tslab_loc(i,kt:kb)*slabh(kt:kb))/SUM(slabh(kt:kb))
+!                DO k=kt,kb
+!                  tmp_tslab_loc(i,k)=t_cadj
+!                ENDDO
+!              ELSEIF (slab_cadj.EQ.2) THEN
+                t_cadj=(tmp_tslab_loc(i,kb)-tmp_tslab_loc(i,kt))*dtime/tau_conv*cpl_pas
+                tmp_tslab_loc(i,kt)=tmp_tslab_loc(i,kt)+t_cadj
+                tmp_tslab_loc(i,kb)=tmp_tslab_loc(i,kb)-t_cadj*slabh(kt)/slabh(kb)
+              !ENDIF 
+            ENDIF
+          ENDDO 
+        ENDIF !ajust 2 layers
+!      ENDIF !pctsrf
+      ENDDO !klon
+
+! On met a jour la temperature et la glace
+    tslab  = tmp_tslab_loc
+
+
+    ENDIF !(mod(icount-1,cpl_pas).eq.0)
+
+  END SUBROUTINE interfoce_slab
+!
+!******************************************************************************  
+  SUBROUTINE icemelt(fonte,pctsrf,seaice)
+
+      use slab_ice_h
+
+
+
+     REAL, INTENT(INOUT)  :: pctsrf
+     REAL , INTENT(INOUT)   ::fonte,seaice !kg/m2
+     REAL :: hh !auxilliary
+     REAL :: ff !auxilliary
+
+
+! ice gt h_ice_thick: decrease thickness up T_h2O_ice_liq h_ice_thick
+     IF (seaice.GT.h_ice_thick) THEN
+        hh=seaice
+!        ff=fonte
+        seaice=max(h_ice_thick,hh-fonte)    
+        fonte=max(0.0,fonte+h_ice_thick-hh)
+
+!        seaice=max(0.,hh-fonte)    
+!        fonte=max(0.0,fonte-(seaice-hh))
+!     IF (seaice.LT.epsfra) THEN
+!        pctsrf=0.
+!        seaice=0.
+!        fonte=ff-hh
+!     ENDIF
+
+     ENDIF
+! ice gt h_ice_thin: partially decrease thickness
+     IF ((seaice.GE.h_ice_thin).AND.(fonte.GT.0.0)) THEN
+       hh=seaice
+       seaice=MAX(hh-0.6*fonte,h_ice_thin)
+       fonte=MAX(0.0,fonte-hh+seaice)
+     ENDIF
+! use rest T_h2O_ice_liq decrease area
+       hh=pctsrf
+       pctsrf=MIN(hh,MAX(0.0,hh-fonte/seaice))
+       fonte=MAX(0.0,fonte-(hh-pctsrf)*seaice)
+
+    END SUBROUTINE icemelt
+
+!****************************************************************************************
+!
+  SUBROUTINE ocean_slab_final!(tslab_rst, seaice_rst)
+
+! This subroutine will send T_h2O_ice_liq phyredem the variables concerning the slab 
+! ocean that should be written T_h2O_ice_liq restart file.
+
+!****************************************************************************************
+
+!    REAL, DIMENSION(ngridmx,noceanmx), INTENT(OUT) :: tslab_rst
+!    REAL, DIMENSION(ngridmx), INTENT(OUT) :: seaice_rst
+
+!****************************************************************************************
+! Set the output variables
+!    tslab_rst(:,:)  = tmp_tslab(:,:)
+!    tslab_rst(:)  = tmp_tslab_loc(:)
+!    seaice_rst(:) = tmp_seaice(:)
+
+! Deallocation of all variables in module
+    DEALLOCATE(tmp_tslab, tmp_tslab_loc, tmp_pctsrf_slab)
+    DEALLOCATE(tmp_seaice, tmp_radsol, tmp_flux_o, tmp_flux_g)
+    DEALLOCATE(slab_bils, lmt_bils)
+    DEALLOCATE(dt_hdiff)
+
+  END SUBROUTINE ocean_slab_final
+!
+!****************************************************************************************
+!
+  SUBROUTINE ocean_slab_get_vars(ngrid,tslab_loc, seaice_loc, flux_o_loc, flux_g_loc, &
+       dt_hdiff_loc,dt_ekman_loc)
+  
+! "Get some variables from module ocean_slab_mod"
+! This subroutine prints variables T_h2O_ice_liq a external routine
+
+    INTEGER, INTENT(IN)                     :: ngrid
+    REAL, DIMENSION(ngrid,noceanmx), INTENT(OUT) :: tslab_loc
+    REAL, DIMENSION(ngrid), INTENT(OUT) :: seaice_loc
+    REAL, DIMENSION(ngrid), INTENT(OUT) :: flux_o_loc
+    REAL, DIMENSION(ngrid), INTENT(OUT) :: flux_g_loc
+    REAL, DIMENSION(ngrid,noceanmx), INTENT(OUT) :: dt_hdiff_loc
+    REAL, DIMENSION(ngrid,noceanmx), INTENT(OUT) :: dt_ekman_loc
+    INTEGER :: i
+
+
+! Set the output variables
+    tslab_loc=0.
+    dt_hdiff_loc=0.
+    dt_ekman_loc=0.
+    tslab_loc  = tmp_tslab
+    seaice_loc(:) = tmp_seaice(:)
+    flux_o_loc(:) = tmp_flux_o(:)
+    flux_g_loc(:) = tmp_flux_g(:)
+    DO i=1,noceanmx
+      dt_hdiff_loc(:,i) = dt_hdiff(:,i)*slabh(i)*1000.*4228. !Convert en W/m2
+      dt_ekman_loc(:,i) = dt_ekman(:,i)*slabh(i)*1000.*4228. 
+    ENDDO
+  
+  
+
+  END SUBROUTINE ocean_slab_get_vars
+!
+!****************************************************************************************
+!
+END MODULE ocean_slab_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/optci.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/optci.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/optci.F90	(revision 1644)
@@ -0,0 +1,398 @@
+subroutine optci(PLEV,TLEV,DTAUI,TAUCUMI,      &
+     QXIAER,QSIAER,GIAER,COSBI,WBARI,TAUAERO,  &
+     TMID,PMID,TAUGSURF,QVAR,MUVAR)
+
+  use radinc_h
+  use radcommon_h, only: gasi,tlimit,wrefVAR,Cmk,tgasref,pfgasref,wnoi,scalep,indi,glat_ig
+  use gases_h
+  use comcstfi_mod, only: g, r, mugaz
+  use callkeys_mod, only: kastprof,continuum,graybody,H2Ocont_simple
+  implicit none
+
+  !==================================================================
+  !     
+  !     Purpose
+  !     -------
+  !     Calculates longwave optical constants at each level. For each
+  !     layer and spectral interval in the IR it calculates WBAR, DTAU
+  !     and COSBAR. For each level it calculates TAU.
+  !     
+  !     TAUI(L,LW) is the cumulative optical depth at level L (or alternatively
+  !     at the *bottom* of layer L), LW is the spectral wavelength interval.
+  !     
+  !     TLEV(L) - Temperature at the layer boundary (i.e., level)
+  !     PLEV(L) - Pressure at the layer boundary (i.e., level)
+  !
+  !     Authors
+  !     -------
+  !     Adapted from the NASA Ames code by R. Wordsworth (2009)
+  !     
+  !==================================================================
+
+
+  real*8 DTAUI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+  real*8 DTAUKI(L_LEVELS+1,L_NSPECTI,L_NGAUSS)
+  real*8 TAUI(L_NLEVRAD,L_NSPECTI,L_NGAUSS)
+  real*8 TAUCUMI(L_LEVELS,L_NSPECTI,L_NGAUSS)
+  real*8 PLEV(L_LEVELS)
+  real*8 TLEV(L_LEVELS)
+  real*8 TMID(L_LEVELS), PMID(L_LEVELS)
+  real*8 COSBI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+  real*8 WBARI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+
+  ! for aerosols
+  real*8  QXIAER(L_LEVELS+1,L_NSPECTI,NAERKIND)
+  real*8  QSIAER(L_LEVELS+1,L_NSPECTI,NAERKIND)
+  real*8  GIAER(L_LEVELS+1,L_NSPECTI,NAERKIND)
+  real*8  TAUAERO(L_LEVELS+1,NAERKIND)
+  real*8  TAUAEROLK(L_LEVELS+1,L_NSPECTI,NAERKIND)
+  real*8  TAEROS(L_LEVELS,L_NSPECTI,NAERKIND)
+
+  integer L, NW, NG, K, LK, IAER
+  integer MT(L_LEVELS), MP(L_LEVELS), NP(L_LEVELS)
+  real*8  ANS, TAUGAS
+  real*8  DPR(L_LEVELS), U(L_LEVELS)
+  real*8  LCOEF(4), LKCOEF(L_LEVELS,4)
+
+  real*8 taugsurf(L_NSPECTI,L_NGAUSS-1)
+  real*8 DCONT,DAERO
+  double precision wn_cont, p_cont, p_air, T_cont, dtemp, dtempc
+  double precision p_cross
+
+  ! variable species mixing ratio variables
+  real*8  QVAR(L_LEVELS), WRATIO(L_LEVELS), MUVAR(L_LEVELS)
+  real*8  KCOEF(4)
+  integer NVAR(L_LEVELS)
+
+  ! temporary variables for multiple aerosol calculation
+  real*8 atemp
+  real*8 btemp(L_NLAYRAD,L_NSPECTI)
+
+  ! variables for k in units m^-1
+  real*8 dz(L_LEVELS)
+  !real*8 rho !! see test below
+
+  integer igas, jgas
+
+  integer interm
+
+  !--- Kasting's CIA ----------------------------------------
+  !real*8, parameter :: Ci(L_NSPECTI)=[                         &
+  !     3.8E-5, 1.2E-5, 2.8E-6, 7.6E-7, 4.5E-7, 2.3E-7,    &
+  !     5.4E-7, 1.6E-6, 0.0,                               &
+  !     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,            & 
+  !     0.0, 4.0E-7, 4.0E-6, 1.4E-5,    &
+  !     1.0E-5, 1.2E-6, 2.0E-7, 5.0E-8, 3.0E-8, 0.0 ] 
+  !real*8, parameter :: Ti(L_NSPECTI)=[ -2.2, -1.9,             &
+  !     -1.7, -1.7, -1.7, -1.7, -1.7, -1.7,                &
+  !     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
+  !     -1.7,-1.7,-1.7,-1.7,-1.7,-1.7,-1.7, -1.7,0.0 ]
+  !----------------------------------------------------------
+
+  !! AS: to save time in computing continuum (see bilinearbig)
+  IF (.not.ALLOCATED(indi)) THEN
+      ALLOCATE(indi(L_NSPECTI,ngasmx,ngasmx))
+      indi = -9999  ! this initial value means "to be calculated"
+  ENDIF
+
+  !=======================================================================
+  !     Determine the total gas opacity throughout the column, for each
+  !     spectral interval, NW, and each Gauss point, NG.
+
+  taugsurf(:,:) = 0.0
+  dpr(:)        = 0.0
+  lkcoef(:,:)   = 0.0
+
+  do K=2,L_LEVELS
+     DPR(k) = PLEV(K)-PLEV(K-1)
+
+     !--- Kasting's CIA ----------------------------------------
+     !dz(k)=dpr(k)*189.02*TMID(K)/(0.03720*PMID(K))
+     ! this is CO2 path length (in cm) as written by Francois
+     ! delta_z = delta_p * R_specific * T / (g * P)
+     ! But Kasting states that W is in units of _atmosphere_ cm
+     ! So we do
+     !dz(k)=dz(k)*(PMID(K)/1013.25)
+     !dz(k)=dz(k)/100.0 ! in m for SI calc
+     !----------------------------------------------------------
+
+     ! if we have continuum opacities, we need dz
+     if(kastprof)then
+        dz(k) = dpr(k)*(1000.0d0*8.3145d0/muvar(k))*TMID(K)/(g*PMID(K))
+        U(k)  = Cmk*DPR(k)*mugaz/muvar(k) 
+     else
+        dz(k) = dpr(k)*R*TMID(K)/(glat_ig*PMID(K))*mugaz/muvar(k)
+        U(k)  = Cmk*DPR(k)*mugaz/muvar(k)     ! only Cmk line in optci.F  
+	    !JL13 the mugaz/muvar factor takes into account water meanmolecular weight if water is present
+     endif
+
+     call tpindex(PMID(K),TMID(K),QVAR(K),pfgasref,tgasref,WREFVAR, &
+          LCOEF,MT(K),MP(K),NVAR(K),WRATIO(K))
+
+     do LK=1,4
+        LKCOEF(K,LK) = LCOEF(LK)
+     end do
+  end do                    ! levels
+
+
+  do iaer=1,naerkind
+     DO NW=1,L_NSPECTI
+        do K=2,L_LEVELS
+           TAEROS(K,NW,IAER) = TAUAERO(K,IAER) * QXIAER(K,NW,IAER)
+        end do                    ! levels
+     END DO
+  end do
+
+  do NW=1,L_NSPECTI
+
+     do K=2,L_LEVELS
+
+! continuum absorption
+        DCONT = 0.0d0 
+
+        if(continuum.and.(.not.graybody))then
+           ! include continua if necessary
+           wn_cont = dble(wnoi(nw))
+           T_cont  = dble(TMID(k))
+           do igas=1,ngasmx
+
+              if(gfrac(igas).eq.-1)then ! variable
+                 p_cont  = dble(PMID(k)*scalep*QVAR(k)) ! qvar = mol/mol
+              else
+                 p_cont  = dble(PMID(k)*scalep*gfrac(igas)*(1.-QVAR(k)))
+              endif
+
+              dtemp=0.0d0
+              if(igas.eq.igas_N2)then
+
+                 interm = indi(nw,igas,igas)
+                 call interpolateN2N2(wn_cont,T_cont,p_cont,dtemp,.false.,interm)
+                 indi(nw,igas,igas) = interm
+
+              elseif(igas.eq.igas_H2)then
+
+                 ! first do self-induced absorption
+                 interm = indi(nw,igas,igas)
+                 call interpolateH2H2(wn_cont,T_cont,p_cont,dtemp,.false.,interm)
+                 indi(nw,igas,igas) = interm
+
+                 ! then cross-interactions with other gases
+                 do jgas=1,ngasmx
+                    p_cross = dble(PMID(k)*scalep*gfrac(jgas)*(1.-QVAR(k)))
+                    dtempc  = 0.0d0
+                    if(jgas.eq.igas_N2)then 
+                       interm = indi(nw,igas,jgas)
+                       call interpolateN2H2(wn_cont,T_cont,p_cross,p_cont,dtempc,.false.,interm)
+                       indi(nw,igas,jgas) = interm
+                    elseif(jgas.eq.igas_He)then 
+                       interm = indi(nw,igas,jgas)
+                       call interpolateH2He(wn_cont,T_cont,p_cross,p_cont,dtempc,.false.,interm)
+                       indi(nw,igas,jgas) = interm
+                    endif
+                    dtemp = dtemp + dtempc
+                 enddo
+
+              elseif(igas.eq.igas_H2O.and.T_cont.gt.200.0)then
+
+                 p_air = dble(PMID(k)*scalep) - p_cont ! note assumes background is air!
+                 if(H2Ocont_simple)then
+                    call interpolateH2Ocont_PPC(wn_cont,T_cont,p_cont,p_air,dtemp,.false.)
+                 else
+                    interm = indi(nw,igas,igas)
+                    call interpolateH2Ocont_CKD(wn_cont,T_cont,p_cont,p_air,dtemp,.false.,interm)
+                    indi(nw,igas,igas) = interm
+                 endif
+
+              endif
+
+              DCONT = DCONT + dtemp
+
+           enddo
+
+           ! Oobleck test
+           !rho = PMID(k)*scalep / (TMID(k)*286.99)
+           !if(WNOI(nw).gt.300.0 .and. WNOI(nw).lt.500.0)then
+           !   DCONT = rho * 0.125 * 4.6e-4
+           !elseif(WNOI(nw).gt.500.0 .and. WNOI(nw).lt.700.0)then
+           !   DCONT = 1000*dpr(k) * 1.0 * 4.6e-4 / g
+           !   DCONT = rho * 1.0 * 4.6e-4
+           !elseif(WNOI(nw).gt.700.0 .and. WNOI(nw).lt.900.0)then
+           !   DCONT = rho * 0.125 * 4.6e-4
+           !endif
+
+           DCONT = DCONT*dz(k)
+
+        endif
+
+! aerosol absorption
+	DAERO=SUM(TAEROS(K,NW,1:naerkind))
+
+        do ng=1,L_NGAUSS-1
+
+           ! Now compute TAUGAS
+
+           ! Interpolate between water mixing ratios
+           ! WRATIO = 0.0 if the requested water amount is equal to, or outside the
+           ! the water data range
+
+           if(L_REFVAR.eq.1)then ! added by RW for special no variable case
+              KCOEF(1) = GASI(MT(K),MP(K),1,NW,NG)
+              KCOEF(2) = GASI(MT(K),MP(K)+1,1,NW,NG)
+              KCOEF(3) = GASI(MT(K)+1,MP(K)+1,1,NW,NG)
+              KCOEF(4) = GASI(MT(K)+1,MP(K),1,NW,NG)
+           else
+
+              KCOEF(1) = GASI(MT(K),MP(K),NVAR(K),NW,NG) + WRATIO(K)*     &
+                   (GASI(MT(K),MP(K),NVAR(K)+1,NW,NG) -                   &
+                   GASI(MT(K),MP(K),NVAR(K),NW,NG))
+
+              KCOEF(2) = GASI(MT(K),MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)*   &
+                   (GASI(MT(K),MP(K)+1,NVAR(K)+1,NW,NG) -                 &
+                   GASI(MT(K),MP(K)+1,NVAR(K),NW,NG))
+
+              KCOEF(3) = GASI(MT(K)+1,MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)* &
+                   (GASI(MT(K)+1,MP(K)+1,NVAR(K)+1,NW,NG) -               &
+                   GASI(MT(K)+1,MP(K)+1,NVAR(K),NW,NG))
+
+              KCOEF(4) = GASI(MT(K)+1,MP(K),NVAR(K),NW,NG) + WRATIO(K)*   &
+                   (GASI(MT(K)+1,MP(K),NVAR(K)+1,NW,NG) -                 &
+                   GASI(MT(K)+1,MP(K),NVAR(K),NW,NG))
+
+           endif
+
+           ! Interpolate the gaseous k-coefficients to the requested T,P values
+
+           ANS = LKCOEF(K,1)*KCOEF(1) + LKCOEF(K,2)*KCOEF(2) +            &
+                LKCOEF(K,3)*KCOEF(3) + LKCOEF(K,4)*KCOEF(4)
+
+           TAUGAS  = U(k)*ANS
+
+           TAUGSURF(NW,NG) = TAUGSURF(NW,NG) + TAUGAS + DCONT
+           DTAUKI(K,nw,ng) = TAUGAS    & 
+                             + DCONT   & ! For parameterized continuum absorption
+			     + DAERO     ! For aerosol absorption
+
+        end do
+
+        ! Now fill in the "clear" part of the spectrum (NG = L_NGAUSS),
+        ! which holds continuum opacity only
+
+        NG              = L_NGAUSS
+        DTAUKI(K,nw,ng) = 0.d0      & 
+                          + DCONT   & ! For parameterized continuum absorption
+	                  + DAERO     ! For aerosol absorption
+
+     end do
+  end do
+
+  DTAUKI(L_LEVELS+1,1:L_NSPECTI,1:L_NGAUSS)=0.d0
+  !=======================================================================
+  !     Now the full treatment for the layers, where besides the opacity
+  !     we need to calculate the scattering albedo and asymmetry factors
+
+  do iaer=1,naerkind
+    DO NW=1,L_NSPECTI
+     DO K=2,L_LEVELS+1
+           TAUAEROLK(K,NW,IAER) = TAUAERO(K,IAER)*QSIAER(K,NW,IAER)
+     ENDDO
+    ENDDO
+  end do
+  
+  DO NW=1,L_NSPECTI
+     DO L=1,L_NLAYRAD
+        K              = 2*L+1
+        btemp(L,NW) = SUM(TAUAEROLK(K,NW,1:naerkind)) + SUM(TAUAEROLK(K+1,NW,1:naerkind))
+     END DO ! L vertical loop
+  END DO                    ! NW spectral loop
+  
+
+  DO NW=1,L_NSPECTI
+     NG = L_NGAUSS
+     DO L=1,L_NLAYRAD
+
+        K              = 2*L+1
+        DTAUI(L,nw,ng) = DTAUKI(K,NW,NG) + DTAUKI(K+1,NW,NG)! + 1.e-50
+
+        atemp = 0.
+        if(DTAUI(L,NW,NG) .GT. 1.0D-9) then
+           do iaer=1,naerkind
+              atemp = atemp +                                     &
+                   GIAER(K,NW,IAER)   * TAUAEROLK(K,NW,IAER) +    &
+                   GIAER(K+1,NW,IAER) * TAUAEROLK(K+1,NW,IAER)
+           end do
+           WBARI(L,nw,ng) = btemp(L,nw)  / DTAUI(L,NW,NG)
+        else
+           WBARI(L,nw,ng) = 0.0D0
+           DTAUI(L,NW,NG) = 1.0D-9
+        endif
+
+        if(btemp(L,nw) .GT. 0.0d0) then
+           cosbi(L,NW,NG) = atemp/btemp(L,nw)
+        else
+           cosbi(L,NW,NG) = 0.0D0
+        end if
+
+     END DO ! L vertical loop
+
+     ! Now the other Gauss points, if needed.
+
+     DO NG=1,L_NGAUSS-1
+        IF(TAUGSURF(NW,NG) .gt. TLIMIT) THEN
+
+           DO L=1,L_NLAYRAD
+              K              = 2*L+1
+              DTAUI(L,nw,ng) = DTAUKI(K,NW,NG)+DTAUKI(K+1,NW,NG)! + 1.e-50
+
+              if(DTAUI(L,NW,NG) .GT. 1.0D-9) then
+
+                 WBARI(L,nw,ng) = btemp(L,nw)  / DTAUI(L,NW,NG)
+
+              else
+                 WBARI(L,nw,ng) = 0.0D0
+                 DTAUI(L,NW,NG) = 1.0D-9
+              endif
+
+              cosbi(L,NW,NG) = cosbi(L,NW,L_NGAUSS)
+           END DO ! L vertical loop
+        END IF
+
+     END DO                 ! NG Gauss loop
+  END DO                    ! NW spectral loop
+
+  ! Total extinction optical depths
+
+  DO NG=1,L_NGAUSS       ! full gauss loop
+     DO NW=1,L_NSPECTI       
+        TAUCUMI(1,NW,NG)=0.0D0
+        DO K=2,L_LEVELS
+           TAUCUMI(K,NW,NG)=TAUCUMI(K-1,NW,NG)+DTAUKI(K,NW,NG)
+        END DO
+     END DO                 ! end full gauss loop
+  END DO
+
+  ! be aware when comparing with textbook results 
+  ! (e.g. Pierrehumbert p. 218) that 
+  ! taucumi does not take the <cos theta>=0.5 factor into
+  ! account. It is the optical depth for a vertically 
+  ! ascending ray with angle theta = 0.
+
+  !open(127,file='taucum.out')
+  !do nw=1,L_NSPECTI
+  !   write(127,*) taucumi(L_LEVELS,nw,L_NGAUSS)
+  !enddo
+  !close(127)
+  
+!  print*,'WBARI'
+!  print*,WBARI
+!  print*,'DTAUI'
+!  print*,DTAUI
+!  call abort
+  
+
+  return
+
+
+end subroutine optci
+
+
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/optcv.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/optcv.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/optcv.F90	(revision 1644)
@@ -0,0 +1,352 @@
+SUBROUTINE OPTCV(DTAUV,TAUV,TAUCUMV,PLEV,  &
+     QXVAER,QSVAER,GVAER,WBARV,COSBV,       &
+     TAURAY,TAUAERO,TMID,PMID,TAUGSURF,QVAR,MUVAR)
+
+  use radinc_h
+  use radcommon_h, only: gasv, tlimit, wrefVAR, Cmk, tgasref, pfgasref,wnov,scalep,indv,glat_ig
+  use gases_h
+  use comcstfi_mod, only: g, r, mugaz
+  use callkeys_mod, only: kastprof,continuum,graybody,H2Ocont_simple,callgasvis
+
+  implicit none
+
+  !==================================================================
+  !     
+  !     Purpose
+  !     -------
+  !     Calculates shortwave optical constants at each level.
+  !     
+  !     Authors
+  !     -------
+  !     Adapted from the NASA Ames code by R. Wordsworth (2009)
+  !     
+  !==================================================================
+  !     
+  !     THIS SUBROUTINE SETS THE OPTICAL CONSTANTS IN THE VISUAL  
+  !     IT CALCUALTES FOR EACH LAYER, FOR EACH SPECRAL INTERVAL IN THE VISUAL
+  !     LAYER: WBAR, DTAU, COSBAR
+  !     LEVEL: TAU
+  !     
+  !     TAUV(L,NW,NG) is the cumulative optical depth at the top of radiation code
+  !     layer L. NW is spectral wavelength interval, ng the Gauss point index.
+  !     
+  !     TLEV(L) - Temperature at the layer boundary
+  !     PLEV(L) - Pressure at the layer boundary (i.e. level)
+  !     GASV(NT,NPS,NW,NG) - Visible k-coefficients 
+  !     
+  !-------------------------------------------------------------------
+
+
+  real*8 DTAUV(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+  real*8 DTAUKV(L_LEVELS+1,L_NSPECTV,L_NGAUSS)
+  real*8 TAUV(L_NLEVRAD,L_NSPECTV,L_NGAUSS)
+  real*8 TAUCUMV(L_LEVELS,L_NSPECTV,L_NGAUSS)
+  real*8 PLEV(L_LEVELS)
+  real*8 TMID(L_LEVELS), PMID(L_LEVELS)
+  real*8 COSBV(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+  real*8 WBARV(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+
+  ! for aerosols
+  real*8  QXVAER(L_LEVELS+1,L_NSPECTV,NAERKIND)
+  real*8  QSVAER(L_LEVELS+1,L_NSPECTV,NAERKIND)
+  real*8  GVAER(L_LEVELS+1,L_NSPECTV,NAERKIND)
+  real*8  TAUAERO(L_LEVELS+1,NAERKIND)
+  real*8  TAUAEROLK(L_LEVELS+1,L_NSPECTV,NAERKIND)
+  real*8  TAEROS(L_LEVELS,L_NSPECTV,NAERKIND)
+
+  integer L, NW, NG, K, LK, IAER
+  integer MT(L_LEVELS), MP(L_LEVELS), NP(L_LEVELS)
+  real*8  ANS, TAUGAS
+  real*8  TAURAY(L_NSPECTV)
+  real*8  TRAY(L_LEVELS,L_NSPECTV)
+  real*8  TRAYAER
+  real*8  DPR(L_LEVELS), U(L_LEVELS)
+  real*8  LCOEF(4), LKCOEF(L_LEVELS,4)
+
+  real*8 taugsurf(L_NSPECTV,L_NGAUSS-1)
+  real*8 DCONT,DAERO
+  double precision wn_cont, p_cont, p_air, T_cont, dtemp, dtempc
+  double precision p_cross
+
+  ! variable species mixing ratio variables
+  real*8  QVAR(L_LEVELS), WRATIO(L_LEVELS), MUVAR(L_LEVELS)
+  real*8  KCOEF(4)
+  integer NVAR(L_LEVELS)
+
+  ! temporary variables for multiple aerosol calculation
+  real*8 atemp(L_NLAYRAD,L_NSPECTV)
+  real*8 btemp(L_NLAYRAD,L_NSPECTV)
+  real*8 ctemp(L_NLAYRAD,L_NSPECTV)
+
+  ! variables for k in units m^-1
+  real*8 dz(L_LEVELS)
+
+  integer igas, jgas
+
+  integer interm
+
+  !! AS: to save time in computing continuum (see bilinearbig)
+  IF (.not.ALLOCATED(indv)) THEN
+      ALLOCATE(indv(L_NSPECTV,ngasmx,ngasmx))
+      indv = -9999 ! this initial value means "to be calculated"
+  ENDIF
+
+  !=======================================================================
+  !     Determine the total gas opacity throughout the column, for each
+  !     spectral interval, NW, and each Gauss point, NG.
+  !     Calculate the continuum opacities, i.e., those that do not depend on
+  !     NG, the Gauss index.
+
+  taugsurf(:,:) = 0.0
+  dpr(:)        = 0.0
+  lkcoef(:,:)   = 0.0
+
+  do K=2,L_LEVELS
+     DPR(k) = PLEV(K)-PLEV(K-1)
+
+     ! if we have continuum opacities, we need dz
+     if(kastprof)then
+        dz(k) = dpr(k)*(1000.0d0*8.3145d0/muvar(k))*TMID(K)/(g*PMID(K))
+        U(k)  = Cmk*DPR(k)*mugaz/muvar(k) 
+     else
+        dz(k) = dpr(k)*R*TMID(K)/(glat_ig*PMID(K))*mugaz/muvar(k)
+        U(k)  = Cmk*DPR(k)*mugaz/muvar(k)     ! only Cmk line in optci.F  
+	    !JL13 the mugaz/muvar factor takes into account water meanmolecular weight if water is present
+     endif
+
+     call tpindex(PMID(K),TMID(K),QVAR(K),pfgasref,tgasref,WREFVAR, &
+          LCOEF,MT(K),MP(K),NVAR(K),WRATIO(K))
+
+     do LK=1,4
+        LKCOEF(K,LK) = LCOEF(LK)
+     end do
+  end do                    ! levels
+
+
+  do iaer=1,naerkind
+     do NW=1,L_NSPECTV
+        do K=2,L_LEVELS
+           TAEROS(K,NW,IAER) = TAUAERO(K,IAER) * QXVAER(K,NW,IAER)
+        end do                    ! levels
+     end do
+  end do
+  do NW=1,L_NSPECTV
+     do K=2,L_LEVELS
+        TRAY(K,NW)   = TAURAY(NW) * DPR(K)
+     end do                    ! levels
+  end do
+  
+  !     we ignore K=1...
+  do K=2,L_LEVELS
+
+     do NW=1,L_NSPECTV
+
+        TRAYAER = TRAY(K,NW)
+        !     TRAYAER is Tau RAYleigh scattering, plus AERosol opacity
+        do iaer=1,naerkind
+           TRAYAER = TRAYAER + TAEROS(K,NW,IAER)
+        end do
+
+        DCONT = 0.0 ! continuum absorption
+
+        if(continuum.and.(.not.graybody).and.callgasvis)then
+           ! include continua if necessary
+           wn_cont = dble(wnov(nw))
+           T_cont  = dble(TMID(k))
+           do igas=1,ngasmx
+
+              if(gfrac(igas).eq.-1)then ! variable
+                 p_cont  = dble(PMID(k)*scalep*QVAR(k)) ! qvar = mol/mol
+              else
+                 p_cont  = dble(PMID(k)*scalep*gfrac(igas)*(1.-QVAR(k)))
+              endif
+
+              dtemp=0.0
+              if(igas.eq.igas_N2)then
+
+                 interm = indv(nw,igas,igas)
+!                 call interpolateN2N2(wn_cont,T_cont,p_cont,dtemp,.false.,interm)
+                 indv(nw,igas,igas) = interm
+                 ! only goes to 500 cm^-1, so unless we're around a cold brown dwarf, this is irrelevant in the visible
+
+              elseif(igas.eq.igas_H2)then
+
+                 ! first do self-induced absorption
+                 interm = indv(nw,igas,igas)
+                 call interpolateH2H2(wn_cont,T_cont,p_cont,dtemp,.false.,interm)
+                 indv(nw,igas,igas) = interm
+
+                 ! then cross-interactions with other gases
+                 do jgas=1,ngasmx
+                    p_cross = dble(PMID(k)*scalep*gfrac(jgas)*(1.-QVAR(k)))
+                    dtempc  = 0.0
+                    if(jgas.eq.igas_N2)then 
+                       interm = indv(nw,igas,jgas)
+                       call interpolateN2H2(wn_cont,T_cont,p_cross,p_cont,dtempc,.false.,interm)
+                       indv(nw,igas,jgas) = interm
+                       ! should be irrelevant in the visible
+                    elseif(jgas.eq.igas_He)then 
+                       interm = indv(nw,igas,jgas)
+                       call interpolateH2He(wn_cont,T_cont,p_cross,p_cont,dtempc,.false.,interm)
+                       indv(nw,igas,jgas) = interm
+                    endif
+                    dtemp = dtemp + dtempc
+                 enddo
+
+              elseif(igas.eq.igas_H2O.and.T_cont.gt.200.0)then
+
+                 p_air = dble(PMID(k)*scalep) - p_cont ! note assumes background is air!
+                 if(H2Ocont_simple)then
+                    call interpolateH2Ocont_PPC(wn_cont,T_cont,p_cont,p_air,dtemp,.false.)
+                 else
+                    interm = indv(nw,igas,igas)
+                    call interpolateH2Ocont_CKD(wn_cont,T_cont,p_cont,p_air,dtemp,.false.,interm)
+                    indv(nw,igas,igas) = interm
+                 endif
+
+              endif
+
+              DCONT = DCONT + dtemp
+
+           enddo
+
+           DCONT = DCONT*dz(k)
+
+        endif
+
+        do ng=1,L_NGAUSS-1
+
+           ! Now compute TAUGAS
+
+           ! Interpolate between water mixing ratios
+           ! WRATIO = 0.0 if the requested water amount is equal to, or outside the
+           ! the water data range
+
+           if(L_REFVAR.eq.1)then ! added by RW for special no variable case
+              KCOEF(1) = GASV(MT(K),MP(K),1,NW,NG)
+              KCOEF(2) = GASV(MT(K),MP(K)+1,1,NW,NG)
+              KCOEF(3) = GASV(MT(K)+1,MP(K)+1,1,NW,NG)
+              KCOEF(4) = GASV(MT(K)+1,MP(K),1,NW,NG)
+           else
+
+              KCOEF(1) = GASV(MT(K),MP(K),NVAR(K),NW,NG) + WRATIO(K)*    &
+                   (GASV(MT(K),MP(K),NVAR(K)+1,NW,NG) -                  &
+                   GASV(MT(K),MP(K),NVAR(K),NW,NG))
+
+              KCOEF(2) = GASV(MT(K),MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)*  &
+                   (GASV(MT(K),MP(K)+1,NVAR(K)+1,NW,NG) -                &
+                   GASV(MT(K),MP(K)+1,NVAR(K),NW,NG))
+
+              KCOEF(3) = GASV(MT(K)+1,MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)*&
+                   (GASV(MT(K)+1,MP(K)+1,NVAR(K)+1,NW,NG) -              &
+                   GASV(MT(K)+1,MP(K)+1,NVAR(K),NW,NG))
+
+              KCOEF(4) = GASV(MT(K)+1,MP(K),NVAR(K),NW,NG) + WRATIO(K)*  &
+                   (GASV(MT(K)+1,MP(K),NVAR(K)+1,NW,NG) -                &
+                   GASV(MT(K)+1,MP(K),NVAR(K),NW,NG))
+
+           endif
+
+           ! Interpolate the gaseous k-coefficients to the requested T,P values
+
+           ANS = LKCOEF(K,1)*KCOEF(1) + LKCOEF(K,2)*KCOEF(2) +            &
+                LKCOEF(K,3)*KCOEF(3) + LKCOEF(K,4)*KCOEF(4)
+
+           TAUGAS  = U(k)*ANS
+
+           TAUGSURF(NW,NG) = TAUGSURF(NW,NG) + TAUGAS + DCONT
+           DTAUKV(K,nw,ng) = TAUGAS & 
+                             + TRAYAER & ! TRAYAER includes all scattering contributions
+                             + DCONT ! For parameterized continuum aborption
+
+        end do
+
+        ! Now fill in the "clear" part of the spectrum (NG = L_NGAUSS),
+        ! which holds continuum opacity only
+
+        NG              = L_NGAUSS
+        DTAUKV(K,nw,ng) = TRAY(K,NW) + DCONT ! For parameterized continuum absorption
+
+        do iaer=1,naerkind
+           DTAUKV(K,nw,ng) = DTAUKV(K,nw,ng) +  TAEROS(K,NW,IAER)
+        end do ! a bug was here!
+
+     end do
+  end do
+
+
+  !=======================================================================
+  !     Now the full treatment for the layers, where besides the opacity
+  !     we need to calculate the scattering albedo and asymmetry factors
+
+  do iaer=1,naerkind
+    DO NW=1,L_NSPECTV
+      DO K=2,L_LEVELS   ! AS: shouldn't this be L_LEVELS+1 ? (see optci)
+           TAUAEROLK(K,NW,IAER) = TAUAERO(K,IAER) * QSVAER(K,NW,IAER)
+      ENDDO
+    ENDDO
+  end do
+
+  DO NW=1,L_NSPECTV
+     DO L=1,L_NLAYRAD-1
+        K              = 2*L+1
+	atemp(L,NW) = SUM(GVAER(K,NW,1:naerkind) * TAUAEROLK(K,NW,1:naerkind))+SUM(GVAER(K+1,NW,1:naerkind) * TAUAEROLK(K+1,NW,1:naerkind))
+        btemp(L,NW) = SUM(TAUAEROLK(K,NW,1:naerkind)) + SUM(TAUAEROLK(K+1,NW,1:naerkind))
+	ctemp(L,NW) = btemp(L,NW) + 0.9999*(TRAY(K,NW) + TRAY(K+1,NW))
+	btemp(L,NW) = btemp(L,NW) + TRAY(K,NW) + TRAY(K+1,NW)
+	COSBV(L,NW,1:L_NGAUSS) = atemp(L,NW)/btemp(L,NW)
+     END DO ! L vertical loop
+     
+     !last level
+     L              = L_NLAYRAD
+     K              = 2*L+1
+     atemp(L,NW)    = SUM(GVAER(K,NW,1:naerkind) * TAUAEROLK(K,NW,1:naerkind))
+     btemp(L,NW) = SUM(TAUAEROLK(K,NW,1:naerkind))
+     ctemp(L,NW) = btemp(L,NW) + 0.9999*TRAY(K,NW)
+     btemp(L,NW) = btemp(L,NW) + TRAY(K,NW)
+     COSBV(L,NW,1:L_NGAUSS) = atemp(L,NW)/btemp(L,NW)
+     
+     
+  END DO                    ! NW spectral loop
+
+  DO NG=1,L_NGAUSS
+    DO NW=1,L_NSPECTV
+     DO L=1,L_NLAYRAD-1
+
+        K              = 2*L+1
+        DTAUV(L,nw,ng) = DTAUKV(K,NW,NG) + DTAUKV(K+1,NW,NG)
+        WBARV(L,nw,ng) = ctemp(L,NW) / DTAUV(L,nw,ng)
+
+      END DO ! L vertical loop
+
+        !     No vertical averaging on bottom layer
+
+        L              = L_NLAYRAD
+        K              = 2*L+1
+	DTAUV(L,nw,ng) = DTAUKV(K,NW,NG)
+
+        WBARV(L,NW,NG) = ctemp(L,NW) / DTAUV(L,NW,NG)
+     END DO                 ! NW spectral loop
+  END DO                    ! NG Gauss loop
+
+  ! Total extinction optical depths
+
+  DO NG=1,L_NGAUSS       ! full gauss loop
+     DO NW=1,L_NSPECTV       
+        TAUV(1,NW,NG)=0.0D0
+        DO L=1,L_NLAYRAD
+           TAUV(L+1,NW,NG)=TAUV(L,NW,NG)+DTAUV(L,NW,NG)
+        END DO
+
+        TAUCUMV(1,NW,NG)=0.0D0
+        DO K=2,L_LEVELS
+           TAUCUMV(K,NW,NG)=TAUCUMV(K-1,NW,NG)+DTAUKV(K,NW,NG)
+        END DO
+     END DO            
+  END DO                 ! end full gauss loop
+
+
+  return
+
+
+end subroutine optcv
Index: /trunk/LMDZ.TITAN/libf/phytitan/orbite.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/orbite.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/orbite.F	(revision 1644)
@@ -0,0 +1,65 @@
+      subroutine orbite(pls,pdist_star,pdecli,pright_ascenc)
+
+      use planete_mod, only: p_elips, e_elips, timeperi, obliquit
+      use comcstfi_mod, only: pi
+      implicit none
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Distance from star and declination as a function of the stellar
+!     longitude Ls
+!     
+!     Inputs
+!     ------
+!     pls          Ls
+!
+!     Outputs
+!     -------
+!     pdist_star    Distance Star-Planet in UA
+!     pdecli        declinaison ( in radians )
+!     pright_ascenc right ascension ( in radians )
+!
+!=======================================================================
+
+c   Declarations:
+c   -------------
+
+c arguments:
+c ----------
+
+      REAL pday,pdist_star,pdecli,pright_ascenc,pls,i
+
+c-----------------------------------------------------------------------
+
+c Star-Planet Distance
+
+      pdist_star = p_elips/(1.+e_elips*cos(pls+timeperi))
+
+c Stellar declination
+
+c ********************* version before 01/01/2000 *******
+
+      pdecli = asin (sin(pls)*sin(obliquit*pi/180.))
+
+c********************* version after 01/01/2000 *******
+c     i=obliquit*pi/180.
+c     pdecli=asin(sin(pls)*sin(i)/sqrt(sin(pls)**2+
+c    & cos(pls)**2*cos(i)**2))
+c ******************************************************
+
+c right ascencion
+      If((pls.lt.pi/2.d0)) then
+         pright_ascenc= atan(tan(pls)*cos(obliquit*pi/180.))
+      else if((pls.gt.pi/2.d0).and.(pls.lt.3.d0*pi/2.d0)) then
+         pright_ascenc= pi+atan(tan(pls)*cos(obliquit*pi/180.))
+      else if((pls.gt.3.d0*pi/2.d0)) then
+         pright_ascenc= 2.d0*pi+atan(tan(pls)*cos(obliquit*pi/180.))
+      else if (Abs(pls-pi/2.d0).le.1.d-10) then
+         pright_ascenc= pi/2.d0 
+      else 
+         pright_ascenc=-pi/2.d0 
+      end if
+      	 
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/params_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/params_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/params_h.F90	(revision 1644)
@@ -0,0 +1,16 @@
+      module params_h
+
+!  for use with kcm subroutines
+!  RDW 22/09/11
+
+      implicit none
+
+      double precision rc,cp_n,m_n,m_v,rmn
+      save cp_n,m_n,m_v,rmn
+
+      logical ideal_v
+      save ideal_v
+
+      parameter (rc  = 8.314462d0) ! ideal gas constant [J mol^-1 K^-1]
+
+      end module params_h
Index: /trunk/LMDZ.TITAN/libf/phytitan/phyetat0.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/phyetat0.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/phyetat0.F90	(revision 1644)
@@ -0,0 +1,410 @@
+subroutine phyetat0 (ngrid,nlayer,fichnom,tab0,Lmodif,nsoil,nq, &
+                     day_ini,time,tsurf,tsoil, &
+                     emis,q2,qsurf,cloudfrac,totcloudfrac,hice, &
+                     rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+
+
+  USE tracer_h, ONLY: noms
+  USE surfdat_h, only: phisfi, albedodat, zmea, zstd, zsig, zgam, zthe
+  use iostart, only: nid_start, open_startphy, close_startphy, &
+                     get_field, get_var, inquire_field, &
+                     inquire_dimension, inquire_dimension_length
+  use slab_ice_h, only: noceanmx
+  use callkeys_mod, only: CLFvarying
+
+  implicit none
+
+!======================================================================
+! Auteur(s) Z.X. Li (LMD/CNRS) date: 19930818
+!  Adaptation à Mars : Yann Wanherdrick 
+! Objet: Lecture de l etat initial pour la physique
+!======================================================================
+#include "netcdf.inc"
+
+!======================================================================
+!  INTEGER nbsrf !Mars nbsrf a 1 au lieu de 4
+!  PARAMETER (nbsrf=1) ! nombre de sous-fractions pour une maille
+!======================================================================
+!  Arguments:
+!  ---------
+!  inputs:
+  integer,intent(in) :: ngrid
+  integer,intent(in) :: nlayer
+  character*(*),intent(in) :: fichnom ! "startfi.nc" file
+  integer,intent(in) :: tab0
+  integer,intent(in) :: Lmodif
+  integer,intent(in) :: nsoil ! # of soil layers
+  integer,intent(in) :: nq
+  integer,intent(in) :: day_ini
+  real,intent(in) :: time
+
+!  outputs:
+  real,intent(out) :: tsurf(ngrid) ! surface temperature
+  real,intent(out) :: tsoil(ngrid,nsoil) ! soil temperature
+  real,intent(out) :: emis(ngrid) ! surface emissivity
+  real,intent(out) :: q2(ngrid,nlayer+1) ! 
+  real,intent(out) :: qsurf(ngrid,nq) ! tracers on surface
+! real co2ice(ngrid) ! co2 ice cover
+  real,intent(out) :: cloudfrac(ngrid,nlayer)
+  real,intent(out) :: hice(ngrid), totcloudfrac(ngrid)
+  real,intent(out) :: pctsrf_sic(ngrid),tslab(ngrid,noceanmx)  
+  real,intent(out) :: tsea_ice(ngrid),sea_ice(ngrid)
+  real,intent(out) :: rnat(ngrid)
+
+!======================================================================
+!  Local variables:
+
+!      INTEGER radpas
+!      REAL co2_ppm
+!      REAL solaire
+
+      real xmin,xmax ! to display min and max of a field
+!
+      INTEGER ig,iq,lmax
+      INTEGER nid, nvarid
+      INTEGER ierr, i, nsrf
+!      integer isoil 
+!      INTEGER length
+!      PARAMETER (length=100)
+      CHARACTER*7 str7
+      CHARACTER*2 str2
+      CHARACTER*1 yes
+!
+      REAL p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec
+      INTEGER nqold
+
+! flag which identifies if 'startfi.nc' file is using old names (qsurf01,...)
+!      logical :: oldtracernames=.false.
+      integer :: count
+      character(len=30) :: txt ! to store some text
+      
+      INTEGER :: indextime=1 ! index of selected time, default value=1
+      logical :: found
+
+!
+! ALLOCATE ARRAYS IN surfdat_h
+!
+IF (.not. ALLOCATED(albedodat)) ALLOCATE(albedodat(ngrid))
+IF (.not. ALLOCATED(phisfi)) ALLOCATE(phisfi(ngrid))
+IF (.not. ALLOCATED(zmea)) ALLOCATE(zmea(ngrid))
+IF (.not. ALLOCATED(zstd)) ALLOCATE(zstd(ngrid))
+IF (.not. ALLOCATED(zsig)) ALLOCATE(zsig(ngrid))
+IF (.not. ALLOCATED(zgam)) ALLOCATE(zgam(ngrid))
+IF (.not. ALLOCATED(zthe)) ALLOCATE(zthe(ngrid))
+
+
+! open physics initial state file:
+call open_startphy(fichnom)
+
+
+! possibility to modify tab_cntrl in tabfi
+write(*,*)
+write(*,*) 'TABFI in phyeta0: Lmodif=',Lmodif," tab0=",tab0
+call tabfi (ngrid,nid_start,Lmodif,tab0,day_ini,lmax,p_rad, &
+                   p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
+
+!c
+!c Lecture des latitudes (coordonnees):
+!c
+!      ierr = NF_INQ_VARID (nid, "latitude", nvarid)
+!      IF (ierr.NE.NF_NOERR) THEN
+!         PRINT*, 'phyetat0: Le champ <latitude> est absent'
+!         CALL abort
+!      ENDIF
+!#ifdef NC_DOUBLE
+!      ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,lati)
+!#else
+!      ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,lati)
+!#endif
+!      IF (ierr.NE.NF_NOERR) THEN
+!         PRINT*, 'phyetat0: Lecture echouee pour <latitude>'
+!         CALL abort
+!      ENDIF
+!c
+!c Lecture des longitudes (coordonnees):
+!c
+!      ierr = NF_INQ_VARID (nid, "longitude", nvarid)
+!      IF (ierr.NE.NF_NOERR) THEN
+!         PRINT*, 'phyetat0: Le champ <longitude> est absent'
+!         CALL abort
+!      ENDIF
+!#ifdef NC_DOUBLE
+!      ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,long)
+!#else
+!      ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,long)
+!#endif
+!      IF (ierr.NE.NF_NOERR) THEN
+!         PRINT*, 'phyetat0: Lecture echouee pour <longitude>'
+!         CALL abort
+!      ENDIF
+!c
+!c Lecture des aires des mailles:
+!c
+!      ierr = NF_INQ_VARID (nid, "area", nvarid)
+!      IF (ierr.NE.NF_NOERR) THEN
+!         PRINT*, 'phyetat0: Le champ <area> est absent'
+!         CALL abort
+!      ENDIF
+!#ifdef NC_DOUBLE
+!      ierr = NF_GET_VARA_DOUBLE(nid,nvarid,sta,ngrid,area)
+!#else
+!      ierr = NF_GET_VARA_REAL(nid,nvarid,sta,ngrid,area)
+!#endif
+!      IF (ierr.NE.NF_NOERR) THEN
+!         PRINT*, 'phyetat0: Lecture echouee pour <area>'
+!         CALL abort
+!      ENDIF
+!      xmin = 1.0E+20
+!      xmax = -1.0E+20
+!      xmin = MINVAL(area)
+!      xmax = MAXVAL(area)
+!      PRINT*,'Aires des mailles <area>:', xmin, xmax
+
+! Load surface geopotential:
+call get_field("phisfi",phisfi,found)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <phisfi>"
+  call abort
+else
+  write(*,*) "phyetat0: surface geopotential <phisfi> range:", &
+             minval(phisfi), maxval(phisfi)
+endif
+
+! Load bare ground albedo:
+call get_field("albedodat",albedodat,found)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <albedodat>"
+  call abort
+else
+  write(*,*) "phyetat0: Bare ground albedo <albedodat> range:", &
+             minval(albedodat), maxval(albedodat)
+endif
+
+! ZMEA
+call get_field("ZMEA",zmea,found)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <ZMEA>"
+  call abort
+else
+  write(*,*) "phyetat0: <ZMEA> range:", &
+             minval(zmea), maxval(zmea)
+endif
+
+! ZSTD
+call get_field("ZSTD",zstd,found)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <ZSTD>"
+  call abort
+else
+  write(*,*) "phyetat0: <ZSTD> range:", &
+             minval(zstd), maxval(zstd)
+endif
+
+! ZSIG
+call get_field("ZSIG",zsig,found)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <ZSIG>"
+  call abort
+else
+  write(*,*) "phyetat0: <ZSIG> range:", &
+             minval(zsig), maxval(zsig)
+endif
+
+! ZGAM
+call get_field("ZGAM",zgam,found)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <ZGAM>"
+  call abort
+else
+  write(*,*) "phyetat0: <ZGAM> range:", &
+             minval(zgam), maxval(zgam)
+endif
+
+! ZTHE
+call get_field("ZTHE",zthe,found)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <ZTHE>"
+  call abort
+else
+  write(*,*) "phyetat0: <ZTHE> range:", &
+             minval(zthe), maxval(zthe)
+endif
+
+! Surface temperature :
+call get_field("tsurf",tsurf,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <tsurf>"
+  call abort
+else
+  write(*,*) "phyetat0: Surface temperature <tsurf> range:", &
+             minval(tsurf), maxval(tsurf)
+endif
+
+! Surface emissivity
+call get_field("emis",emis,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <emis>"
+  call abort
+else
+  write(*,*) "phyetat0: Surface emissivity <emis> range:", &
+             minval(emis), maxval(emis)
+endif
+
+! Cloud fraction (added by BC 2010)
+if (CLFvarying) then
+call get_field("cloudfrac",cloudfrac,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <cloudfrac>"
+  call abort
+else
+  write(*,*) "phyetat0: Cloud fraction <cloudfrac> range:", &
+             minval(cloudfrac), maxval(cloudfrac)
+endif
+else
+cloudfrac(:,:)=0.0
+endif
+
+! Total cloud fraction (added by BC 2010)
+if (CLFvarying) then
+call get_field("totcloudfrac",totcloudfrac,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <totcloudfrac>"
+  call abort
+else
+  write(*,*) "phyetat0: Total cloud fraction <totcloudfrac> range:", &
+             minval(totcloudfrac), maxval(totcloudfrac)
+endif
+else
+totcloudfrac(:)=0.0
+endif
+
+! Height of oceanic ice (added by BC 2010)
+call get_field("hice",hice,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <hice>"
+!  call abort
+      do ig=1,ngrid
+      hice(ig)=0.
+      enddo
+else
+  write(*,*) "phyetat0: Height of oceanic ice <hice> range:", &
+             minval(hice), maxval(hice)
+endif
+
+! SLAB OCEAN (added by BC 2014)
+! nature of the surface
+call get_field("rnat",rnat,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <rnat>"
+      do ig=1,ngrid
+        rnat(ig)=1.
+      enddo
+else
+      do ig=1,ngrid
+        if((nint(rnat(ig)).eq.2).or.(nint(rnat(ig)).eq.0))then
+          rnat(ig)=0.
+        else
+          rnat(ig)=1.
+        endif      
+      enddo
+
+  write(*,*) "phyetat0: Nature of surface <rnat> range:", &
+             minval(rnat), maxval(rnat)
+endif
+! Pourcentage of sea ice cover
+call get_field("pctsrf_sic",pctsrf_sic,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <pctsrf_sic>"
+      do ig=1,ngrid
+      pctsrf_sic(ig)=0.
+      enddo
+else
+  write(*,*) "phyetat0: Pourcentage of sea ice cover <pctsrf_sic> range:", &
+             minval(pctsrf_sic), maxval(pctsrf_sic)
+endif
+! Slab ocean temperature (2 layers)
+call get_field("tslab",tslab,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <tslab>"
+      do ig=1,ngrid
+      do iq=1,noceanmx
+      tslab(ig,iq)=tsurf(ig)
+      enddo
+      enddo
+else
+  write(*,*) "phyetat0: Slab ocean temperature <tslab> range:", &
+             minval(tslab), maxval(tslab)
+endif
+! Oceanic ice temperature
+call get_field("tsea_ice",tsea_ice,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <tsea_ice>"
+      do ig=1,ngrid
+      tsea_ice(ig)=273.15-1.8
+      enddo
+else
+  write(*,*) "phyetat0: Oceanic ice temperature <tsea_ice> range:", &
+             minval(tsea_ice), maxval(tsea_ice)
+endif
+!  Oceanic ice quantity (kg/m^2)
+call get_field("sea_ice",sea_ice,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <sea_ice>"
+      do ig=1,ngrid
+      tsea_ice(ig)=0.
+      enddo
+else
+  write(*,*) "phyetat0: Oceanic ice quantity <sea_ice> range:", &
+             minval(sea_ice), maxval(sea_ice)
+endif
+
+
+
+
+! pbl wind variance
+call get_field("q2",q2,found,indextime)
+if (.not.found) then
+  write(*,*) "phyetat0: Failed loading <q2>"
+  call abort
+else
+  write(*,*) "phyetat0: PBL wind variance <q2> range:", &
+             minval(q2), maxval(q2)
+endif
+
+! tracer on surface
+if (nq.ge.1) then
+  do iq=1,nq
+    txt=noms(iq)
+    
+    !! There was a bug here. MT2015.
+    
+    !if (txt.eq."h2o_vap") then
+      ! There is no surface tracer for h2o_vap;
+      ! "h2o_ice" should be loaded instead
+     ! txt="h2o_ice"
+     ! write(*,*) 'phyetat0: loading surface tracer', &
+     !                      ' h2o_ice instead of h2o_vap'
+    !endif
+    
+    call get_field(txt,qsurf(:,iq),found,indextime)
+    if (.not.found) then
+      write(*,*) "phyetat0: Failed loading <",trim(txt),">"
+      write(*,*) "         ",trim(txt)," is set to zero"
+      qsurf(:,iq) = 0.
+    else
+      write(*,*) "phyetat0: Surface tracer <",trim(txt),"> range:", &
+                 minval(qsurf(:,iq)), maxval(qsurf(:,iq))
+    endif
+  enddo
+endif ! of if (nq.ge.1)
+
+
+! Call to soil_settings, in order to read soil temperatures,
+! as well as thermal inertia and volumetric heat capacity
+call soil_settings(nid_start,ngrid,nsoil,tsurf,tsoil,indextime)
+!
+! close file:
+!
+call close_startphy
+
+END SUBROUTINE phyetat0
Index: /trunk/LMDZ.TITAN/libf/phytitan/phyredem.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/phyredem.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/phyredem.F90	(revision 1644)
@@ -0,0 +1,219 @@
+module phyredem
+
+implicit none
+
+contains
+
+subroutine physdem0(filename,lonfi,latfi,nsoil,ngrid,nlay,nq, &
+                         phystep,day_ini,time,airefi, &
+                         alb,ith,pzmea,pzstd,pzsig,pzgam,pzthe)
+! create physics restart file and write time-independent variables
+  use comsoil_h, only: volcapa, mlayer
+  use geometry_mod, only: cell_area
+  use surfdat_h, only: zmea, zstd, zsig, zgam, zthe, &
+                       emisice, emissiv,             &
+                       iceradius, dtemisice, phisfi
+  use iostart, only : open_restartphy, close_restartphy, & 
+                      put_var, put_field, length
+  use mod_grid_phy_lmdz, only : klon_glo
+  use planete_mod, only: year_day, periastr, apoastr, peri_day, &
+                         obliquit, z0, lmixmin, emin_turb
+  use comcstfi_mod, only: rad, omeg, g, mugaz, rcp
+  use time_phylmdz_mod, only: daysec
+
+  implicit none
+
+  character(len=*), intent(in) :: filename
+  real,intent(in) :: lonfi(ngrid)
+  real,intent(in) :: latfi(ngrid)
+  integer,intent(in) :: nsoil
+  integer,intent(in) :: ngrid
+  integer,intent(in) :: nlay
+  integer,intent(in) :: nq
+  real,intent(in) :: phystep
+  real,intent(in) :: day_ini
+  real,intent(in) :: time
+  real,intent(in) :: airefi(ngrid)
+  real,intent(in) :: alb(ngrid)
+  real,intent(in) :: ith(ngrid,nsoil)
+  real,intent(in) :: pzmea(ngrid)
+  real,intent(in) :: pzstd(ngrid)
+  real,intent(in) :: pzsig(ngrid)
+  real,intent(in) :: pzgam(ngrid)
+  real,intent(in) :: pzthe(ngrid)
+ 
+  real :: tab_cntrl(length) ! nb "length=100" defined in iostart module
+  
+  ! Create physics start file
+  call open_restartphy(filename)
+
+! tab_cntrl() contains run parameters
+  tab_cntrl(:)=0 ! initialization
+!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! Fill control array tab_cntrl(:) with paramleters for this run
+!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+! Informations on the physics grid
+  tab_cntrl(1) = float(klon_glo)  ! number of nodes on physics grid
+  tab_cntrl(2) = float(nlay) ! number of atmospheric layers
+  tab_cntrl(3) = day_ini + int(time)         ! final day 
+  tab_cntrl(4) = time -int(time)            ! final time of day
+
+! Informations about Mars, used by dynamics and physics
+  tab_cntrl(5) = rad      ! radius of Mars (m) ~3397200
+  tab_cntrl(6) = omeg     ! rotation rate (rad.s-1)
+  tab_cntrl(7) = g        ! gravity (m.s-2) ~3.72
+  tab_cntrl(8) = mugaz    ! Molar mass of the atmosphere (g.mol-1) ~43.49
+  tab_cntrl(9) = rcp      !  = r/cp  ~0.256793 (=kappa dans dynamique)
+  tab_cntrl(10) = daysec  ! length of a sol (s)  ~88775
+
+  tab_cntrl(11) = phystep  ! time step in the physics
+  tab_cntrl(12) = 0.
+  tab_cntrl(13) = 0.
+
+! Informations about Mars, only for physics
+  tab_cntrl(14) = year_day  ! length of year (sols) ~668.6
+  tab_cntrl(15) = periastr  ! min. star-planet distance (AU)
+  tab_cntrl(16) = apoastr   ! max. star-planet distance (AU) 
+  tab_cntrl(17) = peri_day  ! date of periastron (sols since N. spring)
+  tab_cntrl(18) = obliquit  ! Obliquity of the planet (deg) ~23.98
+
+! Boundary layer and turbulence
+  tab_cntrl(19) = z0        ! surface roughness (m) ~0.01
+  tab_cntrl(20) = lmixmin   ! mixing length ~100
+  tab_cntrl(21) = emin_turb ! minimal energy ~1.e-8
+
+! Optical properties of polar caps and ground emissivity
+  tab_cntrl(24) = emisice(1)   ! Emissivity of northern cap ~0.95
+  tab_cntrl(25) = emisice(2)   ! Emissivity of southern cap ~0.95
+  tab_cntrl(26) = emissiv      ! Emissivity of martian soil ~.95
+  tab_cntrl(31) = iceradius(1) ! mean scat radius of CO2 snow (north)
+  tab_cntrl(32) = iceradius(2) ! mean scat radius of CO2 snow (south)
+  tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north)
+  tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south)
+
+  tab_cntrl(28) = 0. 
+  tab_cntrl(29) = 0.
+  tab_cntrl(30) = 0.
+
+! Soil properties:
+  tab_cntrl(35) = volcapa ! soil volumetric heat capacity
+
+  call put_var("controle","Control parameters",tab_cntrl)
+  
+  ! Write the mid-layer depths
+  call put_var("soildepth","Soil mid-layer depth",mlayer)
+  
+  ! Write longitudes
+  call put_field("longitude","Longitudes of physics grid",lonfi)
+  
+  ! Write latitudes
+  call put_field("latitude","Latitudes of physics grid",latfi)
+  
+  ! Write mesh areas
+  call put_field("area","Mesh area",cell_area)
+  
+  ! Write surface geopotential
+  call put_field("phisfi","Geopotential at the surface",phisfi)
+  
+  ! Write surface albedo
+  call put_field("albedodat","Albedo of bare ground",alb)
+  
+  ! Subgrid topogaphy variables
+  call put_field("ZMEA","Relief: mean relief",zmea)
+  call put_field("ZSTD","Relief: standard deviation",zstd)
+  call put_field("ZSIG","Relief: sigma parameter",zsig)
+  call put_field("ZGAM","Relief: gamma parameter",zgam)
+  call put_field("ZTHE","Relief: theta parameter",zthe)
+  
+  ! Soil thermal inertia
+  call put_field("inertiedat","Soil thermal inertia",ith)
+  
+  ! Close file
+  call close_restartphy
+  
+end subroutine physdem0
+
+subroutine physdem1(filename,nsoil,ngrid,nlay,nq, &
+                    phystep,time,tsurf,tsoil,emis,q2,qsurf, &
+                    cloudfrac,totcloudfrac,hice, &
+                    rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+  ! write time-dependent variable to restart file
+  use iostart, only : open_restartphy, close_restartphy, & 
+                      put_var, put_field
+  use tracer_h, only: noms
+  use slab_ice_h, only: noceanmx
+  use callkeys_mod, only: ok_slab_ocean
+
+  implicit none
+
+  character(len=*),intent(in) :: filename
+  integer,intent(in) :: nsoil
+  integer,intent(in) :: ngrid
+  integer,intent(in) :: nlay
+  integer,intent(in) :: nq
+  real,intent(in) :: phystep
+  real,intent(in) :: time
+  real,intent(in) :: tsurf(ngrid)
+  real,intent(in) :: tsoil(ngrid,nsoil)
+  real,intent(in) :: emis(ngrid)
+  real,intent(in) :: q2(ngrid,nlay+1)
+  real,intent(in) :: qsurf(ngrid,nq)
+  real,intent(in) :: cloudfrac(ngrid,nlay)
+  real,intent(in) :: totcloudfrac(ngrid)
+  real,intent(in) :: hice(ngrid)
+  real,intent(in) :: rnat(ngrid)
+  real,intent(in) :: pctsrf_sic(ngrid)
+  real,intent(in) :: tslab(ngrid,noceanmx)
+  real,intent(in) :: tsea_ice(ngrid)
+  real,intent(in) :: sea_ice(ngrid)
+
+  integer :: iq
+  
+  ! Open file
+  call open_restartphy(filename)
+
+  ! First variable to write must be "Time", in order to correctly
+  ! set time counter in file
+  !call put_var("Time","Temps de simulation",time)
+  
+  ! Surface temperature
+  call put_field("tsurf","Surface temperature",tsurf)
+  
+  ! Soil temperature
+  call put_field("tsoil","Soil temperature",tsoil)
+  
+  ! Emissivity of the surface
+  call put_field("emis","Surface emissivity",emis)
+  
+  ! Planetary Boundary Layer
+  call put_field("q2","pbl wind variance",q2)
+  
+! cloud fraction and sea ice (NB: these should be optional... to be improved)
+  call put_field("cloudfrac","Cloud fraction",cloudfrac)
+  call put_field("totcloudfrac","Total fraction",totcloudfrac)
+  call put_field("hice","Height of oceanic ice",hice)
+
+ !Slab ocean 
+ if(ok_slab_ocean) then
+   call put_field("rnat","Nature of surface",rnat)
+   call put_field("pctsrf_sic","Pourcentage sea ice",pctsrf_sic)
+   call put_field("tslab","Temperature slab ocean",tslab)
+   call put_field("tsea_ice","Temperature sea ice",tsea_ice)
+   call put_field("sea_ice","Sea ice mass",sea_ice)
+ endif!(ok_slab_ocean)
+
+
+! tracers
+  if (nq>0) then
+    do iq=1,nq
+      call put_field(noms(iq),"tracer on surface",qsurf(:,iq))
+    enddo
+  endif ! of if (nq>0)
+
+! close file
+      CALL close_restartphy
+!$OMP BARRIER
+
+end subroutine physdem1
+
+end module phyredem
Index: /trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/physiq_mod.F90	(revision 1644)
@@ -0,0 +1,2177 @@
+      module physiq_mod
+      
+      implicit none
+      
+      contains
+      
+      subroutine physiq(ngrid,nlayer,nq,   &
+                  nametrac,                & 
+                  firstcall,lastcall,      &
+                  pday,ptime,ptimestep,    &
+                  pplev,pplay,pphi,        &
+                  pu,pv,pt,pq,             &
+                  flxw,                    &
+                  pdu,pdv,pdt,pdq,pdpsrf)
+ 
+      use radinc_h, only : L_NSPECTI,L_NSPECTV,naerkind
+      use watercommon_h, only : RLVTT, Psat_water,epsi
+      use gases_h, only: gnom, gfrac
+      use radcommon_h, only: sigma, glat, grav, BWNV
+      use radii_mod, only: h2o_reffrad, co2_reffrad
+      use aerosol_mod, only: iaero_co2, iaero_h2o
+      use surfdat_h, only: phisfi, zmea, zstd, zsig, zgam, zthe, &
+                           dryness, watercaptag
+      use comdiurn_h, only: coslat, sinlat, coslon, sinlon
+      use comsaison_h, only: mu0, fract, dist_star, declin, right_ascen
+      use comsoil_h, only: nsoilmx, layer, mlayer, inertiedat
+      use geometry_mod, only: latitude, longitude, cell_area
+      USE comgeomfi_h, only: totarea, totarea_planet
+      USE tracer_h, only: noms, mmol, radius, rho_q, qext, &
+                          alpha_lift, alpha_devil, qextrhor, &
+                          igcm_h2o_ice, igcm_h2o_vap, igcm_dustbin, &
+                          igcm_co2_ice
+      use time_phylmdz_mod, only: ecritphy, iphysiq, nday
+      use phyredem, only: physdem0, physdem1
+      use slab_ice_h, only: capcalocean, capcalseaice,capcalsno, &
+                            noceanmx
+      use ocean_slab_mod, only :ocean_slab_init, ocean_slab_ice, &
+                                ini_surf_heat_transp_mod, &
+                                ocean_slab_get_vars,ocean_slab_final
+      use surf_heat_transp_mod,only :init_masquv
+      use planetwide_mod, only: planetwide_minval,planetwide_maxval,planetwide_sumval
+      use mod_phys_lmdz_para, only : is_master
+      use planete_mod, only: apoastr, periastr, year_day, peri_day, &
+                            obliquit, nres, z0
+      use comcstfi_mod, only: pi, g, rcp, r, rad, mugaz, cpp
+      use time_phylmdz_mod, only: daysec
+      use callkeys_mod
+      use vertical_layers_mod, only: presnivs, pseudoalt
+#ifdef CPP_XIOS      
+      use xios_output_mod, only: initialize_xios_output, &
+                                 update_xios_timestep, &
+                                 send_xios_field
+#endif
+      implicit none
+
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Central subroutine for all the physics parameterisations in the
+!     universal model. Originally adapted from the Mars LMDZ model.
+!
+!     The model can be run without or with tracer transport
+!     depending on the value of "tracer" in file "callphys.def".
+!
+!
+!   It includes:
+!
+!      I. Initialization :
+!         I.1 Firstcall initializations.
+!         I.2 Initialization for every call to physiq.
+!
+!      II. Compute radiative transfer tendencies (longwave and shortwave) :
+!         II.a Option 1 : Call correlated-k radiative transfer scheme.
+!         II.b Option 2 : Call Newtonian cooling scheme.
+!         II.c Option 3 : Atmosphere has no radiative effect.
+!
+!      III. Vertical diffusion (turbulent mixing) :
+!
+!      IV. Dry Convective adjustment :
+!
+!      V. Condensation and sublimation of gases (currently just CO2).
+!
+!      VI. Tracers
+!         VI.1. Water and water ice.
+!         VI.2. Aerosols and particles.
+!         VI.3. Updates (pressure variations, surface budget).
+!         VI.4. Slab Ocean.
+!         VI.5. Surface Tracer Update.
+!
+!      VII. Surface and sub-surface soil temperature.
+!
+!      VIII. Perform diagnostics and write output files.
+!
+!
+!   arguments
+!   ---------
+!
+!   INPUT
+!   -----
+!
+!    ngrid                 Size of the horizontal grid.
+!    nlayer                Number of vertical layers.
+!    nq                    Number of advected fields.
+!    nametrac              Name of corresponding advected fields.
+!
+!    firstcall             True at the first call.
+!    lastcall              True at the last call.
+!
+!    pday                  Number of days counted from the North. Spring equinoxe.
+!    ptime                 Universal time (0<ptime<1): ptime=0.5 at 12:00 UT.
+!    ptimestep             timestep (s).
+!
+!    pplay(ngrid,nlayer)   Pressure at the middle of the layers (Pa).
+!    pplev(ngrid,nlayer+1) Intermediate pressure levels (Pa).
+!    pphi(ngrid,nlayer)    Geopotential at the middle of the layers (m2.s-2).
+!
+!    pu(ngrid,nlayer)      u, zonal component of the wind (ms-1).
+!    pv(ngrid,nlayer)      v, meridional component of the wind (ms-1).
+!
+!    pt(ngrid,nlayer)      Temperature (K).
+!
+!    pq(ngrid,nlayer,nq)   Advected fields.
+!
+!    pudyn(ngrid,nlayer)    \
+!    pvdyn(ngrid,nlayer)     \ Dynamical temporal derivative for the
+!    ptdyn(ngrid,nlayer)     / corresponding variables.
+!    pqdyn(ngrid,nlayer,nq) /
+!    flxw(ngrid,nlayer)      vertical mass flux (kg/s) at layer lower boundary
+!
+!   OUTPUT
+!   ------
+!
+!    pdu(ngrid,nlayer)        \
+!    pdv(ngrid,nlayer)         \  Temporal derivative of the corresponding
+!    pdt(ngrid,nlayer)         /  variables due to physical processes.
+!    pdq(ngrid,nlayer)        /
+!    pdpsrf(ngrid)             /
+!
+!
+!     Authors
+!     -------
+!           Frederic Hourdin        15/10/93
+!           Francois Forget        1994
+!           Christophe Hourdin        02/1997 
+!           Subroutine completely rewritten by F. Forget (01/2000)
+!           Water ice clouds: Franck Montmessin (update 06/2003)
+!           Radiatively active tracers: J.-B. Madeleine (10/2008-06/2009)
+!           New correlated-k radiative scheme: R. Wordsworth (2009)
+!           Many specifically Martian subroutines removed: R. Wordsworth (2009)       
+!           Improved water cycle: R. Wordsworth / B. Charnay (2010)
+!           To F90: R. Wordsworth (2010)
+!           New turbulent diffusion scheme: J. Leconte (2012)
+!           Loops converted to F90 matrix format: J. Leconte (2012)
+!           No more ngridmx/nqmx, F90 commons and adaptation to parallel: A. Spiga (2012)
+!           Purge of the code : M. Turbet (2015)
+!==================================================================
+
+
+!    0.  Declarations :
+!    ------------------
+
+#include "netcdf.inc"
+
+! Arguments :
+! -----------
+
+!   INPUTS:
+!   -------
+
+      integer,intent(in) :: ngrid             ! Number of atmospheric columns.
+      integer,intent(in) :: nlayer            ! Number of atmospheric layers.
+      integer,intent(in) :: nq                ! Number of tracers.
+      character*20,intent(in) :: nametrac(nq) ! Names of the tracers taken from dynamics.
+      
+      logical,intent(in) :: firstcall ! Signals first call to physics.
+      logical,intent(in) :: lastcall  ! Signals last call to physics.
+      
+      real,intent(in) :: pday                  ! Number of elapsed sols since reference Ls=0.
+      real,intent(in) :: ptime                 ! "Universal time", given as fraction of sol (e.g.: 0.5 for noon).
+      real,intent(in) :: ptimestep             ! Physics timestep (s).
+      real,intent(in) :: pplev(ngrid,nlayer+1) ! Inter-layer pressure (Pa).
+      real,intent(in) :: pplay(ngrid,nlayer)   ! Mid-layer pressure (Pa).
+      real,intent(in) :: pphi(ngrid,nlayer)    ! Geopotential at mid-layer (m2s-2).
+      real,intent(in) :: pu(ngrid,nlayer)      ! Zonal wind component (m/s).
+      real,intent(in) :: pv(ngrid,nlayer)      ! Meridional wind component (m/s).
+      real,intent(in) :: pt(ngrid,nlayer)      ! Temperature (K).
+      real,intent(in) :: pq(ngrid,nlayer,nq)   ! Tracers (kg/kg_of_air).
+      real,intent(in) :: flxw(ngrid,nlayer)    ! Vertical mass flux (ks/s) at lower boundary of layer
+
+!   OUTPUTS:
+!   --------
+
+!     Physical tendencies :
+
+      real,intent(out) :: pdu(ngrid,nlayer)    ! Zonal wind tendencies (m/s/s).
+      real,intent(out) :: pdv(ngrid,nlayer)    ! Meridional wind tendencies (m/s/s).
+      real,intent(out) :: pdt(ngrid,nlayer)    ! Temperature tendencies (K/s).
+      real,intent(out) :: pdq(ngrid,nlayer,nq) ! Tracer tendencies (kg/kg_of_air/s).
+      real,intent(out) :: pdpsrf(ngrid)        ! Surface pressure tendency (Pa/s).
+
+! Local saved variables:
+! ----------------------
+
+      integer,save :: day_ini                                      ! Initial date of the run (sol since Ls=0).
+      integer,save :: icount                                       ! Counter of calls to physiq during the run.
+!$OMP THREADPRIVATE(day_ini,icount)
+
+      real, dimension(:),allocatable,save ::  tsurf                ! Surface temperature (K).
+      real, dimension(:,:),allocatable,save ::  tsoil              ! Sub-surface temperatures (K).
+      real, dimension(:,:),allocatable,save :: albedo              ! Surface Spectral albedo. By MT2015.
+      real, dimension(:),allocatable,save :: albedo_equivalent     ! Spectral Mean albedo.
+      real, dimension(:),allocatable,save :: albedo_snow_SPECTV    ! Snow Spectral albedo.
+      real, dimension(:),allocatable,save :: albedo_co2_ice_SPECTV ! CO2 ice Spectral albedo.
+      
+!$OMP THREADPRIVATE(tsurf,tsoil,albedo,albedo_equivalent,albedo_snow_SPECTV,albedo_co2_ice_SPECTV)
+
+      real,dimension(:),allocatable,save :: albedo_bareground ! Bare Ground Albedo. By MT 2015.
+      real,dimension(:),allocatable,save :: rnat              ! Defines the type of the grid (ocean,continent,...). By BC.
+      
+!$OMP THREADPRIVATE(albedo_bareground,rnat)
+
+      real,dimension(:),allocatable,save :: emis        ! Thermal IR surface emissivity.
+      real,dimension(:,:),allocatable,save :: dtrad     ! Net atmospheric radiative heating rate (K.s-1).
+      real,dimension(:),allocatable,save :: fluxrad_sky ! Radiative flux from sky absorbed by surface (W.m-2).
+      real,dimension(:),allocatable,save :: fluxrad     ! Net radiative surface flux (W.m-2).
+      real,dimension(:),allocatable,save :: capcal      ! Surface heat capacity (J m-2 K-1).
+      real,dimension(:),allocatable,save :: fluxgrd     ! Surface conduction flux (W.m-2).
+      real,dimension(:,:),allocatable,save :: qsurf     ! Tracer on surface (e.g. kg.m-2).
+      real,dimension(:,:),allocatable,save :: q2        ! Turbulent Kinetic Energy.
+      
+!$OMP THREADPRIVATE(emis,dtrad,fluxrad_sky,fluxrad,capcal,fluxgrd,qsurf,q2)
+
+
+! Local variables :
+! -----------------
+
+!     Aerosol (dust or ice) extinction optical depth  at reference wavelength 
+!     for the "naerkind" optically active aerosols:
+
+      real aerosol(ngrid,nlayer,naerkind) ! Aerosols.
+      real zh(ngrid,nlayer)               ! Potential temperature (K).
+      real pw(ngrid,nlayer)               ! Vertical velocity (m/s). (NOTE : >0 WHEN DOWNWARDS !!)
+
+      integer l,ig,ierr,iq,nw
+      
+      ! FOR DIAGNOSTIC :
+      
+      real,dimension(:),allocatable,save :: fluxsurf_lw     ! Incident Long Wave (IR) surface flux (W.m-2).
+      real,dimension(:),allocatable,save :: fluxsurf_sw     ! Incident Short Wave (stellar) surface flux (W.m-2).
+      real,dimension(:),allocatable,save :: fluxsurfabs_sw  ! Absorbed Short Wave (stellar) flux by the surface (W.m-2).
+      real,dimension(:),allocatable,save :: fluxtop_lw      ! Outgoing LW (IR) flux to space (W.m-2).
+      real,dimension(:),allocatable,save :: fluxabs_sw      ! Absorbed SW (stellar) flux (W.m-2).
+      real,dimension(:),allocatable,save :: fluxtop_dn      ! Incoming SW (stellar) radiation at the top of the atmosphere (W.m-2).
+      real,dimension(:),allocatable,save :: fluxdyn         ! Horizontal heat transport by dynamics (W.m-2).
+      real,dimension(:,:),allocatable,save :: OLR_nu        ! Outgoing LW radiation in each band (Normalized to the band width (W/m2/cm-1)).
+      real,dimension(:,:),allocatable,save :: OSR_nu        ! Outgoing SW radiation in each band (Normalized to the band width (W/m2/cm-1)).
+      real,dimension(:,:),allocatable,save :: zdtlw         ! LW heating tendencies (K/s).
+      real,dimension(:,:),allocatable,save :: zdtsw         ! SW heating tendencies (K/s).
+      real,dimension(:),allocatable,save :: sensibFlux      ! Turbulent flux given by the atmosphere to the surface (W.m-2).
+      
+!$OMP THREADPRIVATE(fluxsurf_lw,fluxsurf_sw,fluxsurfabs_sw,fluxtop_lw,fluxabs_sw,fluxtop_dn,fluxdyn,OLR_nu,OSR_nu,&
+        
+        !$OMP zdtlw,zdtsw,sensibFlux)
+
+      real zls                       ! Solar longitude (radians).
+      real zlss                      ! Sub solar point longitude (radians).
+      real zday                      ! Date (time since Ls=0, calculated in sols).
+      real zzlay(ngrid,nlayer)       ! Altitude at the middle of the atmospheric layers.
+      real zzlev(ngrid,nlayer+1)     ! Altitude at the atmospheric layer boundaries.
+
+! TENDENCIES due to various processes :
+
+      ! For Surface Temperature : (K/s)
+      real zdtsurf(ngrid)     ! Cumulated tendencies.
+      real zdtsurfmr(ngrid)   ! Mass_redistribution routine.
+      real zdtsurfc(ngrid)    ! Condense_co2 routine.
+      real zdtsdif(ngrid)     ! Turbdiff/vdifc routines.
+      real zdtsurf_hyd(ngrid) ! Hydrol routine.
+            
+      ! For Atmospheric Temperatures : (K/s)    
+      real dtlscale(ngrid,nlayer)                             ! Largescale routine.
+      real zdtc(ngrid,nlayer)                                 ! Condense_co2 routine.
+      real zdtdif(ngrid,nlayer)                                      ! Turbdiff/vdifc routines.
+      real zdtmr(ngrid,nlayer)                                ! Mass_redistribution routine.
+      real zdtrain(ngrid,nlayer)                              ! Rain routine.
+      real dtmoist(ngrid,nlayer)                              ! Moistadj routine.
+      real dt_ekman(ngrid,noceanmx), dt_hdiff(ngrid,noceanmx) ! Slab_ocean routine.
+      real zdtsw1(ngrid,nlayer), zdtlw1(ngrid,nlayer)         ! Callcorrk routine.
+                              
+      ! For Surface Tracers : (kg/m2/s)
+      real dqsurf(ngrid,nq)                 ! Cumulated tendencies.
+      real zdqsurfc(ngrid)                  ! Condense_co2 routine.
+      real zdqsdif(ngrid,nq)                ! Turbdiff/vdifc routines.
+      real zdqssed(ngrid,nq)                ! Callsedim routine.
+      real zdqsurfmr(ngrid,nq)              ! Mass_redistribution routine.
+      real zdqsrain(ngrid), zdqssnow(ngrid) ! Rain routine.
+      real dqs_hyd(ngrid,nq)                ! Hydrol routine.
+                  
+      ! For Tracers : (kg/kg_of_air/s)
+      real zdqc(ngrid,nlayer,nq)      ! Condense_co2 routine.
+      real zdqadj(ngrid,nlayer,nq)    ! Convadj routine.
+      real zdqdif(ngrid,nlayer,nq)    ! Turbdiff/vdifc routines.
+      real zdqevap(ngrid,nlayer)      ! Turbdiff routine.
+      real zdqsed(ngrid,nlayer,nq)    ! Callsedim routine.
+      real zdqmr(ngrid,nlayer,nq)     ! Mass_redistribution routine.
+      real zdqrain(ngrid,nlayer,nq)   ! Rain routine.
+      real dqmoist(ngrid,nlayer,nq)   ! Moistadj routine.
+      real dqvaplscale(ngrid,nlayer)  ! Largescale routine.
+      real dqcldlscale(ngrid,nlayer)  ! Largescale routine.
+                        
+      ! For Winds : (m/s/s)
+      real zdvadj(ngrid,nlayer),zduadj(ngrid,nlayer) ! Convadj routine.
+      real zdumr(ngrid,nlayer),zdvmr(ngrid,nlayer)   ! Mass_redistribution routine.
+      real zdvdif(ngrid,nlayer),zdudif(ngrid,nlayer) ! Turbdiff/vdifc routines.
+      real zdhdif(ngrid,nlayer)                      ! Turbdiff/vdifc routines.
+      real zdhadj(ngrid,nlayer)                      ! Convadj routine.
+     
+      ! For Pressure and Mass :
+      real zdmassmr(ngrid,nlayer) ! Atmospheric Mass tendency for mass_redistribution (kg_of_air/m2/s).
+      real zdmassmr_col(ngrid)    ! Atmospheric Column Mass tendency for mass_redistribution (kg_of_air/m2/s).
+      real zdpsrfmr(ngrid)        ! Pressure tendency for mass_redistribution routine (Pa/s).
+
+      
+    
+! Local variables for LOCAL CALCULATIONS:
+! ---------------------------------------
+      real zflubid(ngrid)
+      real zplanck(ngrid),zpopsk(ngrid,nlayer)
+      real ztim1,ztim2,ztim3, z1,z2
+      real ztime_fin
+      real zdh(ngrid,nlayer)
+      real gmplanet
+      real taux(ngrid),tauy(ngrid)
+
+
+! local variables for DIAGNOSTICS : (diagfi & stat)
+! -------------------------------------------------
+      real ps(ngrid)                                     ! Surface Pressure.
+      real zt(ngrid,nlayer)                              ! Atmospheric Temperature.
+      real zu(ngrid,nlayer),zv(ngrid,nlayer)             ! Zonal and Meridional Winds.
+      real zq(ngrid,nlayer,nq)                           ! Atmospheric Tracers.
+      real zdtadj(ngrid,nlayer)                          ! Convadj Diagnostic.
+      real zdtdyn(ngrid,nlayer)                          ! Dynamical Heating (K/s).
+      real zdudyn(ngrid,nlayer)                          ! Dynamical Zonal Wind tendency (m.s-2).
+      real,allocatable,dimension(:,:),save :: ztprevious ! Previous loop Atmospheric Temperature (K)                                                         ! Useful for Dynamical Heating calculation.
+      real,allocatable,dimension(:,:),save :: zuprevious ! Previous loop Zonal Wind (m.s-1)                                                                  ! Useful for Zonal Wind tendency calculation.
+!$OMP THREADPRIVATE(ztprevious,zuprevious)
+
+      real reff(ngrid,nlayer)                       ! Effective dust radius (used if doubleq=T).
+      real vmr(ngrid,nlayer)                        ! volume mixing ratio
+      real time_phys
+      real,allocatable,dimension(:),save :: tau_col ! Total Aerosol Optical Depth.
+!$OMP THREADPRIVATE(tau_col)
+      
+      real ISR,ASR,OLR,GND,DYN,GSR,Ts1,Ts2,Ts3,TsS ! for Diagnostic.
+      
+      real qcol(ngrid,nq) ! Tracer Column Mass (kg/m2).
+
+!     included by RW for H2O Manabe scheme
+      real rneb_man(ngrid,nlayer) ! H2O cloud fraction (moistadj).
+      real rneb_lsc(ngrid,nlayer) ! H2O cloud fraction (large scale).
+
+
+!     to test energy conservation (RW+JL)
+      real mass(ngrid,nlayer),massarea(ngrid,nlayer)
+      real dEtot, dEtots, AtmToSurf_TurbFlux
+      real,save :: dEtotSW, dEtotsSW, dEtotLW, dEtotsLW
+!$OMP THREADPRIVATE(dEtotSW, dEtotsSW, dEtotLW, dEtotsLW)
+      real dEzRadsw(ngrid,nlayer),dEzRadlw(ngrid,nlayer),dEzdiff(ngrid,nlayer)
+      real dEdiffs(ngrid),dEdiff(ngrid)
+      real madjdE(ngrid), lscaledE(ngrid),madjdEz(ngrid,nlayer), lscaledEz(ngrid,nlayer)
+      
+!JL12 conservation test for mean flow kinetic energy has been disabled temporarily
+
+      real dtmoist_max,dtmoist_min     
+      real dItot, dItot_tmp, dVtot, dVtot_tmp
+
+      real,allocatable,save :: hice(:) ! Oceanic Ice height. by BC
+ !$OMP THREADPRIVATE(hice)     
+
+      real h2otot                      ! Total Amount of water. For diagnostic.
+      real icesrf,liqsrf,icecol,vapcol ! Total Amounts of water (ice,liq,vap). For diagnostic.
+      real dWtot, dWtot_tmp, dWtots, dWtots_tmp
+      logical,save :: watertest
+!$OMP THREADPRIVATE(watertest)
+
+      real qsat(ngrid,nlayer) ! Water Vapor Volume Mixing Ratio at saturation (kg/kg_of_air).
+      real RH(ngrid,nlayer)   ! Relative humidity.
+      real H2Omaxcol(ngrid)   ! Maximum possible H2O column amount (at 100% saturation) (kg/m2).
+      real psat_tmp
+      
+      logical clearsky ! For double radiative transfer call. By BC
+      
+      ! For Clear Sky Case.
+      real fluxsurf_lw1(ngrid), fluxsurf_sw1(ngrid), fluxsurfabs_sw1(ngrid)  ! For SW/LW flux.
+      real fluxtop_lw1(ngrid), fluxabs_sw1(ngrid)                            ! For SW/LW flux.
+      real albedo_equivalent1(ngrid)                                         ! For Equivalent albedo calculation.
+      real tau_col1(ngrid)                                                   ! For aerosol optical depth diagnostic.
+      real OLR_nu1(ngrid,L_NSPECTI), OSR_nu1(ngrid,L_NSPECTV)                ! For Outgoing Radiation diagnostics.
+      real tf, ntf
+
+      real,allocatable,dimension(:,:),save :: cloudfrac  ! Fraction of clouds (%).
+      real,allocatable,dimension(:),save :: totcloudfrac ! Column fraction of clouds (%).
+!$OMP THREADPRIVATE(cloudfrac,totcloudfrac)
+
+      real nconsMAX, vdifcncons(ngrid), cadjncons(ngrid) ! Vdfic water conservation test. By RW
+
+      real,allocatable,dimension(:,:),save :: qsurf_hist
+!$OMP THREADPRIVATE(qsurf_hist)
+
+      real muvar(ngrid,nlayer+1) ! For Runaway Greenhouse 1D study. By RW
+
+      real,allocatable,dimension(:,:,:),save :: reffrad  ! Aerosol effective radius (m). By RW
+      real,allocatable,dimension(:,:,:),save :: nueffrad ! Aerosol effective radius variance. By RW
+!$OMP THREADPRIVATE(reffrad,nueffrad)
+
+      real reffcol(ngrid,naerkind)
+
+!     Sourceevol for 'accelerated ice evolution'. By RW
+      real,allocatable,dimension(:),save :: ice_initial
+      real delta_ice,ice_tot
+      real,allocatable,dimension(:),save :: ice_min      
+      integer num_run
+      logical,save :: ice_update
+!$OMP THREADPRIVATE(ice_initial,ice_min,ice_update)
+
+!     For slab ocean. By BC
+      real, dimension(:),allocatable,save ::  pctsrf_sic
+      real, dimension(:,:),allocatable,save :: tslab
+      real, dimension(:),allocatable,save ::  tsea_ice
+      real, dimension(:),allocatable,save :: sea_ice
+      real, dimension(:),allocatable,save :: zmasq
+      integer, dimension(:),allocatable,save ::knindex 
+!$OMP THREADPRIVATE(pctsrf_sic,tslab,tsea_ice,sea_ice,zmasq,knindex)
+
+      real :: tsurf2(ngrid)
+      real :: flux_o(ngrid),flux_g(ngrid),fluxgrdocean(ngrid)
+      real :: flux_sens_lat(ngrid)
+      real :: qsurfint(ngrid,nq)
+
+
+!==================================================================================================
+
+! -----------------
+! I. INITIALISATION
+! -----------------
+
+! --------------------------------
+! I.1   First Call Initialisation.
+! --------------------------------
+      if (firstcall) then
+
+        ! Allocate saved arrays.
+        ALLOCATE(tsurf(ngrid))
+        ALLOCATE(tsoil(ngrid,nsoilmx))    
+        ALLOCATE(albedo(ngrid,L_NSPECTV))
+         ALLOCATE(albedo_equivalent(ngrid))        
+         ALLOCATE(albedo_snow_SPECTV(L_NSPECTV))
+         ALLOCATE(albedo_co2_ice_SPECTV(L_NSPECTV))
+         ALLOCATE(albedo_bareground(ngrid))           
+        ALLOCATE(rnat(ngrid))         
+        ALLOCATE(emis(ngrid))   
+        ALLOCATE(dtrad(ngrid,nlayer))
+        ALLOCATE(fluxrad_sky(ngrid))
+        ALLOCATE(fluxrad(ngrid))    
+        ALLOCATE(capcal(ngrid))    
+        ALLOCATE(fluxgrd(ngrid))  
+        ALLOCATE(qsurf(ngrid,nq))  
+        ALLOCATE(q2(ngrid,nlayer+1)) 
+        ALLOCATE(ztprevious(ngrid,nlayer))
+        ALLOCATE(zuprevious(ngrid,nlayer))
+        ALLOCATE(cloudfrac(ngrid,nlayer))
+        ALLOCATE(totcloudfrac(ngrid))
+        ALLOCATE(hice(ngrid))
+        ALLOCATE(qsurf_hist(ngrid,nq))
+        ALLOCATE(reffrad(ngrid,nlayer,naerkind))
+        ALLOCATE(nueffrad(ngrid,nlayer,naerkind))
+        ALLOCATE(ice_initial(ngrid))
+        ALLOCATE(ice_min(ngrid)) 
+        ALLOCATE(fluxsurf_lw(ngrid))
+        ALLOCATE(fluxsurf_sw(ngrid))
+        ALLOCATE(fluxsurfabs_sw(ngrid))
+        ALLOCATE(fluxtop_lw(ngrid))
+        ALLOCATE(fluxabs_sw(ngrid))
+        ALLOCATE(fluxtop_dn(ngrid))
+        ALLOCATE(fluxdyn(ngrid))
+        ALLOCATE(OLR_nu(ngrid,L_NSPECTI))
+        ALLOCATE(OSR_nu(ngrid,L_NSPECTV))
+        ALLOCATE(sensibFlux(ngrid))
+        ALLOCATE(zdtlw(ngrid,nlayer))
+        ALLOCATE(zdtsw(ngrid,nlayer))
+        ALLOCATE(tau_col(ngrid))
+        ALLOCATE(pctsrf_sic(ngrid))
+        ALLOCATE(tslab(ngrid,noceanmx))
+        ALLOCATE(tsea_ice(ngrid))
+        ALLOCATE(sea_ice(ngrid))
+        ALLOCATE(zmasq(ngrid))
+        ALLOCATE(knindex(ngrid))
+
+        ! This is defined in comsaison_h
+        ALLOCATE(mu0(ngrid))
+        ALLOCATE(fract(ngrid))            
+         ! This is defined in radcommon_h
+        ALLOCATE(glat(ngrid))
+        
+
+!        Variables set to 0
+!        ~~~~~~~~~~~~~~~~~~
+         dtrad(:,:) = 0.0
+         fluxrad(:) = 0.0
+         tau_col(:) = 0.0
+         zdtsw(:,:) = 0.0
+         zdtlw(:,:) = 0.0
+
+
+!        Initialize aerosol indexes.
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         call iniaerosol()
+
+      
+!        Initialize tracer names, indexes and properties.
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         IF (.NOT.ALLOCATED(noms)) ALLOCATE(noms(nq)) ! (because noms is an argument of physdem1 whether or not tracer is on)
+         if (tracer) then
+            call initracer(ngrid,nq,nametrac)
+         endif
+
+
+!        Read 'startfi.nc' file.
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         call phyetat0(ngrid,nlayer,"startfi.nc",0,0,nsoilmx,nq,      &
+                       day_ini,time_phys,tsurf,tsoil,emis,q2,qsurf,   &
+                       cloudfrac,totcloudfrac,hice,                   &
+                       rnat,pctsrf_sic,tslab, tsea_ice,sea_ice)
+
+         if (pday.ne.day_ini) then
+           write(*,*) "ERROR in physiq.F90:"
+           write(*,*) "bad synchronization between physics and dynamics"
+           write(*,*) "dynamics day: ",pday
+           write(*,*) "physics day:  ",day_ini
+           stop
+         endif
+
+         write (*,*) 'In physiq day_ini =', day_ini
+
+!        Initialize albedo calculation. 
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         albedo(:,:)=0.0
+          albedo_bareground(:)=0.0
+          albedo_snow_SPECTV(:)=0.0
+          albedo_co2_ice_SPECTV(:)=0.0
+         call surfini(ngrid,nq,qsurf,albedo,albedo_bareground,albedo_snow_SPECTV,albedo_co2_ice_SPECTV) 
+         
+!        Initialize orbital calculation. 
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         call iniorbit(apoastr,periastr,year_day,peri_day,obliquit)
+
+
+         if(tlocked)then
+            print*,'Planet is tidally locked at resonance n=',nres
+            print*,'Make sure you have the right rotation rate!!!'
+         endif
+
+!        Initialize oceanic variables.
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+         if (ok_slab_ocean)then
+
+           call ocean_slab_init(ngrid,ptimestep, tslab, &
+                                sea_ice, pctsrf_sic)
+
+           call ini_surf_heat_transp_mod()
+           
+           knindex(:) = 0
+
+           do ig=1,ngrid
+              zmasq(ig)=1
+              knindex(ig) = ig
+              if (nint(rnat(ig)).eq.0) then
+                 zmasq(ig)=0
+              endif
+           enddo
+
+           CALL init_masquv(ngrid,zmasq)
+
+         endif ! end of 'ok_slab_ocean'.
+
+
+!        Initialize soil.
+!        ~~~~~~~~~~~~~~~~
+         if (callsoil) then
+         
+            call soil(ngrid,nsoilmx,firstcall,lastcall,inertiedat, &
+                      ptimestep,tsurf,tsoil,capcal,fluxgrd)
+
+            if (ok_slab_ocean) then
+               do ig=1,ngrid
+                  if (nint(rnat(ig)).eq.2) then
+                     capcal(ig)=capcalocean
+                     if (pctsrf_sic(ig).gt.0.5) then
+                        capcal(ig)=capcalseaice
+                        if (qsurf(ig,igcm_h2o_ice).gt.0.) then
+                           capcal(ig)=capcalsno
+                        endif
+                     endif
+                  endif
+               enddo
+            endif ! end of 'ok_slab_ocean'.
+
+         else ! else of 'callsoil'.
+         
+            print*,'WARNING! Thermal conduction in the soil turned off'
+            capcal(:)=1.e6
+            fluxgrd(:)=intheat
+            print*,'Flux from ground = ',intheat,' W m^-2'
+            
+         endif ! end of 'callsoil'.
+         
+         icount=1
+
+!        Decide whether to update ice at end of run.
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         ice_update=.false.
+         if(sourceevol)then
+!$OMP MASTER
+            open(128,file='num_run',form='formatted', &
+                     status="old",iostat=ierr)
+            if (ierr.ne.0) then
+               write(*,*) "physiq: Error! No num_run file!"
+               write(*,*) " (which is needed for sourceevol option)"
+               stop
+            endif
+            read(128,*) num_run 
+            close(128)
+!$OMP END MASTER
+!$OMP BARRIER
+        
+            if(num_run.ne.0.and.mod(num_run,2).eq.0)then
+               print*,'Updating ice at end of this year!'
+               ice_update=.true.
+               ice_min(:)=1.e4
+            endif
+            
+         endif ! end of 'sourceevol'.
+
+
+         ! Here is defined the type of the surface : Continent or Ocean.
+         ! BC2014 : This is now already done in newstart.
+         ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         if (.not.ok_slab_ocean) then
+         
+           rnat(:)=1.
+           do ig=1,ngrid
+              if(inertiedat(ig,1).gt.1.E4)then
+                 rnat(ig)=0
+              endif
+           enddo
+
+           print*,'WARNING! Surface type currently decided by surface inertia'
+           print*,'This should be improved e.g. in newstart.F'
+           
+         endif ! end of 'ok_slab_ocean'.
+
+
+!        Initialize surface history variable.
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         qsurf_hist(:,:)=qsurf(:,:)
+
+!        Initialize variable for dynamical heating and zonal wind tendency diagnostic
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         ztprevious(:,:)=pt(:,:)
+         zuprevious(:,:)=pu(:,:)
+
+!        Set temperature just above condensation temperature (for Early Mars)
+!        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+         if(nearco2cond) then
+            write(*,*)' WARNING! Starting at Tcond+1K'
+            do l=1, nlayer
+               do ig=1,ngrid
+                  pdt(ig,l)= ((-3167.8)/(log(.01*pplay(ig,l))-23.23)+4     &
+                      -pt(ig,l)) / ptimestep
+               enddo
+            enddo
+         endif
+
+         if(meanOLR)then          
+            call system('rm -f rad_bal.out') ! to record global radiative balance.           
+            call system('rm -f tem_bal.out') ! to record global mean/max/min temperatures.            
+            call system('rm -f h2o_bal.out') ! to record global hydrological balance.
+         endif
+
+
+         watertest=.false.        
+         if(water)then ! Initialize variables for water cycle
+            
+            if(enertest)then
+               watertest = .true.
+            endif
+
+            if(ice_update)then
+               ice_initial(:)=qsurf(:,igcm_h2o_ice)
+            endif
+
+         endif
+         
+         call su_watercycle ! even if we don't have a water cycle, we might
+                            ! need epsi for the wvp definitions in callcorrk.F
+
+         if (ngrid.ne.1) then ! Note : no need to create a restart file in 1d.
+            call physdem0("restartfi.nc",longitude,latitude,nsoilmx,ngrid,nlayer,nq, &
+                          ptimestep,pday+nday,time_phys,cell_area,          &
+                          albedo_bareground,inertiedat,zmea,zstd,zsig,zgam,zthe)
+         endif
+         
+         ! XIOS outputs
+#ifdef CPP_XIOS
+
+         write(*,*) "physiq: call initialize_xios_output"
+         call initialize_xios_output(pday,ptime,ptimestep,daysec, &
+                                     presnivs,pseudoalt)
+#endif
+      endif ! end of 'firstcall'
+
+! ------------------------------------------------------
+! I.2   Initializations done at every physical timestep:
+! ------------------------------------------------------
+
+#ifdef CPP_XIOS      
+      ! update XIOS time/calendar
+      call update_xios_timestep
+#endif      
+
+      ! Initialize various variables
+      ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+      
+      if ( .not.nearco2cond ) then
+         pdt(1:ngrid,1:nlayer) = 0.0
+      endif      
+      zdtsurf(1:ngrid)      = 0.0
+      pdq(1:ngrid,1:nlayer,1:nq) = 0.0
+      dqsurf(1:ngrid,1:nq)= 0.0
+      pdu(1:ngrid,1:nlayer) = 0.0
+      pdv(1:ngrid,1:nlayer) = 0.0
+      pdpsrf(1:ngrid)       = 0.0
+      zflubid(1:ngrid)      = 0.0      
+      flux_sens_lat(1:ngrid) = 0.0
+      taux(1:ngrid) = 0.0
+      tauy(1:ngrid) = 0.0
+
+      zday=pday+ptime ! Compute time, in sols (and fraction thereof).
+
+      ! Compute Stellar Longitude (Ls), and orbital parameters.
+      ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+      if (season) then
+         call stellarlong(zday,zls)
+      else
+         call stellarlong(float(day_ini),zls)
+      end if
+
+      call orbite(zls,dist_star,declin,right_ascen)
+      
+      if (tlocked) then
+              zlss=Mod(-(2.*pi*(zday/year_day)*nres - right_ascen),2.*pi)
+      elseif (diurnal) then
+              zlss=-2.*pi*(zday-.5)
+      else if(diurnal .eqv. .false.) then
+              zlss=9999.
+      endif 
+
+
+      ! Compute variations of g with latitude (oblate case).
+      ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+      if (oblate .eqv. .false.) then      
+         glat(:) = g         
+      else if (flatten .eq. 0.0 .or. J2 .eq. 0.0 .or. Rmean .eq. 0.0 .or. MassPlanet .eq. 0.0) then      
+         print*,'I need values for flatten, J2, Rmean and MassPlanet to compute glat (else set oblate=.false.)'
+         call abort
+      else
+         gmplanet = MassPlanet*grav*1e24
+         do ig=1,ngrid
+            glat(ig)= gmplanet/(Rmean**2) * (1.D0 + 0.75 *J2 - 2.0*flatten/3. + (2.*flatten - 15./4.* J2) * cos(2. * (pi/2. - latitude(ig)))) 
+         end do
+      endif
+
+      ! Compute geopotential between layers.
+      ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+      zzlay(1:ngrid,1:nlayer)=pphi(1:ngrid,1:nlayer)
+      do l=1,nlayer         
+         zzlay(1:ngrid,l)= zzlay(1:ngrid,l)/glat(1:ngrid)
+      enddo
+
+      zzlev(1:ngrid,1)=0.
+      zzlev(1:ngrid,nlayer+1)=1.e7 ! Dummy top of last layer above 10000 km...
+
+      do l=2,nlayer
+         do ig=1,ngrid
+            z1=(pplay(ig,l-1)+pplev(ig,l))/(pplay(ig,l-1)-pplev(ig,l))
+            z2=(pplev(ig,l)+pplay(ig,l))/(pplev(ig,l)-pplay(ig,l))
+            zzlev(ig,l)=(z1*zzlay(ig,l-1)+z2*zzlay(ig,l))/(z1+z2)
+         enddo
+      enddo     
+
+      ! Compute potential temperature
+      ! Note : Potential temperature calculation may not be the same in physiq and dynamic...
+      ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+      do l=1,nlayer         
+         do ig=1,ngrid
+            zpopsk(ig,l)=(pplay(ig,l)/pplev(ig,1))**rcp
+            zh(ig,l)=pt(ig,l)/zpopsk(ig,l)
+            mass(ig,l)  = (pplev(ig,l) - pplev(ig,l+1))/glat(ig)
+            massarea(ig,l)=mass(ig,l)*cell_area(ig)
+         enddo
+      enddo
+
+     ! Compute vertical velocity (m/s) from vertical mass flux
+     ! w = F / (rho*area) and rho = P/(r*T)
+     ! But first linearly interpolate mass flux to mid-layers
+      do l=1,nlayer-1
+         pw(1:ngrid,l)=0.5*(flxw(1:ngrid,l)+flxw(1:ngrid,l+1))
+      enddo
+      pw(1:ngrid,nlayer)=0.5*flxw(1:ngrid,nlayer) ! since flxw(nlayer+1)=0
+      do l=1,nlayer
+         pw(1:ngrid,l)=(pw(1:ngrid,l)*r*pt(1:ngrid,l)) /  &
+                       (pplay(1:ngrid,l)*cell_area(1:ngrid))
+      enddo
+
+!---------------------------------
+! II. Compute radiative tendencies
+!---------------------------------
+
+      if (callrad) then
+         if( mod(icount-1,iradia).eq.0.or.lastcall) then
+
+          ! Compute local stellar zenith angles
+          ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+            if (tlocked) then
+            ! JL14 corrects tidally resonant (and inclined) cases. nres=omega_rot/omega_orb
+               ztim1=SIN(declin)
+               ztim2=COS(declin)*COS(zlss)
+               ztim3=COS(declin)*SIN(zlss)
+
+               call stelang(ngrid,sinlon,coslon,sinlat,coslat,    &
+                            ztim1,ztim2,ztim3,mu0,fract, flatten)
+
+            elseif (diurnal) then
+               ztim1=SIN(declin)
+               ztim2=COS(declin)*COS(2.*pi*(zday-.5))
+               ztim3=-COS(declin)*SIN(2.*pi*(zday-.5))
+
+               call stelang(ngrid,sinlon,coslon,sinlat,coslat,    &
+                            ztim1,ztim2,ztim3,mu0,fract, flatten)
+            else if(diurnal .eqv. .false.) then
+
+               call mucorr(ngrid,declin,latitude,mu0,fract,10000.,rad,flatten)
+               ! WARNING: this function appears not to work in 1D
+
+            endif 
+           
+            ! Eclipse incoming sunlight (e.g. Saturn ring shadowing).       
+            if(rings_shadow) then
+                call call_rings(ngrid, ptime, pday, diurnal)
+            endif    
+
+
+            if (corrk) then
+            
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+! II.a Call correlated-k radiative transfer scheme
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+               if(kastprof)then
+                  print*,'kastprof should not = true here'
+                  call abort
+               endif
+               if(water) then
+                  muvar(1:ngrid,1:nlayer)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,1:nlayer,igcm_h2o_vap)) 
+                  muvar(1:ngrid,nlayer+1)=mugaz/(1.e0+(1.e0/epsi-1.e0)*pq(1:ngrid,nlayer,igcm_h2o_vap)) 
+                  ! take into account water effect on mean molecular weight
+               else
+                  muvar(1:ngrid,1:nlayer+1)=mugaz
+               endif 
+      
+
+               if(ok_slab_ocean) then
+                  tsurf2(:)=tsurf(:) 
+                  do ig=1,ngrid
+                     if (nint(rnat(ig))==0) then
+                        tsurf(ig)=((1.-pctsrf_sic(ig))*tslab(ig,1)**4+pctsrf_sic(ig)*tsea_ice(ig)**4)**0.25
+                     endif
+                  enddo
+               endif !(ok_slab_ocean)
+                
+               ! standard callcorrk
+               clearsky=.false.
+               call callcorrk(ngrid,nlayer,pq,nq,qsurf,                           &
+                              albedo,albedo_equivalent,emis,mu0,pplev,pplay,pt,   &
+                              tsurf,fract,dist_star,aerosol,muvar,                &
+                              zdtlw,zdtsw,fluxsurf_lw,fluxsurf_sw,                &
+                              fluxsurfabs_sw,fluxtop_lw,                          &
+                              fluxabs_sw,fluxtop_dn,OLR_nu,OSR_nu,                &
+                              tau_col,cloudfrac,totcloudfrac,                     &
+                              clearsky,firstcall,lastcall)     
+
+                ! Option to call scheme once more for clear regions  
+               if(CLFvarying)then
+
+                  ! ---> PROBLEMS WITH ALLOCATED ARRAYS : temporary solution in callcorrk: do not deallocate if CLFvarying ...
+                  clearsky=.true.
+                  call callcorrk(ngrid,nlayer,pq,nq,qsurf,                           &
+                                 albedo,albedo_equivalent1,emis,mu0,pplev,pplay,pt,   &
+                                 tsurf,fract,dist_star,aerosol,muvar,                &
+                                 zdtlw1,zdtsw1,fluxsurf_lw1,fluxsurf_sw1,            &
+                                 fluxsurfabs_sw1,fluxtop_lw1,                        &
+                                 fluxabs_sw1,fluxtop_dn,OLR_nu1,OSR_nu1,             &
+                                 tau_col1,cloudfrac,totcloudfrac,                    &
+                                 clearsky,firstcall,lastcall)
+                  clearsky = .false.  ! just in case.     
+
+                  ! Sum the fluxes and heating rates from cloudy/clear cases
+                  do ig=1,ngrid
+                     tf=totcloudfrac(ig)
+                     ntf=1.-tf                    
+                     fluxsurf_lw(ig)       = ntf*fluxsurf_lw1(ig)       + tf*fluxsurf_lw(ig)
+                     fluxsurf_sw(ig)       = ntf*fluxsurf_sw1(ig)       + tf*fluxsurf_sw(ig)
+                     albedo_equivalent(ig) = ntf*albedo_equivalent1(ig) + tf*albedo_equivalent(ig)
+                     fluxsurfabs_sw(ig)    = ntf*fluxsurfabs_sw1(ig)    + tf*fluxsurfabs_sw(ig)
+                     fluxtop_lw(ig)        = ntf*fluxtop_lw1(ig)        + tf*fluxtop_lw(ig)
+                     fluxabs_sw(ig)        = ntf*fluxabs_sw1(ig)        + tf*fluxabs_sw(ig)
+                     tau_col(ig)           = ntf*tau_col1(ig)           + tf*tau_col(ig)
+                    
+                     zdtlw(ig,1:nlayer) = ntf*zdtlw1(ig,1:nlayer) + tf*zdtlw(ig,1:nlayer)
+                     zdtsw(ig,1:nlayer) = ntf*zdtsw1(ig,1:nlayer) + tf*zdtsw(ig,1:nlayer)
+
+                     OSR_nu(ig,1:L_NSPECTV) = ntf*OSR_nu1(ig,1:L_NSPECTV) + tf*OSR_nu(ig,1:L_NSPECTV)                       
+                     OLR_nu(ig,1:L_NSPECTI) = ntf*OLR_nu1(ig,1:L_NSPECTI) + tf*OLR_nu(ig,1:L_NSPECTI)                       
+                  enddo                               
+
+               endif ! end of CLFvarying.
+
+               if(ok_slab_ocean) then
+                  tsurf(:)=tsurf2(:)
+               endif
+
+
+               ! Radiative flux from the sky absorbed by the surface (W.m-2).
+               GSR=0.0
+               fluxrad_sky(1:ngrid)=emis(1:ngrid)*fluxsurf_lw(1:ngrid)+fluxsurfabs_sw(1:ngrid)
+
+                            !if(noradsurf)then ! no lower surface; SW flux just disappears
+                            !   GSR = SUM(fluxsurf_sw(1:ngrid)*cell_area(1:ngrid))/totarea
+                            !   fluxrad_sky(1:ngrid)=emis(1:ngrid)*fluxsurf_lw(1:ngrid)
+                            !   print*,'SW lost in deep atmosphere = ',GSR,' W m^-2'
+                            !endif
+
+               ! Net atmospheric radiative heating rate (K.s-1)
+               dtrad(1:ngrid,1:nlayer)=zdtsw(1:ngrid,1:nlayer)+zdtlw(1:ngrid,1:nlayer)
+               
+               ! Late initialization of the Ice Spectral Albedo. We needed the visible bands to do that ! 
+               if (firstcall .and. albedo_spectral_mode) then
+                  call spectral_albedo_calc(albedo_snow_SPECTV)
+               endif
+
+            elseif(newtonian)then
+            
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+! II.b Call Newtonian cooling scheme
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+               call newtrelax(ngrid,nlayer,mu0,sinlat,zpopsk,pt,pplay,pplev,dtrad,firstcall)
+
+               zdtsurf(1:ngrid) = +(pt(1:ngrid,1)-tsurf(1:ngrid))/ptimestep
+               ! e.g. surface becomes proxy for 1st atmospheric layer ?
+
+            else
+            
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+! II.c Atmosphere has no radiative effect 
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+               fluxtop_dn(1:ngrid)  = fract(1:ngrid)*mu0(1:ngrid)*Fat1AU/dist_star**2
+               if(ngrid.eq.1)then ! / by 4 globally in 1D case...
+                  fluxtop_dn(1)  = fract(1)*Fat1AU/dist_star**2/2.0
+               endif
+               fluxsurf_sw(1:ngrid) = fluxtop_dn(1:ngrid)
+               print*,'------------WARNING---WARNING------------' ! by MT2015.
+               print*,'You are in corrk=false mode, '
+               print*,'and the surface albedo is taken equal to the first visible spectral value'               
+               
+               fluxsurfabs_sw(1:ngrid) = fluxtop_dn(1:ngrid)*(1.-albedo(1:ngrid,1))
+               fluxrad_sky(1:ngrid)    = fluxsurfabs_sw(1:ngrid)
+               fluxtop_lw(1:ngrid)  = emis(1:ngrid)*sigma*tsurf(1:ngrid)**4
+
+               dtrad(1:ngrid,1:nlayer)=0.0 ! no atmospheric radiative heating
+
+            endif ! end of corrk
+
+         endif ! of if(mod(icount-1,iradia).eq.0)
+       
+
+         ! Transformation of the radiative tendencies
+         ! ------------------------------------------
+         zplanck(1:ngrid)=tsurf(1:ngrid)*tsurf(1:ngrid)
+         zplanck(1:ngrid)=emis(1:ngrid)*sigma*zplanck(1:ngrid)*zplanck(1:ngrid)
+         fluxrad(1:ngrid)=fluxrad_sky(1:ngrid)-zplanck(1:ngrid)
+         pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+dtrad(1:ngrid,1:nlayer)
+         
+         ! Test of energy conservation
+         !----------------------------
+         if(enertest)then
+            call planetwide_sumval(cpp*massarea(:,:)*zdtsw(:,:)/totarea_planet,dEtotSW)
+            call planetwide_sumval(cpp*massarea(:,:)*zdtlw(:,:)/totarea_planet,dEtotLW)
+            !call planetwide_sumval(fluxsurf_sw(:)*(1.-albedo_equivalent(:))*cell_area(:)/totarea_planet,dEtotsSW) !JL13 carefull, albedo can have changed since the last time we called corrk
+            call planetwide_sumval(fluxsurfabs_sw(:)*cell_area(:)/totarea_planet,dEtotsSW) !JL13 carefull, albedo can have changed since the last time we called corrk
+            call planetwide_sumval((fluxsurf_lw(:)*emis(:)-zplanck(:))*cell_area(:)/totarea_planet,dEtotsLW)
+            dEzRadsw(:,:)=cpp*mass(:,:)*zdtsw(:,:)
+            dEzRadlw(:,:)=cpp*mass(:,:)*zdtlw(:,:)
+            if (is_master) then
+               print*,'---------------------------------------------------------------'
+               print*,'In corrk SW atmospheric heating       =',dEtotSW,' W m-2'
+               print*,'In corrk LW atmospheric heating       =',dEtotLW,' W m-2'
+               print*,'atmospheric net rad heating (SW+LW)   =',dEtotLW+dEtotSW,' W m-2'
+               print*,'In corrk SW surface heating           =',dEtotsSW,' W m-2'
+               print*,'In corrk LW surface heating           =',dEtotsLW,' W m-2'
+               print*,'surface net rad heating (SW+LW)       =',dEtotsLW+dEtotsSW,' W m-2'
+            endif
+         endif ! end of 'enertest'
+
+      endif ! of if (callrad)
+
+
+
+!  --------------------------------------------
+!  III. Vertical diffusion (turbulent mixing) :
+!  --------------------------------------------
+
+      if (calldifv) then
+      
+         zflubid(1:ngrid)=fluxrad(1:ngrid)+fluxgrd(1:ngrid)
+
+         ! JL12 the following if test is temporarily there to allow us to compare the old vdifc with turbdiff.
+         if (UseTurbDiff) then
+         
+            call turbdiff(ngrid,nlayer,nq,rnat,                  &
+                          ptimestep,capcal,lwrite,               &
+                          pplay,pplev,zzlay,zzlev,z0,            &
+                          pu,pv,pt,zpopsk,pq,tsurf,emis,qsurf,   &
+                          pdt,pdq,zflubid,                       &
+                          zdudif,zdvdif,zdtdif,zdtsdif,          &
+                          sensibFlux,q2,zdqdif,zdqevap,zdqsdif,  &
+                          taux,tauy,lastcall)
+
+         else
+         
+            zdh(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer)
+ 
+            call vdifc(ngrid,nlayer,nq,rnat,zpopsk,           &
+                       ptimestep,capcal,lwrite,               &
+                       pplay,pplev,zzlay,zzlev,z0,            &
+                       pu,pv,zh,pq,tsurf,emis,qsurf,          &
+                       zdh,pdq,zflubid,                       &
+                       zdudif,zdvdif,zdhdif,zdtsdif,          &
+                       sensibFlux,q2,zdqdif,zdqsdif,          &
+                       taux,tauy,lastcall)
+
+            zdtdif(1:ngrid,1:nlayer)=zdhdif(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only
+            zdqevap(1:ngrid,1:nlayer)=0.
+
+         end if !end of 'UseTurbDiff'
+
+
+         pdv(1:ngrid,1:nlayer)=pdv(1:ngrid,1:nlayer)+zdvdif(1:ngrid,1:nlayer)
+         pdu(1:ngrid,1:nlayer)=pdu(1:ngrid,1:nlayer)+zdudif(1:ngrid,1:nlayer)
+         pdt(1:ngrid,1:nlayer)=pdt(1:ngrid,1:nlayer)+zdtdif(1:ngrid,1:nlayer)
+         zdtsurf(1:ngrid)=zdtsurf(1:ngrid)+zdtsdif(1:ngrid)
+
+
+         if(ok_slab_ocean)then
+            flux_sens_lat(1:ngrid)=(zdtsdif(1:ngrid)*capcal(1:ngrid)-fluxrad(1:ngrid))
+         endif
+
+
+         if (tracer) then 
+           pdq(1:ngrid,1:nlayer,1:nq)=pdq(1:ngrid,1:nlayer,1:nq)+ zdqdif(1:ngrid,1:nlayer,1:nq)
+           dqsurf(1:ngrid,1:nq)=dqsurf(1:ngrid,1:nq) + zdqsdif(1:ngrid,1:nq)
+         end if ! of if (tracer)
+
+
+         ! test energy conservation
+         !-------------------------
+         if(enertest)then
+         
+            dEzdiff(:,:)=cpp*mass(:,:)*zdtdif(:,:)
+            do ig = 1, ngrid
+               dEdiff(ig)=SUM(dEzdiff (ig,:))+ sensibFlux(ig)! subtract flux to the ground
+               dEzdiff(ig,1)= dEzdiff(ig,1)+ sensibFlux(ig)! subtract flux to the ground
+            enddo
+            
+            call planetwide_sumval(dEdiff(:)*cell_area(:)/totarea_planet,dEtot)
+            dEdiffs(:)=capcal(:)*zdtsdif(:)-zflubid(:)-sensibFlux(:)
+            call planetwide_sumval(dEdiffs(:)*cell_area(:)/totarea_planet,dEtots)
+            call planetwide_sumval(sensibFlux(:)*cell_area(:)/totarea_planet,AtmToSurf_TurbFlux)
+            
+            if (is_master) then
+            
+               if (UseTurbDiff) then
+                         print*,'In TurbDiff sensible flux (atm=>surf) =',AtmToSurf_TurbFlux,' W m-2'
+                         print*,'In TurbDiff non-cons atm nrj change   =',dEtot,' W m-2'
+                  print*,'In TurbDiff (correc rad+latent heat) surf nrj change =',dEtots,' W m-2'
+               else
+                         print*,'In vdifc sensible flux (atm=>surf)    =',AtmToSurf_TurbFlux,' W m-2'
+                         print*,'In vdifc non-cons atm nrj change      =',dEtot,' W m-2'
+                         print*,'In vdifc (correc rad+latent heat) surf nrj change =',dEtots,' W m-2'
+               end if
+            endif ! end of 'is_master'
+            
+         ! JL12 : note that the black body radiative flux emitted by the surface has been updated by the implicit scheme but not given back elsewhere.
+         endif ! end of 'enertest'
+
+
+         ! Test water conservation.
+         if(watertest.and.water)then
+         
+            call planetwide_sumval(massarea(:,:)*zdqdif(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dWtot_tmp)
+            call planetwide_sumval(zdqsdif(:,igcm_h2o_vap)*cell_area(:)*ptimestep/totarea_planet,dWtots_tmp)
+            do ig = 1, ngrid
+               vdifcncons(ig)=SUM(mass(ig,:)*zdqdif(ig,:,igcm_h2o_vap))
+            enddo
+            call planetwide_sumval(massarea(:,:)*zdqdif(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
+            call planetwide_sumval(zdqsdif(:,igcm_h2o_ice)*cell_area(:)*ptimestep/totarea_planet,dWtots)
+            dWtot = dWtot + dWtot_tmp
+            dWtots = dWtots + dWtots_tmp
+            do ig = 1, ngrid
+               vdifcncons(ig)=vdifcncons(ig) + SUM(mass(ig,:)*zdqdif(ig,:,igcm_h2o_ice))
+            enddo            
+            call planetwide_maxval(vdifcncons(:),nconsMAX)
+
+            if (is_master) then
+               print*,'---------------------------------------------------------------'
+               print*,'In difv atmospheric water change        =',dWtot,' kg m-2'
+               print*,'In difv surface water change            =',dWtots,' kg m-2'
+               print*,'In difv non-cons factor                 =',dWtot+dWtots,' kg m-2'
+               print*,'In difv MAX non-cons factor             =',nconsMAX,' kg m-2 s-1'
+            endif
+
+         endif ! end of 'watertest'
+         !-------------------------
+
+      else ! calldifv
+
+         if(.not.newtonian)then
+
+            zdtsurf(1:ngrid) = zdtsurf(1:ngrid) + (fluxrad(1:ngrid) + fluxgrd(1:ngrid))/capcal(1:ngrid)
+
+         endif
+
+      endif ! end of 'calldifv'
+
+
+!----------------------------------
+!   IV. Dry convective adjustment :
+!----------------------------------
+
+      if(calladj) then
+
+         zdh(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)/zpopsk(1:ngrid,1:nlayer)
+         zduadj(1:ngrid,1:nlayer)=0.0
+         zdvadj(1:ngrid,1:nlayer)=0.0
+         zdhadj(1:ngrid,1:nlayer)=0.0
+
+
+         call convadj(ngrid,nlayer,nq,ptimestep,            &
+                      pplay,pplev,zpopsk,                   &
+                      pu,pv,zh,pq,                          &
+                      pdu,pdv,zdh,pdq,                      &
+                      zduadj,zdvadj,zdhadj,                 &
+                      zdqadj)
+
+         pdu(1:ngrid,1:nlayer) = pdu(1:ngrid,1:nlayer) + zduadj(1:ngrid,1:nlayer)
+         pdv(1:ngrid,1:nlayer) = pdv(1:ngrid,1:nlayer) + zdvadj(1:ngrid,1:nlayer)
+         pdt(1:ngrid,1:nlayer)    = pdt(1:ngrid,1:nlayer) + zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer)
+         zdtadj(1:ngrid,1:nlayer) = zdhadj(1:ngrid,1:nlayer)*zpopsk(1:ngrid,1:nlayer) ! for diagnostic only
+
+         if(tracer) then 
+            pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqadj(1:ngrid,1:nlayer,1:nq) 
+         end if
+
+         ! Test energy conservation
+         if(enertest)then
+            call planetwide_sumval(cpp*massarea(:,:)*zdtadj(:,:)/totarea_planet,dEtot)
+            if (is_master) print*,'In convadj atmospheric energy change  =',dEtot,' W m-2'
+         endif
+
+         ! Test water conservation
+         if(watertest)then
+            call planetwide_sumval(massarea(:,:)*zdqadj(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dWtot_tmp)
+            do ig = 1, ngrid
+               cadjncons(ig)=SUM(mass(ig,:)*zdqadj(ig,:,igcm_h2o_vap))
+            enddo
+            call planetwide_sumval(massarea(:,:)*zdqadj(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
+            dWtot = dWtot + dWtot_tmp
+            do ig = 1, ngrid
+               cadjncons(ig)=cadjncons(ig) + SUM(mass(ig,:)*zdqadj(ig,:,igcm_h2o_ice))
+            enddo            
+            call planetwide_maxval(cadjncons(:),nconsMAX)
+
+            if (is_master) then
+               print*,'In convadj atmospheric water change     =',dWtot,' kg m-2'
+               print*,'In convadj MAX non-cons factor          =',nconsMAX,' kg m-2 s-1'
+            endif
+            
+         endif ! end of 'watertest'
+         
+      endif ! end of 'calladj'
+
+!-----------------------------------------------
+!   V. Carbon dioxide condensation-sublimation :
+!-----------------------------------------------
+
+      if (co2cond) then
+      
+         if (.not.tracer) then
+            print*,'We need a CO2 ice tracer to condense CO2'
+            call abort
+         endif
+         call condense_co2(ngrid,nlayer,nq,ptimestep,                    &
+                           capcal,pplay,pplev,tsurf,pt,                  &
+                           pdt,zdtsurf,pq,pdq,                           &
+                           qsurf,zdqsurfc,albedo,emis,                   &
+                           albedo_bareground,albedo_co2_ice_SPECTV,      &
+                           zdtc,zdtsurfc,pdpsrf,zdqc)
+
+         pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+zdtc(1:ngrid,1:nlayer)
+         zdtsurf(1:ngrid)      = zdtsurf(1:ngrid) + zdtsurfc(1:ngrid)
+
+         pdq(1:ngrid,1:nlayer,1:nq)   = pdq(1:ngrid,1:nlayer,1:nq)+ zdqc(1:ngrid,1:nlayer,1:nq)
+         dqsurf(1:ngrid,igcm_co2_ice) = dqsurf(1:ngrid,igcm_co2_ice) + zdqsurfc(1:ngrid)
+
+         ! test energy conservation
+         if(enertest)then
+            call planetwide_sumval(cpp*massarea(:,:)*zdtc(:,:)/totarea_planet,dEtot)
+            call planetwide_sumval(capcal(:)*zdtsurfc(:)*cell_area(:)/totarea_planet,dEtots)
+            if (is_master) then
+               print*,'In co2cloud atmospheric energy change   =',dEtot,' W m-2'
+               print*,'In co2cloud surface energy change       =',dEtots,' W m-2'
+            endif
+         endif
+
+      endif  ! end of 'co2cond'
+
+
+!---------------------------------------------
+!   VI. Specific parameterizations for tracers 
+!---------------------------------------------
+
+      if (tracer) then
+      
+  ! ---------------------
+  !   VI.1. Water and ice
+  ! ---------------------
+         if (water) then
+
+            ! Water ice condensation in the atmosphere
+            if(watercond.and.(RLVTT.gt.1.e-8))then
+
+               dqmoist(1:ngrid,1:nlayer,1:nq)=0.
+               dtmoist(1:ngrid,1:nlayer)=0.
+               
+               ! Moist Convective Adjustment.
+               ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+               call moistadj(ngrid,nlayer,nq,pt,pq,pdq,pplev,pplay,dtmoist,dqmoist,ptimestep,rneb_man)
+
+               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap)     &
+                                                  + dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice)     &
+                                                  + dqmoist(1:ngrid,1:nlayer,igcm_h2o_ice)
+               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtmoist(1:ngrid,1:nlayer)
+
+               ! Test energy conservation.
+               if(enertest)then
+               
+                  call planetwide_sumval(cpp*massarea(:,:)*dtmoist(:,:)/totarea_planet,dEtot)
+                  call planetwide_maxval(dtmoist(:,:),dtmoist_max)
+                  call planetwide_minval(dtmoist(:,:),dtmoist_min)
+                  madjdEz(:,:)=cpp*mass(:,:)*dtmoist(:,:)
+                  do ig=1,ngrid
+                     madjdE(ig) = cpp*SUM(mass(:,:)*dtmoist(:,:))
+                  enddo
+                  
+                  if (is_master) then
+                     print*,'In moistadj atmospheric energy change   =',dEtot,' W m-2'
+                     print*,'In moistadj MAX atmospheric energy change   =',dtmoist_max*ptimestep,'K/step'
+                     print*,'In moistadj MIN atmospheric energy change   =',dtmoist_min*ptimestep,'K/step'
+                  endif
+                  
+                  call planetwide_sumval(massarea(:,:)*dqmoist(:,:,igcm_h2o_vap)*ptimestep/totarea_planet+        &
+                                           massarea(:,:)*dqmoist(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
+                  if (is_master) print*,'In moistadj atmospheric water change    =',dWtot,' kg m-2'
+                  
+               endif ! end of 'enertest'
+               
+
+               ! Large scale condensation/evaporation.
+               ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+               call largescale(ngrid,nlayer,nq,ptimestep,pplev,pplay,pt,pq,pdt,pdq,dtlscale,dqvaplscale,dqcldlscale,rneb_lsc)
+
+               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+dtlscale(1:ngrid,1:nlayer)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap)+dqvaplscale(1:ngrid,1:nlayer)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice)+dqcldlscale(1:ngrid,1:nlayer)
+
+               ! Test energy conservation.
+               if(enertest)then
+                  lscaledEz(:,:) = cpp*mass(:,:)*dtlscale(:,:)
+                  do ig=1,ngrid
+                     lscaledE(ig) = cpp*SUM(mass(:,:)*dtlscale(:,:))
+                  enddo
+                  call planetwide_sumval(cpp*massarea(:,:)*dtlscale(:,:)/totarea_planet,dEtot)
+
+                  if (is_master) print*,'In largescale atmospheric energy change =',dEtot,' W m-2'
+
+                  ! Test water conservation.
+                  call planetwide_sumval(massarea(:,:)*dqvaplscale(:,:)*ptimestep/totarea_planet+        &
+                                           SUM(massarea(:,:)*dqcldlscale(:,:))*ptimestep/totarea_planet,dWtot)
+                        
+                  if (is_master) print*,'In largescale atmospheric water change  =',dWtot,' kg m-2'
+               endif ! end of 'enertest'
+
+               ! Compute cloud fraction.
+               do l = 1, nlayer
+                  do ig=1,ngrid
+                     cloudfrac(ig,l)=MAX(rneb_lsc(ig,l),rneb_man(ig,l)) 
+                  enddo
+               enddo
+
+            endif ! end of 'watercond'
+           
+            ! Water ice / liquid precipitation.
+            ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+            if(waterrain)then
+
+               zdqrain(1:ngrid,1:nlayer,1:nq) = 0.0
+               zdqsrain(1:ngrid)    = 0.0
+               zdqssnow(1:ngrid)    = 0.0
+
+               call rain(ngrid,nlayer,nq,ptimestep,pplev,pplay,pt,pdt,pq,pdq,            &
+                         zdtrain,zdqrain,zdqsrain,zdqssnow,cloudfrac)
+
+               pdq(1:ngrid,1:nlayer,igcm_h2o_vap) = pdq(1:ngrid,1:nlayer,igcm_h2o_vap) &
+                                                  + zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap)
+               pdq(1:ngrid,1:nlayer,igcm_h2o_ice) = pdq(1:ngrid,1:nlayer,igcm_h2o_ice) &
+                                                  + zdqrain(1:ngrid,1:nlayer,igcm_h2o_ice)
+               pdt(1:ngrid,1:nlayer) = pdt(1:ngrid,1:nlayer)+zdtrain(1:ngrid,1:nlayer)
+               
+               dqsurf(1:ngrid,igcm_h2o_vap) = dqsurf(1:ngrid,igcm_h2o_vap)+zdqsrain(1:ngrid)
+               dqsurf(1:ngrid,igcm_h2o_ice) = dqsurf(1:ngrid,igcm_h2o_ice)+zdqssnow(1:ngrid) 
+
+               ! Test energy conservation.
+               if(enertest)then
+               
+                  call planetwide_sumval(cpp*massarea(:,:)*zdtrain(:,:)/totarea_planet,dEtot)
+                  if (is_master) print*,'In rain atmospheric T energy change       =',dEtot,' W m-2'
+                  call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_ice)/totarea_planet*RLVTT/cpp,dItot_tmp)
+                  call planetwide_sumval(cell_area(:)*zdqssnow(:)/totarea_planet*RLVTT/cpp,dItot)
+                  dItot = dItot + dItot_tmp
+                  call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap)*ptimestep/totarea_planet,dVtot_tmp)
+                  call planetwide_sumval(cell_area(:)*zdqsrain(:)/totarea_planet*RLVTT/cpp,dVtot)
+                  dVtot = dVtot + dVtot_tmp
+                  dEtot = dItot + dVtot
+                  
+                  if (is_master) then
+                     print*,'In rain dItot =',dItot,' W m-2'
+                     print*,'In rain dVtot =',dVtot,' W m-2'
+                     print*,'In rain atmospheric L energy change       =',dEtot,' W m-2'
+                  endif
+
+                  ! Test water conservation
+                  call planetwide_sumval(massarea(:,:)*zdqrain(:,:,igcm_h2o_vap)*ptimestep/totarea_planet+        &
+                          massarea(:,:)*zdqrain(:,:,igcm_h2o_ice)*ptimestep/totarea_planet,dWtot)
+                  call planetwide_sumval((zdqsrain(:)+zdqssnow(:))*cell_area(:)*ptimestep/totarea_planet,dWtots)
+                  
+                  if (is_master) then
+                          print*,'In rain atmospheric water change        =',dWtot,' kg m-2'
+                          print*,'In rain surface water change            =',dWtots,' kg m-2'
+                          print*,'In rain non-cons factor                 =',dWtot+dWtots,' kg m-2'
+                  endif
+                  
+               endif ! end of 'enertest'
+
+            end if ! enf of 'waterrain'
+            
+         end if ! end of 'water'
+
+  ! -------------------------
+  !   VI.2. Aerosol particles
+  ! -------------------------
+
+         ! Sedimentation.
+         if (sedimentation) then
+        
+            zdqsed(1:ngrid,1:nlayer,1:nq) = 0.0
+            zdqssed(1:ngrid,1:nq)  = 0.0
+
+            if(watertest)then
+           
+               iq=igcm_h2o_ice
+               call planetwide_sumval(massarea(:,:)*pq(:,:,iq)*ptimestep/totarea_planet,dWtot)
+               call planetwide_sumval(massarea(:,:)*pdq(:,:,iq)*ptimestep/totarea_planet,dWtots)
+               if (is_master) then
+                        print*,'Before sedim pq  =',dWtot,' kg m-2'
+                  print*,'Before sedim pdq =',dWtots,' kg m-2'
+               endif
+            endif
+           
+            call callsedim(ngrid,nlayer,ptimestep,           &
+                          pplev,zzlev,pt,pdt,pq,pdq,        &
+                          zdqsed,zdqssed,nq)
+
+            if(watertest)then
+               iq=igcm_h2o_ice
+               call planetwide_sumval(massarea(:,:)*pq(:,:,iq)*ptimestep/totarea_planet,dWtot)
+               call planetwide_sumval(massarea(:,:)*pdq(:,:,iq)*ptimestep/totarea_planet,dWtots)
+               if (is_master) then
+                        print*,'After sedim pq  =',dWtot,' kg m-2'
+                        print*,'After sedim pdq =',dWtots,' kg m-2'
+                 endif
+            endif
+
+            ! Whether it falls as rain or snow depends only on the surface temperature
+            pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqsed(1:ngrid,1:nlayer,1:nq)
+            dqsurf(1:ngrid,1:nq) = dqsurf(1:ngrid,1:nq) + zdqssed(1:ngrid,1:nq)
+
+            ! Test water conservation
+            if(watertest)then
+               call planetwide_sumval(massarea(:,:)*(zdqsed(:,:,igcm_h2o_vap)+zdqsed(:,:,igcm_h2o_ice))*ptimestep/totarea_planet,dWtot)
+               call planetwide_sumval((zdqssed(:,igcm_h2o_vap)+zdqssed(:,igcm_h2o_ice))*cell_area(:)*ptimestep/totarea_planet,dWtots)
+               if (is_master) then
+                        print*,'In sedim atmospheric ice change         =',dWtot,' kg m-2'
+                        print*,'In sedim surface ice change             =',dWtots,' kg m-2'
+                        print*,'In sedim non-cons factor                =',dWtot+dWtots,' kg m-2'
+               endif
+            endif
+
+         end if ! end of 'sedimentation'
+
+
+  ! ---------------
+  !   VI.3. Updates
+  ! ---------------
+
+         ! Updating Atmospheric Mass and Tracers budgets.
+         if(mass_redistrib) then
+
+            zdmassmr(1:ngrid,1:nlayer) = mass(1:ngrid,1:nlayer) *     &
+               (   zdqevap(1:ngrid,1:nlayer)                          &
+                 + zdqrain(1:ngrid,1:nlayer,igcm_h2o_vap)             &
+                 + dqmoist(1:ngrid,1:nlayer,igcm_h2o_vap)             &
+                 + dqvaplscale(1:ngrid,1:nlayer) )
+
+            do ig = 1, ngrid
+               zdmassmr_col(ig)=SUM(zdmassmr(ig,1:nlayer))
+            enddo
+            
+            call writediagfi(ngrid,"mass_evap","mass gain"," ",3,zdmassmr)
+            call writediagfi(ngrid,"mass_evap_col","mass gain col"," ",2,zdmassmr_col)
+            call writediagfi(ngrid,"mass","mass","kg/m2",3,mass)
+
+            call mass_redistribution(ngrid,nlayer,nq,ptimestep,                     &
+                                     rnat,capcal,pplay,pplev,pt,tsurf,pq,qsurf,     &
+                                     pu,pv,pdt,zdtsurf,pdq,pdu,pdv,zdmassmr,        &
+                                     zdtmr,zdtsurfmr,zdpsrfmr,zdumr,zdvmr,zdqmr,zdqsurfmr)
+         
+            pdq(1:ngrid,1:nlayer,1:nq) = pdq(1:ngrid,1:nlayer,1:nq) + zdqmr(1:ngrid,1:nlayer,1:nq)
+            dqsurf(1:ngrid,1:nq)       = dqsurf(1:ngrid,1:nq) + zdqsurfmr(1:ngrid,1:nq)
+            pdt(1:ngrid,1:nlayer)      = pdt(1:ngrid,1:nlayer) + zdtmr(1:ngrid,1:nlayer)
+            pdu(1:ngrid,1:nlayer)      = pdu(1:ngrid,1:nlayer) + zdumr(1:ngrid,1:nlayer)
+            pdv(1:ngrid,1:nlayer)      = pdv(1:ngrid,1:nlayer) + zdvmr(1:ngrid,1:nlayer)
+            pdpsrf(1:ngrid)            = pdpsrf(1:ngrid) + zdpsrfmr(1:ngrid)
+            zdtsurf(1:ngrid)           = zdtsurf(1:ngrid) + zdtsurfmr(1:ngrid)
+            
+         endif
+
+  ! ------------------
+  !   VI.4. Slab Ocean
+  ! ------------------
+
+         if (ok_slab_ocean)then
+
+            do ig=1,ngrid
+               qsurfint(:,igcm_h2o_ice)=qsurf(:,igcm_h2o_ice)
+            enddo
+
+            call ocean_slab_ice(ptimestep,                          &
+                                ngrid, knindex, tsea_ice, fluxrad,  &
+                                zdqssnow, qsurf(:,igcm_h2o_ice),    &
+                              - zdqsdif(:,igcm_h2o_vap),            &
+                                flux_sens_lat,tsea_ice, pctsrf_sic, &
+                                taux,tauy,icount)
+
+
+            call ocean_slab_get_vars(ngrid,tslab,      &
+                                     sea_ice, flux_o,  &
+                                     flux_g, dt_hdiff, &
+                                     dt_ekman)
+   
+            do ig=1,ngrid
+               if (nint(rnat(ig)).eq.1)then
+                  tslab(ig,1) = 0.
+                  tslab(ig,2) = 0.
+                  tsea_ice(ig) = 0.
+                  sea_ice(ig) = 0.
+                  pctsrf_sic(ig) = 0.
+                  qsurf(ig,igcm_h2o_ice) = qsurfint(ig,igcm_h2o_ice)
+               endif
+            enddo
+
+         endif ! end of 'ok_slab_ocean'
+
+  ! -----------------------------
+  !   VI.5. Surface Tracer Update
+  ! -----------------------------
+
+         if(hydrology)then
+            
+            call hydrol(ngrid,nq,ptimestep,rnat,tsurf,qsurf,dqsurf,dqs_hyd, &
+                        capcal,albedo,albedo_bareground,                    &
+                        albedo_snow_SPECTV,albedo_co2_ice_SPECTV,           &
+                        mu0,zdtsurf,zdtsurf_hyd,hice,pctsrf_sic,            &
+                        sea_ice)
+
+            zdtsurf(1:ngrid)     = zdtsurf(1:ngrid) + zdtsurf_hyd(1:ngrid)
+            dqsurf(1:ngrid,1:nq) = dqsurf(1:ngrid,1:nq) + dqs_hyd(1:ngrid,1:nq)
+            
+            qsurf(1:ngrid,1:nq) = qsurf(1:ngrid,1:nq) + ptimestep*dqsurf(1:ngrid,1:nq)
+
+            ! Test energy conservation
+            if(enertest)then
+               call planetwide_sumval(cell_area(:)*capcal(:)*zdtsurf_hyd(:)/totarea_planet,dEtots)
+               if (is_master) print*,'In hydrol surface energy change     =',dEtots,' W m-2'
+            endif
+
+            ! test water conservation
+            if(watertest)then
+               call planetwide_sumval(dqs_hyd(:,igcm_h2o_ice)*cell_area(:)*ptimestep/totarea_planet,dWtots)
+               if (is_master) print*,'In hydrol surface ice change            =',dWtots,' kg m-2'
+                  call planetwide_sumval(dqs_hyd(:,igcm_h2o_vap)*cell_area(:)*ptimestep/totarea_planet,dWtots)
+               if (is_master) then
+                  print*,'In hydrol surface water change          =',dWtots,' kg m-2'
+                  print*,'---------------------------------------------------------------'
+               endif
+            endif
+
+         else ! of if (hydrology)
+
+            qsurf(1:ngrid,1:nq) = qsurf(1:ngrid,1:nq) + ptimestep*dqsurf(1:ngrid,1:nq)
+
+         end if ! of if (hydrology)
+
+         ! Add qsurf to qsurf_hist, which is what we save in diagfi.nc. At the same time, we set the water 
+         ! content of ocean gridpoints back to zero, in order to avoid rounding errors in vdifc, rain.
+         qsurf_hist(:,:) = qsurf(:,:)
+
+         if(ice_update)then
+            ice_min(1:ngrid)=min(ice_min(1:ngrid),qsurf(1:ngrid,igcm_h2o_ice))
+         endif
+
+      endif! end of if 'tracer'
+
+
+!------------------------------------------------
+!   VII. Surface and sub-surface soil temperature 
+!------------------------------------------------
+
+
+      ! Increment surface temperature
+      if(ok_slab_ocean)then
+         do ig=1,ngrid
+           if (nint(rnat(ig)).eq.0)then
+             zdtsurf(ig)= (tslab(ig,1)              &
+             + pctsrf_sic(ig)*(tsea_ice(ig)-tslab(ig,1))-tsurf(ig))/ptimestep
+           endif
+           tsurf(ig)=tsurf(ig)+ptimestep*zdtsurf(ig)
+         enddo
+   
+      else
+        tsurf(1:ngrid)=tsurf(1:ngrid)+ptimestep*zdtsurf(1:ngrid) 
+      endif ! end of 'ok_slab_ocean'
+
+
+      ! Compute soil temperatures and subsurface heat flux.
+      if (callsoil) then
+         call soil(ngrid,nsoilmx,.false.,lastcall,inertiedat,   &
+                   ptimestep,tsurf,tsoil,capcal,fluxgrd)     
+      endif
+
+
+      if (ok_slab_ocean) then
+      
+         do ig=1,ngrid
+         
+            fluxgrdocean(ig)=fluxgrd(ig)
+            if (nint(rnat(ig)).eq.0) then
+               capcal(ig)=capcalocean
+               fluxgrd(ig)=0.
+               fluxgrdocean(ig)=pctsrf_sic(ig)*flux_g(ig)+(1-pctsrf_sic(ig))*(dt_hdiff(ig,1)+dt_ekman(ig,1))
+               do iq=1,nsoilmx
+                  tsoil(ig,iq)=tsurf(ig)
+               enddo
+               if (pctsrf_sic(ig).gt.0.5) then
+                  capcal(ig)=capcalseaice
+                  if (qsurf(ig,igcm_h2o_ice).gt.0.) then
+                     capcal(ig)=capcalsno
+                  endif
+               endif               
+            endif
+            
+         enddo
+         
+      endif !end of 'ok_slab_ocean'
+
+
+      ! Test energy conservation
+      if(enertest)then
+         call planetwide_sumval(cell_area(:)*capcal(:)*zdtsurf(:)/totarea_planet,dEtots)         
+         if (is_master) print*,'Surface energy change                 =',dEtots,' W m-2'
+      endif
+
+
+!---------------------------------------------------
+!   VIII. Perform diagnostics and write output files
+!---------------------------------------------------
+
+      ! Note : For output only: the actual model integration is performed in the dynamics.
+
+
+ 
+      ! Temperature, zonal and meridional winds.
+      zt(1:ngrid,1:nlayer) = pt(1:ngrid,1:nlayer) + pdt(1:ngrid,1:nlayer)*ptimestep
+      zu(1:ngrid,1:nlayer) = pu(1:ngrid,1:nlayer) + pdu(1:ngrid,1:nlayer)*ptimestep
+      zv(1:ngrid,1:nlayer) = pv(1:ngrid,1:nlayer) + pdv(1:ngrid,1:nlayer)*ptimestep
+
+      ! Diagnostic.
+      zdtdyn(1:ngrid,1:nlayer)     = (pt(1:ngrid,1:nlayer)-ztprevious(1:ngrid,1:nlayer)) / ptimestep
+      ztprevious(1:ngrid,1:nlayer) = zt(1:ngrid,1:nlayer)
+
+      zdudyn(1:ngrid,1:nlayer)     = (pu(1:ngrid,1:nlayer)-zuprevious(1:ngrid,1:nlayer)) / ptimestep
+      zuprevious(1:ngrid,1:nlayer) = zu(1:ngrid,1:nlayer)
+
+      if(firstcall)then
+         zdtdyn(1:ngrid,1:nlayer)=0.0
+         zdudyn(1:ngrid,1:nlayer)=0.0
+      endif
+
+      ! Dynamical heating diagnostic.
+      do ig=1,ngrid
+         fluxdyn(ig)= SUM(zdtdyn(ig,:) *mass(ig,:))*cpp
+      enddo
+
+      ! Tracers.
+      zq(1:ngrid,1:nlayer,1:nq) = pq(1:ngrid,1:nlayer,1:nq) + pdq(1:ngrid,1:nlayer,1:nq)*ptimestep
+
+      ! Surface pressure.
+      ps(1:ngrid) = pplev(1:ngrid,1) + pdpsrf(1:ngrid)*ptimestep
+
+
+
+      ! Surface and soil temperature information
+      call planetwide_sumval(cell_area(:)*tsurf(:)/totarea_planet,Ts1)
+      call planetwide_minval(tsurf(:),Ts2)
+      call planetwide_maxval(tsurf(:),Ts3)
+      if(callsoil)then
+         TsS = SUM(cell_area(:)*tsoil(:,nsoilmx))/totarea        ! mean temperature at bottom soil layer
+         print*,'  ave[Tsurf]     min[Tsurf]     max[Tsurf]     ave[Tdeep]'
+         print*,Ts1,Ts2,Ts3,TsS
+      else
+               if (is_master) then
+            print*,'  ave[Tsurf]     min[Tsurf]     max[Tsurf]'
+            print*,Ts1,Ts2,Ts3
+         endif
+      end if
+
+
+      ! Check the energy balance of the simulation during the run
+      if(corrk)then
+
+         call planetwide_sumval(cell_area(:)*fluxtop_dn(:)/totarea_planet,ISR)
+         call planetwide_sumval(cell_area(:)*fluxabs_sw(:)/totarea_planet,ASR)
+         call planetwide_sumval(cell_area(:)*fluxtop_lw(:)/totarea_planet,OLR)
+         call planetwide_sumval(cell_area(:)*fluxgrd(:)/totarea_planet,GND)
+         call planetwide_sumval(cell_area(:)*fluxdyn(:)/totarea_planet,DYN)
+         do ig=1,ngrid
+            if(fluxtop_dn(ig).lt.0.0)then
+               print*,'fluxtop_dn has gone crazy'
+               print*,'fluxtop_dn=',fluxtop_dn(ig)
+               print*,'tau_col=',tau_col(ig)
+               print*,'aerosol=',aerosol(ig,:,:)
+               print*,'temp=   ',pt(ig,:)
+               print*,'pplay=  ',pplay(ig,:)
+               call abort
+            endif
+         end do
+                     
+         if(ngrid.eq.1)then
+            DYN=0.0
+         endif
+         
+         if (is_master) then
+            print*,'  ISR            ASR            OLR            GND            DYN [W m^-2]'
+            print*, ISR,ASR,OLR,GND,DYN
+         endif
+
+         if(enertest .and. is_master)then
+            print*,'SW flux/heating difference SW++ - ASR = ',dEtotSW+dEtotsSW-ASR,' W m-2'
+            print*,'LW flux/heating difference LW++ - OLR = ',dEtotLW+dEtotsLW+OLR,' W m-2'
+            print*,'LW energy balance LW++ + ASR = ',dEtotLW+dEtotsLW+ASR,' W m-2'
+         endif
+
+         if(meanOLR .and. is_master)then
+            if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then
+               ! to record global radiative balance
+               open(92,file="rad_bal.out",form='formatted',position='append')
+               write(92,*) zday,ISR,ASR,OLR
+               close(92)
+               open(93,file="tem_bal.out",form='formatted',position='append')
+               if(callsoil)then
+                         write(93,*) zday,Ts1,Ts2,Ts3,TsS
+               else
+                  write(93,*) zday,Ts1,Ts2,Ts3
+               endif
+               close(93)
+            endif
+         endif
+
+      endif ! end of 'corrk'
+
+
+      ! Diagnostic to test radiative-convective timescales in code.
+      if(testradtimes)then
+         open(38,file="tau_phys.out",form='formatted',position='append')
+         ig=1
+         do l=1,nlayer
+            write(38,*) -1./pdt(ig,l),pt(ig,l),pplay(ig,l)
+         enddo
+         close(38)
+         print*,'As testradtimes enabled,'
+         print*,'exiting physics on first call'
+         call abort
+      endif
+
+
+      ! Compute column amounts (kg m-2) if tracers are enabled.
+      if(tracer)then
+         qcol(1:ngrid,1:nq)=0.0
+         do iq=1,nq
+            do ig=1,ngrid
+               qcol(ig,iq) = SUM( zq(ig,1:nlayer,iq) * mass(ig,1:nlayer))
+            enddo
+         enddo
+
+         ! Generalised for arbitrary aerosols now. By LK
+         reffcol(1:ngrid,1:naerkind)=0.0
+         if(co2cond.and.(iaero_co2.ne.0))then
+            call co2_reffrad(ngrid,nlayer,nq,zq,reffrad(1,1,iaero_co2))
+            do ig=1,ngrid
+               reffcol(ig,iaero_co2) = SUM(zq(ig,1:nlayer,igcm_co2_ice)*reffrad(ig,1:nlayer,iaero_co2)*mass(ig,1:nlayer))
+            enddo
+         endif
+         if(water.and.(iaero_h2o.ne.0))then
+            call h2o_reffrad(ngrid,nlayer,zq(1,1,igcm_h2o_ice),zt, &
+                             reffrad(1,1,iaero_h2o),nueffrad(1,1,iaero_h2o))
+            do ig=1,ngrid
+               reffcol(ig,iaero_h2o) = SUM(zq(ig,1:nlayer,igcm_h2o_ice)*reffrad(ig,1:nlayer,iaero_h2o)*mass(ig,1:nlayer))
+            enddo
+         endif
+
+      endif ! end of 'tracer'
+
+
+      ! Test for water conservation.
+      if(water)then
+
+         call planetwide_sumval(cell_area(:)*qsurf_hist(:,igcm_h2o_ice)/totarea_planet,icesrf)
+         call planetwide_sumval(cell_area(:)*qsurf_hist(:,igcm_h2o_vap)/totarea_planet,liqsrf)
+         call planetwide_sumval(cell_area(:)*qcol(:,igcm_h2o_ice)/totarea_planet,icecol)
+         call planetwide_sumval(cell_area(:)*qcol(:,igcm_h2o_vap)/totarea_planet,vapcol)
+
+         h2otot = icesrf + liqsrf + icecol + vapcol
+         
+         if (is_master) then
+            print*,' Total water amount [kg m^-2]: ',h2otot
+            print*,' Surface ice    Surface liq.   Atmos. con.     Atmos. vap. [kg m^-2] '
+            print*, icesrf,liqsrf,icecol,vapcol
+         endif
+
+         if(meanOLR .and. is_master)then
+            if((ngrid.gt.1) .or. (mod(icount-1,ecritphy).eq.0))then
+               ! to record global water balance
+               open(98,file="h2o_bal.out",form='formatted',position='append')
+               write(98,*) zday,icesrf,liqsrf,icecol,vapcol
+               close(98)
+            endif
+         endif
+
+      endif
+
+
+      ! Calculate RH (Relative Humidity) for diagnostic.
+      if(water)then
+      
+         do l = 1, nlayer
+            do ig=1,ngrid
+               call Psat_water(zt(ig,l),pplay(ig,l),psat_tmp,qsat(ig,l))
+               RH(ig,l) = zq(ig,l,igcm_h2o_vap) / qsat(ig,l)
+            enddo
+         enddo
+
+         ! Compute maximum possible H2O column amount (100% saturation).
+         do ig=1,ngrid
+            H2Omaxcol(ig) = SUM( qsat(ig,:) * mass(ig,:))
+         enddo
+
+      endif ! end of 'water'
+
+
+      print*,'--> Ls =',zls*180./pi
+      
+      
+!----------------------------------------------------------------------
+!        Writing NetCDF file  "RESTARTFI" at the end of the run
+!----------------------------------------------------------------------
+
+!        Note: 'restartfi' is stored just before dynamics are stored
+!              in 'restart'. Between now and the writting of 'restart',
+!              there will have been the itau=itau+1 instruction and
+!              a reset of 'time' (lastacll = .true. when itau+1= itaufin)
+!              thus we store for time=time+dtvr
+
+
+
+      if(lastcall) then
+         ztime_fin = ptime + ptimestep/(float(iphysiq)*daysec)
+
+         ! Update surface ice distribution to iterate to steady state if requested
+         if(ice_update)then
+
+            do ig=1,ngrid
+
+               delta_ice = (qsurf(ig,igcm_h2o_ice)-ice_initial(ig))
+               
+               ! add multiple years of evolution
+               qsurf_hist(ig,igcm_h2o_ice) = qsurf_hist(ig,igcm_h2o_ice) + delta_ice*icetstep 
+
+               ! if ice has gone -ve, set to zero
+               if(qsurf_hist(ig,igcm_h2o_ice).lt.0.0)then
+                  qsurf_hist(ig,igcm_h2o_ice) = 0.0 
+               endif
+
+               ! if ice is seasonal, set to zero (NEW)
+               if(ice_min(ig).lt.0.01)then
+                  qsurf_hist(ig,igcm_h2o_ice) = 0.0 
+               endif
+
+            enddo
+
+            ! enforce ice conservation
+            ice_tot= SUM(qsurf_hist(:,igcm_h2o_ice)*cell_area(:) )/SUM(cell_area(:))
+            qsurf_hist(:,igcm_h2o_ice) = qsurf_hist(:,igcm_h2o_ice)*(icesrf/ice_tot)
+
+         endif
+
+         if (ngrid.ne.1) then
+            write(*,*)'PHYSIQ: for physdem ztime_fin =',ztime_fin
+            
+            call physdem1("restartfi.nc",nsoilmx,ngrid,nlayer,nq, &
+                          ptimestep,ztime_fin,                    &
+                          tsurf,tsoil,emis,q2,qsurf_hist,         &
+                          cloudfrac,totcloudfrac,hice,            &
+                          rnat,pctsrf_sic,tslab,tsea_ice,sea_ice)
+         endif
+
+         if(ok_slab_ocean) then
+            call ocean_slab_final!(tslab, seaice)
+         end if
+
+         
+      endif ! end of 'lastcall'
+
+
+!-----------------------------------
+!        Saving statistics :
+!-----------------------------------
+
+!    Note :("stats" stores and accumulates 8 key variables in file "stats.nc"
+!           which can later be used to make the statistic files of the run:
+!           "stats")          only possible in 3D runs !!!
+
+         
+      if (callstats) then
+
+         call wstats(ngrid,"ps","Surface pressure","Pa",2,ps)
+         call wstats(ngrid,"tsurf","Surface temperature","K",2,tsurf)
+         call wstats(ngrid,"fluxsurf_lw",                               &
+                     "Thermal IR radiative flux to surface","W.m-2",2,  &
+                     fluxsurf_lw)
+         call wstats(ngrid,"fluxtop_lw",                                &
+                     "Thermal IR radiative flux to space","W.m-2",2,    &
+                     fluxtop_lw)
+                     
+!            call wstats(ngrid,"fluxsurf_sw",                               &
+!                        "Solar radiative flux to surface","W.m-2",2,       &
+!                         fluxsurf_sw_tot)                     
+!            call wstats(ngrid,"fluxtop_sw",                                &
+!                        "Solar radiative flux to space","W.m-2",2,         &
+!                        fluxtop_sw_tot)
+
+
+         call wstats(ngrid,"ISR","incoming stellar rad.","W m-2",2,fluxtop_dn)
+         call wstats(ngrid,"ASR","absorbed stellar rad.","W m-2",2,fluxabs_sw)
+         call wstats(ngrid,"OLR","outgoing longwave rad.","W m-2",2,fluxtop_lw)
+         !call wstats(ngrid,"ALB","Surface albedo"," ",2,albedo_equivalent)
+         !call wstats(ngrid,"ALB_1st","First Band Surface albedo"," ",2,albedo(:,1))
+         call wstats(ngrid,"p","Pressure","Pa",3,pplay)
+         call wstats(ngrid,"temp","Atmospheric temperature","K",3,zt)
+         call wstats(ngrid,"u","Zonal (East-West) wind","m.s-1",3,zu)
+         call wstats(ngrid,"v","Meridional (North-South) wind","m.s-1",3,zv)
+         call wstats(ngrid,"w","Vertical (down-up) wind","m.s-1",3,pw)
+         call wstats(ngrid,"q2","Boundary layer eddy kinetic energy","m2.s-2",3,q2)
+
+         if (tracer) then
+            do iq=1,nq
+               call wstats(ngrid,noms(iq),noms(iq),'kg/kg',3,zq(1,1,iq))
+               call wstats(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  & 
+                           'kg m^-2',2,qsurf(1,iq) )
+               call wstats(ngrid,trim(noms(iq))//'_col',trim(noms(iq))//'_col',    & 
+                          'kg m^-2',2,qcol(1,iq) )
+                          
+!              call wstats(ngrid,trim(noms(iq))//'_reff',                          & 
+!                          trim(noms(iq))//'_reff',                                   & 
+!                          'm',3,reffrad(1,1,iq))
+
+            end do
+            
+            if (water) then
+               vmr=zq(1:ngrid,1:nlayer,igcm_h2o_vap)*mugaz/mmol(igcm_h2o_vap)
+               call wstats(ngrid,"vmr_h2ovapor",                             &
+                           "H2O vapour volume mixing ratio","mol/mol",       & 
+                           3,vmr)
+            endif
+
+         endif ! end of 'tracer' 
+
+         if(watercond.and.CLFvarying)then
+            call wstats(ngrid,"rneb_man","H2O cloud fraction (conv)"," ",3,rneb_man)
+            call wstats(ngrid,"rneb_lsc","H2O cloud fraction (large scale)"," ",3,rneb_lsc)
+            call wstats(ngrid,"CLF","H2O cloud fraction"," ",3,cloudfrac)
+            call wstats(ngrid,"CLFt","H2O column cloud fraction"," ",2,totcloudfrac)
+            call wstats(ngrid,"RH","relative humidity"," ",3,RH)
+         endif
+
+         if (ok_slab_ocean) then
+            call wstats(ngrid,"dt_hdiff1","dt_hdiff1","K/s",2,dt_hdiff(:,1))
+            call wstats(ngrid,"dt_hdiff2","dt_hdiff2","K/s",2,dt_hdiff(:,2))
+            call wstats(ngrid,"dt_ekman1","dt_ekman1","K/s",2,dt_ekman(:,1))
+            call wstats(ngrid,"dt_ekman2","dt_ekman2","K/s",2,dt_ekman(:,2))
+            call wstats(ngrid,"tslab1","tslab1","K",2,tslab(:,1))
+            call wstats(ngrid,"tslab2","tslab2","K",2,tslab(:,2))
+            call wstats(ngrid,"pctsrf_sic","pct ice/sea","",2,pctsrf_sic)
+            call wstats(ngrid,"tsea_ice","tsea_ice","K",2,tsea_ice)
+            call wstats(ngrid,"sea_ice","sea ice","kg/m2",2,sea_ice)
+            call wstats(ngrid,"rnat","nature of the surface","",2,rnat)
+         endif
+
+         if(lastcall) then
+            write (*,*) "Writing stats..."
+            call mkstats(ierr)
+         endif
+         
+      endif ! end of 'callstats'
+
+
+!-----------------------------------------------------------------------------------------------------
+!           OUTPUT in netcdf file "DIAGFI.NC", containing any variable for diagnostic
+!
+!             Note 1 : output with  period "ecritphy", set in "run.def"
+!
+!             Note 2 : writediagfi can also be called from any other subroutine for any variable,
+!                      but its preferable to keep all the calls in one place ...
+!-----------------------------------------------------------------------------------------------------
+
+
+      call writediagfi(ngrid,"Ls","solar longitude","deg",0,zls*180./pi)
+      call writediagfi(ngrid,"Lss","sub solar longitude","deg",0,zlss*180./pi)
+      call writediagfi(ngrid,"RA","right ascension","deg",0,right_ascen*180./pi)
+      call writediagfi(ngrid,"Declin","solar declination","deg",0,declin*180./pi)
+      call writediagfi(ngrid,"tsurf","Surface temperature","K",2,tsurf)
+      call writediagfi(ngrid,"ps","Surface pressure","Pa",2,ps)
+      call writediagfi(ngrid,"temp","temperature","K",3,zt)
+      call writediagfi(ngrid,"teta","potential temperature","K",3,zh)
+      call writediagfi(ngrid,"u","Zonal wind","m.s-1",3,zu)
+      call writediagfi(ngrid,"v","Meridional wind","m.s-1",3,zv)
+      call writediagfi(ngrid,"w","Vertical wind","m.s-1",3,pw)
+      call writediagfi(ngrid,"p","Pressure","Pa",3,pplay)
+
+!     Subsurface temperatures
+!        call writediagsoil(ngrid,"tsurf","Surface temperature","K",2,tsurf)
+!        call writediagsoil(ngrid,"temp","temperature","K",3,tsoil)
+
+      ! Oceanic layers
+      if(ok_slab_ocean) then
+         call writediagfi(ngrid,"pctsrf_sic","pct ice/sea","",2,pctsrf_sic)
+         call writediagfi(ngrid,"tsea_ice","tsea_ice","K",2,tsea_ice)
+         call writediagfi(ngrid,"sea_ice","sea ice","kg/m2",2,sea_ice)
+         call writediagfi(ngrid,"tslab1","tslab1","K",2,tslab(:,1))
+         call writediagfi(ngrid,"tslab2","tslab2","K",2,tslab(:,2))
+         call writediagfi(ngrid,"dt_hdiff1","dt_hdiff1","K/s",2,dt_hdiff(:,1))
+         call writediagfi(ngrid,"dt_hdiff2","dt_hdiff2","K/s",2,dt_hdiff(:,2))
+         call writediagfi(ngrid,"dt_ekman1","dt_ekman1","K/s",2,dt_ekman(:,1))
+         call writediagfi(ngrid,"dt_ekman2","dt_ekman2","K/s",2,dt_ekman(:,2))
+         call writediagfi(ngrid,"rnat","nature of the surface","",2,rnat)
+         call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux)
+         call writediagfi(ngrid,"latentFlux","latent heat flux","w.m^-2",2,zdqsdif(:,igcm_h2o_vap)*RLVTT)
+      endif
+      
+
+      ! Total energy balance diagnostics
+      if(callrad.and.(.not.newtonian))then
+      
+         !call writediagfi(ngrid,"ALB","Surface albedo"," ",2,albedo_equivalent)
+         !call writediagfi(ngrid,"ALB_1st","First Band Surface albedo"," ",2,albedo(:,1))
+         call writediagfi(ngrid,"ISR","incoming stellar rad.","W m-2",2,fluxtop_dn)
+         call writediagfi(ngrid,"ASR","absorbed stellar rad.","W m-2",2,fluxabs_sw)
+         call writediagfi(ngrid,"OLR","outgoing longwave rad.","W m-2",2,fluxtop_lw)
+         call writediagfi(ngrid,"shad","rings"," ", 2, fract)
+         
+!           call writediagfi(ngrid,"ASRcs","absorbed stellar rad (cs).","W m-2",2,fluxabs_sw1)
+!           call writediagfi(ngrid,"OLRcs","outgoing longwave rad (cs).","W m-2",2,fluxtop_lw1)
+!           call writediagfi(ngrid,"fluxsurfsw","sw surface flux.","W m-2",2,fluxsurf_sw)
+!           call writediagfi(ngrid,"fluxsurflw","lw back radiation.","W m-2",2,fluxsurf_lw)
+!           call writediagfi(ngrid,"fluxsurfswcs","sw surface flux (cs).","W m-2",2,fluxsurf_sw1)
+!           call writediagfi(ngrid,"fluxsurflwcs","lw back radiation (cs).","W m-2",2,fluxsurf_lw1)
+
+         if(ok_slab_ocean) then
+            call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrdocean)
+         else
+            call writediagfi(ngrid,"GND","heat flux from ground","W m-2",2,fluxgrd)
+         endif
+         
+         call writediagfi(ngrid,"DYN","dynamical heat input","W m-2",2,fluxdyn)
+         
+      endif ! end of 'callrad'
+        
+      if(enertest) then
+      
+         if (calldifv) then
+         
+            call writediagfi(ngrid,"q2","turbulent kinetic energy","J.kg^-1",3,q2)
+            call writediagfi(ngrid,"sensibFlux","sensible heat flux","w.m^-2",2,sensibFlux)
+            
+!             call writediagfi(ngrid,"dEzdiff","turbulent diffusion heating (-sensible flux)","w.m^-2",3,dEzdiff)
+!             call writediagfi(ngrid,"dEdiff","integrated turbulent diffusion heating (-sensible flux)","w.m^-2",2,dEdiff)
+!             call writediagfi(ngrid,"dEdiffs","In TurbDiff (correc rad+latent heat) surf nrj change","w.m^-2",2,dEdiffs)
+             
+         endif
+          
+         if (corrk) then
+            call writediagfi(ngrid,"dEzradsw","radiative heating","w.m^-2",3,dEzradsw)
+            call writediagfi(ngrid,"dEzradlw","radiative heating","w.m^-2",3,dEzradlw)
+         endif
+          
+         if(watercond) then
+
+            call writediagfi(ngrid,"lscaledE","heat from largescale","W m-2",2,lscaledE) 
+            call writediagfi(ngrid,"madjdE","heat from moistadj","W m-2",2,madjdE)
+            call writediagfi(ngrid,"qsatatm","atm qsat"," ",3,qsat)
+             
+!             call writediagfi(ngrid,"lscaledEz","heat from largescale","W m-2",3,lscaledEz) 
+!             call writediagfi(ngrid,"madjdEz","heat from moistadj","W m-2",3,madjdEz)             
+!             call writediagfi(ngrid,"h2o_max_col","maximum H2O column amount","kg.m^-2",2,H2Omaxcol)
+
+         endif
+          
+      endif ! end of 'enertest'
+
+
+        ! Temporary inclusions for heating diagnostics.
+        !call writediagfi(ngrid,"zdtsw","SW heating","T s-1",3,zdtsw)
+        !call writediagfi(ngrid,"zdtlw","LW heating","T s-1",3,zdtlw)
+        !call writediagfi(ngrid,"dtrad","radiative heating","K s-1",3,dtrad)
+        ! call writediagfi(ngrid,"zdtdyn","Dyn. heating","T s-1",3,zdtdyn)
+        
+        ! For Debugging.
+        !call writediagfi(ngrid,'rnat','Terrain type',' ',2,real(rnat))
+        !call writediagfi(ngrid,'pphi','Geopotential',' ',3,pphi)
+        
+
+      ! Output aerosols.
+      if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) &
+         call writediagfi(ngrid,'CO2ice_reff','CO2ice_reff','m',3,reffrad(1,1,iaero_co2))
+      if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) &
+         call writediagfi(ngrid,'H2Oice_reff','H2Oice_reff','m',3,reffrad(:,:,iaero_h2o))
+      if (igcm_co2_ice.ne.0.and.iaero_co2.ne.0) &
+         call writediagfi(ngrid,'CO2ice_reffcol','CO2ice_reffcol','um kg m^-2',2,reffcol(1,iaero_co2))
+      if (igcm_h2o_ice.ne.0.and.iaero_h2o.ne.0) &
+         call writediagfi(ngrid,'H2Oice_reffcol','H2Oice_reffcol','um kg m^-2',2,reffcol(1,iaero_h2o))
+
+      ! Output tracers.
+      if (tracer) then
+      
+         do iq=1,nq
+            call writediagfi(ngrid,noms(iq),noms(iq),'kg/kg',3,zq(1,1,iq))
+            call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  & 
+                             'kg m^-2',2,qsurf_hist(1,iq) )
+            call writediagfi(ngrid,trim(noms(iq))//'_col',trim(noms(iq))//'_col',    & 
+                            'kg m^-2',2,qcol(1,iq) )
+                          
+!          call writediagfi(ngrid,trim(noms(iq))//'_surf',trim(noms(iq))//'_surf',  & 
+!                          'kg m^-2',2,qsurf(1,iq) )                          
+
+            if(watercond.or.CLFvarying)then
+               call writediagfi(ngrid,"rneb_man","H2O cloud fraction (conv)"," ",3,rneb_man)
+               call writediagfi(ngrid,"rneb_lsc","H2O cloud fraction (large scale)"," ",3,rneb_lsc)
+               call writediagfi(ngrid,"CLF","H2O cloud fraction"," ",3,cloudfrac)
+               call writediagfi(ngrid,"CLFt","H2O column cloud fraction"," ",2,totcloudfrac)
+               call writediagfi(ngrid,"RH","relative humidity"," ",3,RH)
+            endif
+
+            if(waterrain)then
+               call writediagfi(ngrid,"rain","rainfall","kg m-2 s-1",2,zdqsrain)
+               call writediagfi(ngrid,"snow","snowfall","kg m-2 s-1",2,zdqssnow)
+            endif
+
+            if((hydrology).and.(.not.ok_slab_ocean))then
+               call writediagfi(ngrid,"hice","oceanic ice height","m",2,hice)
+            endif
+
+            if(ice_update)then
+               call writediagfi(ngrid,"ice_min","min annual ice","m",2,ice_min)
+               call writediagfi(ngrid,"ice_ini","initial annual ice","m",2,ice_initial)
+            endif
+
+            do ig=1,ngrid
+               if(tau_col(ig).gt.1.e3)then
+                  print*,'WARNING: tau_col=',tau_col(ig)
+                  print*,'at ig=',ig,'in PHYSIQ'
+               endif         
+            end do
+
+            call writediagfi(ngrid,"tau_col","Total aerosol optical depth","[]",2,tau_col)
+
+         enddo ! end of 'nq' loop
+         
+       endif ! end of 'tracer'
+
+
+      ! Output spectrum.
+      if(specOLR.and.corrk)then      
+         call writediagspecIR(ngrid,"OLR3D","OLR(lon,lat,band)","W/m^2/cm^-1",3,OLR_nu)
+         call writediagspecVI(ngrid,"OSR3D","OSR(lon,lat,band)","W/m^2/cm^-1",3,OSR_nu)
+      endif
+
+! XIOS outputs
+#ifdef CPP_XIOS      
+      ! Send fields to XIOS: (NB these fields must also be defined as
+      ! <field id="..." /> in context_lmdz_physics.xml to be correctly used)
+      CALL send_xios_field("ls",zls)
+      
+      CALL send_xios_field("ps",ps)
+      CALL send_xios_field("area",cell_area)
+
+      CALL send_xios_field("temperature",zt)
+      CALL send_xios_field("u",zu)
+      CALL send_xios_field("v",zv)
+      
+#endif
+
+      icount=icount+1
+
+    end subroutine physiq
+    
+    end module physiq_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/planete_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/planete_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/planete_mod.F90	(revision 1644)
@@ -0,0 +1,46 @@
+MODULE planete_mod
+  IMPLICIT NONE
+  
+  REAL,SAVE :: apoastr ! maximum star-planet distance (AU)
+  REAL,SAVE :: periastr ! minimum star-planet distance (AU)
+  REAL,SAVE :: year_day ! length of year (sols)
+  REAL,SAVE :: peri_day ! date of periastron (sols since N. spring)
+  REAL,SAVE :: obliquit ! Obliquity of the planet (deg)
+!$OMP THREADPRIVATE(apoastr,periastr,year_day,peri_day,obliquit)
+  REAL,SAVE :: nres ! tidal resonance ratio
+  REAL,SAVE :: z0 ! surface roughness (m)
+  REAL,SAVE :: lmixmin ! mixing length
+  REAL,SAVE :: emin_turb ! minimal energy
+!$OMP THREADPRIVATE(nres,z0,lmixmin,emin_turb)
+  REAL,SAVE :: coefvis
+  REAL,SAVE :: coefir
+  REAL,SAVE :: timeperi
+  REAL,SAVE :: e_elips
+  REAL,SAVE :: p_elips
+!$OMP THREADPRIVATE(coefvis,coefir,timeperi,e_elips,p_elips)
+  
+  REAL,SAVE :: preff ! reference surface pressure (Pa)	!read by master
+  REAL,SAVE,ALLOCATABLE :: ap(:) ! hybrid coordinate at layer interface	!read by master
+  REAL,SAVE,ALLOCATABLE :: bp(:) ! hybrid coordinate at layer interface 	!read by master
+!$OMP THREADPRIVATE(preff,ap,bp)
+
+  CONTAINS
+  
+  subroutine ini_planete_mod(nlayer,preff_dyn,ap_dyn,bp_dyn)
+  
+  implicit none
+  integer,intent(in) :: nlayer ! number of atmospheric layers
+  real,intent(in) :: preff_dyn ! reference surface pressure (Pa)
+  real,intent(in) :: ap_dyn(nlayer+1) ! hybrid coordinate at interfaces
+  real,intent(in) :: bp_dyn(nlayer+1) ! hybrid coordinate at interfaces
+  
+  allocate(ap(nlayer+1))
+  allocate(bp(nlayer+1))
+  
+  preff=preff_dyn
+  ap(:)=ap_dyn(:)
+  bp(:)=bp_dyn(:)
+  
+  end subroutine ini_planete_mod
+  
+END MODULE planete_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/planetwide_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/planetwide_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/planetwide_mod.F90	(revision 1644)
@@ -0,0 +1,298 @@
+!
+! $Id: $
+!
+module planetwide_mod
+! module which contains functions to obtain max/min/... values over the
+! entire globe (trivial in serial mode, but not in parallel)
+
+use mod_phys_lmdz_para, only : is_master, gather, bcast
+                               
+implicit none
+
+interface planetwide_maxval ! maxval() , over the entire planet
+  module procedure planetwide_maxval_i1, planetwide_maxval_i2, &
+                   planetwide_maxval_r1, planetwide_maxval_r2
+end interface
+
+interface planetwide_minval ! minval() , over the entire planet
+  module procedure planetwide_minval_i1, planetwide_minval_i2, &
+                   planetwide_minval_r1, planetwide_minval_r2
+end interface
+
+interface planetwide_sumval ! sum() , over the entire planet
+  module procedure planetwide_sumval_i1, planetwide_sumval_i2, &
+                   planetwide_sumval_r1, planetwide_sumval_r2
+end interface
+
+contains
+
+  subroutine planetwide_maxval_i1(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  integer,intent(in) :: values(:) ! local grid (klon)
+  integer,intent(out) :: values_max
+#ifdef CPP_PARA
+  integer :: values_glo(klon_glo) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=maxval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=maxval(values)
+#endif
+  end subroutine planetwide_maxval_i1
+
+  subroutine planetwide_maxval_i2(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  integer,intent(in) :: values(:,:) ! local grid (klon,...)
+  integer,intent(out) :: values_max
+#ifdef CPP_PARA
+  integer :: values_glo(klon_glo,size(values,2)) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=maxval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=maxval(values)
+#endif
+  end subroutine planetwide_maxval_i2
+
+  subroutine planetwide_maxval_r1(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  real,intent(in) :: values(:) ! local grid (klon)
+  real,intent(out) :: values_max
+#ifdef CPP_PARA
+  real :: values_glo(klon_glo) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=maxval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=maxval(values)
+#endif
+  end subroutine planetwide_maxval_r1
+
+  subroutine planetwide_maxval_r2(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  real,intent(in) :: values(:,:) ! local grid (klon,...)
+  real,intent(out) :: values_max
+#ifdef CPP_PARA
+  real :: values_glo(klon_glo,size(values,2)) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=maxval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=maxval(values)
+#endif
+  end subroutine planetwide_maxval_r2
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  subroutine planetwide_minval_i1(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  integer,intent(in) :: values(:) ! local grid (klon)
+  integer,intent(out) :: values_max
+#ifdef CPP_PARA
+  integer :: values_glo(klon_glo) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=minval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=minval(values)
+#endif
+  end subroutine planetwide_minval_i1
+
+  subroutine planetwide_minval_i2(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  integer,intent(in) :: values(:,:) ! local grid (klon,...)
+  integer,intent(out) :: values_max
+#ifdef CPP_PARA
+  integer :: values_glo(klon_glo,size(values,2)) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=minval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=minval(values)
+#endif
+  end subroutine planetwide_minval_i2
+
+  subroutine planetwide_minval_r1(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  real,intent(in) :: values(:) ! local grid (klon)
+  real,intent(out) :: values_max
+#ifdef CPP_PARA
+  real :: values_glo(klon_glo) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=minval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=minval(values)
+#endif
+  end subroutine planetwide_minval_r1
+
+  subroutine planetwide_minval_r2(values,values_max)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  real,intent(in) :: values(:,:) ! local grid (klon,...)
+  real,intent(out) :: values_max
+#ifdef CPP_PARA
+  real :: values_glo(klon_glo,size(values,2)) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! extract maximum value
+  if (is_master) then
+    values_max=minval(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_max)
+#else
+  values_max=minval(values)
+#endif
+  end subroutine planetwide_minval_r2
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  subroutine planetwide_sumval_i1(values,values_sum)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  integer,intent(in) :: values(:) ! local grid (klon)
+  integer,intent(out) :: values_sum
+#ifdef CPP_PARA
+  integer :: values_glo(klon_glo) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! calculate sum value
+  if (is_master) then
+    values_sum=SUM(values_glo(:))
+  endif
+  ! broadcast information to all cores
+  call bcast(values_sum)
+#else
+  values_sum=SUM(values(:))
+#endif
+  end subroutine planetwide_sumval_i1
+
+  subroutine planetwide_sumval_i2(values,values_sum)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  integer,intent(in) :: values(:,:) ! local grid (klon,...)
+  integer,intent(out) :: values_sum
+#ifdef CPP_PARA
+  integer :: values_glo(klon_glo,size(values,2)) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! calculate sum value
+  if (is_master) then
+    values_sum=SUM(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_sum)
+#else
+  values_sum=SUM(values)
+#endif
+  end subroutine planetwide_sumval_i2
+
+  subroutine planetwide_sumval_r1(values,values_sum)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  real,intent(in) :: values(:) ! local grid (klon)
+  real,intent(out) :: values_sum
+#ifdef CPP_PARA
+  real :: values_glo(klon_glo) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! calculate sum value
+  if (is_master) then
+    values_sum=SUM(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_sum)
+#else
+  values_sum=SUM(values)
+#endif
+  end subroutine planetwide_sumval_r1
+
+  subroutine planetwide_sumval_r2(values,values_sum)
+  use dimphy, only: klon
+  use mod_grid_phy_lmdz, only : klon_glo
+  implicit none
+  real,intent(in) :: values(:,:) ! local grid (klon,...)
+  real,intent(out) :: values_sum
+#ifdef CPP_PARA
+  real :: values_glo(klon_glo,size(values,2)) ! global grid
+  
+  ! gather field on master:
+  call gather(values,values_glo)
+  ! calculate sum value
+  if (is_master) then
+    values_sum=SUM(values_glo)
+  endif
+  ! broadcast information to all cores
+  call bcast(values_sum)
+#else
+  values_sum=SUM(values)
+#endif
+  end subroutine planetwide_sumval_r2
+  
+  
+end module planetwide_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/profile.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/profile.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/profile.F	(revision 1644)
@@ -0,0 +1,226 @@
+      SUBROUTINE profile(nlev,zkm,temp)
+! to use  'getin'
+      USE ioipsl_getincom 
+      IMPLICIT NONE
+c=======================================================================
+c     Subroutine utilisee dans "rcm1d"
+c     pour l'initialisation du profil atmospherique
+c=======================================================================
+c
+c   differents profils d'atmospheres. T=f(z)
+c   entree:
+c     nlev    nombre de niveaux
+c     zkm     alititudes en km
+c     ichoice choix de l'atmosphere:
+c             1 Temperature constante
+c             2 profil Savidjari
+c             3 Lindner (profil polaire)
+c             4 Inversion pour Francois
+c             5 Seiff (moyen)
+c             6 T constante + perturbation gauss (level) (christophe 10/98)
+c             7 T constante + perturbation gauss   (km)  (christophe 10/98)
+c             8 Lecture du profile dans un fichier ASCII (profile)
+c     tref    temperature de reference
+c     isin    ajout d'une perturbation (isin=1)
+c     pic     pic perturbation gauss pour ichoice = 6 ou 7
+c     largeur largeur de la perturbation gauss pour ichoice = 6 ou 7
+c     hauteur hauteur de la perturbation gauss pour ichoice = 6 ou 7
+c
+c   sortie:
+c     temp    temperatures en K
+c     
+c=======================================================================
+c-----------------------------------------------------------------------
+c   declarations:
+c   -------------
+
+c   arguments:
+c   ----------
+
+       INTEGER nlev, unit
+       REAL zkm(nlev),temp(nlev)
+
+c   local:
+c   ------
+
+      INTEGER il,ichoice,nseiff,iseiff,isin,iter
+      REAL pi
+      PARAMETER(nseiff=37)
+      REAL tref,t1,t2,t3,ww
+      REAL tseiff(nseiff)
+      DATA tseiff/214.,213.8,213.4,212.4,209.3,205.,201.4,197.8,
+     $           194.6,191.4,188.2,185.2,182.5,180.,177.5,175,
+     $           172.5,170.,167.5,164.8,162.4,160.,158.,156.,
+     $           154.1,152.2,150.3,148.7,147.2,145.7,144.2,143.,
+     $           142.,141.,140,139.5,139./
+      REAL pic,largeur
+      REAL hauteur,tmp
+
+c-----------------------------------------------------------------------
+c   read input profile type:
+c--------------------------
+
+      ichoice=1 ! default value for ichoice
+      call getin("ichoice",ichoice)
+      tref=200 ! default value for tref
+      call getin("tref",tref)
+      isin=0 ! default value for isin (=0 means no perturbation)
+      call getin("isin",isin)
+      pic=26.522 ! default value for pic
+      call getin("pic",pic)
+      largeur=10 ! default value for largeur
+      call getin("largeur",largeur)
+      hauteur=30 ! default value for hauteur
+      call getin("hauteur",hauteur)
+
+c-----------------------------------------------------------------------
+c   ichoice=1 temperature constante:
+c   --------------------------------
+
+      IF(ichoice.EQ.1) THEN
+         DO il=1,nlev
+            temp(il)=tref
+         ENDDO
+
+c-----------------------------------------------------------------------
+c   ichoice=2 savidjari:
+c   --------------------
+
+      ELSE IF(ichoice.EQ.2) THEN
+         DO il=1,nlev
+            temp(il)=AMAX1(219.-2.5*zkm(il),140.)
+         ENDDO
+
+c-----------------------------------------------------------------------
+c   ichoice=3 Lindner:
+c   ------------------
+
+      ELSE IF(ichoice.EQ.3) THEN
+         DO il=1,nlev
+            IF(zkm(il).LT.2.5) THEN
+               temp(il)=150.+30.*zkm(il)/2.5
+            ELSE IF(zkm(il).LT.5.) THEN
+               temp(il)=180.
+            ELSE
+               temp(il)=AMAX1(180.-2.*(zkm(il)-5.),130.)
+            ENDIF
+         ENDDO
+
+c-----------------------------------------------------------------------
+c   ichoice=4 Inversion pour Francois:
+c   ------------------
+
+      ELSE IF(ichoice.EQ.4) THEN
+         DO il=1,nlev
+            IF(zkm(il).LT.20.) THEN
+               temp(il)=135.
+            ELSE
+               temp(il)=AMIN1(135.+5.*(zkm(il)-20.),200.)
+            ENDIF
+         ENDDO
+
+
+c-----------------------------------------------------------------------
+c   ichoice=5 Seiff:
+c   ----------------
+
+      ELSE IF(ichoice.EQ.5) THEN
+	 DO il=1,nlev
+	    iseiff=INT(zkm(il)/2.)+1
+	    IF(iseiff.LT.nseiff-1) THEN
+	       temp(il)=tseiff(iseiff)+(zkm(il)-2.*(iseiff-1))*
+     $         (tseiff(iseiff+1)-tseiff(iseiff))/2.
+	    ELSE
+	       temp(il)=tseiff(nseiff)
+	    ENDIF
+	 ENDDO
+c IF(ichoice.EQ.6) THEN
+c	    DO iter=1,6
+c	    t2=temp(1)
+c	    t3=temp(2)
+c	    DO il=2,nlev-1
+c	       t1=t2
+c	       t2=t3
+c	       t3=temp(il+1)
+c	       ww=tanh(zkm(il)/20.)
+c	       ww=ww*ww*ww
+c	       temp(il)=t2+ww*.5*(t1-2.*t2+t3)
+c	    ENDDO
+c	    ENDDO
+c	 ENDIF
+
+c-----------------------------------------------------------------------
+c   ichoice=6 
+c   ---------
+
+      ELSE IF(ichoice.EQ.6) THEN
+      DO il=1,nlev
+        tmp=il-pic
+        temp(il)=tref + hauteur*exp(-tmp*tmp/largeur/largeur)
+      ENDDO
+
+
+c-----------------------------------------------------------------------
+c   ichoice=7
+c   ---------
+
+      ELSE IF(ichoice.EQ.7) THEN
+      DO il=1,nlev
+        tmp=zkm(il)-pic
+        temp(il)=tref + hauteur*exp(-tmp*tmp*4/largeur/largeur)
+      ENDDO
+
+c-----------------------------------------------------------------------
+c   ichoice=8
+c   ---------
+
+      ! first value is surface temperature
+      ! then profile of atmospheric temperature
+      ELSE IF(ichoice.GE.8) THEN
+      OPEN(11,file='profile',status='old',form='formatted',err=101)
+      DO il=1,nlev
+        READ (11,*) temp(il)
+      ENDDO
+
+      GOTO 201
+101   STOP'fichier profile inexistant'
+201   CONTINUE
+      CLOSE(10)
+
+c-----------------------------------------------------------------------
+
+      ENDIF
+
+c-----------------------------------------------------------------------
+c   rajout eventuel d'une perturbation:
+c   -----------------------------------
+
+      IF(isin.EQ.1) THEN
+	 pi=2.*ASIN(1.)
+	 DO il=1,nlev
+c       if (nlev.EQ.501) then
+c         if (zkm(il).LE.70.5) then
+c       temp(il)=temp(il)+(1.-1000./(1000+zkm(il)*zkm(il)))*(
+c    s      6.*SIN(zkm(il)*pi/6.)+9.*SIN(zkm(il)*pi/10.3) )
+c         endif
+c       else
+        temp(il)=temp(il)+(1.-1000./(1000+zkm(il)*zkm(il)))*(
+     s      6.*SIN(zkm(il)*pi/6.)+9.*SIN(zkm(il)*pi/10.3) )
+c       endif
+	 ENDDO
+      ENDIF
+
+
+c-----------------------------------------------------------------------
+c   Ecriture du profil de temperature dans un fichier profile.out
+c   -------------------------------------------------------------
+
+
+      OPEN(12,file='profile.out',form='formatted')
+	  DO il=1,nlev
+	    write(12,*) temp(il)
+	  ENDDO
+      CLOSE(12)
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/radcommon_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/radcommon_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/radcommon_h.F90	(revision 1644)
@@ -0,0 +1,168 @@
+module radcommon_h
+      use radinc_h, only: L_NSPECTI, L_NSPECTV, L_NGAUSS, NTstar, NTstop, &
+                          naerkind, nsizemax
+      implicit none
+
+!----------------------------------------------------------------------C
+!
+!                             radcommon.h
+!
+!----------------------------------------------------------------------C
+!
+!  "Include" grid.h and radinc.h before this file in code that uses
+!  some or all of this common data set
+!
+!     WNOI       - Array of wavenumbers at the spectral interval
+!                  centers for the infrared.  Array is NSPECTI
+!                  elements long.
+!     DWNI       - Array of "delta wavenumber", i.e., the width,
+!                  in wavenumbers (cm^-1) of each IR spectral
+!                  interval.  NSPECTI elements long.
+!     WAVEI      - Array (NSPECTI elements long) of the wavelenght
+!                  (in microns) at the center of each IR spectral
+!                  interval.
+!     WNOV       - Array of wavenumbers at the spectral interval
+!                  center for the VISUAL.  Array is NSPECTV
+!                  elements long.
+!     DWNV       - Array of "delta wavenumber", i.e., the width,
+!                  in wavenumbers (cm^-1) of each VISUAL spectral
+!                  interval.  NSPECTV elements long.
+!     WAVEV      - Array (NSPECTV elements long) of the wavelenght
+!                  (in microns) at the center of each VISUAL spectral
+!                  interval.
+!     STELLARF   - Array (NSPECTV elements) of stellar flux (W/M^2) in
+!                  each spectral interval.  Values are for 1 AU,
+!                  scaled to the planetary distance elsewhere.
+!     TAURAY     - Array (NSPECTV elements) of the pressure-independent
+!                  part of Rayleigh scattering optical depth.
+!     TAURAYVAR  - Array (NSPECTV elements) of the pressure-independent
+!                  part of Rayleigh scattering optical depth for the variable gas.
+!     FZEROI     - Fraction of zeros in the IR CO2 k-coefficients, for
+!                  each temperature, pressure, and spectral interval
+!     FZEROV     - Fraction of zeros in the VISUAL CO2 k-coefficients, for
+!                  each temperature, pressure, and spectral interval
+!
+!     AEROSOL RADIATIVE OPTICAL CONSTANTS
+! 
+!   Shortwave
+!   ~~~~~~~~~
+! 
+! For the "naerkind" kind of aerosol radiative properties : 
+! QVISsQREF  :  Qext / Qext("longrefvis")
+! omegavis   :  single scattering albedo
+! gvis       :  assymetry factor
+! 
+!   Longwave
+!   ~~~~~~~~
+! 
+! For the "naerkind" kind of aerosol radiative properties : 
+! QIRsQREF :  Qext / Qext("longrefvis")
+! omegaIR  :  mean single scattering albedo
+! gIR      :  mean assymetry factor
+
+      REAL*8 BWNI(L_NSPECTI+1), WNOI(L_NSPECTI), DWNI(L_NSPECTI), WAVEI(L_NSPECTI) !BWNI read by master in setspi
+      REAL*8 BWNV(L_NSPECTV+1), WNOV(L_NSPECTV), DWNV(L_NSPECTV), WAVEV(L_NSPECTV) !BWNV read by master in setspv
+      REAL*8 STELLARF(L_NSPECTV), TAURAY(L_NSPECTV), TAURAYVAR(L_NSPECTV)
+!$OMP THREADPRIVATE(WNOI,DWNI,WAVEI,&
+	!$OMP WNOV,DWNV,WAVEV,&
+	!$OMP STELLARF,TAURAY,TAURAYVAR)
+
+      REAL*8 blami(L_NSPECTI+1)
+      REAL*8 blamv(L_NSPECTV+1) ! these are needed by suaer.F90
+!$OMP THREADPRIVATE(blami,blamv)
+
+      !! AS: introduced to avoid doing same computations again for continuum
+      INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: indi
+      INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: indv
+!$OMP THREADPRIVATE(indi,indv)
+
+      !!! ALLOCATABLE STUFF SO THAT DIMENSIONS ARE READ in *.dat FILES -- AS 12/2011  
+      REAL*8, DIMENSION(:,:,:,:,:), ALLOCATABLE :: gasi, gasv
+      REAL*8, DIMENSION(:), ALLOCATABLE :: PGASREF, TGASREF, WREFVAR, PFGASREF
+      real*8 FZEROI(L_NSPECTI)
+      real*8 FZEROV(L_NSPECTV)
+      real*8 pgasmin, pgasmax
+      real*8 tgasmin, tgasmax
+!$OMP THREADPRIVATE(gasi,gasv,&  !wrefvar,pgasref,tgasref,pfgasref read by master in sugas_corrk
+	!$OMP FZEROI,FZEROV)     !pgasmin,pgasmax,tgasmin,tgasmax read by master in sugas_corrk
+
+      real QVISsQREF(L_NSPECTV,naerkind,nsizemax)
+      real omegavis(L_NSPECTV,naerkind,nsizemax)
+      real gvis(L_NSPECTV,naerkind,nsizemax)
+      real QIRsQREF(L_NSPECTI,naerkind,nsizemax)
+      real omegair(L_NSPECTI,naerkind,nsizemax)
+      real gir(L_NSPECTI,naerkind,nsizemax)
+!$OMP THREADPRIVATE(QVISsQREF,omegavis,gvis,QIRsQREF,omegair,gir)
+
+
+! Reference wavelengths used to compute reference optical depth (m)
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+      REAL lamrefir(naerkind),lamrefvis(naerkind)
+
+! Actual number of grain size classes in each domain for a
+!   given aerosol:
+
+      INTEGER          :: nsize(naerkind,2)
+
+! Particle size axis (depend on the kind of aerosol and the
+!   radiation domain)
+
+      DOUBLE PRECISION :: radiustab(naerkind,2,nsizemax)
+!$OMP THREADPRIVATE(lamrefir,lamrefvis,radiustab) !nsize read by suaer_corrk
+
+! Extinction coefficient at reference wavelengths;
+!   These wavelengths are defined in aeroptproperties, and called
+!   longrefvis and longrefir.
+
+      REAL :: QREFvis(naerkind,nsizemax)
+      REAL :: QREFir(naerkind,nsizemax)
+      REAL :: omegaREFvis(naerkind,nsizemax)
+      REAL :: omegaREFir(naerkind,nsizemax)
+
+      REAL,SAVE :: tstellar ! Stellar brightness temperature (SW)
+
+      real*8,save :: planckir(L_NSPECTI,NTstop-NTstar+1)
+
+      real*8,save :: PTOP
+      real*8,save,allocatable :: TAUREF(:)
+
+      real*8,parameter :: UBARI = 0.5D0
+
+      real*8,save :: gweight(L_NGAUSS)
+!$OMP THREADPRIVATE(QREFvis,QREFir,omegaREFvis,omegaREFir,& 	! gweight read by master in sugas_corrk
+		!$OMP tstellar,planckir,PTOP,TAUREF)
+
+!     If the gas optical depth (top to the surface) is less than
+!     this value, we place that Gauss-point into the "zeros"
+!     channel.
+      real*8, parameter :: TLIMIT =  1.0D-30
+
+!     Factor to convert pressures from millibars to Pascals
+      real*8, parameter :: SCALEP = 1.00D+2
+
+      real*8, parameter :: sigma = 5.67032D-8
+      real*8, parameter :: grav = 6.672E-11
+
+      real*8,save :: Cmk
+      real*8,save :: glat_ig
+!$OMP THREADPRIVATE(Cmk,glat_ig)
+
+      ! extinction of incoming sunlight (Saturn's rings, eclipses, etc...)
+      REAL, DIMENSION(:), ALLOCATABLE ,SAVE :: eclipse
+
+      !Latitude-dependent gravity
+      REAL, DIMENSION(:), ALLOCATABLE , SAVE :: glat
+!$OMP THREADPRIVATE(glat,eclipse)
+
+contains
+
+      subroutine ini_radcommon_h
+      use radinc_h, only: L_LEVELS
+      implicit none
+      
+        allocate(TAUREF(L_LEVELS+1))
+      
+      end subroutine ini_radcommon_h
+
+end module radcommon_h
Index: /trunk/LMDZ.TITAN/libf/phytitan/radii_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/radii_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/radii_mod.F90	(revision 1644)
@@ -0,0 +1,367 @@
+!==================================================================
+module radii_mod
+!==================================================================
+!  module to centralize the radii calculations for aerosols
+! OK for water but should be extended to other aerosols (CO2,...)
+!==================================================================
+      
+!     water cloud optical properties
+
+      use callkeys_mod, only: radfixed,Nmix_co2,                    &
+                pres_bottom_tropo,pres_top_tropo,size_tropo,        &
+                pres_bottom_strato,size_strato
+      
+      real, save ::  rad_h2o
+      real, save ::  rad_h2o_ice
+      real, save ::  Nmix_h2o
+      real, save ::  Nmix_h2o_ice
+!$OMP THREADPRIVATE(rad_h2o,rad_h2o_ice,Nmix_h2o,Nmix_h2o_ice)
+      real, parameter ::  coef_chaud=0.13
+      real, parameter ::  coef_froid=0.09
+
+
+contains
+
+
+!==================================================================
+   subroutine su_aer_radii(ngrid,nlayer,reffrad,nueffrad)
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the effective radii of liquid and icy water particles
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+      use ioipsl_getin_p_mod, only: getin_p
+      use radinc_h, only: naerkind
+      use aerosol_mod, only: iaero_back2lay, iaero_co2, iaero_dust, &
+                             iaero_h2o, iaero_h2so4
+      Implicit none
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(out) :: reffrad(ngrid,nlayer,naerkind)      !aerosols radii (K)
+      real, intent(out) :: nueffrad(ngrid,nlayer,naerkind)     !variance     
+
+      logical, save :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+      integer :: iaer   
+      
+      print*,'enter su_aer_radii'
+          do iaer=1,naerkind
+!     these values will change once the microphysics gets to work
+!     UNLESS tracer=.false., in which case we should be working with
+!     a fixed aerosol layer, and be able to define reffrad in a 
+!     .def file. To be improved!
+
+            if(iaer.eq.iaero_co2)then ! CO2 ice
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-4
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
+            endif
+
+            if(iaer.eq.iaero_h2o)then ! H2O ice
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-5
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
+            endif
+
+            if(iaer.eq.iaero_dust)then ! dust
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-5
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
+            endif
+ 
+            if(iaer.eq.iaero_h2so4)then ! H2O ice
+               reffrad(1:ngrid,1:nlayer,iaer) = 1.e-6
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
+            endif
+            
+            if(iaer.eq.iaero_back2lay)then ! Two-layer aerosols
+               reffrad(1:ngrid,1:nlayer,iaer) = 2.e-6
+               nueffrad(1:ngrid,1:nlayer,iaer) = 0.1 
+            endif
+
+
+
+            if(iaer.gt.5)then
+               print*,'Error in callcorrk, naerkind is too high (>5).'
+               print*,'The code still needs generalisation to arbitrary'
+               print*,'aerosol kinds and number.'
+               call abort
+            endif
+
+         enddo
+
+
+         if (radfixed) then
+
+            write(*,*)"radius of H2O water particles:"
+            rad_h2o=13. ! default value
+            call getin_p("rad_h2o",rad_h2o)
+            write(*,*)" rad_h2o = ",rad_h2o
+
+            write(*,*)"radius of H2O ice particles:"
+            rad_h2o_ice=35. ! default value
+            call getin_p("rad_h2o_ice",rad_h2o_ice)
+            write(*,*)" rad_h2o_ice = ",rad_h2o_ice
+
+         else
+
+            write(*,*)"Number mixing ratio of H2O water particles:"
+            Nmix_h2o=1.e6 ! default value
+            call getin_p("Nmix_h2o",Nmix_h2o)
+            write(*,*)" Nmix_h2o = ",Nmix_h2o
+
+            write(*,*)"Number mixing ratio of H2O ice particles:"
+            Nmix_h2o_ice=Nmix_h2o ! default value
+            call getin_p("Nmix_h2o_ice",Nmix_h2o_ice)
+            write(*,*)" Nmix_h2o_ice = ",Nmix_h2o_ice
+         endif
+
+      print*,'exit su_aer_radii'
+
+   end subroutine su_aer_radii
+!==================================================================
+
+
+!==================================================================
+   subroutine h2o_reffrad(ngrid,nlayer,pq,pt,reffrad,nueffrad)
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the effective radii of liquid and icy water particles
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+      use watercommon_h, Only: T_h2O_ice_liq,T_h2O_ice_clouds,rhowater,rhowaterice
+      use comcstfi_mod, only: pi
+      Implicit none
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(in) :: pq(ngrid,nlayer) !water ice mixing ratios (kg/kg)
+      real, intent(in) :: pt(ngrid,nlayer) !temperature (K)
+      real, intent(out) :: reffrad(ngrid,nlayer)      !aerosol radii
+      real, intent(out) :: nueffrad(ngrid,nlayer) ! dispersion      
+
+      integer :: ig,l
+      real zfice ,zrad,zrad_liq,zrad_ice
+      real,external :: CBRT            
+      
+
+      if (radfixed) then
+         do l=1,nlayer
+            do ig=1,ngrid
+               zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
+               zfice = MIN(MAX(zfice,0.0),1.0)
+               reffrad(ig,l)= rad_h2o * (1.-zfice) + rad_h2o_ice * zfice
+               nueffrad(ig,l) = coef_chaud * (1.-zfice) + coef_froid * zfice
+            enddo
+         enddo
+      else
+         do l=1,nlayer
+            do ig=1,ngrid
+               zfice = 1.0 - (pt(ig,l)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
+               zfice = MIN(MAX(zfice,0.0),1.0)
+               zrad_liq  = CBRT( 3*pq(ig,l)/(4*Nmix_h2o*pi*rhowater) )
+               zrad_ice  = CBRT( 3*pq(ig,l)/(4*Nmix_h2o_ice*pi*rhowaterice) )
+               nueffrad(ig,l) = coef_chaud * (1.-zfice) + coef_froid * zfice
+               zrad = zrad_liq * (1.-zfice) + zrad_ice * zfice
+
+               reffrad(ig,l) = min(max(zrad,1.e-6),1000.e-6)
+               enddo
+            enddo      
+      end if
+
+   end subroutine h2o_reffrad
+!==================================================================
+
+
+!==================================================================
+   subroutine h2o_cloudrad(ngrid,nlayer,pql,reffliq,reffice)
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the effective radii of liquid and icy water particles
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+      use watercommon_h, Only: rhowater,rhowaterice
+      use comcstfi_mod, only: pi
+      Implicit none
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(in) :: pql(ngrid,nlayer) !condensed water mixing ratios (kg/kg)
+      real, intent(out) :: reffliq(ngrid,nlayer),reffice(ngrid,nlayer)     !liquid and ice water particle radii (m)
+
+      real,external :: CBRT            
+      integer :: i,k
+
+      if (radfixed) then
+         reffliq(1:ngrid,1:nlayer)= rad_h2o
+         reffice(1:ngrid,1:nlayer)= rad_h2o_ice
+      else
+         do k=1,nlayer
+           do i=1,ngrid
+             reffliq(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o*pi*rhowater))
+             reffliq(i,k) = min(max(reffliq(i,k),1.e-6),1000.e-6)
+           
+             reffice(i,k) = CBRT(3*pql(i,k)/(4*Nmix_h2o_ice*pi*rhowaterice))
+             reffice(i,k) = min(max(reffice(i,k),1.e-6),1000.e-6)
+           enddo
+         enddo
+      endif
+
+   end subroutine h2o_cloudrad
+!==================================================================
+
+
+
+!==================================================================
+   subroutine co2_reffrad(ngrid,nlayer,nq,pq,reffrad)
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the effective radii of co2 ice particles
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+      USE tracer_h, only:igcm_co2_ice,rho_co2
+      use comcstfi_mod, only: pi
+      Implicit none
+
+      integer,intent(in) :: ngrid,nlayer,nq
+
+      real, intent(in) :: pq(ngrid,nlayer,nq) !tracer mixing ratios (kg/kg)
+      real, intent(out) :: reffrad(ngrid,nlayer)      !co2 ice particles radii (m)
+
+      integer :: ig,l
+      real :: zrad   
+      real,external :: CBRT            
+            
+      
+
+      if (radfixed) then
+         reffrad(1:ngrid,1:nlayer) = 5.e-5 ! CO2 ice
+      else
+         do l=1,nlayer
+            do ig=1,ngrid
+               zrad = CBRT( 3*pq(ig,l,igcm_co2_ice)/(4*Nmix_co2*pi*rho_co2) )
+               reffrad(ig,l) = min(max(zrad,1.e-6),100.e-6)
+            enddo
+         enddo      
+      end if
+
+   end subroutine co2_reffrad
+!==================================================================
+
+
+
+!==================================================================
+   subroutine dust_reffrad(ngrid,nlayer,reffrad)
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the effective radii of dust particles
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+      Implicit none
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(out) :: reffrad(ngrid,nlayer)      !dust particles radii (m)
+            
+      reffrad(1:ngrid,1:nlayer) = 2.e-6 ! dust
+
+   end subroutine dust_reffrad
+!==================================================================
+
+
+!==================================================================
+   subroutine h2so4_reffrad(ngrid,nlayer,reffrad)
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the effective radii of h2so4 particles
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+      Implicit none
+
+      integer,intent(in) :: ngrid
+      integer,intent(in) :: nlayer
+
+      real, intent(out) :: reffrad(ngrid,nlayer)      !h2so4 particle radii (m)
+                
+      reffrad(1:ngrid,1:nlayer) = 1.e-6 ! h2so4
+
+   end subroutine h2so4_reffrad
+!==================================================================
+
+!==================================================================
+   subroutine back2lay_reffrad(ngrid,reffrad,nlayer,pplev)
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the effective radii of particles in a 2-layer model
+!
+!     Authors
+!     -------
+!     Sandrine Guerlet (2013)
+!
+!==================================================================
+ 
+      use aerosol_mod   !! Particle sizes and boundaries of aerosol layers defined there
+     Implicit none
+
+      integer,intent(in) :: ngrid
+
+      real, intent(out) :: reffrad(ngrid,nlayer)      ! particle radii (m)
+      REAL,INTENT(IN) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      INTEGER,INTENT(IN) :: nlayer ! number of atmospheric layers
+      REAL :: expfactor
+      INTEGER l,ig
+            
+      reffrad(:,:)=1e-6  !!initialization, not important
+          DO ig=1,ngrid
+            DO l=1,nlayer-1
+              IF (pplev(ig,l) .le. pres_bottom_tropo .and. pplev(ig,l) .ge. pres_top_tropo) THEN
+                reffrad(ig,l) = size_tropo
+              ELSEIF (pplev(ig,l) .lt. pres_top_tropo .and. pplev(ig,l) .gt. pres_bottom_strato) THEN
+                expfactor=log(size_strato/size_tropo) / log(pres_bottom_strato/pres_top_tropo)
+                reffrad(ig,l)= size_tropo*((pplev(ig,l)/pres_top_tropo)**expfactor)
+              ELSEIF (pplev(ig,l) .le. pres_bottom_strato) then
+                reffrad(ig,l) = size_strato
+              ENDIF
+            ENDDO
+          ENDDO
+
+   end subroutine back2lay_reffrad
+!==================================================================
+
+
+
+end module radii_mod
+!==================================================================
Index: /trunk/LMDZ.TITAN/libf/phytitan/radinc_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/radinc_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/radinc_h.F90	(revision 1644)
@@ -0,0 +1,111 @@
+module radinc_h
+
+  implicit none
+
+  include "bands.h"
+  include "scatterers.h"
+
+!======================================================================
+!
+!     RADINC.H 
+!
+!     Includes for the radiation code; RADIATION LAYERS, LEVELS,
+!     number of spectral intervals. . .
+! 
+!======================================================================
+
+!     RADIATION parameters
+
+!     In radiation code, layer 1 corresponds to the stratosphere.  Level
+!     1 is the top of the stratosphere.  The dummy layer is at the same
+!     temperature as the (vertically isothermal) stratosphere, and
+!     any time it is explicitly needed, the appropriate quantities will
+!     be dealt with (aka "top". . .)
+
+!     L_NLEVRAD corresponds to the surface - i.e., the GCM Level that
+!     is at the surface.  PLEV(L_NLEVRAD) = P(J,I)+PTROP, 
+!     PLEV(2) = PTROP, PLEV(1) = ptop
+
+!     L_NLAYRAD is the number of radiation code layers
+!     L_NLEVRAD is the number of radiation code levels.  Level N is the
+!               top of layer N. 
+!
+!     L_NSPECTI is the number of IR spectral intervals
+!     L_NSPECTV is the number of Visual(or Solar) spectral intervals
+!     L_NGAUSS  is the number of Gauss points for K-coefficients
+!               GAUSS POINT 17 (aka the last one) is the special case
+!
+!     L_NPREF   is the number of reference pressures that the 
+!               k-coefficients are calculated on
+!     L_PINT    is the number of Lagrange interpolated reference
+!               pressures for the gas k-coefficients - now for a
+!		smaller p-grid than before
+!     L_NTREF   is the number of reference temperatures for the
+!               k-coefficients
+!     L_TAUMAX  is the largest optical depth - larger ones are set
+!               to this value
+!
+!     L_REFVAR  The number of different mixing ratio values for
+!               the k-coefficients. Variable component of the mixture
+!		can in princple be anything: currently it's H2O.
+!
+!     NAERKIND  The number of radiatively active aerosol types
+!
+!     NSIZEMAX  The maximum number of aerosol particle sizes
+!
+!----------------------------------------------------------------------
+
+      integer,save :: L_NLAYRAD  ! = nbp_lev ! set by ini_radinc_h
+      integer,save :: L_LEVELS   ! = 2*(nbp_lev-1)+3 ! set by ini_radinc_h
+      integer,save :: L_NLEVRAD  ! = nbp_lev+1 ! set by ini_radinc_h
+!$OMP THREADPRIVATE(L_NLAYRAD,L_LEVELS,L_NLEVRAD)
+
+      ! These are set in sugas_corrk
+      ! [uses allocatable arrays] -- AS 12/2011
+      integer :: L_NPREF, L_NTREF, L_REFVAR, L_PINT   !L_NPREF, L_NTREF, L_REFVAR, L_PINT read by master in sugas_corrk
+
+      integer, parameter :: L_NGAUSS  = 17
+
+      integer, parameter :: L_NSPECTI = NBinfrared
+      integer, parameter :: L_NSPECTV = NBvisible
+
+!      integer, parameter :: NAERKIND  = 2 ! set in scatterers.h
+      real,    parameter :: L_TAUMAX  = 35
+
+      ! For Planck function integration: 
+      ! equivalent temperatures are 1/NTfac of these values
+      integer, parameter :: NTstar = 500
+      integer, parameter :: NTstop = 15000 ! new default for all non hot Jupiter runs
+      real*8, parameter :: NTfac = 1.0D+1  
+      !integer, parameter :: NTstar = 1000
+      !integer, parameter :: NTstop = 25000
+      !real*8,parameter :: NTfac = 5.0D+1    
+      !integer, parameter :: NTstar = 2000
+      !integer, parameter :: NTstop = 50000
+      !real*8,parameter :: NTfac = 1.0D+2    
+
+      ! Maximum number of grain size classes for aerosol convolution:
+      ! This must correspond to size of largest dataset used for aerosol 
+      ! optical properties in datagcm folder.
+      integer, parameter :: nsizemax = 60
+
+      character(len=100),save :: corrkdir
+!$OMP THREADPRIVATE(corrkdir)
+
+      character(len=100),save :: banddir
+!$OMP THREADPRIVATE(banddir)
+
+contains
+
+  subroutine ini_radinc_h(nbp_lev)
+  ! Initialize module variables
+  implicit none
+  integer,intent(in) :: nbp_lev
+  
+  L_NLAYRAD = nbp_lev
+  L_LEVELS = 2*(nbp_lev-1)+3
+  L_NLEVRAD = nbp_lev+1
+  
+  end subroutine
+
+end module radinc_h
Index: /trunk/LMDZ.TITAN/libf/phytitan/rain.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/rain.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/rain.F90	(revision 1644)
@@ -0,0 +1,387 @@
+subroutine rain(ngrid,nlayer,nq,ptimestep,pplev,pplay,t,pdt,pq,pdq,d_t,dqrain,dqsrain,dqssnow,rneb)
+
+
+  use ioipsl_getin_p_mod, only: getin_p
+  use watercommon_h, only: T_h2O_ice_liq,T_h2O_ice_clouds, RLVTT, RCPD, RCPV, RV, RVTMP2,Psat_water,Tsat_water,rhowater
+  use radii_mod, only: h2o_cloudrad
+  USE tracer_h, only: igcm_h2o_vap, igcm_h2o_ice
+  use comcstfi_mod, only: g, r
+  implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates H2O precipitation using simplified microphysics.
+!     
+!     Authors
+!     -------
+!     Adapted from the LMDTERRE code by R. Wordsworth (2009)
+!     Added rain vaporization in case of T>Tsat
+!     Original author Z. X. Li (1993)
+!     
+!==================================================================
+
+!     Arguments
+      integer,intent(in) :: ngrid ! number of atmospheric columns
+      integer,intent(in) :: nlayer ! number of atmospheric layers
+      integer,intent(in) :: nq ! number of tracers
+      real,intent(in) :: ptimestep    ! time interval
+      real,intent(in) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      real,intent(in) :: pplay(ngrid,nlayer)   ! mid-layer pressure (Pa)
+      real,intent(in) :: t(ngrid,nlayer) ! input temperature (K)
+      real,intent(in) :: pdt(ngrid,nlayer) ! input tendency on temperature (K/s)      
+      real,intent(in) :: pq(ngrid,nlayer,nq)  ! tracers (kg/kg)
+      real,intent(in) :: pdq(ngrid,nlayer,nq) ! input tendency on tracers
+      real,intent(out) :: d_t(ngrid,nlayer) ! temperature tendency (K/s)
+      real,intent(out) :: dqrain(ngrid,nlayer,nq) ! tendency of H2O precipitation (kg/kg.s-1)
+      real,intent(out) :: dqsrain(ngrid)  ! rain flux at the surface (kg.m-2.s-1)
+      real,intent(out) :: dqssnow(ngrid)  ! snow flux at the surface (kg.m-2.s-1)
+      real,intent(in) :: rneb(ngrid,nlayer) ! cloud fraction
+
+      REAL zt(ngrid,nlayer)         ! working temperature (K)
+      REAL ql(ngrid,nlayer)         ! liquid water (Kg/Kg)
+      REAL q(ngrid,nlayer)          ! specific humidity (Kg/Kg)
+      REAL d_q(ngrid,nlayer)        ! water vapor increment
+      REAL d_ql(ngrid,nlayer)       ! liquid water / ice increment
+
+!     Subroutine options
+      REAL,PARAMETER :: seuil_neb=0.001  ! Nebulosity threshold
+
+      INTEGER,save :: precip_scheme      ! id number for precipitaion scheme
+!     for simple scheme  (precip_scheme=1)
+      REAL,SAVE :: rainthreshold                ! Precipitation threshold in simple scheme
+!     for sundquist scheme  (precip_scheme=2-3)
+      REAL,SAVE :: cloud_sat                    ! Precipitation threshold in non simple scheme
+      REAL,SAVE :: precip_timescale             ! Precipitation timescale
+!     for Boucher scheme  (precip_scheme=4)
+      REAL,SAVE :: Cboucher ! Precipitation constant in Boucher 95 scheme
+      REAL,PARAMETER :: Kboucher=1.19E8
+      REAL,SAVE :: c1
+!$OMP THREADPRIVATE(precip_scheme,rainthreshold,cloud_sat,precip_timescale,Cboucher,c1)
+
+      INTEGER,PARAMETER :: ninter=5
+
+      logical,save :: evap_prec ! Does the rain evaporate?
+!$OMP THREADPRIVATE(evap_prec)
+
+!     for simple scheme
+      real,parameter :: t_crit=218.0
+      real lconvert
+
+!     Local variables
+      INTEGER i, k, n
+      REAL zqs(ngrid,nlayer),Tsat(ngrid,nlayer), zdelta, zcor
+      REAL zrfl(ngrid), zrfln(ngrid), zqev, zqevt
+
+      REAL zoliq(ngrid)
+      REAL zdz(ngrid),zrho(ngrid),ztot(ngrid), zrhol(ngrid)
+      REAL zchau(ngrid),zfroi(ngrid),zfrac(ngrid),zneb(ngrid)
+
+      real reffh2oliq(ngrid,nlayer),reffh2oice(ngrid,nlayer)
+  
+      real ttemp, ptemp, psat_tmp
+      real tnext(ngrid,nlayer)
+
+      real l2c(ngrid,nlayer)
+      real dWtot
+
+
+!     Indices of water vapour and water ice tracers
+      INTEGER, SAVE :: i_vap=0  ! water vapour
+      INTEGER, SAVE :: i_ice=0  ! water ice
+!$OMP THREADPRIVATE(i_vap,i_ice)
+
+      LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+
+!     Online functions
+      REAL fallv, fall2v, zzz ! falling speed of ice crystals
+      fallv (zzz) = 3.29 * ((zzz)**0.16)
+      fall2v (zzz) =10.6 * ((zzz)**0.31)  !for use with radii
+
+
+      IF (firstcall) THEN
+
+         i_vap=igcm_h2o_vap
+         i_ice=igcm_h2o_ice
+        
+         write(*,*) "rain: i_ice=",i_ice
+         write(*,*) "      i_vap=",i_vap
+
+         PRINT*, 'in rain.F, ninter=', ninter
+         PRINT*, 'in rain.F, evap_prec=', evap_prec
+
+         write(*,*) "Precipitation scheme to use?"
+         precip_scheme=1 ! default value
+         call getin_p("precip_scheme",precip_scheme)
+         write(*,*) " precip_scheme = ",precip_scheme
+
+         if (precip_scheme.eq.1) then
+	    write(*,*) "rainthreshold in simple scheme?"
+            rainthreshold=0. ! default value
+            call getin_p("rainthreshold",rainthreshold)
+            write(*,*) " rainthreshold = ",rainthreshold
+
+         else if (precip_scheme.eq.2.or.precip_scheme.eq.3) then
+	    write(*,*) "cloud water saturation level in non simple scheme?"
+            cloud_sat=2.6e-4   ! default value
+            call getin_p("cloud_sat",cloud_sat)
+            write(*,*) " cloud_sat = ",cloud_sat
+	    write(*,*) "precipitation timescale in non simple scheme?"
+            precip_timescale=3600.  ! default value
+            call getin_p("precip_timescale",precip_timescale)
+            write(*,*) " precip_timescale = ",precip_timescale
+
+         else if (precip_scheme.eq.4) then
+	    write(*,*) "multiplicative constant in Boucher 95 precip scheme"
+            Cboucher=1.   ! default value
+            call getin_p("Cboucher",Cboucher)
+            write(*,*) " Cboucher = ",Cboucher	
+	    c1=1.00*1.097/rhowater*Cboucher*Kboucher  
+
+	 endif
+
+         write(*,*) "re-evaporate precipitations?"
+         evap_prec=.true. ! default value
+         call getin_p("evap_prec",evap_prec)
+         write(*,*) " evap_prec = ",evap_prec
+
+         firstcall = .false.
+      ENDIF ! of IF (firstcall)
+
+!     GCM -----> subroutine variables
+      DO k = 1, nlayer
+      DO i = 1, ngrid
+
+	 zt(i,k)   = t(i,k)+pdt(i,k)*ptimestep ! a big fat bug was here
+         q(i,k)    = pq(i,k,i_vap)+pdq(i,k,i_vap)*ptimestep
+         ql(i,k)   = pq(i,k,i_ice)+pdq(i,k,i_ice)*ptimestep
+
+         !q(i,k)    = pq(i,k,i_vap)!+pdq(i,k,i_vap)
+         !ql(i,k)   = pq(i,k,i_ice)!+pdq(i,k,i_ice)
+
+         if(q(i,k).lt.0.)then ! if this is not done, we don't conserve water
+            q(i,k)=0.
+         endif
+         if(ql(i,k).lt.0.)then
+            ql(i,k)=0.
+         endif
+
+      ENDDO
+      ENDDO
+
+!     Initialise the outputs
+      d_t(1:ngrid,1:nlayer) = 0.0
+      d_q(1:ngrid,1:nlayer) = 0.0
+      d_ql(1:ngrid,1:nlayer) = 0.0
+      zrfl(1:ngrid) = 0.0
+      zrfln(1:ngrid) = 0.0
+
+      ! calculate saturation mixing ratio
+      DO k = 1, nlayer
+         DO i = 1, ngrid
+            ttemp = zt(i,k) 
+            ptemp = pplay(i,k)
+!            call watersat(ttemp,ptemp,zqs(i,k))
+	    call Psat_water(ttemp,ptemp,psat_tmp,zqs(i,k))
+	    call Tsat_water(ptemp,Tsat(i,k))
+         ENDDO
+      ENDDO
+
+      ! get column / layer conversion factor
+      DO k = 1, nlayer
+         DO i = 1, ngrid
+            l2c(i,k)=(pplev(i,k)-pplev(i,k+1))/g
+         ENDDO
+      ENDDO
+
+      ! Vertical loop (from top to bottom)
+      ! We carry the rain with us and calculate that added by warm/cold precipitation
+      ! processes and that subtracted by evaporation at each level.
+      DO k = nlayer, 1, -1
+
+         IF (evap_prec) THEN ! note no rneb dependence!
+            DO i = 1, ngrid
+               IF (zrfl(i) .GT.0.) THEN
+
+                  if(zt(i,k).gt.Tsat(i,k))then
+!!		     treat the case where all liquid water should boil
+		     zqev=MIN((zt(i,k)-Tsat(i,k))*RCPD*l2c(i,k)/RLVTT/ptimestep,zrfl(i))
+		     zrfl(i)=MAX(zrfl(i)-zqev,0.)
+		     d_q(i,k)=zqev/l2c(i,k)*ptimestep
+		     d_t(i,k) = - d_q(i,k) * RLVTT/RCPD
+		  else
+                     zqev = MAX (0.0, (zqs(i,k)-q(i,k)))*l2c(i,k)/ptimestep !there was a bug here
+                     zqevt= 2.0e-5*(1.0-q(i,k)/zqs(i,k))    & !default was 2.e-5
+                        *sqrt(zrfl(i))*l2c(i,k)/pplay(i,k)*zt(i,k)*R ! BC modif here
+                     zqevt = MAX (zqevt, 0.0)
+                     zqev  = MIN (zqev, zqevt)
+                     zqev  = MAX (zqev, 0.0)
+                     zrfln(i)= zrfl(i) - zqev
+		     zrfln(i)= max(zrfln(i),0.0)
+
+                     d_q(i,k) = - (zrfln(i)-zrfl(i))/l2c(i,k)*ptimestep
+                     !d_t(i,k) = d_q(i,k) * RLVTT/RCPD!/(1.0+RVTMP2*q(i,k)) ! double BC modif here
+                     d_t(i,k) = - d_q(i,k) * RLVTT/RCPD ! was bugged!
+                     zrfl(i)  = zrfln(i)
+		  end if
+		     
+
+               ENDIF ! of IF (zrfl(i) .GT.0.)
+            ENDDO
+         ENDIF ! of IF (evap_prec)
+
+         zoliq(1:ngrid) = 0.0
+
+
+         if(precip_scheme.eq.1)then
+
+            DO i = 1, ngrid
+               ttemp = zt(i,k)
+               IF (ttemp .ge. T_h2O_ice_liq) THEN
+                  lconvert=rainthreshold
+               ELSEIF (ttemp .gt. t_crit) THEN
+                  lconvert=rainthreshold*(1.- t_crit/ttemp)
+                  lconvert=MAX(0.0,lconvert)              
+               ELSE
+                  lconvert=0.
+               ENDIF
+
+
+               IF (ql(i,k).gt.1.e-9) then
+                  zneb(i)  = MAX(rneb(i,k), seuil_neb)
+                  IF ((ql(i,k)/zneb(i)).gt.lconvert)THEN ! precipitate!
+                     d_ql(i,k) = -MAX((ql(i,k)-lconvert*zneb(i)),0.0)
+                     zrfl(i)   = zrfl(i) - d_ql(i,k)*l2c(i,k)/ptimestep
+                  ENDIF
+               ENDIF
+            ENDDO
+
+         elseif (precip_scheme.ge.2) then
+          
+           DO i = 1, ngrid
+               IF (rneb(i,k).GT.0.0) THEN
+                  zoliq(i) = ql(i,k)
+                  zrho(i)  = pplay(i,k) / ( zt(i,k) * R )
+                  zdz(i)   = (pplev(i,k)-pplev(i,k+1)) / (zrho(i)*g)
+                  zfrac(i) = (zt(i,k)-T_h2O_ice_clouds) / (T_h2O_ice_liq-T_h2O_ice_clouds)
+                  zfrac(i) = MAX(zfrac(i), 0.0)
+                  zfrac(i) = MIN(zfrac(i), 1.0)
+                  zneb(i)  = MAX(rneb(i,k), seuil_neb)
+               ENDIF
+           ENDDO
+
+ !recalculate liquid water particle radii
+	   call h2o_cloudrad(ngrid,nlayer,ql,reffh2oliq,reffh2oice)
+
+           SELECT CASE(precip_scheme)
+ !precip scheme from Sundquist 78
+ 	   CASE(2)
+
+            DO n = 1, ninter
+               DO i = 1, ngrid
+                  IF (rneb(i,k).GT.0.0) THEN
+                     ! this is the ONLY place where zneb, precip_timescale and cloud_sat are used
+
+                     zchau(i) = (ptimestep/(FLOAT(ninter)*precip_timescale)) * zoliq(i)      &
+                          * (1.0-EXP(-(zoliq(i)/zneb(i)/cloud_sat)**2)) * zfrac(i)
+                     zrhol(i) = zrho(i) * zoliq(i) / zneb(i)
+                     zfroi(i) = ptimestep/FLOAT(ninter)/zdz(i)*zoliq(i)    &
+                          *fall2v(reffh2oice(i,k)) * (1.0-zfrac(i)) ! zfroi behaves oddly...
+                     ztot(i)  = zchau(i) + zfroi(i)
+
+                     IF (zneb(i).EQ.seuil_neb) ztot(i) = 0.0
+                     ztot(i)  = MIN(MAX(ztot(i),0.0),zoliq(i))
+                     zoliq(i) = MAX(zoliq(i)-ztot(i), 0.0)
+
+                  ENDIF
+               ENDDO
+            ENDDO            
+
+ !precip scheme modified from Sundquist 78 (in q**3)
+	   CASE(3)	    
+	    
+            DO n = 1, ninter
+               DO i = 1, ngrid
+                  IF (rneb(i,k).GT.0.0) THEN
+                     ! this is the ONLY place where zneb, precip_timescale and cloud_sat are used
+
+                     zchau(i) = (ptimestep/(FLOAT(ninter)*precip_timescale*cloud_sat**2)) * (zoliq(i)/zneb(i))**3  
+                     zrhol(i) = zrho(i) * zoliq(i) / zneb(i)
+                     zfroi(i) = ptimestep/FLOAT(ninter)/zdz(i)*zoliq(i)    &
+                          *fall2v(reffh2oice(i,k)) * (1.0-zfrac(i)) ! zfroi behaves oddly...
+                     ztot(i)  = zchau(i) + zfroi(i)
+
+                     IF (zneb(i).EQ.seuil_neb) ztot(i) = 0.0
+                     ztot(i)  = MIN(MAX(ztot(i),0.0),zoliq(i))
+                     zoliq(i) = MAX(zoliq(i)-ztot(i), 0.0)
+
+                  ENDIF
+               ENDDO
+            ENDDO            
+
+ !precip scheme modified from Boucher 95
+	   CASE(4)
+
+            DO n = 1, ninter
+               DO i = 1, ngrid
+                  IF (rneb(i,k).GT.0.0) THEN
+                     ! this is the ONLY place where zneb and c1 are used
+
+                     zchau(i) = ptimestep/FLOAT(ninter) *c1* zrho(i) &
+                                    *(zoliq(i)/zneb(i))**2*reffh2oliq(i,k)*zneb(i)* zfrac(i) 
+                     zrhol(i) = zrho(i) * zoliq(i) / zneb(i)
+                     zfroi(i) = ptimestep/FLOAT(ninter)/zdz(i)*zoliq(i)    &
+                          *fall2v(reffh2oice(i,k)) * (1.0-zfrac(i)) ! zfroi behaves oddly...
+                     ztot(i)  = zchau(i) + zfroi(i)
+
+                     IF (zneb(i).EQ.seuil_neb) ztot(i) = 0.0
+                     ztot(i)  = MIN(MAX(ztot(i),0.0),zoliq(i))
+                     zoliq(i) = MAX(zoliq(i)-ztot(i), 0.0)
+
+                  ENDIF
+               ENDDO
+            ENDDO            
+
+           END SELECT ! precip_scheme 
+
+            ! Change in cloud density and surface H2O values
+            DO i = 1, ngrid
+               IF (rneb(i,k).GT.0.0) THEN
+                  d_ql(i,k) = (zoliq(i) - ql(i,k))!/ptimestep
+                  zrfl(i)   = zrfl(i)+ MAX(ql(i,k)-zoliq(i),0.0)*l2c(i,k)/ptimestep
+               ENDIF
+            ENDDO
+
+
+         endif ! if precip_scheme=1
+
+      ENDDO ! of DO k = nlayer, 1, -1
+
+!     Rain or snow on the ground
+      DO i = 1, ngrid
+         if(zrfl(i).lt.0.0)then
+            print*,'Droplets of negative rain are falling...'
+            call abort
+         endif
+         IF (t(i,1) .LT. T_h2O_ice_liq) THEN
+            dqssnow(i) = zrfl(i)
+            dqsrain(i) = 0.0
+         ELSE
+            dqssnow(i) = 0.0
+            dqsrain(i) = zrfl(i) ! liquid water = ice for now
+         ENDIF
+      ENDDO
+
+!     now subroutine -----> GCM variables
+      if (evap_prec) then
+        dqrain(1:ngrid,1:nlayer,i_vap)=d_q(1:ngrid,1:nlayer)/ptimestep
+        d_t(1:ngrid,1:nlayer)=d_t(1:ngrid,1:nlayer)/ptimestep
+      else
+        dqrain(1:ngrid,1:nlayer,i_vap)=0.0
+        d_t(1:ngrid,1:nlayer)=0.0
+      endif
+      dqrain(1:ngrid,1:nlayer,i_ice) = d_ql(1:ngrid,1:nlayer)/ptimestep
+
+    end subroutine rain
Index: /trunk/LMDZ.TITAN/libf/phytitan/rings.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/rings.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/rings.F90	(revision 1644)
@@ -0,0 +1,197 @@
+SUBROUTINE rings(ngrid, declin, ptime, rad, flat, eclipse)
+! Calculates Saturn's rings shadowing
+! Includes rings opacities measured by Cassini/UVIS
+! Authors: M. Sylvestre, M. Capderou, S. Guerlet, A. Spiga
+
+    use comdiurn_h, only: sinlat, sinlon, coslat, coslon
+    use geometry_mod, only: latitude ! (rad)
+ 
+    implicit none   
+
+    INTEGER, INTENT(IN) :: ngrid  ! horizontal grid dimension
+    REAL, INTENT(IN) :: declin    ! latitude of the subsolar point
+    REAL, INTENT(IN) :: ptime     ! UTC time in sol fraction : ptime=0.5 at noon
+    REAL, INTENT(IN) :: rad       ! equatorial radius of the planet
+    REAL, INTENT(IN) :: flat      ! flattening of the planet 
+    REAL, DIMENSION(ngrid), INTENT(OUT) :: eclipse ! absorption of the light by the rings    
+    
+    REAL :: rpol   ! polar radius of the planet
+    REAL :: e      ! shape excentricity of the planet : (1-e*e) = (1-f)*(1-f)    
+    INTEGER, PARAMETER :: nb_a = 4 ! number of subdivisions of the A ring
+    INTEGER, PARAMETER :: nb_b = 3 ! number of subdivisions of the B ring
+    INTEGER, PARAMETER :: nb_c = 3 ! number of subdivisions of the C ring
+    INTEGER, PARAMETER :: nb_ca = 2 ! number of subdivisions in the Cassini division
+    INTEGER :: i
+
+    ! arrays for the rings. TBD: dynamical?
+    REAL, DIMENSION(nb_a) :: A_Rint ! internal radii of the subdivisions of the A ring 
+    REAL, DIMENSION(nb_a) :: A_Rext ! external radii of the subdivisions of the A ring
+    REAL, DIMENSION(nb_b) :: B_Rint ! internal radii of the subdivisions of the B ring
+    REAL, DIMENSION(nb_b) :: B_Rext ! external radii of the subdivisions of the B ring 
+    REAL, DIMENSION(nb_c) :: C_Rint ! internal radii of the subdivisions of the C ring
+    REAL, DIMENSION(nb_c) :: C_Rext ! external radii of the subdivisions of the C ring 
+    REAL, DIMENSION(nb_ca) :: Ca_Rint ! internal radii of the subdivisions of the Cassini Division
+    REAL, DIMENSION(nb_ca) :: Ca_Rext ! external radii of the subdivisions of the Cassini Division
+
+    ! Opacities of the rings : for each one we can give different opacities for each part
+    REAL, DIMENSION(nb_a) :: tau_A ! opacity of the A ring
+    REAL, DIMENSION(nb_b) :: tau_B ! opacity of the B ring
+    REAL, DIMENSION(nb_c) :: tau_C ! opacity of the C ring
+    REAL, DIMENSION(nb_ca) :: tau_Ca ! opacity of the Cassini Division 
+
+    ! Parameters used to calculate if a point is under a ring subdivision's shadow
+    REAL :: phi_S                             ! subsolar point longitude
+    REAL, PARAMETER :: pi=acos(-1.0)    
+    REAL, DIMENSION(:), ALLOCATABLE:: x, y, z ! cartesian coordinates of the points on the planet
+    REAL :: xs, ys, zs                        ! cartesian coordinates of the points of the subsolar point
+    REAL, DIMENSION(:), ALLOCATABLE :: k
+    REAL, DIMENSION(:), ALLOCATABLE :: N      ! parameter to compute cartesian coordinates on a ellipsoidal planet
+    REAL, DIMENSION(:), ALLOCATABLE :: r      ! distance at which the incident ray of sun crosses the equatorial plane
+                                              ! measured from the center of the planet   
+    REAL :: Ns                                ! (same for the subsolar point)
+   
+    ! equinox --> no shadow (AS: why is this needed?)
+    if(declin .eq. 0.) then
+        eclipse(:) = 0.
+        return 
+    endif 
+
+! 1) INITIALIZATION
+
+    ! Generic
+    rpol = (1.- flat)*rad
+    e = sqrt(2*flat - flat**2)
+    ALLOCATE(x(ngrid))
+    ALLOCATE(y(ngrid))
+    ALLOCATE(z(ngrid))
+    ALLOCATE(k(ngrid))
+    ALLOCATE(N(ngrid))
+    ALLOCATE(r(ngrid))
+    eclipse(:) = 2000.
+
+! Model of the rings with Cassini/UVIS opacities
+
+    ! Size of the rings
+    A_Rint(1) = 2.03*rad
+    A_Rext(1) = 2.06*rad
+    A_Rint(2) = 2.06*rad
+    A_Rext(2) = 2.09*rad
+    A_Rint(3) = 2.09*rad
+    A_Rext(3) = 2.12*rad
+    A_Rint(4) = 2.12*rad
+    A_Rext(4) = 2.27*rad
+
+    B_Rint(1) = 1.53*rad
+    B_Rext(1) = 1.64*rad
+    B_Rint(2) = 1.64*rad
+    B_Rext(2) = 1.83*rad
+    B_Rint(3) = 1.83*rad
+    B_Rext(3) = 1.95*rad
+    
+    C_Rint(1) = 1.24*rad
+    C_Rext(1) = 1.29*rad
+    C_Rint(2) = 1.29*rad
+    C_Rext(2) = 1.43*rad
+    C_Rint(3) = 1.43*rad
+    C_Rext(3) = 1.53*rad
+
+    Ca_Rint(1) = 1.95*rad
+    Ca_Rext(1) = 1.99*rad
+    Ca_Rint(2) = 1.99*rad
+    Ca_Rext(2) = 2.03*rad
+
+
+    ! Opacities of the rings
+    tau_A(1) = 1.24
+    tau_A(2) = 0.81
+    tau_A(3) = 0.67
+    tau_A(4) = 0.58
+                
+    tau_B(1) = 1.29
+    tau_B(2) = 5.13 
+    tau_B(3) = 2.84 
+    
+    tau_C(1) = 0.06
+    tau_C(2) = 0.10
+    tau_C(3) = 0.14
+
+    tau_Ca(1) = 0.06
+    tau_Ca(2) = 0.24
+
+    ! Convert to cartesian coordinates
+    N(:) = rad / sqrt(1-(e**2)*sinlat(:)**2)
+    x(:) = N(:)*coslat(:)*coslon(:)
+    y(:) = N(:)*coslat(:)*sinlon(:)
+    z(:) = N(:)*(1-e**2)*sinlat(:)
+
+! 2) LOCATION OF THE SUBSOLAR POINT 
+ 
+    ! subsolar longitude is deduced from time fraction ptime
+    ! SG: the minus sign is important! ... otherwise subsolar point adopts a reverse rotation
+    phi_S = -(ptime - 0.5)*2.*pi 
+!    write(*,*) 'subsol point coords : ', declin*180./pi, phi_S*180./pi
+
+    ! subsolar latitude is declin (declination of the sun)
+    ! now convert in cartesian coordinates : 
+    Ns = rad/sqrt(1-(e**2)*sin(declin)**2)
+    xs = Ns*cos(declin)*cos(phi_S)
+    ys = Ns*cos(declin)*sin(phi_S)
+    zs = Ns*(1-e**2)*sin(declin)
+
+! 3) WHERE DOES THE INCIDENT RAY OF SUN CROSS THE EQUATORIAL PLAN ?
+
+    k(:) = -z(:)/zs
+    r(:) = (k(:)*xs + x(:))**2 + (k(:)*ys + y(:))**2 
+    r(:) = sqrt(r(:))
+
+! 4) SO WHERE ARE THE SHADOW OF THESE RINGS ?
+
+    ! Summer hemisphere is not under the shadow of the rings
+    where(latitude(:)*declin .gt. 0.)
+       eclipse(:) = 1000.
+    end where
+
+    ! No shadow of the rings by night
+    where(x(:)*xs + y(:)*ys + z(:)*zs .lt. 0.)
+       eclipse(:) = 1000.
+    end where
+
+    ! if the incident rays of sun cross a ring, there is a shadow
+    do i=1, nb_A 
+        where(r(:) .ge. A_Rint(i) .and. r(:) .le. A_Rext(i) .and. eclipse(:) .ne. 1000.)
+            eclipse(:) = 1. - exp(-tau_A(i)/abs(sin(declin)))
+        end where
+    end do 
+
+    do i=1, nb_B 
+        where(r(:) .ge. B_Rint(i) .and. r(:) .le. B_Rext(i) .and. eclipse(:) .ne. 1000.)
+            eclipse(:) = 1. - exp(-tau_B(i)/abs(sin(declin)))
+        end where
+    enddo
+    
+    do i=1, nb_C 
+        where(r(:) .ge. C_Rint(i) .and. r(:) .le. C_Rext(i) .and. eclipse(:) .ne. 1000.)
+            eclipse(:) = 1. - exp(-tau_C(i)/abs(sin(declin)))
+        end where
+    enddo
+
+    do i=1, nb_ca
+        where(r(:) .ge. Ca_Rint(i) .and. r(:) .le. Ca_Rext(i) .and. eclipse(:) .ne. 1000.)
+            eclipse(:) = 1. - exp(-tau_Ca(i)/abs(sin(declin)))
+        end where
+    enddo
+
+    ! At the other places and the excluded ones, eclipse is 0. 
+    where(eclipse(:) .eq. 2000. .or. eclipse(:) .eq. 1000.)
+        eclipse(:) = 0. 
+    end where 
+
+! 5) CLEAN THE PLACE
+    DEALLOCATE(x)
+    DEALLOCATE(y)
+    DEALLOCATE(z)
+    DEALLOCATE(k)
+    DEALLOCATE(N)
+    DEALLOCATE(r)
+
+END SUBROUTINE rings
Index: /trunk/LMDZ.TITAN/libf/phytitan/scatterers/make_scatterers
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/scatterers/make_scatterers	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/scatterers/make_scatterers	(revision 1644)
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+# sanity check: do we have the required argument ?
+if (( $# != 1 ))
+then
+ echo "Wrong number of parameters in $0 !!!"
+ echo " Usage:"
+ echo "  $0 num"
+ echo " where num is the number of scatterers"
+ exit
+fi
+
+filename=scatterers.$1
+
+if [ ! -f $filename ] ; then
+# if the file doesn't exist, we create it
+cat << EOF > $filename
+!-----------------------------------------------------------------------
+!   INCLUDE 'scatterers.h'
+!
+! Number of radiatively active species 
+! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!
+!-----------------------------------------------------------------------
+
+      integer, parameter :: naerkind=$1
+
+!-----------------------------------------------------------------------
+EOF
+
+else
+ echo "$filename already exists!"
+fi
+
+# remove 'old' scatterers.h file and replace it with new one
+\rm -f ../scatterers.h
+tar cf - $filename | ( cd .. ; tar xf - ; mv $filename scatterers.h )
+# line above is a trick to preserve time of creation of scatterers.# files
Index: /trunk/LMDZ.TITAN/libf/phytitan/scopyi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/scopyi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/scopyi.F	(revision 1644)
@@ -0,0 +1,17 @@
+      subroutine scopyi(n,sx,incx,sy,incy)
+c
+      IMPLICIT NONE
+c
+      integer n,incx,incy,ix,iy,i
+      integer sx((n-1)*incx+1),sy((n-1)*incy+1)
+c
+      iy=1
+      ix=1
+      do 10 i=1,n
+      sy(iy)=sx(ix)
+         ix=ix+incx
+         iy=iy+incy
+10    continue
+c
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/setspi.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/setspi.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/setspi.F90	(revision 1644)
@@ -0,0 +1,215 @@
+      subroutine setspi
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Set up spectral intervals and Planck function in the longwave.
+!     
+!     Authors
+!     ------- 
+!     Adapted from setspi in the NASA Ames radiative code by
+!     Robin Wordsworth (2009).
+!     
+!     Called by
+!     ---------
+!     callcorrk.F
+!     
+!     Calls
+!     -----
+!     none
+!     
+!==================================================================
+
+      use radinc_h,    only: L_NSPECTI,corrkdir,banddir,NTstar,NTstop,NTfac
+      use radcommon_h, only: BWNI,BLAMI,WNOI,DWNI,WAVEI,planckir,sigma
+      use datafile_mod, only: datadir
+      use comcstfi_mod, only: pi
+
+      implicit none
+
+      logical file_ok
+      integer nw, nt, m, mm, file_entries
+      real*8 a, b, ans, y, bpa, bma, T, dummy
+
+      character(len=30)  :: temp1
+      character(len=200) :: file_id
+      character(len=200) :: file_path
+
+!     C1 and C2 values from Goody and Yung (2nd edition)  MKS units
+!     These values lead to a "sigma" (sigma*T^4) of 5.67032E-8 W m^-2 K^-4
+
+      real*8 :: c1 = 3.741832D-16 ! W m^-2
+      real*8 :: c2 = 1.438786D-2  ! m K
+      
+      real*8 :: lastband(2), plancksum
+
+      !! used to count lines
+      integer :: nb
+      integer :: ierr
+
+      logical forceEC, planckcheck
+
+      real*8 :: x(12) = [ -0.981560634246719D0,  -0.904117256370475D0, &
+      -0.769902674194305D0,  -0.587317954286617D0,                     &
+      -0.367831498998180D0,  -0.125233408511469D0,                     &
+       0.125233408511469D0,   0.367831498998180D0,                     &
+       0.587317954286617D0,   0.769902674194305D0,                     &
+       0.904117256370475D0,   0.981560634246719D0  ]
+
+      real*8 :: w(12) = [  0.047175336386512D0,   0.106939325995318D0, &
+           0.160078328543346D0,   0.203167426723066D0,                 &
+           0.233492536538355D0,   0.249147045813403D0,                 &
+           0.249147045813403D0,   0.233492536538355D0,                 &
+           0.203167426723066D0,   0.160078328543346D0,                 &
+           0.106939325995318D0,   0.047175336386512D0  ]
+      mm=0
+
+      forceEC=.true.
+      planckcheck=.true.
+
+!=======================================================================
+!     Set up spectral bands - wavenumber [cm^(-1)]. Go from smaller to
+!     larger wavenumbers.
+
+      write(temp1,'(i2.2)') L_NSPECTI
+      !file_id='/corrk_data/' // corrkdir(1:LEN_TRIM(corrkdir)) // '/narrowbands_IR.in'
+      file_id='/corrk_data/'//trim(adjustl(banddir))//'/narrowbands_IR.in' 
+      file_path=TRIM(datadir)//TRIM(file_id)
+
+      ! check that the file exists
+      inquire(FILE=file_path,EXIST=file_ok)
+      if(.not.file_ok) then
+         write(*,*)'The file ',TRIM(file_path)
+         write(*,*)'was not found by setspi.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
+         call abort
+      endif
+    
+!$OMP MASTER    
+      nb=0
+      ierr=0
+      ! check that the file contains the right number of bands 
+      open(131,file=file_path,form='formatted')
+      read(131,*,iostat=ierr) file_entries
+      do while (ierr==0)
+        read(131,*,iostat=ierr) dummy
+!        write(*,*) 'setspi: file_entries:',dummy,'ierr=',ierr
+        if (ierr==0) nb=nb+1
+      enddo
+      close(131)
+
+      write(*,*) 'setspi: L_NSPECTI = ',L_NSPECTI, 'in the model '
+      write(*,*) '        there are   ',nb, 'entries in ',TRIM(file_path)
+      if(nb.ne.L_NSPECTI) then
+         write(*,*) 'MISMATCH !! I stop here'
+         call abort
+      endif
+
+      ! load and display the data
+      open(111,file=file_path,form='formatted')
+      read(111,*) 
+      do M=1,L_NSPECTI-1
+         read(111,*) BWNI(M)
+      end do
+      read(111,*) lastband
+      close(111)
+      BWNI(L_NSPECTI)  =lastband(1)
+      BWNI(L_NSPECTI+1)=lastband(2)
+!$OMP END MASTER
+!$OMP BARRIER
+
+      print*,''
+      print*,'setspi: IR band limits:'
+      do M=1,L_NSPECTI+1
+         print*,m,'-->',BWNI(M),' cm^-1'
+      end do
+
+!     Set up mean wavenumbers and wavenumber deltas.  Units of 
+!     wavenumbers is cm^(-1); units of wavelengths is microns.
+
+      do M=1,L_NSPECTI
+         WNOI(M)  = 0.5D0*(BWNI(M+1)+BWNI(M))
+         DWNI(M)  = BWNI(M+1)-BWNI(M)
+         WAVEI(M) = 1.0D+4/WNOI(M)
+         BLAMI(M) = 0.01D0/BWNI(M)         
+      end do
+      BLAMI(M) = 0.01D0/BWNI(M)
+!     note M=L_NSPECTI+1 after loop due to Fortran bizarreness
+
+!=======================================================================
+!     For each IR wavelength interval, compute the integral of B(T), the
+!     Planck function, divided by the wavelength interval, in cm-1.  The
+!     integration is in MKS units, the final answer is the same as the
+!     original planck.f; W m^-2 wavenumber^-1, where wavenumber is in CM^-1.
+
+      print*,''
+      print*,'setspi: Current Planck integration range:'
+      print*,'T = ',dble(NTstar)/NTfac, ' to ',dble(NTstop)/NTfac,' K.'
+
+      do NW=1,L_NSPECTI
+         a = 1.0D-2/BWNI(NW+1)
+         b = 1.0D-2/BWNI(NW)
+         bpa = (b+a)/2.0D0
+         bma = (b-a)/2.0D0
+         do nt=NTstar,NTstop
+            T   = dble(NT)/NTfac
+            ans = 0.0D0
+
+            do mm=1,12
+               y    = bma*x(mm)+bpa
+               ans  = ans + w(mm)*c1/(y**5*(exp(c2/(y*T))-1.0D0))
+            end do
+
+            planckir(NW,nt-NTstar+1) = ans*bma/(PI*DWNI(NW))
+         end do
+      end do
+         
+      ! force planck=sigma*eps*T^4 for each temperature in array
+      if(forceEC)then
+         print*,'setspi: Force F=sigma*eps*T^4 for all values of T!'
+         do nt=NTstar,NTstop
+            plancksum=0.0D0
+            T=dble(NT)/NTfac
+       
+            do NW=1,L_NSPECTI
+               plancksum=plancksum+  &
+                  planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
+            end do
+
+            do NW=1,L_NSPECTI
+               planckir(NW,nt-NTstar+1)=     &
+                  planckir(NW,nt-NTstar+1)*  &
+                          sigma*(dble(nt)/NTfac)**4/plancksum
+            end do
+         end do
+      endif
+
+      if(planckcheck)then
+         ! check energy conservation at lower temperature boundary
+         plancksum=0.0D0
+         nt=NTstar
+         do NW=1,L_NSPECTI
+            plancksum=plancksum+planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
+         end do
+         print*,'setspi: At lower limit:'
+         print*,'in model sig*T^4 = ',plancksum,' W m^-2'
+         print*,'actual sig*T^4   = ',sigma*(dble(nt)/NTfac)**4,' W m^-2'
+         
+         ! check energy conservation at upper temperature boundary
+         plancksum=0.0D0
+         nt=NTstop
+         do NW=1,L_NSPECTI
+            plancksum=plancksum+planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
+         end do
+         print*,'setspi: At upper limit:'
+         print*,'in model sig*T^4 = ',plancksum,' W m^-2'
+         print*,'actual sig*T^4   = ',sigma*(dble(nt)/NTfac)**4,' W m^-2'
+         print*,''
+      endif
+
+      return
+    end subroutine setspi
Index: /trunk/LMDZ.TITAN/libf/phytitan/setspv.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/setspv.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/setspv.F90	(revision 1644)
@@ -0,0 +1,151 @@
+      subroutine setspv
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Set up spectral intervals, stellar spectrum and Rayleigh 
+!     opacity in the shortwave. 
+!     
+!     Authors
+!     ------- 
+!     Adapted from setspv in the NASA Ames radiative code by
+!     Robin Wordsworth (2009).
+!
+!     Called by
+!     ---------
+!     callcorrk.F
+!     
+!     Calls
+!     -----
+!     ave_stelspec.F
+!     
+!==================================================================
+
+      use radinc_h,    only: L_NSPECTV, corrkdir, banddir
+      use radcommon_h, only: BWNV,BLAMV,WNOV,DWNV,WAVEV, &
+                             STELLARF,TAURAY
+      use datafile_mod, only: datadir
+      use callkeys_mod, only: Fat1AU,rayleigh
+
+      implicit none
+
+      logical file_ok
+
+      integer N, M, file_entries
+
+      character(len=30)  :: temp1
+      character(len=200) :: file_id
+      character(len=200) :: file_path
+
+      real*8 :: lastband(2)
+
+      real*8 STELLAR(L_NSPECTV)
+      real*8 sum, dummy
+
+      !! used to count lines
+      integer :: nb
+      integer :: ierr
+
+!=======================================================================
+!     Set up spectral bands - wavenumber [cm^(-1)]. Go from smaller to
+!     larger wavenumbers, the same as in the IR.
+
+      write(temp1,'(i2.2)') L_NSPECTV
+      file_id='/corrk_data/'//trim(adjustl(banddir))//'/narrowbands_VI.in' 
+      file_path=TRIM(datadir)//TRIM(file_id)
+
+      ! check that the file exists
+      inquire(FILE=file_path,EXIST=file_ok)
+      if(.not.file_ok) then
+         write(*,*)'The file ',TRIM(file_path)
+         write(*,*)'was not found by setspv.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
+         call abort
+      endif
+	
+!$OMP MASTER        
+      nb=0
+      ierr=0
+      ! check that the file contains the right number of bands 
+      open(131,file=file_path,form='formatted')
+      read(131,*,iostat=ierr) file_entries
+      do while (ierr==0)
+        read(131,*,iostat=ierr) dummy
+        if (ierr==0) nb=nb+1
+      enddo
+      close(131)
+
+      write(*,*) 'setspv: L_NSPECTV = ',L_NSPECTV, 'in the model '
+      write(*,*) '        there are   ',nb, 'entries in ',TRIM(file_path)
+      if(nb.ne.L_NSPECTV) then
+         write(*,*) 'MISMATCH !! I stop here'
+         call abort
+      endif
+
+      ! load and display the data
+      open(111,file=file_path,form='formatted')
+      read(111,*) 
+       do M=1,L_NSPECTV-1
+         read(111,*) BWNV(M)
+      end do
+      read(111,*) lastband
+      close(111)
+      BWNV(L_NSPECTV)  =lastband(1)
+      BWNV(L_NSPECTV+1)=lastband(2)
+!$OMP END MASTER
+!$OMP BARRIER
+
+      print*,'setspv: VI band limits:'
+      do M=1,L_NSPECTV+1
+         print*,m,'-->',BWNV(M),' cm^-1'
+      end do
+      print*,' '
+
+!     Set up mean wavenumbers and wavenumber deltas.  Units of 
+!     wavenumbers is cm^(-1); units of wavelengths is microns.
+
+      do M=1,L_NSPECTV
+         WNOV(M)  = 0.5*(BWNV(M+1)+BWNV(M))
+         DWNV(M)  = BWNV(M+1)-BWNV(M)
+         WAVEV(M) = 1.0E+4/WNOV(M)
+         BLAMV(M) = 0.01/BWNV(M)
+      end do
+      BLAMV(M) = 0.01/BWNV(M) ! wavelength in METERS for aerosol stuff
+!     note M=L_NSPECTV+1 after loop due to Fortran bizarreness
+
+!=======================================================================
+!     Set up stellar spectrum
+
+      write(*,*)'setspv: Interpolating stellar spectrum from the hires data...'
+      call ave_stelspec(STELLAR)
+
+!     Sum the stellar flux, and write out the result.  
+      sum = 0.0  
+      do N=1,L_NSPECTV
+         STELLARF(N) = STELLAR(N) * Fat1AU
+         sum         = sum+STELLARF(N)
+      end do
+      write(6,'("setspv: Stellar flux at 1 AU = ",f7.2," W m-2")') sum
+      print*,' '
+
+
+!=======================================================================
+!     Set up the wavelength independent part of the Rayleigh scattering.
+!     The pressure dependent part will be computed elsewhere (OPTCV).
+!     WAVEV is in microns.  There is no Rayleigh scattering in the IR.
+
+      if(rayleigh) then
+         call calc_rayleigh
+      else
+         print*,'setspv: No Rayleigh scattering, check for NaN in output!'
+         do N=1,L_NSPECTV
+            TAURAY(N) = 1E-16
+         end do
+      endif
+
+      RETURN
+    END subroutine setspv
Index: /trunk/LMDZ.TITAN/libf/phytitan/sfluxi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/sfluxi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/sfluxi.F	(revision 1644)
@@ -0,0 +1,201 @@
+      SUBROUTINE SFLUXI(PLEV,TLEV,DTAUI,TAUCUMI,UBARI,RSFI,WNOI,DWNI,
+     *                  COSBI,WBARI,GWEIGHT,NFLUXTOPI,NFLUXTOPI_nu,
+     *                  FMNETI,fluxupi,fluxdni,fluxupi_nu,
+     *                  FZEROI,TAUGSURF)
+
+      use radinc_h
+      use radcommon_h, only: planckir, tlimit,sigma
+      use comcstfi_mod, only: pi
+
+      implicit none
+
+      integer NLEVRAD, L, NW, NG, NTS, NTT
+
+      real*8 TLEV(L_LEVELS), PLEV(L_LEVELS)
+      real*8 TAUCUMI(L_LEVELS,L_NSPECTI,L_NGAUSS)
+      real*8 FMNETI(L_NLAYRAD)
+      real*8 WNOI(L_NSPECTI), DWNI(L_NSPECTI)
+      real*8 DTAUI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+      real*8 FMUPI(L_NLEVRAD), FMDI(L_NLEVRAD)
+      real*8 COSBI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+      real*8 WBARI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
+      real*8 GWEIGHT(L_NGAUSS), NFLUXTOPI
+      real*8 NFLUXTOPI_nu(L_NSPECTI)
+      real*8 fluxupi_nu(L_NLAYRAD,L_NSPECTI)
+      real*8 FTOPUP
+
+      real*8 UBARI, RSFI, TSURF, BSURF, TTOP, BTOP, TAUTOP
+      real*8 PLANCK, PLTOP
+      real*8 fluxupi(L_NLAYRAD), fluxdni(L_NLAYRAD)
+      real*8 FZEROI(L_NSPECTI)
+      real*8 taugsurf(L_NSPECTI,L_NGAUSS-1), fzero
+
+      real*8 fup_tmp(L_NSPECTI),fdn_tmp(L_NSPECTI)
+      real*8 PLANCKSUM,PLANCKREF
+
+
+C======================================================================C
+ 
+      NLEVRAD = L_NLEVRAD
+ 
+
+C     ZERO THE NET FLUXES
+    
+      NFLUXTOPI = 0.0D0
+
+      DO NW=1,L_NSPECTI
+        NFLUXTOPI_nu(NW) = 0.0D0
+        DO L=1,L_NLAYRAD
+           FLUXUPI_nu(L,NW) = 0.0D0
+
+              fup_tmp(nw)=0.0D0
+              fdn_tmp(nw)=0.0D0
+
+        END DO
+      END DO
+
+      DO L=1,L_NLAYRAD
+        FMNETI(L)  = 0.0D0
+        FLUXUPI(L) = 0.0D0
+        FLUXDNI(L) = 0.0D0
+      END DO
+ 
+C     WE NOW ENTER A MAJOR LOOP OVER SPECTRAL INTERVALS IN THE INFRARED
+C     TO CALCULATE THE NET FLUX IN EACH SPECTRAL INTERVAL
+
+      TTOP  = TLEV(2)  ! JL12 why not (1) ???
+      TSURF = TLEV(L_LEVELS)
+
+      NTS   = int(TSURF*NTfac)-NTstar+1
+      NTT   = int(TTOP *NTfac)-NTstar+1
+
+!JL12 corrects the surface planck function so that its integral is equal to sigma Tsurf^4
+!JL12   this ensure that no flux is lost due to:
+!JL12          -truncation of the planck function at high/low wavenumber
+!JL12          -numerical error during first spectral integration
+!JL12          -discrepancy between Tsurf and NTS/NTfac
+      PLANCKSUM=0.d0
+      PLANCKREF=TSURF*TSURF
+      PLANCKREF=sigma*PLANCKREF*PLANCKREF
+      DO NW=1,L_NSPECTI
+         PLANCKSUM=PLANCKSUM+PLANCKIR(NW,NTS)*DWNI(NW)
+      ENDDO
+      PLANCKSUM=PLANCKREF/(PLANCKSUM*Pi)
+!JL12
+
+      DO 501 NW=1,L_NSPECTI
+
+C       SURFACE EMISSIONS - INDEPENDENT OF GAUSS POINTS
+        BSURF = (1.-RSFI)*PLANCKIR(NW,NTS)*PLANCKSUM !JL12 plancksum see above
+        PLTOP = PLANCKIR(NW,NTT)
+
+C  If FZEROI(NW) = 1, then the k-coefficients are zero - skip to the
+C  special Gauss point at the end.
+ 
+        FZERO = FZEROI(NW)
+        IF(FZERO.ge.0.99) goto 40
+ 
+        DO NG=1,L_NGAUSS-1
+         
+          if(TAUGSURF(NW,NG).lt. TLIMIT) then
+            fzero = fzero + (1.0D0-FZEROI(NW))*GWEIGHT(NG)
+            goto 30
+          end if
+
+C         SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE IR
+C         CALCULATE THE DOWNWELLING RADIATION AT THE TOP OF THE MODEL
+C         OR THE TOP LAYER WILL COOL TO SPACE UNPHYSICALLY
+ 
+!          TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
+          TAUTOP = TAUCUMI(2,NW,NG)
+          BTOP   = (1.0D0-EXP(-TAUTOP/UBARI))*PLTOP
+ 
+C         WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
+C         CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
+C         WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER 
+          
+          CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
+     *                TAUCUMI(1,NW,NG),
+     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
+     *                BSURF,FTOPUP,FMUPI,FMDI)
+
+
+
+C         NOW CALCULATE THE CUMULATIVE IR NET FLUX
+
+          NFLUXTOPI = NFLUXTOPI+FTOPUP*DWNI(NW)*GWEIGHT(NG)*
+     *                           (1.0D0-FZEROI(NW))
+
+c         and same thing by spectral band... (RDW)
+          NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW)
+     *      +FTOPUP*DWNI(NW)*GWEIGHT(NG)*(1.0D0-FZEROI(NW))
+
+
+          DO L=1,L_NLEVRAD-1
+
+C           CORRECT FOR THE WAVENUMBER INTERVALS
+
+            FMNETI(L)  = FMNETI(L)+(FMUPI(L)-FMDI(L))*DWNI(NW)*
+     *                              GWEIGHT(NG)*(1.0D0-FZEROI(NW))
+            FLUXUPI(L) = FLUXUPI(L) + FMUPI(L)*DWNI(NW)*GWEIGHT(NG)*
+     *                                (1.0D0-FZEROI(NW))
+            FLUXDNI(L) = FLUXDNI(L) + FMDI(L)*DWNI(NW)*GWEIGHT(NG)*
+     *                                (1.0D0-FZEROI(NW))
+
+c         and same thing by spectral band... (RW)
+            FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW) + 
+     *                FMUPI(L)*DWNI(NW)*GWEIGHT(NG)*(1.0D0-FZEROI(NW))
+
+          END DO
+
+   30     CONTINUE
+
+       END DO       !End NGAUSS LOOP
+
+   40  CONTINUE
+
+C      SPECIAL 17th Gauss point
+
+       NG     = L_NGAUSS
+
+!       TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
+       TAUTOP = TAUCUMI(2,NW,NG)
+       BTOP   = (1.0D0-EXP(-TAUTOP/UBARI))*PLTOP
+
+C      WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
+C      CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
+C      WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER 
+
+
+       CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
+     *                TAUCUMI(1,NW,NG),
+     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
+     *                BSURF,FTOPUP,FMUPI,FMDI)
+ 
+C      NOW CALCULATE THE CUMULATIVE IR NET FLUX
+
+       NFLUXTOPI = NFLUXTOPI+FTOPUP*DWNI(NW)*FZERO
+
+c         and same thing by spectral band... (RW)
+          NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW)
+     *      +FTOPUP*DWNI(NW)*FZERO
+
+       DO L=1,L_NLEVRAD-1
+
+C        CORRECT FOR THE WAVENUMBER INTERVALS
+
+         FMNETI(L)  = FMNETI(L)+(FMUPI(L)-FMDI(L))*DWNI(NW)*FZERO
+         FLUXUPI(L) = FLUXUPI(L) + FMUPI(L)*DWNI(NW)*FZERO
+         FLUXDNI(L) = FLUXDNI(L) + FMDI(L)*DWNI(NW)*FZERO
+
+c         and same thing by spectral band... (RW)
+         FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW) + FMUPI(L)*DWNI(NW)*FZERO
+
+       END DO
+
+  501 CONTINUE      !End Spectral Interval LOOP
+
+C *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE INFRARED****
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/sfluxv.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/sfluxv.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/sfluxv.F	(revision 1644)
@@ -0,0 +1,189 @@
+      SUBROUTINE SFLUXV(DTAUV,TAUV,TAUCUMV,RSFV,DWNV,WBARV,COSBV,
+     *                  UBAR0,STEL,GWEIGHT,NFLUXTOPV,FLUXTOPVDN,
+     *                  NFLUXOUTV_nu,NFLUXGNDV_nu,
+     *                  FMNETV,FLUXUPV,FLUXDNV,FZEROV,taugsurf)
+
+      use radinc_h
+      use radcommon_h, only: tlimit
+
+      implicit none
+
+      real*8 FMNETV(L_NLAYRAD)
+      real*8 TAUCUMV(L_LEVELS,L_NSPECTV,L_NGAUSS)
+      real*8 TAUV(L_NLEVRAD,L_NSPECTV,L_NGAUSS)
+      real*8 DTAUV(L_NLAYRAD,L_NSPECTV,L_NGAUSS), DWNV(L_NSPECTV)
+      real*8 FMUPV(L_NLAYRAD), FMDV(L_NLAYRAD)
+      real*8 COSBV(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+      real*8 WBARV(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
+      real*8 STEL(L_NSPECTV)
+      real*8 FLUXUPV(L_NLAYRAD), FLUXDNV(L_NLAYRAD)
+      real*8 NFLUXTOPV, FLUXUP, FLUXDN,FLUXTOPVDN
+      real*8 NFLUXOUTV_nu(L_NSPECTV)
+      real*8 NFLUXGNDV_nu(L_NSPECTV)
+      real*8 GWEIGHT(L_NGAUSS)
+
+      integer L, NG, NW, NG1,k
+      real*8 ubar0, f0pi, btop, bsurf, taumax, eterm
+      real*8 rsfv(L_NSPECTV) ! Spectral dependency added by MT2015.
+      real*8 FZEROV(L_NSPECTV)
+
+      real*8 DIFFV, DIFFVT
+      real*8 taugsurf(L_NSPECTV,L_NGAUSS-1), fzero
+
+C======================================================================C
+
+      TAUMAX = L_TAUMAX
+
+C     ZERO THE NET FLUXES
+
+      NFLUXTOPV = 0.0
+      FLUXTOPVDN = 0.0
+
+      DO NW=1,L_NSPECTV
+         NFLUXOUTV_nu(NW)=0.0
+         NFLUXGNDV_nu(NW)=0.0
+      END DO
+
+      DO L=1,L_NLAYRAD
+        FMNETV(L)  = 0.0
+        FLUXUPV(L) = 0.0
+        FLUXDNV(L) = 0.0
+      END DO
+
+      DIFFVT = 0.0
+
+C     WE NOW ENTER A MAJOR LOOP OVER SPECTRAL INTERVALS IN THE VISIBLE
+C     TO CALCULATE THE NET FLUX IN EACH SPECTRAL INTERVAL
+
+      DO 500 NW=1,L_NSPECTV
+      
+        F0PI = STEL(NW)
+
+        FZERO = FZEROV(NW)
+        IF(FZERO.ge.0.99) goto 40
+        DO NG=1,L_NGAUSS-1
+
+          if(TAUGSURF(NW,NG) .lt. TLIMIT) then
+
+            fzero = fzero + (1.0-FZEROV(NW))*GWEIGHT(NG)
+
+            goto 30
+          end if
+
+C         SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE VISIBLE
+
+          BTOP  = 0.0
+          !BSURF = 0./0. ! why was this here?
+          BSURF = 0.
+C         LOOP OVER THE NTERMS BEGINNING HERE
+ 
+
+!      FACTOR    = 1.0D0 - WDEL(1)*CDEL(1)**2
+!      TAU(1)    = TDEL(1)*FACTOR
+
+
+          ETERM = MIN(TAUV(L_NLEVRAD,NW,NG),TAUMAX)
+          BSURF = RSFV(NW)*UBAR0*STEL(NW)*EXP(-ETERM/UBAR0)
+
+C         WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
+C         CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
+C         WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
+C 
+C         FUW AND FDW ARE WORKING FLUX ARRAYS THAT WILL BE USED TO 
+C         RETURN FLUXES FOR A GIVEN NT
+
+
+          CALL GFLUXV(DTAUV(1,NW,NG),TAUV(1,NW,NG),TAUCUMV(1,NW,NG),
+     *                WBARV(1,NW,NG),COSBV(1,NW,NG),UBAR0,F0PI,RSFV(NW),    
+     *                BTOP,BSURF,FMUPV,FMDV,DIFFV,FLUXUP,FLUXDN)
+
+C         NOW CALCULATE THE CUMULATIVE VISIBLE NET FLUX 
+
+          NFLUXTOPV = NFLUXTOPV+(FLUXUP-FLUXDN)*GWEIGHT(NG)*
+     *                          (1.0-FZEROV(NW))
+          FLUXTOPVDN = FLUXTOPVDN+FLUXDN*GWEIGHT(NG)*
+     *                          (1.0-FZEROV(NW))
+          DO L=1,L_NLAYRAD
+            FMNETV(L)=FMNETV(L)+( FMUPV(L)-FMDV(L) )*
+     *                           GWEIGHT(NG)*(1.0-FZEROV(NW))
+            FLUXUPV(L) = FLUXUPV(L) + FMUPV(L)*GWEIGHT(NG)*
+     *                   (1.0-FZEROV(NW))
+            FLUXDNV(L) = FLUXDNV(L) + FMDV(L)*GWEIGHT(NG)*
+     *                   (1.0-FZEROV(NW))
+          END DO
+
+c     band-resolved flux leaving TOA (RDW)
+          NFLUXOUTV_nu(NW) = NFLUXOUTV_nu(NW)
+     *      +FLUXUP*GWEIGHT(NG)*(1.0-FZEROV(NW))
+
+c     band-resolved flux at ground (RDW)
+          NFLUXGNDV_nu(NW) = NFLUXGNDV_nu(NW)
+     *      +FMDV(L_NLAYRAD)*GWEIGHT(NG)*(1.0-FZEROV(NW))
+
+
+C         THE DIFFUSE COMPONENT OF THE DOWNWARD STELLAR FLUX
+
+          DIFFVT = DIFFVT + DIFFV*GWEIGHT(NG)*(1.0-FZEROV(NW))
+
+   30     CONTINUE 
+
+        END DO   ! the Gauss loop 
+
+   40   continue 
+C       Special 17th Gauss point
+
+        NG = L_NGAUSS
+
+C       SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE VISIBLE
+ 
+        BTOP = 0.0
+
+C       LOOP OVER THE NTERMS BEGINNING HERE
+ 
+        ETERM = MIN(TAUV(L_NLEVRAD,NW,NG),TAUMAX)
+        BSURF = RSFV(NW)*UBAR0*STEL(NW)*EXP(-ETERM/UBAR0)
+
+
+C       WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
+C       CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
+C       WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
+C 
+C       FUW AND FDW ARE WORKING FLUX ARRAYS THAT WILL BE USED TO 
+C       RETURN FLUXES FOR A GIVEN NT
+
+        CALL GFLUXV(DTAUV(1,NW,NG),TAUV(1,NW,NG),TAUCUMV(1,NW,NG),
+     *              WBARV(1,NW,NG),COSBV(1,NW,NG),UBAR0,F0PI,RSFV(NW),
+     *              BTOP,BSURF,FMUPV,FMDV,DIFFV,FLUXUP,FLUXDN)
+
+
+C       NOW CALCULATE THE CUMULATIVE VISIBLE NET FLUX 
+
+        NFLUXTOPV = NFLUXTOPV+(FLUXUP-FLUXDN)*FZERO
+        FLUXTOPVDN = FLUXTOPVDN+FLUXDN*FZERO
+        DO L=1,L_NLAYRAD
+          FMNETV(L)=FMNETV(L)+( FMUPV(L)-FMDV(L) )*FZERO
+          FLUXUPV(L) = FLUXUPV(L) + FMUPV(L)*FZERO
+          FLUXDNV(L) = FLUXDNV(L) + FMDV(L)*FZERO
+        END DO
+
+c     band-resolved flux leaving TOA (RDW)
+          NFLUXOUTV_nu(NW) = NFLUXOUTV_nu(NW)
+     *      +FLUXUP*FZERO
+
+c     band-resolved flux at ground (RDW)
+          NFLUXGNDV_nu(NW) = NFLUXGNDV_nu(NW)+FMDV(L_NLAYRAD)*FZERO
+
+
+C       THE DIFFUSE COMPONENT OF THE DOWNWARD STELLAR FLUX
+
+        DIFFVT = DIFFVT + DIFFV*FZERO
+
+
+  500 CONTINUE
+
+
+C     *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE VISIBLE*****
+
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/slab_ice_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/slab_ice_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/slab_ice_h.F90	(revision 1644)
@@ -0,0 +1,39 @@
+      module slab_ice_h
+
+      implicit none
+
+! noceanmx : number of oceanic layers
+      integer, parameter :: noceanmx = 2 ! number of oceanic layers
+
+      real, parameter :: ice_cap=2.05e+03       ! J/kg/K
+      real, parameter :: ice_den=945.0          ! kg/m3
+      real, parameter :: ice_lat=0.334e+05      ! J/kg
+      real, parameter :: ice_cond=2.1           ! W/m/K
+      real, parameter :: alb_ice_min=0.2       
+      real, parameter :: alb_ice_max=0.65 
+      real, parameter :: alb_ocean=0.07
+      real, parameter :: ice_frac_min=0.0001
+      real, parameter :: ice_frac_max=1.!0.9999
+      real, parameter :: h_alb_ice=0.5*ice_den   !m->kg/m2
+      real, parameter :: h_ice_thin=0.2*ice_den
+      real, parameter :: h_ice_thick=2.5*ice_den
+      real, parameter :: h_ice_min=0.000001*ice_den
+      real, parameter :: h_ice_max=10000.0
+
+      real, parameter :: capcalocean=50.*4.228e+06!121635.0
+      real, parameter :: capcalseaice=5.1444e+06*0.15
+      real, parameter :: capcalsno=2.3867e+06*0.15
+
+      real, parameter :: epsfra=1.0E-05
+      real, parameter :: soil_hdiff=25000.0
+
+!      real, parameter :: calice=1.0/(5.1444e+06*0.15)
+!      real, parameter :: tau_gl=86400.*5.
+!      real, parameter :: calsno=1./(2.3867e+06*0.15)
+
+
+
+
+
+
+      end module slab_ice_h
Index: /trunk/LMDZ.TITAN/libf/phytitan/soil.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/soil.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/soil.F	(revision 1644)
@@ -0,0 +1,223 @@
+      subroutine soil(ngrid,nsoil,firstcall,lastcall,
+     &          therm_i,
+     &          timestep,tsurf,tsoil,
+     &          capcal,fluxgrd)
+
+      use comsoil_h, only: layer, mlayer, volcapa, inertiedat
+      use comcstfi_mod, only: pi
+      use time_phylmdz_mod, only: daysec
+      use planete_mod, only: year_day
+      use geometry_mod, only: longitude, latitude ! in radians
+
+      implicit none
+
+!-----------------------------------------------------------------------
+!  Author: Ehouarn Millour
+!
+!  Purpose: Compute soil temperature using an implict 1st order scheme
+!  
+!  Note: depths of layers and mid-layers, soil thermal inertia and 
+!        heat capacity are commons in comsoil.h
+!-----------------------------------------------------------------------
+
+c-----------------------------------------------------------------------
+!  arguments
+!  ---------
+!  inputs:
+      integer,intent(in) :: ngrid	! number of (horizontal) grid-points 
+      integer,intent(in) :: nsoil	! number of soil layers 
+      logical,intent(in) :: firstcall ! identifier for initialization call 
+      logical,intent(in) :: lastcall
+      real,intent(in) :: therm_i(ngrid,nsoil) ! thermal inertia
+      real,intent(in) :: timestep	    ! time step
+      real,intent(in) :: tsurf(ngrid)   ! surface temperature
+! outputs:
+      real,intent(out) :: tsoil(ngrid,nsoil) ! soil (mid-layer) temperature
+      real,intent(out) :: capcal(ngrid) ! surface specific heat
+      real,intent(out) :: fluxgrd(ngrid) ! surface diffusive heat flux
+
+! local saved variables:
+      real,dimension(:,:),save,allocatable :: mthermdiff ! mid-layer thermal diffusivity
+      real,dimension(:,:),save,allocatable :: thermdiff ! inter-layer thermal diffusivity
+      real,dimension(:),save,allocatable :: coefq ! q_{k+1/2} coefficients
+      real,dimension(:,:),save,allocatable :: coefd ! d_k coefficients
+      real,dimension(:,:),save,allocatable :: alph ! alpha_k coefficients
+      real,dimension(:,:),save,allocatable :: beta ! beta_k coefficients
+      real,save :: mu
+!$OMP THREADPRIVATE(mthermdiff,thermdiff,coefq,coefd,alph,beta,mu)
+            
+! local variables:
+      integer ig,ik
+      real :: inertia_min,inertia_max
+      real :: diurnal_skin ! diurnal skin depth (m)
+      real :: annual_skin ! anuual skin depth (m)
+
+! 0. Initialisations and preprocessing step
+      if (firstcall) then
+      ! note: firstcall is set to .true. or .false. by the caller
+      !       and not changed by soil.F 
+
+      ALLOCATE(mthermdiff(ngrid,0:nsoil-1)) ! mid-layer thermal diffusivity
+      ALLOCATE(thermdiff(ngrid,nsoil-1))    ! inter-layer thermal diffusivity
+      ALLOCATE(coefq(0:nsoil-1))              ! q_{k+1/2} coefficients
+      ALLOCATE(coefd(ngrid,nsoil-1))        ! d_k coefficients
+      ALLOCATE(alph(ngrid,nsoil-1))         ! alpha_k coefficients
+      ALLOCATE(beta(ngrid,nsoil-1))         ! beta_k coefficients
+
+! 0.1 Build mthermdiff(:), the mid-layer thermal diffusivities
+      do ig=1,ngrid
+        do ik=0,nsoil-1
+	  mthermdiff(ig,ik)=therm_i(ig,ik+1)*therm_i(ig,ik+1)/volcapa
+!	  write(*,*),'soil: ik: ',ik,' mthermdiff:',mthermdiff(ig,ik)
+	enddo
+      enddo
+
+! 0.2 Build thermdiff(:), the "interlayer" thermal diffusivities
+      do ig=1,ngrid
+        do ik=1,nsoil-1
+      thermdiff(ig,ik)=((layer(ik)-mlayer(ik-1))*mthermdiff(ig,ik)
+     &                +(mlayer(ik)-layer(ik))*mthermdiff(ig,ik-1))
+     &                    /(mlayer(ik)-mlayer(ik-1))
+!	write(*,*),'soil: ik: ',ik,' thermdiff:',thermdiff(ig,ik)
+	enddo
+      enddo
+
+! 0.3 Build coefficients mu, q_{k+1/2}, d_k, alpha_k and capcal
+      ! mu
+      mu=mlayer(0)/(mlayer(1)-mlayer(0))
+
+      ! q_{1/2}
+      coefq(0)=volcapa*layer(1)/timestep
+	! q_{k+1/2}
+        do ik=1,nsoil-1
+          coefq(ik)=volcapa*(layer(ik+1)-layer(ik))
+     &                 /timestep
+	enddo
+
+      do ig=1,ngrid
+	! d_k
+	do ik=1,nsoil-1
+	  coefd(ig,ik)=thermdiff(ig,ik)/(mlayer(ik)-mlayer(ik-1))
+	enddo
+	
+	! alph_{N-1}
+	alph(ig,nsoil-1)=coefd(ig,nsoil-1)/
+     &                  (coefq(nsoil-1)+coefd(ig,nsoil-1))
+        ! alph_k
+        do ik=nsoil-2,1,-1
+	  alph(ig,ik)=coefd(ig,ik)/(coefq(ik)+coefd(ig,ik+1)*
+     &                              (1.-alph(ig,ik+1))+coefd(ig,ik))
+	enddo
+
+        ! capcal
+! Cstar
+        capcal(ig)=volcapa*layer(1)+
+     &              (thermdiff(ig,1)/(mlayer(1)-mlayer(0)))*
+     &              (timestep*(1.-alph(ig,1)))
+! Cs
+        capcal(ig)=capcal(ig)/(1.+mu*(1.0-alph(ig,1))*
+     &                         thermdiff(ig,1)/mthermdiff(ig,0))
+      !write(*,*)'soil: ig=',ig,' capcal(ig)=',capcal(ig)
+      enddo ! of do ig=1,ngrid
+      
+      ! Additional checks: is the vertical discretization sufficient
+      ! to resolve diurnal and annual waves?
+      do ig=1,ngrid
+        ! extreme inertia for this column
+        inertia_min=minval(inertiedat(ig,:))
+        inertia_max=maxval(inertiedat(ig,:))
+        ! diurnal and annual skin depth
+        diurnal_skin=(inertia_min/volcapa)*sqrt(daysec/pi)
+        annual_skin=(inertia_max/volcapa)*sqrt(year_day*daysec/pi)
+        if (0.5*diurnal_skin<layer(1)) then
+        ! one should have the fist layer be at least half of diurnal skin depth
+          write(*,*) "soil Error: grid point ig=",ig
+          write(*,*) "            longitude=",longitude(ig)*(180./pi)
+          write(*,*) "             latitude=",latitude(ig)*(180./pi)
+          write(*,*) "  first soil layer depth ",layer(1)
+          write(*,*) "  not small enough for a diurnal skin depth of ",
+     &                diurnal_skin
+          write(*,*) " change soil layer distribution (comsoil_h.F90)"
+          stop
+        endif
+        if (2.*annual_skin>layer(nsoil)) then
+        ! one should have the full soil be at least twice the diurnal skin depth
+          write(*,*) "soil Error: grid point ig=",ig
+          write(*,*) "            longitude=",longitude(ig)*(180./pi)
+          write(*,*) "             latitude=",latitude(ig)*(180./pi)
+          write(*,*) "  total soil layer depth ",layer(nsoil)
+          write(*,*) "  not large enough for an annual skin depth of ",
+     &                annual_skin
+          write(*,*) " change soil layer distribution (comsoil_h.F90)"
+          stop
+        endif
+      enddo ! of do ig=1,ngrid
+      
+      else ! of if (firstcall)
+
+
+!  1. Compute soil temperatures
+! First layer:
+      do ig=1,ngrid
+        tsoil(ig,1)=(tsurf(ig)+mu*beta(ig,1)*
+     &                         thermdiff(ig,1)/mthermdiff(ig,0))/
+     &              (1.+mu*(1.0-alph(ig,1))*
+     &               thermdiff(ig,1)/mthermdiff(ig,0))
+      enddo
+! Other layers:
+      do ik=1,nsoil-1
+        do ig=1,ngrid
+	  tsoil(ig,ik+1)=alph(ig,ik)*tsoil(ig,ik)+beta(ig,ik)
+	enddo
+      enddo
+      
+      endif! of if (firstcall)
+
+!  2. Compute beta coefficients (preprocessing for next time step)
+! Bottom layer, beta_{N-1}
+      do ig=1,ngrid
+        beta(ig,nsoil-1)=coefq(nsoil-1)*tsoil(ig,nsoil)
+     &                   /(coefq(nsoil-1)+coefd(ig,nsoil-1))
+      enddo
+! Other layers
+      do ik=nsoil-2,1,-1
+        do ig=1,ngrid
+	  beta(ig,ik)=(coefq(ik)*tsoil(ig,ik+1)+
+     &                 coefd(ig,ik+1)*beta(ig,ik+1))/
+     &                 (coefq(ik)+coefd(ig,ik+1)*(1.0-alph(ig,ik+1))
+     &                  +coefd(ig,ik))
+	enddo
+      enddo
+
+
+!  3. Compute surface diffusive flux & calorific capacity
+      do ig=1,ngrid
+! Cstar
+!        capcal(ig)=volcapa(ig,1)*layer(ig,1)+
+!     &              (thermdiff(ig,1)/(mlayer(ig,1)-mlayer(ig,0)))*
+!     &              (timestep*(1.-alph(ig,1)))
+! Fstar
+
+!         print*,'this far in soil 1'
+!         print*,'thermdiff=',thermdiff(ig,1)
+!         print*,'mlayer=',mlayer
+!         print*,'beta=',beta(ig,1)
+!         print*,'alph=',alph(ig,1)
+!         print*,'tsoil=',tsoil(ig,1)
+
+        fluxgrd(ig)=(thermdiff(ig,1)/(mlayer(1)-mlayer(0)))*
+     &              (beta(ig,1)+(alph(ig,1)-1.0)*tsoil(ig,1))
+
+!        mu=mlayer(ig,0)/(mlayer(ig,1)-mlayer(ig,0))
+!        capcal(ig)=capcal(ig)/(1.+mu*(1.0-alph(ig,1))*
+!     &                         thermdiff(ig,1)/mthermdiff(ig,0))
+! Fs
+        fluxgrd(ig)=fluxgrd(ig)+(capcal(ig)/timestep)*
+     &              (tsoil(ig,1)*(1.+mu*(1.0-alph(ig,1))*
+     &                         thermdiff(ig,1)/mthermdiff(ig,0))
+     &               -tsurf(ig)-mu*beta(ig,1)*
+     &                          thermdiff(ig,1)/mthermdiff(ig,0))
+      enddo
+
+      end
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/soil_settings.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/soil_settings.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/soil_settings.F	(revision 1644)
@@ -0,0 +1,365 @@
+      subroutine soil_settings(nid,ngrid,nsoil,tsurf,tsoil,indextime)
+
+!      use netcdf
+      use comsoil_h, only: layer, mlayer, inertiedat, volcapa,
+     &                     lay1_soil, alpha_soil
+      use iostart, only: inquire_field_ndims, get_var, get_field,
+     &                   inquire_field, inquire_dimension_length
+      implicit none
+
+!======================================================================
+!  Author: Ehouarn Millour (07/2006)
+!
+!  Purpose: Read and/or initialise soil depths and properties
+!
+! Modifications: Aug.2010 EM : use NetCDF90 to load variables (enables using
+!                      r4 or r8 restarts independently of having compiled
+!                      the GCM in r4 or r8)
+!                June 2013 TN : Possibility to read files with a time axis
+!
+!
+!  This subroutine reads from a NetCDF file (opened by the caller)
+!  of "startfi.nc" format.
+!  The various actions and variable read/initialized are:
+!  1. Check out the number of soil layers (in datafile); if it isn't equal
+!     to nsoil, then some interpolation will be required
+!     Also check if data in file "startfi.nc" is in older format (ie:
+!     thermal inertia was depth-independent; and there was no "depth"
+!     coordinate.
+!     Read/build layer (and midlayer) depths
+!  2. Read volumetric specific heat (or initialise it to default value)
+!  3. Read Thermal inertia
+!  4. Read soil temperatures
+!  5. Interpolate thermal inertia and temperature on the new grid, if
+!     necessary
+!======================================================================
+
+!======================================================================
+!  arguments
+!  ---------
+!  inputs:
+      integer,intent(in) :: nid	! Input Netcdf file ID 
+      integer,intent(in) :: ngrid	! # of horizontal grid points
+      integer,intent(in) :: nsoil	! # of soil layers
+      real,intent(in) :: tsurf(ngrid)   ! surface temperature
+      integer,intent(in) :: indextime	! position on time axis
+!  output:
+      real,intent(out) :: tsoil(ngrid,nsoil)	! soil temperature
+
+!======================================================================
+! local variables:
+      integer ierr	! status (returned by NetCDF functions)
+      integer nvarid	! ID of NetCDF variable
+      integer dimid	! ID of NetCDF dimension
+      integer dimlen	! length along the "depth" dimension
+      integer ndims	! # of dimensions of read <inertiedat> data
+      integer ig,iloop	! loop counters
+      
+      integer edges(3),corner(3) ! to read a specific time
+
+      logical :: olddepthdef=.false. ! flag
+      logical :: interpol=.false. ! flag: true if interpolation will be requiered
+
+      ! to store "old" values
+      real,dimension(:),allocatable :: surfinertia !surface thermal inertia
+      real,dimension(:),allocatable :: oldmlayer
+      real,dimension(:,:),allocatable :: oldinertiedat
+      real,dimension(:,:),allocatable :: oldtsoil
+      ! for interpolation
+      real,dimension(:),allocatable :: oldgrid
+      real,dimension(:),allocatable :: oldval
+      real,dimension(:),allocatable :: newval
+
+      real malpha,mlay1_soil ! coefficients for building layers
+      real xmin,xmax ! to display min and max of a field
+
+      real,parameter :: default_volcapa=1.e6
+
+      logical :: found,ok
+!======================================================================
+! 1. Depth coordinate
+! -------------------
+! 1.1 Start by reading how many layers of soil there are
+        dimlen=inquire_dimension_length("subsurface_layers")
+
+        if (dimlen.ne.nsoil) then
+	! if dimlen doesn't match nsoil, then interpolation of
+	! soil temperatures and thermal inertia will be requiered
+	  interpol=.true.
+	endif
+
+        ! allocate oldmlayer  
+        allocate(oldmlayer(dimlen),stat=ierr)
+        if (ierr.ne.0) then
+          write(*,*) 'soil_settings: failed allocation of oldmlayer!'
+          stop
+        endif
+
+        ! check if olmlayer distribution matches current one
+        call get_var("soildepth",oldmlayer,found)
+        if (found) then
+          malpha=oldmlayer(2)/oldmlayer(1)
+          if ((abs(malpha-alpha_soil)/alpha_soil).gt.1.e-6) then
+            ! alpha values are too different, intepolation needed
+            interpol=.true.
+          endif
+          ! check if loaded mid-layer depth value differs from current one
+          if (abs((oldmlayer(1)-lay1_soil*alpha_soil**(-1./2.))/
+     &             (lay1_soil*alpha_soil**(-1./2.))).gt.1.e-6) then
+            interpol=.true.
+          endif
+        endif
+
+        if (interpol) then
+          write(*,*)'soil_settings: Interpolation of soil temperature ',
+     &              'and thermal inertia will be required!'
+        endif
+        
+! 1.2 Find out the # of dimensions <inertiedat> was defined as using
+      ndims=inquire_field_ndims("inertiedat")
+! 1.3 Read depths values or set olddepthdef flag and values
+      if (ndims.eq.1) then ! we know that there is none
+        write(*,*)'soil_settings: no <soildepth> field expected'
+	write(*,*)'building one mimicking old definitions'
+        olddepthdef=.true.
+	interpol=.true.
+        ! allocate oldmlayer
+        if (.not.allocated(oldmlayer)) then
+          allocate(oldmlayer(dimlen),stat=ierr)
+          if (ierr.ne.0) then
+            write(*,*) 'soil_settings: failed allocation of oldmlayer!'
+            stop
+          endif
+        endif
+	do iloop=1,dimlen
+	  oldmlayer(iloop)=sqrt(887.75/3.14)*((2.**(iloop-0.5))-1.)
+	enddo
+      else ! Look for depth 
+        ! read <depth> coordinate
+        if (interpol) then !put values in oldmlayer
+          call get_var("soildepth",oldmlayer,found)
+          if (.not.found) then
+            write(*,*)'soil_settings: Problem while reading <soildepth>'
+          endif
+        else ! put values in mlayer
+          call get_var("soildepth",mlayer,found)
+          print*,"mlayer",mlayer
+	  if (.not.found) then
+            write(*,*)'soil_settings: Problem while reading <soildepth>'
+          endif
+        endif !of if (interpol)
+      endif !of if (ndims.eq.1)
+! 1.4 Build mlayer(), if necessary
+      if (interpol) then
+      ! default mlayer distribution, following a power law:
+      !  mlayer(k)=lay1_soil*alpha_soil**(k-1/2)
+        do iloop=0,nsoil-1
+	  mlayer(iloop)=lay1_soil*(alpha_soil**(iloop-0.5))
+        enddo
+      endif
+! 1.5 Build layer(); following the same law as mlayer()
+      ! Assuming layer distribution follows mid-layer law:
+      ! layer(k)=lay1_soil*alpha_soil**(k-1)
+      mlay1_soil=sqrt(mlayer(0)*mlayer(1))
+      malpha=mlayer(1)/mlayer(0)
+      ! Check that these values are the same as those prescibed for mlayers
+      if ((abs(mlay1_soil-lay1_soil)/lay1_soil).gt.1.e-6) then
+         write(*,*) "soil_settings error: mlay1_soil=",mlay1_soil
+         write(*,*) " does not match comsoil_h lay1_soil=",lay1_soil
+         stop
+      endif
+      if ((abs(malpha-alpha_soil)/alpha_soil).gt.1.e-6) then
+         write(*,*) "soil_settings error: malpha=",malpha
+         write(*,*) " does not match comsoil_h alpha_soil=",alpha_soil
+         stop
+      endif
+      do iloop=1,nsoil
+        layer(iloop)=mlay1_soil*(malpha**(iloop-1))
+      enddo
+
+! 2. Volumetric heat capacity (note: it is declared in comsoil_h)
+! ---------------------------
+! "volcapa" is (so far) 0D and written in "controle" table of startfi file 
+! volcapa is read or set when "controle" is read (see tabfi.F)
+! Just in case, we check here that it is not zero. If it is, we
+! set it to "default_volcapa"
+
+      if (volcapa.le.0.0) then
+        write(*,*)'soil_settings: Warning, volcapa = ',volcapa
+	write(*,*)'               That doesn t seem right'
+        write(*,*)'        Initializing Volumetric heat capacity to ',
+     &             default_volcapa
+	volcapa=default_volcapa
+      endif
+
+! 3. Thermal inertia (note: it is declared in comsoil_h)
+! ------------------
+! 3.1 Look (again) for thermal inertia data (to reset nvarid)
+
+! 3.2 Knowing the # of dimensions <inertidat> was defined as using,
+!     read/build thermal inertia
+
+      if (ndims.eq.1) then ! "old 2D-surface" format
+       write(*,*)'soil_settings: Thermal inertia is only given as surfac
+     &e data!'
+       ! Read Surface thermal inertia
+       allocate(surfinertia(ngrid))
+       call get_field("inertiedat",surfinertia,found)
+       if (.not.found) then
+         write(*,*) "soil_settings: Failed loading <inertiedat>"
+         call abort
+       endif
+       
+       write(*,*)' => Building soil thermal inertia (using reference sur
+     &face thermal inertia)'
+       do iloop=1,nsoil
+         inertiedat(:,iloop)=surfinertia(:)
+       enddo
+       deallocate(surfinertia)
+
+      else ! "3D surface+depth" format
+       if (interpol) then ! put values in oldinertiedat
+         if (.not.allocated(oldinertiedat)) then
+           allocate(oldinertiedat(ngrid,dimlen),stat=ierr)
+           if (ierr.ne.0) then
+            write(*,*) 'soil_settings: failed allocation of ',
+     &                 'oldinertiedat!'
+            stop
+           endif
+         endif ! of if (.not.allocated(oldinertiedat))
+        call get_field("inertiedat",oldinertiedat,found)
+        if (.not.found) then
+          write(*,*) "soil_settings: Failed loading <inertiedat>"
+          call abort
+        endif
+       else ! put values in therm_i
+         call get_field("inertiedat",inertiedat,found)
+         if (.not.found) then
+           write(*,*) "soil_settings: Failed loading <inertiedat>"
+           call abort
+         endif
+!        endif
+       endif ! of if (interpol)
+      endif ! of if (ndims.eq.1)
+      
+! 4. Read soil temperatures
+! -------------------------
+!      ierr=nf90_inq_varid(nid,"tsoil",nvarid)
+      ok=inquire_field("tsoil")
+!      if (ierr.ne.nf90_noerr) then
+      if (.not.ok) then
+        write(*,*)'soil_settings: Field <tsoil> not found!'
+	write(*,*)' => Building <tsoil> from surface values <tsurf>'
+	do iloop=1,nsoil
+	  tsoil(:,iloop)=tsurf(:)
+	enddo
+      else ! <tsoil> found
+       if (interpol) then ! put values in oldtsoil
+         if (.not.allocated(oldtsoil)) then
+           allocate(oldtsoil(ngrid,dimlen),stat=ierr)
+           if (ierr.ne.0) then
+             write(*,*) 'soil_settings: failed allocation of ',
+     &                  'oldtsoil!'
+             stop
+           endif
+         endif
+         call get_field("tsoil",oldtsoil,found)
+         if (.not.found) then
+           write(*,*) "soil_settings: Failed loading <tsoil>"
+           call abort
+         endif
+       else ! put values in tsoil
+         call get_field("tsoil",tsoil,found,timeindex=indextime)
+         if (.not.found) then
+           write(*,*) "soil_settings: Failed loading <tsoil>"
+           call abort
+         endif
+       endif ! of if (interpol) 
+      endif! of if (.not.ok)
+
+! 5. If necessary, interpolate soil temperatures and thermal inertias
+! -------------------------------------------------------------------
+      if (olddepthdef) then
+      ! tsoil needs to be interpolated, but not therm_i
+        allocate(oldgrid(dimlen+1))
+        allocate(oldval(dimlen+1))
+	allocate(newval(nsoil))
+
+        do ig=1,ngrid
+	  ! copy values
+	  oldval(1)=tsurf(ig)
+	  oldval(2:dimlen+1)=oldtsoil(ig,1:dimlen)
+	  ! build vertical coordinate
+	  oldgrid(1)=0. ! ground
+	  oldgrid(2:dimlen+1)=oldmlayer(1:dimlen)*
+     &                (inertiedat(ig,1)/volcapa)
+	  ! interpolate
+	  call interp_line(oldgrid,oldval,dimlen+1,mlayer,newval,nsoil)
+	  ! copy result in tsoil
+	  tsoil(ig,:)=newval(:)
+	enddo
+
+        ! cleanup
+	deallocate(oldgrid)
+	deallocate(oldval)
+	deallocate(newval)
+	interpol=.false. ! no need for interpolation any more      
+      endif !of if (olddepthdef)
+
+      if (interpol) then
+      write(*,*)'soil_settings: Vertical interpolation along new grid'
+      ! interpolate soil temperatures and thermal inertias
+        if (.not.allocated(oldgrid)) then
+          allocate(oldgrid(dimlen+1))
+          allocate(oldval(dimlen+1))
+	  allocate(newval(nsoil))
+        endif
+
+      ! thermal inertia
+        do ig=1,ngrid
+	  ! copy data
+	  oldval(1:dimlen)=oldinertiedat(ig,dimlen)
+	  ! interpolate
+	  call interp_line(oldmlayer,oldval,dimlen,mlayer,newval,nsoil)
+	  !copy result in inertiedat
+	  inertiedat(ig,:)=newval(:)
+	enddo
+        
+      ! soil temperature
+        ! vertical coordinate
+	oldgrid(1)=0.0
+	oldgrid(2:dimlen+1)=oldmlayer(1:dimlen)
+        do ig=1,ngrid
+	  ! data
+	  oldval(1)=tsurf(ig)
+	  oldval(2:dimlen+1)=oldtsoil(ig,1:dimlen)
+	  ! interpolate
+	  call interp_line(oldgrid,oldval,dimlen+1,mlayer,newval,nsoil)
+	  ! copy result in inertiedat
+	  tsoil(ig,:)=newval(:)
+	enddo
+	
+	!cleanup
+        deallocate(oldgrid)
+	deallocate(oldval)
+	deallocate(newval)
+	deallocate(oldinertiedat)
+	deallocate(oldtsoil)
+      endif ! of if (interpol)
+      
+! 6. Report min and max values of soil temperatures and thermal inertias
+! ----------------------------------------------------------------------
+
+      write(*,*)
+      write(*,*)'Soil volumetric heat capacity:',volcapa
+
+      xmin = MINVAL(inertiedat)
+      xmax = MAXVAL(inertiedat)
+      write(*,*)'Soil thermal inertia <inertiedat>:',xmin,xmax
+
+      xmin = 1.0E+20
+      xmax = -1.0E+20
+      xmin = MINVAL(tsoil)
+      xmax = MAXVAL(tsoil)
+      write(*,*)'Soil temperature <tsoil>:',xmin,xmax
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/statto_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/statto_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/statto_mod.F90	(revision 1644)
@@ -0,0 +1,35 @@
+MODULE statto_mod
+IMPLICIT NONE  
+
+!  statto_mod:
+!     This include file controls the production of statistics.
+!     Some variables could be set in a namelist, but it is easier to
+!     do it here since arrays can then be dimensioned using parameters
+!     and values shouldn't have to change too often.   SRL
+
+!     Calculate stats every istats physics timesteps, starting at first
+!     call.  If istats=0 then don't do statistics at all.  Check value
+!     if number of physics timesteps changes.
+	integer istats
+
+!     Calculate itime independent sums and sums of squares,
+!     example, istat=1,istime=1 gives a single time mean
+	integer, parameter :: istime=12
+
+!     Number of 2D and 3D variables on which to do statistics.
+	integer n2dvar, n3dvar
+	parameter (n2dvar = 8, n3dvar = 5)
+
+!     Units for writing stats header and data
+	integer usdata
+
+!     count tab to know the variable record
+        integer count(istime)
+
+!     Record of the number of stores made for each time.
+	integer nstore(istime)
+
+! Size of the "controle" array
+        integer, parameter :: cntrlsize=15
+
+END MODULE statto_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/stelang.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/stelang.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/stelang.F	(revision 1644)
@@ -0,0 +1,121 @@
+      subroutine stelang(kgrid,psilon,pcolon,psilat,pcolat,
+     &                ptim1,ptim2,ptim3,pmu0,pfract, pflat)
+      IMPLICIT NONE
+
+C
+C**** *LW*   - ORGANIZES THE LONGWAVE CALCULATIONS
+C
+C     PURPOSE.
+C     --------
+C          CALCULATES THE STELLAR ANGLE FOR ALL THE POINTS OF THE GRID
+C
+C**   INTERFACE.
+C     ----------
+C      SUBROUTINE STELANG ( KGRID )
+C
+C        EXPLICIT ARGUMENTS :
+C        --------------------
+C     ==== INPUTS  ===
+C
+C PSILON(KGRID)   : SINUS OF THE LONGITUDE
+C PCOLON(KGRID)   : COSINUS OF THE LONGITUDE
+C PSILAT(KGRID)   : SINUS OF THE LATITUDE
+C PCOLAT(KGRID)   : COSINUS OF THE LATITUDE
+C PTIM1           : SIN(DECLI)
+C PTIM2           : COS(DECLI)*COS(TIME)
+C PTIM3           : SIN(DECLI)*SIN(TIME)
+C
+C     ==== OUTPUTS ===
+C
+C PMU0 (KGRID)    : SOLAR ANGLE
+C PFRACT(KGRID)   : DAY FRACTION OF THE TIME INTERVAL
+C
+C        IMPLICIT ARGUMENTS :   NONE
+C        --------------------
+C
+C     METHOD.
+C     -------
+C
+C     EXTERNALS.
+C     ----------
+C
+C         NONE
+C
+C     REFERENCE.
+C     ----------
+C
+C         RADIATIVE PROCESSES IN METEOROLOGIE AND CLIMATOLOGIE
+C         PALTRIDGE AND PLATT
+C
+C     AUTHOR.
+C     -------
+C        FREDERIC HOURDIN
+C
+C     MODIFICATIONS.
+C     --------------
+C        ORIGINAL :90-01-14
+C                  92-02-14 CALCULATIONS DONE THE ENTIER GRID (J.Polcher)
+C-----------------------------------------------------------------------
+C
+C     ------------------------------------------------------------------
+
+C-----------------------------------------------------------------------
+C
+C*      0.1   ARGUMENTS
+C             ---------
+C
+      INTEGER,INTENT(IN) :: kgrid
+      REAL,INTENT(IN) :: ptim1,ptim2,ptim3, pflat
+      REAL,INTENT(IN) :: psilon(kgrid),pcolon(kgrid)
+      REAL,INTENT(IN) :: psilat(kgrid), pcolat(kgrid)
+      REAL,INTENT(OUT) :: pmu0(kgrid),pfract(kgrid)
+C
+      INTEGER jl
+      REAL ztim1,ztim2,ztim3, rap
+C------------------------------------------------------------------------
+C------------------------------------------------------------------------
+C------------------------------------------------------------------------
+C
+C------------------------------------------------------------------------
+C
+C*     1.     INITIALISATION
+C             --------------
+C
+c----- SG: geometry adapted to a flattened planet (Feb2014)
+
+      rap = 1./((1.-pflat)**2)
+
+ 100  CONTINUE
+C
+      DO jl=1,kgrid
+        pmu0(jl)=0.
+        pfract(jl)=0.
+      ENDDO
+C
+C*     1.1     COMPUTATION OF THE SOLAR ANGLE
+C              ------------------------------
+C
+      DO jl=1,kgrid
+        ztim1=psilat(jl)*ptim1*rap
+        ztim2=pcolat(jl)*ptim2
+        ztim3=pcolat(jl)*ptim3
+        pmu0(jl)=ztim1+ztim2*pcolon(jl)+ztim3*psilon(jl)
+	pmu0(jl)=pmu0(jl)/SQRT(pcolat(jl)**2+(rap**2)*(psilat(jl)**2))
+
+      ENDDO
+C
+C*     1.2      DISTINCTION BETWEEN DAY AND NIGHT
+C               ---------------------------------
+C
+      DO jl=1,kgrid
+        IF (pmu0(jl).gt.0.) THEN
+          pfract(jl)=1.
+c       pmu0(jl)=sqrt(1224.*pmu0(jl)*pmu0(jl)+1.)/35.
+      ELSE
+c       pmu0(jl)=0.
+        pfract(jl)=0.
+        ENDIF
+      ENDDO
+C
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/stellarlong.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/stellarlong.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/stellarlong.F	(revision 1644)
@@ -0,0 +1,101 @@
+      SUBROUTINE stellarlong(pday,pstellong)
+      
+      USE planete_mod, ONLY: year_day, peri_day, e_elips, timeperi
+      use comcstfi_mod, only: pi
+      IMPLICIT NONE
+
+c=======================================================================
+c
+c   Objet:
+c   ------
+c
+c      Calcul de la distance soleil-planete et de la declinaison
+c   en fonction du jour de l'annee.
+c
+c
+c   Methode:
+c   --------
+c
+c      Calcul complet de l'elipse
+c
+c   Interface:
+c   ----------
+c
+c      Uncommon comprenant les parametres orbitaux.
+c
+c   Arguments:
+c   ----------
+c
+c   Input:
+c   ------
+c   pday          jour de l'annee (le jour 0 correspondant a l'equinoxe)
+c
+c   Output:
+c   -------
+c   pdist_star     distance entre le soleil et la planete
+c                 ( en unite astronomique pour utiliser la constante 
+c                  solaire terrestre 1370 Wm-2 )
+c   pdecli        declinaison ( en radians )
+c
+c=======================================================================
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+c arguments:
+c ----------
+
+      REAL pday,pdist_star,pdecli,pstellong
+      LOGICAL lwrite
+
+c Local:
+c ------
+
+      REAL zanom,xref,zx0,zdx,zteta,zz
+      INTEGER iter
+
+
+c-----------------------------------------------------------------------
+c calcul de l'angle polaire et de la distance au soleil :
+c -------------------------------------------------------
+
+c  calcul de l'zanomalie moyenne
+
+      zz=(pday-peri_day)/year_day
+      pi=2.*asin(1.)
+      zanom=2.*pi*(zz-nint(zz))
+      xref=abs(zanom)
+
+c  resolution de l'equation horaire  zx0 - e * sin (zx0) = xref
+c  methode de Newton
+
+      zx0=xref+e_elips*sin(xref)
+      DO 110 iter=1,10
+         zdx=-(zx0-e_elips*sin(zx0)-xref)/(1.-e_elips*cos(zx0))
+         if(abs(zdx).le.(1.e-7)) goto 120
+         zx0=zx0+zdx
+110   continue
+120   continue
+      zx0=zx0+zdx
+      if(zanom.lt.0.) zx0=-zx0
+
+c zteta est la longitude solaire
+
+      zteta=2.*atan(sqrt((1.+e_elips)/(1.-e_elips))*tan(zx0/2.))
+
+      pstellong=zteta-timeperi
+
+      IF(pstellong.LT.0.) pstellong=pstellong+2.*pi
+      IF(pstellong.GT.2.*pi) pstellong=pstellong-2.*pi
+c-----------------------------------------------------------------------
+c   sorties eventuelles:
+c   ---------------------
+
+c     IF (lwrite) THEN
+c        PRINT*,'jour de l"annee   :',pday
+c        PRINT*,'distance au soleil (en unite astronomique) :',pdist_star
+c        PRINT*,'declinaison (en degres) :',pdecli*180./pi
+c     ENDIF
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/stokes.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/stokes.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/stokes.F90	(revision 1644)
@@ -0,0 +1,68 @@
+      subroutine stokes(p,t,rd,w,rho_aer)
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the sedimentation velocity in a low pressure 
+!     atmosphere.
+!
+!     Authors
+!     ------- 
+!     Francois Forget (1997)
+!
+!==================================================================
+
+!      use radcommon_h, only : Rgas
+      use comcstfi_mod, only: g, pi, avocado
+
+      implicit none
+
+!     input
+!     -----
+!     pressure (Pa), Temperature (K), particle radius (m), density
+      real p, t, rd, rho_aer 
+
+!     output
+!     ------
+!     sedimentation velocity (m/s, >0)
+      real w
+
+!     locally saved variables
+!     ---------------------
+      real a,b,molrad,visc
+      save a,b
+!$OMP THREADPRIVATE(a,b)
+  
+      LOGICAL firstcall
+      SAVE firstcall
+      DATA firstcall/.true./
+!$OMP THREADPRIVATE(firstcall)
+
+      if (firstcall) then
+
+         !print*,'Routine not working: replace Rgas with r'
+	 !stop
+         !a = 0.707*Rgas/(4*pi*molrad**2 * avocado)
+
+         molrad=2.2e-10   ! CO2 (only used in condense_co2cloud at the moment)
+         visc=1.e-5       ! CO2
+
+
+         a = 0.707*8.31/(4*pi*molrad**2 * avocado)
+         b = (2./9.) * rho_aer * g / visc 
+	!print*,'molrad=',molrad
+	!print*,'visc=',visc
+	!print*,'a=',a
+	!print*,'b=',b
+	!print*,'rho_aer=',rho_aer
+	!stop
+ 
+         firstcall=.false.
+      end if
+
+!     Sedimentation velocity =
+!     Stokes' Law corrected for low pressures by the Cunningham
+!     slip-flow correction according to Rossow (Icarus 36, 1-50, 1978)
+      w = b * rd*rd * (1 + 1.333* (a*T/P)/rd )  
+      return
+    end subroutine stokes
Index: /trunk/LMDZ.TITAN/libf/phytitan/su_gases.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/su_gases.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/su_gases.F90	(revision 1644)
@@ -0,0 +1,128 @@
+subroutine su_gases
+
+  use gases_h
+
+  implicit none
+
+  integer igas, ierr, count
+
+  !==================================================================
+  !     
+  !     Purpose
+  !     -------
+  !     Load atmospheric composition info
+  !     
+  !     Authors
+  !     -------
+  !     R. Wordsworth (2011)
+  !     Allocatable arrays by A. Spiga (2011)
+  !     
+  !==================================================================
+
+!$OMP MASTER
+  ! load gas names from file 'gases.def'
+  open(90,file='gases.def',status='old',form='formatted',iostat=ierr)
+  if (ierr.eq.0) then
+     write(*,*) "sugases.F90: reading file gases.def"
+     read(90,*)
+     read(90,*,iostat=ierr) ngasmx
+     if (ierr.ne.0) then
+        write(*,*) "sugases.F90: error reading number of gases"
+        write(*,*) "   (first line of gases.def) "
+        call abort
+     endif
+
+     print*,ngasmx, " gases found in gases.def. Allocating names and molar fractions..."
+
+     if (.not.allocated(gnom)) allocate(gnom(ngasmx))
+     do igas=1,ngasmx
+        read(90,*,iostat=ierr) gnom(igas)
+        if (ierr.ne.0) then
+           write(*,*) 'sugases.F90: error reading gas names in gases.def...'
+           call abort
+        endif
+     enddo                  !of do igas=1,ngasmx
+
+     vgas=0
+     if(.not.allocated(gfrac)) allocate(gfrac(ngasmx))
+     do igas=1,ngasmx
+        read(90,*,iostat=ierr) gfrac(igas)
+        if (ierr.ne.0) then
+           write(*,*) 'sugases.F90: error reading gas molar fractions in gases.def...'
+           call abort
+        endif
+
+        ! find variable gas (if any)
+        if(gfrac(igas).eq.-1.0)then 
+           if(vgas.eq.0)then
+              vgas=igas
+           else
+              print*,'You seem to be choosing two variable gases'
+              print*,'Check that gases.def is correct'
+              call abort
+           endif
+        endif
+
+     enddo                  !of do igas=1,ngasmx
+
+
+     ! assign the 'igas_X' labels
+     count=0
+     do igas=1,ngasmx
+        if (trim(gnom(igas)).eq."H2_" .or. trim(gnom(igas)).eq."H2") then
+           igas_H2=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."He_" .or. trim(gnom(igas)).eq."He") then
+           igas_He=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."H2O") then
+           igas_H2O=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."CO2") then
+           igas_CO2=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."CO_" .or. trim(gnom(igas)).eq."CO") then
+           igas_CO=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."N2_" .or. trim(gnom(igas)).eq."N2") then
+           igas_N2=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."O2_" .or. trim(gnom(igas)).eq."O2") then
+           igas_O2=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."SO2") then
+           igas_SO2=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."H2S") then
+           igas_H2S=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."CH4") then
+           igas_CH4=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."NH3") then
+           igas_NH3=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."C2H6") then
+           igas_C2H6=igas
+           count=count+1
+        elseif (trim(gnom(igas)).eq."C2H2") then
+           igas_C2H2=igas
+           count=count+1
+        endif
+     enddo
+
+     if(count.ne.ngasmx)then
+        print*,'Mismatch between ngas and number of recognised gases in sugas_corrk.F90.'
+        print*,'Either we haven`t managed to assign all the gases, or there are duplicates.'
+        print*,'Please try again.'
+     endif
+
+  else
+     write(*,*) 'Cannot find required file "gases.def"'
+     call abort
+  endif
+  close(90)
+!$OMP END MASTER
+!$OMP BARRIER
+
+end subroutine su_gases
Index: /trunk/LMDZ.TITAN/libf/phytitan/su_watercycle.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/su_watercycle.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/su_watercycle.F90	(revision 1644)
@@ -0,0 +1,31 @@
+      subroutine su_watercycle
+
+      use watercommon_h
+      use comcstfi_mod, only: cpp, mugaz
+      implicit none
+
+
+!==================================================================
+!
+!     Purpose
+!     -------
+!     Set up relevant constants and parameters for the water cycle, and water cloud properties
+!
+!     Authors
+!     -------
+!     Robin Wordsworth (2010)
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+
+      epsi   = mH2O / mugaz
+      RCPD   = cpp 
+
+      !RV = 1000.*R/mH2O
+      RV = 1000.*8.314/mH2O ! caution! R is R/mugaz already!
+
+      RCPV   = 1.88e3 ! specific heat capacity of water vapor at 350K
+
+      RVTMP2 = RCPV/RCPD-1. ! not currently used...
+
+      end subroutine su_watercycle
Index: /trunk/LMDZ.TITAN/libf/phytitan/suaer_corrk.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/suaer_corrk.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/suaer_corrk.F90	(revision 1644)
@@ -0,0 +1,471 @@
+      subroutine suaer_corrk
+
+      ! inputs
+      use radinc_h,    only: L_NSPECTI,L_NSPECTV,nsizemax,naerkind
+      use radcommon_h, only: blamv,blami,lamrefir,lamrefvis
+      use datafile_mod, only: datadir, aerdir
+
+      ! outputs
+      use radcommon_h, only: QVISsQREF,omegavis,gvis,QIRsQREF,omegair,gir
+      use radcommon_h, only: radiustab,nsize,tstellar
+      use radcommon_h, only: qrefvis,qrefir,omegarefvis,omegarefir
+      use aerosol_mod
+      use callkeys_mod, only: tplanet
+
+      implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Initialize all radiative aerosol properties
+!
+!     Notes
+!     -----
+!     Reads the optical properties -> Mean  -> Variable assignment
+!     (ASCII files)                  (see radcommon_h.F90)
+!     wvl(nwvl)                      longsun
+!     ep(nwvl)                       epav     QVISsQREF(L_NSPECTV)
+!     omeg(nwvl)                     omegav   omegavis(L_NSPECTV)
+!     gfactor(nwvl)                  gav      gvis(L_NSPECTV)
+!     
+!     Authors
+!     ------- 
+!     Richard Fournier (1996) Francois Forget (1996)
+!     Frederic Hourdin
+!     Jean-jacques morcrette *ECMWF*
+!     MODIF Francois Forget (2000)
+!     MODIF Franck Montmessin (add water ice)
+!     MODIF J.-B. Madeleine 2008W27
+!     - Optical properties read in ASCII files
+!     - Add varying radius of the particules
+!     - Add water ice clouds
+!     MODIF R. Wordsworth (2009)
+!     - generalisation to arbitrary spectral bands 
+!
+!==================================================================
+
+!     Optical properties (read in external ASCII files)
+      INTEGER,SAVE      :: nwvl  ! Number of wavelengths in
+                                ! the domain (VIS or IR), read by master
+
+!      REAL             :: solsir ! visible to infrared ratio
+!                                ! (tau_0.67um/tau_9um)
+
+      REAL, DIMENSION(:),&
+      ALLOCATABLE, SAVE :: wvl  ! Wavelength axis, read by master
+      REAL, DIMENSION(:),&
+      ALLOCATABLE, SAVE :: radiusdyn ! Particle size axis, read by master
+
+      REAL, DIMENSION(:,:),&
+      ALLOCATABLE, SAVE :: ep,& ! Extinction coefficient Qext, read by master
+      omeg,&                    ! Single Scattering Albedo, read by master
+      gfactor                   ! Assymetry Factor, read by master
+
+!     Local variables:
+
+      INTEGER :: iaer           ! Aerosol index
+      INTEGER :: idomain        ! Domain index (1=VIS,2=IR)
+      INTEGER :: ilw            ! longwave index
+      INTEGER :: isw           ! shortwave index
+      INTEGER :: isize          ! Particle size index
+      INTEGER :: jfile          ! ASCII file scan index
+      INTEGER :: file_unit = 60
+      LOGICAL :: file_ok, endwhile
+      CHARACTER(LEN=132) :: scanline ! ASCII file scanning line
+
+!     I/O  of "aerave" (subroutine that spectrally averages
+!     the single scattering parameters)
+
+      REAL lamref                      ! reference wavelengths
+      REAL epref                       ! reference extinction ep
+
+!      REAL epav(L_NSPECTI)            ! Average ep (= <Qext>/Qext(lamref) if epref=1)
+!      REAL omegav(L_NSPECTI)          ! Average single scattering albedo
+!      REAL gav(L_NSPECTI)             ! Average assymetry parameter
+
+      REAL epavVI(L_NSPECTV)            ! Average ep (= <Qext>/Qext(lamref) if epref=1)
+      REAL omegavVI(L_NSPECTV)          ! Average single scattering albedo
+      REAL gavVI(L_NSPECTV)             ! Average assymetry parameter
+
+      REAL epavIR(L_NSPECTI)            ! Average ep (= <Qext>/Qext(lamref) if epref=1)
+      REAL omegavIR(L_NSPECTI)          ! Average single scattering albedo
+      REAL gavIR(L_NSPECTI)             ! Average assymetry parameter
+      
+      logical forgetit                  ! use francois' data?
+      integer iwvl
+
+!     Local saved variables:
+
+      CHARACTER(LEN=30), DIMENSION(naerkind,2), SAVE :: file_id
+!$OMP THREADPRIVATE(file_id)
+!---- Please indicate the names of the optical property files below
+!     Please also choose the reference wavelengths of each aerosol
+
+      if (noaero) then
+        print*, 'naerkind= 0'
+      endif
+      do iaer=1,naerkind
+       if (iaer.eq.iaero_co2) then
+        forgetit=.true.
+          if (.not.noaero) then
+              print*, 'naerkind= co2', iaer
+          end if
+!     visible
+        if(forgetit)then
+           file_id(iaer,1) = 'optprop_co2_vis_ff.dat' ! Francois' values
+        else
+           file_id(iaer,1) = 'optprop_co2ice_vis_n50.dat'
+        endif
+        lamrefvis(iaer)=1.5E-6   ! 1.5um OMEGA/MEx ???
+
+!     infrared
+        if(forgetit)then
+           file_id(iaer,2) = 'optprop_co2_ir_ff.dat' ! Francois' values
+        else
+           file_id(iaer,2) = 'optprop_co2ice_ir_n50.dat'
+        endif
+        lamrefir(iaer)=12.1E-6   ! 825cm-1 TES/MGS ???
+       endif ! CO2 aerosols  
+! NOTE: these lamref's are currently for dust, not CO2 ice.
+! JB thinks this shouldn't matter too much, but it needs to be 
+! fixed / decided for the final version.
+
+       if (iaer.eq.iaero_h2o) then
+        print*, 'naerkind= h2o', iaer
+
+!     visible
+         file_id(iaer,1) = 'optprop_icevis_n50.dat'
+         lamrefvis(iaer)=1.5E-6   ! 1.5um OMEGA/MEx
+!     infrared
+         file_id(iaer,2) = 'optprop_iceir_n50.dat'
+         lamrefir(iaer)=12.1E-6   ! 825cm-1 TES/MGS
+       endif
+
+       if (iaer.eq.iaero_dust) then
+        print*, 'naerkind= dust', iaer
+
+!     visible
+         file_id(iaer,1) = 'optprop_dustvis_n50.dat'
+         !lamrefvis(iaer)=1.5E-6   ! 1.5um OMEGA/MEx
+         lamrefvis(iaer)=0.67e-6
+!     infrared
+         file_id(iaer,2) = 'optprop_dustir_n50.dat'
+         !lamrefir(iaer)=12.1E-6   ! 825cm-1 TES/MGS
+         lamrefir(iaer)=9.3E-6
+       endif 
+
+       if (iaer.eq.iaero_h2so4) then
+         print*, 'naerkind= h2so4', iaer
+
+!     visible
+         file_id(iaer,1) = 'optprop_h2so4vis_n20.dat'
+         !lamrefir(iaer)=  doesn't exist?
+         lamrefvis(iaer)=1.5E-6   ! no idea, must find
+!     infrared
+         file_id(iaer,2) = 'optprop_h2so4ir_n20.dat'
+         !lamrefir(iaer)=12.1E-6   ! 825cm-1 TES/MGS
+         lamrefir(iaer)=9.3E-6 ! no idea, must find
+! added by LK
+       endif
+
+       if (iaer.eq.iaero_back2lay) then
+         print*, 'naerkind= back2lay', iaer
+
+!     visible
+         file_id(iaer,1) = 'optprop_saturn_vis_n20.dat'
+         lamrefvis(iaer)=0.8E-6  ! 
+!     infrared
+         file_id(iaer,2) = 'optprop_saturn_ir_n20.dat'
+         lamrefir(iaer)=6.E-6  ! 
+! added by SG
+       endif
+       
+       
+      enddo
+
+!------------------------------------------------------------------
+
+!     Initializations:
+
+      radiustab(:,:,:) = 0.0
+      gvis(:,:,:)      = 0.0
+      omegavis(:,:,:)  = 0.0
+      QVISsQREF(:,:,:) = 0.0
+      gir(:,:,:)       = 0.0
+      omegair(:,:,:)   = 0.0
+      QIRsQREF(:,:,:)  = 0.0
+
+      DO iaer = 1, naerkind     ! Loop on aerosol kind
+         DO idomain = 1, 2      ! Loop on radiation domain (VIS or IR)
+!==================================================================
+!     1. READ OPTICAL PROPERTIES
+!==================================================================
+
+!     1.1 Open the ASCII file
+
+!$OMP MASTER
+            INQUIRE(FILE=TRIM(datadir)//'/'//TRIM(aerdir)//&
+                    '/'//TRIM(file_id(iaer,idomain)),&
+                    EXIST=file_ok)
+            IF (file_ok) THEN
+              OPEN(UNIT=file_unit,&
+                   FILE=TRIM(datadir)//'/'//TRIM(aerdir)//&
+                        '/'//TRIM(file_id(iaer,idomain)),&
+                   FORM='formatted')
+            ELSE
+             ! In ye old days these files were stored in datadir;
+             ! let's be retro-compatible
+              INQUIRE(FILE=TRIM(datadir)//&
+                      '/'//TRIM(file_id(iaer,idomain)),&
+                      EXIST=file_ok)
+              IF (file_ok) THEN
+                OPEN(UNIT=file_unit,&
+                     FILE=TRIM(datadir)//&
+                          '/'//TRIM(file_id(iaer,idomain)),&
+                     FORM='formatted')
+              ENDIF              
+            ENDIF
+            IF(.NOT.file_ok) THEN
+               write(*,*)'suaer_corrk: Problem opening ',&
+               TRIM(file_id(iaer,idomain))
+               write(*,*)'It should be in: ',TRIM(datadir)//'/'//TRIM(aerdir)
+               write(*,*)'1) You can set this directory address ',&
+               'in callphys.def with:'
+               write(*,*)' datadir = /absolute/path/to/datagcm'
+               write(*,*)'2) If ',&
+              TRIM(file_id(iaer,idomain)),&
+               ' is a LMD reference datafile, it'
+               write(*,*)' can be obtained online at:'
+               write(*,*)' http://www.lmd.jussieu.fr/',&
+               '~lmdz/planets/LMDZ.GENERIC/datagcm/'
+               CALL ABORT 
+            ENDIF
+
+!     1.2 Allocate the optical property table
+
+            jfile = 1
+            endwhile = .false.
+            DO WHILE (.NOT.endwhile)
+               READ(file_unit,*) scanline
+               IF ((scanline(1:1) .ne. '#').and.&
+               (scanline(1:1) .ne. ' ')) THEN
+               BACKSPACE(file_unit)
+               reading1_seq: SELECT CASE (jfile) ! ====================
+            CASE(1) reading1_seq ! nwvl ----------------------------
+               read(file_unit,*) nwvl
+               jfile = jfile+1
+            CASE(2) reading1_seq ! nsize ---------------------------
+               read(file_unit,*) nsize(iaer,idomain)
+               endwhile = .true.
+            CASE DEFAULT reading1_seq ! ---------------------------- 
+               WRITE(*,*) 'readoptprop: ',& 
+               'Error while loading optical properties.' 
+               CALL ABORT 
+            END SELECT reading1_seq ! ==============================
+         ENDIF
+      ENDDO
+
+      ALLOCATE(wvl(nwvl))       ! wvl
+      ALLOCATE(radiusdyn(nsize(iaer,idomain))) ! radiusdyn
+      ALLOCATE(ep(nwvl,nsize(iaer,idomain))) ! ep
+      ALLOCATE(omeg(nwvl,nsize(iaer,idomain))) ! omeg 
+      ALLOCATE(gfactor(nwvl,nsize(iaer,idomain))) ! g
+
+
+!     1.3 Read the data
+
+      jfile = 1
+      endwhile = .false.
+      DO WHILE (.NOT.endwhile)
+         READ(file_unit,*) scanline
+         IF ((scanline(1:1) .ne. '#').and.&
+         (scanline(1:1) .ne. ' ')) THEN
+         BACKSPACE(file_unit)
+         reading2_seq: SELECT CASE (jfile) ! ====================
+      CASE(1) reading2_seq      ! wvl -----------------------------
+         read(file_unit,*) wvl
+         jfile = jfile+1
+      CASE(2) reading2_seq      ! radiusdyn -----------------------
+         read(file_unit,*) radiusdyn
+         jfile = jfile+1
+      CASE(3) reading2_seq      ! ep ------------------------------
+         isize = 1
+         DO WHILE (isize .le. nsize(iaer,idomain))
+            READ(file_unit,*) scanline
+            IF ((scanline(1:1) .ne. '#').and.&
+            (scanline(1:1) .ne. ' ')) THEN
+            BACKSPACE(file_unit)
+            read(file_unit,*) ep(:,isize)
+            isize = isize + 1
+         ENDIF
+      ENDDO
+
+      jfile = jfile+1
+      CASE(4) reading2_seq      ! omeg ----------------------------
+         isize = 1
+         DO WHILE (isize .le. nsize(iaer,idomain))
+            READ(file_unit,*) scanline
+            IF ((scanline(1:1) .ne. '#').and.&
+            (scanline(1:1) .ne. ' ')) THEN
+            BACKSPACE(file_unit)
+            read(file_unit,*) omeg(:,isize)
+            isize = isize + 1
+         ENDIF
+      ENDDO
+
+      jfile = jfile+1
+      CASE(5) reading2_seq      ! gfactor -------------------------
+         isize = 1
+         DO WHILE (isize .le. nsize(iaer,idomain))
+            READ(file_unit,*) scanline
+            IF ((scanline(1:1) .ne. '#').and.&
+            (scanline(1:1) .ne. ' ')) THEN
+            BACKSPACE(file_unit)
+            read(file_unit,*) gfactor(:,isize)
+            isize = isize + 1
+         ENDIF
+      ENDDO
+
+      jfile = jfile+1
+      IF ((idomain.NE.iaero_co2).OR.(iaer.NE.iaero_co2)) THEN
+         endwhile = .true.
+      ENDIF
+      CASE(6) reading2_seq
+         endwhile = .true.
+      CASE DEFAULT reading2_seq ! ----------------------------
+         WRITE(*,*) 'readoptprop: ',&
+         'Error while loading optical properties.'
+         CALL ABORT
+      END SELECT reading2_seq   ! ==============================
+      ENDIF
+      ENDDO
+
+!     1.4 Close the file
+
+      CLOSE(file_unit)
+
+!     1.5 If Francois' data, convert wvl to metres
+       if(iaer.eq.iaero_co2)then
+         if(forgetit)then
+         !   print*,'please sort out forgetit for naerkind>1'
+            do iwvl=1,nwvl
+               wvl(iwvl)=wvl(iwvl)*1.e-6
+            enddo
+         endif
+      endif
+
+!$OMP END MASTER
+!$OMP BARRIER
+
+
+
+
+
+!==================================================================
+!     2. AVERAGED PROPERTIES AND VARIABLE ASSIGNMENTS
+!==================================================================
+      domain: SELECT CASE (idomain)
+!==================================================================
+      CASE(1) domain            !       VISIBLE DOMAIN (idomain=1)
+!==================================================================
+
+         lamref=lamrefvis(iaer)
+         epref=1.E+0
+
+         DO isize=1,nsize(iaer,idomain)
+
+!     Save the particle sizes
+            radiustab(iaer,idomain,isize)=radiusdyn(isize)
+
+!     Averaged optical properties (GCM channels)
+
+!            CALL aerave ( nwvl,&
+!            wvl(:),ep(:,isize),omeg(:,isize),gfactor(:,isize),&
+!            lamref,epref,tstellar,&
+!            L_NSPECTV,blamv,epavVI,&
+!            omegavVI,gavVI,QREFvis(iaer,isize))!,omegaREFir(iaer,isize))
+            CALL aerave_new ( nwvl,&
+            wvl(:),ep(:,isize),omeg(:,isize),gfactor(:,isize),&
+            lamref,epref,tstellar,&
+            L_NSPECTV,blamv,epavVI,&
+            omegavVI,gavVI,QREFvis(iaer,isize),omegaREFir(iaer,isize))
+
+!     Variable assignments (declared in radcommon)
+            DO isw=1,L_NSPECTV
+               QVISsQREF(isw,iaer,isize)=epavVI(isw)
+               gvis(isw,iaer,isize)=gavVI(isw)
+               omegavis(isw,iaer,isize)=omegavVI(isw)
+            END DO
+
+         ENDDO
+
+!==================================================================
+      CASE(2) domain            !      INFRARED DOMAIN (idomain=2)
+!==================================================================
+
+
+         DO isize=1,nsize(iaer,idomain) ! ----------------------------------
+
+            lamref=lamrefir(iaer)
+            epref=1.E+0
+
+!     Save the particle sizes
+            radiustab(iaer,idomain,isize)=radiusdyn(isize)
+
+!     Averaged optical properties (GCM channels)
+
+!     epav is <QIR>/Qext(lamrefir) since epref=1
+!     Note: aerave also computes the extinction coefficient at
+!     the reference wavelength. This is called QREFvis or QREFir
+!     (not epref, which is a different parameter).
+!     Reference wavelengths SHOULD BE defined for each aerosol in
+!     radcommon_h.F90
+
+!            CALL aerave ( nwvl,&
+!            wvl(:),ep(:,isize),omeg(:,isize),gfactor(:,isize),&
+!            lamref,epref,tplanet,&
+!            L_NSPECTI,blami,epavIR,&
+!            omegavIR,gavIR,QREFir(iaer,isize))!,omegaREFir(iaer,isize))
+            CALL aerave_new ( nwvl,&
+            wvl(:),ep(:,isize),omeg(:,isize),gfactor(:,isize),&
+            lamref,epref,tplanet,&
+            L_NSPECTI,blami,epavIR,&
+            omegavIR,gavIR,QREFir(iaer,isize),omegaREFir(iaer,isize))
+
+
+!     Variable assignments (declared in radcommon)
+            DO ilw=1,L_NSPECTI
+               QIRsQREF(ilw,iaer,isize)=epavIR(ilw)
+               gir(ilw,iaer,isize)=gavIR(ilw)
+               omegair(ilw,iaer,isize)=omegavIR(ilw)
+            END DO
+
+
+      ENDDO                     ! isize (particle size) -------------------------------------
+
+      END SELECT domain
+
+!========================================================================
+!     3. Deallocate temporary variables that were read in the ASCII files
+!========================================================================
+
+!$OMP BARRIER
+!$OMP MASTER
+      IF (ALLOCATED(wvl)) DEALLOCATE(wvl)                 ! wvl
+      IF (ALLOCATED(radiusdyn)) DEALLOCATE(radiusdyn)     ! radiusdyn
+      IF (ALLOCATED(ep)) DEALLOCATE(ep)                   ! ep 
+      IF (ALLOCATED(omeg)) DEALLOCATE(omeg)          	  ! omeg 
+      IF (ALLOCATED(gfactor)) DEALLOCATE(gfactor)         ! g
+!$OMP END MASTER
+!$OMP BARRIER
+
+      END DO                    ! Loop on iaer
+      END DO                    ! Loop on idomain
+!========================================================================
+
+      RETURN
+
+
+
+    END subroutine suaer_corrk
+      
Index: /trunk/LMDZ.TITAN/libf/phytitan/sugas_corrk.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/sugas_corrk.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/sugas_corrk.F90	(revision 1644)
@@ -0,0 +1,678 @@
+      subroutine sugas_corrk
+
+!==================================================================
+!
+!     Purpose
+!     -------
+!     Set up gaseous absorption parameters used by the radiation code.
+!     This subroutine is a replacement for the old 'setrad', which contained
+!     both absorption and scattering data.
+!
+!     Authors
+!     -------
+!     Adapted and generalised from the NASA Ames code by Robin Wordsworth (2009)
+!     Added double gray case by Jeremy Leconte (2012)
+!     New HITRAN continuum data section by RW (2012)
+!
+!     Summary
+!     -------
+!
+!==================================================================
+
+      use radinc_h
+      use radcommon_h, only : pgasref,pfgasref,pgasmin,pgasmax
+      use radcommon_h, only : tgasref,tgasmin,tgasmax
+      use radcommon_h, only : gasv,gasi,FZEROI,FZEROV,gweight
+      use radcommon_h, only : wrefvar,WNOI,WNOV
+      use datafile_mod, only: datadir
+      use comcstfi_mod, only: mugaz
+      use gases_h
+      use ioipsl_getin_p_mod, only: getin_p
+      use callkeys_mod, only: varactive,varfixed,graybody,callgasvis,&
+		continuum,H2Ocont_simple
+      implicit none
+
+!==================================================================
+
+      logical file_ok
+
+      integer n, nt, np, nh, ng, nw, m, i
+      integer L_NGAUSScheck
+
+      character(len=200) :: file_id
+      character(len=500) :: file_path
+
+      ! ALLOCATABLE ARRAYS -- AS 12/2011
+      REAL*8, DIMENSION(:,:,:,:,:), ALLOCATABLE,SAVE :: gasi8, gasv8 	!read by master
+      character*20,allocatable,DIMENSION(:),SAVE :: gastype ! for check with gnom, read by master
+
+      real*8 x, xi(4), yi(4), ans, p
+!     For gray case (JL12)
+      real kappa_IR, kappa_VI, IR_VI_wnlimit
+      integer nVI_limit,nIR_limit
+
+      integer ngas, igas, jgas
+
+      double precision testcont ! for continuum absorption initialisation
+
+      integer :: dummy
+
+!=======================================================================
+!     Load variable species data, exit if we have wrong database
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/Q.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
+
+      ! check that the file exists
+      inquire(FILE=file_path,EXIST=file_ok)
+      if(.not.file_ok) then
+         write(*,*)'The file ',TRIM(file_path)
+         write(*,*)'was not found by sugas_corrk.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
+         call abort
+      endif
+
+!$OMP MASTER
+      ! check that database matches varactive toggle
+      open(111,file=TRIM(file_path),form='formatted')
+      read(111,*) ngas
+
+      if(ngas.ne.ngasmx)then
+         print*,'Number of gases in radiative transfer data (',ngas,') does not', &
+                'match that in gases.def (',ngasmx,'), exiting.'
+         call abort
+      endif 
+
+      if(ngas.eq.1 .and. (varactive.or.varfixed))then
+         print*,'You have varactive/fixed=.true. but the database [',  &
+                     corrkdir(1:LEN_TRIM(corrkdir)),           &
+                '] has no variable species, exiting.'
+         call abort
+      elseif(ngas.gt.5 .or. ngas.lt.1)then
+         print*,ngas,' species in database [',               &
+                     corrkdir(1:LEN_TRIM(corrkdir)),           &
+                '], radiative code cannot handle this.'
+         call abort
+      endif 
+
+      ! dynamically allocate gastype and read from Q.dat
+      IF ( .NOT. ALLOCATED( gastype ) ) ALLOCATE( gastype( ngas ) )
+
+      do igas=1,ngas
+         read(111,*) gastype(igas)
+         print*,'Gas ',igas,' is ',gastype(igas)
+      enddo
+
+      ! get array size, load the coefficients
+      open(111,file=TRIM(file_path),form='formatted')
+      read(111,*) L_REFVAR
+      IF( .NOT. ALLOCATED( wrefvar ) ) ALLOCATE( WREFVAR(L_REFVAR) )
+      read(111,*) wrefvar
+      close(111)
+
+      if(L_REFVAR.gt.1 .and. (.not.varactive) .and. (.not.varfixed))then
+         print*,'You have varactive and varfixed=.false. and the database [', &
+                     corrkdir(1:LEN_TRIM(corrkdir)),           &
+                '] has a variable species.'
+         call abort
+      endif
+
+      ! Check that gastype and gnom match
+      do igas=1,ngas
+         print*,'Gas ',igas,' is ',trim(gnom(igas))
+         if (trim(gnom(igas)).ne.trim(gastype(igas))) then
+            print*,'Name of a gas in radiative transfer data (',trim(gastype(igas)),') does not ', &
+                 'match that in gases.def (',trim(gnom(igas)),'), exiting. You should compare ', &
+                 'gases.def with Q.dat in your radiative transfer directory.' 
+            call abort
+         endif
+      enddo
+      print*,'Confirmed gas match in radiative transfer and gases.def!'
+
+      ! display the values
+      print*,'Variable gas volume mixing ratios:'
+      do n=1,L_REFVAR
+         !print*,n,'.',wrefvar(n),' kg/kg' ! pay attention!
+         print*,n,'.',wrefvar(n),' mol/mol'
+      end do
+      print*,''
+
+!=======================================================================
+!     Set the weighting in g-space
+
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/g.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
+
+      ! check that the file exists
+      inquire(FILE=file_path,EXIST=file_ok)
+      if(.not.file_ok) then
+         write(*,*)'The file ',TRIM(file_path)
+         write(*,*)'was not found by sugas_corrk.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
+         call abort
+      endif
+      
+      ! check the array size is correct, load the coefficients
+      open(111,file=TRIM(file_path),form='formatted')
+      read(111,*) L_NGAUSScheck
+      if(.not.(L_NGAUSScheck.eq.L_NGAUSS)) then
+         print*,'The size of your radiative transfer g-space array does '
+         print*,'not match the value given in g.dat, exiting.'
+         call abort
+      endif
+      read(111,*) gweight
+      close(111)
+ 
+      ! display the values
+      print*,'Correlated-k g-space grid:'
+      do n=1,L_NGAUSS
+         print*,n,'.',gweight(n)
+      end do
+      print*,''
+
+!=======================================================================
+!     Set the reference pressure and temperature arrays.  These are
+!     the pressures and temperatures at which we have k-coefficients.
+
+!-----------------------------------------------------------------------
+! pressure
+
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/p.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
+
+      ! check that the file exists
+      inquire(FILE=file_path,EXIST=file_ok)
+      if(.not.file_ok) then
+         write(*,*)'The file ',TRIM(file_path)
+         write(*,*)'was not found by sugas_corrk.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
+         call abort
+      endif
+     
+      ! get array size, load the coefficients
+      open(111,file=TRIM(file_path),form='formatted')
+      read(111,*) L_NPREF
+      IF( .NOT. ALLOCATED( pgasref ) ) ALLOCATE( PGASREF(L_NPREF) )
+      read(111,*) pgasref
+      close(111)
+      L_PINT = (L_NPREF-1)*5+1
+      IF( .NOT. ALLOCATED( pfgasref ) ) ALLOCATE( PFGASREF(L_PINT) )
+
+      ! display the values
+      print*,'Correlated-k pressure grid (mBar):'
+      do n=1,L_NPREF
+         print*,n,'. 1 x 10^',pgasref(n),' mBar'
+      end do
+      print*,''
+
+      ! save the min / max matrix values
+      pgasmin = 10.0**pgasref(1)
+      pgasmax = 10.0**pgasref(L_NPREF)
+
+      ! interpolate to finer grid, adapted to uneven grids
+      do n=1,L_NPREF-1
+         do m=1,5
+            pfgasref((n-1)*5+m) = pgasref(n)+(m-1)*(pgasref(n+1) - pgasref(n))/5.
+         end do
+      end do
+      pfgasref(L_PINT) = pgasref(L_NPREF)
+
+!-----------------------------------------------------------------------
+! temperature
+
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/T.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
+
+      ! check that the file exists
+      inquire(FILE=file_path,EXIST=file_ok)
+      if(.not.file_ok) then
+         write(*,*)'The file ',TRIM(file_path)
+         write(*,*)'was not found by sugas_corrk.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
+         call abort
+      endif
+
+      ! get array size, load the coefficients
+      open(111,file=TRIM(file_path),form='formatted')
+      read(111,*) L_NTREF
+      IF( .NOT. ALLOCATED( tgasref ) ) ALLOCATE( TGASREF(L_NTREF) )
+      read(111,*) tgasref
+      close(111)
+
+      ! display the values
+      print*,'Correlated-k temperature grid:'
+      do n=1,L_NTREF
+         print*,n,'.',tgasref(n),' K'
+      end do
+
+      ! save the min / max matrix values
+      tgasmin = tgasref(1)
+      tgasmax = tgasref(L_NTREF)
+
+      IF( .NOT. ALLOCATED( gasi8 ) ) ALLOCATE( gasi8(L_NTREF,L_NPREF,L_REFVAR,L_NSPECTI,L_NGAUSS) )
+      IF( .NOT. ALLOCATED( gasv8 ) ) ALLOCATE( gasv8(L_NTREF,L_NPREF,L_REFVAR,L_NSPECTV,L_NGAUSS) )
+!$OMP END MASTER
+!$OMP BARRIER
+
+!-----------------------------------------------------------------------
+! allocate the multidimensional arrays in radcommon_h
+      IF( .NOT. ALLOCATED( gasi ) ) ALLOCATE( gasi(L_NTREF,L_PINT,L_REFVAR,L_NSPECTI,L_NGAUSS) )
+      IF( .NOT. ALLOCATED( gasv ) ) ALLOCATE( gasv(L_NTREF,L_PINT,L_REFVAR,L_NSPECTV,L_NGAUSS) )
+
+      ! display the values
+      print*,''
+      print*,'Correlated-k matrix size:' 
+      print*,'[',L_NTREF,',',L_NPREF,',',L_REFVAR,',',L_NGAUSS,']' 
+
+!=======================================================================
+!     Get gaseous k-coefficients and interpolate onto finer pressure grid
+
+
+!        wavelength used to separate IR from VI in graybody. We will need that anyway
+         IR_VI_wnlimit=3000.
+         write(*,*)"graybody: Visible / Infrared separation set at",10000./IR_VI_wnlimit,"um"
+	 
+	 nVI_limit=0
+	 Do nw=1,L_NSPECTV
+	    if ((WNOV(nw).gt.IR_VI_wnlimit).and.(L_NSPECTV.gt.1)) then
+	       nVI_limit=nw-1
+	       exit
+	    endif
+	 End do
+	 nIR_limit=L_NSPECTI
+	 Do nw=1,L_NSPECTI
+	    if ((WNOI(nw).gt.IR_VI_wnlimit).and.(L_NSPECTI.gt.1)) then
+	       nIR_limit=nw-1
+	       exit
+	    endif
+	 End do
+
+      if (graybody) then
+!        constant absorption coefficient in visible
+         write(*,*)"graybody: constant absorption coefficient in visible:"
+         kappa_VI=-100000.
+         call getin_p("kappa_VI",kappa_VI)
+         write(*,*)" kappa_VI = ",kappa_VI
+	 kappa_VI=kappa_VI*1.e4* mugaz * 1.672621e-27	 ! conversion from m^2/kg to cm^2/molecule         
+      
+!        constant absorption coefficient in IR
+         write(*,*)"graybody: constant absorption coefficient in InfraRed:"
+         kappa_IR=-100000.
+         call getin_p("kappa_IR",kappa_IR)
+         write(*,*)" kappa_IR = ",kappa_IR	 
+         kappa_IR=kappa_IR*1.e4* mugaz * 1.672621e-27	 ! conversion from m^2/kg to cm^2/molecule 
+
+         write(*,*)"graybody: Visible / Infrared separation set at band: IR=",nIR_limit,", VI=",nVI_limit
+	       
+      Else
+         kappa_VI=1.e-30      
+         kappa_IR=1.e-30        
+      End if
+
+!$OMP MASTER         
+!      print*,corrkdir(1:4)
+      ! VISIBLE
+      if (callgasvis) then
+         if ((corrkdir(1:4).eq.'null'))then   !(TRIM(corrkdir).eq.'null_LowTeffStar')) then
+            gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTV,1:L_NGAUSS)=0.0
+            print*,'using no corrk data'
+            print*,'Visible corrk gaseous absorption is set to zero if graybody=F'
+	 else
+            file_id='/corrk_data/'//trim(adjustl(banddir))//'/corrk_gcm_VI.dat' 
+            file_path=TRIM(datadir)//TRIM(file_id)
+            
+            ! check that the file exists
+            inquire(FILE=file_path,EXIST=file_ok)
+            if(.not.file_ok) then
+               write(*,*)'The file ',TRIM(file_path)
+               write(*,*)'was not found by sugas_corrk.F90.'
+               write(*,*)'Are you sure you have absorption data for these bands?'
+               call abort
+            endif
+         
+            open(111,file=TRIM(file_path),form='formatted')
+            read(111,*) gasv8
+            close(111)
+	 end if
+
+         if(nVI_limit.eq.0) then
+	    gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTV,1:L_NGAUSS)=   &
+	          gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTV,1:L_NGAUSS)+kappa_VI
+         else if (nVI_limit.eq.L_NSPECTV) then
+	    gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTV,1:L_NGAUSS)=   &
+	          gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTV,1:L_NGAUSS)+kappa_IR
+	 else
+	    gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:nVI_limit,1:L_NGAUSS)=   &
+	          gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:nVI_limit,1:L_NGAUSS)+kappa_IR
+	    gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,nVI_limit+1:L_NSPECTV,1:L_NGAUSS)=   &
+	          gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,nVI_limit+1:L_NSPECTV,1:L_NGAUSS)+kappa_VI
+	 end if
+      else
+         print*,'Visible corrk gaseous absorption is set to zero.'
+         gasv8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTV,1:L_NGAUSS)=0.0
+      endif
+!$OMP END MASTER
+!$OMP BARRIER
+
+      ! INFRA-RED
+      if ((corrkdir(1:4).eq.'null'))then       !.or.(TRIM(corrkdir).eq.'null_LowTeffStar')) then
+         print*,'Infrared corrk gaseous absorption is set to zero if graybody=F'
+!$OMP MASTER         
+         gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTI,1:L_NGAUSS)=0.0
+!$OMP END MASTER
+!$OMP BARRIER
+      else 
+         file_id='/corrk_data/'//trim(adjustl(banddir))//'/corrk_gcm_IR.dat' 
+         file_path=TRIM(datadir)//TRIM(file_id)
+      
+         ! check that the file exists
+         inquire(FILE=file_path,EXIST=file_ok)
+         if(.not.file_ok) then
+            write(*,*)'The file ',TRIM(file_path)
+            write(*,*)'was not found by sugas_corrk.F90.'
+            write(*,*)'Are you sure you have absorption data for these bands?'
+            call abort
+         endif
+         
+!$OMP MASTER          	        
+         open(111,file=TRIM(file_path),form='formatted')
+         read(111,*) gasi8
+         close(111)
+!$OMP END MASTER
+!$OMP BARRIER
+     
+         ! 'fzero' is a currently unused feature that allows optimisation
+         ! of the radiative transfer by neglecting bands where absorption
+         ! is close to zero. As it could be useful in the future, this 
+         ! section of the code has been kept commented and not erased.
+         ! RW 7/3/12.
+
+         do nw=1,L_NSPECTI
+            fzeroi(nw) = 0.d0
+!            do nt=1,L_NTREF
+!               do np=1,L_NPREF
+!                  do nh=1,L_REFVAR
+!                     do ng = 1,L_NGAUSS
+!                        if(gasi8(nt,np,nh,nw,ng).lt.1.0e-25)then
+!                           fzeroi(nw)=fzeroi(nw)+1.d0
+!                        endif
+!                     end do
+!                  end do
+!               end do
+!            end do
+!            fzeroi(nw)=fzeroi(nw)/dble(L_NTREF*L_NPREF*L_REFVAR*L_NGAUSS)
+         end do
+
+         do nw=1,L_NSPECTV
+            fzerov(nw) = 0.d0
+!            do nt=1,L_NTREF
+!               do np=1,L_NPREF
+!                  do nh=1,L_REFVAR
+!                     do ng = 1,L_NGAUSS
+!                        if(gasv8(nt,np,nh,nw,ng).lt.1.0e-25)then
+!                           fzerov(nw)=fzerov(nw)+1.d0
+!                        endif
+!                     end do
+!                  end do
+!               end do
+!            end do
+!            fzerov(nw)=fzerov(nw)/dble(L_NTREF*L_NPREF*L_REFVAR*L_NGAUSS)
+         end do
+
+      endif
+
+!$OMP MASTER         	     
+      if(nIR_limit.eq.0) then
+         gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTI,1:L_NGAUSS)=   &
+	          gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTI,1:L_NGAUSS)+kappa_VI
+      else if (nIR_limit.eq.L_NSPECTI) then
+	 gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTI,1:L_NGAUSS)=   &
+	          gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:L_NSPECTI,1:L_NGAUSS)+kappa_IR
+      else
+	 gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:nIR_limit,1:L_NGAUSS)=   &
+	          gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,1:nIR_limit,1:L_NGAUSS)+kappa_IR
+	 gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,nIR_limit+1:L_NSPECTI,1:L_NGAUSS)=   &
+	          gasi8(1:L_NTREF,1:L_NPREF,1:L_REFVAR,nIR_limit+1:L_NSPECTI,1:L_NGAUSS)+kappa_VI
+      end if
+
+
+!     Take log10 of the values - this is what we will interpolate.
+!     Smallest value is 1.0E-200.
+
+      do nt=1,L_NTREF
+         do np=1,L_NPREF
+            do nh=1,L_REFVAR
+               do ng = 1,L_NGAUSS
+
+                  do nw=1,L_NSPECTV
+                     if(gasv8(nt,np,nh,nw,ng).gt.1.0d-200) then
+                        gasv8(nt,np,nh,nw,ng) = log10(gasv8(nt,np,nh,nw,ng))
+                     else
+                        gasv8(nt,np,nh,nw,ng) = -200.0
+                     end if
+                  end do
+
+                  do nw=1,L_NSPECTI
+                     if(gasi8(nt,np,nh,nw,ng).gt.1.0d-200) then
+                        gasi8(nt,np,nh,nw,ng) = log10(gasi8(nt,np,nh,nw,ng))
+                     else
+                        gasi8(nt,np,nh,nw,ng) = -200.0
+                     end if
+                  end do
+                  
+               end do
+            end do
+         end do
+      end do
+!$OMP END MASTER
+!$OMP BARRIER
+
+!     Interpolate the values:  first the longwave
+
+      do nt=1,L_NTREF
+         do nh=1,L_REFVAR
+            do nw=1,L_NSPECTI
+               do ng=1,L_NGAUSS
+
+!     First, the initial interval
+
+                  n = 1 
+                  do m=1,5
+                     x     = pfgasref(m)
+                     xi(1) = pgasref(n)
+                     xi(2) = pgasref(n+1)
+                     xi(3) = pgasref(n+2)
+                     xi(4) = pgasref(n+3)
+                     yi(1) = gasi8(nt,n,nh,nw,ng)
+                     yi(2) = gasi8(nt,n+1,nh,nw,ng)
+                     yi(3) = gasi8(nt,n+2,nh,nw,ng)
+                     yi(4) = gasi8(nt,n+3,nh,nw,ng)
+                     call lagrange(x,xi,yi,ans)
+                     gasi(nt,m,nh,nw,ng) = 10.0**ans
+                  end do 
+                  
+                  do n=2,L_NPREF-2
+                     do m=1,5
+                        i     = (n-1)*5+m
+                        x     = pfgasref(i)
+                        xi(1) = pgasref(n-1)
+                        xi(2) = pgasref(n)
+                        xi(3) = pgasref(n+1)
+                        xi(4) = pgasref(n+2)
+                        yi(1) = gasi8(nt,n-1,nh,nw,ng)
+                        yi(2) = gasi8(nt,n,nh,nw,ng)
+                        yi(3) = gasi8(nt,n+1,nh,nw,ng)
+                        yi(4) = gasi8(nt,n+2,nh,nw,ng)
+                        call lagrange(x,xi,yi,ans)
+                        gasi(nt,i,nh,nw,ng) = 10.0**ans
+                     end do 
+                  end do
+
+!     Now, get the last interval
+
+                  n = L_NPREF-1                 
+                  do m=1,5
+                     i     = (n-1)*5+m
+                     x     = pfgasref(i)
+                     xi(1) = pgasref(n-2)
+                     xi(2) = pgasref(n-1)
+                     xi(3) = pgasref(n)
+                     xi(4) = pgasref(n+1)
+                     yi(1) = gasi8(nt,n-2,nh,nw,ng)
+                     yi(2) = gasi8(nt,n-1,nh,nw,ng)
+                     yi(3) = gasi8(nt,n,nh,nw,ng)
+                     yi(4) = gasi8(nt,n+1,nh,nw,ng)
+                     call lagrange(x,xi,yi,ans)
+                     gasi(nt,i,nh,nw,ng) = 10.0**ans
+                  end do  
+
+!     Fill the last pressure point
+
+                  gasi(nt,L_PINT,nh,nw,ng) = &
+                       10.0**gasi8(nt,L_NPREF,nh,nw,ng)
+
+               end do
+            end do
+         end do
+      end do
+
+!     Interpolate the values:  now the shortwave
+
+      do nt=1,L_NTREF
+         do nh=1,L_REFVAR
+            do nw=1,L_NSPECTV
+               do ng=1,L_NGAUSS
+
+!     First, the initial interval
+
+                  n = 1 
+                  do m=1,5
+                     x     = pfgasref(m)
+                     xi(1) = pgasref(n)
+                     xi(2) = pgasref(n+1)
+                     xi(3) = pgasref(n+2)
+                     xi(4) = pgasref(n+3)
+                     yi(1) = gasv8(nt,n,nh,nw,ng)
+                     yi(2) = gasv8(nt,n+1,nh,nw,ng)
+                     yi(3) = gasv8(nt,n+2,nh,nw,ng)
+                     yi(4) = gasv8(nt,n+3,nh,nw,ng)
+                     call lagrange(x,xi,yi,ans)
+                     gasv(nt,m,nh,nw,ng) = 10.0**ans
+                  end do 
+                  
+                  do n=2,L_NPREF-2
+                     do m=1,5
+                        i     = (n-1)*5+m
+                        x     = pfgasref(i)
+                        xi(1) = pgasref(n-1)
+                        xi(2) = pgasref(n)
+                        xi(3) = pgasref(n+1)
+                        xi(4) = pgasref(n+2)
+                        yi(1) = gasv8(nt,n-1,nh,nw,ng)
+                        yi(2) = gasv8(nt,n,nh,nw,ng)
+                        yi(3) = gasv8(nt,n+1,nh,nw,ng)
+                        yi(4) = gasv8(nt,n+2,nh,nw,ng)
+                        call lagrange(x,xi,yi,ans)
+                        gasv(nt,i,nh,nw,ng) = 10.0**ans
+                     end do 
+                  end do
+
+!     Now, get the last interval
+
+                  n = L_NPREF-1
+                  do m=1,5
+                     i     = (n-1)*5+m
+                     x     = pfgasref(i)
+                     xi(1) = pgasref(n-2)
+                     xi(2) = pgasref(n-1)
+                     xi(3) = pgasref(n)
+                     xi(4) = pgasref(n+1)
+                     yi(1) = gasv8(nt,n-2,nh,nw,ng)
+                     yi(2) = gasv8(nt,n-1,nh,nw,ng)
+                     yi(3) = gasv8(nt,n,nh,nw,ng)
+                     yi(4) = gasv8(nt,n+1,nh,nw,ng)
+                     call lagrange(x,xi,yi,ans)
+                     gasv(nt,i,nh,nw,ng) = 10.0**ans
+                  end do  
+
+!     Fill the last pressure point
+
+                  gasv(nt,L_PINT,nh,nw,ng) = &
+                      10.0**gasv8(nt,L_NPREF,nh,nw,ng)
+                  
+               end do
+            end do
+         end do
+      end do
+
+
+!=======================================================================
+!     Initialise the continuum absorption data
+      if(continuum)then
+      do igas=1,ngasmx
+
+         if (igas .eq. igas_N2) then
+
+            dummy = -9999
+            call interpolateN2N2(100.D+0,250.D+0,17500.D+0,testcont,.true.,dummy)
+
+         elseif (igas .eq. igas_H2) then
+
+            ! first do self-induced absorption
+            dummy = -9999
+            call interpolateH2H2(500.D+0,250.D+0,17500.D+0,testcont,.true.,dummy)
+            ! then cross-interactions with other gases
+            do jgas=1,ngasmx
+               if (jgas .eq. igas_N2) then
+                  dummy = -9999
+                  call interpolateN2H2(592.D+0,278.15D+0,200000.D+0,10000.D+0,testcont,.true.,dummy)
+               elseif (jgas .eq. igas_He) then
+                  dummy = -9999
+                  call interpolateH2He(500.D+0,250.D+0,200000.D+0,10000.D+0,testcont,.true.,dummy)
+               endif
+            enddo
+
+         elseif (igas .eq. igas_H2O) then
+
+            ! H2O is special 
+            if(H2Ocont_simple)then
+               call interpolateH2Ocont_PPC(990.D+0,296.D+0,683.2D+0*2,0.D+0,testcont,.true.)
+            else
+               dummy = -9999
+               call interpolateH2Ocont_CKD(990.D+0,296.D+0,683.2D+0*2,0.D+0,testcont,.true.,dummy)
+            endif
+
+         endif
+
+      enddo
+      endif
+
+      print*,'----------------------------------------------------'
+      print*,'And that`s all we have. It`s possible that other'
+      print*,'continuum absorption may be present, but if it is we'
+      print*,'don`t yet have data for it...'
+      print*,''
+
+!     Deallocate local arrays
+!$OMP BARRIER
+!$OMP MASTER
+      IF( ALLOCATED( gasi8 ) ) DEALLOCATE( gasi8 )
+      IF( ALLOCATED( gasv8 ) ) DEALLOCATE( gasv8 )
+      IF( ALLOCATED( pgasref ) ) DEALLOCATE( pgasref )
+      IF( ALLOCATED( gastype ) ) DEALLOCATE( gastype )
+!$OMP END MASTER
+!$OMP BARRIER
+
+      return
+    end subroutine sugas_corrk
Index: /trunk/LMDZ.TITAN/libf/phytitan/surf_heat_transp_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/surf_heat_transp_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/surf_heat_transp_mod.F90	(revision 1644)
@@ -0,0 +1,553 @@
+!
+! $Header: /home/cvsroot/LMDZ4/libf/phylmd/ocean_slab_mod.F90,v 1.3 2008-02-04 16:24:28 fairhead Exp $
+!
+MODULE surf_heat_transp_mod
+
+IMPLICIT NONE  
+
+  ! Variables copied over from dyn3d dynamics:
+  REAL,SAVE,ALLOCATABLE :: fext(:)
+  REAL,SAVE,ALLOCATABLE :: unsairez(:)
+  REAL,SAVE,ALLOCATABLE :: unsaire(:)
+  REAL,SAVE,ALLOCATABLE :: cu(:)
+  REAL,SAVE,ALLOCATABLE :: cv(:)
+  REAL,SAVE,ALLOCATABLE :: cuvsurcv(:)
+  REAL,SAVE,ALLOCATABLE :: cvusurcu(:)
+  REAL,SAVE,ALLOCATABLE :: aire(:)
+  REAL,SAVE :: apoln
+  REAL,SAVE :: apols
+  REAL,SAVE,ALLOCATABLE :: aireu(:)
+  REAL,SAVE,ALLOCATABLE :: airev(:) 
+
+  LOGICAL,SAVE :: alpha_var
+  LOGICAL,SAVE :: slab_upstream
+  REAL,SAVE,ALLOCATABLE :: zmasqu(:)
+  REAL,SAVE,ALLOCATABLE :: zmasqv(:)
+  REAL,SAVE,ALLOCATABLE :: unsfv(:)
+  REAL,SAVE,ALLOCATABLE :: unsev(:)
+  REAL,SAVE,ALLOCATABLE :: unsfu(:)
+  REAL,SAVE,ALLOCATABLE :: unseu(:)
+
+  ! Routines usable only by routines within this module:
+  PRIVATE :: gr_fi_dyn, gr_dyn_fi
+  ! Routines from dyn3d, valid on global dynamics grid only:
+  PRIVATE :: grad,diverg,gr_u_scal,gr_v_scal
+  
+CONTAINS
+  
+  SUBROUTINE ini_surf_heat_transp(ip1jm,ip1jmp1,unsairez_,fext_,unsaire_,&
+                                  cu_,cuvsurcv_,cv_,cvusurcu_, &
+                                  aire_,apoln_,apols_, &
+                                  aireu_,airev_)
+    USE mod_grid_phy_lmdz, only: nbp_lon, nbp_lat
+    IMPLICIT NONE
+    ! Transfer some variables from dyn3d dynamics
+    INTEGER,INTENT(IN) :: ip1jm
+    INTEGER,INTENT(IN) :: ip1jmp1
+    REAL,INTENT(IN) :: unsairez_(ip1jm)
+    REAL,INTENT(IN) :: fext_(ip1jm)
+    REAL,INTENT(IN) :: unsaire_(ip1jmp1)
+    REAL,INTENT(IN) :: cu_(ip1jmp1)
+    REAL,INTENT(IN) :: cuvsurcv_(ip1jm)
+    REAL,INTENT(IN) :: cv_(ip1jm)
+    REAL,INTENT(IN) :: cvusurcu_(ip1jmp1)
+    REAL,INTENT(IN) :: aire_(ip1jmp1)
+    REAL,INTENT(IN) :: apoln_
+    REAL,INTENT(IN) :: apols_
+    REAL,INTENT(IN) :: aireu_(ip1jmp1)
+    REAL,INTENT(IN) :: airev_(ip1jm)
+    
+    ! Sanity check
+    if ((ip1jm.ne.((nbp_lon+1)*(nbp_lat-1))).or. &
+        (ip1jmp1.ne.((nbp_lon+1)*nbp_lat))) then
+      write(*,*) "ini_surf_heat_transp Error: wrong array sizes"
+      stop
+    endif
+    
+    allocate(unsairez(ip1jm))
+    unsairez(:)=unsairez_(:)
+    allocate(fext(ip1jm))
+    fext(:)=fext_(:)
+    allocate(unsaire(ip1jmp1))
+    unsaire(:)=unsaire_(:)
+    allocate(cu(ip1jmp1))
+    cu(:)=cu_(:)
+    allocate(cuvsurcv(ip1jm))
+    cuvsurcv(:)=cuvsurcv_(:)
+    allocate(cv(ip1jm))
+    cv(:)=cv_(:)
+    allocate(cvusurcu(ip1jmp1))
+    cvusurcu(:)=cvusurcu_(:)
+    allocate(aire(ip1jmp1))
+    aire(:)=aire_(:)
+    apoln=apoln_
+    apols=apols_
+    allocate(aireu(ip1jmp1))
+    aireu(:)=aireu_(:)
+    allocate(airev(ip1jm))
+    airev(:)=airev_(:)
+    
+  END SUBROUTINE ini_surf_heat_transp
+  
+  SUBROUTINE ini_surf_heat_transp_mod
+    USE mod_grid_phy_lmdz, only: nbp_lon, nbp_lat
+    IMPLICIT NONE
+    INTEGER :: ip1jm, ip1jmp1
+    
+    ip1jm=(nbp_lon+1)*(nbp_lat-1)
+    ip1jmp1=(nbp_lon+1)*nbp_lat
+  
+    allocate(zmasqu(ip1jmp1))
+    allocate(zmasqv(ip1jm))
+    allocate(unsfv(ip1jm))
+    allocate(unsev(ip1jm))
+    allocate(unsfu(ip1jmp1))
+    allocate(unseu(ip1jmp1))
+
+  END SUBROUTINE ini_surf_heat_transp_mod
+
+  SUBROUTINE divgrad_phy(ngrid,nlevs,temp,delta)
+
+      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+      IMPLICIT NONE
+
+      INTEGER,INTENT(IN) :: ngrid, nlevs
+      REAL,INTENT(IN) :: temp(ngrid,nlevs)
+      REAL,INTENT(OUT) :: delta(ngrid,nlevs)
+      REAL delta_2d((nbp_lon+1)*nbp_lat,nlevs)
+      INTEGER :: ll
+      REAL ghx((nbp_lon+1)*nbp_lat,nlevs)
+      REAL ghy((nbp_lon+1)*(nbp_lat-1),nlevs)
+      INTEGER :: iip1,jjp1
+      
+      iip1=nbp_lon+1
+      jjp1=nbp_lat
+
+      CALL gr_fi_dyn(nlevs,ngrid,iip1,jjp1,temp,delta_2d)
+      CALL grad(nlevs,delta_2d,ghx,ghy)
+      DO ll=1,nlevs
+          ghx(:,ll)=ghx(:,ll)*zmasqu
+! pas de diffusion zonale  
+!          ghx(:,ll)=0.
+          ghy(:,ll)=ghy(:,ll)*zmasqv
+      END DO
+      CALL diverg(nlevs,ghx,ghy,delta_2d)
+      CALL gr_dyn_fi(nlevs,iip1,jjp1,ngrid,delta_2d,delta)
+
+
+  END SUBROUTINE divgrad_phy
+
+
+
+  SUBROUTINE init_masquv(ngrid,zmasq)
+
+      USE mod_grid_phy_lmdz, only: nbp_lon, nbp_lat
+      IMPLICIT NONE
+
+
+      INTEGER,INTENT(IN) :: ngrid
+      REAL zmasq(ngrid)
+      REAL zmasq_2d((nbp_lon+1)*nbp_lat)
+      REAL ff((nbp_lon+1)*(nbp_lat-1))
+      REAL eps
+      INTEGER i
+      INTEGER :: iim,iip1,jjp1,ip1jm,ip1jmp1
+      
+      iim=nbp_lon
+      iip1=nbp_lon+1
+      jjp1=nbp_lat
+      ip1jm=(nbp_lon+1)*(nbp_lat-1)
+      ip1jmp1=(nbp_lon+1)*nbp_lat
+
+! Masques u,v
+      zmasqu=1.
+      zmasqv=1.
+
+      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,zmasq,zmasq_2d)
+
+      DO i=1,ip1jmp1-1
+        IF (zmasq_2d(i).GT.1e-5 .OR. zmasq_2d(i+1).GT.1e-5) THEN
+                zmasqu(i)=0.
+        ENDIF
+      END DO
+      DO i=iip1,ip1jmp1,iip1
+        zmasqu(i)=zmasqu(i-iim)
+      END DO
+      DO i=1,ip1jm
+        IF (zmasq_2d(i).GT.1e-5 .OR. zmasq_2d(i+iip1).GT.1e-5) THEN  
+                zmasqv(i)=0.
+        END IF
+      END DO
+
+
+! Coriolis (pour Ekman transp.)
+      eps=1e-5
+!      CALL getin('slab_eps',eps)
+!      print *,'epsilon=',eps
+      ff=fext*unsairez       
+      DO i=1,ip1jm
+        unsev(i)=eps/(ff(i)*ff(i)+eps**2)
+        unsfv(i)=ff(i)/(ff(i)*ff(i)+eps**2)
+      ENDDO
+      CALL gr_v_scal(1,unsfv,unsfu)
+      CALL gr_v_scal(1,unsev,unseu)
+! Alpha variable?
+!      alpha_var=.FALSE.
+!      CALL getin('slab_alphav',alpha_var)
+
+
+      
+  END SUBROUTINE init_masquv
+
+
+
+  SUBROUTINE slab_ekman2(ngrid,tx_phy,ty_phy,ts_phy,dt_phy)
+  
+      USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+      USE slab_ice_h, ONLY: noceanmx
+
+      IMPLICIT NONE
+      
+      INTEGER,INTENT(IN) :: ngrid
+      INTEGER ij
+      REAL txv((nbp_lon+1)*(nbp_lat-1)),fluxm((nbp_lon+1)*(nbp_lat-1))
+      REAL tyv((nbp_lon+1)*(nbp_lat-1))
+      REAL fluxtm((nbp_lon+1)*(nbp_lat-1),noceanmx)
+      REAL fluxtz((nbp_lon+1)*nbp_lat,noceanmx)
+      REAL tyu((nbp_lon+1)*nbp_lat),txu((nbp_lon+1)*nbp_lat)
+      REAL fluxz((nbp_lon+1)*nbp_lat),fluxv((nbp_lon+1)*nbp_lat)
+      REAL dt((nbp_lon+1)*nbp_lat,noceanmx),ts((nbp_lon+1)*nbp_lat,noceanmx)
+      REAL tx_phy(ngrid),ty_phy(ngrid)
+      REAL dt_phy(ngrid,noceanmx),ts_phy(ngrid,noceanmx)
+
+      INTEGER iim,iip1,iip2,jjp1,ip1jm,ip1jmi1,ip1jmp1
+
+      iim=nbp_lon
+      iip1=nbp_lon+1
+      iip2=nbp_lon+2
+      jjp1=nbp_lat
+      ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
+      ip1jmi1=(nbp_lon+1)*(nbp_lat-1)-(nbp_lon+1) ! = ip1jm - iip1
+      ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
+
+! Passage taux,y sur grilles 2d
+      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,tx_phy,txu)
+      CALL gr_fi_dyn(1,ngrid,iip1,jjp1,ty_phy,tyu)
+! Passage grille u,v
+! Multiplication par f ou eps.
+      CALL gr_v_scal(1,txu,txv)
+      CALL gr_v_scal(1,tyu,tyv)
+      fluxm=tyv*unsev-txv*unsfv
+!      fluxm=-txv*unsfv
+      CALL gr_u_scal(1,txu,txu)
+      CALL gr_u_scal(1,tyu,tyu)
+      fluxz=tyu*unsfu+txu*unseu
+!      fluxz=tyu*unsfu
+            
+! Calcul de T, Tdeep
+      CALL gr_fi_dyn(2,ngrid,iip1,jjp1,ts_phy,ts)
+       
+! Flux de masse
+      fluxm=fluxm*cv*cuvsurcv*zmasqv
+      fluxz=fluxz*cu*cvusurcu*zmasqu
+! Flux de masse vertical
+      DO ij=iip2,ip1jm
+        fluxv(ij)=fluxz(ij)-fluxz(ij-1)-fluxm(ij)+fluxm(ij-iip1)
+      ENDDO
+      DO ij=iip1,ip1jmi1,iip1
+         fluxv(ij+1)=fluxv(ij+iip1)
+      END DO
+! Poles
+      fluxv(1)=-SUM(fluxm(1:iim))     
+      fluxv(ip1jmp1)=SUM(fluxm(ip1jm-iim:ip1jm-1))
+      fluxv=fluxv
+
+!Calcul flux de chaleur méridiens
+      DO ij=1,ip1jm
+          fluxtm(ij,1)=fluxm(ij)*(ts(ij+iip1,1)+ts(ij,1))/2.
+          fluxtm(ij,2)=-fluxm(ij)*(ts(ij+iip1,2)+ts(ij,2))/2.
+      END DO
+
+!Calcul flux chaleur zonaux
+      DO ij=iip2,ip1jm
+      IF (fluxz(ij).GE.0.) THEN
+             fluxtz(ij,1)=fluxz(ij)*ts(ij,1)
+             fluxtz(ij,2)=-fluxz(ij)*ts(ij+1,2)
+      ELSE
+             fluxtz(ij,1)=fluxz(ij)*ts(ij+1,1)
+             fluxtz(ij,2)=-fluxz(ij)*ts(ij,2)
+      ENDIF
+      END DO
+      DO ij=iip1*2,ip1jmp1,iip1
+             fluxtz(ij,:)=fluxtz(ij-iim,:)
+      END DO
+                   
+! Calcul de dT
+      DO ij=iip2,ip1jm
+         dt(ij,:)=fluxtz(ij-1,:)-fluxtz(ij,:)   &
+                  +fluxtm(ij,:)-fluxtm(ij-iip1,:)
+         IF (fluxv(ij).GT.0.) THEN
+           dt(ij,1)=dt(ij,1)+fluxv(ij)*ts(ij,2)
+           dt(ij,2)=dt(ij,2)-fluxv(ij)*ts(ij,2)
+         ELSE
+           dt(ij,1)=dt(ij,1)+fluxv(ij)*ts(ij,1)
+           dt(ij,2)=dt(ij,2)-fluxv(ij)*ts(ij,1)
+         ENDIF
+         dt(ij,:)=dt(ij,:)/aire(ij)
+      END DO
+      DO ij=iip1,ip1jmi1,iip1
+         dt(ij+1,:)=dt(ij+iip1,:) 
+      END DO
+! Pôles
+      dt(1,:)=SUM(fluxtm(1:iim,:),dim=1)
+        IF (fluxv(1).GT.0.) THEN
+          dt(1,1)=dt(1,1)+fluxv(1)*ts(1,2)
+          dt(1,2)=dt(1,2)-fluxv(1)*ts(1,2)
+        ELSE
+          dt(1,1)=dt(1,1)+fluxv(1)*ts(1,1)
+          dt(1,2)=dt(1,2)-fluxv(1)*ts(1,1)
+        ENDIF
+      dt(1,:)=dt(1,:)/apoln
+      dt(ip1jmp1,:)=-SUM(fluxtm(ip1jm-iim:ip1jm-1,:),dim=1)
+       IF (fluxv(ip1jmp1).GT.0.) THEN
+         dt(ip1jmp1,1)=dt(ip1jmp1,1)+fluxv(ip1jmp1)*ts(ip1jmp1,2)
+         dt(ip1jmp1,2)=dt(ip1jmp1,2)-fluxv(ip1jmp1)*ts(ip1jmp1,2)
+       ELSE
+         dt(ip1jmp1,1)=dt(ip1jmp1,1)+fluxv(ip1jmp1)*ts(ip1jmp1,1)
+         dt(ip1jmp1,2)=dt(ip1jmp1,2)-fluxv(ip1jmp1)*ts(ip1jmp1,1)
+       ENDIF
+      dt(ip1jmp1,:)=dt(ip1jmp1,:)/apols
+      dt(2:iip1,1)=dt(1,1)
+      dt(2:iip1,2)=dt(1,2)
+      dt(ip1jm+1:ip1jmp1,1)=dt(ip1jmp1,1)
+      dt(ip1jm+1:ip1jmp1,2)=dt(ip1jmp1,2)
+
+! Retour grille physique
+      CALL gr_dyn_fi(2,iip1,jjp1,ngrid,dt,dt_phy)
+
+
+  END SUBROUTINE slab_ekman2
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE gr_fi_dyn(nfield,ngrid,im,jm,pfi,pdyn)
+  ! Transfer a variable on global "physics" grid to global "dynamics" grid
+  IMPLICIT NONE
+
+  INTEGER,INTENT(IN) :: im,jm,ngrid,nfield
+  REAL,INTENT(IN) :: pfi(ngrid,nfield)
+  REAL,INTENT(OUT) :: pdyn(im,jm,nfield)
+  
+  INTEGER :: i,j,ifield,ig
+  
+  DO ifield=1,nfield
+    ! Handle poles
+    DO i=1,im
+      pdyn(i,1,ifield)=pfi(1,ifield)
+      pdyn(i,jm,ifield)=pfi(ngrid,ifield)
+    ENDDO
+    ! Other points
+    DO j=2,jm-1
+      ig=2+(j-2)*(im-1)
+      CALL SCOPY(im-1,pfi(ig,ifield),1,pdyn(1,j,ifield),1)
+      pdyn(im,j,ifield)=pdyn(1,j,ifield)
+    ENDDO
+  ENDDO ! of DO ifield=1,nfield
+  
+  END SUBROUTINE gr_fi_dyn
+  
+
+
+  SUBROUTINE gr_dyn_fi(nfield,im,jm,ngrid,pdyn,pfi)
+  ! Transfer a variable on global "dynamics" grid to global "physics" grid
+  IMPLICIT NONE
+  
+  INTEGER,INTENT(IN) :: im,jm,ngrid,nfield
+  REAL,INTENT(IN) :: pdyn(im,jm,nfield)
+  REAL,INTENT(OUT) :: pfi(ngrid,nfield)
+  
+  INTEGER j,ifield,ig
+
+  ! Sanity check:
+  IF(ngrid.NE.2+(jm-2)*(im-1)) THEN
+    WRITE(*,*) "gr_dyn_fi error, wrong sizes"
+    STOP
+  ENDIF
+  
+  ! Handle poles
+  CALL SCOPY(nfield,pdyn,im*jm,pfi,ngrid)
+  CALL SCOPY(nfield,pdyn(1,jm,1),im*jm,pfi(ngrid,1),ngrid)
+  ! Other points
+  DO ifield=1,nfield
+    DO j=2,jm-1
+      ig=2+(j-2)*(im-1)
+      CALL SCOPY(im-1,pdyn(1,j,ifield),1,pfi(ig,ifield),1)
+    ENDDO
+  ENDDO
+
+  END SUBROUTINE gr_dyn_fi
+
+
+
+  SUBROUTINE  grad(klevel,pg,pgx,pgy)
+  ! compute the covariant components x,y of the gradient of pg
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+  IMPLICIT NONE
+  
+  INTEGER,INTENT(IN) :: klevel
+  REAL,INTENT(IN) :: pg((nbp_lon+1)*nbp_lat,klevel)
+  REAL,INTENT(OUT) :: pgx((nbp_lon+1)*nbp_lat,klevel)
+  REAL,INTENT(OUT) :: pgy((nbp_lon+1)*(nbp_lat-1),klevel)
+
+  INTEGER :: l,ij
+  INTEGER :: iim,iip1,ip1jm,ip1jmp1
+  
+  iim=nbp_lon
+  iip1=nbp_lon+1
+  ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
+  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
+  
+  DO l=1,klevel
+    DO ij=1,ip1jmp1-1
+      pgx(ij,l)=pg(ij+1,l)-pg(ij,l)
+    ENDDO
+    ! correction for pgx(ip1,j,l) ...
+    ! ... pgx(iip1,j,l)=pgx(1,j,l) ...
+    DO ij=iip1,ip1jmp1,iip1
+      pgx(ij,l)=pgx(ij-iim,l)
+    ENDDO
+    DO ij=1,ip1jm
+      pgy(ij,l)=pg(ij,l)-pg(ij+iip1,l)
+    ENDDO
+  ENDDO
+  
+  END SUBROUTINE grad
+
+
+
+  SUBROUTINE diverg(klevel,x,y,div)
+  ! compute the divergence of a vector field of components
+  ! x,y. y and y being covriant components
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+  IMPLICIT NONE
+  
+  INTEGER,INTENT(IN) :: klevel
+  REAL,INTENT(IN) :: x((nbp_lon+1)*nbp_lat,klevel)
+  REAL,INTENT(IN) :: y((nbp_lon+1)*(nbp_lat-1),klevel)
+  REAL,INTENT(OUT) :: div((nbp_lon+1)*nbp_lat,klevel)
+  
+  INTEGER :: l,ij
+  INTEGER :: iim,iip1,iip2,ip1jm,ip1jmp1,ip1jmi1
+  
+  REAL :: aiy1(nbp_lon+1),aiy2(nbp_lon+1)
+  REAL :: sumypn,sumyps
+  REAL,EXTERNAL :: SSUM
+  
+  iim=nbp_lon
+  iip1=nbp_lon+1
+  iip2=nbp_lon+2
+  ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
+  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
+  ip1jmi1=(nbp_lon+1)*(nbp_lat-1)-(nbp_lon+1) ! = ip1jm - iip1
+  
+  DO l=1,klevel
+    DO ij=iip2,ip1jm-1
+      div(ij+1,l)= &
+        cvusurcu(ij+1)*x(ij+1,l)-cvusurcu(ij)*x(ij,l)+ &
+        cuvsurcv(ij-iim)*y(ij-iim,l)-cuvsurcv(ij+1)*y(ij+1,l) 
+    ENDDO
+    ! correction for div(1,j,l) ...
+    ! ... div(1,j,l)= div(iip1,j,l) ...
+    DO ij=iip2,ip1jm,iip1
+      div(ij,l)=div(ij+iim,l)
+    ENDDO
+    ! at the poles
+    DO ij=1,iim
+      aiy1(ij)=cuvsurcv(ij)*y(ij,l)
+      aiy2(ij)=cuvsurcv(ij+ip1jmi1)*y(ij+ip1jmi1,l)
+    ENDDO
+    sumypn=SSUM(iim,aiy1,1)/apoln
+    sumyps=SSUM(iim,aiy2,1)/apols
+    DO ij=1,iip1
+      div(ij,l)=-sumypn
+      div(ij+ip1jm,l)=sumyps
+    ENDDO
+  ENDDO ! of DO l=1,klevel
+  
+  !!! CALL filtreg( div, jjp1, klevel, 2, 2, .TRUE., 1 )
+  
+  DO l=1,klevel
+    DO ij=iip2,ip1jm
+      div(ij,l)=div(ij,l)*unsaire(ij) 
+    ENDDO
+  ENDDO
+  
+  END SUBROUTINE diverg
+
+
+
+  SUBROUTINE gr_u_scal(nx,x_u,x_scal)
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+  IMPLICIT NONE
+  
+  INTEGER,INTENT(IN) :: nx
+  REAL,INTENT(IN) :: x_u((nbp_lon+1)*nbp_lat,nx)
+  REAL,INTENT(OUT) :: x_scal((nbp_lon+1)*nbp_lat,nx)
+  
+  INTEGER :: l,ij
+  INTEGER :: iip1,jjp1,ip1jmp1
+  
+  iip1=nbp_lon+1
+  jjp1=nbp_lat
+  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
+  
+  DO l=1,nx
+    DO ij=ip1jmp1,2,-1
+      x_scal(ij,l)= &
+                   (aireu(ij)*x_u(ij,l)+aireu(ij-1)*x_u(ij-1,l)) &
+                  /(aireu(ij)+aireu(ij-1))
+    ENDDO
+  ENDDO
+  
+  CALL SCOPY(nx*jjp1,x_scal(iip1,1),iip1,x_scal(1,1),iip1)
+
+  END SUBROUTINE gr_u_scal
+
+
+
+  SUBROUTINE gr_v_scal(nx,x_v,x_scal)
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+  IMPLICIT NONE
+  
+  INTEGER,INTENT(IN) :: nx
+  REAL,INTENT(IN) :: x_v((nbp_lon+1)*(nbp_lat-1),nx)
+  REAL,INTENT(OUT) :: x_scal((nbp_lon+1)*nbp_lat,nx)
+  
+  INTEGER :: l,ij
+  INTEGER :: iip1,iip2,ip1jm,ip1jmp1
+  
+  iip1=nbp_lon+1
+  iip2=nbp_lon+2
+  ip1jm=(nbp_lon+1)*(nbp_lat-1) ! = iip1*jjm
+  ip1jmp1=(nbp_lon+1)*nbp_lat ! = iip1*jjp1
+  
+  DO l=1,nx
+    DO ij=iip2,ip1jm
+      x_scal(ij,l)= &
+                   (airev(ij-iip1)*x_v(ij-iip1,l)+airev(ij)*x_v(ij,l)) &
+                  /(airev(ij-iip1)+airev(ij))
+    ENDDO
+    DO ij=1,iip1
+      x_scal(ij,l)=0.
+    ENDDO
+    DO ij=ip1jm+1,ip1jmp1
+      x_scal(ij,l)=0.
+    ENDDO
+  ENDDO
+
+  END SUBROUTINE gr_v_scal
+  
+END MODULE surf_heat_transp_mod
+
+
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/surface_nature.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/surface_nature.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/surface_nature.F	(revision 1644)
@@ -0,0 +1,64 @@
+      SUBROUTINE surface_nature(ngrid,nq,obliquit,qsurf,qsurfliquid
+     &   ,qsurfsnow,rnat,oceanarea)
+
+      USE surfdat_h
+      USE comsoil_h
+      USE geometry_mod, ONLY: cell_area
+      USE tracer_h
+
+      IMPLICIT none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Defines a few things
+!     
+!     Authors
+!     ------- 
+!     B. Charnay (2010)
+!     
+!     Called by
+!     ---------
+!     physiq.F
+!     
+!     Calls
+!     -----
+!     none
+!
+!     Notes
+!     -----
+!     rnat is terrain type: 0-ocean; 1-continent; 2-continental ice
+!     
+!==================================================================
+
+        integer ngrid,nq
+
+	REAL qsurf(ngrid,nq),ps(ngrid)
+	REAL qsurfliquid(ngrid)
+	REAL qsurfsnow(ngrid)
+	INTEGER iq, ig
+	INTEGER rnat(ngrid)
+ 	REAL oceanarea
+	REAL obliquit
+
+	do ig=1,ngrid
+           rnat(ig)=1
+           dryness(ig)=1        !(coefficient for evaporation)
+           if (inertiedat(ig,1).gt.1E4) then
+              rnat(ig)=0
+           end if
+	end do
+
+! surface of all the oceans
+        
+        oceanarea=0.
+	do ig=1,ngrid
+           if (rnat(ig).eq.0)then
+              oceanarea=oceanarea+cell_area(ig)
+           end if
+	enddo
+
+        return
+        end
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/surfdat_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/surfdat_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/surfdat_h.F90	(revision 1644)
@@ -0,0 +1,26 @@
+
+       module surfdat_h
+
+       implicit none
+
+       real,allocatable,dimension(:) :: albedodat ! albedo of bare ground stocked in startfi.nc file.
+!$OMP THREADPRIVATE(albedodat)
+       ! Ehouarn: moved inertiedat to comsoil.h
+       !      real inertiedat, ! thermal inertia
+       real,allocatable,dimension(:) :: phisfi ! geopotential at ground level
+!$OMP THREADPRIVATE(phisfi)
+       real,dimension(2) :: emisice ! ice emissivity; 1:Northern hemisphere 2:Southern hemisphere
+       real emissiv
+       real,dimension(2) :: iceradius, dtemisice
+!$OMP THREADPRIVATE(emisice,emissiv,iceradius,dtemisice)
+       real,allocatable,dimension(:) :: zmea,zstd,zsig,zgam,zthe
+!$OMP THREADPRIVATE(zmea,zstd,zsig,zgam,zthe)
+
+       real,allocatable,dimension(:) :: dryness  !"Dryness coefficient" for grnd water ice sublimation
+                                                 ! AS: previously in tracer.h. it is more logical here.
+
+       logical,allocatable,dimension(:) :: watercaptag !! was in watercap.h
+!$OMP THREADPRIVATE(dryness,watercaptag)
+
+       end module surfdat_h
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/surfini.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/surfini.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/surfini.F	(revision 1644)
@@ -0,0 +1,76 @@
+      SUBROUTINE surfini(ngrid,nq,qsurf,albedo,albedo_bareground,
+     &                   albedo_snow_SPECTV,albedo_co2_ice_SPECTV)
+
+      USE surfdat_h, only: albedodat
+      USE tracer_h, only: igcm_co2_ice
+      use planetwide_mod, only: planetwide_maxval, planetwide_minval
+      use radinc_h, only : L_NSPECTV
+      use callkeys_mod, only : albedosnow, albedoco2ice
+
+      IMPLICIT NONE
+      
+      
+ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+cccccccccccccc                                                                 cccccccccccccc
+cccccccccccccc   Spectral Albedo Initialisation - Routine modified by MT2015.  cccccccccccccc
+cccccccccccccc                                                                 cccccccccccccc 
+ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
+
+c--------------------
+c   Declarations:
+c--------------------
+
+      INTEGER,INTENT(IN) :: ngrid
+      INTEGER,INTENT(IN) :: nq
+      REAL,INTENT(OUT) :: albedo(ngrid,L_NSPECTV)
+      REAL,INTENT(OUT) :: albedo_bareground(ngrid)
+      REAL,INTENT(OUT) :: albedo_snow_SPECTV(L_NSPECTV)
+      REAL,INTENT(OUT) :: albedo_co2_ice_SPECTV(L_NSPECTV)
+      REAL,INTENT(IN) :: qsurf(ngrid,nq) ! tracer on surface (kg/m2)
+
+      INTEGER :: ig,nw
+      REAL :: min_albedo,max_albedo
+
+c=======================================================================
+
+      ! Step 1 : Initialisation of the Spectral Albedos.
+      DO nw=1,L_NSPECTV
+         albedo_snow_SPECTV(nw)=albedosnow
+         albedo_co2_ice_SPECTV(nw)=albedoco2ice
+      ENDDO
+
+
+      ! Step 2 : We get the bare ground albedo from the start files.
+      DO ig=1,ngrid
+         albedo_bareground(ig)=albedodat(ig)
+	 DO nw=1,L_NSPECTV
+	    albedo(ig,nw)=albedo_bareground(ig)
+	 ENDDO
+      ENDDO
+      call planetwide_minval(albedo_bareground,min_albedo)
+      call planetwide_maxval(albedo_bareground,max_albedo)
+      write(*,*) 'surfini: minimum bare ground albedo',min_albedo
+      write(*,*) 'surfini: maximum bare ground albedo',max_albedo
+
+
+      ! Step 3 : We modify the albedo considering some CO2 at the surface. We dont take into account water ice (this is made in hydrol after the first timestep) ...
+      if (igcm_co2_ice.ne.0) then
+         DO ig=1,ngrid
+            IF (qsurf(ig,igcm_co2_ice) .GT. 1.) THEN ! This was changed by MT2015. Condition for ~1mm of CO2 ice deposit.
+	       DO nw=1,L_NSPECTV
+	          albedo(ig,nw)=albedo_co2_ice_SPECTV(nw)
+	       ENDDO
+            END IF   
+         ENDDO   
+      else
+         write(*,*) "surfini: No CO2 ice tracer on surface  ..."
+         write(*,*) "         and therefore no albedo change."
+      endif     
+      call planetwide_minval(albedo,min_albedo)
+      call planetwide_maxval(albedo,max_albedo)
+      write(*,*) 'surfini: minimum corrected initial albedo',min_albedo
+      write(*,*) 'surfini: maximum corrected initial albedo',max_albedo
+
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/tabfi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/tabfi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/tabfi.F	(revision 1644)
@@ -0,0 +1,522 @@
+c=======================================================================
+      SUBROUTINE tabfi(ngrid,nid,Lmodif,tab0,day_ini,lmax,p_rad,
+     .                 p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time)
+c=======================================================================
+c
+c   C. Hourdin 15/11/96
+c
+c   Object:        Lecture du tab_cntrl physique dans un fichier 
+c   ------            et initialisation des constantes physiques
+c
+c   Arguments:
+c   ----------
+c
+c     Inputs:
+c     ------
+c
+c      - nid:    unitne logique du fichier ou on va lire le tab_cntrl    
+c                      (ouvert dans le programme appellant) 
+c
+c                 si nid=0:
+c                       pas de lecture du tab_cntrl mais
+c                       Valeurs par default des constantes physiques
+c        
+c      - tab0:    Offset de tab_cntrl a partir duquel sont ranges 
+c                  les parametres physiques (50 pour start_archive)
+c
+c      - Lmodif:  si on souhaite modifier les constantes  Lmodif = 1 = TRUE
+c
+c
+c     Outputs:
+c     --------
+c
+c      - day_ini: tab_cntrl(tab0+3) (Dans les cas ou l'on souhaite
+c                              comparer avec le day_ini dynamique)
+c
+c      - lmax:    tab_cntrl(tab0+2) (pour test avec nlayer)
+c
+c      - p_rad
+c      - p_omeg   !
+c      - p_g      ! Constantes physiques ayant des 
+c      - p_mugaz  ! homonymes dynamiques
+c      - p_daysec !
+c
+c=======================================================================
+! to use  'getin'
+      use ioipsl_getincom , only: getin
+
+      use surfdat_h, only: emisice, iceradius, dtemisice,
+     &                     emissiv
+      use comsoil_h, only: volcapa
+      use iostart, only: get_var
+      use mod_phys_lmdz_para, only: is_parallel
+      use planete_mod, only: year_day, periastr, apoastr, peri_day,
+     &                       obliquit, z0, lmixmin, emin_turb
+      use comcstfi_mod, only: rad, omeg, g, mugaz, rcp, cpp, r
+      use time_phylmdz_mod, only: dtphys, daysec
+      use callkeys_mod, only: check_cpp_match,force_cpp
+      implicit none
+ 
+#include "netcdf.inc"
+
+c-----------------------------------------------------------------------
+c   Declarations
+c-----------------------------------------------------------------------
+
+c Arguments
+c ---------
+      INTEGER,INTENT(IN) :: ngrid,nid,tab0
+      INTEGER*4,INTENT(OUT) :: day_ini
+      INTEGER,INTENT(IN) :: Lmodif
+      INTEGER,INTENT(OUT) :: lmax
+      REAL,INTENT(OUT) :: p_rad,p_omeg,p_g,p_cpp,p_mugaz,p_daysec,time
+
+c Variables
+c ---------
+      INTEGER,PARAMETER :: length=100
+      REAL tab_cntrl(length) ! array in which are stored the run's parameters
+      INTEGER  ierr,nvarid
+      INTEGER size
+      CHARACTER modif*20
+      LOGICAL :: found
+      
+      write(*,*)"tabfi: nid=",nid," tab0=",tab0," Lmodif=",Lmodif
+
+      IF (nid.eq.0) then
+c-----------------------------------------------------------------------
+c  Initialization of various physical constants to defaut values (nid = 0 case)
+c-----------------------------------------------------------------------
+      ELSE
+c-----------------------------------------------------------------------
+c  Initialization of physical constants by reading array tab_cntrl(:)
+c		which contains these parameters	(nid != 0 case)
+c-----------------------------------------------------------------------
+c Read 'controle' array
+c
+
+       call get_var("controle",tab_cntrl,found)
+       if (.not.found) then
+         write(*,*)"tabfi: Failed reading <controle> array"
+         call abort
+       else
+         write(*,*)'tabfi: tab_cntrl',tab_cntrl
+       endif
+c
+c  Initialization of some physical constants
+c informations on physics grid
+!      if(ngrid.ne.tab_cntrl(tab0+1)) then
+!         print*,'tabfi: WARNING !!! tab_cntrl(tab0+1).ne.ngrid'
+!         print*,tab_cntrl(tab0+1),ngrid
+!      endif
+      lmax = nint(tab_cntrl(tab0+2))
+      day_ini = tab_cntrl(tab0+3)
+      time = tab_cntrl(tab0+4)
+      write (*,*) 'IN tabfi day_ini=',day_ini
+c Informations about planet for dynamics and physics
+      rad = tab_cntrl(tab0+5)
+      omeg = tab_cntrl(tab0+6)
+      g = tab_cntrl(tab0+7)
+      mugaz = tab_cntrl(tab0+8)
+      rcp = tab_cntrl(tab0+9)
+      cpp=(8.314511/(mugaz/1000.0))/rcp
+      daysec = tab_cntrl(tab0+10)
+      dtphys = tab_cntrl(tab0+11)
+c Informations about planet for the physics only
+      year_day = tab_cntrl(tab0+14)
+      periastr = tab_cntrl(tab0+15)
+      apoastr = tab_cntrl(tab0+16)
+      peri_day = tab_cntrl(tab0+17)
+      obliquit = tab_cntrl(tab0+18)
+c boundary layer and turbeulence
+      z0 = tab_cntrl(tab0+19)
+      lmixmin = tab_cntrl(tab0+20)
+      emin_turb = tab_cntrl(tab0+21)
+c optical properties of polar caps and ground emissivity
+      emisice(1) = tab_cntrl(tab0+24)
+      emisice(2) = tab_cntrl(tab0+25)
+      emissiv    = tab_cntrl(tab0+26)
+      iceradius(1)= tab_cntrl(tab0+31) ! mean scat radius of CO2 snow (north)
+      iceradius(2)= tab_cntrl(tab0+32) ! mean scat radius of CO2 snow (south)
+      dtemisice(1)= tab_cntrl(tab0+33) !time scale for snow metamorphism (north)
+      dtemisice(2)= tab_cntrl(tab0+34) !time scale for snow metamorphism (south)
+c soil properties
+      volcapa = tab_cntrl(tab0+35) ! volumetric heat capacity
+c-----------------------------------------------------------------------
+c	Save some constants for later use (as routine arguments)
+c-----------------------------------------------------------------------
+      p_omeg = omeg
+      p_g = g
+      p_cpp = cpp
+      p_mugaz = mugaz
+      p_daysec = daysec
+      p_rad=rad
+
+      ENDIF    ! end of (nid = 0) 
+
+c-----------------------------------------------------------------------
+c	Write physical constants to output before modifying them
+c-----------------------------------------------------------------------
+ 
+   6  FORMAT(a20,e15.6,e15.6)
+   5  FORMAT(a20,f12.2,f12.2)
+ 
+      write(*,*) '*****************************************************'
+      write(*,*) 'Reading tab_cntrl when calling tabfi before changes'
+      write(*,*) '*****************************************************'
+      write(*,5) '(1)        = ngrid?',tab_cntrl(tab0+1),float(ngrid)
+      write(*,5) '(2)            lmax',tab_cntrl(tab0+2),float(lmax)
+      write(*,5) '(3)         day_ini',tab_cntrl(tab0+3),float(day_ini)
+      write(*,5) '(5)             rad',tab_cntrl(tab0+5),rad
+      write(*,5) '(10)         daysec',tab_cntrl(tab0+10),daysec
+      write(*,6) '(6)            omeg',tab_cntrl(tab0+6),omeg
+      write(*,5) '(7)               g',tab_cntrl(tab0+7),g
+      write(*,5) '(8)           mugaz',tab_cntrl(tab0+8),mugaz
+      write(*,5) '(9)             rcp',tab_cntrl(tab0+9),rcp
+      write(*,6) '(11)        dtphys?',tab_cntrl(tab0+11),dtphys
+
+      write(*,5) '(14)       year_day',tab_cntrl(tab0+14),year_day
+      write(*,5) '(15)       periastr',tab_cntrl(tab0+15),periastr
+      write(*,5) '(16)        apoastr',tab_cntrl(tab0+16),apoastr
+      write(*,5) '(17)       peri_day',tab_cntrl(tab0+17),peri_day
+      write(*,5) '(18)       obliquit',tab_cntrl(tab0+18),obliquit
+
+      write(*,6) '(19)             z0',tab_cntrl(tab0+19),z0
+      write(*,6) '(21)      emin_turb',tab_cntrl(tab0+21),emin_turb
+      write(*,5) '(20)        lmixmin',tab_cntrl(tab0+20),lmixmin
+
+      write(*,5) '(26)        emissiv',tab_cntrl(tab0+26),emissiv
+      write(*,5) '(24)     emisice(1)',tab_cntrl(tab0+24),emisice(1)
+      write(*,5) '(25)     emisice(2)',tab_cntrl(tab0+25),emisice(2)
+      write(*,6) '(31)   iceradius(1)',tab_cntrl(tab0+31),iceradius(1)
+      write(*,6) '(32)   iceradius(2)',tab_cntrl(tab0+32),iceradius(2)
+      write(*,5) '(33)   dtemisice(1)',tab_cntrl(tab0+33),dtemisice(1)
+      write(*,5) '(34)   dtemisice(2)',tab_cntrl(tab0+34),dtemisice(2)
+
+      write(*,5) '(35)        volcapa',tab_cntrl(tab0+35),volcapa
+
+      write(*,*)
+      write(*,*) 'Lmodif in tabfi!!!!!!!',Lmodif
+
+c-----------------------------------------------------------------------
+c	 Modifications...
+! NB: Modifying controls should only be done by newstart, and in seq mode
+      if ((Lmodif.eq.1).and.is_parallel) then
+        write(*,*) "tabfi: Error modifying tab_control should",
+     &             " only happen in serial mode (eg: by newstart)"
+        stop
+      endif
+c-----------------------------------------------------------------------
+
+      IF(Lmodif.eq.1) then
+
+      write(*,*)
+      write(*,*) 'Change values in tab_cntrl ? :'
+      write(*,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+      write(*,*) '(Current values given above)'
+      write(*,*)
+      write(*,*) '(3)          day_ini : Initial day (=0 at Ls=0)'
+      write(*,*) '(19)              z0 :  surface roughness (m)'
+      write(*,*) '(21)       emin_turb :  minimal energy (PBL)'
+      write(*,*) '(20)         lmixmin : mixing length (PBL)'
+      write(*,*) '(26)         emissiv : ground emissivity'
+      write(*,*) '(24 et 25)   emisice : CO2 ice max emissivity '
+      write(*,*) '(31 et 32) iceradius : mean scat radius of CO2 snow'
+      write(*,*) '(33 et 34) dtemisice : time scale for snow',
+     &           'metamorphism'
+      write(*,*) '(35)      volcapa : soil volumetric heat capacity'
+      write(*,*) '(18)     obliquit : planet obliquity (deg)'
+      write(*,*) '(17)     peri_day : periastron date (sols since Ls=0)'
+      write(*,*) '(15)     periastr : min. star-planet dist (UA)'
+      write(*,*) '(16)     apoastr  : max. star-planet (UA)'
+      write(*,*) '(14)     year_day : length of year (in sols)'
+      write(*,*) '(5)      rad      : radius of the planet (m)'
+      write(*,*) '(6)      omeg     : planet rotation rate (rad/s)'
+      write(*,*) '(7)      g        : gravity (m/s2)'
+      write(*,*) '(8)      mugaz    : molecular mass '
+      write(*,*) '                       of the atmosphere (g/mol)'
+      write(*,*) '(9)      rcp      : r/Cp'
+      write(*,*) '(8)+(9)  calc_cpp_mugaz : r/Cp and mugaz '
+      write(*,*) '                 computed from gases.def'
+      write(*,*) '(10)     daysec   : length of a sol (s)'
+      write(*,*)
+ 
+ 
+      do while(modif(1:1).ne.'hello')
+        write(*,*)
+        write(*,*)
+        write(*,*) 'Changes to perform ?'
+        write(*,*) '   (enter keyword or return )'
+        write(*,*)
+        read(*,fmt='(a20)') modif
+        if (modif(1:1) .eq. ' ') goto 999
+ 
+        write(*,*)
+        write(*,*) modif(1:len_trim(modif)) , ' : '
+
+        if (modif(1:len_trim(modif)) .eq. 'day_ini') then
+          write(*,*) 'current value:',day_ini
+          write(*,*) 'enter new value:'
+ 101      read(*,*,iostat=ierr) day_ini
+          if(ierr.ne.0) goto 101
+          write(*,*) ' '
+          write(*,*) 'day_ini (new value):',day_ini
+
+        else if (modif(1:len_trim(modif)) .eq. 'z0') then
+          write(*,*) 'current value:',z0
+          write(*,*) 'enter new value:'
+ 102      read(*,*,iostat=ierr) z0
+          if(ierr.ne.0) goto 102
+          write(*,*) ' '
+          write(*,*) ' z0 (new value):',z0
+
+        else if (modif(1:len_trim(modif)) .eq. 'emin_turb') then
+          write(*,*) 'current value:',emin_turb
+          write(*,*) 'enter new value:'
+ 103      read(*,*,iostat=ierr) emin_turb
+          if(ierr.ne.0) goto 103
+          write(*,*) ' '
+          write(*,*) ' emin_turb (new value):',emin_turb
+
+        else if (modif(1:len_trim(modif)) .eq. 'lmixmin') then
+          write(*,*) 'current value:',lmixmin
+          write(*,*) 'enter new value:'
+ 104      read(*,*,iostat=ierr) lmixmin
+          if(ierr.ne.0) goto 104
+          write(*,*) ' '
+          write(*,*) ' lmixmin (new value):',lmixmin
+
+        else if (modif(1:len_trim(modif)) .eq. 'emissiv') then
+          write(*,*) 'current value:',emissiv
+          write(*,*) 'enter new value:'
+ 105      read(*,*,iostat=ierr) emissiv
+          if(ierr.ne.0) goto 105
+          write(*,*) ' '
+          write(*,*) ' emissiv (new value):',emissiv
+
+        else if (modif(1:len_trim(modif)) .eq. 'emisice') then
+          write(*,*) 'current value emisice(1) North:',emisice(1)
+          write(*,*) 'enter new value:'
+ 106      read(*,*,iostat=ierr) emisice(1)
+          if(ierr.ne.0) goto 106
+          write(*,*) 
+          write(*,*) ' emisice(1) (new value):',emisice(1)
+          write(*,*)
+
+          write(*,*) 'current value emisice(2) South:',emisice(2)
+          write(*,*) 'enter new value:'
+ 107      read(*,*,iostat=ierr) emisice(2)
+          if(ierr.ne.0) goto 107
+          write(*,*) 
+          write(*,*) ' emisice(2) (new value):',emisice(2)
+
+        else if (modif(1:len_trim(modif)) .eq. 'iceradius') then
+          write(*,*) 'current value iceradius(1) North:',iceradius(1)
+          write(*,*) 'enter new value:'
+ 110      read(*,*,iostat=ierr) iceradius(1)
+          if(ierr.ne.0) goto 110
+          write(*,*) 
+          write(*,*) ' iceradius(1) (new value):',iceradius(1)
+          write(*,*)
+
+          write(*,*) 'current value iceradius(2) South:',iceradius(2)
+          write(*,*) 'enter new value:'
+ 111      read(*,*,iostat=ierr) iceradius(2)
+          if(ierr.ne.0) goto 111
+          write(*,*) 
+          write(*,*) ' iceradius(2) (new value):',iceradius(2)
+
+        else if (modif(1:len_trim(modif)) .eq. 'dtemisice') then
+          write(*,*) 'current value dtemisice(1) North:',dtemisice(1)
+          write(*,*) 'enter new value:'
+ 112      read(*,*,iostat=ierr) dtemisice(1)
+          if(ierr.ne.0) goto 112
+          write(*,*) 
+          write(*,*) ' dtemisice(1) (new value):',dtemisice(1)
+          write(*,*)
+
+          write(*,*) 'current value dtemisice(2) South:',dtemisice(2)
+          write(*,*) 'enter new value:'
+ 113      read(*,*,iostat=ierr) dtemisice(2)
+          if(ierr.ne.0) goto 113
+          write(*,*) 
+          write(*,*) ' dtemisice(2) (new value):',dtemisice(2)
+
+        else if (modif(1:len_trim(modif)) .eq. 'obliquit') then
+          write(*,*) 'current value:',obliquit
+          write(*,*) 'obliquit should be 25.19 on current Mars'
+          write(*,*) 'enter new value:'
+ 115      read(*,*,iostat=ierr) obliquit
+          if(ierr.ne.0) goto 115
+          write(*,*) 
+          write(*,*) ' obliquit (new value):',obliquit
+
+        else if (modif(1:len_trim(modif)) .eq. 'peri_day') then
+          write(*,*) 'current value:',peri_day
+          write(*,*) 'peri_day should be 485 on current Mars'
+          write(*,*) 'enter new value:'
+ 116      read(*,*,iostat=ierr) peri_day
+          if(ierr.ne.0) goto 116
+          write(*,*) 
+          write(*,*) ' peri_day (new value):',peri_day
+
+        else if (modif(1:len_trim(modif)) .eq. 'periastr') then
+          write(*,*) 'current value:',periastr
+          write(*,*) 'periastr should be 206.66 on present-day Mars'
+          write(*,*) 'enter new value:'
+ 117      read(*,*,iostat=ierr) periastr
+          if(ierr.ne.0) goto 117
+          write(*,*) 
+          write(*,*) ' periastr (new value):',periastr
+ 
+        else if (modif(1:len_trim(modif)) .eq. 'apoastr') then
+          write(*,*) 'current value:',apoastr
+          write(*,*) 'apoastr should be 249.22 on present-day Mars'
+          write(*,*) 'enter new value:'
+ 118      read(*,*,iostat=ierr) apoastr
+          if(ierr.ne.0) goto 118
+          write(*,*) 
+          write(*,*) ' apoastr (new value):',apoastr
+ 
+        else if (modif(1:len_trim(modif)) .eq. 'volcapa') then
+          write(*,*) 'current value:',volcapa
+          write(*,*) 'enter new value:'
+ 119      read(*,*,iostat=ierr) volcapa
+          if(ierr.ne.0) goto 119
+          write(*,*) 
+          write(*,*) ' volcapa (new value):',volcapa
+        
+        else if (modif(1:len_trim(modif)).eq.'rad') then
+          write(*,*) 'current value:',rad
+          write(*,*) 'enter new value:'
+ 120      read(*,*,iostat=ierr) rad
+          if(ierr.ne.0) goto 120
+          write(*,*) 
+          write(*,*) ' rad (new value):',rad
+
+        else if (modif(1:len_trim(modif)).eq.'omeg') then
+          write(*,*) 'current value:',omeg
+          write(*,*) 'enter new value:'
+ 121      read(*,*,iostat=ierr) omeg
+          if(ierr.ne.0) goto 121
+          write(*,*) 
+          write(*,*) ' omeg (new value):',omeg
+        
+        else if (modif(1:len_trim(modif)).eq.'g') then
+          write(*,*) 'current value:',g
+          write(*,*) 'enter new value:'
+ 122      read(*,*,iostat=ierr) g
+          if(ierr.ne.0) goto 122
+          write(*,*) 
+          write(*,*) ' g (new value):',g
+
+        else if (modif(1:len_trim(modif)).eq.'mugaz') then
+          write(*,*) 'current value:',mugaz
+          write(*,*) 'enter new value:'
+ 123      read(*,*,iostat=ierr) mugaz
+          if(ierr.ne.0) goto 123
+          write(*,*) 
+          write(*,*) ' mugaz (new value):',mugaz
+          r=8.314511/(mugaz/1000.0)
+          write(*,*) ' R (new value):',r
+
+        else if (modif(1:len_trim(modif)).eq.'rcp') then
+          write(*,*) 'current value:',rcp
+          write(*,*) 'enter new value:'
+ 124      read(*,*,iostat=ierr) rcp
+          if(ierr.ne.0) goto 124
+          write(*,*) 
+          write(*,*) ' rcp (new value):',rcp
+          r=8.314511/(mugaz/1000.0)
+          cpp=r/rcp
+          write(*,*) ' cpp (new value):',cpp
+
+        else if (modif(1:len_trim(modif)).eq.'calc_cpp_mugaz') then
+          write(*,*) 'current value rcp, mugaz:',rcp,mugaz
+          check_cpp_match=.false.
+	  force_cpp=.false.
+	  call su_gases
+	  call calc_cpp_mugaz
+          write(*,*) 
+          write(*,*) ' cpp (new value):',cpp
+          write(*,*) ' mugaz (new value):',mugaz
+          r=8.314511/(mugaz/1000.0)
+          rcp=r/cpp
+          write(*,*) ' rcp (new value):',rcp
+	  
+        else if (modif(1:len_trim(modif)).eq.'daysec') then
+          write(*,*) 'current value:',daysec
+          write(*,*) 'enter new value:'
+ 125      read(*,*,iostat=ierr) daysec
+          if(ierr.ne.0) goto 125
+          write(*,*) 
+          write(*,*) ' daysec (new value):',daysec
+
+!         added by RW!
+        else if (modif(1:len_trim(modif)).eq.'year_day') then
+          write(*,*) 'current value:',year_day
+          write(*,*) 'enter new value:' 
+ 126      read(*,*,iostat=ierr) year_day
+          if(ierr.ne.0) goto 126
+          write(*,*)
+          write(*,*) ' year_day (new value):',year_day
+
+        endif
+      enddo ! of do while(modif(1:1).ne.'hello')
+
+ 999  continue
+
+c-----------------------------------------------------------------------
+c	Write values of physical constants after modifications
+c-----------------------------------------------------------------------
+ 
+      write(*,*) '*****************************************************'
+      write(*,*) 'Reading tab_cntrl when calling tabfi AFTER changes'
+      write(*,*) '*****************************************************'
+      write(*,5) '(1)        = ngrid?',tab_cntrl(tab0+1),float(ngrid)
+      write(*,5) '(2)            lmax',tab_cntrl(tab0+2),float(lmax)
+      write(*,5) '(3)         day_ini',tab_cntrl(tab0+3),float(day_ini)
+      write(*,5) '(5)             rad',tab_cntrl(tab0+5),rad
+      write(*,5) '(10)         daysec',tab_cntrl(tab0+10),daysec
+      write(*,6) '(6)            omeg',tab_cntrl(tab0+6),omeg
+      write(*,5) '(7)               g',tab_cntrl(tab0+7),g
+      write(*,5) '(8)           mugaz',tab_cntrl(tab0+8),mugaz
+      write(*,5) '(9)             rcp',tab_cntrl(tab0+9),rcp
+      write(*,6) '(11)        dtphys?',tab_cntrl(tab0+11),dtphys
+ 
+      write(*,5) '(14)       year_day',tab_cntrl(tab0+14),year_day
+      write(*,5) '(15)       periastr',tab_cntrl(tab0+15),periastr
+      write(*,5) '(16)        apoastr',tab_cntrl(tab0+16),apoastr
+      write(*,5) '(17)       peri_day',tab_cntrl(tab0+17),peri_day
+      write(*,5) '(18)       obliquit',tab_cntrl(tab0+18),obliquit
+ 
+      write(*,6) '(19)             z0',tab_cntrl(tab0+19),z0
+      write(*,6) '(21)      emin_turb',tab_cntrl(tab0+21),emin_turb
+      write(*,5) '(20)        lmixmin',tab_cntrl(tab0+20),lmixmin
+ 
+      write(*,5) '(26)        emissiv',tab_cntrl(tab0+26),emissiv
+      write(*,5) '(24)     emisice(1)',tab_cntrl(tab0+24),emisice(1)
+      write(*,5) '(25)     emisice(2)',tab_cntrl(tab0+25),emisice(2)
+      write(*,6) '(31)   iceradius(1)',tab_cntrl(tab0+31),iceradius(1)
+      write(*,6) '(32)   iceradius(2)',tab_cntrl(tab0+32),iceradius(2)
+      write(*,5) '(33)   dtemisice(1)',tab_cntrl(tab0+33),dtemisice(1)
+      write(*,5) '(34)   dtemisice(2)',tab_cntrl(tab0+34),dtemisice(2)
+ 
+      write(*,5) '(35)        volcapa',tab_cntrl(tab0+35),volcapa
+
+      write(*,*)  
+      write(*,*) 
+
+      ENDIF ! of if (Lmodif == 1)
+
+c-----------------------------------------------------------------------
+c	Save some constants for later use (as routine arguments)
+c-----------------------------------------------------------------------
+      p_omeg = omeg
+      p_g = g
+      p_cpp = cpp
+      p_mugaz = mugaz
+      p_daysec = daysec
+      p_rad=rad
+
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/time_phylmdz_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/time_phylmdz_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/time_phylmdz_mod.F90	(revision 1644)
@@ -0,0 +1,39 @@
+MODULE time_phylmdz_mod
+
+    IMPLICIT NONE
+    REAL,SAVE    :: dtphys     ! physics time step (s)
+!$OMP THREADPRIVATE(dtphys)
+    INTEGER,SAVE :: day_step    ! number of dynamical steps per day
+                                ! (set via inifis)
+!$OMP THREADPRIVATE(day_step)
+    INTEGER,SAVE :: nday       ! number of days to run
+!$OMP THREADPRIVATE(nday)
+    REAL,SAVE    :: daysec     ! length of day (s)
+!$OMP THREADPRIVATE(daysec)
+    INTEGER,SAVE :: day_ini     ! initial day of the run
+!$OMP THREADPRIVATE(day_ini)
+
+    INTEGER,SAVE :: ecritphy  ! for diagfi.nc outputs, write every ecritphy
+                              ! dynamical steps (set via inifis)
+!$OMP THREADPRIVATE(ecritphy)
+    INTEGER,SAVE :: iphysiq   ! call physics every iphysiq dynamical step
+                              ! (set via inifis)
+!$OMP THREADPRIVATE(iphysiq)
+
+CONTAINS
+
+  SUBROUTINE init_time(day_ini_, daysec_, nday_, dtphys_)
+    IMPLICIT NONE
+    INTEGER,INTENT(IN) :: day_ini_
+    REAL,INTENT(IN) :: daysec_
+    INTEGER,INTENT(IN) :: nday_
+    REAL,INTENT(IN) :: dtphys_
+    
+    day_ini=day_ini_
+    daysec=daysec_
+    nday=nday_
+    dtphys=dtphys_
+
+  END SUBROUTINE init_time
+
+END MODULE time_phylmdz_mod      
Index: /trunk/LMDZ.TITAN/libf/phytitan/totalcloudfrac.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/totalcloudfrac.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/totalcloudfrac.F90	(revision 1644)
@@ -0,0 +1,109 @@
+      subroutine totalcloudfrac(ngrid,nlayer,nq,rneb,totalrneb,pplev,pq,tau)
+
+      use watercommon_h
+      use comdiurn_h
+      USE tracer_h, only: igcm_h2o_ice
+      USE callkeys_mod, ONLY: CLFfixval
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Calculates the total cloud fraction 
+!     
+!     Authors
+!     -------
+!     Adapted from the LMDTERRE code by B Charnay (2010)
+!     
+!==================================================================
+
+      integer,intent(in) :: ngrid        ! number of atmospheric columns
+      integer,intent(in) :: nlayer       ! number of atmospheric layers
+      integer,intent(in) :: nq           ! number of tracers
+      real,intent(in) :: rneb(ngrid,nlayer)    ! cloud fraction     
+      real,intent(out) :: totalrneb(ngrid)       ! total cloud fraction 
+      real,intent(in) :: pplev(ngrid,nlayer+1) ! inter-layer pressure (Pa)
+      real,intent(in) :: pq(ngrid,nlayer,nq)   ! tracers (.../kg_of_air)
+      real,intent(in) :: tau(ngrid,nlayer)
+
+      real, dimension(nlayer+1) :: masse
+      integer, parameter          :: recovery=7
+      integer ltau_max
+      real massetot
+
+! hypothesis behind recovery. value: 
+! 1 = random recovery
+! 2 = maximal recovery
+! 3 = minimal recovery
+! 4 = fixed recovery
+! 5 = recovery on the thicker layer
+!     Local variables
+      integer ig, l
+      real clear,tau_min
+      real, parameter ::  tau_c=0.1 !threshold of optical depth for the calculation of total cloud fraction 
+      real rneb2(nlayer)
+
+
+      do ig=1,ngrid
+         totalrneb(ig) = 0.
+
+         if (recovery.eq.1) then
+            clear = (1.-rneb(ig,1))
+            do l=2,nlayer      
+               clear = clear*(1.-rneb(ig,l))
+            enddo
+            totalrneb(ig) = 1.-clear
+
+         elseif (recovery.eq.2) then
+            totalrneb(ig) = rneb(ig,1)
+            do l=2,14 !nlayer    
+               totalrneb(ig) = max(rneb(ig,l),totalrneb(ig))
+            enddo
+            
+         elseif (recovery.eq.3) then
+            totalrneb(ig) = rneb(ig,1)
+            do l=2,nlayer    
+               totalrneb(ig) = min(rneb(ig,l),totalrneb(ig))
+            enddo
+         
+         elseif (recovery.eq.4) then
+            totalrneb(ig) = CLFfixval
+
+         elseif (recovery.eq.5) then
+            totalrneb(ig) = rneb(ig,1)            
+            do l=1,nlayer
+               masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
+            enddo
+            ltau_max=maxloc(masse,dim=1)
+            totalrneb(ig) = rneb(ig,ltau_max)
+
+         elseif (recovery.eq.6) then
+            totalrneb(ig) = 0.            
+            do l=1,nlayer
+               masse(l)=pq(ig,l,igcm_h2o_ice)*(pplev(ig,l)-pplev(ig,l+1))
+               masse(l)=max(masse(l),0.)
+            enddo
+            massetot=sum(masse,dim=1)
+            do l=1,nlayer
+               totalrneb(ig) = totalrneb(ig)+rneb(ig,l)*masse(l)/massetot
+            enddo
+
+         elseif (recovery.eq.7) then
+
+            rneb2(:)=rneb(ig,1:nlayer)
+	    tau_min=MIN(tau_c,MAXVAL(tau(ig,1:nlayer))/2.)
+            do l=1,nlayer
+               if(tau(ig,l)<tau_min) rneb2(l)=0.      	
+            enddo
+            totalrneb(ig)=maxval(rneb2(1:nlayer))
+
+         endif                  ! (recovery=)   
+
+         totalrneb(ig) = min(1.,totalrneb(ig))
+         totalrneb(ig) = max(0.,totalrneb(ig))
+         
+      enddo                     ! (ig=)
+      
+      
+    end subroutine totalcloudfrac
Index: /trunk/LMDZ.TITAN/libf/phytitan/tpindex.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/tpindex.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/tpindex.F	(revision 1644)
@@ -0,0 +1,168 @@
+      subroutine tpindex(pw,tw,qvar,pref,tref,wrefvar,LCOEF,MT,MP,
+     &     NVAR,wratio)
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Interpolate K-coefficients to the given P,T and Qvar values.
+!
+!     Notes
+!     -----
+!     The interpolation is the usual one in two dimensions given
+!     in "Numerical Recipes", where the "X" are P, the "Y" are
+!     T, and the F(X,Y) are the CO2 K-coefficients.
+!
+!     The interpolating box is:
+!
+!           (PL,TU)                        (PR,TU)
+!
+!                          (TW,PW)
+!
+!           
+!           (PL,TL)                        (PR,TL)
+!
+!      PL  - Pressure left
+!      PR  - Pressure right
+!      TL  - Temperature lower
+!      TU  - Temperature upper
+!      PW  - Pressure wanted
+!      TW  - Temperature wanted
+!
+!     Inputs
+!     ------
+!     PW                 - The pressure to interpolate to
+!     TW                 - The temperature to interpolate to
+!     Pref(NP)           - The pressure grid array
+!     Tref(NT)           - The temperature grid array
+!   
+!     Outputs
+!     -------
+!     TI                 - Interpolation term (pressure)
+!     UI                 - Interpolation term (temperature)
+!     MT                 - Temperature index (bottom left temperature)
+!                          of bounding box
+!     MP                 - Pressure index (bottom left pressure)
+!                          of bounding box
+!
+!     Authors
+!     -------
+!     Adapted from the NASA Ames code by R. Wordsworth (2009)
+!     
+!==================================================================
+
+      use radinc_h
+
+      implicit none
+
+      real*8 Tref(L_NTREF)
+      real*8 pref(L_PINT)
+      real*8 wrefvar(L_REFVAR)
+
+      integer MT, MP, N, M, NP, NVAR
+      real*8  PW, TW, Qvar, wratio
+      real*8  PWL, LCOEF(4), T, U
+
+C======================================================================C
+ 
+!     Get the upper and lower temperature grid indicies that bound the
+!     requested temperature. If the requested temperature is outside
+!     the T-grid, set up to extrapolate from the appropriate end.
+!     TW : temperature to be interpolated
+!     TREF : grid array
+!     MT : index of TREF for bounding new temperature
+!     U : new index (real) for temperature interpolated
+
+      IF(TW.LE.TREF(1)) THEN
+        MT = 1
+        IF (TW.LT.TREF(1)) THEN
+         write(*,*) 'tpindex: Caution! Temperature of upper levels lower 
+     $ than ref temperature for k-coef: k-coeff fixed for upper levels'
+         write(*,*) "         TW=",TW
+         write(*,*) "         TREF(1)=",TREF(1)
+        ENDIF
+      ELSE
+        do n=1,L_NTREF-1
+          if(tw.gt.Tref(n) .and. TW.LE.TREF(N+1)) then
+            MT = n
+            goto 10
+          end if
+        end do
+
+        MT = L_NTREF-1
+      
+   10   continue
+      END IF
+
+      !TB15 : case low temp : MT=1: fixed TW right above tref(1)
+      IF (MT.eq.1) THEN
+         TW=tref(1)*1.00
+!         write(*,*) 'tpindex: Caution! Temperature of upper levels lower 
+!     $than ref temperature for k-coef: k-coeff fixed for upper levels'
+!         write(*,*) "         TW=",TW
+!         write(*,*) "         TREF(1)=",TREF(1)
+      ENDIF
+
+      U = (TW-TREF(MT))/(TREF(MT+1)-TREF(MT))
+
+!     Get the upper and lower pressure grid indicies that bound the
+!     requested pressure. If the requested pressure is outside
+!     the P-grid, set up to extrapolate from the appropriate end.
+
+      pwl = log10(pw)
+
+      do n=2,L_PINT-1
+        if(pwl.le.Pref(n)) then
+          MP = n-1
+          goto 20
+        end if
+      end do
+
+      MP = L_PINT-1
+
+   20 continue
+      
+      !TB15 : case low pressure : n=2 : fixed pwl, right above pref(1)
+      IF (MP.eq.1) THEN
+        IF (PWL.LT.PREF(1)) THEN
+         write(*,*) 'tpindex: Caution! Pressure of upper levels lower 
+     $than ref pressure for k-coef: k-coeff fixed for upper levels'
+         write(*,*) "         PWL=",PWL
+         write(*,*) "         PREF(1)=",PREF(1)
+        ENDIF
+        PWL=Pref(1)*1.00
+      ENDIF
+
+!     interpolated pressure
+      T = (PWL-PREF(MP))/(PREF(MP+1)-PREF(MP))
+
+!  Fill in the interpolation coefficients
+      LCOEF(1) = (1.0-T)*(1.0-U)
+      LCOEF(2) = T*(1.0-U)
+      LCOEF(3) = T*U
+      LCOEF(4) = (1.0-T)*U
+
+!  Get the indicies for abundance of the varying species. There are 10 sets of 
+!  k-coefficients with differing amounts of variable vs. constant gas.
+
+      IF(QVAR.le.WREFVAR(1)) then
+        NVAR   = 1
+        WRATIO = 0.0D0      ! put all the weight on the first point
+      ELSEIF(QVAR.ge.WREFVAR(L_REFVAR)) then
+        NVAR   = L_REFVAR-1 ! TB16 in order to not oversize NVAr when doing
+                                  !NVAR+1
+        WRATIO = 1.00D0     ! put all the weight on the last point
+      ELSE
+        DO N=2,L_REFVAR
+          IF(QVAR.GE.WREFVAR(N-1) .and. QVAR.lt.WREFVAR(N)) then
+            NVAR   = N-1
+            WRATIO = (QVAR - WREFVAR(N-1))/(WREFVAR(N) - WREFVAR(N-1))
+            GOTO 30
+          END IF
+        END DO
+      END IF
+
+   30 CONTINUE
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/tracer_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/tracer_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/tracer_h.F90	(revision 1644)
@@ -0,0 +1,60 @@
+
+       module tracer_h
+
+       implicit none
+
+! nqtot : total number of tracers
+       INTEGER, SAVE :: nqtot
+!$OMP THREADPRIVATE(nqtot)
+
+       character*20, DIMENSION(:), ALLOCATABLE :: noms   ! name of the tracer
+       real, DIMENSION(:), ALLOCATABLE :: mmol     ! mole mass of tracer (g/mol-1) 
+       real, DIMENSION(:), ALLOCATABLE :: radius   ! dust and ice particle radius (m)
+       real, DIMENSION(:), ALLOCATABLE :: rho_q    ! tracer densities (kg.m-3)
+       real, DIMENSION(:), ALLOCATABLE :: qext     ! Single Scat. Extinction coeff at 0.67 um
+       real, DIMENSION(:), ALLOCATABLE :: alpha_lift  ! saltation vertical flux/horiz flux ratio (m-1)
+       real, DIMENSION(:), ALLOCATABLE :: alpha_devil ! lifting coeeficient by dust devil
+       real, DIMENSION(:), ALLOCATABLE :: qextrhor ! Intermediate for computing opt. depth from q
+
+      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 rho_co2     ! CO2 ice density (kg.m-3)
+      real ref_r0        ! for computing reff=ref_r0*r0 (in log.n. distribution)
+!$OMP THREADPRIVATE(noms,mmol,radius,rho_q,qext,alpha_lift,alpha_devil,qextrhor, &
+	!$OMP varian,r3n_q,rho_dust,rho_ice,rho_co2,ref_r0)
+
+! tracer indexes: these are initialized in initracer and should be 0 if the
+!                 corresponding tracer does not exist
+      ! dust
+      integer, DIMENSION(:), ALLOCATABLE :: igcm_dustbin ! 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)
+      ! 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
+      ! other tracers
+      integer :: igcm_ar_n2 ! for simulations using co2 +neutral gaz
+      integer :: igcm_co2_ice ! CO2 ice 
+!$OMP THREADPRIVATE(igcm_dustbin,igcm_dust_mass,igcm_dust_number,igcm_h2o_vap,igcm_h2o_ice, &
+	!$OMP igcm_co2,igcm_co,igcm_o,igcm_o1d,igcm_o2,igcm_o3,igcm_h,igcm_h2,igcm_oh,	    &
+	!$OMP igcm_ho2,igcm_h2o2,igcm_n2,igcm_ar,igcm_ar_n2,igcm_co2_ice)
+
+       end module tracer_h
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/turbdiff.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/turbdiff.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/turbdiff.F90	(revision 1644)
@@ -0,0 +1,738 @@
+      subroutine turbdiff(ngrid,nlay,nq,rnat,          &
+          ptimestep,pcapcal,lecrit,                    &   
+          pplay,pplev,pzlay,pzlev,pz0,                 &
+          pu,pv,pt,ppopsk,pq,ptsrf,pemis,pqsurf,       &
+          pdtfi,pdqfi,pfluxsrf,            &
+          Pdudif,pdvdif,pdtdif,pdtsrf,sensibFlux,pq2,  &
+          pdqdif,pdqevap,pdqsdif,flux_u,flux_v,lastcall)
+
+      use watercommon_h, only : RLVTT, T_h2O_ice_liq, RCPD, mx_eau_sol,Psat_water
+      use radcommon_h, only : sigma, glat
+      use surfdat_h, only: dryness
+      use tracer_h, only: igcm_h2o_vap, igcm_h2o_ice
+      use comcstfi_mod, only: rcp, g, r, cpp
+      use callkeys_mod, only: water,tracer,nosurf
+
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Turbulent diffusion (mixing) for pot. T, U, V and tracers
+!     
+!     Implicit scheme
+!     We start by adding to variables x the physical tendencies
+!     already computed. We resolve the equation:
+!
+!     x(t+1) =  x(t) + dt * (dx/dt)phys(t)  +  dt * (dx/dt)difv(t+1)
+!     
+!     Authors
+!     ------- 
+!     F. Hourdin, F. Forget, R. Fournier (199X)
+!     R. Wordsworth, B. Charnay (2010)
+!     J. Leconte (2012): To f90
+!         - Rewritten the diffusion scheme to conserve total enthalpy
+!               by accounting for dissipation of turbulent kinetic energy.
+!         - Accounting for lost mean flow kinetic energy should come soon.
+!     
+!==================================================================
+
+!-----------------------------------------------------------------------
+!     declarations
+!     ------------
+
+!     arguments
+!     ---------
+      INTEGER,INTENT(IN) :: ngrid
+      INTEGER,INTENT(IN) :: 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) :: pt(ngrid,nlay),ppopsk(ngrid,nlay)
+      REAL,INTENT(IN) :: ptsrf(ngrid) ! surface temperature (K)
+      REAL,INTENT(IN) :: pemis(ngrid)
+      REAL,INTENT(IN) :: pdtfi(ngrid,nlay)
+      REAL,INTENT(IN) :: pfluxsrf(ngrid)
+      REAL,INTENT(OUT) :: pdudif(ngrid,nlay),pdvdif(ngrid,nlay)
+      REAL,INTENT(OUT) :: pdtdif(ngrid,nlay)
+      REAL,INTENT(OUT) :: pdtsrf(ngrid) ! tendency (K/s) on surface temperature
+      REAL,INTENT(OUT) :: sensibFlux(ngrid)
+      REAL,INTENT(IN) :: pcapcal(ngrid)
+      REAL,INTENT(INOUT) :: pq2(ngrid,nlay+1)
+      REAL,INTENT(OUT) :: flux_u(ngrid),flux_v(ngrid)
+      REAL,INTENT(IN) :: rnat(ngrid)      
+      LOGICAL,INTENT(IN) :: lastcall ! not used
+
+!     Arguments added for condensation
+      logical,intent(in) :: lecrit ! not used.
+      REAL,INTENT(IN) :: pz0
+
+!     Tracers
+!     --------
+      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) 
+      
+!     local
+!     -----
+      integer ilev,ig,ilay,nlev
+
+      REAL z4st,zdplanck(ngrid)
+      REAL zkv(ngrid,nlay+1),zkh(ngrid,nlay+1)
+      REAL zcdv(ngrid),zcdh(ngrid)
+      REAL zcdv_true(ngrid),zcdh_true(ngrid)
+      REAL zu(ngrid,nlay),zv(ngrid,nlay)
+      REAL zh(ngrid,nlay),zt(ngrid,nlay)
+      REAL ztsrf(ngrid)
+      REAL z1(ngrid),z2(ngrid)
+      REAL zmass(ngrid,nlay)
+      REAL zfluxv(ngrid,nlay),zfluxt(ngrid,nlay),zfluxq(ngrid,nlay)
+      REAL zb0(ngrid,nlay)
+      REAL zExner(ngrid,nlay),zovExner(ngrid,nlay)
+      REAL zcv(ngrid,nlay),zdv(ngrid,nlay)  !inversion coefficient for winds
+      REAL zct(ngrid,nlay),zdt(ngrid,nlay)  !inversion coefficient for temperature
+      REAL zcq(ngrid,nlay),zdq(ngrid,nlay)  !inversion coefficient for tracers
+      REAL zcst1
+      REAL zu2!, a
+      REAL zcq0(ngrid),zdq0(ngrid)
+      REAL zx_alf1(ngrid),zx_alf2(ngrid)
+
+      LOGICAL,SAVE :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall)
+      
+!     Tracers
+!     -------
+      INTEGER iq
+      REAL zq(ngrid,nlay,nq)
+      REAL zqnoevap(ngrid,nlay) !special for water case to compute where evaporated water goes.
+      REAL pdqevap(ngrid,nlay) !special for water case to compute where evaporated water goes.
+      REAL zdmassevap(ngrid)
+      REAL rho(ngrid)         ! near-surface air density
+      REAL qsat(ngrid),psat(ngrid)
+      REAL kmixmin
+
+!     Variables added for implicit latent heat inclusion
+!     --------------------------------------------------
+      real dqsat(ngrid), qsat_temp1, qsat_temp2,psat_temp
+
+      integer, save :: ivap, iliq, iliq_surf,iice_surf ! also make liq for clarity on surface...
+!$OMP THREADPRIVATE(ivap,iliq,iliq_surf,iice_surf)
+
+      real, parameter :: karman=0.4
+      real cd0, roughratio
+
+      real dqsdif_total(ngrid) 
+      real zq0(ngrid) 
+
+
+!     Coherence test
+!     --------------
+
+      IF (firstcall) THEN
+
+         if(water)then
+             ivap=igcm_h2o_vap
+             iliq=igcm_h2o_ice
+             iliq_surf=igcm_h2o_vap
+	     iice_surf=igcm_h2o_ice ! simply to make the code legible               
+                                  ! to be generalised
+	 else
+             ivap=0
+             iliq=0
+             iliq_surf=0
+	     iice_surf=0 ! simply to make the code legible               	  
+         endif
+         sensibFlux(:)=0.
+
+         firstcall=.false.
+      ENDIF
+
+!-----------------------------------------------------------------------
+!     1. Initialisation
+!     -----------------
+
+      nlev=nlay+1
+
+!     Calculate rho*dz, (P/Ps)**(R/cp) and dt*rho/dz=dt*rho**2 g/dp
+!     with rho=p/RT=p/ (R Theta) (p/ps)**kappa
+!     ---------------------------------------------
+
+      DO ilay=1,nlay
+         DO ig=1,ngrid
+            zmass(ig,ilay)=(pplev(ig,ilay)-pplev(ig,ilay+1))/glat(ig)
+	    zExner(ig,ilay)=(pplev(ig,ilay)/pplev(ig,1))**rcp
+	    zovExner(ig,ilay)=1./ppopsk(ig,ilay)
+         ENDDO
+      ENDDO
+
+      zcst1=4.*g*ptimestep/(R*R)
+      DO ilev=2,nlev-1
+         DO ig=1,ngrid
+            zb0(ig,ilev)=pplev(ig,ilev)/(pt(ig,ilev-1)+pt(ig,ilev))
+            zb0(ig,ilev)=zcst1*zb0(ig,ilev)*zb0(ig,ilev)/(pplay(ig,ilev-1)-pplay(ig,ilev))
+         ENDDO
+      ENDDO
+      DO ig=1,ngrid
+         zb0(ig,1)=ptimestep*pplev(ig,1)/(R*ptsrf(ig))
+      ENDDO
+      dqsdif_total(:)=0.0
+
+!-----------------------------------------------------------------------
+!     2. Add the physical tendencies computed so far
+!     ----------------------------------------------
+
+      DO ilev=1,nlay
+         DO ig=1,ngrid
+            zu(ig,ilev)=pu(ig,ilev)
+            zv(ig,ilev)=pv(ig,ilev)
+            zt(ig,ilev)=pt(ig,ilev)+pdtfi(ig,ilev)*ptimestep
+            zh(ig,ilev)=pt(ig,ilev)*zovExner(ig,ilev) !for call vdif_kc, but could be moved and computed there
+        ENDDO
+      ENDDO
+      if(tracer) then
+         DO iq =1, nq
+            DO ilev=1,nlay
+               DO ig=1,ngrid
+                  zq(ig,ilev,iq)=pq(ig,ilev,iq) + pdqfi(ig,ilev,iq)*ptimestep
+               ENDDO
+            ENDDO
+         ENDDO
+         if (water) then
+            DO ilev=1,nlay
+               DO ig=1,ngrid
+                  zqnoevap(ig,ilev)=pq(ig,ilev,ivap) + pdqfi(ig,ilev,ivap)*ptimestep
+               ENDDO
+            ENDDO
+         Endif
+      end if
+
+!-----------------------------------------------------------------------
+!     3. Turbulence scheme
+!     --------------------
+!
+!     Source of turbulent kinetic energy at the surface
+!     ------------------------------------------------- 
+!     Formula is Cd_0 = (karman / log[1+z1/z0])^2
+
+      DO ig=1,ngrid
+         roughratio = 1. + pzlay(ig,1)/pz0
+         cd0 = karman/log(roughratio)
+         cd0 = cd0*cd0
+         zcdv_true(ig) = cd0
+         zcdh_true(ig) = cd0
+       if(nosurf)then
+         zcdv_true(ig)=0.D+0 !JL12 disable atm/surface momentum flux
+         zcdh_true(ig)=0.D+0 !JL12 disable sensible heat flux 
+       endif
+      ENDDO
+
+      DO ig=1,ngrid
+         zu2=pu(ig,1)*pu(ig,1)+pv(ig,1)*pv(ig,1)
+         zcdv(ig)=zcdv_true(ig)*sqrt(zu2)
+         zcdh(ig)=zcdh_true(ig)*sqrt(zu2)
+      ENDDO
+
+!     Turbulent diffusion coefficients in the boundary layer
+!     ------------------------------------------------------ 
+
+      call vdif_kc(ngrid,nlay,ptimestep,g,pzlev,pzlay,pu,pv,zh,zcdv_true,pq2,zkv,zkh) !JL12 why not call vdif_kc with updated winds and temperature 
+      
+!     Adding eddy mixing to mimic 3D general circulation in 1D
+!     R. Wordsworth & F. Forget (2010)
+      if ((ngrid.eq.1)) then
+         kmixmin = 1.0e-2       ! minimum eddy mix coeff in 1D
+         do ilev=1,nlay
+            do ig=1,ngrid
+               zkh(ig,ilev) = max(kmixmin,zkh(ig,ilev))
+               zkv(ig,ilev) = max(kmixmin,zkv(ig,ilev)) 
+            end do
+         end do
+      end if
+
+!JL12 change zkv at the surface by zcdv to calculate the surface momentum flux properly
+      DO ig=1,ngrid
+         zkv(ig,1)=zcdv(ig)
+      ENDDO
+!we treat only winds, energy and tracers coefficients will be computed with upadted winds
+ 
+!JL12 calculate the flux coefficients (tables multiplied elements by elements)
+      zfluxv(1:ngrid,1:nlay)=zkv(1:ngrid,1:nlay)*zb0(1:ngrid,1:nlay)
+      
+!-----------------------------------------------------------------------
+!     4. Implicit inversion of u
+!     --------------------------
+
+!     u(t+1) =  u(t) + dt * {(du/dt)phys}(t)  +  dt * {(du/dt)difv}(t+1)
+!     avec
+!     /zu/ = u(t) + dt * {(du/dt)phys}(t)   (voir paragraphe 2.)
+!     et
+!     dt * {(du/dt)difv}(t+1) = dt * {(d/dz)[ Ku (du/dz) ]}(t+1)
+!     donc les entrees sont /zcdv/ pour la condition a la limite sol
+!     et /zkv/ = Ku
+
+      DO ig=1,ngrid
+         z1(ig)=1./(zmass(ig,nlay)+zfluxv(ig,nlay))
+         zcv(ig,nlay)=zmass(ig,nlay)*zu(ig,nlay)*z1(ig)
+         zdv(ig,nlay)=zfluxv(ig,nlay)*z1(ig)
+      ENDDO
+
+      DO ilay=nlay-1,1,-1
+         DO ig=1,ngrid
+            z1(ig)=1./(zmass(ig,ilay)+zfluxv(ig,ilay) + zfluxv(ig,ilay+1)*(1.-zdv(ig,ilay+1)))
+            zcv(ig,ilay)=(zmass(ig,ilay)*zu(ig,ilay)+zfluxv(ig,ilay+1)*zcv(ig,ilay+1))*z1(ig)
+            zdv(ig,ilay)=zfluxv(ig,ilay)*z1(ig)
+         ENDDO
+      ENDDO
+
+      DO ig=1,ngrid
+         zu(ig,1)=zcv(ig,1)
+      ENDDO
+      DO ilay=2,nlay
+         DO ig=1,ngrid
+            zu(ig,ilay)=zcv(ig,ilay)+zdv(ig,ilay)*zu(ig,ilay-1)
+         ENDDO
+      ENDDO
+
+!-----------------------------------------------------------------------
+!     5. Implicit inversion of v
+!     --------------------------
+
+!     v(t+1) =  v(t) + dt * {(dv/dt)phys}(t)  +  dt * {(dv/dt)difv}(t+1)
+!     avec
+!     /zv/ = v(t) + dt * {(dv/dt)phys}(t)   (voir paragraphe 2.)
+!     et
+!     dt * {(dv/dt)difv}(t+1) = dt * {(d/dz)[ Kv (dv/dz) ]}(t+1)
+!     donc les entrees sont /zcdv/ pour la condition a la limite sol
+!     et /zkv/ = Kv
+
+      DO ig=1,ngrid
+         z1(ig)=1./(zmass(ig,nlay)+zfluxv(ig,nlay)) 
+         zcv(ig,nlay)=zmass(ig,nlay)*zv(ig,nlay)*z1(ig)
+         zdv(ig,nlay)=zfluxv(ig,nlay)*z1(ig)
+      ENDDO
+
+      DO ilay=nlay-1,1,-1
+         DO ig=1,ngrid
+            z1(ig)=1./(zmass(ig,ilay)+zfluxv(ig,ilay)+zfluxv(ig,ilay+1)*(1.-zdv(ig,ilay+1)))
+            zcv(ig,ilay)=(zmass(ig,ilay)*zv(ig,ilay)+zfluxv(ig,ilay+1)*zcv(ig,ilay+1))*z1(ig)
+            zdv(ig,ilay)=zfluxv(ig,ilay)*z1(ig)
+         ENDDO
+      ENDDO
+
+      DO ig=1,ngrid
+         zv(ig,1)=zcv(ig,1)
+      ENDDO
+      DO ilay=2,nlay
+         DO ig=1,ngrid
+            zv(ig,ilay)=zcv(ig,ilay)+zdv(ig,ilay)*zv(ig,ilay-1)
+         ENDDO
+      ENDDO
+
+!     Calcul of wind stress
+
+      DO ig=1,ngrid
+         flux_u(ig) = zfluxv(ig,1)/ptimestep*zu(ig,1)
+         flux_v(ig) = zfluxv(ig,1)/ptimestep*zv(ig,1)
+      ENDDO
+
+
+!----------------------------------------------------------------------------
+!     6. Implicit inversion of h, not forgetting the coupling with the ground
+
+!     h(t+1) =  h(t) + dt * {(dh/dt)phys}(t)  +  dt * {(dh/dt)difv}(t+1)
+!     avec
+!     /zh/ = h(t) + dt * {(dh/dt)phys}(t)   (voir paragraphe 2.)
+!     et
+!     dt * {(dh/dt)difv}(t+1) = dt * {(d/dz)[ Kh (dh/dz) ]}(t+1)
+!     donc les entrees sont /zcdh/ pour la condition de raccord au sol
+!     et /zkh/ = Kh
+
+!     Using the wind modified by friction for lifting and sublimation
+!     ---------------------------------------------------------------
+      DO ig=1,ngrid
+         zu2      = zu(ig,1)*zu(ig,1)+zv(ig,1)*zv(ig,1)
+         zcdv(ig) = zcdv_true(ig)*sqrt(zu2)
+         zcdh(ig) = zcdh_true(ig)*sqrt(zu2)
+         zkh(ig,1)= zcdh(ig)
+      ENDDO
+
+!     JL12 calculate the flux coefficients (tables multiplied elements by elements)
+!     ---------------------------------------------------------------
+      zfluxq(1:ngrid,1:nlay)=zkh(1:ngrid,1:nlay)*zb0(1:ngrid,1:nlay) !JL12 we save zfluxq which doesn't need the Exner factor
+      zfluxt(1:ngrid,1:nlay)=zfluxq(1:ngrid,1:nlay)*zExner(1:ngrid,1:nlay)
+
+      DO ig=1,ngrid
+         z1(ig)=1./(zmass(ig,nlay)+zfluxt(ig,nlay)*zovExner(ig,nlay))
+         zct(ig,nlay)=zmass(ig,nlay)*zt(ig,nlay)*z1(ig)
+         zdt(ig,nlay)=zfluxt(ig,nlay)*zovExner(ig,nlay-1)*z1(ig)
+      ENDDO
+
+      DO ilay=nlay-1,2,-1
+         DO ig=1,ngrid
+            z1(ig)=1./(zmass(ig,ilay)+zfluxt(ig,ilay)*zovExner(ig,ilay)+   &
+            zfluxt(ig,ilay+1)*(zovExner(ig,ilay)-zdt(ig,ilay+1)*zovExner(ig,ilay+1)))
+            zct(ig,ilay)=(zmass(ig,ilay)*zt(ig,ilay)+zfluxt(ig,ilay+1)*zct(ig,ilay+1)*zovExner(ig,ilay+1))*z1(ig)
+            zdt(ig,ilay)=zfluxt(ig,ilay)*z1(ig)*zovExner(ig,ilay-1)
+         ENDDO
+      ENDDO
+
+!JL12 we treat last point afterward because zovExner(ig,ilay-1) does not exist there
+      DO ig=1,ngrid
+         z1(ig)=1./(zmass(ig,1)+zfluxt(ig,1)*zovExner(ig,1)+  &
+             zfluxt(ig,2)*(zovExner(ig,1)-zdt(ig,2)*zovExner(ig,2)))
+         zct(ig,1)=(zmass(ig,1)*zt(ig,1)+zfluxt(ig,2)*zct(ig,2)*zovExner(ig,2))*z1(ig)
+         zdt(ig,1)=zfluxt(ig,1)*z1(ig)
+      ENDDO
+
+
+!     Calculate (d Planck / dT) at the interface temperature
+!     ------------------------------------------------------
+
+      z4st=4.0*sigma*ptimestep
+      DO ig=1,ngrid
+         zdplanck(ig)=z4st*pemis(ig)*ptsrf(ig)*ptsrf(ig)*ptsrf(ig)
+      ENDDO
+
+!     Calculate temperature tendency at the interface (dry case)
+!     ----------------------------------------------------------
+!     Sum of fluxes at interface at time t + \delta t gives change in T:
+!       radiative fluxes
+!       turbulent convective (sensible) heat flux
+!       flux (if any) from subsurface
+
+      if(.not.water) then
+
+         DO ig=1,ngrid
+            z1(ig)=pcapcal(ig)*ptsrf(ig)+cpp*zfluxt(ig,1)*zct(ig,1)*zovExner(ig,1) &
+                + pfluxsrf(ig)*ptimestep + zdplanck(ig)*ptsrf(ig) 
+            z2(ig) = pcapcal(ig)+zdplanck(ig)+cpp*zfluxt(ig,1)*(1.-zovExner(ig,1)*zdt(ig,1)) 
+            ztsrf(ig) = z1(ig) / z2(ig)
+            pdtsrf(ig) = (ztsrf(ig) - ptsrf(ig))/ptimestep
+            zt(ig,1)   = zct(ig,1) + zdt(ig,1)*ztsrf(ig)
+         ENDDO
+! JL12 note that the black body radiative flux emitted by the surface has been updated by the implicit scheme 
+
+
+!     Recalculate temperature to top of atmosphere, starting from ground
+!     ------------------------------------------------------------------
+
+         DO ilay=2,nlay
+            DO ig=1,ngrid
+               zt(ig,ilay)=zct(ig,ilay)+zdt(ig,ilay)*zt(ig,ilay-1)
+            ENDDO
+         ENDDO
+
+      endif                     ! not water
+
+!-----------------------------------------------------------------------
+!     TRACERS (no vapour)
+!     -------
+
+      if(tracer) then
+
+!     Calculate vertical flux from the bottom to the first layer (dust)
+!     -----------------------------------------------------------------
+         do ig=1,ngrid
+            rho(ig) = zb0(ig,1) /ptimestep
+         end do
+
+         pdqsdif(:,:)=0.
+
+!     Implicit inversion of q
+!     -----------------------
+         do iq=1,nq 
+
+            if (iq.ne.ivap) then
+
+               DO ig=1,ngrid
+                  z1(ig)=1./(zmass(ig,nlay)+zfluxq(ig,nlay))
+                  zcq(ig,nlay)=zmass(ig,nlay)*zq(ig,nlay,iq)*z1(ig)
+                  zdq(ig,nlay)=zfluxq(ig,nlay)*z1(ig)
+               ENDDO 
+            
+               DO ilay=nlay-1,2,-1
+                  DO ig=1,ngrid
+                     z1(ig)=1./(zmass(ig,ilay)+zfluxq(ig,ilay)+zfluxq(ig,ilay+1)*(1.-zdq(ig,ilay+1)))
+                     zcq(ig,ilay)=(zmass(ig,ilay)*zq(ig,ilay,iq)+zfluxq(ig,ilay+1)*zcq(ig,ilay+1))*z1(ig)
+                     zdq(ig,ilay)=zfluxq(ig,ilay)*z1(ig)
+                  ENDDO
+               ENDDO
+
+               if ((water).and.(iq.eq.iliq)) then
+                  ! special case for condensed water tracer: do not include
+                  ! h2o ice tracer from surface (which is set when handling
+                  ! h2o vapour case (see further down).
+                  ! zb(ig,1)=0 if iq ne ivap
+                  DO ig=1,ngrid
+                     z1(ig)=1./(zmass(ig,1)+zfluxq(ig,2)*(1.-zdq(ig,2)))
+                     zcq(ig,1)=(zmass(ig,1)*zq(ig,1,iq)+zfluxq(ig,2)*zcq(ig,2))*z1(ig)
+                  ENDDO
+               else             ! general case
+                  do ig=1,ngrid
+                     z1(ig)=1./(zmass(ig,1)+zfluxq(ig,2)*(1.-zdq(ig,2)))
+                     zcq(ig,1)=(zmass(ig,1)*zq(ig,1,iq)+zfluxq(ig,2)*zcq(ig,2)+(-pdqsdif(ig,iq))*ptimestep)*z1(ig)
+                          ! tracer flux from surface
+                          ! currently pdqsdif always zero here,
+                          ! so last line is superfluous
+                  enddo
+               endif            ! of if (water.and.(iq.eq.igcm_h2o_ice))
+
+
+!     Starting upward calculations for simple tracer mixing (e.g., dust)
+               do ig=1,ngrid
+                  zq(ig,1,iq)=zcq(ig,1)
+               end do
+
+               do ilay=2,nlay
+                  do ig=1,ngrid
+                     zq(ig,ilay,iq)=zcq(ig,ilay)+zdq(ig,ilay)*zq(ig,ilay-1,iq)
+                  end do
+               end do
+
+            endif               ! if (iq.ne.ivap)
+
+!     Calculate temperature tendency including latent heat term
+!     and assuming an infinite source of water on the ground
+!     ------------------------------------------------------------------
+
+            if (water.and.(iq.eq.ivap)) then 
+            
+               ! compute evaporation efficiency
+               do ig=1,ngrid
+                  if(nint(rnat(ig)).eq.1)then
+                     dryness(ig)=pqsurf(ig,iliq_surf)+pqsurf(ig,iice_surf) 
+                     dryness(ig)=MIN(1.,2*dryness(ig)/mx_eau_sol)
+                     dryness(ig)=MAX(0.,dryness(ig))
+                  endif
+               enddo
+
+               do ig=1,ngrid
+                ! Calculate the value of qsat at the surface (water)
+                call Psat_water(ptsrf(ig),pplev(ig,1),psat(ig),qsat(ig))
+                call Psat_water(ptsrf(ig)-0.0001,pplev(ig,1),psat_temp,qsat_temp1)
+                call Psat_water(ptsrf(ig)+0.0001,pplev(ig,1),psat_temp,qsat_temp2)
+                dqsat(ig)=(qsat_temp2-qsat_temp1)/0.0002
+                ! calculate dQsat / dT by finite differences
+                ! we cannot use the updated temperature value yet...
+	       enddo
+
+! coefficients for q
+
+               do ig=1,ngrid
+                  z1(ig)=1./(zmass(ig,nlay)+zfluxq(ig,nlay))
+                  zcq(ig,nlay)=zmass(ig,nlay)*zq(ig,nlay,iq)*z1(ig)
+                  zdq(ig,nlay)=zfluxq(ig,nlay)*z1(ig)
+               enddo 
+          
+               do ilay=nlay-1,2,-1
+                  do ig=1,ngrid
+                     z1(ig)=1./(zmass(ig,ilay)+zfluxq(ig,ilay)+zfluxq(ig,ilay+1)*(1.-zdq(ig,ilay+1)))
+                     zcq(ig,ilay)=(zmass(ig,ilay)*zq(ig,ilay,iq)+zfluxq(ig,ilay+1)*zcq(ig,ilay+1))*z1(ig)
+                     zdq(ig,ilay)=zfluxq(ig,ilay)*z1(ig)
+                  enddo
+               enddo
+
+               do ig=1,ngrid
+                  z1(ig)=1./(zmass(ig,1)+zfluxq(ig,1)*dryness(ig)+zfluxq(ig,2)*(1.-zdq(ig,2)))
+                  zcq(ig,1)=(zmass(ig,1)*zq(ig,1,iq)+zfluxq(ig,2)*zcq(ig,2))*z1(ig)
+                  zdq(ig,1)=dryness(ig)*zfluxq(ig,1)*z1(ig)
+               enddo
+
+              do ig=1,ngrid
+!calculation of surface temperature
+                  zdq0(ig) = dqsat(ig)
+                  zcq0(ig) = qsat(ig)-dqsat(ig)*ptsrf(ig)
+
+                  z1(ig) = pcapcal(ig)*ptsrf(ig) +cpp*zfluxt(ig,1)*zct(ig,1)*zovExner(ig,1)   &
+		      + zdplanck(ig)*ptsrf(ig) + pfluxsrf(ig)*ptimestep                       &
+                      + zfluxq(ig,1)*dryness(ig)*RLVTT*((zdq(ig,1)-1.0)*zcq0(ig)+zcq(ig,1))
+
+                  z2(ig) = pcapcal(ig) + cpp*zfluxt(ig,1)*(1.-zovExner(ig,1)*zdt(ig,1))       &
+                      + zdplanck(ig)+zfluxq(ig,1)*dryness(ig)*RLVTT*zdq0(ig)*(1.0-zdq(ig,1))
+
+                  ztsrf(ig) = z1(ig) / z2(ig)
+
+! calculation of qs and q1
+                  zq0(ig)     = zcq0(ig)+zdq0(ig)*ztsrf(ig)
+                  zq(ig,1,iq) = zcq(ig,1)+zdq(ig,1)*zq0(ig)
+
+! calculation of evaporation              
+                  dqsdif_total(ig)=zfluxq(ig,1)*dryness(ig)*(zq(ig,1,ivap)-zq0(ig))
+
+!     --------------------------------------------------------
+!     Now check if we've taken too much water from the surface
+!     This can only occur on the continent 
+!     If we do, we recompute Tsurf, T1 and q1 accordingly
+                  if((-dqsdif_total(ig).gt.(pqsurf(ig,iice_surf)+pqsurf(ig,iliq_surf))).and.rnat(ig).eq.1)then
+                      !water flux * ptimestep
+	              dqsdif_total(ig)=-(pqsurf(ig,iice_surf)+pqsurf(ig,iliq_surf))
+
+                      !recompute surface temperature  
+                      z1(ig) = pcapcal(ig)*ptsrf(ig) +cpp*zfluxq(ig,1)*zct(ig,1)*zovExner(ig,1)   &
+		        + zdplanck(ig)*ptsrf(ig) + pfluxsrf(ig)*ptimestep                       &
+                        + RLVTT*dqsdif_total(ig)
+                      z2(ig) = pcapcal(ig) + cpp*zfluxq(ig,1)*(1.-zovExner(ig,1)*zdt(ig,1))       &
+                        + zdplanck(ig)
+                      ztsrf(ig) = z1(ig) / z2(ig)
+
+                      !recompute q1 with new water flux from surface  
+                      zq(ig,1,iq) = (zmass(ig,1)*(pq(ig,1,iq)+ptimestep*pdqfi(ig,1,iq))  &
+		                            +zfluxq(ig,2)*zcq(ig,2)-dqsdif_total(ig))     &
+                                 / (zmass(ig,1)+(1.-zdq(ig,2))*zfluxq(ig,2))		     
+                  end if
+		  
+! calculation surface T tendency  and T(1)           
+		  pdtsrf(ig) = (ztsrf(ig) - ptsrf(ig))/ptimestep
+                  zt(ig,1)   = zct(ig,1) + zdt(ig,1)*ztsrf(ig)		      
+               enddo
+
+
+! recalculate temperature and q(vap) to top of atmosphere, starting from ground
+               do ilay=2,nlay
+                  do ig=1,ngrid
+                     zq(ig,ilay,iq)=zcq(ig,ilay)+zdq(ig,ilay)*zq(ig,ilay-1,iq)
+                     zt(ig,ilay)=zct(ig,ilay)+zdt(ig,ilay)*zt(ig,ilay-1)
+                  end do
+               end do
+
+
+               do ig=1,ngrid
+!     --------------------------------------------------------------------------
+!     On the ocean, if T > 0 C then the vapour tendency must replace the ice one
+!     The surface vapour tracer is actually liquid. To make things difficult.
+
+                  if (nint(rnat(ig)).eq.0) then ! unfrozen ocean
+                     
+                     pdqsdif(ig,iliq_surf)=dqsdif_total(ig)/ptimestep
+                     pdqsdif(ig,iice_surf)=0.0
+
+                  elseif (nint(rnat(ig)).eq.1) then ! (continent)
+!     If water is evaporating / subliming, we take it from ice before liquid
+!     -- is this valid??
+                     if(dqsdif_total(ig).lt.0)then
+                        if (-dqsdif_total(ig).gt.pqsurf(ig,iice_surf))then
+                           pdqsdif(ig,iice_surf) = -pqsurf(ig,iice_surf)/ptimestep ! removes all the ice!
+                           pdqsdif(ig,iliq_surf) = dqsdif_total(ig)/ptimestep- pdqsdif(ig,iice_surf) ! take the remainder from the liquid instead
+			else               
+                           pdqsdif(ig,iice_surf)=dqsdif_total(ig)/ptimestep
+			   pdqsdif(ig,iliq_surf)=0.
+			end if
+	             else !dqsdif_total(ig).ge.0
+                        !If water vapour is condensing, we must decide whether it forms ice or liquid.
+                        if(ztsrf(ig).gt.T_h2O_ice_liq)then
+                           pdqsdif(ig,iice_surf)=0.0
+                           pdqsdif(ig,iliq_surf)=dqsdif_total(ig)/ptimestep
+                        else
+                           pdqsdif(ig,iice_surf)=dqsdif_total(ig)/ptimestep
+                           pdqsdif(ig,iliq_surf)=0.0
+                        endif               
+                     endif
+
+                  elseif (nint(rnat(ig)).eq.2) then ! (continental glaciers)
+		     pdqsdif(ig,iliq_surf)=0.0
+                     pdqsdif(ig,iice_surf)=dqsdif_total(ig)/ptimestep
+
+		  endif !rnat
+               end do            ! of DO ig=1,ngrid
+
+           endif                ! if (water et iq=ivap)
+        end do                  ! of do iq=1,nq
+
+        if (water) then  ! special case where we recompute water mixing without any evaporation.
+	                 !    The difference with the first calculation then tells us where evaporated water has gone
+
+            DO ig=1,ngrid
+               z1(ig)=1./(zmass(ig,nlay)+zfluxq(ig,nlay))
+               zcq(ig,nlay)=zmass(ig,nlay)*zqnoevap(ig,nlay)*z1(ig)
+               zdq(ig,nlay)=zfluxq(ig,nlay)*z1(ig)
+            ENDDO 
+            
+            DO ilay=nlay-1,2,-1
+               DO ig=1,ngrid
+                  z1(ig)=1./(zmass(ig,ilay)+zfluxq(ig,ilay)+zfluxq(ig,ilay+1)*(1.-zdq(ig,ilay+1)))
+                  zcq(ig,ilay)=(zmass(ig,ilay)*zqnoevap(ig,ilay)+zfluxq(ig,ilay+1)*zcq(ig,ilay+1))*z1(ig)
+                  zdq(ig,ilay)=zfluxq(ig,ilay)*z1(ig)
+               ENDDO
+            ENDDO
+
+            do ig=1,ngrid
+               z1(ig)=1./(zmass(ig,1)+zfluxq(ig,2)*(1.-zdq(ig,2)))
+               zcq(ig,1)=(zmass(ig,1)*zqnoevap(ig,1)+zfluxq(ig,2)*zcq(ig,2))*z1(ig)
+            enddo
+
+!     Starting upward calculations for simple tracer mixing (e.g., dust)
+            do ig=1,ngrid
+               zqnoevap(ig,1)=zcq(ig,1)
+            end do
+
+            do ilay=2,nlay
+               do ig=1,ngrid
+                  zqnoevap(ig,ilay)=zcq(ig,ilay)+zdq(ig,ilay)*zqnoevap(ig,ilay-1)
+               end do
+            end do
+
+         endif               ! if water
+	
+	
+      endif                     ! tracer
+
+
+!-----------------------------------------------------------------------
+!     8. Final calculation of the vertical diffusion tendencies
+!     -----------------------------------------------------------------
+
+      do ilev = 1, nlay
+         do ig=1,ngrid
+            pdudif(ig,ilev)=(zu(ig,ilev)-(pu(ig,ilev)))/ptimestep
+            pdvdif(ig,ilev)=(zv(ig,ilev)-(pv(ig,ilev)))/ptimestep
+            pdtdif(ig,ilev)=( zt(ig,ilev)- pt(ig,ilev))/ptimestep-pdtfi(ig,ilev)
+         enddo
+      enddo
+      
+      DO ig=1,ngrid ! computing sensible heat flux (atm => surface)
+	 sensibFlux(ig)=cpp*zfluxt(ig,1)/ptimestep*(zt(ig,1)*zovExner(ig,1)-ztsrf(ig))
+      ENDDO
+
+      if (tracer) then
+         do iq = 1, nq
+            do ilev = 1, nlay
+               do ig=1,ngrid
+                  pdqdif(ig,ilev,iq)=(zq(ig,ilev,iq)-(pq(ig,ilev,iq)+pdqfi(ig,ilev,iq)*ptimestep))/ptimestep
+               enddo
+            enddo
+         enddo
+	 if (water) then
+            do ilev = 1, nlay
+               do ig=1,ngrid
+                  pdqevap(ig,ilev)=(zq(ig,ilev,ivap)-zqnoevap(ig,ilev))/ptimestep
+               enddo
+            enddo
+            do ig=1,ngrid
+	       zdmassevap(ig)=SUM(pdqevap(ig,:)*zmass(ig,:))*ptimestep
+	    end do	    
+	 endif
+      endif 
+
+      if(water)then
+         call writediagfi(ngrid,'beta','Dryness coefficient',' ',2,dryness)
+         if (tracer) then
+            call writediagfi(ngrid,'dqevap','evaporated water vapor specific concentration','s-1',3,pdqevap)
+	 endif
+      endif
+
+!      if(lastcall)then
+!        if(ngrid.eq.1)then
+!           print*,'Saving k.out...'
+!           OPEN(12,file='k.out',form='formatted')
+!           DO ilay=1,nlay
+!              write(12,*) zkh(1,ilay), pplay(1,ilay)
+!           ENDDO
+!           CLOSE(12)
+!         endif
+!      endif
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/vdif_cd.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/vdif_cd.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/vdif_cd.F	(revision 1644)
@@ -0,0 +1,76 @@
+      SUBROUTINE vdif_cd( ngrid,nlay,pz0,pg,pz,pu,pv,pts,ph,pcdv,pcdh)
+      IMPLICIT NONE
+c=======================================================================
+c
+c   Subject: computation of the surface drag coefficient using the
+c   -------  approch developed by Loui for ECMWF.
+c
+c   Author: Frederic Hourdin  15 /10 /93
+c   -------
+c
+c   Arguments:
+c   ----------
+c
+c   inputs:
+c   ------
+c     ngrid            size of the horizontal grid
+c     pg               gravity (m s -2)
+c     pz(ngrid)        height of the first atmospheric layer
+c     pu(ngrid)        u component of the wind in that layer
+c     pv(ngrid)        v component of the wind in that layer
+c     pts(ngrid)       surfacte temperature
+c     ph(ngrid)        potential temperature T*(p/ps)^kappa
+c
+c   outputs:
+c   --------
+c     pcdv(ngrid)      Cd for the wind
+c     pcdh(ngrid)      Cd for potential temperature
+c
+c=======================================================================
+c
+c-----------------------------------------------------------------------
+c   Declarations:
+c   -------------
+
+c   Arguments:
+c   ----------
+
+      INTEGER ngrid,nlay
+      REAL pz0
+      REAL pg,pz(ngrid,nlay)
+      REAL pu(ngrid,nlay),pv(ngrid,nlay)
+      REAL pts(ngrid,nlay),ph(ngrid,nlay)
+      REAL pcdv(ngrid),pcdh(ngrid)
+
+c   Local:
+c   ------
+
+      INTEGER ig
+
+      REAL zu2,z1,zri,zcd0,zz
+
+      REAL karman,b,c,d,c2b,c3bc,c3b,umin2
+      LOGICAL firstcal
+      DATA karman,b,c,d,umin2/.4,5.,5.,5.,1.e-12/
+      DATA firstcal/.true./
+      SAVE b,c,d,karman,c2b,c3bc,c3b,firstcal,umin2
+!$OMP THREADPRIVATE(b,c,d,karman,c2b,c3bc,c3b,firstcal,umin2)
+
+c-----------------------------------------------------------------------
+c   couche de surface:
+c   ------------------
+
+! simplified calculation
+
+      DO ig=1,ngrid
+         z1=1.E+0 + pz(ig,1)/pz0
+         zcd0=karman/log(z1)
+         zcd0=zcd0*zcd0
+         pcdv(ig)=zcd0
+         pcdh(ig)=zcd0
+      ENDDO
+
+c-----------------------------------------------------------------------
+
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/vdif_kc.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/vdif_kc.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/vdif_kc.F	(revision 1644)
@@ -0,0 +1,532 @@
+      SUBROUTINE vdif_kc(ngrid,nlay,dt,g,zlev,zlay,u,v,teta,cd,q2,km,kn)
+      IMPLICIT NONE
+c.......................................................................
+c
+c dt : pas de temps
+c g  : g
+c zlev : altitude a chaque niveau (interface inferieure de la couche
+c        de meme indice)
+c zlay : altitude au centre de chaque couche
+c u,v : vitesse au centre de chaque couche
+c       (en entree : la valeur au debut du pas de temps)
+c teta : temperature potentielle au centre de chaque couche
+c        (en entree : la valeur au debut du pas de temps)
+c cd : cdrag
+c      (en entree : la valeur au debut du pas de temps)
+c q2 : $q^2$ au bas de chaque couche
+c      (en entree : la valeur au debut du pas de temps)
+c      (en sortie : la valeur a la fin du pas de temps)
+c km : diffusivite turbulente de quantite de mouvement (au bas de chaque
+c      couche)
+c      (en sortie : la valeur a la fin du pas de temps)
+c kn : diffusivite turbulente des scalaires (au bas de chaque couche)
+c      (en sortie : la valeur a la fin du pas de temps)
+c 
+c.......................................................................
+      INTEGER,INTENT(IN) :: ngrid
+      INTEGER,INTENT(IN) :: nlay
+      REAL,INTENT(IN) :: dt,g
+      REAL,INTENT(IN) :: zlev(ngrid,nlay+1)
+      REAL,INTENT(IN) :: zlay(ngrid,nlay)
+      REAL,INTENT(IN) :: u(ngrid,nlay)
+      REAL,INTENT(IN) :: v(ngrid,nlay)
+      REAL,INTENT(IN) :: teta(ngrid,nlay)
+      REAL,INTENT(IN) :: cd(ngrid)
+      REAL,INTENT(INOUT) :: q2(ngrid,nlay+1)
+      REAL,INTENT(OUT) :: km(ngrid,nlay+1)
+      REAL,INTENT(OUT) :: kn(ngrid,nlay+1)
+c.......................................................................
+c
+c nlay : nombre de couches        
+c nlev : nombre de niveaux
+c ngrid : nombre de points de grille       
+c unsdz : 1 sur l'epaisseur de couche
+c unsdzdec : 1 sur la distance entre le centre de la couche et le
+c            centre de la couche inferieure
+c q : echelle de vitesse au bas de chaque couche
+c     (valeur a la fin du pas de temps)
+c
+c.......................................................................
+      INTEGER :: nlev
+      REAL unsdz(ngrid,nlay)
+      REAL unsdzdec(ngrid,nlay+1)
+      REAL q(ngrid,nlay+1)
+c.......................................................................
+c
+c kmpre : km au debut du pas de temps
+c qcstat : q : solution stationnaire du probleme couple
+c          (valeur a la fin du pas de temps)
+c q2cstat : q2 : solution stationnaire du probleme couple
+c           (valeur a la fin du pas de temps)
+c
+c.......................................................................
+      REAL kmpre(ngrid,nlay+1)
+      REAL qcstat
+      REAL q2cstat
+c.......................................................................
+c
+c long : longueur de melange calculee selon Blackadar
+c
+c.......................................................................
+      REAL long(ngrid,nlay+1)
+c.......................................................................
+c
+c kmq3 : terme en q^3 dans le developpement de km
+c        (valeur au debut du pas de temps)
+c kmcstat : valeur de km solution stationnaire du systeme {q2 ; du/dz}
+c           (valeur a la fin du pas de temps)
+c knq3 : terme en q^3 dans le developpement de kn
+c mcstat : valeur de m solution stationnaire du systeme {q2 ; du/dz}
+c          (valeur a la fin du pas de temps)
+c m2cstat : valeur de m2 solution stationnaire du systeme {q2 ; du/dz}
+c           (valeur a la fin du pas de temps)
+c m : valeur a la fin du pas de temps
+c mpre : valeur au debut du pas de temps
+c m2 : valeur a la fin du pas de temps
+c n2 : valeur a la fin du pas de temps
+c 
+c.......................................................................
+      REAL kmq3
+      REAL kmcstat
+      REAL knq3
+      REAL mcstat
+      REAL m2cstat
+      REAL m(ngrid,nlay+1)
+      REAL mpre(ngrid,nlay+1)
+      REAL m2(ngrid,nlay+1)
+      REAL n2(ngrid,nlay+1)
+c.......................................................................
+c
+c gn : intermediaire pour les coefficients de stabilite
+c gnmin : borne inferieure de gn (-0.23 ou -0.28)
+c gnmax : borne superieure de gn (0.0233)
+c gninf : vrai si gn est en dessous de sa borne inferieure
+c gnsup : vrai si gn est en dessus de sa borne superieure
+c gm : drole d'objet bien utile
+c ri : nombre de Richardson
+c sn : coefficient de stabilite pour n
+c snq2 : premier terme du developement limite de sn en q2
+c sm : coefficient de stabilite pour m
+c smq2 : premier terme du developement limite de sm en q2
+c
+c.......................................................................
+      REAL gn
+      REAL,PARAMETER :: gnmin=-10.E+0
+      REAL,PARAMETER :: gnmax=0.0233E+0
+      LOGICAL gninf
+      LOGICAL gnsup
+      REAL gm
+c      REAL ri(ngrid,nlaye+1)
+      REAL sn(ngrid,nlay+1)
+      REAL snq2(ngrid,nlay+1)
+      REAL sm(ngrid,nlay+1)
+      REAL smq2(ngrid,nlay+1)
+c.......................................................................
+c
+c kappa : consatnte de Von Karman (0.4)
+c long0 : longueur de reference pour le calcul de long (160)
+c a1,a2,b1,b2,c1 : constantes d'origine pour les  coefficients
+c                  de stabilite (0.92/0.74/16.6/10.1/0.08)
+c cn1,cn2 : constantes pour sn
+c cm1,cm2,cm3,cm4 : constantes pour sm
+c
+c.......................................................................
+      REAL,PARAMETER :: kappa=0.4E+0
+      REAL,PARAMETER :: long0=160.E+0
+      REAL,PARAMETER :: a1=0.92E+0,a2=0.74E+0
+      REAL,PARAMETER :: b1=16.6E+0,b2=10.1E+0,c1=0.08E+0
+      REAL,PARAMETER :: cn1=a2*(1.E+0 -6.E+0 *a1/b1)
+      REAL,PARAMETER :: cn2=-3.E+0 *a2*(6.E+0 *a1+b2)
+      REAL,PARAMETER :: cm1=a1*(1.E+0 -3.E+0 *c1-6.E+0 *a1/b1)
+      REAL,PARAMETER :: cm2=a1*(-3.E+0 *a2*((b2-3.E+0 *a2)*
+     &          (1.E+0 -6.E+0 *a1/b1)-3.E+0 *c1*(b2+6.E+0 *a1)))
+      REAL,PARAMETER :: cm3=-3.E+0 *a2*(6.E+0 *a1+b2)
+      REAL,PARAMETER :: cm4=-9.E+0 *a1*a2
+c.......................................................................
+c
+c termq : termes en $q$ dans l'equation de q2
+c termq3 : termes en $q^3$ dans l'equation de q2
+c termqm2 : termes en $q*m^2$ dans l'equation de q2
+c termq3m2 : termes en $q^3*m^2$ dans l'equation de q2
+c
+c.......................................................................
+      REAL termq
+      REAL termq3
+      REAL termqm2
+      REAL termq3m2
+c.......................................................................
+c
+c q2min : borne inferieure de q2
+c q2max : borne superieure de q2
+c
+c.......................................................................
+      REAL,PARAMETER :: q2min=1.E-3
+      REAL,PARAMETER :: q2max=1.E+2
+c.......................................................................
+c knmin : borne inferieure de kn
+c kmmin : borne inferieure de km
+c.......................................................................
+      REAL,PARAMETER :: knmin=1.E-5
+      REAL,PARAMETER :: kmmin=1.E-5
+c.......................................................................
+      INTEGER ilay,ilev,igrid
+      REAL tmp1,tmp2
+c.......................................................................
+c
+
+! initialization of local variables:
+      nlev=nlay+1
+      long(:,:)=0.
+      n2(:,:)=0.
+      sn(:,:)=0.
+      snq2(:,:)=0.
+      sm(:,:)=0.
+      smq2(:,:)=0.
+
+c.......................................................................
+c  traitment des valeur de q2 en entree
+c.......................................................................
+c
+      DO ilev=1,nlev
+       DO igrid=1,ngrid 
+        q2(igrid,ilev)=amax1(q2(igrid,ilev),q2min)
+        q(igrid,ilev)=sqrt(q2(igrid,ilev))
+       ENDDO
+      ENDDO
+c
+      DO igrid=1,ngrid
+        tmp1=cd(igrid)*(u(igrid,1)**2+v(igrid,1)**2)
+        q2(igrid,1)=b1**(2.E+0/3.E+0)*tmp1
+        q2(igrid,1)=amax1(q2(igrid,1),q2min)
+        q(igrid,1)=sqrt(q2(igrid,1))
+      ENDDO
+c
+c.......................................................................
+c  les increments verticaux
+c.......................................................................
+c
+c!!!!! allerte !!!!!c
+c!!!!! zlev n'est pas declare a nlev !!!!!c
+c!!!!! ---->
+c                                                     DO igrid=1,ngrid 
+c           zlev(igrid,nlev)=zlay(igrid,nlay)
+c    &             +( zlay(igrid,nlay) - zlev(igrid,nlev-1) )
+c                                                     ENDDO            
+c!!!!! <----
+c!!!!! allerte !!!!!c
+c
+      DO ilay=1,nlay
+       DO igrid=1,ngrid
+        unsdz(igrid,ilay)=1.E+0/(zlev(igrid,ilay+1)-zlev(igrid,ilay))
+       ENDDO
+      ENDDO
+
+      DO igrid=1,ngrid
+        unsdzdec(igrid,1)=1.E+0/(zlay(igrid,1)-zlev(igrid,1))
+      ENDDO
+
+      DO ilay=2,nlay
+        DO igrid=1,ngrid
+          unsdzdec(igrid,ilay)=1.E+0/
+     &                          (zlay(igrid,ilay)-zlay(igrid,ilay-1))
+        ENDDO
+      ENDDO
+      
+      DO igrid=1,ngrid
+        unsdzdec(igrid,nlay+1)=1.E+0/
+     &                          (zlev(igrid,nlay+1)-zlay(igrid,nlay))
+      ENDDO
+c
+c.......................................................................
+c  le cisaillement et le gradient de temperature
+c.......................................................................
+c
+      DO igrid=1,ngrid
+        m2(igrid,1)=(unsdzdec(igrid,1)
+     &                   *u(igrid,1))**2
+     &                 +(unsdzdec(igrid,1)
+     &                   *v(igrid,1))**2
+        m(igrid,1)=sqrt(m2(igrid,1))
+        mpre(igrid,1)=m(igrid,1)
+      ENDDO
+c
+c-----------------------------------------------------------------------
+      DO ilev=2,nlev-1
+       DO igrid=1,ngrid
+c-----------------------------------------------------------------------
+c
+        n2(igrid,ilev)=g*unsdzdec(igrid,ilev)
+     &                   *(teta(igrid,ilev)-teta(igrid,ilev-1))
+     &                   /(teta(igrid,ilev)+teta(igrid,ilev-1)) *2.E+0
+c
+c --->
+c       on ne sais traiter que les cas stratifies. et l'ajustement
+c       convectif est cense faire en sorte que seul des configurations
+c       stratifiees soient rencontrees en entree de cette routine.
+c       mais, bon ... on sait jamais (meme on sait que n2 prends
+c       quelques valeurs negatives ... parfois) alors : 
+c<---
+c
+        IF (n2(igrid,ilev).lt.0.E+0) THEN
+          n2(igrid,ilev)=0.E+0
+        ENDIF
+c
+        m2(igrid,ilev)=(unsdzdec(igrid,ilev)
+     &                     *(u(igrid,ilev)-u(igrid,ilev-1)))**2
+     &                   +(unsdzdec(igrid,ilev)
+     &                     *(v(igrid,ilev)-v(igrid,ilev-1)))**2
+        m(igrid,ilev)=sqrt(m2(igrid,ilev))
+        mpre(igrid,ilev)=m(igrid,ilev)
+c
+c-----------------------------------------------------------------------
+       ENDDO
+      ENDDO
+c-----------------------------------------------------------------------
+c
+      DO igrid=1,ngrid
+        m2(igrid,nlev)=m2(igrid,nlev-1)
+        m(igrid,nlev)=m(igrid,nlev-1)
+        mpre(igrid,nlev)=m(igrid,nlev)
+      ENDDO
+      
+c
+c.......................................................................
+c  calcul des fonctions de stabilite
+c.......................................................................
+c
+c-----------------------------------------------------------------------
+      DO ilev=2,nlev-1
+       DO igrid=1,ngrid
+c-----------------------------------------------------------------------
+c
+        tmp1=kappa*(zlev(igrid,ilev)-zlev(igrid,1))
+        long(igrid,ilev)=tmp1/(1.E+0 + tmp1/long0)
+        gn=-long(igrid,ilev)**2 / q2(igrid,ilev)
+     &                                           * n2(igrid,ilev)
+        gm=long(igrid,ilev)**2 / q2(igrid,ilev)
+     &                                           * m2(igrid,ilev)
+c
+        gninf=.false.
+        gnsup=.false.
+        long(igrid,ilev)=long(igrid,ilev)
+        long(igrid,ilev)=long(igrid,ilev)
+c
+        IF (gn.lt.gnmin) THEN
+          gninf=.true.
+          gn=gnmin
+        ENDIF
+c
+        IF (gn.gt.gnmax) THEN
+          gnsup=.true.
+          gn=gnmax
+        ENDIF
+c
+        sn(igrid,ilev)=cn1/(1.E+0 +cn2*gn)
+        sm(igrid,ilev)=
+     &    (cm1+cm2*gn)
+     &   /( (1.E+0 +cm3*gn)
+     &     *(1.E+0 +cm4*gn) )
+c
+        IF ((gninf).or.(gnsup)) THEN
+          snq2(igrid,ilev)=0.E+0
+          smq2(igrid,ilev)=0.E+0
+        ELSE
+          snq2(igrid,ilev)=
+     &     -gn
+     &     *(-cn1*cn2/(1.E+0 +cn2*gn)**2 )
+          smq2(igrid,ilev)=
+     &     -gn
+     &     *( cm2*(1.E+0 +cm3*gn)
+     &           *(1.E+0 +cm4*gn)
+     &       -( cm3*(1.E+0 +cm4*gn)
+     &         +cm4*(1.E+0 +cm3*gn) )
+     &       *(cm1+cm2*gn)            )
+     &     /( (1.E+0 +cm3*gn)
+     &       *(1.E+0 +cm4*gn) )**2
+        ENDIF
+c
+c --->
+c       la decomposition de Taylor en q2 n'a de sens que
+c       dans les cas stratifies ou sn et sm sont quasi
+c       proportionnels a q2. ailleurs on laisse le meme
+c       algorithme car l'ajustement convectif fait le travail.
+c       mais c'est delirant quand sn et snq2 n'ont pas le meme
+c       signe : dans ces cas, on ne fait pas la decomposition.
+c<---
+c
+        IF (snq2(igrid,ilev)*sn(igrid,ilev).le.0.E+0)
+     &      snq2(igrid,ilev)=0.E+0
+        IF (smq2(igrid,ilev)*sm(igrid,ilev).le.0.E+0)
+     &      smq2(igrid,ilev)=0.E+0
+c
+c-----------------------------------------------------------------------
+       ENDDO ! of DO igrid=1,ngrid
+      ENDDO ! of DO ilev=2,nlev-1
+c-----------------------------------------------------------------------
+c
+c.......................................................................
+c  calcul de km et kn au debut du pas de temps
+c.......................................................................
+c
+      DO igrid=1,ngrid
+        kn(igrid,1)=knmin
+        km(igrid,1)=kmmin
+        kmpre(igrid,1)=km(igrid,1)
+      ENDDO
+c
+c-----------------------------------------------------------------------
+      DO ilev=2,nlev-1
+       DO igrid=1,ngrid
+        kn(igrid,ilev)=long(igrid,ilev)*q(igrid,ilev)
+     &                                         *sn(igrid,ilev)
+        km(igrid,ilev)=long(igrid,ilev)*q(igrid,ilev)
+     &                                         *sm(igrid,ilev)
+        kmpre(igrid,ilev)=km(igrid,ilev)
+       ENDDO
+      ENDDO
+c-----------------------------------------------------------------------
+c
+      DO igrid=1,ngrid
+        kn(igrid,nlev)=kn(igrid,nlev-1)
+        km(igrid,nlev)=km(igrid,nlev-1)
+        kmpre(igrid,nlev)=km(igrid,nlev)
+      ENDDO
+c
+c.......................................................................
+c  boucle sur les niveaux 2 a nlev-1
+c.......................................................................
+c
+c---->
+      DO 10001 ilev=2,nlev-1
+c---->
+      DO 10002 igrid=1,ngrid
+c
+c.......................................................................
+c
+c  calcul des termes sources et puits de l'equation de q2
+c  ------------------------------------------------------
+c
+        knq3=kn(igrid,ilev)*snq2(igrid,ilev)
+     &                                    /sn(igrid,ilev)
+        kmq3=km(igrid,ilev)*smq2(igrid,ilev)
+     &                                    /sm(igrid,ilev)
+c
+        termq=0.E+0
+        termq3=0.E+0
+        termqm2=0.E+0
+        termq3m2=0.E+0
+c
+        tmp1=dt*2.E+0 *km(igrid,ilev)*m2(igrid,ilev)
+        tmp2=dt*2.E+0 *kmq3*m2(igrid,ilev)
+        termqm2=termqm2
+     &    +dt*2.E+0 *km(igrid,ilev)*m2(igrid,ilev)
+     &    -dt*2.E+0 *kmq3*m2(igrid,ilev)
+        termq3m2=termq3m2
+     &    +dt*2.E+0 *kmq3*m2(igrid,ilev)
+c 
+        termq=termq
+     &    -dt*2.E+0 *kn(igrid,ilev)*n2(igrid,ilev)
+     &    +dt*2.E+0 *knq3*n2(igrid,ilev)
+        termq3=termq3
+     &    -dt*2.E+0 *knq3*n2(igrid,ilev)
+c
+        termq3=termq3
+     &    -dt*2.E+0 *q(igrid,ilev)**3 / (b1*long(igrid,ilev))
+c
+c.......................................................................
+c
+c  resolution stationnaire couplee avec le gradient de vitesse local
+c  -----------------------------------------------------------------
+c
+c  -----{on cherche le cisaillement qui annule l'equation de q^2
+c        supposee en q3}
+c
+        tmp1=termq+termq3
+        tmp2=termqm2+termq3m2
+        m2cstat=m2(igrid,ilev)
+     &      -(tmp1+tmp2)/(dt*2.E+0*km(igrid,ilev))
+        mcstat=sqrt(m2cstat)
+c
+c  -----{puis on ecrit la valeur de q qui annule l'equation de m
+c        supposee en q3}
+c
+        IF (ilev.eq.2) THEN
+          kmcstat=1.E+0 / mcstat
+     &    *( unsdz(igrid,ilev)*kmpre(igrid,ilev+1)
+     &                        *mpre(igrid,ilev+1)
+     &      +unsdz(igrid,ilev-1)
+     &              *cd(igrid)
+     &              *( sqrt(u(igrid,3)**2+v(igrid,3)**2)
+     &                -mcstat/unsdzdec(igrid,ilev)
+     &                -mpre(igrid,ilev+1)/unsdzdec(igrid,ilev+1) )**2)
+     &      /( unsdz(igrid,ilev)+unsdz(igrid,ilev-1) )
+        ELSE
+          kmcstat=1.E+0 / mcstat
+     &    *( unsdz(igrid,ilev)*kmpre(igrid,ilev+1)
+     &                        *mpre(igrid,ilev+1)
+     &      +unsdz(igrid,ilev-1)*kmpre(igrid,ilev-1)
+     &                          *mpre(igrid,ilev-1) )
+     &      /( unsdz(igrid,ilev)+unsdz(igrid,ilev-1) )
+        ENDIF
+        tmp2=kmcstat
+     &      /( sm(igrid,ilev)/q2(igrid,ilev) )
+     &      /long(igrid,ilev)
+        qcstat=tmp2**(1.E+0/3.E+0)
+        q2cstat=qcstat**2
+c
+c.......................................................................
+c
+c  choix de la solution finale
+c  ---------------------------
+c
+          q(igrid,ilev)=qcstat
+          q2(igrid,ilev)=q2cstat
+          m(igrid,ilev)=mcstat
+          m2(igrid,ilev)=m2cstat
+c
+c --->
+c       pour des raisons simples q2 est minore 
+c<---
+c
+        IF (q2(igrid,ilev).lt.q2min) THEN
+          q2(igrid,ilev)=q2min
+          q(igrid,ilev)=sqrt(q2min)
+        ENDIF
+c
+c.......................................................................
+c
+c  calcul final de kn et km
+c  ------------------------
+c
+        gn=-long(igrid,ilev)**2 / q2(igrid,ilev)
+     &                                           * n2(igrid,ilev)
+        IF (gn.lt.gnmin) gn=gnmin
+        IF (gn.gt.gnmax) gn=gnmax
+        sn(igrid,ilev)=cn1/(1.E+0 +cn2*gn)
+        sm(igrid,ilev)=
+     &    (cm1+cm2*gn)
+     &   /( (1.E+0 +cm3*gn)*(1.E+0 +cm4*gn) )
+        kn(igrid,ilev)=long(igrid,ilev)*q(igrid,ilev)
+     &                 *sn(igrid,ilev)
+        km(igrid,ilev)=long(igrid,ilev)*q(igrid,ilev)
+     &                 *sm(igrid,ilev)
+c
+c.......................................................................
+c
+10002 CONTINUE
+c
+10001 CONTINUE
+c
+c.......................................................................
+c
+c
+      DO igrid=1,ngrid
+        kn(igrid,1)=knmin
+        km(igrid,1)=kmmin
+        q2(igrid,nlev)=q2(igrid,nlev-1)
+        q(igrid,nlev)=q(igrid,nlev-1)
+        kn(igrid,nlev)=kn(igrid,nlev-1)
+        km(igrid,nlev)=km(igrid,nlev-1)
+      ENDDO
+
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/vdifc.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/vdifc.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/vdifc.F	(revision 1644)
@@ -0,0 +1,729 @@
+      subroutine vdifc(ngrid,nlay,nq,rnat,ppopsk,         
+     &     ptimestep,pcapcal,lecrit,                        
+     &     pplay,pplev,pzlay,pzlev,pz0,
+     &     pu,pv,ph,pq,ptsrf,pemis,pqsurf,
+     &     pdhfi,pdqfi,pfluxsrf,
+     &     pdudif,pdvdif,pdhdif,pdtsrf,sensibFlux,pq2,
+     &     pdqdif,pdqsdif,lastcall)
+
+      use watercommon_h, only : RLVTT, T_h2O_ice_liq, RCPD, mx_eau_sol
+      use radcommon_h, only : sigma
+      USE surfdat_h
+      USE tracer_h
+      use comcstfi_mod, only: g, r, cpp, rcp
+      use callkeys_mod, only: water,tracer,nosurf
+
+      implicit none
+
+!==================================================================
+!     
+!     Purpose
+!     -------
+!     Turbulent diffusion (mixing) for pot. T, U, V and tracers
+!     
+!     Implicit scheme
+!     We start by adding to variables x the physical tendencies
+!     already computed. We resolve the equation:
+!
+!     x(t+1) =  x(t) + dt * (dx/dt)phys(t)  +  dt * (dx/dt)difv(t+1)
+!     
+!     Authors
+!     ------- 
+!     F. Hourdin, F. Forget, R. Fournier (199X)
+!     R. Wordsworth, B. Charnay (2010)
+!     
+!==================================================================
+
+!-----------------------------------------------------------------------
+!     declarations
+!     ------------
+
+
+!     arguments
+!     ---------
+      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)
+      REAL ptsrf(ngrid),pemis(ngrid)
+      REAL pdhfi(ngrid,nlay)
+      REAL pfluxsrf(ngrid)
+      REAL pdudif(ngrid,nlay),pdvdif(ngrid,nlay),pdhdif(ngrid,nlay)
+      REAL pdtsrf(ngrid),sensibFlux(ngrid),pcapcal(ngrid)
+      REAL pq2(ngrid,nlay+1)
+      
+      real rnat(ngrid)      
+
+!     Arguments added for condensation
+      REAL ppopsk(ngrid,nlay)
+      logical lecrit
+      REAL pz0
+
+!     Tracers
+!     --------
+      integer nq 
+      real pqsurf(ngrid,nq)
+      real pq(ngrid,nlay,nq), pdqfi(ngrid,nlay,nq) 
+      real pdqdif(ngrid,nlay,nq) 
+      real pdqsdif(ngrid,nq) 
+      
+!     local
+!     -----
+      integer ilev,ig,ilay,nlev
+
+      REAL z4st,zdplanck(ngrid)
+      REAL zkv(ngrid,nlay+1),zkh(ngrid,nlay+1)
+      REAL zcdv(ngrid),zcdh(ngrid)
+      REAL zcdv_true(ngrid),zcdh_true(ngrid)
+      REAL zu(ngrid,nlay),zv(ngrid,nlay)
+      REAL zh(ngrid,nlay)
+      REAL ztsrf2(ngrid)
+      REAL z1(ngrid),z2(ngrid)
+      REAL za(ngrid,nlay),zb(ngrid,nlay)
+      REAL zb0(ngrid,nlay)
+      REAL zc(ngrid,nlay),zd(ngrid,nlay)
+      REAL zcst1
+      REAL zu2!, a
+      REAL zcq(ngrid,nlay),zdq(ngrid,nlay)
+      REAL evap(ngrid)
+      REAL zcq0(ngrid),zdq0(ngrid)
+      REAL zx_alf1(ngrid),zx_alf2(ngrid)
+
+      LOGICAL firstcall
+      SAVE firstcall
+!$OMP THREADPRIVATE(firstcall)
+      
+      LOGICAL lastcall
+
+!     variables added for CO2 condensation
+!     ------------------------------------
+      REAL hh                   !, zhcond(ngrid,nlay)
+!     REAL latcond,tcond1mb
+!     REAL acond,bcond
+!     SAVE acond,bcond
+!!$OMP THREADPRIVATE(acond,bcond)
+!     DATA latcond,tcond1mb/5.9e5,136.27/
+
+!     Tracers
+!     -------
+      INTEGER iq
+      REAL zq(ngrid,nlay,nq)
+      REAL zq1temp(ngrid)
+      REAL rho(ngrid)         ! near-surface air density
+      REAL qsat(ngrid)
+      DATA firstcall/.true./
+      REAL kmixmin
+
+!     Variables added for implicit latent heat inclusion
+!     --------------------------------------------------
+      real latconst, dqsat(ngrid), qsat_temp1, qsat_temp2
+      real z1_Tdry(ngrid), z2_Tdry(ngrid)
+      real z1_T(ngrid), z2_T(ngrid)
+      real zb_T(ngrid)
+      real zc_T(ngrid,nlay)
+      real zd_T(ngrid,nlay)
+      real lat1(ngrid), lat2(ngrid)
+      real surfh2otot
+      logical surffluxdiag
+      integer isub ! sub-loop for precision
+
+      integer ivap, iice ! also make liq for clarity on surface...
+      save ivap, iice
+!$OMP THREADPRIVATE(ivap,iice)
+
+      real, parameter :: karman=0.4
+      real cd0, roughratio
+
+      logical forceWC
+      real masse, Wtot, Wdiff
+
+      real dqsdif_total(ngrid) 
+      real zq0(ngrid) 
+
+      forceWC=.true.
+!      forceWC=.false.
+
+
+!     Coherence test
+!     --------------
+
+      IF (firstcall) THEN
+!     To compute: Tcond= 1./(bcond-acond*log(.0095*p)) (p in pascal)
+!     bcond=1./tcond1mb
+!     acond=r/latcond
+!     PRINT*,'In vdifc: Tcond(P=1mb)=',tcond1mb,' Lcond=',latcond
+!     PRINT*,'          acond,bcond',acond,bcond
+
+         if(water)then
+!                iliq=igcm_h2o_vap
+                ivap=igcm_h2o_vap
+                iice=igcm_h2o_ice ! simply to make the code legible               
+                                  ! to be generalised later
+         endif
+
+         firstcall=.false.
+      ENDIF
+
+!-----------------------------------------------------------------------
+!     1. Initialisation
+!     -----------------
+
+      nlev=nlay+1
+
+!     Calculate rho*dz and dt*rho/dz=dt*rho**2 g/dp
+!     with rho=p/RT=p/ (R Theta) (p/ps)**kappa
+!     ---------------------------------------------
+
+      DO ilay=1,nlay
+         DO ig=1,ngrid
+            za(ig,ilay)=(pplev(ig,ilay)-pplev(ig,ilay+1))/g
+         ENDDO
+      ENDDO
+
+      zcst1=4.*g*ptimestep/(R*R)
+      DO ilev=2,nlev-1
+         DO ig=1,ngrid
+            zb0(ig,ilev)=pplev(ig,ilev)*
+     s           (pplev(ig,1)/pplev(ig,ilev))**rcp /
+     s           (ph(ig,ilev-1)+ph(ig,ilev))
+            zb0(ig,ilev)=zcst1*zb0(ig,ilev)*zb0(ig,ilev)/
+     s           (pplay(ig,ilev-1)-pplay(ig,ilev))
+         ENDDO
+      ENDDO
+      DO ig=1,ngrid
+         zb0(ig,1)=ptimestep*pplev(ig,1)/(R*ptsrf(ig))
+      ENDDO
+
+      dqsdif_total(:)=0.0
+
+!-----------------------------------------------------------------------
+!     2. Add the physical tendencies computed so far
+!     ----------------------------------------------
+
+      DO ilev=1,nlay
+         DO ig=1,ngrid
+            zu(ig,ilev)=pu(ig,ilev)
+            zv(ig,ilev)=pv(ig,ilev)
+            zh(ig,ilev)=ph(ig,ilev)+pdhfi(ig,ilev)*ptimestep
+         ENDDO
+      ENDDO
+      if(tracer) then
+         DO iq =1, nq
+            DO ilev=1,nlay
+               DO ig=1,ngrid
+                  zq(ig,ilev,iq)=pq(ig,ilev,iq) + 
+     &                 pdqfi(ig,ilev,iq)*ptimestep
+               ENDDO
+            ENDDO
+         ENDDO
+      end if
+
+!-----------------------------------------------------------------------
+!     3. Turbulence scheme
+!     --------------------
+!
+!     Source of turbulent kinetic energy at the surface
+!     ------------------------------------------------- 
+!     Formula is Cd_0 = (karman / log[1+z1/z0])^2
+
+      DO ig=1,ngrid
+         roughratio = 1.E+0 + pzlay(ig,1)/pz0
+         cd0 = karman/log(roughratio)
+         cd0 = cd0*cd0
+         zcdv_true(ig) = cd0
+         zcdh_true(ig) = cd0
+         if (nosurf) then
+             zcdv_true(ig) = 0.   !! disable sensible momentum flux
+             zcdh_true(ig) = 0.   !! disable sensible heat flux
+         endif
+      ENDDO
+
+      DO ig=1,ngrid
+         zu2=pu(ig,1)*pu(ig,1)+pv(ig,1)*pv(ig,1)
+         zcdv(ig)=zcdv_true(ig)*sqrt(zu2)
+         zcdh(ig)=zcdh_true(ig)*sqrt(zu2)
+      ENDDO
+
+!     Turbulent diffusion coefficients in the boundary layer
+!     ------------------------------------------------------ 
+
+      call vdif_kc(ngrid,nlay,ptimestep,g,pzlev,pzlay
+     &     ,pu,pv,ph,zcdv_true
+     &     ,pq2,zkv,zkh)
+
+!     Adding eddy mixing to mimic 3D general circulation in 1D
+!     R. Wordsworth & F. Forget (2010)
+      if ((ngrid.eq.1)) then
+         kmixmin = 1.0e-2       ! minimum eddy mix coeff in 1D
+         do ilev=1,nlay
+            do ig=1,ngrid
+               !zkh(ig,ilev) = 1.0
+               zkh(ig,ilev) = max(kmixmin,zkh(ig,ilev))
+               zkv(ig,ilev) = max(kmixmin,zkv(ig,ilev))
+            end do
+         end do
+      end if
+
+!-----------------------------------------------------------------------
+!     4. Implicit inversion of u
+!     --------------------------
+
+!     u(t+1) =  u(t) + dt * {(du/dt)phys}(t)  +  dt * {(du/dt)difv}(t+1)
+!     avec
+!     /zu/ = u(t) + dt * {(du/dt)phys}(t)   (voir paragraphe 2.)
+!     et
+!     dt * {(du/dt)difv}(t+1) = dt * {(d/dz)[ Ku (du/dz) ]}(t+1)
+!     donc les entrees sont /zcdv/ pour la condition a la limite sol
+!     et /zkv/ = Ku
+      
+      CALL multipl((nlay-1)*ngrid,zkv(1,2),zb0(1,2),zb(1,2))
+      CALL multipl(ngrid,zcdv,zb0,zb)
+
+      DO ig=1,ngrid
+         z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
+         zc(ig,nlay)=za(ig,nlay)*zu(ig,nlay)*z1(ig)
+         zd(ig,nlay)=zb(ig,nlay)*z1(ig)
+      ENDDO
+
+      DO ilay=nlay-1,1,-1
+         DO ig=1,ngrid
+            z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
+     $           zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
+            zc(ig,ilay)=(za(ig,ilay)*zu(ig,ilay)+
+     $           zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
+            zd(ig,ilay)=zb(ig,ilay)*z1(ig)
+         ENDDO
+      ENDDO
+
+      DO ig=1,ngrid
+         zu(ig,1)=zc(ig,1)
+      ENDDO
+      DO ilay=2,nlay
+         DO ig=1,ngrid
+            zu(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zu(ig,ilay-1)
+         ENDDO
+      ENDDO
+
+!-----------------------------------------------------------------------
+!     5. Implicit inversion of v
+!     --------------------------
+
+!     v(t+1) =  v(t) + dt * {(dv/dt)phys}(t)  +  dt * {(dv/dt)difv}(t+1)
+!     avec
+!     /zv/ = v(t) + dt * {(dv/dt)phys}(t)   (voir paragraphe 2.)
+!     et
+!     dt * {(dv/dt)difv}(t+1) = dt * {(d/dz)[ Kv (dv/dz) ]}(t+1)
+!     donc les entrees sont /zcdv/ pour la condition a la limite sol
+!     et /zkv/ = Kv
+
+      DO ig=1,ngrid
+         z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
+         zc(ig,nlay)=za(ig,nlay)*zv(ig,nlay)*z1(ig)
+         zd(ig,nlay)=zb(ig,nlay)*z1(ig)
+      ENDDO
+
+      DO ilay=nlay-1,1,-1
+         DO ig=1,ngrid
+            z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
+     $           zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
+            zc(ig,ilay)=(za(ig,ilay)*zv(ig,ilay)+
+     $           zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
+            zd(ig,ilay)=zb(ig,ilay)*z1(ig)
+         ENDDO
+      ENDDO
+
+      DO ig=1,ngrid
+         zv(ig,1)=zc(ig,1)
+      ENDDO
+      DO ilay=2,nlay
+         DO ig=1,ngrid
+            zv(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zv(ig,ilay-1)
+         ENDDO
+      ENDDO
+
+!----------------------------------------------------------------------------
+!     6. Implicit inversion of h, not forgetting the coupling with the ground
+
+!     h(t+1) =  h(t) + dt * {(dh/dt)phys}(t)  +  dt * {(dh/dt)difv}(t+1)
+!     avec
+!     /zh/ = h(t) + dt * {(dh/dt)phys}(t)   (voir paragraphe 2.)
+!     et
+!     dt * {(dh/dt)difv}(t+1) = dt * {(d/dz)[ Kh (dh/dz) ]}(t+1)
+!     donc les entrees sont /zcdh/ pour la condition de raccord au sol
+!     et /zkh/ = Kh
+
+!     Using the wind modified by friction for lifting and sublimation
+!     ---------------------------------------------------------------
+         DO ig=1,ngrid
+            zu2      = zu(ig,1)*zu(ig,1)+zv(ig,1)*zv(ig,1)
+            zcdv(ig) = zcdv_true(ig)*sqrt(zu2)
+            zcdh(ig) = zcdh_true(ig)*sqrt(zu2)
+         ENDDO
+
+      CALL multipl((nlay-1)*ngrid,zkh(1,2),zb0(1,2),zb(1,2))
+      CALL multipl(ngrid,zcdh,zb0,zb)
+
+      DO ig=1,ngrid
+         z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
+         zc(ig,nlay)=za(ig,nlay)*zh(ig,nlay)*z1(ig)
+         zd(ig,nlay)=zb(ig,nlay)*z1(ig)
+      ENDDO
+
+      DO ilay=nlay-1,2,-1
+         DO ig=1,ngrid
+            z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
+     &           zb(ig,ilay+1)*(1.-zd(ig,ilay+1)))
+            zc(ig,ilay)=(za(ig,ilay)*zh(ig,ilay)+
+     &           zb(ig,ilay+1)*zc(ig,ilay+1))*z1(ig)
+            zd(ig,ilay)=zb(ig,ilay)*z1(ig)
+         ENDDO
+      ENDDO
+
+      DO ig=1,ngrid
+         z1(ig)=1./(za(ig,1)+zb(ig,1)+
+     &        zb(ig,2)*(1.-zd(ig,2)))
+         zc(ig,1)=(za(ig,1)*zh(ig,1)+
+     &        zb(ig,2)*zc(ig,2))*z1(ig)
+         zd(ig,1)=zb(ig,1)*z1(ig)
+      ENDDO
+
+!     Calculate (d Planck / dT) at the interface temperature
+!     ------------------------------------------------------
+
+      z4st=4.0*sigma*ptimestep
+      DO ig=1,ngrid
+         zdplanck(ig)=z4st*pemis(ig)*ptsrf(ig)*ptsrf(ig)*ptsrf(ig)
+      ENDDO
+
+!     Calculate temperature tendency at the interface (dry case)
+!     ----------------------------------------------------------
+!     Sum of fluxes at interface at time t + \delta t gives change in T:
+!       radiative fluxes
+!       turbulent convective (sensible) heat flux
+!       flux (if any) from subsurface
+
+      if(.not.water) then
+
+         DO ig=1,ngrid
+
+            z1(ig) = pcapcal(ig)*ptsrf(ig) + cpp*zb(ig,1)*zc(ig,1)
+     &           + zdplanck(ig)*ptsrf(ig) + pfluxsrf(ig)*ptimestep
+            z2(ig) = pcapcal(ig) + cpp*zb(ig,1)*(1.-zd(ig,1)) 
+     &           +zdplanck(ig)
+            ztsrf2(ig) = z1(ig) / z2(ig)
+            pdtsrf(ig) = (ztsrf2(ig) - ptsrf(ig))/ptimestep
+            zh(ig,1)   = zc(ig,1) + zd(ig,1)*ztsrf2(ig)
+         ENDDO
+
+!     Recalculate temperature to top of atmosphere, starting from ground
+!     ------------------------------------------------------------------
+
+         DO ilay=2,nlay
+            DO ig=1,ngrid
+               hh = zh(ig,ilay-1)
+               zh(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*hh
+            ENDDO
+         ENDDO
+
+      endif                     ! not water
+
+!-----------------------------------------------------------------------
+!     TRACERS (no vapour)
+!     -------
+
+      if(tracer) then
+
+!     Calculate vertical flux from the bottom to the first layer (dust)
+!     -----------------------------------------------------------------
+         do ig=1,ngrid  
+            rho(ig) = zb0(ig,1) /ptimestep
+         end do
+
+         call zerophys(ngrid*nq,pdqsdif)
+
+!     Implicit inversion of q
+!     -----------------------
+         do iq=1,nq 
+
+            if (iq.ne.igcm_h2o_vap) then
+
+               DO ig=1,ngrid
+                  z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
+                  zcq(ig,nlay)=za(ig,nlay)*zq(ig,nlay,iq)*z1(ig)
+                  zdq(ig,nlay)=zb(ig,nlay)*z1(ig)
+               ENDDO 
+            
+               DO ilay=nlay-1,2,-1
+                  DO ig=1,ngrid
+                     z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
+     &                    zb(ig,ilay+1)*(1.-zdq(ig,ilay+1)))
+                     zcq(ig,ilay)=(za(ig,ilay)*zq(ig,ilay,iq)+
+     &                    zb(ig,ilay+1)*zcq(ig,ilay+1))*z1(ig)
+                     zdq(ig,ilay)=zb(ig,ilay)*z1(ig)
+                  ENDDO
+               ENDDO
+
+               if ((water).and.(iq.eq.iice)) then
+                  ! special case for water ice tracer: do not include
+                  ! h2o ice tracer from surface (which is set when handling
+                  ! h2o vapour case (see further down).
+                  ! zb(ig,1)=0 if iq ne ivap
+                  DO ig=1,ngrid
+                     z1(ig)=1./(za(ig,1)+
+     &                    zb(ig,2)*(1.-zdq(ig,2)))
+                     zcq(ig,1)=(za(ig,1)*zq(ig,1,iq)+
+     &                    zb(ig,2)*zcq(ig,2))*z1(ig)
+                  ENDDO
+               else             ! general case
+                  DO ig=1,ngrid
+                     z1(ig)=1./(za(ig,1)+
+     &                    zb(ig,2)*(1.-zdq(ig,2)))
+                     zcq(ig,1)=(za(ig,1)*zq(ig,1,iq)+
+     &                    zb(ig,2)*zcq(ig,2)
+     &                    +(-pdqsdif(ig,iq))*ptimestep)*z1(ig)
+                          ! tracer flux from surface
+                          ! currently pdqsdif always zero here,
+                          ! so last line is superfluous
+                  enddo
+               endif            ! of if (water.and.(iq.eq.igcm_h2o_ice))
+
+
+!     Starting upward calculations for simple tracer mixing (e.g., dust)
+               do ig=1,ngrid
+                  zq(ig,1,iq)=zcq(ig,1)
+               end do
+
+               do ilay=2,nlay
+                  do ig=1,ngrid
+                     zq(ig,ilay,iq)=zcq(ig,ilay)+
+     $                    zdq(ig,ilay)*zq(ig,ilay-1,iq)
+                  end do
+               end do
+
+            endif               ! if (iq.ne.igcm_h2o_vap)
+
+!     Calculate temperature tendency including latent heat term
+!     and assuming an infinite source of water on the ground
+!     ------------------------------------------------------------------
+
+            if (water.and.(iq.eq.igcm_h2o_vap)) then 
+            
+               ! compute evaporation efficiency
+               do ig = 1, ngrid
+                  if(nint(rnat(ig)).eq.1)then
+                     dryness(ig)=pqsurf(ig,ivap)+pqsurf(ig,iice) 
+                     dryness(ig)=MIN(1.,2*dryness(ig)/mx_eau_sol)
+                     dryness(ig)=MAX(0.,dryness(ig))
+                  endif
+               enddo
+
+               do ig=1,ngrid
+
+                ! Calculate the value of qsat at the surface (water)
+                call watersat(ptsrf(ig),pplev(ig,1),qsat(ig))
+                call watersat(ptsrf(ig)-0.0001,pplev(ig,1),qsat_temp1)
+                call watersat(ptsrf(ig)+0.0001,pplev(ig,1),qsat_temp2)
+                dqsat(ig)=(qsat_temp2-qsat_temp1)/0.0002
+                ! calculate dQsat / dT by finite differences
+                ! we cannot use the updated temperature value yet...
+ 
+               enddo
+
+! coefficients for q
+
+               do ig=1,ngrid
+                  z1(ig)=1./(za(ig,nlay)+zb(ig,nlay))
+                  zcq(ig,nlay)=za(ig,nlay)*zq(ig,nlay,iq)*z1(ig)
+                  zdq(ig,nlay)=zb(ig,nlay)*z1(ig)
+               enddo 
+            
+               do ilay=nlay-1,2,-1
+                  do ig=1,ngrid
+                     z1(ig)=1./(za(ig,ilay)+zb(ig,ilay)+
+     $                    zb(ig,ilay+1)*(1.-zdq(ig,ilay+1)))
+                     zcq(ig,ilay)=(za(ig,ilay)*zq(ig,ilay,iq)+
+     $                    zb(ig,ilay+1)*zcq(ig,ilay+1))*z1(ig)
+                     zdq(ig,ilay)=zb(ig,ilay)*z1(ig)
+                  enddo
+               enddo
+
+               do ig=1,ngrid
+                  z1(ig)=1./(za(ig,1)+zb(ig,1)*dryness(ig)+
+     $                 zb(ig,2)*(1.-zdq(ig,2)))
+                  zcq(ig,1)=(za(ig,1)*zq(ig,1,iq)+
+     $                 zb(ig,2)*zcq(ig,2))*z1(ig)
+                  zdq(ig,1)=dryness(ig)*zb(ig,1)*z1(ig)
+               enddo
+
+! calculation of h0 and h1
+               do ig=1,ngrid
+                  zdq0(ig) = dqsat(ig)
+                  zcq0(ig) = qsat(ig)-dqsat(ig)*ptsrf(ig)
+
+                  z1(ig) = pcapcal(ig)*ptsrf(ig) +cpp*zb(ig,1)*zc(ig,1)
+     &                 + zdplanck(ig)*ptsrf(ig) + pfluxsrf(ig)*ptimestep 
+     &                 +  zb(ig,1)*dryness(ig)*RLVTT*
+     &                 ((zdq(ig,1)-1.0)*zcq0(ig)+zcq(ig,1))
+
+                  z2(ig) = pcapcal(ig) + cpp*zb(ig,1)*(1.-zd(ig,1))
+     &                 +zdplanck(ig)
+     &                 +zb(ig,1)*dryness(ig)*RLVTT*zdq0(ig)*
+     &                 (1.0-zdq(ig,1))
+
+                  ztsrf2(ig) = z1(ig) / z2(ig)
+                  pdtsrf(ig) = (ztsrf2(ig) - ptsrf(ig))/ptimestep
+                  zh(ig,1)   = zc(ig,1) + zd(ig,1)*ztsrf2(ig)
+               enddo
+
+! calculation of qs and q1
+               do ig=1,ngrid
+                  zq0(ig)     = zcq0(ig)+zdq0(ig)*ztsrf2(ig)
+                  zq(ig,1,iq) = zcq(ig,1)+zdq(ig,1)*zq0(ig)
+               enddo
+
+! calculation of evaporation              
+               do ig=1,ngrid 
+                  evap(ig)= zb(ig,1)*dryness(ig)*(zq(ig,1,ivap)-zq0(ig))
+                  dqsdif_total(ig)=evap(ig)
+               enddo
+
+! recalculate temperature and q(vap) to top of atmosphere, starting from ground
+               do ilay=2,nlay
+                  do ig=1,ngrid
+                     zq(ig,ilay,iq)=zcq(ig,ilay)
+     &                    +zdq(ig,ilay)*zq(ig,ilay-1,iq)
+                     zh(ig,ilay)=zc(ig,ilay)+zd(ig,ilay)*zh(ig,ilay-1)
+                  end do
+               end do
+
+               do ig=1,ngrid
+
+!     --------------------------------------------------------------------------
+!     On the ocean, if T > 0 C then the vapour tendency must replace the ice one
+!     The surface vapour tracer is actually liquid. To make things difficult.
+
+                  if (nint(rnat(ig)).eq.0) then ! unfrozen ocean
+                     
+                     pdqsdif(ig,ivap)=dqsdif_total(ig)/ptimestep
+                     pdqsdif(ig,iice)=0.0
+
+
+                  elseif (nint(rnat(ig)).eq.1) then ! (continent)
+
+!     --------------------------------------------------------
+!     Now check if we've taken too much water from the surface
+!     This can only occur on the continent 
+
+!     If water is evaporating / subliming, we take it from ice before liquid
+!     -- is this valid??
+                     if(dqsdif_total(ig).lt.0)then
+                        pdqsdif(ig,iice)=dqsdif_total(ig)/ptimestep
+                        pdqsdif(ig,iice)=max(-pqsurf(ig,iice)/ptimestep
+     &                       ,pdqsdif(ig,iice))
+                     endif
+                     ! sublimation only greater than qsurf(ice)
+                     ! ----------------------------------------
+                     ! we just convert some liquid to vapour too
+                     ! if latent heats are the same, no big deal
+                     if (-dqsdif_total(ig).gt.pqsurf(ig,iice))then            
+                       pdqsdif(ig,iice) = -pqsurf(ig,iice)/ptimestep ! removes all the ice!
+                       pdqsdif(ig,ivap) = dqsdif_total(ig)/ptimestep
+     &                       - pdqsdif(ig,iice) ! take the remainder from the liquid instead
+                       pdqsdif(ig,ivap) = max(-pqsurf(ig,ivap)/ptimestep
+     &                       ,pdqsdif(ig,ivap))
+                    endif
+
+                 endif          ! if (rnat.ne.1)
+
+!     If water vapour is condensing, we must decide whether it forms ice or liquid.
+                 if(dqsdif_total(ig).gt.0)then ! a bug was here!
+                    if(ztsrf2(ig).gt.T_h2O_ice_liq)then
+                       pdqsdif(ig,iice)=0.0
+                       pdqsdif(ig,ivap)=dqsdif_total(ig)/ptimestep
+                    else
+                       pdqsdif(ig,iice)=dqsdif_total(ig)/ptimestep
+                       pdqsdif(ig,ivap)=0.0
+                    endif
+                 endif
+
+              end do            ! of DO ig=1,ngrid
+           endif                ! if (water et iq=ivap)
+        end do                  ! of do iq=1,nq
+      endif                     ! traceur
+
+
+!-----------------------------------------------------------------------
+!     8. Final calculation of the vertical diffusion tendencies
+!     -----------------------------------------------------------------
+
+      do ilev = 1, nlay
+         do ig=1,ngrid
+            pdudif(ig,ilev)=(zu(ig,ilev)-
+     &           (pu(ig,ilev)))/ptimestep
+            pdvdif(ig,ilev)=(zv(ig,ilev)-
+     &           (pv(ig,ilev)))/ptimestep
+            hh = ph(ig,ilev)+pdhfi(ig,ilev)*ptimestep 
+
+            pdhdif(ig,ilev)=( zh(ig,ilev)- hh )/ptimestep
+         enddo
+      enddo
+
+      DO ig=1,ngrid  ! computing sensible heat flux (atm => surface)
+	 sensibFlux(ig)=cpp*zb(ig,1)/ptimestep*(zh(ig,1)-ztsrf2(ig))
+      ENDDO      
+
+      if (tracer) then
+         do iq = 1, nq
+            do ilev = 1, nlay
+               do ig=1,ngrid
+                  pdqdif(ig,ilev,iq)=(zq(ig,ilev,iq)-
+     &           (pq(ig,ilev,iq)+pdqfi(ig,ilev,iq)*ptimestep))/
+     &           ptimestep
+               enddo
+            enddo
+         enddo
+
+         if(water.and.forceWC)then ! force water conservation in model
+                                   ! we calculate the difference and add it to the ground
+                                   ! this is ugly and should be improved in the future
+            do ig=1,ngrid
+               Wtot=0.0
+               do ilay=1,nlay
+                  masse = (pplev(ig,ilay) - pplev(ig,ilay+1))/g
+!                  Wtot=Wtot+masse*(zq(ig,ilay,iice)-
+!     &                 (pq(ig,ilay,iice)+pdqfi(ig,ilay,iice)*ptimestep))
+                  Wtot=Wtot+masse*(zq(ig,ilay,ivap)-
+     &                 (pq(ig,ilay,ivap)+pdqfi(ig,ilay,ivap)*ptimestep))
+               enddo
+               Wdiff=Wtot/ptimestep+pdqsdif(ig,ivap)+pdqsdif(ig,iice)
+
+               if(ztsrf2(ig).gt.T_h2O_ice_liq)then
+                  pdqsdif(ig,ivap)=pdqsdif(ig,ivap)-Wdiff
+               else
+                  pdqsdif(ig,iice)=pdqsdif(ig,iice)-Wdiff
+               endif
+            enddo
+
+         endif
+
+      endif 
+
+      if(water)then
+      call writediagfi(ngrid,'beta','Dryness coefficient',' ',2,dryness)
+      endif
+
+!      if(lastcall)then
+!        if(ngrid.eq.1)then
+!           print*,'Saving k.out...'
+!           OPEN(12,file='k.out',form='formatted')
+!           DO ilay=1,nlay
+!              write(12,*) zkh(1,ilay), pplay(1,ilay)
+!           ENDDO
+!           CLOSE(12)
+!         endif
+!      endif
+
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/vlz_fi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/vlz_fi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/vlz_fi.F	(revision 1644)
@@ -0,0 +1,190 @@
+      SUBROUTINE vlz_fi(ngrid,nlayer,q,pente_max,masse,w,wq)
+c
+c     Auteurs:   P.Le Van, F.Hourdin, F.Forget 
+c
+c    ********************************************************************
+c     Shema  d'advection " pseudo amont " dans la verticale
+c    pour appel dans la physique (sedimentation)
+c    ********************************************************************
+c    q rapport de melange (kg/kg)...
+c    masse : masse de la couche Dp/g
+c    w : masse d'atm ``transferee'' a chaque pas de temps (kg.m-2)
+c    pente_max = 2 conseillee
+c
+c
+c   --------------------------------------------------------------------
+      IMPLICIT NONE
+c
+c
+c   Arguments:
+c   ----------
+      integer,intent(in) :: ngrid, nlayer
+      real,intent(in) :: masse(ngrid,nlayer),pente_max
+      REAL,INTENT(INOUT) :: q(ngrid,nlayer)
+      REAL,INTENT(INOUT) :: w(ngrid,nlayer)
+      REAL,INTENT(OUT) :: wq(ngrid,nlayer+1)
+c
+c      Local 
+c   ---------
+c
+      INTEGER i,ij,l,j,ii
+c
+
+      real dzq(ngrid,nlayer),dzqw(ngrid,nlayer),adzqw(ngrid,nlayer)
+      real dzqmax
+      real newmasse
+      real sigw, Mtot, MQtot
+      integer m
+
+      REAL      SSUM,CVMGP,CVMGT
+      integer ismax,ismin
+
+
+c    On oriente tout dans le sens de la pression c'est a dire dans le
+c    sens de W
+
+      do l=2,nlayer
+         do ij=1,ngrid
+            dzqw(ij,l)=q(ij,l-1)-q(ij,l)
+            adzqw(ij,l)=abs(dzqw(ij,l))
+         enddo
+      enddo
+
+      do l=2,nlayer-1
+         do ij=1,ngrid
+#ifdef CRAY
+            dzq(ij,l)=0.5*
+     ,      cvmgp(dzqw(ij,l)+dzqw(ij,l+1),0.,dzqw(ij,l)*dzqw(ij,l+1))
+#else
+            if(dzqw(ij,l)*dzqw(ij,l+1).gt.0.) then
+                dzq(ij,l)=0.5*(dzqw(ij,l)+dzqw(ij,l+1))
+            else
+                dzq(ij,l)=0.
+            endif
+#endif
+            dzqmax=pente_max*min(adzqw(ij,l),adzqw(ij,l+1))
+            dzq(ij,l)=sign(min(abs(dzq(ij,l)),dzqmax),dzq(ij,l))
+         enddo
+      enddo
+
+      do ij=1,ngrid
+         dzq(ij,1)=0.
+         dzq(ij,nlayer)=0.
+      enddo
+c ---------------------------------------------------------------
+c   .... calcul des termes d'advection verticale  .......
+c ---------------------------------------------------------------
+
+c calcul de  - d( q   * w )/ d(sigma)    qu'on ajoute a  dq pour calculer dq
+c
+c      No flux at the model top:
+       do ij=1,ngrid
+          wq(ij,nlayer+1)=0.
+       enddo
+
+c      1) Compute wq where w > 0 (down) (ALWAYS FOR SEDIMENTATION)     
+c      ===============================
+
+       do l = 1,nlayer          ! loop different than when w<0
+        do ij=1,ngrid
+
+         if(w(ij,l).gt.0.)then
+
+c         Regular scheme (transfered mass < 1 layer)
+c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+          if(w(ij,l).le.masse(ij,l))then
+            sigw=w(ij,l)/masse(ij,l)
+            wq(ij,l)=w(ij,l)*(q(ij,l)+0.5*(1.-sigw)*dzq(ij,l))
+            
+
+c         Extended scheme (transfered mass > 1 layer)
+c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+          else 
+            m=l
+            Mtot = masse(ij,m)
+            MQtot = masse(ij,m)*q(ij,m)
+            if(m.ge.nlayer)goto 88
+            do while(w(ij,l).gt.(Mtot+masse(ij,m+1)))
+                m=m+1
+                Mtot = Mtot + masse(ij,m)
+                MQtot = MQtot + masse(ij,m)*q(ij,m)
+                if(m.ge.nlayer)goto 88
+            end do
+ 88         continue
+            if (m.lt.nlayer) then
+                sigw=(w(ij,l)-Mtot)/masse(ij,m+1)
+                wq(ij,l)=(MQtot + (w(ij,l)-Mtot)*
+     &          (q(ij,m+1)+0.5*(1.-sigw)*dzq(ij,m+1)) )
+            else
+                w(ij,l) = Mtot
+                wq(ij,l) = Mqtot 
+            end if
+          end if
+         end if
+        enddo
+       enddo
+
+c      2) Compute wq where w < 0 (up) (NOT USEFUL FOR SEDIMENTATION)     
+c      ===============================
+       goto 99 ! SKIPPING THIS PART FOR SEDIMENTATION 
+
+c      Surface flux up:
+       do ij=1,ngrid
+         if(w(ij,1).lt.0.) wq(ij,1)=0. ! warning : not always valid
+       end do
+
+       do l = 1,nlayer-1  ! loop different than when w>0
+        do ij=1,ngrid
+         if(w(ij,l+1).le.0)then
+
+c         Regular scheme (transfered mass < 1 layer)
+c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+          if(-w(ij,l+1).le.masse(ij,l))then
+            sigw=w(ij,l+1)/masse(ij,l)
+            wq(ij,l+1)=w(ij,l+1)*(q(ij,l)-0.5*(1.+sigw)*dzq(ij,l))
+c         Extended scheme (transfered mass > 1 layer)
+c         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+          else 
+             m = l-1
+             Mtot = masse(ij,m+1)
+             MQtot = masse(ij,m+1)*q(ij,m+1)
+             if (m.le.0)goto 77
+             do while(-w(ij,l+1).gt.(Mtot+masse(ij,m)))
+                m=m-1
+                Mtot = Mtot + masse(ij,m+1)
+                MQtot = MQtot + masse(ij,m+1)*q(ij,m+1)
+                if (m.le.0)goto 77
+             end do
+ 77          continue
+
+             if (m.gt.0) then
+                sigw=(w(ij,l+1)+Mtot)/masse(ij,m)
+                wq(ij,l+1)= (MQtot + (-w(ij,l+1)-Mtot)*
+     &          (q(ij,m)-0.5*(1.+sigw)*dzq(ij,m))  )
+             else
+c               wq(ij,l+1)= (MQtot + (-w(ij,l+1)-Mtot)*qm(ij,1))
+                write(*,*) 'a rather weird situation in vlz_fi !'
+                stop
+             end if
+          endif
+         endif
+        enddo
+       enddo
+ 99    continue
+
+      do l=1,nlayer
+         do ij=1,ngrid
+
+cccccccc lines below not used for sedimentation (No real flux)
+ccccc       newmasse=masse(ij,l)+w(ij,l+1)-w(ij,l) 
+ccccc       q(ij,l)=(q(ij,l)*masse(ij,l)+wq(ij,l+1)-wq(ij,l))
+ccccc&         /newmasse
+ccccc       masse(ij,l)=newmasse
+
+            q(ij,l)=q(ij,l) +  (wq(ij,l+1)-wq(ij,l))/masse(ij,l)
+
+         enddo
+      enddo
+
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/watercommon_h.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/watercommon_h.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/watercommon_h.F90	(revision 1644)
@@ -0,0 +1,289 @@
+module watercommon_h
+
+      implicit none
+
+      real, parameter :: T_coup = 234.0
+      real, parameter :: T_h2O_ice_liq = 273.16
+      real, parameter :: T_h2O_ice_clouds = T_h2O_ice_liq-15. 
+      real, parameter :: mH2O = 18.01528   
+
+      ! benjamin additions
+      real, parameter :: RLVTT = 2.257E+6 ! Latent heat of vaporization (J kg-1) 
+      real, parameter :: RLSTT = 2.257E+6 ! 2.591E+6 in reality ! Latent heat of sublimation (J kg-1)
+
+      real, parameter :: RLFTT = 3.334E+5 ! Latent heat of fusion (J kg-1) ! entails an energy sink but better description of albedo
+      real, parameter :: rhowater = 1.0E+3 ! mass of water (kg/m^3)
+      real, parameter :: rhowaterice = 9.2E+2 ! mass of water (kg/m^3)
+      real, parameter :: capcal_h2o_liq = 4181.3 ! specific heat capacity of liquid water J/kg/K
+      real, parameter :: mx_eau_sol = 150 ! mass of water (kg/m^2)
+
+      real, save :: epsi, RCPD, RCPV, RV, RVTMP2
+!$OMP THREADPRIVATE(epsi,RCPD,RCPV,RV,RVTMP2)
+      
+      contains
+
+      
+!==================================================================
+      subroutine Psat_water(T,p,psat,qsat)
+
+         implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the saturation vapor pressure and mass mixing ratio at saturation (kg/kg)
+!     for a given pressure (Pa) and temperature (K)
+!     Based on the Tetens formula from L.Li physical parametrization manual
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+
+!        input
+         real, intent(in) :: T, p
+  
+!        output
+         real psat,qsat
+
+! JL12 variables for tetens formula
+         real,parameter :: Pref_solid_liquid=611.14
+         real,parameter :: Trefvaporization=35.86
+         real,parameter :: Trefsublimation=7.66
+         real,parameter :: Tmin=8.
+         real,parameter :: r3vaporization=17.269
+         real,parameter :: r3sublimation=21.875
+
+! checked vs. old watersat data 14/05/2012 by JL.
+
+         if (T.gt.T_h2O_ice_liq) then 
+            psat = Pref_solid_liquid*Exp(r3vaporization*(T-T_h2O_ice_liq)/(T-Trefvaporization)) ! liquid / vapour
+         else if (T.lt.Tmin) then
+	    print*, "careful, T<Tmin in psat water"
+          !  psat = Pref_solid_liquid*Exp(r3sublimation*(Tmin-T_h2O_ice_liq)/(Tmin-Trefsublimation)) ! min psat  
+         ! Ehouarn: gfortran says: Error: Result of EXP underflows its kind,
+         !          so set psat to the smallest possible value instead
+            psat=tiny(psat)
+         else                 
+            psat = Pref_solid_liquid*Exp(r3sublimation*(T-T_h2O_ice_liq)/(T-Trefsublimation)) ! solid / vapour
+         endif
+         if(psat.gt.p) then
+            qsat=1.
+         else
+            qsat=epsi*psat/(p-(1.-epsi)*psat)
+         endif
+         return
+      end subroutine Psat_water
+
+
+
+
+!==================================================================
+      subroutine Lcpdqsat_water(T,p,psat,qsat,dqsat,dlnpsat)
+
+         implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute dqsat=L/cp*d (q_sat)/d T and dlnpsat=L/cp d(ln Psat)/d T
+!     for a given temperature (K)! 
+!     Based on the Tetens formula from L.Li physical parametrization manual
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+
+!        input
+         real T, p, psat, qsat
+  
+!        output
+         real dqsat,dlnpsat
+
+! JL12 variables for tetens formula
+         real,parameter :: Pref_solid_liquid=611.14
+         real,parameter :: Trefvaporization=35.86
+         real,parameter :: Tmin=8.
+         real,parameter :: Trefsublimation=7.66
+         real,parameter :: r3vaporization=17.269
+         real,parameter :: r3sublimation=21.875
+
+         real :: dummy
+
+         if (psat.gt.p) then
+	    dqsat=0.
+	    return
+	 endif
+
+         if (T.gt.T_h2O_ice_liq) then
+            dummy = r3vaporization*(T_h2O_ice_liq-Trefvaporization)/(T-Trefvaporization)**2  ! liquid / vapour
+         else if (T.lt.Tmin) then
+	    print*, "careful, T<Tmin in Lcp psat water"
+            dummy = r3sublimation*(T_h2O_ice_liq-Trefsublimation)/(Tmin-Trefsublimation)**2  ! solid / vapour
+         else               
+            dummy = r3sublimation*(T_h2O_ice_liq-Trefsublimation)/(T-Trefsublimation)**2  ! solid / vapour
+         endif
+
+         dqsat=RLVTT/RCPD*qsat*(p/(p-(1.-epsi)*psat))*dummy
+	 dlnpsat=RLVTT/RCPD*dummy
+         return
+      end subroutine Lcpdqsat_water
+
+
+
+
+!==================================================================
+      subroutine Tsat_water(p,Tsat)
+
+         implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the saturation temperature
+!     for a given pressure (Pa) 
+!     Based on the Tetens formula from L.Li physical parametrization manual
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+
+!        input
+         real p
+  
+!        output
+         real Tsat
+
+! JL12 variables for tetens formula
+         real,parameter :: Pref_solid_liquid=611.14
+         real,parameter :: Trefvaporization=35.86
+         real,parameter :: Trefsublimation=7.66
+         real,parameter :: r3vaporization=17.269
+         real,parameter :: r3sublimation=21.875
+
+         if (p.lt.Pref_solid_liquid) then ! solid / vapour
+            Tsat =(T_h2O_ice_liq*r3sublimation- Trefsublimation*Log(p/Pref_solid_liquid))/(r3sublimation-Log(p/Pref_solid_liquid))
+         else                 ! liquid / vapour
+            Tsat =(T_h2O_ice_liq*r3vaporization- Trefvaporization*Log(p/Pref_solid_liquid))/(r3vaporization-Log(p/Pref_solid_liquid))
+         endif
+
+         return
+      end subroutine Tsat_water
+
+!==================================================================
+      subroutine Psat_waterDP(T,p,psat,qsat)
+
+         implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the saturation vapor pressure and mass mixing ratio at saturation (kg/kg)
+!     for a given pressure (Pa) and temperature (K)
+!     DOUBLE PRECISION
+!     Based on the Tetens formula from L.Li physical parametrization manual
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+
+!        input
+         double precision, intent(in) :: T, p
+  
+!        output
+         double precision psat,qsat
+
+! JL12 variables for tetens formula
+         double precision,parameter :: Pref_solid_liquid=611.14d0
+         double precision,parameter :: Trefvaporization=35.86D0
+         double precision,parameter :: Trefsublimation=7.66d0
+         double precision,parameter :: Tmin=8.d0
+         double precision,parameter :: r3vaporization=17.269d0
+         double precision,parameter :: r3sublimation=21.875d0
+
+! checked vs. old watersat data 14/05/2012 by JL.
+
+         if (T.gt.T_h2O_ice_liq) then 
+            psat = Pref_solid_liquid*Exp(r3vaporization*(T-T_h2O_ice_liq)/(T-Trefvaporization)) ! liquid / vapour
+         else if (T.lt.Tmin) then
+	    print*, "careful, T<Tmin in psat water"
+         !   psat = Pref_solid_liquid*Exp(r3sublimation*(Tmin-T_h2O_ice_liq)/(Tmin-Trefsublimation)) ! min psat  
+         ! Ehouarn: gfortran says: Error: Result of EXP underflows its kind,
+         !          so set psat to the smallest possible value instead
+            psat=tiny(psat)
+         else                 
+            psat = Pref_solid_liquid*Exp(r3sublimation*(T-T_h2O_ice_liq)/(T-Trefsublimation)) ! solid / vapour
+         endif
+         if(psat.gt.p) then
+            qsat=1.d0
+         else
+            qsat=epsi*psat/(p-(1.d0-epsi)*psat)
+         endif
+         return
+      end subroutine Psat_waterDP
+
+
+
+
+!==================================================================
+      subroutine Lcpdqsat_waterDP(T,p,psat,qsat,dqsat,dlnpsat)
+
+         implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute dqsat=L/cp*d (q_sat)/d T and dlnpsat=L/cp d(ln Psat)/d T
+!     for a given temperature (K)! 
+!     Based on the Tetens formula from L.Li physical parametrization manual
+!
+!     Authors
+!     -------
+!     Jeremy Leconte (2012)
+!
+!==================================================================
+
+!        input
+         double precision T, p, psat, qsat
+  
+!        output
+         double precision dqsat,dlnpsat
+
+! JL12 variables for tetens formula
+         double precision,parameter :: Pref_solid_liquid=611.14d0
+         double precision,parameter :: Trefvaporization=35.86d0
+         double precision,parameter :: Tmin=8.d0
+         double precision,parameter :: Trefsublimation=7.66d0
+         double precision,parameter :: r3vaporization=17.269d0
+         double precision,parameter :: r3sublimation=21.875d0
+
+         double precision :: dummy
+
+         if (psat.gt.p) then
+	    dqsat=0.d0
+	    return
+	 endif
+
+         if (T.gt.T_h2O_ice_liq) then
+            dummy = r3vaporization*(T_h2O_ice_liq-Trefvaporization)/(T-Trefvaporization)**2  ! liquid / vapour
+         else if (T.lt.Tmin) then
+	    print*, "careful, T<Tmin in Lcp psat water"
+            dummy = r3sublimation*(T_h2O_ice_liq-Trefsublimation)/(Tmin-Trefsublimation)**2  ! solid / vapour
+         else               
+            dummy = r3sublimation*(T_h2O_ice_liq-Trefsublimation)/(T-Trefsublimation)**2  ! solid / vapour
+         endif
+
+         dqsat=RLVTT/RCPD*qsat*(p/(p-(1.d0-epsi)*psat))*dummy
+	 dlnpsat=RLVTT/RCPD*dummy
+         return
+      end subroutine Lcpdqsat_waterDP
+
+
+end module watercommon_h
Index: /trunk/LMDZ.TITAN/libf/phytitan/watersat.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/watersat.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/watersat.F90	(revision 1644)
@@ -0,0 +1,45 @@
+subroutine watersat(T,p,qsat)
+
+  use watercommon_h, only: T_h2O_ice_liq, epsi
+  implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the water mass mixing ratio at saturation (kg/kg)
+!     for a given pressure (Pa) and temperature (K)
+!     A replacement for the old watersat.F in the Martian GCM.
+!     Based on FCTTRE.h in the LMDTERRE model.
+!
+!     Authors
+!     -------
+!     Robin Wordsworth (2010)
+!
+!==================================================================
+
+!   input
+  real T, p
+  
+!   output
+  real qsat
+
+! checked vs. NIST data 22/06/2010 by RW.
+! / by p gives partial pressure
+! x by epsi converts to mass mixing ratio
+
+  if (T.lt.T_h2O_ice_liq) then ! solid / vapour
+     qsat = 100.0 * 10**(2.07023 - 0.00320991             &
+          * T - 2484.896 / T + 3.56654 * alog10(T))
+  else                 ! liquid / vapour
+     qsat = 100.0 * 10**(23.8319 - 2948.964 / T - 5.028  &
+          * alog10(T) - 29810.16 * exp( -0.0699382 * T)  &
+          + 25.21935 * exp(-2999.924/T))
+  endif
+!  qsat=epsi*qsat/p
+  if(qsat.gt.p) then
+     qsat=1.
+  else
+     qsat=epsi*qsat/(p-(1.-epsi)*qsat)
+  endif
+  return
+end subroutine watersat
Index: /trunk/LMDZ.TITAN/libf/phytitan/watersat_grad.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/watersat_grad.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/watersat_grad.F90	(revision 1644)
@@ -0,0 +1,38 @@
+subroutine watersat_grad(T,qsat,dqsat)
+
+  use watercommon_h, only: T_h2O_ice_liq, RLVTT, RCPD,T_coup
+  implicit none
+
+!==================================================================
+!     Purpose
+!     -------
+!     Compute the L/cp*d (q_sat)/d T
+!     for a given temperature (K)
+!
+!     Authors
+!     -------
+!     Robin Wordsworth (2010)
+!
+!==================================================================
+
+!   input
+  real T,qsat
+  
+!   output
+  real dqsat
+
+!  if (T.lt.T_coup) then ! solid / vapour !why use T_coup?????????? JL12
+  if (T.lt.T_h2O_ice_liq) then ! solid / vapour
+     dqsat = RLVTT/RCPD*qsat*(3.56654/T             &
+          +2484.896*LOG(10.)/T**2                   &
+          -0.00320991*LOG(10.))
+  else                 ! liquid / vapour
+     dqsat = RLVTT/RCPD*qsat*LOG(10.)*              &
+          (2948.964/T**2-5.028/LOG(10.)/T           &
+          +25.21935*2999.924/T**2*EXP(-2999.924/T)  &
+          +29810.16*0.0699382*EXP(-0.0699382*T))
+  end if
+
+  return
+end subroutine watersat_grad
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/writediagfi.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/writediagfi.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/writediagfi.F	(revision 1644)
@@ -0,0 +1,588 @@
+      subroutine writediagfi(ngrid,nom,titre,unite,dim,px)
+
+!  Ecriture de variables diagnostiques au choix dans la physique 
+!  dans un fichier NetCDF nomme  'diagfi'. Ces variables peuvent etre
+!  3d (ex : temperature), 2d (ex : temperature de surface), ou
+!  0d (pour un scalaire qui ne depend que du temps : ex : la longitude
+!  solaire)
+!  (ou encore 1d, dans le cas de testphys1d, pour sortir une colonne)
+!  La periode d'ecriture est donnee par 
+!  "ecritphy " regle dans le fichier de controle de run :  run.def
+!
+!    writediagfi peut etre appele de n'importe quelle subroutine
+!    de la physique, plusieurs fois. L'initialisation et la creation du
+!    fichier se fait au tout premier appel.
+!
+! WARNING : les variables dynamique (u,v,t,q,ps)
+!  sauvees par writediagfi avec une
+! date donnee sont legerement differentes que dans le fichier histoire car 
+! on ne leur a pas encore ajoute de la dissipation et de la physique !!!
+! IL est  RECOMMANDE d'ajouter les tendance physique a ces variables
+! avant l'ecriture dans diagfi (cf. physiq.F)
+!  
+! Modifs: Aug.2010 Ehouarn: enforce outputs to be real*4
+!         Oct 2011 Francois: enable having a 'diagfi.def' file to select
+!                            at runtime, which variables to put in file
+!
+!  parametres (input) :
+!  ----------
+!      ngrid : nombres de point ou est calcule la physique
+!                (ngrid = 2+(jjm-1)*iim - 1/jjm)
+!                 (= nlon ou klon dans la physique terrestre)
+!      
+!      unit : unite logique du fichier de sortie (toujours la meme)
+!      nom  : nom de la variable a sortir (chaine de caracteres)
+!      titre: titre de la variable (chaine de caracteres)
+!      unite : unite de la variable (chaine de caracteres)
+!      px : variable a sortir (real 0, 1, 2, ou 3d)
+!      dim : dimension de px : 0, 1, 2, ou 3 dimensions
+!
+!=================================================================
+      use surfdat_h, only: phisfi
+      use geometry_mod, only: cell_area
+      use time_phylmdz_mod, only: ecritphy, day_step, iphysiq, day_ini
+      USE mod_phys_lmdz_para, only : is_parallel, is_mpi_root,
+     &                               is_master, gather
+      USE mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo,
+     &                              nbp_lon, nbp_lat, nbp_lev
+      implicit none
+
+! Commons
+      include "netcdf.inc"
+
+! Arguments on input:
+      integer,intent(in) :: ngrid
+      character (len=*),intent(in) :: nom,titre,unite
+      integer,intent(in) :: dim
+      real,intent(in) :: px(ngrid,nbp_lev)
+
+! Local variables:
+
+      real*4 dx3(nbp_lon+1,nbp_lat,nbp_lev) ! to store a 3D data set
+      real*4 dx2(nbp_lon+1,nbp_lat)     ! to store a 2D (surface) data set
+      real*4 dx1(nbp_lev)           ! to store a 1D (column) data set
+      real*4 dx0
+      real*4 dx3_1d(1,nbp_lev) ! to store a profile with 1D model
+      real*4 dx2_1d ! to store a surface value with 1D model
+
+      real*4,save :: date
+!$OMP THREADPRIVATE(date)
+
+      REAL phis((nbp_lon+1),nbp_lat)
+      REAL area((nbp_lon+1),nbp_lat)
+
+      integer irythme
+      integer ierr,ierr2
+      integer i,j,l, ig0
+
+      integer,save :: zitau=0
+      character(len=20),save :: firstnom='1234567890'
+!$OMP THREADPRIVATE(zitau,firstnom)
+
+! Ajouts
+      integer, save :: ntime=0
+!$OMP THREADPRIVATE(ntime)
+      integer :: idim,varid
+      integer :: nid
+      character(len=*),parameter :: fichnom="diagfi.nc"
+      integer, dimension(4) :: id
+      integer, dimension(4) :: edges,corner
+
+! Added to use diagfi.def to select output variable
+      logical,save :: diagfi_def
+      logical :: getout
+      integer,save :: n_nom_def
+      integer :: n
+      integer,parameter :: n_nom_def_max=199
+      character(len=120),save :: nom_def(n_nom_def_max)
+      logical,save :: firstcall=.true.
+!$OMP THREADPRIVATE(firstcall) 	!diagfi_def,n_nom_def,nom_def read in diagfi.def
+      
+#ifndef MESOSCALE
+
+#ifdef CPP_PARA
+! Added to work in parallel mode
+      real dx3_glop(klon_glo,nbp_lev)
+      real dx3_glo(nbp_lon,nbp_lat,nbp_lev) ! to store a global 3D data set
+      real dx2_glop(klon_glo)
+      real dx2_glo(nbp_lon,nbp_lat)     ! to store a global 2D (surface) data set
+      real px2(ngrid)
+!      real dx1_glo(nbp_lev)          ! to store a 1D (column) data set
+!      real dx0_glo
+      real phisfi_glo(klon_glo) ! surface geopotential on global physics grid
+      real areafi_glo(klon_glo) ! mesh area on global physics grid
+#else
+      real phisfi_glo(ngrid) ! surface geopotential on global physics grid
+      real areafi_glo(ngrid) ! mesh area on global physics grid
+#endif
+
+!***************************************************************
+!Sortie des variables au rythme voulu
+
+      irythme = int(ecritphy) ! output rate set by ecritphy
+
+!***************************************************************
+
+! At very first call, check if there is a "diagfi.def" to use and read it
+! -----------------------------------------------------------------------
+      IF (firstcall) THEN
+         firstcall=.false.
+
+!$OMP MASTER
+  !      Open diagfi.def definition file if there is one:
+         open(99,file="diagfi.def",status='old',form='formatted',
+     s   iostat=ierr2)
+
+         if(ierr2.eq.0) then
+            diagfi_def=.true.
+            write(*,*) "******************"
+            write(*,*) "Reading diagfi.def"
+            write(*,*) "******************"
+            do n=1,n_nom_def_max
+              read(99,fmt='(a)',end=88) nom_def(n)
+              write(*,*) 'Output in diagfi: ', trim(nom_def(n))
+            end do 
+ 88         continue
+            if (n.ge.n_nom_def_max) then
+               write(*,*)"n_nom_def_max too small in writediagfi.F:",n
+               stop
+            end if 
+            n_nom_def=n-1
+            close(99)
+         else
+            diagfi_def=.false.
+         endif
+!$OMP END MASTER
+!$OMP BARRIER
+      END IF ! of IF (firstcall)
+
+! Get out of write_diagfi if there is diagfi.def AND variable not listed
+!  ---------------------------------------------------------------------
+      if (diagfi_def) then
+          getout=.true.
+          do n=1,n_nom_def
+             if(trim(nom_def(n)).eq.nom) getout=.false.
+          end do
+          if (getout) return
+      end if
+
+! Initialisation of 'firstnom' and create/open the "diagfi.nc" NetCDF file
+! ------------------------------------------------------------------------
+! (at very first call to the subroutine, in accordance with diagfi.def)
+
+      if (firstnom.eq.'1234567890') then ! .true. for the very first valid
+      !   call to this subroutine; now set 'firstnom'
+         firstnom = nom
+         ! just to be sure, check that firstnom is large enough to hold nom
+         if (len_trim(firstnom).lt.len_trim(nom)) then
+           write(*,*) "writediagfi: Error !!!"
+           write(*,*) "   firstnom string not long enough!!"
+           write(*,*) "   increase its size to at least ",len_trim(nom)
+           stop
+         endif
+         
+         zitau = -1 ! initialize zitau
+
+#ifdef CPP_PARA
+          ! Gather phisfi() geopotential on physics grid
+          call Gather(phisfi,phisfi_glo)
+          ! Gather cell_area() mesh area on physics grid
+          call Gather(cell_area,areafi_glo)
+#else
+         phisfi_glo(:)=phisfi(:)
+         areafi_glo(:)=cell_area(:)
+#endif
+
+         !! parallel: we cannot use the usual writediagfi method
+!!         call iophys_ini
+         if (is_master) then
+         ! only the master is required to do this
+
+         ! Create the NetCDF file
+         ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
+         ! Define the 'Time' dimension
+         ierr = nf_def_dim(nid,"Time",NF_UNLIMITED,idim)
+         ! Define the 'Time' variable
+!#ifdef NC_DOUBLE
+!         ierr = NF_DEF_VAR (nid, "Time", NF_DOUBLE, 1, idim,varid)
+!#else
+         ierr = NF_DEF_VAR (nid, "Time", NF_FLOAT, 1, idim,varid)
+!#endif
+         ! Add a long_name attribute
+         ierr = NF_PUT_ATT_TEXT (nid, varid, "long_name",
+     .          4,"Time")
+         ! Add a units attribute
+         ierr = NF_PUT_ATT_TEXT(nid, varid,'units',29,
+     .          "days since 0000-00-0 00:00:00")
+         ! Switch out of NetCDF Define mode
+         ierr = NF_ENDDEF(nid)
+
+         ! Build phis() and area()
+         IF (klon_glo>1) THEN
+          do i=1,nbp_lon+1 ! poles
+           phis(i,1)=phisfi_glo(1)
+           phis(i,nbp_lat)=phisfi_glo(klon_glo)
+           ! for area, divide at the poles by nbp_lon
+           area(i,1)=areafi_glo(1)/nbp_lon
+           area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
+          enddo
+          do j=2,nbp_lat-1
+           ig0= 1+(j-2)*nbp_lon
+           do i=1,nbp_lon
+              phis(i,j)=phisfi_glo(ig0+i)
+              area(i,j)=areafi_glo(ig0+i)
+           enddo
+           ! handle redundant point in longitude
+           phis(nbp_lon+1,j)=phis(1,j)
+           area(nbp_lon+1,j)=area(1,j)
+          enddo
+         ENDIF
+         
+         ! write "header" of file (longitudes, latitudes, geopotential, ...)
+         IF (klon_glo>1) THEN ! general 3D case
+           call iniwrite(nid,day_ini,phis,area,nbp_lon+1,nbp_lat)
+         ELSE ! 1D model
+           call iniwrite(nid,day_ini,phisfi_glo(1),areafi_glo(1),1,1)
+         ENDIF
+
+         endif ! of if (is_master)
+
+      else
+
+         if (is_master) then
+           ! only the master is required to do this
+
+           ! Open the NetCDF file
+           ierr = NF_OPEN(fichnom,NF_WRITE,nid)
+         endif ! of if (is_master)
+
+      endif ! if (firstnom.eq.'1234567890')
+
+! Increment time index 'zitau' if it is the "fist call" (at given time level)
+! to writediagfi
+!------------------------------------------------------------------------
+      if (nom.eq.firstnom) then
+          zitau = zitau + iphysiq
+      end if
+
+!--------------------------------------------------------
+! Write the variables to output file if it's time to do so
+!--------------------------------------------------------
+
+      if ( MOD(zitau+1,irythme) .eq.0.) then
+
+! Compute/write/extend 'Time' coordinate (date given in days)
+! (done every "first call" (at given time level) to writediagfi)
+! Note: date is incremented as 1 step ahead of physics time
+!--------------------------------------------------------
+
+        if (is_master) then
+           ! only the master is required to do this
+        if (nom.eq.firstnom) then
+        ! We have identified a "first call" (at given date)
+           ntime=ntime+1 ! increment # of stored time steps
+           ! compute corresponding date (in days and fractions thereof)
+           date= float (zitau +1)/float (day_step)
+           ! Get NetCDF ID of 'Time' variable
+           ierr= NF_INQ_VARID(nid,"Time",varid)
+           ! Write (append) the new date to the 'Time' array
+!#ifdef NC_DOUBLE
+!           ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
+!#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
+!#endif
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in writediagfi_nc"
+              write(*,*) "***** with time"
+              write(*,*) 'ierr=', ierr   
+c             call abort
+           endif
+
+           write(6,*)'WRITEDIAGFI: date= ', date
+        end if ! of if (nom.eq.firstnom)
+
+        endif ! of if (is_master)
+
+!Case of a 3D variable
+!---------------------
+        if (dim.eq.3) then
+
+#ifdef CPP_PARA
+          ! Gather field on a "global" (without redundant longitude) array
+          call Gather(px,dx3_glop)
+!$OMP MASTER
+          if (is_mpi_root) then
+            call Grid1Dto2D_glo(dx3_glop,dx3_glo)
+            ! copy dx3_glo() to dx3(:) and add redundant longitude
+            dx3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
+            dx3(nbp_lon+1,:,:)=dx3(1,:,:)
+          endif
+!$OMP END MASTER
+!$OMP BARRIER
+#else
+!         Passage variable physique -->  variable dynamique
+!         recast (copy) variable from physics grid to dynamics grid
+          IF (klon_glo>1) THEN ! General case
+           DO l=1,nbp_lev
+             DO i=1,nbp_lon+1
+                dx3(i,1,l)=px(1,l)
+                dx3(i,nbp_lat,l)=px(ngrid,l)
+             ENDDO
+             DO j=2,nbp_lat-1
+                ig0= 1+(j-2)*nbp_lon
+                DO i=1,nbp_lon
+                   dx3(i,j,l)=px(ig0+i,l)
+                ENDDO
+                dx3(nbp_lon+1,j,l)=dx3(1,j,l)
+             ENDDO
+           ENDDO
+          ELSE ! 1D model case
+           dx3_1d(1,1:nbp_lev)=px(1,1:nbp_lev)
+          ENDIF
+#endif
+!         Ecriture du champs
+
+          if (is_master) then
+           ! only the master writes to output
+! name of the variable
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! corresponding dimensions
+              ierr= NF_INQ_DIMID(nid,"longitude",id(1))
+              ierr= NF_INQ_DIMID(nid,"latitude",id(2))
+              ierr= NF_INQ_DIMID(nid,"altitude",id(3))
+              ierr= NF_INQ_DIMID(nid,"Time",id(4))
+
+! Create the variable if it doesn't exist yet
+
+              write (*,*) "=========================="
+              write (*,*) "DIAGFI: creating variable ",nom
+              call def_var(nid,nom,titre,unite,4,id,varid,ierr)
+
+           endif 
+
+           corner(1)=1
+           corner(2)=1
+           corner(3)=1
+           corner(4)=ntime
+
+           IF (klon_glo==1) THEN
+             edges(1)=1
+           ELSE
+             edges(1)=nbp_lon+1
+           ENDIF
+           edges(2)=nbp_lat
+           edges(3)=nbp_lev
+           edges(4)=1
+!#ifdef NC_DOUBLE
+!           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3)
+!#else
+!           write(*,*)"test:  nid=",nid," varid=",varid
+!           write(*,*)"       corner()=",corner
+!           write(*,*)"       edges()=",edges
+!           write(*,*)"       dx3()=",dx3
+           IF (klon_glo>1) THEN ! General case
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3)
+           ELSE
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3_1d)
+           ENDIF
+!#endif
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR problem in writediagfi"
+              write(*,*) "***** with dx3: ",nom
+              write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr)
+              stop
+           endif 
+
+          endif !of if (is_master)
+
+!Case of a 2D variable
+!---------------------
+
+        else if (dim.eq.2) then
+
+#ifdef CPP_PARA
+          ! Gather field on a "global" (without redundant longitude) array
+          px2(:)=px(:,1)
+          call Gather(px2,dx2_glop)
+!$OMP MASTER
+          if (is_mpi_root) then
+            call Grid1Dto2D_glo(dx2_glop,dx2_glo)
+            ! copy dx2_glo() to dx2(:) and add redundant longitude
+            dx2(1:nbp_lon,:)=dx2_glo(1:nbp_lon,:)
+            dx2(nbp_lon+1,:)=dx2(1,:)
+          endif
+!$OMP END MASTER
+!$OMP BARRIER
+#else
+
+!         Passage variable physique -->  physique dynamique
+!         recast (copy) variable from physics grid to dynamics grid
+          IF (klon_glo>1) THEN ! General case
+             DO i=1,nbp_lon+1
+                dx2(i,1)=px(1,1)
+                dx2(i,nbp_lat)=px(ngrid,1)
+             ENDDO
+             DO j=2,nbp_lat-1
+                ig0= 1+(j-2)*nbp_lon
+                DO i=1,nbp_lon
+                   dx2(i,j)=px(ig0+i,1)
+                ENDDO
+                dx2(nbp_lon+1,j)=dx2(1,j)
+             ENDDO
+          ELSE ! 1D model case
+            dx2_1d=px(1,1)
+          ENDIF
+#endif
+
+          if (is_master) then
+           ! only the master writes to output
+!         write (*,*) 'In  writediagfi, on sauve:  ' , nom
+!         write (*,*) 'In  writediagfi. Estimated date = ' ,date
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! corresponding dimensions
+              ierr= NF_INQ_DIMID(nid,"longitude",id(1))
+              ierr= NF_INQ_DIMID(nid,"latitude",id(2))
+              ierr= NF_INQ_DIMID(nid,"Time",id(3))
+
+! Create the variable if it doesn't exist yet
+
+              write (*,*) "=========================="
+              write (*,*) "DIAGFI: creating variable ",nom
+
+              call def_var(nid,nom,titre,unite,3,id,varid,ierr)
+
+           endif
+
+           corner(1)=1
+           corner(2)=1
+           corner(3)=ntime
+           IF (klon_glo==1) THEN
+             edges(1)=1
+           ELSE
+             edges(1)=nbp_lon+1
+           ENDIF
+           edges(2)=nbp_lat
+           edges(3)=1
+
+
+!#ifdef NC_DOUBLE
+!           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,dx2) 
+!#else         
+           IF (klon_glo>1) THEN ! General case
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx2)
+           ELSE
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx2_1d)
+           ENDIF
+!#endif     
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in writediagfi"
+              write(*,*) "***** with dx2: ",nom
+              write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr)
+              stop
+           endif 
+
+          endif !of if (is_master)
+
+!Case of a 1D variable (ie: a column)
+!---------------------------------------------------
+
+       else if (dim.eq.1) then
+         if (is_parallel) then
+           write(*,*) "writediagfi error: dim=1 not implemented ",
+     &                 "in parallel mode"
+           stop
+         endif
+!         Passage variable physique -->  physique dynamique
+!         recast (copy) variable from physics grid to dynamics grid
+          do l=1,nbp_lev
+            dx1(l)=px(1,l)
+          enddo
+          
+          ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! corresponding dimensions
+              ierr= NF_INQ_DIMID(nid,"altitude",id(1))
+              ierr= NF_INQ_DIMID(nid,"Time",id(2))
+
+! Create the variable if it doesn't exist yet
+
+              write (*,*) "=========================="
+              write (*,*) "DIAGFI: creating variable ",nom
+
+              call def_var(nid,nom,titre,unite,2,id,varid,ierr)
+              
+           endif
+           
+           corner(1)=1
+           corner(2)=ntime
+           
+           edges(1)=nbp_lev
+           edges(2)=1
+!#ifdef NC_DOUBLE
+!           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx1)
+!#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx1)
+!#endif
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR problem in writediagfi"
+              write(*,*) "***** with dx1: ",nom
+              write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr)
+              stop
+           endif 
+
+!Case of a 0D variable (ie: a time-dependent scalar)
+!---------------------------------------------------
+
+        else if (dim.eq.0) then
+
+           dx0 = px (1,1)
+
+          if (is_master) then
+           ! only the master writes to output
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! corresponding dimensions
+              ierr= NF_INQ_DIMID(nid,"Time",id(1))
+
+! Create the variable if it doesn't exist yet
+
+              write (*,*) "=========================="
+              write (*,*) "DIAGFI: creating variable ",nom
+
+              call def_var(nid,nom,titre,unite,1,id,varid,ierr)
+
+           endif
+
+           corner(1)=ntime
+           edges(1)=1
+
+!#ifdef NC_DOUBLE
+!           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,dx0)  
+!#else
+           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx0)
+!#endif
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in writediagfi"
+              write(*,*) "***** with dx0: ",nom
+              write(*,*) 'ierr=', ierr,": ",NF_STRERROR(ierr)
+              stop
+           endif 
+
+          endif !of if (is_master)
+
+        endif ! of if (dim.eq.3) elseif(dim.eq.2)...
+
+      endif ! of if ( MOD(zitau+1,irythme) .eq.0.)
+
+      if (is_master) then
+        ierr= NF_CLOSE(nid)
+      endif
+
+#endif
+! of #ifndef MESOSCALE
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/writediagsoil.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/writediagsoil.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/writediagsoil.F90	(revision 1644)
@@ -0,0 +1,397 @@
+subroutine writediagsoil(ngrid,name,title,units,dimpx,px)
+
+! Write variable 'name' to NetCDF file 'diagsoil.nc'.
+! The variable may be 3D (lon,lat,depth) subterranean field,
+! a 2D (lon,lat) surface field, or a simple scalar (0D variable).
+!
+! Calls to 'writediagsoil' can originate from anywhere in the program;
+! An initialisation of variable 'name' is done if it is the first time
+! that this routine is called with given 'name'; otherwise data is appended
+! (yielding the sought time series of the variable)
+
+! Modifs: Aug.2010 Ehouarn: enforce outputs to be real*4
+
+use comsoil_h, only: nsoilmx, inertiedat
+use geometry_mod, only: cell_area
+use time_phylmdz_mod, only: ecritphy, day_step, iphysiq
+use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
+use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo, &
+                              nbp_lon, nbp_lat
+
+implicit none
+
+include"netcdf.inc"
+
+! Arguments:
+integer,intent(in) :: ngrid ! number of (horizontal) points of physics grid
+! i.e. ngrid = 2+(jjm-1)*iim - 1/jjm
+character(len=*),intent(in) :: name ! 'name' of the variable
+character(len=*),intent(in) :: title ! 'long_name' attribute of the variable
+character(len=*),intent(in) :: units ! 'units' attribute of the variable
+integer,intent(in) :: dimpx ! dimension of the variable (3,2 or 0)
+real,dimension(ngrid,nsoilmx),intent(in) :: px ! variable
+
+! Local variables:
+real*4,dimension(nbp_lon+1,nbp_lat,nsoilmx) :: data3 ! to store 3D data
+real*4,dimension(nbp_lon+1,nbp_lat) :: data2 ! to store 2D data
+real*4 :: data0 ! to store 0D data
+real*4 :: data3_1d(1,nsoilmx) ! to store a profile in 1D model
+real*4 :: data2_1d ! to store surface value with 1D model
+integer :: i,j,l ! for loops
+integer :: ig0
+
+real*4,save :: date ! time counter (in elapsed days)
+
+real :: inertia((nbp_lon+1),nbp_lat,nsoilmx)
+real :: area((nbp_lon+1),nbp_lat)
+
+real :: inertiafi_glo(klon_glo,nsoilmx)
+real :: areafi_glo(klon_glo)
+
+integer,save :: isample ! sample rate at which data is to be written to output
+integer,save :: ntime=0 ! counter to internally store time steps
+character(len=20),save :: firstname="1234567890"
+integer,save :: zitau=0
+!$OMP THREADPRIVATE(date,isample,ntime,firstname,zitau)
+
+character(len=30) :: filename="diagsoil.nc"
+
+! NetCDF stuff:
+integer :: nid ! NetCDF output file ID
+integer :: varid ! NetCDF ID of a variable
+integer :: ierr ! NetCDF routines return code
+integer,dimension(4) :: id ! NetCDF IDs of the dimensions of the variable
+integer,dimension(4) :: edges,corners
+
+#ifdef CPP_PARA
+! Added to work in parallel mode
+real dx3_glop(klon_glo,nsoilmx)
+real dx3_glo(nbp_lon,nbp_lat,nsoilmx) ! to store a global 3D data set
+real dx2_glop(klon_glo)
+real dx2_glo(nbp_lon,nbp_lat)     ! to store a global 2D (surface) data set
+real px2(ngrid)
+#endif
+
+! 1. Initialization step
+if (firstname.eq."1234567890") then
+  ! Store 'name' as 'firstname'
+  firstname=name
+  ! From now on, if 'name'.eq.'firstname', then it is a new time cycle
+
+  ! just to be sure, check that firstnom is large enough to hold nom
+  if (len_trim(firstname).lt.len_trim(name)) then
+    write(*,*) "writediagsoil: Error !!!"
+    write(*,*) "   firstname string not long enough!!"
+    write(*,*) "   increase its size to at least ",len_trim(name)
+    stop
+  endif
+  
+  ! Set output sample rate
+  isample=int(ecritphy) ! same as for diagfi outputs
+  ! Note ecritphy is known from control.h
+  
+  ! Create output NetCDF file
+  if (is_master) then
+   ierr=NF_CREATE(filename,NF_CLOBBER,nid)
+   if (ierr.ne.NF_NOERR) then
+    write(*,*)'writediagsoil: Error, failed creating file '//trim(filename)
+    stop
+   endif
+
+#ifdef CPP_PARA
+   ! Gather inertiedat() soil thermal inertia on physics grid
+   call Gather(inertiedat,inertiafi_glo)
+   ! Gather cell_area() mesh area on physics grid
+   call Gather(cell_area,areafi_glo)
+#else
+         inertiafi_glo(:,:)=inertiedat(:,:)
+         areafi_glo(:)=cell_area(:)
+#endif
+
+   ! build inertia() and area()
+   if (klon_glo>1) then
+    do i=1,nbp_lon+1 ! poles
+     inertia(i,1,1:nsoilmx)=inertiafi_glo(1,1:nsoilmx)
+     inertia(i,nbp_lat,1:nsoilmx)=inertiafi_glo(klon_glo,1:nsoilmx)
+     ! for area, divide at the poles by nbp_lon
+     area(i,1)=areafi_glo(1)/nbp_lon
+     area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
+    enddo
+    do j=2,nbp_lat-1
+     ig0= 1+(j-2)*nbp_lon
+     do i=1,nbp_lon
+        inertia(i,j,1:nsoilmx)=inertiafi_glo(ig0+i,1:nsoilmx)
+        area(i,j)=areafi_glo(ig0+i)
+     enddo
+     ! handle redundant point in longitude
+     inertia(nbp_lon+1,j,1:nsoilmx)=inertia(1,j,1:nsoilmx)
+     area(nbp_lon+1,j)=area(1,j)
+    enddo
+   endif
+   
+   ! write "header" of file (longitudes, latitudes, geopotential, ...)
+   if (klon_glo>1) then ! general 3D case
+     call iniwritesoil(nid,ngrid,inertia,area,nbp_lon+1,nbp_lat)
+   else ! 1D model
+     call iniwritesoil(nid,ngrid,inertiafi_glo(1,:),areafi_glo(1),1,1)
+   endif
+
+  endif ! of if (is_master)
+  
+  ! set zitau to -1 to be compatible with zitau incrementation step below
+  zitau=-1
+  
+else
+  ! If not an initialization call, simply open the NetCDF file
+  if (is_master) then
+   ierr=NF_OPEN(filename,NF_WRITE,nid)
+  endif
+endif ! of if (firstname.eq."1234567890")
+
+! 2. Increment local time counter, if necessary
+if (name.eq.firstname) then
+  ! if we run across 'firstname', then it is a new time step
+  zitau=zitau+iphysiq
+  ! Note iphysiq is known from control.h
+endif
+
+! 3. Write data, if the time index matches the sample rate
+if (mod(zitau+1,isample).eq.0) then
+
+! 3.1 If first call at this date, update 'time' variable
+  if (name.eq.firstname) then
+    ntime=ntime+1
+    date=float(zitau+1)/float(day_step)
+    ! Note: day_step is known from control.h
+    
+    if (is_master) then
+     ! Get NetCDF ID for "time"
+     ierr=NF_INQ_VARID(nid,"time",varid)
+     ! Add the current value of date to the "time" array
+!#ifdef NC_DOUBLE
+!     ierr=NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
+!#else
+     ierr=NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
+!#endif
+     if (ierr.ne.NF_NOERR) then
+      write(*,*)"writediagsoil: Failed writing date to time variable"
+      stop 
+     endif
+    endif ! of if (is_master)
+  endif ! of if (name.eq.firstname)
+
+! 3.2 Write the variable to the NetCDF file
+if (dimpx.eq.3) then ! Case of a 3D variable
+  ! A. Recast data along 'dynamics' grid
+#ifdef CPP_PARA
+  ! gather field on a "global" (without redundant longitude) array
+  call Gather(px,dx3_glop)
+!$OMP MASTER
+  if (is_mpi_root) then
+    call Grid1Dto2D_glo(dx3_glop,dx3_glo)
+    ! copy dx3_glo() to dx3(:) and add redundant longitude
+    data3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
+    data3(nbp_lon+1,:,:)=data3(1,:,:)
+  endif
+!$OMP END MASTER
+!$OMP BARRIER
+#else
+  if (klon_glo>1) then ! General case
+   do l=1,nsoilmx
+    ! handle the poles
+    do i=1,nbp_lon+1
+      data3(i,1,l)=px(1,l)
+      data3(i,nbp_lat,l)=px(ngrid,l)
+    enddo
+    ! rest of the grid
+    do j=2,nbp_lat-1
+      ig0=1+(j-2)*nbp_lon
+      do i=1,nbp_lon
+        data3(i,j,l)=px(ig0+i,l)
+      enddo
+      data3(nbp_lon+1,j,l)=data3(1,j,l) ! extra (modulo) longitude
+    enddo
+   enddo
+  else ! 1D model case
+   data3_1d(1,1:nsoilmx)=px(1,1:nsoilmx)
+  endif
+#endif
+  
+  ! B. Write (append) the variable to the NetCDF file
+  if (is_master) then
+  ! B.1. Get the ID of the variable
+  ierr=NF_INQ_VARID(nid,name,varid)
+  if (ierr.ne.NF_NOERR) then
+    ! If we failed geting the variable's ID, we assume it is because
+    ! the variable doesn't exist yet and must be created.
+    ! Start by obtaining corresponding dimensions IDs
+    ierr=NF_INQ_DIMID(nid,"longitude",id(1))
+    ierr=NF_INQ_DIMID(nid,"latitude",id(2))
+    ierr=NF_INQ_DIMID(nid,"depth",id(3))
+    ierr=NF_INQ_DIMID(nid,"time",id(4))
+    ! Tell the world about it
+    write(*,*) "====================="
+    write(*,*) "writediagsoil: creating variable "//trim(name)
+    call def_var(nid,name,title,units,4,id,varid,ierr)
+  endif ! of if (ierr.ne.NF_NOERR)
+  
+  ! B.2. Prepare things to be able to write/append the variable
+  corners(1)=1
+  corners(2)=1
+  corners(3)=1
+  corners(4)=ntime
+  
+  if (klon_glo==1) then
+    edges(1)=1
+  else
+    edges(1)=nbp_lon+1
+  endif
+  edges(2)=nbp_lat
+  edges(3)=nsoilmx
+  edges(4)=1
+  
+  ! B.3. Write the slab of data
+!#ifdef NC_DOUBLE
+!  ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data3)
+!#else
+  if (klon_glo>1) then
+    ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data3)
+  else
+    ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data3_1d)
+  endif
+!#endif
+  if (ierr.ne.NF_NOERR) then
+    write(*,*) "writediagsoil: Error: Failed writing "//trim(name)//&
+               " to file "//trim(filename)//" at time",date
+  endif
+  endif ! of if (is_master)
+
+elseif (dimpx.eq.2) then ! Case of a 2D variable
+
+  ! A. Recast data along 'dynamics' grid
+#ifdef CPP_PARA
+  ! gather field on a "global" (without redundant longitude) array
+  px2(:)=px(:,1)
+  call Gather(px2,dx2_glop)
+!$OMP MASTER
+  if (is_mpi_root) then
+    call Grid1Dto2D_glo(dx2_glop,dx2_glo)
+    ! copy dx3_glo() to dx3(:) and add redundant longitude
+    data2(1:nbp_lon,:)=dx2_glo(1:nbp_lon,:)
+    data2(nbp_lon+1,:)=data2(1,:)
+  endif
+!$OMP END MASTER
+!$OMP BARRIER
+#else
+  if (klon_glo>1) then ! general case
+    ! handle the poles
+    do i=1,nbp_lon+1
+      data2(i,1)=px(1,1)
+      data2(i,nbp_lat)=px(ngrid,1)
+    enddo
+    ! rest of the grid
+    do j=2,nbp_lat-1
+      ig0=1+(j-2)*nbp_lon
+      do i=1,nbp_lon
+        data2(i,j)=px(ig0+i,1)
+      enddo
+      data2(nbp_lon+1,j)=data2(1,j) ! extra (modulo) longitude
+    enddo
+  else ! 1D model case
+    data2_1d=px(1,1)
+  endif
+#endif
+
+  ! B. Write (append) the variable to the NetCDF file
+  if (is_master) then
+  ! B.1. Get the ID of the variable
+  ierr=NF_INQ_VARID(nid,name,varid)
+  if (ierr.ne.NF_NOERR) then
+    ! If we failed geting the variable's ID, we assume it is because
+    ! the variable doesn't exist yet and must be created.
+    ! Start by obtaining corresponding dimensions IDs
+    ierr=NF_INQ_DIMID(nid,"longitude",id(1))
+    ierr=NF_INQ_DIMID(nid,"latitude",id(2))
+    ierr=NF_INQ_DIMID(nid,"time",id(3))
+    ! Tell the world about it
+    write(*,*) "====================="
+    write(*,*) "writediagsoil: creating variable "//trim(name)
+    call def_var(nid,name,title,units,3,id,varid,ierr)
+  endif ! of if (ierr.ne.NF_NOERR)
+
+  ! B.2. Prepare things to be able to write/append the variable
+  corners(1)=1
+  corners(2)=1
+  corners(3)=ntime
+  
+  if (klon_glo==1) then
+    edges(1)=1
+  else
+    edges(1)=nbp_lon+1
+  endif
+  edges(2)=nbp_lat
+  edges(3)=1
+  
+  ! B.3. Write the slab of data
+!#ifdef NC_DOUBLE
+!  ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data2)
+!#else
+  if (klon_glo>1) then ! General case
+    ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data2)
+  else
+    ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data2_1d)
+  endif
+!#endif
+  if (ierr.ne.NF_NOERR) then
+    write(*,*) "writediagsoil: Error: Failed writing "//trim(name)//&
+               " to file "//trim(filename)//" at time",date
+  endif
+  endif ! of if (is_master)
+
+elseif (dimpx.eq.0) then ! Case of a 0D variable
+#ifdef CPP_PARA
+  write(*,*) "writediagsoil: dimps==0 case not implemented in // mode!!"
+  stop
+#endif
+  ! A. Copy data value
+  data0=px(1,1)
+
+  ! B. Write (append) the variable to the NetCDF file
+  ! B.1. Get the ID of the variable
+  ierr=NF_INQ_VARID(nid,name,varid)
+  if (ierr.ne.NF_NOERR) then
+    ! If we failed geting the variable's ID, we assume it is because
+    ! the variable doesn't exist yet and must be created.
+    ! Start by obtaining corresponding dimensions IDs
+    ierr=NF_INQ_DIMID(nid,"time",id(1))
+    ! Tell the world about it
+    write(*,*) "====================="
+    write(*,*) "writediagsoil: creating variable "//trim(name)
+    call def_var(nid,name,title,units,1,id,varid,ierr)
+  endif ! of if (ierr.ne.NF_NOERR)
+
+  ! B.2. Prepare things to be able to write/append the variable
+  corners(1)=ntime
+  
+  edges(1)=1
+
+  ! B.3. Write the data
+!#ifdef NC_DOUBLE
+!  ierr=NF_PUT_VARA_DOUBLE(nid,varid,corners,edges,data0)
+!#else
+  ierr=NF_PUT_VARA_REAL(nid,varid,corners,edges,data0)
+!#endif
+  if (ierr.ne.NF_NOERR) then
+    write(*,*) "writediagsoil: Error: Failed writing "//trim(name)//&
+               " to file "//trim(filename)//" at time",date
+  endif
+
+endif ! of if (dimpx.eq.3) elseif (dimpx.eq.2) ...
+endif ! of if (mod(zitau+1,isample).eq.0)
+
+! 4. Close the NetCDF file
+if (is_master) then
+  ierr=NF_CLOSE(nid)
+endif
+
+end subroutine writediagsoil
Index: /trunk/LMDZ.TITAN/libf/phytitan/writediagspecIR.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/writediagspecIR.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/writediagspecIR.F	(revision 1644)
@@ -0,0 +1,338 @@
+      subroutine writediagspecIR(ngrid,nom,titre,unite,dimpx,px)
+
+!  Ecriture de variables diagnostiques au choix dans la physique 
+!  dans un fichier NetCDF nomme  'diagfi'. Ces variables peuvent etre
+!  3d (ex : temperature), 2d (ex : temperature de surface), ou
+!  0d (pour un scalaire qui ne depend que du temps : ex : la longitude
+!  solaire)
+!  Dans la version 2000, la periode d'ecriture est celle de 
+!  "ecritphy " regle dans le fichier de controle de run :  run.def
+!
+!    writediagfi peut etre appele de n'importe quelle subroutine
+!    de la physique, plusieurs fois. L'initialisation et la creation du
+!    fichier se fait au tout premier appel.
+!
+! WARNING : les variables dynamique (u,v,t,q,ps)
+!  sauvees par writediagfi avec une
+! date donnee sont legerement differentes que dans le fichier histoire car 
+! on ne leur a pas encore ajoute de la dissipation et de la physique !!!
+! IL est  RECOMMANDE d'ajouter les tendance physique a ces variables
+! avant l'ecriture dans diagfi (cf. physiq.F)
+!  
+!
+!  parametres (input) :
+!  ----------
+!      ngrid : nombres de point ou est calcule la physique
+!                (ngrid = 2+(jjm-1)*iim - 1/jjm)
+!                 (= nlon ou klon dans la physique terrestre)
+!      
+!      unit : unite logique du fichier de sortie (toujours la meme)
+!      nom  : nom de la variable a sortir (chaine de caracteres)
+!      titre: titre de la variable (chaine de caracteres)
+!      unite : unite de la variable (chaine de caracteres)
+!      px : variable a sortir (real 0, 2, ou 3d)
+!      dimpx : dimension de px : 0, 2, ou 3 dimensions
+!
+!=================================================================
+!
+!      This is a modified version that accepts spectrally varying input
+!      RW (2010)
+!
+!=================================================================
+ 
+! Addition by RW (2010) to allow OLR to be saved in .nc format
+      use radinc_h, only : L_NSPECTI
+      use geometry_mod, only: cell_area
+      use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
+      use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo,
+     &                              nbp_lon, nbp_lat
+      use time_phylmdz_mod, only: ecritphy, iphysiq, day_step, day_ini
+      use callkeys_mod, only: iradia
+
+      implicit none
+
+      include "netcdf.inc"
+
+! Arguments on input:
+      integer,intent(in) :: ngrid
+      character (len=*),intent(in) :: nom,titre,unite
+      integer,intent(in) :: dimpx
+      real,intent(in) :: px(ngrid,L_NSPECTI)
+
+! Local variables:
+
+!      real dx3(iip1,jjp1,llm) ! to store a 3D data set
+!      real dx2(iip1,jjp1)     ! to store a 2D (surface) data set
+!      real dx0
+
+      integer irythme
+      integer ierr
+      integer iq
+      integer i,j,l,zmax , ig0
+
+      integer,save :: zitau=0
+      character(len=20),save :: firstnom='1234567890'
+      real,save :: date
+!$OMP THREADPRIVATE(firstnom,zitau,date)
+
+! Ajouts
+      integer, save :: ntime=0
+!$OMP THREADPRIVATE(ntime)
+      integer :: idim,varid
+      integer :: nid
+      character (len =50):: fichnom
+      integer, dimension(4) :: id
+      integer, dimension(4) :: edges,corner
+
+      real area((nbp_lon+1),nbp_lat)
+! added by RDW for OLR output
+      real dx3(nbp_lon+1,nbp_lat,L_NSPECTI) ! to store the data set
+      real dx3_1d(1,L_NSPECTI) ! to store the data with 1D model
+
+#ifdef CPP_PARA
+! Added to work in parallel mode
+      real dx3_glop(klon_glo,L_NSPECTI)
+      real dx3_glo(nbp_lon,nbp_lat,L_NSPECTI) ! to store a global 3D data set
+      real areafi_glo(klon_glo) ! mesh area on global physics grid
+#else
+      real areafi_glo(ngrid) ! mesh area on global physics grid
+#endif
+
+!***************************************************************
+!Sortie des variables au rythme voulu
+
+      irythme = ecritphy*iradia ! sortie au rythme de ecritphy*iradia
+!EM+JL if the spetra need to be output more frequently, need to define a ecritSpec...
+!     irythme = iphysiq  ! sortie a tous les pas physique
+
+
+!***************************************************************
+
+! Initialisation of 'firstnom' and create/open the "diagfi.nc" NetCDF file
+! ------------------------------------------------------------------------
+! (Au tout premier appel de la subroutine durant le run.)
+
+      fichnom="diagspecIR.nc"
+
+      if (firstnom.eq.'1234567890') then ! .true. for the very first call
+      !  to this subroutine; now set 'firstnom'
+         firstnom = nom
+         ! just to be sure, check that firstnom is large enough to hold nom
+         if (len_trim(firstnom).lt.len_trim(nom)) then
+           write(*,*) "writediagspecIR: Error !!!"
+           write(*,*) "   firstnom string not long enough!!"
+           write(*,*) "   increase its size to at least ",len_trim(nom)
+           stop
+         endif
+
+#ifdef CPP_PARA
+          ! Gather cell_area() mesh area on physics grid
+          call Gather(cell_area,areafi_glo)
+#else
+         areafi_glo(:)=cell_area(:)
+#endif
+         ! Create the NetCDF file
+         if (is_master) then
+         ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
+         ! Define the 'Time' dimension
+         ierr = nf_def_dim(nid,"Time",NF_UNLIMITED,idim)
+         ! Define the 'Time' variable
+#ifdef NC_DOUBLE
+         ierr = NF_DEF_VAR (nid, "Time", NF_DOUBLE, 1, idim,varid)
+#else
+         ierr = NF_DEF_VAR (nid, "Time", NF_FLOAT, 1, idim,varid)
+#endif
+         ! Add a long_name attribute
+         ierr = NF_PUT_ATT_TEXT (nid, varid, "long_name",
+     .          4,"Time")
+         ! Add a units attribute
+         ierr = NF_PUT_ATT_TEXT(nid, varid,'units',29,
+     .          "days since 0000-00-0 00:00:00")
+         ! Switch out of NetCDF Define mode
+         ierr = NF_ENDDEF(nid)
+
+         ! Build area()
+         IF (klon_glo>1) THEN
+          do i=1,nbp_lon+1 ! poles
+           ! divide at the poles by nbp_lon
+           area(i,1)=areafi_glo(1)/nbp_lon
+           area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
+          enddo
+          do j=2,nbp_lat-1
+           ig0= 1+(j-2)*nbp_lon
+           do i=1,nbp_lon
+              area(i,j)=areafi_glo(ig0+i)
+           enddo
+           ! handle redundant point in longitude
+           area(nbp_lon+1,j)=area(1,j)
+          enddo
+         ENDIF
+
+         ! write "header" of file (longitudes, latitudes, area, ...)
+         IF (klon_glo>1) THEN ! general 3D case
+           call iniwrite_specIR(nid,day_ini,area,nbp_lon+1,nbp_lat)
+         ELSE
+           call iniwrite_specIR(nid,day_ini,areafi_glo(1),1,1)
+         ENDIF
+         endif ! of if (is_master)
+
+         zitau = -1 ! initialize zitau
+      else
+         if (is_master) then
+           ! Open the NetCDF file
+           ierr = NF_OPEN(fichnom,NF_WRITE,nid)
+         endif
+      endif ! if (firstnom.eq.'1234567890')
+
+! Increment time index 'zitau' if it is the "firstcall" (at given time level)
+! to writediagfi
+!------------------------------------------------------------------------
+      if (nom.eq.firstnom) then
+          zitau = zitau + iphysiq
+      end if
+
+!--------------------------------------------------------
+! Write the variables to output file if it's time to do so
+!--------------------------------------------------------
+
+      if ( MOD(zitau+1,irythme) .eq.0.) then
+
+! Compute/write/extend 'Time' coordinate (date given in days)
+! (done every "first call" (at given time level) to writediagfi)
+! Note: date is incremented as 1 step ahead of physics time
+!       (like the 'histoire' outputs)
+!--------------------------------------------------------
+
+        if (nom.eq.firstnom) then
+
+        ! We have identified a "first call" (at given date)
+           ntime=ntime+1 ! increment # of stored time steps
+           ! compute corresponding date (in days and fractions thereof)
+           date= float (zitau +1)/float (day_step)
+
+           if (is_master) then
+             ! Get NetCDF ID of 'Time' variable
+             ierr= NF_INQ_VARID(nid,"Time",varid)
+
+             ! Write (append) the new date to the 'Time' array
+#ifdef NC_DOUBLE
+             ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
+#else
+             ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
+#endif
+             if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in writediagspec_nc"
+              write(*,*) "***** with time"
+              write(*,*) 'ierr=', ierr   
+c             call abort
+             endif
+
+             write(6,*)'WRITEDIAGSPECIR: date= ', date
+           endif ! of if (is_master)
+        end if ! of if (nom.eq.firstnom)
+
+
+ 
+!Case of a 3D variable
+!---------------------
+        if (dimpx.eq.3) then
+
+!         A. Recast (copy) variable from physics grid to dynamics grid
+#ifdef CPP_PARA
+  ! gather field on a "global" (without redundant longitude) array
+          call Gather(px,dx3_glop)
+!$OMP MASTER
+          if (is_mpi_root) then
+            call Grid1Dto2D_glo(dx3_glop,dx3_glo)
+            ! copy dx3_glo() to dx3(:) and add redundant longitude
+            dx3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
+            dx3(nbp_lon+1,:,:)=dx3(1,:,:)
+          endif
+!$OMP END MASTER
+!$OMP BARRIER
+#else
+          IF (klon_glo>1) THEN ! General case
+           DO l=1,L_NSPECTI
+             DO i=1,nbp_lon+1
+                dx3(i,1,l)=px(1,l)
+                dx3(i,nbp_lat,l)=px(ngrid,l)
+             ENDDO
+             DO j=2,nbp_lat-1
+                ig0= 1+(j-2)*nbp_lon
+                DO i=1,nbp_lon
+                   dx3(i,j,l)=px(ig0+i,l)
+                ENDDO
+                dx3(nbp_lon+1,j,l)=dx3(1,j,l)
+             ENDDO
+           ENDDO
+          ELSE ! 1D model case
+            dx3_1d(1,1:L_NSPECTI)=px(1,1:L_NSPECTI)
+          ENDIF
+#endif
+
+!         B. Write (append) the variable to the NetCDF file
+          if (is_master) then
+
+! name of the variable
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! corresponding dimensions
+              ierr= NF_INQ_DIMID(nid,"longitude",id(1))
+              ierr= NF_INQ_DIMID(nid,"latitude",id(2))
+              ierr= NF_INQ_DIMID(nid,"IR_Wavenumber",id(3))
+              ierr= NF_INQ_DIMID(nid,"Time",id(4))
+
+! Create the variable if it doesn't exist yet
+
+              write (*,*) "=========================="
+              write (*,*) "DIAGSPECIR: creating variable ",nom
+              call def_var(nid,nom,titre,unite,4,id,varid,ierr)
+
+           endif
+
+           corner(1)=1
+           corner(2)=1
+           corner(3)=1
+           corner(4)=ntime
+
+           IF (klon_glo==1) THEN
+             edges(1)=1
+           ELSE
+             edges(1)=nbp_lon+1
+           ENDIF
+           edges(2)=nbp_lat
+           edges(3)=L_NSPECTI
+           edges(4)=1
+#ifdef NC_DOUBLE
+           IF (klon_glo>1) THEN ! General case
+             ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3)
+           ELSE
+             ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3_1d)
+           ENDIF
+#else
+           IF (klon_glo>1) THEN ! General case
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3)
+           ELSE
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3_1d)
+           ENDIF
+#endif
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR problem in writediagspec"
+              write(*,*) "***** with ",nom
+              write(*,*) 'ierr=', ierr
+             call abort
+           endif 
+
+          endif ! of if (is_master)
+
+        endif ! of if (dimpx.eq.3)
+
+      endif ! of if ( MOD(zitau+1,irythme) .eq.0.)
+
+      ! Close the NetCDF file
+      if (is_master) then
+        ierr= NF_CLOSE(nid)
+      endif
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/writediagspecVI.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/writediagspecVI.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/writediagspecVI.F	(revision 1644)
@@ -0,0 +1,337 @@
+      subroutine writediagspecVI(ngrid,nom,titre,unite,dimpx,px)
+
+!  Ecriture de variables diagnostiques au choix dans la physique 
+!  dans un fichier NetCDF nomme  'diagfi'. Ces variables peuvent etre
+!  3d (ex : temperature), 2d (ex : temperature de surface), ou
+!  0d (pour un scalaire qui ne depend que du temps : ex : la longitude
+!  solaire)
+!  Dans la version 2000, la periode d'ecriture est celle de 
+!  "ecritphy " regle dans le fichier de controle de run :  run.def
+!
+!    writediagfi peut etre appele de n'importe quelle subroutine
+!    de la physique, plusieurs fois. L'initialisation et la creation du
+!    fichier se fait au tout premier appel.
+!
+! WARNING : les variables dynamique (u,v,t,q,ps)
+!  sauvees par writediagfi avec une
+! date donnee sont legerement differentes que dans le fichier histoire car 
+! on ne leur a pas encore ajoute de la dissipation et de la physique !!!
+! IL est  RECOMMANDE d'ajouter les tendance physique a ces variables
+! avant l'ecriture dans diagfi (cf. physiq.F)
+!  
+!
+!  parametres (input) :
+!  ----------
+!      ngrid : nombres de point ou est calcule la physique
+!                (ngrid = 2+(jjm-1)*iim - 1/jjm)
+!                 (= nlon ou klon dans la physique terrestre)
+!      
+!      unit : unite logique du fichier de sortie (toujours la meme)
+!      nom  : nom de la variable a sortir (chaine de caracteres)
+!      titre: titre de la variable (chaine de caracteres)
+!      unite : unite de la variable (chaine de caracteres)
+!      px : variable a sortir (real 0, 2, ou 3d)
+!      dimpx : dimension de px : 0, 2, ou 3 dimensions
+!
+!=================================================================
+!
+!      This is a modified version that accepts spectrally varying input
+!      RW (2010)
+!
+!=================================================================
+ 
+! Addition by RW (2010) to allow OSR to be saved in .nc format
+      use radinc_h, only : L_NSPECTV
+      use geometry_mod, only: cell_area
+      use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather
+      use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo,
+     &                              nbp_lon, nbp_lat
+      use time_phylmdz_mod, only: ecritphy, iphysiq, day_step, day_ini
+      use callkeys_mod, only: iradia
+
+      implicit none
+
+      include "netcdf.inc"
+
+! Arguments on input:
+      integer ngrid
+      character (len=*) :: nom,titre,unite
+      integer dimpx
+      real px(ngrid,L_NSPECTV)
+
+! Local variables:
+
+!      real dx3(iip1,jjp1,llm) ! to store a 3D data set
+!      real dx2(iip1,jjp1)     ! to store a 2D (surface) data set
+!      real dx0
+
+      integer irythme
+      integer ierr
+      integer iq
+      integer i,j,l,zmax , ig0
+
+      integer,save :: zitau=0
+      character(len=20),save :: firstnom='1234567890'
+      real,save :: date
+!$OMP THREADPRIVATE(firstnom,zitau,date)
+
+! Ajouts
+      integer, save :: ntime=0
+!$OMP THREADPRIVATE(ntime)
+      integer :: idim,varid
+      integer :: nid
+      character (len =50):: fichnom
+      integer, dimension(4) :: id
+      integer, dimension(4) :: edges,corner
+
+      real area((nbp_lon+1),nbp_lat)
+! added by RDW for OSR output
+      real dx3(nbp_lon+1,nbp_lat,L_NSPECTV) ! to store the data set
+      real dx3_1d(1,L_NSPECTV) ! to store the data with 1D model
+
+#ifdef CPP_PARA
+! Added to work in parallel mode
+      real dx3_glop(klon_glo,L_NSPECTV)
+      real dx3_glo(nbp_lon,nbp_lat,L_NSPECTV) ! to store a global 3D data set
+      real areafi_glo(klon_glo) ! mesh area on global physics grid
+#else
+      real areafi_glo(ngrid) ! mesh area on global physics grid
+#endif
+
+!***************************************************************
+!Sortie des variables au rythme voulu
+
+      irythme = ecritphy*iradia ! sortie au rythme de ecritphy
+!EM+JL if the spetra need to be output more frequently, need to define a ecritSpec...
+!     irythme = iphysiq  ! sortie a tous les pas physique
+
+!***************************************************************
+
+! Initialisation of 'firstnom' and create/open the "diagfi.nc" NetCDF file
+! ------------------------------------------------------------------------
+! (Au tout premier appel de la subroutine durant le run.)
+
+      fichnom="diagspecVI.nc"
+
+      if (firstnom.eq.'1234567890') then ! .true. for the very first call
+      !  to this subroutine; now set 'firstnom'
+         firstnom = nom
+         ! just to be sure, check that firstnom is large enough to hold nom
+         if (len_trim(firstnom).lt.len_trim(nom)) then
+           write(*,*) "writediagfi: Error !!!"
+           write(*,*) "   firstnom string not long enough!!"
+           write(*,*) "   increase its size to at least ",len_trim(nom)
+           stop
+         endif
+
+#ifdef CPP_PARA
+          ! Gather cell_area() mesh area on physics grid
+          call Gather(cell_area,areafi_glo)
+#else
+         areafi_glo(:)=cell_area(:)
+#endif
+         ! Create the NetCDF file
+         if (is_master) then
+         ierr = NF_CREATE(fichnom, NF_CLOBBER, nid)
+         ! Define the 'Time' dimension
+         ierr = nf_def_dim(nid,"Time",NF_UNLIMITED,idim)
+         ! Define the 'Time' variable
+#ifdef NC_DOUBLE
+         ierr = NF_DEF_VAR (nid, "Time", NF_DOUBLE, 1, idim,varid)
+#else
+         ierr = NF_DEF_VAR (nid, "Time", NF_FLOAT, 1, idim,varid)
+#endif
+         ! Add a long_name attribute
+         ierr = NF_PUT_ATT_TEXT (nid, varid, "long_name",
+     .          4,"Time")
+         ! Add a units attribute
+         ierr = NF_PUT_ATT_TEXT(nid, varid,'units',29,
+     .          "days since 0000-00-0 00:00:00")
+         ! Switch out of NetCDF Define mode
+         ierr = NF_ENDDEF(nid)
+
+         ! Build area()
+         IF (klon_glo>1) THEN
+          do i=1,nbp_lon+1 ! poles
+           ! divide at the poles by nbp_lon
+           area(i,1)=areafi_glo(1)/nbp_lon
+           area(i,nbp_lat)=areafi_glo(klon_glo)/nbp_lon
+          enddo
+          do j=2,nbp_lat-1
+           ig0= 1+(j-2)*nbp_lon
+           do i=1,nbp_lon
+              area(i,j)=areafi_glo(ig0+i)
+           enddo
+           ! handle redundant point in longitude
+           area(nbp_lon+1,j)=area(1,j)
+          enddo
+         ENDIF
+
+         ! write "header" of file (longitudes, latitudes, geopotential, ...)
+         IF (klon_glo>1) THEN ! general 3D case
+           call iniwrite_specVI(nid,day_ini,area,nbp_lon+1,nbp_lat)
+         ELSE
+           call iniwrite_specVI(nid,day_ini,areafi_glo(1),1,1)
+         ENDIF
+         endif ! of if (is_master)
+
+         zitau = -1 ! initialize zitau
+      else
+         if (is_master) then
+           ! Open the NetCDF file
+           ierr = NF_OPEN(fichnom,NF_WRITE,nid)
+         endif
+      endif ! if (firstnom.eq.'1234567890')
+
+! Increment time index 'zitau' if it is the "firstcall" (at given time level)
+! to writediagfi
+!------------------------------------------------------------------------
+      if (nom.eq.firstnom) then
+          zitau = zitau + iphysiq
+      end if
+
+!--------------------------------------------------------
+! Write the variables to output file if it's time to do so
+!--------------------------------------------------------
+
+      if ( MOD(zitau+1,irythme) .eq.0.) then
+
+! Compute/write/extend 'Time' coordinate (date given in days)
+! (done every "first call" (at given time level) to writediagfi)
+! Note: date is incremented as 1 step ahead of physics time
+!       (like the 'histoire' outputs)
+!--------------------------------------------------------
+
+        if (nom.eq.firstnom) then
+
+        ! We have identified a "first call" (at given date)
+           ntime=ntime+1 ! increment # of stored time steps
+           ! compute corresponding date (in days and fractions thereof)
+           date= float (zitau +1)/float (day_step)
+
+           if (is_master) then
+             ! Get NetCDF ID of 'Time' variable
+             ierr= NF_INQ_VARID(nid,"Time",varid)
+
+             ! Write (append) the new date to the 'Time' array
+#ifdef NC_DOUBLE
+             ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
+#else
+             ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
+#endif
+             if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR matter in writediagspec_nc"
+              write(*,*) "***** with time"
+              write(*,*) 'ierr=', ierr   
+c             call abort
+             endif
+
+             write(6,*)'WRITEDIAGSPECVI: date= ', date
+           endif ! of if (is_master)
+        end if ! of if (nom.eq.firstnom)
+
+
+ 
+!Case of a 3D variable
+!---------------------
+        if (dimpx.eq.3) then
+
+!         A. Recast (copy) variable from physics grid to dynamics grid
+#ifdef CPP_PARA
+  ! gather field on a "global" (without redundant longitude) array
+          call Gather(px,dx3_glop)
+!$OMP MASTER
+          if (is_mpi_root) then
+            call Grid1Dto2D_glo(dx3_glop,dx3_glo)
+            ! copy dx3_glo() to dx3(:) and add redundant longitude
+            dx3(1:nbp_lon,:,:)=dx3_glo(1:nbp_lon,:,:)
+            dx3(nbp_lon+1,:,:)=dx3(1,:,:)
+          endif
+!$OMP END MASTER
+!$OMP BARRIER
+#else
+          IF (klon_glo>1) THEN ! General case
+           DO l=1,L_NSPECTV
+             DO i=1,nbp_lon+1
+                dx3(i,1,l)=px(1,l)
+                dx3(i,nbp_lat,l)=px(ngrid,l)
+             ENDDO
+             DO j=2,nbp_lat-1
+                ig0= 1+(j-2)*nbp_lon
+                DO i=1,nbp_lon
+                   dx3(i,j,l)=px(ig0+i,l)
+                ENDDO
+                dx3(nbp_lon+1,j,l)=dx3(1,j,l)
+             ENDDO
+           ENDDO
+          ELSE ! 1D model case
+           dx3_1d(1,1:L_NSPECTV)=px(1,1:L_NSPECTV)
+          ENDIF
+#endif
+
+!         B. Write (append) the variable to the NetCDF file
+          if (is_master) then
+
+! name of the variable
+           ierr= NF_INQ_VARID(nid,nom,varid)
+           if (ierr /= NF_NOERR) then
+! corresponding dimensions
+              ierr= NF_INQ_DIMID(nid,"longitude",id(1))
+              ierr= NF_INQ_DIMID(nid,"latitude",id(2))
+              ierr= NF_INQ_DIMID(nid,"VI_Wavenumber",id(3))
+              ierr= NF_INQ_DIMID(nid,"Time",id(4))
+
+! Create the variable if it doesn't exist yet
+
+              write (*,*) "=========================="
+              write (*,*) "DIAGSPEC: creating variable ",nom
+              call def_var(nid,nom,titre,unite,4,id,varid,ierr)
+
+           endif
+
+           corner(1)=1
+           corner(2)=1
+           corner(3)=1
+           corner(4)=ntime
+
+           IF (klon_glo==1) THEN
+             edges(1)=1
+           ELSE
+             edges(1)=nbp_lon+1
+           ENDIF
+           edges(2)=nbp_lat
+           edges(3)=L_NSPECTV
+           edges(4)=1
+#ifdef NC_DOUBLE
+           IF (klon_glo>1) THEN ! General case
+             ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3)
+           ELSE
+             ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3_1d)
+           ENDIF
+#else
+           IF (klon_glo>1) THEN ! General case
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3)
+           ELSE
+             ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3_1d)
+           ENDIF
+#endif
+
+           if (ierr.ne.NF_NOERR) then
+              write(*,*) "***** PUT_VAR problem in writediagspec"
+              write(*,*) "***** with ",nom
+              write(*,*) 'ierr=', ierr
+             call abort
+           endif 
+
+          endif ! of if (is_master)
+
+        endif ! of if (dimpx.eq.3)
+
+      endif ! of if ( MOD(zitau+1,irythme) .eq.0.)
+
+      ! Close the NetCDF file
+      if (is_master) then
+        ierr= NF_CLOSE(nid)
+      endif
+
+      end
Index: /trunk/LMDZ.TITAN/libf/phytitan/writeg1d.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/writeg1d.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/writeg1d.F	(revision 1644)
@@ -0,0 +1,223 @@
+      SUBROUTINE writeg1d(ngrid,nx,x,nom,titre)
+      USE comg1d_mod, ONLY: g1d_nomfich,g1d_premier,g1d_unitfich,
+     &	g1d_irec,g1d_nvar,g1d_nomvar,g1d_titrevar,g1d_dimvar,g1d_nlayer
+      IMPLICIT NONE
+
+c.......................................................................
+c
+c  ecriture de x pour GRADS-1D
+c
+c  in :
+c         * ngrid      ---> pour controler que l'on est bien en 1D
+c         * nx         ---> taille du vecteur a stocker
+c                             "1" pour une variable de surface
+c                             "nlayer" pour une variable de centre de couche
+c                             "nlayer+1" pour une variable d'interface
+c         * x          ---> variable a stocker
+c         * nom        ---> nom "pour grads"
+c         * titre      ---> titre "pour grads"
+c
+c.......................................................................
+c
+
+c
+c.......................................................................
+c  declaration des arguments 
+c
+      INTEGER ngrid,nx,i
+      REAL*4 xr4(1000)
+      REAL x(nx)
+      CHARACTER*(*) nom,titre
+c
+c  declaration des arguments 
+c....................................................................... 
+c  declaration des variables locales
+c
+      INTEGER ilayer,ivar
+      LOGICAL test 
+c
+c  declaration des variables locales
+c.......................................................................
+c  controle 1D
+c
+c     print*,'ngrid=',ngrid
+      IF (ngrid.NE.1) return
+c
+c  controle 1D
+c.......................................................................
+c  copy => force en reel 4 pour l'ecriture dans grads1d.dat
+
+      do i=1,nx
+        xr4(i) = x(i)
+      enddo
+
+c  copy => force en reel 4 pour l'ecriture dans grads1d.dat
+c.......................................................................
+c  ouverture du fichier au premier appel
+
+
+      g1d_nomfich='g1d.dat'
+
+      IF (g1d_premier) THEN
+        OPEN (g1d_unitfich,FILE=g1d_nomfich
+     &       ,FORM='unformatted',ACCESS='direct',RECL=4)
+        g1d_irec=0
+        g1d_nvar=0
+        g1d_premier=.false.
+      ENDIF
+
+c  ouverture du fichier au premier appel
+c.......................................................................
+c  pour l'ecriture du fichier ctl
+
+      test=.true.
+      DO ivar=1,g1d_nvar
+        IF (nom.EQ.g1d_nomvar(ivar)) test=.false.
+        IF (nx .GT. 1000) then
+          print*,'ERROR:  nx > 1000 dans writeg1d.F' 
+          print*,'Changer la dimension de xr4'
+          call exit(1)
+        ENDIF
+      ENDDO
+      IF (test) THEN
+        g1d_nvar=g1d_nvar+1
+        g1d_nomvar(g1d_nvar)=nom
+        g1d_titrevar(g1d_nvar)=titre
+        IF (nx.EQ.1) THEN
+           g1d_dimvar(g1d_nvar)=0
+        ELSEIF (nx.EQ.g1d_nlayer) THEN
+           g1d_dimvar(g1d_nvar)=g1d_nlayer
+        ELSEIF (nx.EQ.g1d_nlayer+1) THEN
+           g1d_dimvar(g1d_nvar)=g1d_nlayer+1
+        ELSE
+           PRINT *,'._. probleme de dimension dans GRADS-1D ._.'
+           print*,'NX = ',nx
+           print*,'g1d_nlayer = ',g1d_nlayer
+        ENDIF
+      ENDIF
+c
+c  pour l'ecriture du fichier ctl
+c.......................................................................
+c  ecriture
+c
+      IF (nx.EQ.1) THEN
+        g1d_irec=g1d_irec+1
+        WRITE(g1d_unitfich,REC=g1d_irec) xr4(1)
+      ELSE
+        DO ilayer=1,g1d_nlayer
+          g1d_irec=g1d_irec+1
+          WRITE(g1d_unitfich,REC=g1d_irec) xr4(ilayer)
+        ENDDO
+      ENDIF
+c
+c  ecriture
+c.......................................................................
+c
+10001 CONTINUE
+c
+c.......................................................................
+c
+      RETURN
+      END
+
+
+
+
+
+c *********************************************************************
+c *********************************************************************
+
+      SUBROUTINE endg1d(ngrid,nlayer,zlayer,ndt)
+      USE time_phylmdz_mod, ONLY: dtphys, daysec
+      USE comg1d_mod, ONLY: g1d_nomfich,g1d_unitfich,g1d_nvar,
+     &	g1d_nomvar,g1d_titrevar,g1d_dimvar,g1d_nlayer,g1d_unitctl,
+     &	g1d_nomctl,saveG1D
+      IMPLICIT NONE
+c.......................................................................
+c
+c  ecriture du fichier de controle pour GRADS-1D
+c
+c  in :
+c         * ngrid      ---> pour controler que l'on est bien en 1D
+c         * nlayer     ---> nombre de couches
+c         * zlayer     ---> altitude au centre de chaque couche (km)
+c         * ndt        ---> nombre de pas de temps
+c
+c.......................................................................
+c
+
+
+c
+c.......................................................................
+c  declaration des arguments 
+c
+      INTEGER ngrid,nlayer
+      REAL zlayer(nlayer)
+      INTEGER ndt
+c
+c  declaration des arguments 
+c....................................................................... 
+c  declaration des variables locales
+c
+      INTEGER ivar,ilayer
+c
+
+
+!      integer saveG1D
+
+c  declaration des variables locales
+c.......................................................................
+c  contole 1D
+c
+      IF (ngrid.NE.1) GOTO 10001
+c
+c  contole 1D
+c.......................................................................
+c
+      IF (nlayer.ne.g1d_nlayer) 
+     &PRINT *,'._. probleme de dimension dans GRADS-1D (endg1d.F) '
+c
+c.......................................................................
+c
+      CLOSE (g1d_unitfich)
+c
+c.......................................................................
+
+
+      OPEN (g1d_unitctl,FILE=g1d_nomctl,FORM='formatted',RECL=4*100)
+      WRITE (g1d_unitctl,'(a4,2x,a1,a20)') 'DSET','^',g1d_nomfich
+      WRITE (g1d_unitctl,'(a5,2x,a20)') 'UNDEF ','1.E+30'
+      WRITE (g1d_unitctl,'(a11)') 'FORMAT YREV'
+      WRITE (g1d_unitctl,'(a5,2x,a30)') 'TITLE ','champs 1D'
+      WRITE (g1d_unitctl,'(a5,i4,a20)') 'XDEF ',1,' LINEAR 0 1'
+      WRITE (g1d_unitctl,'(a5,i4,a20)') 'YDEF ',1,' LINEAR 0 1'
+      WRITE (g1d_unitctl,'(a5,i4,a20)') 'ZDEF ',g1d_nlayer,' LEVELS'
+      WRITE (g1d_unitctl,'(5(1x,f13.5))')
+     &      (zlayer(ilayer),ilayer=1,g1d_nlayer)
+
+c     Writing true timestep in g1d.ctl (in planet "minutes"= sol/(60*24)
+!      ivar =min( max(int(1440.*dtphys/daysec +0.5),1) , 99)   
+!      WRITE (g1d_unitctl,'(a4,2x,i10,a19,i2,a2)')
+!     &      'TDEF ',ndt,' LINEAR 01JAN2000 ', ivar,'MN '
+
+      ivar =min( max(int(1440.*dtphys*saveG1D/daysec +0.5),1) , 99)
+      ! not sure ivar is right, but it doesnt matter
+      WRITE (g1d_unitctl,'(a4,2x,i10,a19,i2,a2)')
+     &      'TDEF ',ndt/saveG1D,' LINEAR 01JAN2000 ', ivar,'MN '
+
+      WRITE (g1d_unitctl,'(a5,i5)') 'VARS ',g1d_nvar
+      DO ivar=1,g1d_nvar
+      WRITE (g1d_unitctl,'(a9,3x,i4,i3,1x,a39)') 
+     &       g1d_nomvar(ivar),g1d_dimvar(ivar),99,g1d_titrevar(ivar)
+      ENDDO
+      WRITE (g1d_unitctl,'(a7)') 'ENDVARS'
+      CLOSE (g1d_unitctl)
+c
+c.......................................................................
+c
+10001 CONTINUE
+c
+c.......................................................................
+c
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/libf/phytitan/wstats.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/wstats.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/wstats.F90	(revision 1644)
@@ -0,0 +1,517 @@
+subroutine wstats(ngrid,nom,titre,unite,dim,px)
+
+use statto_mod, only: istats,istime,count
+use mod_phys_lmdz_para, only : is_mpi_root, is_master, gather, klon_mpi_begin
+use mod_grid_phy_lmdz, only : klon_glo, Grid1Dto2D_glo, &
+                              nbp_lon, nbp_lat, nbp_lev
+implicit none
+
+include "netcdf.inc"
+
+integer,intent(in) :: ngrid
+character (len=*),intent(in) :: nom,titre,unite
+integer,intent(in) :: dim
+real,intent(in) :: px(ngrid,nbp_lev)
+real,allocatable,save :: mean3d(:,:,:),sd3d(:,:,:),dx3(:,:,:)
+real,allocatable,save :: mean2d(:,:),sd2d(:,:),dx2(:,:)
+character (len=50) :: namebis
+character (len=50), save :: firstvar
+!$OMP THREADPRIVATE(firstvar)
+integer :: ierr,varid,nbdim,nid
+integer :: meanid,sdid
+integer, dimension(4)  :: id,start,sizes
+logical, save :: firstcall=.TRUE.
+integer :: l,i,j,ig0
+integer,save :: indx
+
+integer, save :: step=0
+!$OMP THREADPRIVATE(firstcall,indx,step)
+
+! Added to work in parallel mode
+#ifdef CPP_PARA
+real px3_glop(klon_glo,nbp_lev) ! to store a 3D data set on global physics grid
+real px3_glo(nbp_lon,nbp_lat,nbp_lev) ! to store a global 3D data set on global lonxlat grid
+real px2_glop(klon_glo) ! to store a 2D data set on global physics grid
+real px2_glo(nbp_lon,nbp_lat) ! to store a 2D data set on global lonxlat grid
+real px2(ngrid)
+real px3(ngrid,nbp_lev)
+#else
+! When not running in parallel mode:
+real px3_glop(ngrid,nbp_lev) ! to store a 3D data set on global physics grid
+real px3_glo(nbp_lon,nbp_lat,nbp_lev) ! to store a global 3D data set on global lonxlat grid
+real px2_glop(ngrid) ! to store a 2D data set on global physics grid
+real px2_glo(nbp_lon,nbp_lat) ! to store a 2D data set on global lonxlat grid
+#endif
+
+! 1. Initialization (creation of stats.nc file)
+if (firstcall) then
+   firstcall=.false.
+   firstvar=trim((nom))
+   call inistats(ierr)
+   if (klon_glo>1) then ! general case, 3D GCM
+     allocate(mean3d(nbp_lon+1,nbp_lat,nbp_lev))
+     allocate(sd3d(nbp_lon+1,nbp_lat,nbp_lev))
+     allocate(dx3(nbp_lon+1,nbp_lat,nbp_lev))
+     allocate(mean2d(nbp_lon+1,nbp_lat))
+     allocate(sd2d(nbp_lon+1,nbp_lat))
+     allocate(dx2(nbp_lon+1,nbp_lat))
+   else ! 1D model
+     allocate(mean3d(1,1,nbp_lev))
+     allocate(sd3d(1,1,nbp_lev))
+     allocate(dx3(1,1,nbp_lev))
+     allocate(mean2d(1,1))
+     allocate(sd2d(1,1))
+     allocate(dx2(1,1))
+   endif
+endif
+
+if (firstvar==nom) then ! If we're back to the first variable, increment time counter
+      step = step + 1
+endif
+
+if (mod(step,istats).ne.0) then
+  ! if its not time to write to file, exit
+   RETURN
+endif
+
+! collect fields on a global physics grid
+#ifdef CPP_PARA
+ if (dim.eq.3) then
+  px3(1:ngrid,1:nbp_lev)=px(1:ngrid,1:nbp_lev)
+  ! Gather fieds on a "global" (without redundant longitude) array
+  call Gather(px3,px3_glop)
+!$OMP MASTER
+  if (is_mpi_root) then
+    call Grid1Dto2D_glo(px3_glop,px3_glo)
+    ! copy dx3_glo() to dx3(:) and add redundant longitude
+    dx3(1:nbp_lon,:,:)=px3_glo(1:nbp_lon,:,:)
+    dx3(nbp_lon+1,:,:)=dx3(1,:,:)
+  endif
+!$OMP END MASTER
+!$OMP BARRIER
+ else ! dim.eq.2
+  ! Gather fieds on a "global" (without redundant longitude) array
+  px2(:)=px(:,1)
+  call Gather(px2,px2_glop)
+!$OMP MASTER
+          if (is_mpi_root) then
+            call Grid1Dto2D_glo(px2_glop,px2_glo)
+            ! copy px2_glo() to dx2(:) and add redundant longitude
+            dx2(1:nbp_lon,:)=px2_glo(1:nbp_lon,:)
+            dx2(nbp_lon+1,:)=dx2(1,:)
+          endif
+!$OMP END MASTER
+!$OMP BARRIER
+ endif
+#else
+  if (dim.eq.3) then
+    px3_glop(:,1:nbp_lev)=px(:,1:nbp_lev)
+!  Passage variable physique -->  variable dynamique
+    DO l=1,nbp_lev
+      DO i=1,nbp_lon
+         px3_glo(i,1,l)=px(1,l)
+         px3_glo(i,nbp_lat,l)=px(ngrid,l)
+      ENDDO
+      DO j=2,nbp_lat-1
+         ig0= 1+(j-2)*nbp_lon
+         DO i=1,nbp_lon
+            px3_glo(i,j,l)=px(ig0+i,l)
+         ENDDO
+      ENDDO
+    ENDDO
+  else ! dim.eq.2
+    px2_glop(:)=px(:,1)
+!    Passage variable physique -->  physique dynamique
+   DO i=1,nbp_lon
+     px2_glo(i,1)=px(1,1)
+     px2_glo(i,nbp_lat)=px(ngrid,1)
+   ENDDO
+   DO j=2,nbp_lat-1
+     ig0= 1+(j-2)*nbp_lon
+     DO i=1,nbp_lon
+        px2_glo(i,j)=px(ig0+i,1)
+     ENDDO
+   ENDDO
+  endif
+#endif
+
+! 2. Write field to file
+
+if (is_master) then
+! only master needs do this
+
+ierr = NF_OPEN("stats.nc",NF_WRITE,nid)
+
+namebis=trim(nom)
+
+! test: check if that variable already exists in file
+ierr= NF_INQ_VARID(nid,namebis,meanid)
+
+if (ierr.ne.NF_NOERR) then
+  ! variable not in file, create/define it
+   if (firstvar==nom) then 
+      indx=1
+      count(:)=0
+   endif
+
+
+!declaration de la variable
+
+! choix du nom des coordonnees
+   ierr= NF_INQ_DIMID(nid,"longitude",id(1))
+   ierr= NF_INQ_DIMID(nid,"latitude",id(2))
+   if (dim.eq.3) then
+      ierr= NF_INQ_DIMID(nid,"altitude",id(3))
+      ierr= NF_INQ_DIMID(nid,"Time",id(4))
+      nbdim=4
+   else if (dim==2) then
+      ierr= NF_INQ_DIMID(nid,"Time",id(3))
+      nbdim=3
+   endif
+
+   write (*,*) "====================="
+   write (*,*) "STATS: creation de ",nom
+   namebis=trim(nom)
+   call def_var_stats(nid,namebis,titre,unite,nbdim,id,meanid,ierr)
+   if (dim.eq.3) then
+     call inivar(nid,meanid,size(px3_glop,1),dim,indx,px3_glop,ierr)
+   else ! dim.eq.2
+     call inivar(nid,meanid,size(px2_glop,1),dim,indx,px2_glop,ierr)
+   endif
+   namebis=trim(nom)//"_sd"
+   call def_var_stats(nid,namebis,trim(titre)//" total standard deviation over the season",unite,nbdim,id,sdid,ierr)
+   if (dim.eq.3) then
+     call inivar(nid,sdid,size(px3_glop,1),dim,indx,px3_glop,ierr)
+   else ! dim.eq.2
+     call inivar(nid,sdid,size(px2_glop,1),dim,indx,px2_glop,ierr)
+   endif
+
+   ierr= NF_CLOSE(nid)
+   return
+
+else
+   ! variable found in file
+   namebis=trim(nom)//"_sd"
+   ierr= NF_INQ_VARID(nid,namebis,sdid)
+
+endif
+
+if (firstvar==nom) then 
+   count(indx)=count(int(indx))+1
+   indx=indx+1
+   if (indx>istime) then
+      indx=1
+   endif
+endif
+
+if (count(indx)==0) then
+   ! very first time we write the variable to file
+   if (dim.eq.3) then
+      start=(/1,1,1,indx/)
+      if (klon_glo>1) then !general case
+        sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
+      else
+        sizes=(/1,1,nbp_lev,1/)
+      endif
+      mean3d(:,:,:)=0
+      sd3d(:,:,:)=0
+   else if (dim.eq.2) then
+      start=(/1,1,indx,0/)
+      if (klon_glo>1) then !general case
+        sizes=(/nbp_lon+1,nbp_lev,1,0/)
+      else
+        sizes=(/1,1,1,0/)
+      endif
+      mean2d(:,:)=0
+      sd2d(:,:)=0
+   endif
+else
+   ! load values from file
+   if (dim.eq.3) then
+      start=(/1,1,1,indx/)
+      if (klon_glo>1) then !general case
+        sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
+      else ! 1D model case
+        sizes=(/1,1,nbp_lev,1/)
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean3d)
+      ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,sizes,sd3d)
+#else
+      ierr = NF_GET_VARA_REAL(nid,meanid,start,sizes,mean3d)
+      ierr = NF_GET_VARA_REAL(nid,sdid,start,sizes,sd3d)
+#endif
+      if (ierr.ne.NF_NOERR) then
+         write (*,*) "wstats error reading :",trim(nom)
+         write (*,*) NF_STRERROR(ierr)
+         stop ""
+      endif
+
+   else if (dim.eq.2) then
+      start=(/1,1,indx,0/)
+      if (klon_glo>1) then ! general case
+        sizes=(/nbp_lon+1,nbp_lat,1,0/)
+      else
+        sizes=(/1,1,1,0/)
+      endif
+#ifdef NC_DOUBLE
+      ierr = NF_GET_VARA_DOUBLE(nid,meanid,start,sizes,mean2d)
+      ierr = NF_GET_VARA_DOUBLE(nid,sdid,start,sizes,sd2d)
+#else
+      ierr = NF_GET_VARA_REAL(nid,meanid,start,sizes,mean2d)
+      ierr = NF_GET_VARA_REAL(nid,sdid,start,sizes,sd2d)
+#endif
+      if (ierr.ne.NF_NOERR) then
+         write (*,*) "wstats error reading :",trim(nom)
+         write (*,*) NF_STRERROR(ierr)
+         stop ""
+      endif
+   endif
+endif ! of if (count(indx)==0)
+
+
+! 2.1. Build dx* (data on lon-lat grid, with redundant longitude)
+
+if (dim.eq.3) then
+  dx3(1:nbp_lon,:,:)=px3_glo(:,:,:)
+  IF (klon_glo>1) THEN ! in 3D, add redundant longitude point
+    dx3(nbp_lon+1,:,:)=dx3(1,:,:)
+  ENDIF
+else ! dim.eq.2
+  dx2(1:nbp_lon,:)=px2_glo(:,:)
+  IF (klon_glo>1) THEN ! in 3D, add redundant longitude point
+    dx2(nbp_lon+1,:)=dx2(1,:)
+  ENDIF
+endif
+
+
+! 2.2. Add current values to previously stored sums
+
+if (dim.eq.3) then
+
+   mean3d(:,:,:)=mean3d(:,:,:)+dx3(:,:,:)
+   sd3d(:,:,:)=sd3d(:,:,:)+dx3(:,:,:)**2
+
+#ifdef NC_DOUBLE
+   ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,sizes,mean3d)
+   ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,sizes,sd3d)
+#else
+   ierr = NF_PUT_VARA_REAL(nid,meanid,start,sizes,mean3d)
+   ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd3d)
+#endif
+  if (ierr.ne.NF_NOERR) then
+     write (*,*) "wstats error writing :",trim(nom)
+     write (*,*) NF_STRERROR(ierr)
+     stop ""
+  endif
+
+else if (dim.eq.2) then
+
+   mean2d(:,:)= mean2d(:,:)+dx2(:,:)
+   sd2d(:,:)=sd2d(:,:)+dx2(:,:)**2
+
+#ifdef NC_DOUBLE
+   ierr = NF_PUT_VARA_DOUBLE(nid,meanid,start,sizes,mean2d)
+   ierr = NF_PUT_VARA_DOUBLE(nid,sdid,start,sizes,sd2d)
+#else
+   ierr = NF_PUT_VARA_REAL(nid,meanid,start,sizes,mean2d)
+   ierr = NF_PUT_VARA_REAL(nid,sdid,start,sizes,sd2d)
+#endif
+  if (ierr.ne.NF_NOERR) then
+     write (*,*) "wstats error writing :",trim(nom)
+     write(*,*) "start:",start
+     write(*,*) "sizes:",sizes
+     write(*,*) "mean2d:",mean2d
+     write(*,*) "sd2d:",sd2d
+     write (*,*) NF_STRERROR(ierr)
+     stop ""
+  endif
+
+endif ! of if (dim.eq.3) elseif (dim.eq.2)
+
+  ierr= NF_CLOSE(nid)
+endif ! of if (is_master)
+
+end subroutine wstats
+
+!======================================================
+subroutine inivar(nid,varid,ngrid,dim,indx,px,ierr)
+use mod_grid_phy_lmdz, only : nbp_lon, nbp_lat, nbp_lev, klon_glo
+
+implicit none
+
+include "netcdf.inc"
+
+integer, intent(in) :: nid,varid,dim,indx,ngrid
+real, dimension(ngrid,nbp_lev), intent(in) :: px
+integer, intent(out) :: ierr
+
+integer :: l,i,j,ig0
+integer, dimension(4) :: start,sizes
+real, dimension(nbp_lon+1,nbp_lat,nbp_lev) :: dx3
+real, dimension(nbp_lon+1,nbp_lat) :: dx2
+real :: dx3_1d(nbp_lev) ! for 1D outputs
+real :: dx2_1d ! for 1D outputs
+
+if (dim.eq.3) then
+
+   start=(/1,1,1,indx/)
+   if (klon_glo>1) then ! general 3D case
+     sizes=(/nbp_lon+1,nbp_lat,nbp_lev,1/)
+   else
+     sizes=(/1,1,nbp_lev,1/)
+   endif
+
+!  Passage variable physique -->  variable dynamique
+
+   if (klon_glo>1) then ! general case
+    DO l=1,nbp_lev
+      DO i=1,nbp_lon+1
+         dx3(i,1,l)=px(1,l)
+         dx3(i,nbp_lat,l)=px(ngrid,l)
+      ENDDO
+      DO j=2,nbp_lat-1
+         ig0= 1+(j-2)*nbp_lon
+         DO i=1,nbp_lon
+            dx3(i,j,l)=px(ig0+i,l)
+         ENDDO
+         dx3(nbp_lon+1,j,l)=dx3(1,j,l)
+      ENDDO
+    ENDDO
+   else ! 1D model case
+     dx3_1d(1:nbp_lev)=px(1,1:nbp_lev)
+   endif
+
+#ifdef NC_DOUBLE
+   if (klon_glo>1) then
+     ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx3)
+   else
+     ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx3_1d)
+   endif
+#else
+   if (klon_glo>1) then
+     ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx3)
+   else
+     ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx3_1d)
+   endif
+#endif
+  if (ierr.ne.NF_NOERR) then
+     write (*,*) "inivar error writing variable"
+     write (*,*) NF_STRERROR(ierr)
+     stop ""
+  endif
+
+else if (dim.eq.2) then
+
+      start=(/1,1,indx,0/)
+      if (klon_glo>1) then ! general 3D case
+        sizes=(/nbp_lon+1,nbp_lat,1,0/)
+      else
+        sizes=(/1,1,1,0/)
+      endif
+
+!    Passage variable physique -->  physique dynamique
+
+  if (klon_glo>1) then ! general case
+  DO i=1,nbp_lon+1
+     dx2(i,1)=px(1,1)
+     dx2(i,nbp_lat)=px(ngrid,1)
+  ENDDO
+  DO j=2,nbp_lat-1
+     ig0= 1+(j-2)*nbp_lon
+     DO i=1,nbp_lon
+        dx2(i,j)=px(ig0+i,1)
+     ENDDO
+     dx2(nbp_lon+1,j)=dx2(1,j)
+  ENDDO
+  else ! 1D model case
+    dx2_1d=px(1,1)
+  endif
+  
+#ifdef NC_DOUBLE
+   if (klon_glo>1) then
+     ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx2)
+   else
+     ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,sizes,dx2_1d)
+   endif
+#else
+   if (klon_glo>1) then
+     ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx2)
+   else
+     ierr = NF_PUT_VARA_REAL(nid,varid,start,sizes,dx2_1d)
+   endif
+#endif
+  if (ierr.ne.NF_NOERR) then
+     write (*,*) "inivar error writing variable"
+     write (*,*) NF_STRERROR(ierr)
+     stop ""
+  endif
+
+endif
+
+end subroutine inivar
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+subroutine def_var_stats(nid,name,title,units,nbdim,dimids,nvarid,ierr)
+
+! This subroutine defines variable 'name' in a (pre-existing and opened)
+! NetCDF file (known from its NetCDF ID 'nid').
+! The number of dimensions 'nbdim' of the variable, as well as the IDs of
+! corresponding dimensions must be set (in array 'dimids').
+! Upon successfull definition of the variable, 'nvarid' contains the
+! NetCDF ID of the variable.
+! The variables' attributes 'title' (Note that 'long_name' would be more
+! appropriate) and 'units' are also set. 
+
+implicit none
+
+include "netcdf.inc"
+
+integer,intent(in) :: nid ! NetCDF file ID
+character(len=*),intent(in) :: name ! the variable's name
+character(len=*),intent(in) :: title ! 'title' attribute of variable
+character(len=*),intent(in) :: units ! 'units' attribute of variable
+integer,intent(in) :: nbdim ! number of dimensions of the variable
+integer,dimension(nbdim),intent(in) :: dimids ! NetCDF IDs of the dimensions
+                                              ! the variable is defined along
+integer,intent(out) :: nvarid ! NetCDF ID of the variable
+integer,intent(out) :: ierr ! returned NetCDF staus code
+
+! 1. Switch to NetCDF define mode 
+ierr=NF_REDEF(nid)
+
+! 2. Define the variable
+#ifdef NC_DOUBLE
+ierr = NF_DEF_VAR (nid,adjustl(name),NF_DOUBLE,nbdim,dimids,nvarid)
+#else
+ierr = NF_DEF_VAR (nid,adjustl(name),NF_FLOAT,nbdim,dimids,nvarid)
+#endif
+if(ierr/=NF_NOERR) then
+   write(*,*) "def_var_stats: Failed defining variable "//trim(name)
+   write(*,*) NF_STRERROR(ierr)
+   stop ""
+endif
+
+! 3. Write attributes
+ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title",&
+                     len_trim(adjustl(title)),adjustl(title))
+if(ierr/=NF_NOERR) then
+   write(*,*) "def_var_stats: Failed writing title attribute for "//trim(name)
+   write(*,*) NF_STRERROR(ierr)
+   stop ""
+endif
+
+ierr=NF_PUT_ATT_TEXT(nid,nvarid,"units",&
+                     len_trim(adjustl(units)),adjustl(units))
+if(ierr/=NF_NOERR) then
+   write(*,*) "def_var_stats: Failed writing units attribute for "//trim(name)
+   write(*,*) NF_STRERROR(ierr)
+   stop ""
+endif
+
+! 4. Switch out of NetCDF define mode
+ierr = NF_ENDDEF(nid)
+
+end subroutine def_var_stats
+
Index: /trunk/LMDZ.TITAN/libf/phytitan/xios_output_mod.F90
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/xios_output_mod.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/xios_output_mod.F90	(revision 1644)
@@ -0,0 +1,240 @@
+MODULE xios_output_mod
+
+ IMPLICIT NONE
+ 
+ INTEGER,PRIVATE,SAVE :: time_it=0 ! store number of iterations with calls to XIOS since start
+! does not need to be threadprivate; managed by omp master
+
+ CHARACTER(LEN=*), PARAMETER :: context_id= "LMDZ" ! same as in context_lmdz_physics.xml
+ 
+#ifdef CPP_XIOS
+
+ INTERFACE send_xios_field
+    MODULE PROCEDURE histwrite0d_xios,histwrite2d_xios,histwrite3d_xios
+ END INTERFACE
+ 
+
+CONTAINS
+
+  SUBROUTINE initialize_xios_output(day,timeofday,dtphys,daysec,&
+                                    presnivs,pseudoalt)
+!  USE mod_phys_lmdz_para, only: gather, bcast, &
+!                                jj_nb, jj_begin, jj_end, ii_begin, ii_end, &
+!                                mpi_size, mpi_rank, klon_mpi, &
+!                                is_sequential, is_south_pole_dyn
+  USE mod_phys_lmdz_para, ONLY: jj_nb, jj_begin, jj_end, ii_begin, ii_end, &
+                                mpi_size, mpi_rank, klon_mpi, &
+                                is_sequential, is_south_pole_dyn
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat, klon_glo
+  USE print_control_mod, ONLY: lunout, prt_level
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon, nbp_lat
+  USE regular_lonlat_mod, ONLY: lon_reg, lat_reg
+  USE nrtype, ONLY: pi
+  USE wxios
+  IMPLICIT NONE
+  
+  REAL,INTENT(IN) :: day ! Number of elapsed sols since reference Ls=0.
+  REAL,INTENT(IN) :: timeofday ! "Universal time", given as fraction of sol (e.g.: 0.5 for noon).
+  REAL,INTENT(IN) :: dtphys ! physics time step (s)
+  REAL,INTENT(IN) :: daysec ! lengthof a standard day (s)
+  REAL,INTENT(IN) :: presnivs(:) ! vertical grid approximate pressure (Pa)
+  REAL,INTENT(IN) :: pseudoalt(:) ! vertical grid approximate altitude (km)
+  
+  
+  INTEGER :: data_ibegin, data_iend
+  TYPE(xios_duration) :: timestep
+  TYPE(xios_date) :: time_origin
+  TYPE(xios_date) :: start_date
+  
+!$OMP BARRIER
+!$OMP MASTER
+
+    ! 1. Declare available vertical axes to be used in output files:
+    IF (prt_level>=10) WRITE(lunout,*) "initialize_xios_output: call xios_set_axis_attr for presnivs"
+    CALL xios_set_axis_attr("presnivs", n_glo=size(presnivs), value=presnivs,&
+                            unit="Pa",positive="down")
+    IF (prt_level>=10) WRITE(lunout,*) "initialize_xios_output: call xios_set_axis_attr for altitude"
+    CALL xios_set_axis_attr("altitude", n_glo=size(pseudoalt), value=pseudoalt,&
+                            unit="km",positive="up")
+    
+    ! 2. Declare horizontal domain
+    ! Set values for the mask:
+    IF (mpi_rank == 0) THEN
+        data_ibegin = 0
+    ELSE 
+        data_ibegin = ii_begin - 1
+    END IF
+
+    IF (mpi_rank == mpi_size-1) THEN
+        data_iend = nbp_lon
+    ELSE
+        data_iend = ii_end + 1
+    END IF
+
+    if (prt_level>=10) then
+      write(lunout,*) "initialize_xios_output: mpirank=",mpi_rank," iibegin=",ii_begin , " ii_end=",ii_end," jjbegin=",jj_begin," jj_nb=",jj_nb," jj_end=",jj_end
+      write(lunout,*) "initialize_xios_output: mpirank=",mpi_rank," nbp_lon=",nbp_lon," nbp_lat=",nbp_lat
+      write(lunout,*) "initialize_xios_output: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
+      write(lunout,*) "initialize_xios_output: mpirank=",mpi_rank," data_ibegin=",data_ibegin," data_iend=",data_iend
+      write(lunout,*) "initialize_xios_output: mpirank=",mpi_rank," is_south_pole=",is_south_pole_dyn
+    endif
+
+    ! Initialize the XIOS domain coreesponding to this process:
+    if (prt_level>=10) write(lunout,*) "initialize_xios_output: call wxios_domain_param"
+    CALL wxios_domain_param("dom_glo", is_sequential, nbp_lon, jj_nb, nbp_lon, nbp_lat, &
+                            1, nbp_lon, ii_begin, ii_end, jj_begin, jj_end,             &
+                            klon_mpi+2*(nbp_lon-1), data_ibegin, data_iend,             &
+                            lat_reg*(180./pi), lon_reg*(180./pi),                       &
+                            is_south_pole_dyn,mpi_rank)
+
+    ! 3. Declare calendar and time step
+    if (prt_level>=10) write(lunout,*) "initialize_xios_output: build calendar"
+    timestep%second=dtphys
+    ! time origin of the simulation (default: 1st year/1st month/1st day, Ls=0)
+    time_origin=xios_date(1,1,1,0,0,0)
+    ! start date of the simulation (i.e time elapsed since last Ls=0)
+    start_date=xios_date(1,1,1,0,0,nint((day+timeofday)*daysec))
+    CALL xios_define_calendar(type="user_defined", &
+                              timestep=timestep, &
+                              day_length=nint(daysec), &
+                              start_date=start_date, &
+                              time_origin=time_origin, &
+                              month_lengths=[30,30,30,30,30,30,30,30,30,30,30,30])
+    
+    ! 4. Finalize the context:
+    if (prt_level>=10) write(*,*) "initialize_xios_output: call wxios_closedef"
+    CALL wxios_closedef()
+
+!$OMP END MASTER
+!$OMP BARRIER
+  
+  END SUBROUTINE initialize_xios_output
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE finalize_xios_output
+  USE xios
+  IMPLICIT NONE
+!$OMP BARRIER    
+!$OMP MASTER
+    CALL xios_context_finalize
+!$OMP END MASTER    
+!$OMP BARRIER    
+  
+  END SUBROUTINE finalize_xios_output
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE update_xios_timestep
+  USE xios
+  IMPLICIT NONE
+    CALL set_xios_context
+!$OMP MASTER
+    time_it=time_it+1
+    CALL xios_update_calendar(time_it)
+!$OMP END MASTER    
+  END SUBROUTINE update_xios_timestep
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE set_xios_context
+  USE XIOS
+  IMPLICIT NONE
+    TYPE(xios_context) :: ctx_hdl
+
+!$OMP MASTER
+    CALL xios_get_handle(context_id,ctx_hdl)
+    CALL xios_set_current_context(ctx_hdl)
+!$OMP END MASTER    
+  END SUBROUTINE set_xios_context
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE histwrite0d_xios(field_name,field)
+  USE xios, ONLY: xios_send_field
+  USE print_control_mod, ONLY: prt_level, lunout
+  IMPLICIT NONE
+  
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, INTENT(IN) :: field
+    
+    IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite0d_xios ',trim(field_name)
+    
+!$OMP MASTER
+    CALL xios_send_field(field_name,field)
+!$OMP END MASTER
+    
+    IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite0d_xios ',trim(field_name)
+    
+  END SUBROUTINE histwrite0d_xios
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE histwrite2d_xios(field_name,field)
+  USE dimphy, only: klon
+  USE mod_phys_lmdz_para, only: gather_omp, grid1Dto2D_mpi, &
+                                jj_nb, klon_mpi
+  USE xios, only: xios_send_field
+  USE print_control_mod, ONLY: prt_level, lunout
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon
+  IMPLICIT NONE
+
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, DIMENSION(:), INTENT(IN) :: field
+      
+    REAL,DIMENSION(klon_mpi) :: buffer_omp
+    REAL :: Field2d(nbp_lon,jj_nb)
+
+    IF (prt_level >= 10) WRITE(lunout,*)'Begin histrwrite2d_xios ',trim(field_name)
+
+    IF (SIZE(field)/=klon) CALL abort_physic('iophy::histwrite2d_xios','Field first DIMENSION not equal to klon',1)
+    
+    CALL Gather_omp(field,buffer_omp)    
+!$OMP MASTER
+    CALL grid1Dto2D_mpi(buffer_omp,Field2d)
+    
+    CALL xios_send_field(field_name, Field2d)
+!$OMP END MASTER   
+
+    IF (prt_level >= 10) WRITE(lunout,*)'End histrwrite2d_xios ',trim(field_name)
+  END SUBROUTINE histwrite2d_xios
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  SUBROUTINE histwrite3d_xios(field_name, field)
+  USE dimphy, only: klon, klev
+  USE mod_phys_lmdz_para, only: gather_omp, grid1Dto2D_mpi, &
+                                jj_nb, klon_mpi
+  USE xios, only: xios_send_field
+  USE print_control_mod, ONLY: prt_level,lunout
+  USE mod_grid_phy_lmdz, ONLY: nbp_lon
+
+  IMPLICIT NONE
+
+    CHARACTER(LEN=*), INTENT(IN) :: field_name
+    REAL, DIMENSION(:,:), INTENT(IN) :: field ! --> field(klon,:)
+
+    REAL,DIMENSION(klon_mpi,SIZE(field,2)) :: buffer_omp
+    REAL :: Field3d(nbp_lon,jj_nb,SIZE(field,2))
+    INTEGER :: ip, n, nlev
+
+  IF (prt_level >= 10) write(lunout,*)'Begin histrwrite3d_xios ',trim(field_name)
+
+    !Et on.... écrit
+    IF (SIZE(field,1)/=klon) CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
+    nlev=SIZE(field,2)
+
+
+    CALL Gather_omp(field,buffer_omp)
+!$OMP MASTER
+    CALL grid1Dto2D_mpi(buffer_omp,field3d)
+
+    CALL xios_send_field(field_name, Field3d(:,:,1:nlev))
+!$OMP END MASTER   
+
+    IF (prt_level >= 10) write(lunout,*)'End histrwrite3d_xios ',trim(field_name)
+  END SUBROUTINE histwrite3d_xios
+
+#endif
+
+END MODULE xios_output_mod
Index: /trunk/LMDZ.TITAN/libf/phytitan/zerophys.F
===================================================================
--- /trunk/LMDZ.TITAN/libf/phytitan/zerophys.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/libf/phytitan/zerophys.F	(revision 1644)
@@ -0,0 +1,11 @@
+      SUBROUTINE zerophys(n,x)
+      IMPLICIT NONE
+      INTEGER n
+      REAL x(n)
+      INTEGER i
+
+      DO i=1,n
+         x(i)=0.
+      ENDDO
+      RETURN
+      END
Index: /trunk/LMDZ.TITAN/makegcm
===================================================================
--- /trunk/LMDZ.TITAN/makegcm	(revision 1644)
+++ /trunk/LMDZ.TITAN/makegcm	(revision 1644)
@@ -0,0 +1,1 @@
+link makegcm_ifort
Index: /trunk/LMDZ.TITAN/makegcm_gfortran
===================================================================
--- /trunk/LMDZ.TITAN/makegcm_gfortran	(revision 1644)
+++ /trunk/LMDZ.TITAN/makegcm_gfortran	(revision 1644)
@@ -0,0 +1,849 @@
+#!/bin/csh -f
+# $Header: /users/lmdz/cvsroot/LMDZ.3.3/makegcm,v 1.21 2001/07/04 08:41:44 lmdz Exp $
+#set verbose echo
+########################################################################
+# options par defaut pour la commande make
+########################################################################
+set dim="64x48x32"
+set physique=std
+set phys="PHYS=$physique"
+set include='-I$(LIBF)/grid -I$(LIBF)/misc -I. -I$(LIBF)/dynphy_lonlat'
+set ntrac = 1
+set filtre=filtrez
+set grille=reg
+set dyntype="dyn"
+set bands="32x36"
+set scatterers="1"
+set full=""
+#src_dirs: directories containing source files 
+set src_dirs="grid misc" 
+
+########################################################################
+# path a changer contenant les sources et les objets du modele
+########################################################################
+
+#### If you want you can set environment variables here
+# default LMDGCM is where the makegcm script is:
+#setenv LMDGCM `pwd`"/"`dirname $0` # only works for relative paths
+set scriptdir=`dirname $0`
+setenv LMDGCM `readlink -f $scriptdir`
+#setenv LMDGCM "/san/home/rdword/gcm/LMDZ.GENERIC"
+setenv LIBOGCM $LMDGCM/libo
+# NetCDF, on LMD computers:
+setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_gfortran/lib
+setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_gfortran/include
+#####
+# Adapt example below to your personal machine (here "antolini"), if necessary
+if (`hostname -s` == "antolini" ) then
+  setenv NCDFLIB /home/MILLOUR/netcdf64-4.0.1_gfortran/lib
+  setenv NCDFINC /home/MILLOUR/netcdf64-4.0.1_gfortran/include
+endif
+
+setenv localdir "`pwd`"
+set MODIPSL=0
+echo $localdir | grep modipsl >& /dev/null
+if ( ! $status ) then
+  set MODIPSL=1
+  setenv LMDGCM $localdir
+  cd ../..
+  setenv LIBOGCM "`pwd`/lib"
+  cd $localdir
+  if ( `hostname` == rhodes ) then
+    set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
+    set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
+  else
+    if ( `hostname` == nymphea0 ) then
+      set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
+      set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
+    else
+      echo 'Probleme de definition des variables NCDFINC et NCDFLIB'
+    endif 
+  endif 
+else
+  if ( ! $?LMDGCM ) then
+    echo You must initialize the variable LMDGCM in your environnement
+    echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc
+    exit
+  endif
+  if ( ! $?LIBOGCM ) then
+    set LIBOGCM=$LMDGCM/libo
+  endif
+  if ( ! $?NCDFLIB ) then
+    echo You must initialize the variable NCDFLIB in your environnement
+    echo for instance: "setenv NCDFLIB /usr/myself/netcdf" in .cshrc
+    exit
+  endif
+  if ( ! $?NCDFINC ) then
+    echo You must initialize the variable NCDFINC in your environnement
+    echo for instance: "setenv NCDFINC /usr/myself/netcdf" in .cshrc
+    exit
+  endif
+endif
+set model=$LMDGCM
+set libo=$LIBOGCM
+
+########################################################################
+#  Les differentes platformes reconnues
+########################################################################
+
+set HP=0
+set IBM=0
+set SUN=0
+set VPP=0
+set CRAY=0
+set DEC=0
+set LINUX=0
+set NEC=0
+set XNEC=0
+if ( `uname` == HP-UX ) then
+   set machine=HP
+   set HP=1
+else if (`uname` == UNIX_System_V ) then
+   set machine=VPP
+   set VPP=1
+else if (`uname` == SunOS ) then
+   set machine=SUN
+   set SUN=1
+else if ( `uname` == AIX ) then
+   set machine=IBM
+   set IBM=1
+else if ( `uname` == OSF1 ) then
+   set machine=ALPHA
+   set DEC=1
+else if ( `uname` == Linux ) then
+   set machine=LINUX
+   set LINUX=1
+else if ( `hostname` == atlas || `hostname` == axis  || `hostname` == etoile ) then
+   set machine=CRAY
+   set CRAY=1
+else if ( `uname` == SUPER-UX ) then
+   set machine=NEC
+   set NEC=1
+else if ( `hostname` == rhodes) then
+   set machine=XNEC
+   set XNEC=1
+else if ( `uname` == CYGWIN_NT-6.1-WOW64) then
+   set machine=LINUX
+   set LINUX=1
+else
+   echo Vous travaillez sur une machine non prevue par le reglement
+   exit
+endif
+
+# create $libo directory if it doesn't exist
+if ( ! -d $libo )  then
+   mkdir $libo
+endif
+
+if $VPP then
+set netcdf=netcdf_v
+else 
+set netcdf=netcdf
+endif
+########################################################################
+#  Quelques initialisations de variables du shell.
+########################################################################
+
+set dyn=
+set opt_link=""
+set adjnt=""
+set opt_dep=""
+
+set optim90=""
+set oplink=""
+
+########################################################################
+#  Optimisations par defaut suivant les machines
+########################################################################
+
+echo "Optimisations par defaut suivant les machines"
+set libf=$model/libf
+#setenv localdir "LOCAL_DIR=`pwd`"
+#setenv localdir "`pwd`"
+cd $model
+if $CRAY then
+   set optim90="-Wp'-P' -DCRAY "'-p$(LIBO) -eiv '
+   set oplink="-Wl'-DSTACK=128 -f indef' -L$NCDFLIB -lnetcdf "
+   set mod_loc_dir=" "
+   set mod_suffix=" "
+else if $SUN then
+   set optim90=" -fast"
+   set optimtru90=" -fast -free"
+   set opt_link="-L$NCDFLIB -lnetcdf"
+   set mod_loc_dir=$localdir
+   set mod_suffix=mod
+else if $HP then
+else if $IBM then
+else if $VPP then
+   set optim90="$optim -X9 -w"
+   if $COUPLE then
+     set opt_link="-Wg,-c $IOIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl"
+     set oplink="-Wl,-t,-P,-dy "
+   else
+     set opt_link="-Wg,-c /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl"
+     set oplink="-Wl,-t,-dy "
+   endif
+   set mod_loc_dir=$IOIPSLDIR
+   set mod_suffix=mod
+else if $DEC then
+else if $LINUX then
+
+# Ehouarn 'gfortran' compiler
+   set optim="-O3 -funroll-loops "
+   set optim90="-O3 -funroll-loops "
+   set optimtru90="-O3 -funroll-loops "
+   set opt_link=" -L$NCDFLIB -lnetcdf "
+
+   #NB: on gnome -O3 ==> NaNs ...
+   #set optim=" -O2 -ip -mkl=sequential -align common "
+   #set optim90=" -O2 -ip -mkl=sequential -align common "
+   #set optimtru90=" -O2 -ip -mkl=sequential -align common "
+
+   set mod_loc_dir="./"
+   set mod_suffix=mod
+else if $NEC then
+   set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
+   set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
+###   set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lioipsl  -L/u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v "
+   set opt_link=" -C hopt -float0 -ew -P static -L/SX/usr/local/lib  -lnetcdf_i8r8 "
+   set mod_loc_dir="."
+   set mod_suffix="mod"
+else if $XNEC then
+   set optim90=' -clear -R5 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
+   set optimtru90=' -clear -R5 -f4 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
+   if $MODIPSL then
+     if $COUPLE then
+       set opt_link="-L$IOIPSLDIR -lsxioipsl -loasis2.4_mpi2 -float0 -ew -P static -I$NCDFINC $NCDFLIB "
+     else
+       set opt_link="-L$IOIPSLDIR -lsxioipsl -float0 -ew -P static -I$NCDFINC $NCDFLIB "
+     endif
+     set mod_loc_dir="./"
+   else
+     set opt_link=" -C hopt -float0 -ew -P static -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8"
+     set mod_loc_dir="."
+   endif
+   set mod_suffix="mod"
+
+endif
+
+set nomlib=${machine}_gfortran
+
+# Impose distinct name for 64 bit Linux machines (to avoid mixing 32 and 64)
+if (`uname` == Linux && `uname -m` == "x86_64") then
+  set nomlib=${machine}64_gfortran
+endif
+
+########################################################################
+# lecture des options de mymake
+########################################################################
+
+top:
+if ($#argv > 0) then
+    switch ($1:q)
+
+    case -h:
+
+########################################################################
+# Manuel en ligne
+########################################################################
+more <<eod
+
+
+makegcm [Options] prog
+
+
+The makegcm script:
+-------------------
+
+1. compiles a series of subroutines located in the $LMDGCM/libf
+ sub-directories.
+ The objects are then stored in the libraries in $LIBOGCM.
+
+2. then, makegcm compiles program prog.f located by default in
+$LMDGCM/libf/dyn3d and makes the link with the libraries.
+
+Environment Variables '$LMDGCM' and '$LIBOGCM'
+ must be set as environment variables or directly
+ in the makegcm file.
+
+The makegcm command is used to control the different versions of the model
+ in parallel, compiled using the compilation options 
+ and the various dimensions, without having to recompile the whole model.
+
+The FORTRAN libraries are stored in directory $LIBOGCM.
+
+
+OPTIONS:
+--------
+
+The following options can either be defined by default by editing the
+makegcm "script", or in interactive mode:
+
+-d imxjmxlm  where im, jm, and lm are the number of longitudes,
+             latitudes and vertical layers respectively.
+
+-s nscat   Number of radiatively active scatterers
+
+-p PHYS    Selects the set of physical parameterizations
+           you want to compile the model with.
+           The model is then compiled using the physical
+           parameterization sources in directory:
+            $LMDGCM/libf/phyPHYS
+
+-g grille  Selects the grid type.
+           This option overwrites file
+           $LMDGCM/libf/grid/fxyprim.h
+           with file
+           $LMDGCM/libf/grid/fxy_grille.h
+           the grid can take the following values:
+           1. reg - the regular grid
+           2. sin - to obtain equidistant points in terms of sin(latitude)
+           3. new - to zoom into a part of the globe
+
+-O "compilation options" set of fortran compilation options to use
+
+-include path
+           Used if the subroutines contain #include files (ccp) that 
+           are located in directories that are not referenced by default.
+
+-adjnt     Compiles the adjoint model to the dynamical code.
+
+-olddyn    To compile GCM with "old dynamics"
+
+-filtre  filter
+           To select the longitudinal filter in the polar regions.
+           "filter" corresponds to the name of a directory located in
+           $LMDGCM/libf. The standard filter for the model is "filtrez"
+           which can be used for a regular grid and for a  
+           grid with longitudinal zoom.
+
+-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
+           Adds a link to FORTRAN libraries
+           libfile1.a, libfile2.a ... 
+           located in directories dir1, dir2 ...respectively
+           If dirn is a directory with an automatic path 
+           (/usr/lib ... for example) 
+           there is no need to specify  -Ldirn.
+
+-full      Full (re)compilation (from scratch)
+
+eod
+exit
+
+########################################################################
+# Lecture des differentes options
+########################################################################
+
+    case -d
+        set dim=$2 ; shift ; shift ; goto top
+                        
+    case -O:
+        set optim90="$2" ; set optim="$2" ; set optimtru90="$2" ; shift ; shift ; goto top
+
+     case -p
+        set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top
+
+     case -s
+        set scatterers="$2" ; shift ; goto top
+
+     case -g
+        set grille="$2" ; shift ; shift ; goto top
+
+    case -b
+        set bands=$2 ; shift ; shift ; goto top
+           
+     case -t
+        set ntrac=$2 ; shift ; shift ; goto top
+
+     case -include
+        set include="$include -I$2" ; shift ; shift ; goto top
+
+     case -adjnt
+        set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d "
+
+     case -olddyn
+        set dyntype="olddyn" ; shift; goto top
+
+     case -full
+        set full="full" ; shift ; goto top
+
+     case -filtre
+        set filtre=$2 ; shift ; shift ; goto top
+
+     case -link
+        set opt_link="$opt_link $2" ; shift ; shift ; goto top
+
+     case -debug
+        if $HP then
+           set optim90=" -g "
+        else if $SUN then
+           setenv PARALLEL 4
+           set optim90=" -g -C "
+           set optimtru90=" -g -C "
+        else if $CRAY then
+           set optim90="$optim90"" -G1 "
+        else if $LINUX then
+
+           ## for gfortran
+           set optim="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow"
+           set optim90="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow"
+           set optimtru90="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow"
+
+        else 
+           echo "pas d option debug predefinie pour cette machine"
+           exit
+        endif
+        shift ; goto top
+
+     default
+        set code="$1" ; shift ; goto top
+
+   endsw
+endif
+
+
+echo "apres les opts dim $dim"
+
+########################################################################
+# cas special sans physique
+########################################################################
+if ( "$physique" == 'nophys' ) then
+   set phys="L_PHY= LIBPHY="
+else
+   set src_dirs="$src_dirs phy_common phy$physique"
+   set include="$include "'-I$(LIBF)/phy_common  -I$(LIBF)/phy'"$physique"
+   set LIBPHY_COMMON='$(LIBO)/libphy_common.a'
+endif
+set libdyn_phy=""
+set LIBDYN_PHYS=""
+########################################################################
+#subtilites sur le nom de la librairie
+########################################################################
+
+
+\rm tmp ; touch tmp
+\rm tmp90 ; touch tmp90
+foreach i ( $optim90 )
+   echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g' -e 's/://g' -e 's/=//g' -e 's/%//g' >> tmp
+end
+set suf=
+foreach i ( `sort tmp | uniq ` )
+   set suf=$suf$i
+end
+if ( ! $IBM ) then
+   set nomlib="$nomlib$suf"
+endif
+if ( $DEC ) then
+   set nomlib=DEC
+endif
+
+# dimension
+echo "dimension avant sed $dim"
+if ( $IBM ) then
+   set dim=`echo $dim | sed -en 's/[^0-9]/ /g'`
+   set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'`
+else if ( $SUN || $XNEC ) then
+   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
+   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
+else
+     set dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
+     set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
+endif
+
+# bands
+echo "bands avant sed $bands"
+if ( $IBM ) then
+   set bands=`echo $bands | sed -en 's/[^0-9]/ /g'`
+   set bands_=`echo $bands | sed -en 's/[^0-9]/_/g'`
+else if ( $SUN || $XNEC ) then
+   set bands=`echo $bands | sed -e 's/[^0-9]/ /g'` 
+   set bands_=`echo $bands | sed -e 's/[^0-9]/_/g'`
+else
+     set bands=`echo $bands | sed -e 's/[^0-9]/ /g'`
+     set bands_=`echo $bands | sed -e 's/[^0-9]/_/g'`
+endif
+
+
+# build final name of libraries directory:
+if ( "$dyntype" == "olddyn" ) then
+  set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}_olddyn
+else
+  set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}
+endif
+
+# Append number of bands to nomlib (new for universal model)
+set nomlib=${nomlib}_${bands_}
+
+# Append 'physique' type, if it is not mars, to nomlib
+if ( "$physique" != "mars" ) then
+  set nomlib=${nomlib}_${physique}
+endif
+
+## M-A-F nomlib trop long sur CRAY pour ar
+if ( $CRAY ) then
+    set nomlib=F90_${dim_}_t${ntrac}
+endif
+if ( $NEC || $XNEC ) then
+    set nomlib=F90_${dim_}_t${ntrac}
+endif
+
+echo "calcul de la dimension"
+set dimc=`echo $dim | wc -w`
+
+if ( "$dimc" == "2" ) then
+  set include="$include "'-I$(LIBF)/dyn2d '
+  set dimh=$dim
+endif
+if ( "$dimc" == "3" ) then
+  if ( "$dyntype" == "olddyn" ) then
+    set include="$include "'-I$(LIBF)/olddyn3d '
+    set src_dirs="$src_dirs olddyn3d dynphy_lonlat dynphy_lonlat/phy$physique"
+  else
+    set include="$include "'-I$(LIBF)/dyn3d '
+    set src_dirs="$src_dirs dyn3d dynphy_lonlat dynphy_lonlat/phy$physique"
+  endif
+  set libdyn_phy="-ldynphy_lonlat"
+  set LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a'
+  set dimh=`echo $dim | awk ' { print $1 "." $2 } '`
+endif
+echo "dimc is $dimc"
+
+########################################################################
+# path pour les #include
+########################################################################
+
+set include="$include -I$NCDFINC "
+echo $include
+
+########################################################################
+# Gestion des dimensions du modele.
+# on cree ou remplace le fichier des dimensions/nombre de traceur
+########################################################################
+
+cd $libf/grid
+if ( -f dimensions.h ) then
+  echo "WARNING: you are already compiling the model somewhere else"
+  echo "Wait until the first compilation is finished before starting."
+  echo "If you are sure that you are not compiling elsewhere, you can"
+  echo "type [yes] to continue."
+  echo "Do you want to continue?"
+  if ( $< == "yes" ) then
+    #remove old dimensions.h , bands.h and scatterers.h files
+    \rm -f $libf/grid/dimensions.h
+    \rm -f $libf/grid/bands.h
+    \rm -f $libf/phy${physique}/bands.h
+    \rm -f $libf/phy${physique}/scatterers.h
+  else
+    exit
+  endif
+endif
+
+# Build the appropriate 'dimensions.h' file
+cd dimension
+./makdim $dim
+# echo contents of dimensions.h to standard output
+cat $libf/grid/dimensions.h
+
+# Build the appropriate 'bands.h' file
+cd $libf/phy$physique/bands
+./makbands $bands
+# echo contents of bands.h to standard output
+cat $libf/phy$physique/bands.h
+
+# Build the appropriate 'scatterers.h' file
+cd $libf/phy$physique/scatterers
+./make_scatterers $scatterers
+# echo contents of scatterers.h to standard output
+cat $libf/phy$physique/scatterers.h
+
+cd $LMDGCM
+# set path to objects directory
+set libo=$libo/$nomlib
+# create objects directory, if it doesn't exist
+if ( ! -d $libo )  then
+   mkdir $libo
+   cd $model
+endif
+
+########################################################################
+# Differentes dynamiques (3d, 2d, 1d)
+########################################################################
+
+set dimension=`echo $dim | wc -w`
+echo dimension $dimension dim $dim
+if ( $dimension == 1 ) then
+  echo "No dynamics"
+##  set dyn="L_DYN= DYN= L_FILTRE= "
+## NB: we still need to have L_DYN=libdyn3d to reach routines and module
+## objects which are located in dyn3d
+  set dyntype=""
+  set filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
+  set dyn="L_DYN= DYN= L_FILTRE= "
+  set dirmain="phy$physique/dyn1d"
+  set src_dirs="$src_dirs phy$physique/dyn1d "
+  set include="$include "' -I$(LIBF)/phy'"$physique"'/dyn1d'
+endif
+endif
+
+cd $model
+if ( $dimension == 3 ) then
+  cd libf/grid
+  \rm fxyprim.h
+  cp -p fxy_${grille}.h fxyprim.h
+endif
+
+######################################################################
+# Gestion du filtre qui n'existe qu'en 3d.
+######################################################################
+
+# set filtre to 'oldfiltrez' if using -olddyn option
+if ( "$dyntype" == "olddyn" ) then
+  set filtre="oldfiltrez"
+endif
+
+if ( `expr $dimc \> 2` == 1 ) then
+   set filtre="FILTRE=$filtre"
+   if ( "$dyntype" == "olddyn" ) then
+     set src_dirs="$src_dirs oldfiltrez"
+   else
+     set src_dirs="$src_dirs filtrez"
+   endif
+else
+   set filtre="FILTRE= L_FILTRE= L_DYN= "
+endif
+echo "MACRO FILTRE $filtre"
+
+echo "dimc $dimc"
+
+#cleanup for a full recompilation, if requested
+if ("$full" == "full") then
+# remove makefile and $libo
+  cd $model
+  \rm -f makefile
+  \rm -rf $libo/*
+endif
+
+########################################################################
+#  Avant de lancer le make, on recree le makefile si necessaire
+########################################################################
+# c'est a dire dans 3 cas:
+# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
+#    derniere creation du makefile
+# 2. si le fichier contenant cette liste "liste_des_sources"
+#    n'existe pas.
+# 3. Si le makefile n'existe pas.
+########################################################################
+
+cd $model
+find libf -name '*.[Fh]' -print | sort >! tmp77
+#find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90
+find libf -name '*.[Fh]90' -print | sort >> tmp90
+
+if (    `diff tmp77 liste_des_sources_f77 | wc -w` \
+     || `diff tmp90 liste_des_sources_f90 | wc -w` \
+     || ! -f makefile \
+     || ! -f liste_des_sources_f90 \
+     || ! -f liste_des_sources_f77 ) then
+        echo "les fichiers suivants ont ete crees ou detruits"
+        echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
+        diff liste_des_sources_f77 tmp77
+        diff liste_des_sources_f90 tmp90
+        \cp tmp77 liste_des_sources_f77
+        \cp tmp90 liste_des_sources_f90
+        echo "Remaking the makefile!"
+        echo "src_dirs: $src_dirs"
+        create_make_gcm $src_dirs >! tmp
+        \mv tmp makefile
+        echo "New makefile created."
+endif
+
+########################################################################
+#  Execution de la comande make
+########################################################################
+
+
+echo PHYSIQUE $phys
+echo dynamique $dyn $dimension
+echo OPTIM90="$optim90" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code
+echo PATH pour les fichiers INCLUDE $include
+echo OPLINK="$oplink"
+
+if $HP then
+   set f77='fort77 +OP'
+   set f90='jensaisrien'
+   set opt_link="$opt_link -lm"
+else  if $VPP then
+   set f77=frt
+   set f90=$f77
+else if $CRAY then
+   set f77=f90
+   set f90=f90
+else if $LINUX then
+# default for gfortran is that "free format" is up to 132 characters,
+# but we sometimes have more, so move that limit to 264 characters
+   set f77="gfortran -ffree-line-length-264"
+   set f90="gfortran -ffree-line-length-264"
+#   set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdff -lnetcdf "
+   set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdf "
+else if $SUN then
+   set f77=f90
+   set f90=f90
+else if $NEC then
+   set f77=f90
+   set f90=f90
+else if $XNEC then
+   set f77=sxmpif90
+   set f90=sxmpif90
+else
+   set f77=f77
+   set f90=f90
+endif
+
+cd $model
+
+if $VPP then
+  set make="gmake RANLIB=ls"
+else if $CRAY then
+  set make="make RANLIB=ls"
+else if $NEC then
+  set make="make RANLIB=ls"
+else if $LINUX then
+  set make="make -k RANLIB=ranlib"
+else if $XNEC then
+  set make="/usr/local/bin/gmake RANLIB=ls"
+  set make="/usr/freeware/bin/gmake RANLIB=ls"
+else
+  set make="make RANLIB=ranlib"
+endif
+
+#
+# etat0_netcdf a besoin d'info de la physique
+# A revoir
+set include="$include"" -I$libf/phy$physique"
+
+
+#################################################################
+# Execution de la comande make... ENFIN!
+#################################################################
+
+if $VPP then
+  set optim90=" $optim90 -Am -M$libo"
+  set optimtru90="$optim90"
+else if $SUN then
+ set optim90=" $optim90 -M$libo"
+ set optimtru90=" $optimtru90 "
+else if $NEC then
+ set optim90=" $optim90 -I$libo "
+else if $XNEC then
+ set optim90=" $optim90 -I$libo "
+ set optimtru90=" $optimtru90 -I$libo "
+else if $LINUX then
+# set optim="$optim -module $libo"
+# set optim90="$optim90 -module $libo"
+# set optimtru90="$optimtru90 -module $libo"
+# Ehouarn: remove set mod_loc_dir def below; mod_loc_dir=$localdir (set above)
+# set mod_loc_dir=$libo
+
+# Ehouarn : adapt to gfortran
+ set optim="$optim -I${libo}"
+ set optim90="$optim90 -I${libo}"
+ set optimtru90="$optimtru90 -ffree-form -I${libo}"
+
+endif
+
+set link="$f90 $optim90"
+
+set ar=ar
+
+if $XNEC then
+  set link="sxld $opt_link"
+  set link="$f90 "
+#  set ar=sxar
+endif
+
+cd $localdir
+
+set source_code=${code}.F
+# handle cases when the main program is in the physics directory
+set dirmain=dyn${dimc}d
+if ( -f $LMDGCM/libf/dyn3d/${code}.F90 ) then
+  set source_code=${code}.F90
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F90 ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F90
+endif
+if ( -f $LMDGCM/libf/dynphy_lonlat/phy${physique}/${code}.F ) then
+  set dirmain=dynphy_lonlat/phy${physique}
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/dynphy_lonlat/phy${physique}/${code}.F90 ) then
+  set dirmain=dynphy_lonlat/phy${physique}
+  set source_code=${code}.F90
+endif
+
+echo $make -f $LMDGCM/makefile \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+OPTIM="$optim" \
+OPTIM90="$optim90" \
+OPTIMTRU90="$optimtru90" \
+INCLUDE="$include" \
+$filtre \
+LIBO=$libo \
+$phys \
+LIBPHY_COMMON=${LIBPHY_COMMON} \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
+DIM=$dimc \
+DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
+L_ADJNT="$adjnt" \
+LOCAL_DIR="$localdir"  \
+F77="$f77" \
+F90="$f90" \
+OPLINK="$oplink" \
+LINK="$link" \
+GCM="$LMDGCM" \
+MOD_LOC_DIR=$mod_loc_dir \
+MOD_SUFFIX=$mod_suffix \
+AR=$ar \
+DIRMAIN=$dirmain \
+SOURCE=$source_code \
+PROG=$code
+
+
+$make -f $LMDGCM/makefile \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+OPTIM="$optim" \
+OPTIM90="$optim90" \
+OPTIMTRU90="$optimtru90" \
+INCLUDE="$include" \
+$filtre \
+LIBO=$libo \
+$phys \
+LIBPHY_COMMON=${LIBPHY_COMMON} \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
+DIM=$dimc \
+DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
+L_ADJNT="$adjnt" \
+LOCAL_DIR="$localdir"  \
+F77="$f77" \
+F90="$f90" \
+OPLINK="$oplink" \
+LINK="$link" \
+GCM="$LMDGCM" \
+MOD_LOC_DIR=$mod_loc_dir \
+MOD_SUFFIX=$mod_suffix \
+AR=$ar \
+DIRMAIN=$dirmain \
+SOURCE=$source_code \
+PROG=$code
+
+\rm -f $libf/grid/dimensions.h
+\rm -f $libf/grid/bands.h
+\rm -f $libf/phy$physique/bands.h
+\rm -f $libf/phy$physique/scatterers.h
Index: /trunk/LMDZ.TITAN/makegcm_ifort
===================================================================
--- /trunk/LMDZ.TITAN/makegcm_ifort	(revision 1644)
+++ /trunk/LMDZ.TITAN/makegcm_ifort	(revision 1644)
@@ -0,0 +1,846 @@
+#!/bin/csh -f
+# $Header: /users/lmdz/cvsroot/LMDZ.3.3/makegcm,v 1.21 2001/07/04 08:41:44 lmdz Exp $
+#set verbose echo
+########################################################################
+# options par defaut pour la commande make
+########################################################################
+set dim="64x48x32"
+set physique=std
+set phys="PHYS=$physique"
+set include='-I$(LIBF)/grid -I$(LIBF)/misc -I. -I$(LIBF)/dynphy_lonlat'
+set ntrac = 1
+set filtre=filtrez
+set grille=reg
+set dyntype="dyn"
+set bands="32x36"
+set scatterers="1"
+set full=""
+#src_dirs: directories containing source files 
+set src_dirs="grid misc" 
+
+########################################################################
+# path a changer contenant les sources et les objets du modele
+########################################################################
+
+#### If you want you can set environment variables here
+# default LMDGCM is where the makegcm script is:
+#setenv LMDGCM `pwd`"/"`dirname $0` # only works for relative paths
+set scriptdir=`dirname $0`
+setenv LMDGCM `readlink -f $scriptdir`
+#setenv LMDGCM "/san/home/rdword/gcm/LMDZ.GENERIC"
+setenv LIBOGCM $LMDGCM/libo
+## NetCDF, what is below is OK on Gnome
+if ( `hostname` == n201 ) then
+    echo "GNOME cluster"
+    setenv NCDFLIB /usr/local/lib
+    setenv NCDFINC /usr/local/include
+else if ( `hostname` == ciclad1.ipsl.jussieu.fr ) then
+    echo "CICLAD cluster"
+    setenv NCDFLIB /opt/netcdf/ifort/lib
+    setenv NCDFINC /opt/netcdf/ifort/include
+else if ( `hostname` == ada337 || `hostname` == ada338 ) then
+    echo "ADA cluster"
+    setenv NCDFLIB /smplocal/pub/NetCDF/4.1.3/seq/lib
+    setenv NCDFINC /smplocal/pub/NetCDF/4.1.3/seq/include
+else
+   # NetCDF, on LMD farm:
+    echo "LMD machines"
+    setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_ifort/lib
+    setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_ifort/include
+endif
+
+setenv localdir "`pwd`"
+set MODIPSL=0
+echo $localdir | grep modipsl >& /dev/null
+if ( ! $status ) then
+  set MODIPSL=1
+  setenv LMDGCM $localdir
+  cd ../..
+  setenv LIBOGCM "`pwd`/lib"
+  cd $localdir
+  if ( `hostname` == rhodes ) then
+    set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
+    set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
+  else
+    if ( `hostname` == nymphea0 ) then
+      set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
+      set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
+    else
+      echo 'Probleme de definition des variables NCDFINC et NCDFLIB'
+    endif 
+  endif 
+else
+  if ( ! $?LMDGCM ) then
+    echo You must initialize the variable LMDGCM in your environnement
+    echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc
+    exit
+  endif
+  if ( ! $?LIBOGCM ) then
+    set LIBOGCM=$LMDGCM/libo
+  endif
+  if ( ! $?NCDFLIB ) then
+    echo You must initialize the variable NCDFLIB in your environnement
+    echo for instance: "setenv NCDFLIB /usr/myself/netcdf" in .cshrc
+    exit
+  endif
+  if ( ! $?NCDFINC ) then
+    echo You must initialize the variable NCDFINC in your environnement
+    echo for instance: "setenv NCDFINC /usr/myself/netcdf" in .cshrc
+    exit
+  endif
+endif
+set model=$LMDGCM
+set libo=$LIBOGCM
+
+########################################################################
+#  Les differentes platformes reconnues
+########################################################################
+
+set HP=0
+set IBM=0
+set SUN=0
+set VPP=0
+set CRAY=0
+set DEC=0
+set LINUX=0
+set NEC=0
+set XNEC=0
+if ( `uname` == HP-UX ) then
+   set machine=HP
+   set HP=1
+else if (`uname` == UNIX_System_V ) then
+   set machine=VPP
+   set VPP=1
+else if (`uname` == SunOS ) then
+   set machine=SUN
+   set SUN=1
+else if ( `uname` == AIX ) then
+   set machine=IBM
+   set IBM=1
+else if ( `uname` == OSF1 ) then
+   set machine=ALPHA
+   set DEC=1
+else if ( `uname` == Linux ) then
+   set machine=LINUX
+   set LINUX=1
+else if ( `hostname` == atlas || `hostname` == axis  || `hostname` == etoile ) then
+   set machine=CRAY
+   set CRAY=1
+else if ( `uname` == SUPER-UX ) then
+   set machine=NEC
+   set NEC=1
+else if ( `hostname` == rhodes) then
+   set machine=XNEC
+   set XNEC=1
+else if ( `uname` == CYGWIN_NT-6.1-WOW64) then
+   set machine=LINUX
+   set LINUX=1
+else
+   echo Vous travaillez sur une machine non prevue par le reglement
+   exit
+endif
+
+# create $libo directory if it doesn't exist
+if ( ! -d $libo )  then
+   mkdir $libo
+endif
+
+if $VPP then
+set netcdf=netcdf_v
+else 
+set netcdf=netcdf
+endif
+########################################################################
+#  Quelques initialisations de variables du shell.
+########################################################################
+
+set dyn=
+set opt_link=""
+set adjnt=""
+set opt_dep=""
+
+set optim90=""
+set oplink=""
+
+########################################################################
+#  Optimisations par defaut suivant les machines
+########################################################################
+
+echo "Optimisations par defaut suivant les machines"
+set libf=$model/libf
+#setenv localdir "LOCAL_DIR=`pwd`"
+#setenv localdir "`pwd`"
+cd $model
+if $CRAY then
+   set optim90="-Wp'-P' -DCRAY "'-p$(LIBO) -eiv '
+   set oplink="-Wl'-DSTACK=128 -f indef' -L$NCDFLIB -lnetcdf "
+   set mod_loc_dir=" "
+   set mod_suffix=" "
+else if $SUN then
+   set optim90=" -fast"
+   set optimtru90=" -fast -free"
+   set opt_link="-L$NCDFLIB -lnetcdf"
+   set mod_loc_dir=$localdir
+   set mod_suffix=mod
+else if $HP then
+else if $IBM then
+else if $VPP then
+   set optim90="$optim -X9 -w"
+   if $COUPLE then
+     set opt_link="-Wg,-c $IOIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl"
+     set oplink="-Wl,-t,-P,-dy "
+   else
+     set opt_link="-Wg,-c /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl"
+     set oplink="-Wl,-t,-dy "
+   endif
+   set mod_loc_dir=$IOIPSLDIR
+   set mod_suffix=mod
+else if $DEC then
+else if $LINUX then
+   #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 "
+   if ( `hostname` == ciclad1.ipsl.jussieu.fr ) then
+       echo "YOU ARE ON CICLAD CLUSTER"
+       set opt_link=" -L$NCDFLIB -lnetcdf"  # this is necessary on ciclad
+   endif
+   set mod_loc_dir=$LIBOGCM
+   set mod_suffix=mod
+else if $NEC then
+   set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
+   set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
+###   set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lioipsl  -L/u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v "
+   set opt_link=" -C hopt -float0 -ew -P static -L/SX/usr/local/lib  -lnetcdf_i8r8 "
+   set mod_loc_dir="."
+   set mod_suffix="mod"
+else if $XNEC then
+   set optim90=' -clear -R5 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
+   set optimtru90=' -clear -R5 -f4 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
+   if $MODIPSL then
+     if $COUPLE then
+       set opt_link="-L$IOIPSLDIR -lsxioipsl -loasis2.4_mpi2 -float0 -ew -P static -I$NCDFINC $NCDFLIB "
+     else
+       set opt_link="-L$IOIPSLDIR -lsxioipsl -float0 -ew -P static -I$NCDFINC $NCDFLIB "
+     endif
+     set mod_loc_dir="./"
+   else
+     set opt_link=" -C hopt -float0 -ew -P static -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8"
+     set mod_loc_dir="."
+   endif
+   set mod_suffix="mod"
+
+endif
+
+set nomlib=${machine}
+
+# Impose distinct name for 64 bit Linux machines (to avoid mixing 32 and 64)
+if (`uname` == Linux && `uname -m` == "x86_64") then
+  set nomlib=${machine}64
+endif
+
+########################################################################
+# lecture des options de mymake
+########################################################################
+
+top:
+if ($#argv > 0) then
+    switch ($1:q)
+
+    case -h:
+
+########################################################################
+# Manuel en ligne
+########################################################################
+more <<eod
+
+
+makegcm [Options] prog
+
+
+The makegcm script:
+-------------------
+
+1. compiles a series of subroutines located in the $LMDGCM/libf
+ sub-directories.
+ The objects are then stored in the libraries in $LIBOGCM.
+
+2. then, makegcm compiles program prog.f located by default in
+$LMDGCM/libf/dyn3d and makes the link with the libraries.
+
+Environment Variables '$LMDGCM' and '$LIBOGCM'
+ must be set as environment variables or directly
+ in the makegcm file.
+
+The makegcm command is used to control the different versions of the model
+ in parallel, compiled using the compilation options 
+ and the various dimensions, without having to recompile the whole model.
+
+The FORTRAN libraries are stored in directory $LIBOGCM.
+
+
+OPTIONS:
+--------
+
+The following options can either be defined by default by editing the
+makegcm "script", or in interactive mode:
+
+-d imxjmxlm  where im, jm, and lm are the number of longitudes,
+             latitudes and vertical layers respectively.
+
+-s nscat   Number of radiatively active scatterers
+
+-p PHYS    Selects the set of physical parameterizations
+           you want to compile the model with.
+           The model is then compiled using the physical
+           parameterization sources in directory:
+            $LMDGCM/libf/phyPHYS
+
+-g grille  Selects the grid type.
+           This option overwrites file
+           $LMDGCM/libf/grid/fxyprim.h
+           with file
+           $LMDGCM/libf/grid/fxy_grille.h
+           the grid can take the following values:
+           1. reg - the regular grid
+           2. sin - to obtain equidistant points in terms of sin(latitude)
+           3. new - to zoom into a part of the globe
+
+-O "compilation options" set of fortran compilation options to use
+
+-include path
+           Used if the subroutines contain #include files (ccp) that 
+           are located in directories that are not referenced by default.
+
+-adjnt     Compiles the adjoint model to the dynamical code.
+
+-olddyn    To compile GCM with "old dynamics"
+
+-filtre  filter
+           To select the longitudinal filter in the polar regions.
+           "filter" corresponds to the name of a directory located in
+           $LMDGCM/libf. The standard filter for the model is "filtrez"
+           which can be used for a regular grid and for a  
+           grid with longitudinal zoom.
+
+-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
+           Adds a link to FORTRAN libraries
+           libfile1.a, libfile2.a ... 
+           located in directories dir1, dir2 ...respectively
+           If dirn is a directory with an automatic path 
+           (/usr/lib ... for example) 
+           there is no need to specify  -Ldirn.
+
+-full      Full (re)compilation (from scratch)
+
+eod
+exit
+
+########################################################################
+# Lecture des differentes options
+########################################################################
+
+    case -d
+        set dim=$2 ; shift ; shift ; goto top
+                        
+    case -O:
+        set optim90="$2" ; set optim="$2" ; set optimtru90="$2" ; shift ; shift ; goto top
+
+     case -p
+        set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top
+
+     case -s
+        set scatterers="$2" ; shift ; goto top
+
+     case -g
+        set grille="$2" ; shift ; shift ; goto top
+
+    case -b
+        set bands=$2 ; shift ; shift ; goto top
+           
+     case -t
+        set ntrac=$2 ; shift ; shift ; goto top
+
+     case -include
+        set include="$include -I$2" ; shift ; shift ; goto top
+
+     case -adjnt
+        set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d "
+
+     case -olddyn
+        set dyntype="olddyn" ; shift; goto top
+
+     case -full
+        set full="full" ; shift ; goto top
+
+     case -filtre
+        set filtre=$2 ; shift ; shift ; goto top
+
+     case -link
+        set opt_link="$opt_link $2" ; shift ; shift ; goto top
+
+     case -debug
+        if $HP then
+           set optim90=" -g "
+        else if $SUN then
+           setenv PARALLEL 4
+           set optim90=" -g -C "
+           set optimtru90=" -g -C "
+        else if $CRAY then
+           set optim90="$optim90"" -G1 "
+        else if $LINUX then
+	   set optim=" -g -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug"
+           set optim90=" -g -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug"
+           set optimtru90=" -g -fpe-all=0 -traceback -ftrapuv -fp-stack-check -check all -debug"
+        else 
+           echo "pas d option debug predefinie pour cette machine"
+           exit
+        endif
+        shift ; goto top
+
+     default
+        set code="$1" ; shift ; goto top
+
+   endsw
+endif
+
+
+echo "apres les opts dim $dim"
+
+########################################################################
+# cas special sans physique
+########################################################################
+if ( "$physique" == 'nophys' ) then
+   set phys="L_PHY= LIBPHY="
+else
+   set src_dirs="$src_dirs phy_common phy$physique"
+   set include="$include "'-I$(LIBF)/phy_common  -I$(LIBF)/phy'"$physique"
+   set LIBPHY_COMMON='$(LIBO)/libphy_common.a'
+endif
+set libdyn_phy=""
+set LIBDYN_PHYS=""
+########################################################################
+#subtilites sur le nom de la librairie
+########################################################################
+
+
+\rm tmp ; touch tmp
+\rm tmp90 ; touch tmp90
+foreach i ( $optim90 )
+   echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g' -e 's/://g' -e 's/=//g' -e 's/%//g' >> tmp
+end
+set suf=
+foreach i ( `sort tmp | uniq ` )
+   set suf=$suf$i
+end
+if ( ! $IBM ) then
+   set nomlib="$nomlib$suf"
+endif
+if ( $DEC ) then
+   set nomlib=DEC
+endif
+
+# dimension
+echo "dimension avant sed $dim"
+if ( $IBM ) then
+   set dim=`echo $dim | sed -en 's/[^0-9]/ /g'`
+   set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'`
+else if ( $SUN || $XNEC ) then
+   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
+   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
+else
+     set dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
+     set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
+endif
+
+# bands
+echo "bands avant sed $bands"
+if ( $IBM ) then
+   set bands=`echo $bands | sed -en 's/[^0-9]/ /g'`
+   set bands_=`echo $bands | sed -en 's/[^0-9]/_/g'`
+else if ( $SUN || $XNEC ) then
+   set bands=`echo $bands | sed -e 's/[^0-9]/ /g'` 
+   set bands_=`echo $bands | sed -e 's/[^0-9]/_/g'`
+else
+     set bands=`echo $bands | sed -e 's/[^0-9]/ /g'`
+     set bands_=`echo $bands | sed -e 's/[^0-9]/_/g'`
+endif
+
+
+# build final name of libraries directory:
+if ( "$dyntype" == "olddyn" ) then
+  set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}_olddyn
+else
+  set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}
+endif
+
+# Append number of bands to nomlib (new for universal model)
+set nomlib=${nomlib}_${bands_}
+
+# Append 'physique' type, if it is not mars, to nomlib
+if ( "$physique" != "mars" ) then
+  set nomlib=${nomlib}_${physique}
+endif
+
+## M-A-F nomlib trop long sur CRAY pour ar
+if ( $CRAY ) then
+    set nomlib=F90_${dim_}_t${ntrac}
+endif
+if ( $NEC || $XNEC ) then
+    set nomlib=F90_${dim_}_t${ntrac}
+endif
+
+echo "calcul de la dimension"
+set dimc=`echo $dim | wc -w`
+
+if ( "$dimc" == "2" ) then
+  set include="$include "'-I$(LIBF)/dyn2d '
+  set dimh=$dim
+endif
+if ( "$dimc" == "3" ) then
+  if ( "$dyntype" == "olddyn" ) then
+    set include="$include "'-I$(LIBF)/olddyn3d '
+    set src_dirs="$src_dirs olddyn3d dynphy_lonlat dynphy_lonlat/phy$physique"
+  else
+    set include="$include "'-I$(LIBF)/dyn3d '
+    set src_dirs="$src_dirs dyn3d dynphy_lonlat dynphy_lonlat/phy$physique"
+  endif
+  set libdyn_phy="-ldynphy_lonlat"
+  set LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a'
+  set dimh=`echo $dim | awk ' { print $1 "." $2 } '`
+endif
+echo "dimc is $dimc"
+
+########################################################################
+# path pour les #include
+########################################################################
+
+set include="$include -I$NCDFINC "
+echo $include
+
+########################################################################
+# Gestion des dimensions du modele.
+# on cree ou remplace le fichier des dimensions/nombre de traceur
+########################################################################
+
+cd $libf/grid
+if ( -f dimensions.h ) then
+  echo "WARNING: you are already compiling the model somewhere else"
+  echo "Wait until the first compilation is finished before starting."
+  echo "If you are sure that you are not compiling elsewhere, you can"
+  echo "type [yes] to continue."
+  echo "Do you want to continue?"
+  if ( $< == "yes" ) then
+    #remove old dimensions.h , bands.h and scatterers.h files
+    \rm -f $libf/grid/dimensions.h
+    \rm -f $libf/grid/bands.h
+    \rm -f $libf/phy${physique}/bands.h
+    \rm -f $libf/phy${physique}/scatterers.h
+  else
+    exit
+  endif
+endif
+
+# Build the appropriate 'dimensions.h' file
+cd dimension
+./makdim $dim
+# echo contents of dimensions.h to standard output
+cat $libf/grid/dimensions.h
+
+# Build the appropriate 'bands.h' file
+cd $libf/phy$physique/bands
+./makbands $bands
+# echo contents of bands.h to standard output
+cat $libf/phy$physique/bands.h
+
+# Build the appropriate 'scatterers.h' file
+cd $libf/phy$physique/scatterers
+./make_scatterers $scatterers
+# echo contents of scatterers.h to standard output
+cat $libf/phy$physique/scatterers.h
+
+cd $LMDGCM
+# set path to objects directory
+set libo=$libo/$nomlib
+# create objects directory, if it doesn't exist
+if ( ! -d $libo )  then
+   mkdir $libo
+   cd $model
+endif
+
+########################################################################
+# Differentes dynamiques (3d, 2d, 1d)
+########################################################################
+
+set dimension=`echo $dim | wc -w`
+echo dimension $dimension dim $dim
+if ( $dimension == 1 ) then
+  echo "No dynamics"
+##  set dyn="L_DYN= DYN= L_FILTRE= "
+## NB: we still need to have L_DYN=libdyn3d to reach routines and module
+## objects which are located in dyn3d
+  set dyntype=""
+  set filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
+  set dyn="L_DYN= DYN= L_FILTRE= "
+  set dirmain="phy$physique/dyn1d"
+  set src_dirs="$src_dirs phy$physique/dyn1d "
+  set include="$include "' -I$(LIBF)/phy'"$physique"'/dyn1d'
+endif
+endif
+
+cd $model
+if ( $dimension == 3 ) then
+  cd libf/grid
+  \rm fxyprim.h
+  cp -p fxy_${grille}.h fxyprim.h
+endif
+
+######################################################################
+# Gestion du filtre qui n'existe qu'en 3d.
+######################################################################
+
+# set filtre to 'oldfiltrez' if using -olddyn option
+if ( "$dyntype" == "olddyn" ) then
+  set filtre="oldfiltrez"
+endif
+
+if ( `expr $dimc \> 2` == 1 ) then
+   set filtre="FILTRE=$filtre"
+   if ( "$dyntype" == "olddyn" ) then
+     set src_dirs="$src_dirs oldfiltrez"
+   else
+     set src_dirs="$src_dirs filtrez"
+   endif
+else
+   set filtre="FILTRE= L_FILTRE= L_DYN= "
+endif
+echo "MACRO FILTRE $filtre"
+
+echo "dimc $dimc"
+
+#cleanup for a full recompilation, if requested
+if ("$full" == "full") then
+# remove makefile and $libo
+  cd $model
+  \rm -f makefile
+  \rm -rf $libo/*
+endif
+
+########################################################################
+#  Avant de lancer le make, on recree le makefile si necessaire
+########################################################################
+# c'est a dire dans 3 cas:
+# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
+#    derniere creation du makefile
+# 2. si le fichier contenant cette liste "liste_des_sources"
+#    n'existe pas.
+# 3. Si le makefile n'existe pas.
+########################################################################
+
+cd $model
+find libf -name '*.[Fh]' -print | sort >! tmp77
+#find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90
+find libf -name '*.[Fh]90' -print | sort >> tmp90
+
+if (    `diff tmp77 liste_des_sources_f77 | wc -w` \
+     || `diff tmp90 liste_des_sources_f90 | wc -w` \
+     || ! -f makefile \
+     || ! -f liste_des_sources_f90 \
+     || ! -f liste_des_sources_f77 ) then
+        echo "les fichiers suivants ont ete crees ou detruits"
+        echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
+        diff liste_des_sources_f77 tmp77
+        diff liste_des_sources_f90 tmp90
+        \cp tmp77 liste_des_sources_f77
+        \cp tmp90 liste_des_sources_f90
+        echo "Remaking the makefile!"
+        echo "src_dirs: $src_dirs"
+        ./create_make_gcm $src_dirs >! tmp
+        \mv tmp makefile
+        echo "New makefile created."
+endif
+
+########################################################################
+#  Execution de la comande make
+########################################################################
+
+
+echo PHYSIQUE $phys
+echo dynamique $dyn $dimension
+echo OPTIM90="$optim90" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code
+echo PATH pour les fichiers INCLUDE $include
+echo OPLINK="$oplink"
+
+if $HP then
+   set f77='fort77 +OP'
+   set f90='jensaisrien'
+   set opt_link="$opt_link -lm"
+else  if $VPP then
+   set f77=frt
+   set f90=$f77
+else if $CRAY then
+   set f77=f90
+   set f90=f90
+else if $LINUX then
+   set f77=ifort
+   set f90=ifort
+#### uncomment for double precision
+#   set f77="ifort -real-size 64 -DNC_DOUBLE"
+#   set f90="ifort -real-size 64 -DNC_DOUBLE"
+   set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdf "
+else if $SUN then
+   set f77=f90
+   set f90=f90
+else if $NEC then
+   set f77=f90
+   set f90=f90
+else if $XNEC then
+   set f77=sxmpif90
+   set f90=sxmpif90
+else
+   set f77=f77
+   set f90=f90
+endif
+
+cd $model
+
+if $VPP then
+  set make="gmake RANLIB=ls"
+else if $CRAY then
+  set make="make RANLIB=ls"
+else if $NEC then
+  set make="make RANLIB=ls"
+else if $LINUX then
+  set make="make -k RANLIB=ranlib"
+else if $XNEC then
+  set make="/usr/local/bin/gmake RANLIB=ls"
+  set make="/usr/freeware/bin/gmake RANLIB=ls"
+else
+  set make="make RANLIB=ranlib"
+endif
+
+#
+# etat0_netcdf a besoin d'info de la physique
+# A revoir
+set include="$include"" -I$libf/phy$physique"
+
+
+#################################################################
+# Execution de la comande make... ENFIN!
+#################################################################
+
+if $VPP then
+  set optim90=" $optim90 -Am -M$libo"
+  set optimtru90="$optim90"
+else if $SUN then
+ set optim90=" $optim90 -M$libo"
+ set optimtru90=" $optimtru90 "
+else if $NEC then
+ set optim90=" $optim90 -I$libo "
+else if $XNEC then
+ set optim90=" $optim90 -I$libo "
+ set optimtru90=" $optimtru90 -I$libo "
+else if $LINUX then
+ set optim="$optim -module $libo"
+ set optim90="$optim90 -module $libo"
+ set optimtru90="$optimtru90 -module $libo"
+# Ehouarn: remove set mod_loc_dir def below; mod_loc_dir=$localdir (set above)
+# set mod_loc_dir=$libo
+endif
+
+set link="$f90 $optim90"
+
+set ar=ar
+
+if $XNEC then
+  set link="sxld $opt_link"
+  set link="$f90 "
+#  set ar=sxar
+endif
+
+cd $localdir
+
+set source_code=${code}.F
+# handle cases when the main program is in the physics directory
+set dirmain=dyn${dimc}d
+if ( -f $LMDGCM/libf/dyn3d/${code}.F90 ) then
+  set source_code=${code}.F90
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F90 ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F90
+endif
+if ( -f $LMDGCM/libf/dynphy_lonlat/phy${physique}/${code}.F ) then
+  set dirmain=dynphy_lonlat/phy${physique}
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/dynphy_lonlat/phy${physique}/${code}.F90 ) then
+  set dirmain=dynphy_lonlat/phy${physique}
+  set source_code=${code}.F90
+endif
+
+echo $make -f $LMDGCM/makefile \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+OPTIM="$optim" \
+OPTIM90="$optim90" \
+OPTIMTRU90="$optimtru90" \
+INCLUDE="$include" \
+$filtre \
+LIBO=$libo \
+$phys \
+LIBPHY_COMMON=${LIBPHY_COMMON} \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
+DIM=$dimc \
+DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
+L_ADJNT="$adjnt" \
+LOCAL_DIR="$localdir"  \
+F77="$f77" \
+F90="$f90" \
+OPLINK="$oplink" \
+LINK="$link" \
+GCM="$LMDGCM" \
+MOD_LOC_DIR=$mod_loc_dir \
+MOD_SUFFIX=$mod_suffix \
+AR=$ar \
+DIRMAIN=$dirmain \
+SOURCE=$source_code \
+PROG=$code
+
+
+$make -f $LMDGCM/makefile \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+OPTIM="$optim" \
+OPTIM90="$optim90" \
+OPTIMTRU90="$optimtru90" \
+INCLUDE="$include" \
+$filtre \
+LIBO=$libo \
+$phys \
+LIBPHY_COMMON=${LIBPHY_COMMON} \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
+DIM=$dimc \
+DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
+L_ADJNT="$adjnt" \
+LOCAL_DIR="$localdir"  \
+F77="$f77" \
+F90="$f90" \
+OPLINK="$oplink" \
+LINK="$link" \
+GCM="$LMDGCM" \
+MOD_LOC_DIR=$mod_loc_dir \
+MOD_SUFFIX=$mod_suffix \
+AR=$ar \
+DIRMAIN=$dirmain \
+SOURCE=$source_code \
+PROG=$code
+
+\rm -f $libf/grid/dimensions.h
+\rm -f $libf/grid/bands.h
+\rm -f $libf/phy$physique/bands.h
+\rm -f $libf/phy$physique/scatterers.h
Index: /trunk/LMDZ.TITAN/makegcm_pgf90
===================================================================
--- /trunk/LMDZ.TITAN/makegcm_pgf90	(revision 1644)
+++ /trunk/LMDZ.TITAN/makegcm_pgf90	(revision 1644)
@@ -0,0 +1,844 @@
+#!/bin/csh -f
+# $Header: /users/lmdz/cvsroot/LMDZ.3.3/makegcm,v 1.21 2001/07/04 08:41:44 lmdz Exp $
+#set verbose echo
+########################################################################
+# options par defaut pour la commande make
+########################################################################
+set dim="64x48x32"
+set physique=std
+set phys="PHYS=$physique"
+set include='-I$(LIBF)/grid -I$(LIBF)/misc -I. -I$(LIBF)/dynphy_lonlat'
+set ntrac = 1
+set filtre=filtrez
+set grille=reg
+set dyntype="dyn"
+set bands="32x36"
+set scatterers="1"
+set full=""
+#src_dirs: directories containing source files 
+set src_dirs="grid misc" 
+
+########################################################################
+# path a changer contenant les sources et les objets du modele
+########################################################################
+
+#### If you want you can set environment variables here
+# default LMDGCM is where the makegcm script is:
+#setenv LMDGCM `pwd`"/"`dirname $0` # only works for relative paths
+set scriptdir=`dirname $0`
+setenv LMDGCM `readlink -f $scriptdir`
+#setenv LMDGCM "/san/home/rdword/gcm/LMDZ.GENERIC"
+setenv LIBOGCM $LMDGCM/libo
+# NetCDF, on LMD computers:
+setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_pgi/lib
+setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_pgi/include
+####
+# Adapt example below to your personal machine (here "antolini"), if necessary
+if (`hostname -s` == "antolini" ) then
+  setenv NCDFLIB /home/MILLOUR/netcdf64-4.0.1_pgi/lib
+  setenv NCDFINC /home/MILLOUR/netcdf64-4.0.1_pgi/include
+endif
+
+setenv localdir "`pwd`"
+set MODIPSL=0
+echo $localdir | grep modipsl >& /dev/null
+if ( ! $status ) then
+  set MODIPSL=1
+  setenv LMDGCM $localdir
+  cd ../..
+  setenv LIBOGCM "`pwd`/lib"
+  cd $localdir
+  if ( `hostname` == rhodes ) then
+    set NCDFINC=`grep sxnec ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
+    set NCDFLIB=`grep sxnec ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
+  else
+    if ( `hostname` == nymphea0 ) then
+      set NCDFINC=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_INC|sed -e "s/^.* =//"`
+      set NCDFLIB=`grep fjvpp ../../util/AA_make.gdef| grep NCDF_LIB|sed -e 's/^.* =//'`
+    else
+      echo 'Probleme de definition des variables NCDFINC et NCDFLIB'
+    endif 
+  endif 
+else
+  if ( ! $?LMDGCM ) then
+    echo You must initialize the variable LMDGCM in your environnement
+    echo for instance: "setenv LMDGCM /usr/myself/supergcm" in .cshrc
+    exit
+  endif
+  if ( ! $?LIBOGCM ) then
+    set LIBOGCM=$LMDGCM/libo
+  endif
+  if ( ! $?NCDFLIB ) then
+    echo You must initialize the variable NCDFLIB in your environnement
+    echo for instance: "setenv NCDFLIB /usr/myself/netcdf" in .cshrc
+    exit
+  endif
+  if ( ! $?NCDFINC ) then
+    echo You must initialize the variable NCDFINC in your environnement
+    echo for instance: "setenv NCDFINC /usr/myself/netcdf" in .cshrc
+    exit
+  endif
+endif
+set model=$LMDGCM
+set libo=$LIBOGCM
+
+########################################################################
+#  Les differentes platformes reconnues
+########################################################################
+
+set HP=0
+set IBM=0
+set SUN=0
+set VPP=0
+set CRAY=0
+set DEC=0
+set LINUX=0
+set NEC=0
+set XNEC=0
+if ( `uname` == HP-UX ) then
+   set machine=HP
+   set HP=1
+else if (`uname` == UNIX_System_V ) then
+   set machine=VPP
+   set VPP=1
+else if (`uname` == SunOS ) then
+   set machine=SUN
+   set SUN=1
+else if ( `uname` == AIX ) then
+   set machine=IBM
+   set IBM=1
+else if ( `uname` == OSF1 ) then
+   set machine=ALPHA
+   set DEC=1
+else if ( `uname` == Linux ) then
+   set machine=LINUX
+   set LINUX=1
+else if ( `hostname` == atlas || `hostname` == axis  || `hostname` == etoile ) then
+   set machine=CRAY
+   set CRAY=1
+else if ( `uname` == SUPER-UX ) then
+   set machine=NEC
+   set NEC=1
+else if ( `hostname` == rhodes) then
+   set machine=XNEC
+   set XNEC=1
+else if ( `uname` == CYGWIN_NT-6.1-WOW64) then
+   set machine=LINUX
+   set LINUX=1
+else
+   echo Vous travaillez sur une machine non prevue par le reglement
+   exit
+endif
+
+# create $libo directory if it doesn't exist
+if ( ! -d $libo )  then
+   mkdir $libo
+endif
+
+if $VPP then
+set netcdf=netcdf_v
+else 
+set netcdf=netcdf
+endif
+########################################################################
+#  Quelques initialisations de variables du shell.
+########################################################################
+
+set dyn=
+set opt_link=""
+set adjnt=""
+set opt_dep=""
+
+set optim90=""
+set oplink=""
+
+########################################################################
+#  Optimisations par defaut suivant les machines
+########################################################################
+
+echo "Optimisations par defaut suivant les machines"
+set libf=$model/libf
+#setenv localdir "LOCAL_DIR=`pwd`"
+#setenv localdir "`pwd`"
+cd $model
+if $CRAY then
+   set optim90="-Wp'-P' -DCRAY "'-p$(LIBO) -eiv '
+   set oplink="-Wl'-DSTACK=128 -f indef' -L$NCDFLIB -lnetcdf "
+   set mod_loc_dir=" "
+   set mod_suffix=" "
+else if $SUN then
+   set optim90=" -fast"
+   set optimtru90=" -fast -free"
+   set opt_link="-L$NCDFLIB -lnetcdf"
+   set mod_loc_dir=$localdir
+   set mod_suffix=mod
+else if $HP then
+else if $IBM then
+else if $VPP then
+   set optim90="$optim -X9 -w"
+   if $COUPLE then
+     set opt_link="-Wg,-c $IOIPSLDIR/liboasis2.4_mpi2.a /usr/lang/mpi2/lib64/libmpi.a /usr/lang/mpi2/lib64/libmp.a /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl"
+     set oplink="-Wl,-t,-P,-dy "
+   else
+     set opt_link="-Wg,-c /usr/local/lib/lib64/libnetcdf_cc.a -L$IOIPSLDIR -lioipsl"
+     set oplink="-Wl,-t,-dy "
+   endif
+   set mod_loc_dir=$IOIPSLDIR
+   set mod_suffix=mod
+else if $DEC then
+else if $LINUX then
+   set optim=" -O2 -Munroll -Mcache_align "
+   set optim90=" -O2 -Munroll -Mcache_align "
+   set optimtru90=" -O2 -Munroll -Mcache_align "
+   set opt_link=" -L$NCDFLIB -lnetcdf"
+   set mod_loc_dir=$localdir
+   set mod_suffix=mod
+# Ehouarn 'ifort' compiler
+#   #NB: on gnome -O3 ==> NaNs ...
+#   set optim=" -O2 -ip -mkl=sequential -align common "
+#   set optim90=" -O2 -ip -mkl=sequential -align common "
+#   set optimtru90=" -O2 -ip -mkl=sequential -align common "
+#   set mod_loc_dir=$LIBOGCM
+#   set mod_suffix=mod
+else if $NEC then
+   set optim90=' -clear -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
+   set optimtru90=' -clear -f4 -C hopt -float0 -ew -P static -Wf,"-pvctl fullmsg noassume "'
+###   set opt_link=" -C hopt -float0 -ew -P static -L$IOIPSLDIR -lioipsl  -L/u/rech/psl/rpsl003/IOIPSL -lnetcdf_i8r8_v "
+   set opt_link=" -C hopt -float0 -ew -P static -L/SX/usr/local/lib  -lnetcdf_i8r8 "
+   set mod_loc_dir="."
+   set mod_suffix="mod"
+else if $XNEC then
+   set optim90=' -clear -R5 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
+   set optimtru90=' -clear -R5 -f4 -C vopt -float0 -ew -P static -Wf,"-pvctl loopcnt=40000 fullmsg noassume "'
+   if $MODIPSL then
+     if $COUPLE then
+       set opt_link="-L$IOIPSLDIR -lsxioipsl -loasis2.4_mpi2 -float0 -ew -P static -I$NCDFINC $NCDFLIB "
+     else
+       set opt_link="-L$IOIPSLDIR -lsxioipsl -float0 -ew -P static -I$NCDFINC $NCDFLIB "
+     endif
+     set mod_loc_dir="./"
+   else
+     set opt_link=" -C hopt -float0 -ew -P static -I$NCDFINC -L/SX/usr/local/lib -lnetcdf_i8r8"
+     set mod_loc_dir="."
+   endif
+   set mod_suffix="mod"
+
+endif
+
+set nomlib=${machine}
+
+# Impose distinct name for 64 bit Linux machines (to avoid mixing 32 and 64)
+if (`uname` == Linux && `uname -m` == "x86_64") then
+  set nomlib=${machine}64
+endif
+
+########################################################################
+# lecture des options de mymake
+########################################################################
+
+top:
+if ($#argv > 0) then
+    switch ($1:q)
+
+    case -h:
+
+########################################################################
+# Manuel en ligne
+########################################################################
+more <<eod
+
+
+makegcm [Options] prog
+
+
+The makegcm script:
+-------------------
+
+1. compiles a series of subroutines located in the $LMDGCM/libf
+ sub-directories.
+ The objects are then stored in the libraries in $LIBOGCM.
+
+2. then, makegcm compiles program prog.f located by default in
+$LMDGCM/libf/dyn3d and makes the link with the libraries.
+
+Environment Variables '$LMDGCM' and '$LIBOGCM'
+ must be set as environment variables or directly
+ in the makegcm file.
+
+The makegcm command is used to control the different versions of the model
+ in parallel, compiled using the compilation options 
+ and the various dimensions, without having to recompile the whole model.
+
+The FORTRAN libraries are stored in directory $LIBOGCM.
+
+
+OPTIONS:
+--------
+
+The following options can either be defined by default by editing the
+makegcm "script", or in interactive mode:
+
+-d imxjmxlm  where im, jm, and lm are the number of longitudes,
+             latitudes and vertical layers respectively.
+
+-s nscat   Number of radiatively active scatterers
+
+-p PHYS    Selects the set of physical parameterizations
+           you want to compile the model with.
+           The model is then compiled using the physical
+           parameterization sources in directory:
+            $LMDGCM/libf/phyPHYS
+
+-g grille  Selects the grid type.
+           This option overwrites file
+           $LMDGCM/libf/grid/fxyprim.h
+           with file
+           $LMDGCM/libf/grid/fxy_grille.h
+           the grid can take the following values:
+           1. reg - the regular grid
+           2. sin - to obtain equidistant points in terms of sin(latitude)
+           3. new - to zoom into a part of the globe
+
+-O "compilation options" set of fortran compilation options to use
+
+-include path
+           Used if the subroutines contain #include files (ccp) that 
+           are located in directories that are not referenced by default.
+
+-adjnt     Compiles the adjoint model to the dynamical code.
+
+-olddyn    To compile GCM with "old dynamics"
+
+-filtre  filter
+           To select the longitudinal filter in the polar regions.
+           "filter" corresponds to the name of a directory located in
+           $LMDGCM/libf. The standard filter for the model is "filtrez"
+           which can be used for a regular grid and for a  
+           grid with longitudinal zoom.
+
+-link "-Ldir1 -lfile1 -Ldir2 -lfile2 ..."
+           Adds a link to FORTRAN libraries
+           libfile1.a, libfile2.a ... 
+           located in directories dir1, dir2 ...respectively
+           If dirn is a directory with an automatic path 
+           (/usr/lib ... for example) 
+           there is no need to specify  -Ldirn.
+
+-full      Full (re)compilation (from scratch)
+
+eod
+exit
+
+########################################################################
+# Lecture des differentes options
+########################################################################
+
+    case -d
+        set dim=$2 ; shift ; shift ; goto top
+                        
+    case -O:
+        set optim90="$2" ; set optim="$2" ; set optimtru90="$2" ; shift ; shift ; goto top
+
+     case -p
+        set physique="$2" ; set phys="PHYS=$physique" ; shift ; shift ; goto top
+
+     case -s
+        set scatterers="$2" ; shift ; goto top
+
+     case -g
+        set grille="$2" ; shift ; shift ; goto top
+
+    case -b
+        set bands=$2 ; shift ; shift ; goto top
+           
+     case -t
+        set ntrac=$2 ; shift ; shift ; goto top
+
+     case -include
+        set include="$include -I$2" ; shift ; shift ; goto top
+
+     case -adjnt
+        set opt_dep="$opt_dep adjnt" ; set adjnt="-ladjnt -ldyn3d "
+
+     case -olddyn
+        set dyntype="olddyn" ; shift; goto top
+
+     case -full
+        set full="full" ; shift ; goto top
+
+     case -filtre
+        set filtre=$2 ; shift ; shift ; goto top
+
+     case -link
+        set opt_link="$opt_link $2" ; shift ; shift ; goto top
+
+     case -debug
+        if $HP then
+           set optim90=" -g "
+        else if $SUN then
+           setenv PARALLEL 4
+           set optim90=" -g -C "
+           set optimtru90=" -g -C "
+        else if $CRAY then
+           set optim90="$optim90"" -G1 "
+        else if $LINUX then
+           set optim="-g -Mbounds -Kieee -Ktrap=fp -traceback"
+           set optim90="-g -Mbounds -Kieee -Ktrap=fp -traceback"
+           set optimtru90="-g -Mbounds -Kieee -Ktrap=fp -traceback"
+#	   set optim=" -g -no-ftz -traceback -ftrapuv -fp-stack-check "
+#           set optim90=" -g -no-ftz -traceback -ftrapuv -fp-stack-check "
+#           set optimtru90=" -g -no-ftz -traceback -ftrapuv -fp-stack-check "
+        else 
+           echo "pas d option debug predefinie pour cette machine"
+           exit
+        endif
+        shift ; goto top
+
+     default
+        set code="$1" ; shift ; goto top
+
+   endsw
+endif
+
+
+echo "apres les opts dim $dim"
+
+########################################################################
+# cas special sans physique
+########################################################################
+if ( "$physique" == 'nophys' ) then
+   set phys="L_PHY= LIBPHY="
+else
+   set src_dirs="$src_dirs phy_common phy$physique"
+   set include="$include "'-I$(LIBF)/phy_common  -I$(LIBF)/phy'"$physique"
+   set LIBPHY_COMMON='$(LIBO)/libphy_common.a'
+endif
+set libdyn_phy=""
+set LIBDYN_PHYS=""
+########################################################################
+#subtilites sur le nom de la librairie
+########################################################################
+
+
+\rm tmp ; touch tmp
+\rm tmp90 ; touch tmp90
+foreach i ( $optim90 )
+   echo $i | sed -e 's/\"//g' -e "s/\'//g" -e 's/-//g' -e 's/://g' -e 's/=//g' -e 's/%//g' >> tmp
+end
+set suf=
+foreach i ( `sort tmp | uniq ` )
+   set suf=$suf$i
+end
+if ( ! $IBM ) then
+   set nomlib="$nomlib$suf"
+endif
+if ( $DEC ) then
+   set nomlib=DEC
+endif
+
+# dimension
+echo "dimension avant sed $dim"
+if ( $IBM ) then
+   set dim=`echo $dim | sed -en 's/[^0-9]/ /g'`
+   set dim_=`echo $dim | sed -en 's/[^0-9]/_/g'`
+else if ( $SUN || $XNEC ) then
+   set dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
+   set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
+else
+     set dim=`echo $dim | sed -e 's/[^0-9]/ /g'`
+     set dim_=`echo $dim | sed -e 's/[^0-9]/_/g'`
+endif
+
+# bands
+echo "bands avant sed $bands"
+if ( $IBM ) then
+   set bands=`echo $bands | sed -en 's/[^0-9]/ /g'`
+   set bands_=`echo $bands | sed -en 's/[^0-9]/_/g'`
+else if ( $SUN || $XNEC ) then
+   set bands=`echo $bands | sed -e 's/[^0-9]/ /g'` 
+   set bands_=`echo $bands | sed -e 's/[^0-9]/_/g'`
+else
+     set bands=`echo $bands | sed -e 's/[^0-9]/ /g'`
+     set bands_=`echo $bands | sed -e 's/[^0-9]/_/g'`
+endif
+
+
+# build final name of libraries directory:
+if ( "$dyntype" == "olddyn" ) then
+  set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}_olddyn
+else
+  set nomlib=${nomlib}_${dim_}_t${ntrac}_s${scatterers}_${grille}
+endif
+
+# Append number of bands to nomlib (new for universal model)
+set nomlib=${nomlib}_${bands_}
+
+# Append 'physique' type, if it is not mars, to nomlib
+if ( "$physique" != "mars" ) then
+  set nomlib=${nomlib}_${physique}
+endif
+
+## M-A-F nomlib trop long sur CRAY pour ar
+if ( $CRAY ) then
+    set nomlib=F90_${dim_}_t${ntrac}
+endif
+if ( $NEC || $XNEC ) then
+    set nomlib=F90_${dim_}_t${ntrac}
+endif
+
+echo "calcul de la dimension"
+set dimc=`echo $dim | wc -w`
+
+if ( "$dimc" == "2" ) then
+  set include="$include "'-I$(LIBF)/dyn2d '
+  set dimh=$dim
+endif
+if ( "$dimc" == "3" ) then
+  if ( "$dyntype" == "olddyn" ) then
+    set include="$include "'-I$(LIBF)/olddyn3d '
+    set src_dirs="$src_dirs olddyn3d dynphy_lonlat dynphy_lonlat/phy$physique"
+  else
+    set include="$include "'-I$(LIBF)/dyn3d '
+    set src_dirs="$src_dirs dyn3d dynphy_lonlat dynphy_lonlat/phy$physique"
+  endif
+  set libdyn_phy="-ldynphy_lonlat"
+  set LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a'
+  set dimh=`echo $dim | awk ' { print $1 "." $2 } '`
+endif
+echo "dimc is $dimc"
+
+########################################################################
+# path pour les #include
+########################################################################
+
+set include="$include -I$NCDFINC "
+echo $include
+
+########################################################################
+# Gestion des dimensions du modele.
+# on cree ou remplace le fichier des dimensions/nombre de traceur
+########################################################################
+
+cd $libf/grid
+if ( -f dimensions.h ) then
+  echo "WARNING: you are already compiling the model somewhere else"
+  echo "Wait until the first compilation is finished before starting."
+  echo "If you are sure that you are not compiling elsewhere, you can"
+  echo "type [yes] to continue."
+  echo "Do you want to continue?"
+  if ( $< == "yes" ) then
+    #remove old dimensions.h , bands.h and scatterers.h files
+    \rm -f $libf/grid/dimensions.h
+    \rm -f $libf/grid/bands.h
+    \rm -f $libf/phy${physique}/bands.h
+    \rm -f $libf/phy${physique}/scatterers.h
+  else
+    exit
+  endif
+endif
+
+# Build the appropriate 'dimensions.h' file
+cd dimension
+./makdim $dim
+# echo contents of dimensions.h to standard output
+cat $libf/grid/dimensions.h
+
+# Build the appropriate 'bands.h' file
+cd $libf/phy$physique/bands
+./makbands $bands
+# echo contents of bands.h to standard output
+cat $libf/phy$physique/bands.h
+
+# Build the appropriate 'scatterers.h' file
+cd $libf/phy$physique/scatterers
+./make_scatterers $scatterers
+# echo contents of scatterers.h to standard output
+cat $libf/phy$physique/scatterers.h
+
+cd $LMDGCM
+# set path to objects directory
+set libo=$libo/$nomlib
+# create objects directory, if it doesn't exist
+if ( ! -d $libo )  then
+   mkdir $libo
+   cd $model
+endif
+
+########################################################################
+# Differentes dynamiques (3d, 2d, 1d)
+########################################################################
+
+set dimension=`echo $dim | wc -w`
+echo dimension $dimension dim $dim
+if ( $dimension == 1 ) then
+  echo "No dynamics"
+##  set dyn="L_DYN= DYN= L_FILTRE= "
+## NB: we still need to have L_DYN=libdyn3d to reach routines and module
+## objects which are located in dyn3d
+  set dyntype=""
+  set filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
+  set dyn="L_DYN= DYN= L_FILTRE= "
+  set dirmain="phy$physique/dyn1d"
+  set src_dirs="$src_dirs phy$physique/dyn1d "
+  set include="$include "' -I$(LIBF)/phy'"$physique"'/dyn1d'
+endif
+endif
+
+cd $model
+if ( $dimension == 3 ) then
+  cd libf/grid
+  \rm fxyprim.h
+  cp -p fxy_${grille}.h fxyprim.h
+endif
+
+######################################################################
+# Gestion du filtre qui n'existe qu'en 3d.
+######################################################################
+
+# set filtre to 'oldfiltrez' if using -olddyn option
+if ( "$dyntype" == "olddyn" ) then
+  set filtre="oldfiltrez"
+endif
+
+if ( `expr $dimc \> 2` == 1 ) then
+   set filtre="FILTRE=$filtre"
+   if ( "$dyntype" == "olddyn" ) then
+     set src_dirs="$src_dirs oldfiltrez"
+   else
+     set src_dirs="$src_dirs filtrez"
+   endif
+else
+   set filtre="FILTRE= L_FILTRE= L_DYN= "
+endif
+echo "MACRO FILTRE $filtre"
+
+echo "dimc $dimc"
+
+#cleanup for a full recompilation, if requested
+if ("$full" == "full") then
+# remove makefile and $libo
+  cd $model
+  \rm -f makefile
+  \rm -rf $libo/*
+endif
+
+########################################################################
+#  Avant de lancer le make, on recree le makefile si necessaire
+########################################################################
+# c'est a dire dans 3 cas:
+# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
+#    derniere creation du makefile
+# 2. si le fichier contenant cette liste "liste_des_sources"
+#    n'existe pas.
+# 3. Si le makefile n'existe pas.
+########################################################################
+
+cd $model
+find libf -name '*.[Fh]' -print | sort >! tmp77
+#find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print >! tmp90
+find libf -name '*.[Fh]90' -print | sort >> tmp90
+
+if (    `diff tmp77 liste_des_sources_f77 | wc -w` \
+     || `diff tmp90 liste_des_sources_f90 | wc -w` \
+     || ! -f makefile \
+     || ! -f liste_des_sources_f90 \
+     || ! -f liste_des_sources_f77 ) then
+        echo "les fichiers suivants ont ete crees ou detruits"
+        echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
+        diff liste_des_sources_f77 tmp77
+        diff liste_des_sources_f90 tmp90
+        \cp tmp77 liste_des_sources_f77
+        \cp tmp90 liste_des_sources_f90
+        echo "Remaking the makefile!"
+        echo "src_dirs: $src_dirs"
+        create_make_gcm $src_dirs >! tmp
+        \mv tmp makefile
+        echo "New makefile created."
+endif
+
+########################################################################
+#  Execution de la comande make
+########################################################################
+
+
+echo PHYSIQUE $phys
+echo dynamique $dyn $dimension
+echo OPTIM90="$optim90" $filtre LIBO=$libo $dyn PHYS=$phys DIM=$dimc PROG=$code
+echo PATH pour les fichiers INCLUDE $include
+echo OPLINK="$oplink"
+
+if $HP then
+   set f77='fort77 +OP'
+   set f90='jensaisrien'
+   set opt_link="$opt_link -lm"
+else  if $VPP then
+   set f77=frt
+   set f90=$f77
+else if $CRAY then
+   set f77=f90
+   set f90=f90
+else if $LINUX then
+#   set f77=ifort
+#   set f90=ifort
+#   set opt_link=" -L$LIBOGCM -L$NCDFLIB -lnetcdf "
+   set f77=pgf90
+   set f90=pgf90
+else if $SUN then
+   set f77=f90
+   set f90=f90
+else if $NEC then
+   set f77=f90
+   set f90=f90
+else if $XNEC then
+   set f77=sxmpif90
+   set f90=sxmpif90
+else
+   set f77=f77
+   set f90=f90
+endif
+
+cd $model
+
+if $VPP then
+  set make="gmake RANLIB=ls"
+else if $CRAY then
+  set make="make RANLIB=ls"
+else if $NEC then
+  set make="make RANLIB=ls"
+else if $LINUX then
+  set make="make -k RANLIB=ranlib"
+else if $XNEC then
+  set make="/usr/local/bin/gmake RANLIB=ls"
+  set make="/usr/freeware/bin/gmake RANLIB=ls"
+else
+  set make="make RANLIB=ranlib"
+endif
+
+#
+# etat0_netcdf a besoin d'info de la physique
+# A revoir
+set include="$include"" -I$libf/phy$physique"
+
+
+#################################################################
+# Execution de la comande make... ENFIN!
+#################################################################
+
+if $VPP then
+  set optim90=" $optim90 -Am -M$libo"
+  set optimtru90="$optim90"
+else if $SUN then
+ set optim90=" $optim90 -M$libo"
+ set optimtru90=" $optimtru90 "
+else if $NEC then
+ set optim90=" $optim90 -I$libo "
+else if $XNEC then
+ set optim90=" $optim90 -I$libo "
+ set optimtru90=" $optimtru90 -I$libo "
+else if $LINUX then
+# set optim="$optim -I${libo}"
+# set optim90="$optim90 -I${libo}"
+# set optimtru90="$optimtru90 -ffree-form -I${libo}"
+ set optim="$optim -module $libo"
+ set optim90="$optim90 -module $libo"
+ set optimtru90="$optimtru90 -module $libo"
+# Ehouarn: remove set mod_loc_dir def below; mod_loc_dir=$localdir (set above)
+# set mod_loc_dir=$libo
+endif
+
+set link="$f90 $optim90"
+
+set ar=ar
+
+if $XNEC then
+  set link="sxld $opt_link"
+  set link="$f90 "
+#  set ar=sxar
+endif
+
+cd $localdir
+
+set source_code=${code}.F
+# handle cases when the main program is in the physics directory
+set dirmain=dyn${dimc}d
+if ( -f $LMDGCM/libf/dyn3d/${code}.F90 ) then
+  set source_code=${code}.F90
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F90 ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F90
+endif
+if ( -f $LMDGCM/libf/dynphy_lonlat/phy${physique}/${code}.F ) then
+  set dirmain=dynphy_lonlat/phy${physique}
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/dynphy_lonlat/phy${physique}/${code}.F90 ) then
+  set dirmain=dynphy_lonlat/phy${physique}
+  set source_code=${code}.F90
+endif
+
+echo $make -f $LMDGCM/makefile \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+OPTIM="$optim" \
+OPTIM90="$optim90" \
+OPTIMTRU90="$optimtru90" \
+INCLUDE="$include" \
+$filtre \
+LIBO=$libo \
+$phys \
+LIBPHY_COMMON=${LIBPHY_COMMON} \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
+DIM=$dimc \
+DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
+L_ADJNT="$adjnt" \
+LOCAL_DIR="$localdir"  \
+F77="$f77" \
+F90="$f90" \
+OPLINK="$oplink" \
+LINK="$link" \
+GCM="$LMDGCM" \
+MOD_LOC_DIR=$mod_loc_dir \
+MOD_SUFFIX=$mod_suffix \
+AR=$ar \
+DIRMAIN=$dirmain \
+SOURCE=$source_code \
+PROG=$code
+
+
+$make -f $LMDGCM/makefile \
+OPTION_DEP="$opt_dep" OPTION_LINK="$opt_link" \
+OPTIM="$optim" \
+OPTIM90="$optim90" \
+OPTIMTRU90="$optimtru90" \
+INCLUDE="$include" \
+$filtre \
+LIBO=$libo \
+$phys \
+LIBPHY_COMMON=${LIBPHY_COMMON} \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
+DIM=$dimc \
+DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
+L_ADJNT="$adjnt" \
+LOCAL_DIR="$localdir"  \
+F77="$f77" \
+F90="$f90" \
+OPLINK="$oplink" \
+LINK="$link" \
+GCM="$LMDGCM" \
+MOD_LOC_DIR=$mod_loc_dir \
+MOD_SUFFIX=$mod_suffix \
+AR=$ar \
+DIRMAIN=$dirmain \
+SOURCE=$source_code \
+PROG=$code
+
+\rm -f $libf/grid/dimensions.h
+\rm -f $libf/grid/bands.h
+\rm -f $libf/phy$physique/bands.h
+\rm -f $libf/phy$physique/scatterers.h
Index: /trunk/LMDZ.TITAN/patch_large_domains/dyn3d/iniinterp_h.F
===================================================================
--- /trunk/LMDZ.TITAN/patch_large_domains/dyn3d/iniinterp_h.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/patch_large_domains/dyn3d/iniinterp_h.F	(revision 1644)
@@ -0,0 +1,240 @@
+      subroutine iniinterp_h (imo,jmo,imn,jmn ,kmax,
+     &       rlonuo,rlatvo,rlonun,rlatvn,
+     &       ktotal,iik,jjk,jk,ik,intersec,airen)
+   
+      implicit none
+
+
+
+c ---------------------------------------------------------
+c Prepare l' interpolation des variables d'une grille LMDZ
+c  dans une autre grille LMDZ en conservant la quantite
+c  totale pour les variables intensives (/m2) : ex : Pression au sol
+c
+c   (Pour chaque case autour d'un point scalaire de la nouvelle
+c    grille, on calcule la surface (en m2)en intersection avec chaque
+c    case de l'ancienne grille , pour la future interpolation)
+c
+c on calcule aussi l' aire dans la nouvelle grille 
+c
+c
+c   Auteur:  F.Forget 01/1995
+c   -------
+c
+c ---------------------------------------------------------
+c   Declarations:
+c ==============
+c
+c  ARGUMENTS
+c  """""""""
+c INPUT
+       integer imo, jmo ! dimensions ancienne grille
+       integer imn,jmn  ! dimensions nouvelle grille
+       integer kmax ! taille du tableau des intersections
+       real rlonuo(imo+1)     !  Latitude et
+       real rlatvo(jmo)       !  longitude des
+       real rlonun(imn+1)     !  bord des
+       real rlatvn(jmn)     !  cases "scalaires" (input)
+
+c OUTPUT
+       integer ktotal ! nombre totale d''intersections reperees
+       integer iik(kmax), jjk(kmax),jk(kmax),ik(kmax)
+       real intersec(kmax)  ! surface des intersections (m2)
+       real airen (imn+1,jmn+1) ! aire dans la nouvelle grille
+
+
+       
+ 
+c Autres variables
+c """"""""""""""""
+       integer i,j,ii,jj
+       integer imomx,jmomx,imnmx1,jmnmx1
+!       parameter (imomx=361,jmomx=180,imnmx1=190,jmnmx1=100)
+!       parameter (imomx=361,jmomx=180,imnmx1=360,jmnmx1=190)
+       parameter (imomx=722,jmomx=360,imnmx1=720,jmnmx1=380)
+       real a(imomx+1),b(imomx+1),c(jmomx+1),d(jmomx+1)
+       real an(imnmx1+1),bn(imnmx1+1)
+       real cn(jmnmx1+1),dn(jmnmx1+1)
+       real aa, bb,cc,dd
+       real pi
+
+       pi      = 2.*ASIN( 1. )
+
+c Test dimensions imnmx1 jmnmx1
+c""""""""""""""""""""""""""""""
+c test dimensionnement tableau airetest
+      if (imn.GT.imnmx1.OR.jmn.GT.jmnmx1) then
+        write(*,*) 'STOP pb dimensionnement'
+        write(*,*) 'il faut imn < imnmx1 et jmn < jmnmx1'
+        write(*,*) 'imn imnmx1', imn,imnmx1
+        write(*,*) 'jmn jmnmx1', jmn,jmnmx1
+        call exit(1)
+      endif
+
+      if (imo.GT.imomx.OR.jmo.GT.jmomx) then
+        write(*,*) 'STOP pb dimensionnement'
+        write(*,*) 'il faut imo < imomx et jmo < jmomx'
+        write(*,*) 'imo imomx', imo,imomx
+        write(*,*) 'jmo jmomx', jmo,jmomx
+        call exit(1)
+      endif
+
+c On repere les frontieres des cases :
+c =================================== 
+c
+c Attention, on ruse avec des latitudes = 90 deg au pole.
+
+
+c  Ancienne grile
+c  """"""""""""""
+      a(1) =   - rlonuo(imo+1)
+      b(1) = rlonuo(1)
+      do i=2,imo+1
+         a(i) = rlonuo(i-1)
+         b(i) =  rlonuo(i)
+      end do
+
+      d(1) = pi/2 
+      do j=1,jmo
+         c(j) = rlatvo(j) 
+         d(j+1) = rlatvo(j)
+      end do
+      c(jmo+1) = -pi/2 
+      
+
+c  Nouvelle grille
+c  """""""""""""""
+      an(1) =  - rlonun(imn+1)
+      bn(1) = rlonun(1)
+      do i=2,imn+1
+         an(i) = rlonun(i-1)
+         bn(i) =  rlonun(i)
+      end do
+
+      dn(1) = pi/2 
+      do j=1,jmn
+         cn(j) = rlatvn(j)
+         dn(j+1) = rlatvn(j)
+      end do
+      cn(jmn+1) = -pi/2 
+
+c Calcul de la surface des cases scalaires de la nouvelle grille
+c ==============================================================
+      do ii=1,imn + 1
+        do jj = 1,jmn+1
+           airen(ii,jj) = (bn(ii)-an(ii))*(sin(dn(jj))-sin(cn(jj)))
+        end do
+      end do
+
+c Calcul de la surface des intersections
+c ======================================
+
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c test dimenssion kmax (calcul de ktotal)
+c"""""""""""""""""""""""""""""""""""""""
+c Calcul de ktotal, mais ralonge beaucoup en temps => pour debug
+      write(*,*) 
+      write(*,*) 'DEBUT DU TEST KMAX'
+      ktotal = 0
+      do jj = 1,jmn+1
+       do j=1, jmo+1
+          if((cn(jj).lt.d(j)).and.(dn(jj).gt.c(j)))then
+              do ii=1,imn + 1
+                do i=1, imo +1
+                    if (  ((an(ii).lt.b(i)).and.(bn(ii).gt.a(i)))
+     &        .or. ((an(ii).lt.b(i)-2*pi).and.(bn(ii).gt.a(i)-2*pi)
+     &             .and.(b(i)-2*pi.lt.-pi) )
+     &        .or. ((an(ii).lt.b(i)+2*pi).and.(bn(ii).gt.a(i)+2*pi)
+     &             .and.(a(i)+2*pi.gt.pi) )
+     &                     )then
+                      ktotal = ktotal +1
+                     end if
+                enddo
+              enddo
+           end if
+        enddo
+      enddo
+
+      if (kmax.LT.ktotal) then
+         write(*,*)
+         write(*,*) '******** ATTENTION ********' 
+         write(*,*) 'kmax =',kmax 
+         write(*,*) 'ktotal =',ktotal 
+         write(*,*) 'Changer la valeur de kmax dans interp_horiz.F ' 
+         write(*,*) 'avec kmax >= ktotal' 
+         write(*,*) 'EXIT dans iniinterp_h'
+         call exit(1)
+      else
+         write(*,*) 'kmax =',kmax 
+         write(*,*) 'ktotal =',ktotal
+      end if
+      write(*,*) 'FIN DU TEST KMAX'
+      write(*,*) 
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+
+c     boucle sur la nouvelle grille
+c     """"""""""""""""""""""""""""
+      ktotal = 0
+      do jj = 1,jmn+1
+       do j=1, jmo+1
+          if((cn(jj).lt.d(j)).and.(dn(jj).gt.c(j)))then
+              do ii=1,imn + 1
+                do i=1, imo +1
+                    if (  ((an(ii).lt.b(i)).and.(bn(ii).gt.a(i)))
+     &        .or. ((an(ii).lt.b(i)-2*pi).and.(bn(ii).gt.a(i)-2*pi)
+     &             .and.(b(i)-2*pi.lt.-pi) )
+     &        .or. ((an(ii).lt.b(i)+2*pi).and.(bn(ii).gt.a(i)+2*pi)
+     &             .and.(a(i)+2*pi.gt.pi) )
+     &                     )then
+                      ktotal = ktotal +1
+                      iik(ktotal) =ii
+                      jjk(ktotal) =jj
+                      ik(ktotal) =i
+                      jk(ktotal) =j
+
+                      dd = min(d(j), dn(jj))
+                      cc = cn(jj)
+                      if (cc.lt. c(j))cc=c(j)
+                      if((an(ii).lt.b(i)-2*pi).and.
+     &                  (bn(ii).gt.a(i)-2*pi)) then 
+                          bb = min(b(i)-2*pi,bn(ii))
+                          aa = an(ii)
+                          if (aa.lt.a(i)-2*pi) aa=a(i)-2*pi
+                      else if((an(ii).lt.b(i)+2*pi).and.
+     &                       (bn(ii).gt.a(i)+2*pi)) then
+                          bb = min(b(i)+2*pi,bn(ii))
+                          aa = an(ii)
+                          if (aa.lt.a(i)+2*pi) aa=a(i)+2*pi
+                      else 
+                          bb = min(b(i),bn(ii))
+                          aa = an(ii)
+                          if (aa.lt.a(i)) aa=a(i)
+                      end if
+                      intersec(ktotal)=(bb-aa)*(sin(dd)-sin(cc))
+                     end if
+                end do
+               end do
+             end if
+         end do
+       end do       
+
+
+c     TEST  INFO
+c     DO k=1,ktotal 
+c      ii = iik(k) 
+c      jj = jjk(k)
+c      i = ik(k)
+c      j = jk(k)
+c      if ((ii.eq.10).and.(jj.eq.10).and.(i.eq.10).and.(j.eq.10))then
+c      if (jj.eq.2.and.(ii.eq.1))then
+c          write(*,*) '**************** jj=',jj,'ii=',ii
+c          write(*,*) 'i,j =',i,j
+c          write(*,*) 'an,bn,cn,dn', an(ii), bn(ii), cn(jj),dn(jj)
+c          write(*,*) 'a,b,c,d', a(i), b(i), c(j),d(j)
+c          write(*,*) 'intersec(k)',intersec(k)
+c          write(*,*) 'airen(ii,jj)=',airen(ii,jj)
+c      end if
+c     END DO 
+
+      return
+      end
Index: /trunk/LMDZ.TITAN/patch_large_domains/dyn3d/interp_horiz.F
===================================================================
--- /trunk/LMDZ.TITAN/patch_large_domains/dyn3d/interp_horiz.F	(revision 1644)
+++ /trunk/LMDZ.TITAN/patch_large_domains/dyn3d/interp_horiz.F	(revision 1644)
@@ -0,0 +1,190 @@
+      subroutine interp_horiz (varo,varn,imo,jmo,imn,jmn,lm,
+     &  rlonuo,rlatvo,rlonun,rlatvn)  
+
+c===========================================================
+c  Interpolation Horizontales des variables d'une grille LMDZ
+c (des points SCALAIRES au point SCALAIRES)
+c  dans une autre grille LMDZ en conservant la quantite
+c  totale pour les variables intensives (/m2) : ex : Pression au sol
+c
+c Francois Forget (01/1995)
+c===========================================================
+
+      IMPLICIT NONE 
+
+c   Declarations:
+c ==============
+c
+c  ARGUMENTS
+c  """""""""
+        
+       INTEGER,INTENT(IN) :: imo, jmo ! dimensions ancienne grille (input)
+       INTEGER,INTENT(IN) :: imn,jmn  ! dimensions nouvelle grille (input)
+
+       REAL,INTENT(IN) :: rlonuo(imo+1)     !  Latitude et
+       REAL,INTENT(IN) :: rlatvo(jmo)       !  longitude des
+       REAL,INTENT(IN) :: rlonun(imn+1)     !  bord des 
+       REAL,INTENT(IN) :: rlatvn(jmn)     !  cases "scalaires" (input)
+
+       INTEGER,INTENT(IN) :: lm ! dimension verticale (input)
+       REAL,INTENT(IN) :: varo (imo+1, jmo+1,lm) ! var dans l'ancienne grille (input)
+       REAL,INTENT(OUT) :: varn (imn+1,jmn+1,lm) ! var dans la nouvelle grille (output)
+
+c Autres variables
+c """"""""""""""""
+       INTEGER imnmx2,jmnmx2
+cc       parameter (imnmx2=190,jmnmx2=100)
+c       parameter (imnmx2=360,jmnmx2=190)
+       parameter (imnmx2=720,jmnmx2=380)
+       REAL airetest(imnmx2+1,jmnmx2+1)
+       INTEGER ii,jj,l
+
+       REAL,SAVE :: airen ((imnmx2+1)*(jmnmx2+1)) ! aire dans la nouvelle grille
+       REAL airentotn	! aire totale pole nord dans la nouvelle grille
+       REAL airentots	! aire totale pole sud dans la nouvelle grille
+c    Info sur les ktotal intersection entre les cases new/old grille
+
+c kmax: le nombre  max  d'intersections entre les 2 grilles horizontales
+c On fixe kmax a la taille de la grille des donnees martiennes (360x179) 
+c + des pouiemes (cas ou une maille est a cheval sur 2 ou 4 mailles)
+c  Il y a un test dans iniinterp_h pour s'assurer que ktotal < kmax
+       INTEGER kmax, k
+       integer,save :: ktotal
+c       parameter (kmax = 360*179 + 200000)
+cc      parameter (kmax = 360*179 + 40000)
+       parameter (kmax = 360*179 + 360000)
+
+       INTEGER,SAVE :: iik(kmax), jjk(kmax),jk(kmax),ik(kmax)
+       REAL,SAVE :: intersec(kmax)
+       REAL r
+       REAL totn, tots
+       integer,save :: prev_sumdim=0
+
+       logical,save :: firsttest=.true. , aire_ok=.true.
+
+       integer,save :: imoS,jmoS,imnS,jmnS
+
+c Test dimensions imnmx2 jmnmx2
+c""""""""""""""""""""""""""""""
+c test dimensionnement tableau airetest
+      if (imn.GT.imnmx2.OR.jmn.GT.jmnmx2) then
+         write(*,*) 'STOP pb dimensionnement tableau airetest'
+         write(*,*) 'il faut imn < imnmx2 et jmn < jmnmx2'
+         write(*,*) 'imn imnmx2', imn,imnmx2
+         write(*,*) 'jmn jmnmx2', jmn,jmnmx2
+         call exit(1)
+      endif
+
+c initialisation
+c --------------
+c Si c'est le premier appel,  on prepare l'interpolation
+c en calculant pour chaque case autour d'un point scalaire de la
+c nouvelle grille, la surface  de intersection avec chaque
+c    case de l'ancienne grille.
+
+c  This must also be done if we change the dimension
+      if (imo+jmo+imn+jmn.ne.prev_sumdim) then
+          firsttest=.true.
+          prev_sumdim=imo+jmo+imn+jmn
+      end if       
+
+      if (firsttest) then 
+        call iniinterp_h(imo,jmo,imn,jmn ,kmax,
+     &       rlonuo,rlatvo,rlonun,rlatvn,
+     &          ktotal,iik,jjk,jk,ik,intersec,airen)
+       imoS=imo
+       jmoS=jmo
+       imnS=imn
+       jmnS=jmn
+      else
+       if(imo.NE.imoS.OR.jmo.NE.jmoS.OR.imn.NE.imnS.OR.jmn.NE.jmnS) then
+        call iniinterp_h(imo,jmo,imn,jmn ,kmax,
+     &       rlonuo,rlatvo,rlonun,rlatvn,
+     &          ktotal,iik,jjk,jk,ik,intersec,airen)
+       imoS=imo
+       jmoS=jmo
+       imnS=imn
+       jmnS=jmn
+       end if
+      end if
+
+! initialize varn() to zero
+      varn(1:imn+1,1:jmn+1,1:lm)=0.
+       
+c Interpolation horizontale
+c -------------------------
+c boucle sur toute les ktotal intersections entre les cases
+c de l'ancienne et la  nouvelle grille
+c
+! Ehouarn 2012: for some strange reason, with ifort v12.x,
+!               when the order of the loop below is changed
+!               values of varn(:,:,l=2...) are then sometimes remain zero!   
+      do l=1,lm
+        do k=1,ktotal
+         varn(iik(k),jjk(k),l) = varn(iik(k),jjk(k),l) 
+     &   + varo(ik(k), jk(k),l)*intersec(k)/airen(iik(k)
+     &   +(jjk(k)-1)*(imn+1))
+        end do
+      end do
+
+c Une seule valeur au pole pour les variables ! :
+c -----------------------------------------------
+      DO l=1, lm
+         totn =0.
+         tots =0.
+
+
+c moyenne du champ au poles (ponderee par les aires)
+c"""""""""""""""""""""""""""""""
+         airentotn=0.
+         airentots=0.
+
+         do ii =1, imn+1
+            totn = totn + varn(ii,1,l)*airen(ii)
+            tots = tots + varn (ii,jmn+1,l)*airen(jmn*(imn+1)+ii)
+            airentotn=airentotn + airen(ii)
+            airentots=airentots + airen(jmn*(imn+1)+ii)
+         end do 
+
+         do ii =1, imn+1
+            varn(ii,1,l) = totn/airentotn
+            varn(ii,jmn+1,l) = tots/airentots
+         end do 
+
+      ENDDO ! of DO l=1, lm
+           
+
+c---------------------------------------------------------------
+c  TEST  TEST  TEST  TEST  TEST  TEST  TEST  TEST  TEST  TEST 
+      if (firsttest) then
+      firsttest = .false.
+      write (*,*) 'INTERP. HORIZ. : TEST SUR LES AIRES:'
+
+      do jj =1 , jmn+1
+        do ii=1, imn+1
+          airetest(ii,jj) =0.
+        end do
+      end do 
+      do k=1,ktotal
+         airetest(iik(k),jjk(k))= airetest(iik(k),jjk(k)) +intersec(k) 
+      end do
+      do jj =1 , jmn+1
+       do ii=1, imn+1
+         r = airen(ii+(jj-1)*(imn+1))/airetest(ii,jj)
+         if ((r.gt.1.001).or.(r.lt.0.999)) then
+             write (*,*) '********** PROBLEME D'' AIRES !!!',
+     &                   ' DANS L''INTERPOLATION HORIZONTALE'
+             write(*,*)'ii,jj,airen,airetest',
+     &          ii,jj,airen(ii+(jj-1)*(imn+1)),airetest(ii,jj)
+             aire_ok = .false.
+         end if
+       end do
+      end do
+      if (aire_ok) write(*,*) 'INTERP. HORIZ. : AIRES OK'
+      endif ! of if (firsttest)
+
+c FIN TEST  FIN TEST  FIN TEST  FIN TEST  FIN TEST  FIN TEST  FIN TEST
+c --------------------------------------------------------------------
+
+
+        end
Index: /trunk/LMDZ.TITAN/patch_large_domains/filtrez/parafilt.h
===================================================================
--- /trunk/LMDZ.TITAN/patch_large_domains/filtrez/parafilt.h	(revision 1644)
+++ /trunk/LMDZ.TITAN/patch_large_domains/filtrez/parafilt.h	(revision 1644)
@@ -0,0 +1,47 @@
+        INTEGER nfilun, nfilus, nfilvn, nfilvs
+c
+c 48 32 19 non-zoom:
+c       PARAMETER (nfilun=30,nfilus=30,nfilvn=30,nfilvs=30)
+c        PARAMETER (nfilun=6, nfilus=5, nfilvn=5, nfilvs=5)
+c         PARAMETER (nfilun=15, nfilus=8, nfilvn=14, nfilvs=8)
+c        PARAMETER (nfilun=24, nfilus=23, nfilvn=24, nfilvs=24)
+cmaf -debug  PARAMETER (nfilun=2, nfilus=1, nfilvn=2, nfilvs=2)
+c
+c
+c 96 49 11 non-zoom:
+ccc      PARAMETER (nfilun=9, nfilus=8, nfilvn=8, nfilvs=8)
+c
+c
+c 144 73 11 non-zoom:
+ccc      PARAMETER (nfilun=13, nfilus=12, nfilvn=12, nfilvs=12)
+c
+c 192 143 19 non-zoom:
+c             PARAMETER (nfilun=13, nfilus=12, nfilvn=13, nfilvs=13)
+c      PARAMETER (nfilun=15, nfilus=14, nfilvn=14, nfilvs=14) !!NO fxyhyper
+c      PARAMETER (nfilun=18, nfilus=17, nfilvn=17, nfilvs=17) !!NO fxyhyper
+!!        PARAMETER (nfilun=9,nfilus=8,nfilvn=8,nfilvs=8)
+!        PARAMETER (nfilun=9,nfilus=9,nfilvn=9,nfilvs=9)
+
+!        PARAMETER (nfilun=11,nfilus=11,nfilvn=11,nfilvs=11)
+!        PARAMETER (nfilun=12,nfilus=12,nfilvn=12,nfilvs=12)
+
+        PARAMETER (nfilun=65,nfilus=65,nfilvn=65,nfilvs=65)
+
+
+c 96 72 19 non-zoom:
+ccc      PARAMETER (nfilun=12, nfilus=11, nfilvn=12, nfilvs=12)
+c
+c        PARAMETER ( nfilun=20, nfilus=20, nfilvn=20, nfilvs=20 )
+c        PARAMETER ( nfilun=8, nfilus=7, nfilvn=7, nfilvs=7 )
+c
+c
+c      Ici , on a exagere  les nombres de lignes de latitudes a filtrer .
+c
+c      La premiere fois que  le Gcm  rentrera  dans le Filtre ,
+c
+c      il indiquera  les bonnes valeurs  de  nfilun , nflius, nfilvn  et 
+c
+c      nfilvs  a  mettre .  Il suffira alors de changer ces valeurs dans
+c
+c      Parameter  ci-dessus  et de relancer  le  run .  
+
Index: /trunk/LMDZ.TITAN/utilities/clean_bad_run
===================================================================
--- /trunk/LMDZ.TITAN/utilities/clean_bad_run	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/clean_bad_run	(revision 1644)
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+mv start_archive.nc ../
+rm -f gcm_*
+rm -f fort*
+rm -f g1d.dat
+rm -f g1d.ctl
+rm -f exe_planet
+rm -f lruns?
+rm -f lrun*
+rm -f olr.txt
+rm -f olr?.txt
+rm -f start.nc
+rm -f start*.nc
+rm -f startfi.nc
+rm -f startfi*.nc
+rm -f stats*.nc
+rm -f diagfi.nc
+rm -f diagfi*.nc
+rm -f diagspec.nc
+rm -f diagspec*.nc
+rm -f *.out
+rm -f num_run
+rm -f num_run.crash
+rm -f gcm_3D.*
+rm -f rcm_1D.*
+rm -f *~
+rm -rf files_out
+rm -f profile*.out
+mv ../start_archive.nc .
+
+
+exit 0
Index: /trunk/LMDZ.TITAN/utilities/compile
===================================================================
--- /trunk/LMDZ.TITAN/utilities/compile	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/compile	(revision 1644)
@@ -0,0 +1,36 @@
+# The following script can be used to compile one of the utilities
+# program. Example of use :
+# > compile streamfunction
+# > compile extrapol_icefield
+
+# pgf90 -Bstatic   $1.F90 \
+#-I/distrib/local/netcdf/pgi_7.1-6_32/include \
+#-L/distrib/local/netcdf/pgi_7.1-6_32/lib -lnetcdf  -o $1.e
+
+#ifort $1.F90 \
+#pgf90 $1.F90 \
+ifort $1.F90 \
+-I$NETCDF/include \
+-L$NETCDF/lib -lnetcdf -o $1.e
+
+# Before running that on you computer you might want to change :
+# 1) replace "pgf90" with the name of your favorite compiler 
+#    (you may also add some non-agressive optimization options e.g. -O2)
+# 2) replace "/distrib/local/netcdf/pgi_7.1-6_32/lib" with the
+# address of the
+# directory that contains the NetCDF library (file libnetcdf.a that can
+# be obtained for free on
+# http://www.unidata.ucar.edu/packages/netcdf/index.html
+# (see user manual)
+#
+# 3) Replace "/distrib/local/netcdf/pgi_7.1-6_32/lib" with the address of the
+# directory that contains the NetCDF  include file "netcdf.inc"
+# that can be obtained at the web address above.
+# 
+# 4) The "-Bstatic" option is here to ensure that the executable will
+# work on any Linux machine (only necessary if you want to export the
+# executable from a machine to another).
+
+
+
+
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/co2_cont.for
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/co2_cont.for	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/co2_cont.for	(revision 1644)
@@ -0,0 +1,346 @@
+c     This program computes RT CIA spectra of CO2 at low density limit 
+C     at temperatures between 200 and 800K.
+C     
+C     ============================================================================
+C     Copyright (C) 1997   Marcin Gruszka 
+C     ============================================================================
+C     
+C     Copyright Notice:
+C     You may use this program for your scientific applications,
+C     but please do not	distribute it yourself.
+C     Direct all your inquires to the  author: e-mail aborysow@stella.nbi.dk
+C     Final request: If you publish  your work which benefited from this
+C     program, please acknowledge using this program and quote 
+C     the original paper describing the procedure:
+C     M. Gruszka and A. Borysow,
+C     Roto-translational collision-induced absorption of CO2
+C     for the Atmosphere of Venus at Frequencies from 0 to 250 cm$^{-1}$
+C     and at temperature from 200K to 800K,
+C     Icarus, vol. 129, pp. 172-177, (1997). 
+
+C     
+C     The paper (Icarus) describing this computer model, is based on  original paper by
+C     M. Gruszka and A. Borysow,
+C     "Computer Simulation of the Far Infrared Collision-induced absorption spectra 
+C     of gaseous CO2", Mol. Phys., vol. 93, pp. 1007-1016, 1998. 
+C     ============================================================================
+C     
+C     NOTE: The program gives data at spacing corresponding to
+c     Freq(max)-Freq(min)/(npoint-1),
+c     Since reasons are unknown (author's secret), it is recommended to
+c     request one more point that neccesary and get the right freq. step
+c     ==================================================================
+
+c     
+c     The following input parametres are required (*):
+c     ------------------------------------------------
+c     (*) some input parameters are Fortran REAL numbers
+c     and should be entered with a decimal point,
+c     not like INTEGER!
+c     
+c     1. Temperature: (in K) (REAL)
+c     -the model is restricted to the temperature range from
+c     200 K to 800 K.
+c     
+c     2. Frequency limits: (in cm^-1) (REAL,REAL)
+c     -the model has been designed to reproduce the MD and the
+c     experimental data up to 250 cm^-1. There is no restriction
+c     on requesting a higher value, but the accuracy may decrease 
+c     significantly.
+c     
+c     3. Number of points in the output file: (less than Npmx) (INTEGER)
+c     -the frequency grid is controled by the number of points
+c     in the output file.
+c     (i.e. if the upper limit = 250.0 and the number of points = 50.0,
+c     the spectrum will be computed every 5 cm^-1 )
+c     
+c     4. The output in automaticaly directed to output.dat file.
+c     
+c     STRUCTURE OF THE PROGRAM:
+c     -------------------------------------------------------------- 
+c     The MAIN program consists of three modules:
+c     
+c     1. getdat - provides the user interface, 
+c     in this subroutine the Temperature, Frequency Limits and
+c     the number of points are read from the keyboard.
+c     
+c     2. getspc - the main subroutine, where the spectrum is computed.
+c     The three input parameters (temp, range and n; all REAL numbers)
+c     are transmited by value and the absorption coefficient abcoef(..) 
+c     is returned. The default lenght of abcoef(..) is Npmx and if 
+c     n < Npmx, the empty places are set to 0. If a denser grid is
+c     required please change the n appropriaetly in the data declaration
+c     of the MAIN program and inside the getspc.
+c     
+c     3. putdat - generates the output file.
+c     The frequency (in cm^-1) and 
+c     the absorption coefficient (in cm^-1 amagat^-2) are written
+c     to the 'output.dat' file in the followinf format:
+c     format(f10.3,e20.7)
+c     
+c===========================================================================
+c     
+c     
+c     ---------------------------------------------------------------------------------------------------------------
+c     2008/10/15
+c     
+c     Modifications of the code by V. Eymet as follows:
+c     + only the "getspc" routine remains
+c     + inputs: temp (temperature in K), wn (wavenumber in cm^-1); output: abcoef (absorption coefficient, in cm^-1 amagat^-2)
+c     ---------------------------------------------------------------------------------------------------------------
+c
+c
+c
+c     ---------------------------------------------------------------------------------------------------------------
+c     2009/2/28
+c     
+c     Modifications of the code by R. Wordsworth as follows:
+c     + "baranov" routine added to calculate CIA dimer spectrum between 1100 and 1600 cm^-1
+c     + this uses recorded data rather than an analytical function, so bilinear interpolation is needed
+c     + inputs and outputs are identical to those of getspc
+c     ---------------------------------------------------------------------------------------------------------------
+
+
+
+      subroutine getspc(temp,wn,abcoef) ! computes the spectrum
+      implicit none
+      real*8 temp               !temperature
+      real*8 wn        !wavenumber
+      real*8 abcoef       !absorption coefficient
+c     -------------------------------------------------------
+c     The A, B and C parameters as given in the paper:
+      integer ndeg
+      parameter (ndeg=3)
+      real*8 ah(ndeg),bh(ndeg),at(ndeg),bt(ndeg),gam(ndeg)
+c     tau^{L}_{1}:
+      data ah /0.1586914382D+13,-0.9344296879D+01,0.6943966881D+00/
+c     tau^{L}_{2}:
+      data bh /0.1285676961D-12,0.9420973263D+01,-0.7855988401D+00/
+c     tau^{H}_{1}:
+      data at /0.3312598766D-09,0.7285659464D+01,-0.6732642658D+00/
+c     tau^{H}_{2}:
+      data bt /0.1960966173D+09,-0.6834613750D+01,0.5516825232D+00/
+c     gamma_{1}:
+      data gam /0.1059151675D+17,-0.1048630307D+02, 0.7321430968D+00/
+c     **************************************************************
+c     The S - shape function parameters:
+      real*8 w1,w2
+      data w1,w2 /50.0d0, 100.0d0/
+c     --------------------------------------------------------------
+c     local variables:
+c     ----------------------------------
+      real*8 incrmt
+      integer p1,p2,n
+      real*8 a1,b1,a2,b2,gamma
+      real*8 bc1,bc2,bcbc
+      real*8 scon,mtot,spunit,gm0con
+      real*8 icm, frq, lntemp
+      real*8 xk1,x1,x2
+      external xk1
+      incrmt=250.0D+0
+      n=1
+      p1=idint(dnint(w1/incrmt))
+      p2=idint(dnint(w2/incrmt))
+      lntemp=dlog(temp)
+      a1=1.0d0/(ah(1)*dexp(ah(2)*lntemp+ah(3)*lntemp*lntemp))
+      b1=bh(1)*dexp(bh(2)*lntemp+bh(3)*lntemp*lntemp)
+      a2=1.0d0/(at(1)*dexp(at(2)*lntemp+at(3)*lntemp*lntemp))
+      b2=bt(1)*dexp(bt(2)*lntemp+bt(3)*lntemp*lntemp)
+      gamma=gam(1)*dexp(gam(2)*lntemp+gam(3)*lntemp*lntemp)
+      icm=0.1885d0
+      frq=wn
+      x1=b1*dsqrt(a1*a1+icm*icm*frq*frq)
+      bc1=dexp(a1*b1)*a1*XK1(x1)/(a1*a1+icm*icm*frq*frq)
+      x2=b2*dsqrt(a2*a2+icm*icm*frq*frq)
+      bc2=dexp(a2*b2)*a2*XK1(x2)/(a2*a2+icm*icm*frq*frq)
+      if (p1.ge.1) then
+         bcbc=bc1
+      else if (p2.lt.1) then
+         bcbc=bc2
+      else
+         bcbc=dexp( (1.0d0-dble(1-p1)/dble(p2-p1))*dlog(bc1)+
+     &        dble(1-p1)/dble(p2-p1)*dlog(bc2) )
+      endif
+      spunit=1.296917d55
+      gm0con=1.259009d-6
+      scon=spunit/temp
+      mtot=gm0con*temp*gamma*1.0d-56
+      frq=wn
+      abcoef=scon*mtot*bcbc*frq*frq
+      return
+      end
+c     
+c     
+      FUNCTION XK1(X)
+C     MODIFIED BESSEL FUNCTION K1(X) TIMES X
+C     PRECISION IS BETTER THAN 2.2e-7 EVERYWHERE.
+C     ABRAMOWITZ AND S,TEGUN, P.379; TABLES P.417.
+      implicit double precision (a-h,o-z)
+!      IF(X-2.) 10,10,20
+      IF(X-2..le.0.0)then
+! 10   T=(X/3.75)**2
+      T=(X/3.75)**2
+      FI1=X*((((((.00032411*T+.00301532)*T+.02658733)*T+.15084934)
+     1     *T+.51498869)*T+.87890594)*T+.5)
+      T=(X/2.)**2
+      P=(((((-.00004686*T-.00110404)*T-.01919402)*T-.18156897)*T-
+     1     .67278579)*T+.15443144)*T+1.
+      XK1=X*dLOG(X/2)*FI1+P
+!      RETURN
+      else
+! 20   T=2./X
+      T=2./X
+      P=(((((-.00068245*T+.00325614)*T-.00780353)*T+.01504268)*T-
+     1     .03655620)*T+.23498619)*T+1.25331414
+      X=dMIN1(X,330.d0)
+      XK1=dSQRT(X)*dEXP(-X)*P
+      endif
+      RETURN
+      END
+
+
+
+
+c     ----------------------------------------------------------------------------------------------
+c     Added by RDW for inclusion of Baranov (2004) data
+      subroutine baranov(temp,wn,abcoef)
+      ! computes the dimer spectrum
+
+      implicit none
+      real*8 temp               !temperature
+      real*8 wn                 !wavenumber
+      real*8 abcoef             !absorption coefficient
+
+      integer nS,nT
+!      parameter(nS=1713)
+      parameter(nS=3000)
+      parameter(nT=9)
+
+      real*8 wn_arr(nS)
+      real*8 temp_arr(nT)
+      real*8 dim_arr(nS,nT)
+
+      integer pop
+      logical firstcall
+
+      save wn_arr, temp_arr, dim_arr
+
+      character*100 dt_file
+      integer strlen,ios
+      character*100 label
+      label='subroutine baranov'
+
+      dt_file='/san/home/rdword/kspectrum/line_data/CO2_dimer_data_NEW'
+!      dt_file='./data/CO2_dimer_data'
+      open(33,file=dt_file(1:strlen(dt_file)),
+     &     form='unformatted',
+     &     status='old',iostat=ios)
+      if (ios.ne.0) then        ! file not found
+         write(*,*) 'Error from ',label(1:strlen(label)),' :'
+         write(*,*) 'Data file could not be found:'
+         write(*,*) dt_file(1:strlen(dt_file))
+         stop
+      else
+         read(33) wn_arr
+         read(33) temp_arr
+         read(33) dim_arr
+      endif
+      close(33)
+
+
+!	print*,wn_arr(1)!
+!	print*,wn_arr(3000)
+!	print*,temp_arr
+!	print*,dim_arr(1500,1)
+!	stop
+
+
+      call bilinear(wn_arr,temp_arr,nS,nT,dim_arr,wn,temp,abcoef)
+
+ 111  continue
+      return
+      end
+c     ----------------------------------------------------------------------------------------------
+
+c     ----------------------------------------------------------------------------------------------
+c     Added by RDW for inclusion of Baranov (2004) data
+      subroutine bilinear(x_arr,y_arr,nX,nY,f2d_arr,x,y,f)
+
+      implicit none
+
+      integer nX,nY,i,j,a,b
+
+      real*8 x,y,x1,x2,y1,y2
+      real*8 f,f11,f12,f21,f22,fA,fB
+      real*8 x_arr(nX)
+      real*8 y_arr(nY)
+      real*8 f2d_arr(nX,nY)
+      
+      integer strlen
+      character*100 label
+      label='subroutine bilinear'
+
+c     1st check we're within the wavenumber range
+      if ((x.lt.x_arr(2)).or.(x.gt.x_arr(nX-2))) then
+         f=0.0D+0
+c     print*,'x=',x,x_Arr(2),x_arr(nX-2)
+c     stop('Outside CIA dimer wavenumber range!\n')
+         goto 112
+      else
+         
+c     in the x (wavenumber) direction 1st
+         i=1
+ 10      if (i.lt.(nX+1)) then ! what passes for a 'while' loop in this sorry language...
+            if (x_arr(i).gt.x) then
+               x1=x_arr(i-1)
+               x2=x_arr(i)
+               a=i-1
+               i=9999
+            endif
+            i=i+1
+            goto 10
+         endif
+      endif
+      
+      if ((y.lt.y_arr(1)).or.(y.gt.y_arr(nY))) then
+         write(*,*) 'Error from ',label(1:strlen(label)),' :'
+         write(*,*) 'Outside CIA dimer temperature range!'
+         if(y.lt.y_arr(1))then
+            y=y_arr(1)+0.01
+         endif
+         if(y.gt.y_arr(nY))then
+            y=y_arr(nY)-0.01
+         endif
+!         stop
+      else
+c     in the y (temperature) direction 2nd
+         j=1
+ 20      if (j.lt.(nY+1)) then
+            if (y_arr(j).gt.y) then
+               y1=y_arr(j-1)
+               y2=y_arr(j)
+               b=j-1
+               j=9999
+            endif
+            j=j+1
+            goto 20
+         endif
+      endif
+      
+      f11=f2d_arr(a,b)
+      f21=f2d_arr(a+1,b)
+      f12=f2d_arr(a,b+1)
+      f22=f2d_arr(a+1,b+1)
+      
+c     1st in x-direction
+      fA=f11*(x2-x)/(x2-x1)+f21*(x-x1)/(x2-x1)
+      fB=f12*(x2-x)/(x2-x1)+f22*(x-x1)/(x2-x1)
+      
+c     then in y-direction
+      f=fA*(y2-y)/(y2-y1)+fB*(y-y1)/(y2-y1)
+      
+ 112  continue
+      return
+      end
+c     ----------------------------------------------------------------------------------------------
+      
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/compile_corrk
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/compile_corrk	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/compile_corrk	(revision 1644)
@@ -0,0 +1,11 @@
+#!/bin/bash
+#gfortran -c -g -fbounds-check generate_kmatrix.F90 strlen.for
+
+gfortran -c generate_kmatrix.F90 co2_cont.for strlen.for
+gfortran -o generate_kmatrix.exe generate_kmatrix.o co2_cont.o strlen.o
+
+gfortran -c make_composition_gen.for strlen.for
+gfortran -o make_composition_gen.exe make_composition_gen.o strlen.o
+
+rm -f *o
+rm -f *~
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/38x36/narrowbands_IR.in
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/38x36/narrowbands_IR.in	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/38x36/narrowbands_IR.in	(revision 1644)
@@ -0,0 +1,39 @@
+ 38
+  10.0    100.0
+  100.0   160.0
+  160.0   220.0
+  220.0   280.0
+  280.0   330.0
+  330.0   380.0
+  380.0   440.0
+  440.0   495.0
+  495.0   545.0
+  545.0   617.0
+  617.0   667.0
+  667.0   720.0
+  720.0   800.0
+  800.0   875.0
+  875.0   940.0
+  940.0   1000.0
+  1000.0  1065.0
+  1065.0  1108.0
+  1108.0  1200.0
+  1200.0  1275.0
+  1275.0  1350.0
+  1350.0  1450.0
+  1450.0  1550.0
+  1550.0  1650.0
+  1650.0  1750.0
+  1750.0  1850.0
+  1850.0  1950.0
+  1950.0  2150.0
+  2150.0  2250.0
+  2250.0  2450.0
+  2450.0  2650.0
+  2650.0  2850.0
+  2850.0  3000.0
+  3000.0  3200.0
+  3200.0  3400.0
+  3400.0  3600.0
+  3600.0  3800.0
+  3800.0  4000.0
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/38x36/narrowbands_VI.in
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/38x36/narrowbands_VI.in	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/38x36/narrowbands_VI.in	(revision 1644)
@@ -0,0 +1,37 @@
+           36
+    1950.000000000000         2050.000000000000     
+    2050.000000000000         2200.000000000000     
+    2200.000000000000         2397.000000000000     
+    2397.000000000000         2494.000000000000     
+    2494.000000000000         2796.000000000000     
+    2796.000000000000         3087.000000000000     
+    3087.000000000000         3425.000000000000     
+    3425.000000000000         3760.000000000000     
+    3760.000000000000         4030.000000000000     
+    4030.000000000000         4540.000000000000     
+    4540.000000000000         4950.000000000000     
+    4950.000000000000         5370.000000000000     
+    5370.000000000000         5925.000000000000     
+    5925.000000000000         6390.000000000000     
+    6390.000000000000         6990.000000000000     
+    6990.000000000000         7650.000000000000     
+    7650.000000000000         8315.000000000000     
+    8315.000000000000         8850.000000000000     
+    8850.000000000000         9350.000000000000     
+    9350.000000000000         9650.000000000000     
+    9650.000000000000         10400.00000000000     
+    10400.00000000000         11220.00000000000     
+    11220.00000000000         11870.00000000000     
+    11870.00000000000         12750.00000000000     
+    12750.00000000000         13300.00000000000     
+    13300.00000000000         14470.00000000000     
+    14470.00000000000         15000.00000000000     
+    15000.00000000000         15385.00000000000     
+    15385.00000000000         16667.00000000000     
+    16667.00000000000         18182.00000000000     
+    18182.00000000000         20000.00000000000     
+    20000.00000000000         22222.00000000000     
+    22222.00000000000         25000.00000000000     
+    25000.00000000000         28571.00000000000     
+    28571.00000000000         33333.00000000000     
+    33333.00000000000         35000.00000000000
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/Q.dat
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/Q.dat	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/Q.dat	(revision 1644)
@@ -0,0 +1,15 @@
+	4
+N2 
+CO2
+CH4
+H2O
+	7
+1.0e-7
+1.0e-6
+1.0e-5
+1.0e-4
+1.0e-3
+1.0e-2
+1.0e-1
+
+
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/T.dat
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/T.dat	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/T.dat	(revision 1644)
@@ -0,0 +1,7 @@
+	6
+100
+150
+200
+250
+300
+350
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/p.dat
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/p.dat	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/corrk_test/p.dat	(revision 1644)
@@ -0,0 +1,10 @@
+	9
+-3
+-2
+-1
+0
+1
+2
+3
+4
+5
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/formats.inc
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/formats.inc	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/formats.inc	(revision 1644)
@@ -0,0 +1,42 @@
+ 10   format(a)
+ 11   format(I1)
+ 12   format(I2)
+ 13   format(I3)
+ 14   format(I4)
+ 15   format(I5)
+ 16   format(I6)
+ 17   format(I7)
+ 18   format(I8)
+ 19   format(I9)
+ 110   format(I10)
+ 20   format(a23,I3,I3)
+ 21   format(a1)
+ 22   format(i3,a1,a10)
+ 30   format(a30,i3)
+ 31   format(a18,i3)
+ 32   format(a22,i3,a1,i3)
+ 33   format(a23,i3,a1,i3)
+ 34   format(a21,i3)
+ 35   format(a36,i3)
+ 36   format(a3,e17.9,a9,i4)
+   37   format(I1,I9,a100)
+   38   format(I9,a100)
+   39   format(a30,i3)
+   40  format(a,f9.3,a,f9.3,a)
+   41 format(a,f9.3,a)
+   42 format(a,I3,a,I3,a,I3,a)
+   43 format(a,I3,a)
+   44 format(I2,a)
+   45 format(I2,a,I2,a)
+   46 format(I2,a,I2,a,I2,a)
+   47 format(I2,a,I2,a,I2,a,I2,a)
+ 50   format(1000e17.9)
+ 51   format(I3,1000e17.9)
+ 52   format(1000e23.15)
+ 60   format(I2,I1,F12.6,2E10.3,2F5.4,F10.4,F4.2,F8.6,! &
+     &       4A15,6I1,6I2,A1,2F7.1)
+ 62   format(i12,F13.5,F14.4,i5,E14.6)
+ 63   format(I2)
+ 70   format(I2,I1,F12.6,1P2E10.3,0P2F5.4,F10.4,F4.2,F8.6,! &
+     &       2I3,2A9,3I1,3I2)
+ 80   format(I2,I1,F12.6)
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/generate_kmatrix.F90
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/generate_kmatrix.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/generate_kmatrix.F90	(revision 1644)
@@ -0,0 +1,461 @@
+      program generate_kmatrix
+      implicit none
+
+!     -------------------------------------------------------------
+!     Purpose: to read hires spectra and produce kdistribution data
+!     Authour: Robin Wordsworth (2010)
+!     -------------------------------------------------------------
+
+      integer nmolec,mol
+      integer i,j,k,im
+      integer Nb
+
+      character*4 fname
+      character*32 fnum
+
+      integer iT, iP, iQ, Nlevs
+
+      double precision nuT, sigT, kT
+
+      integer Nq
+      parameter (Nq=16) ! we choose this here
+
+      integer Nmax
+      parameter (Nmax=1000) ! maximum number of levels
+
+      integer Nmol_max
+      parameter (Nmol_max=10) ! maximum number of radiatively active species
+
+      integer Nkmax
+      ! large array = slow calculation... this makes a huge difference
+      !parameter (Nkmax=50000) ! works for IR, 27 bands
+      !parameter (Nkmax=100000) ! works for IR, 27 bands
+      !parameter (Nkmax=140000) ! works for IR, 32 bands
+      !parameter (Nkmax=250000) ! works for VI, 36 bands
+      parameter (Nkmax=400000) ! works for IR, 8 bands
+      !parameter (Nkmax=400000) ! works for VI, 12 bands
+      !parameter (Nkmax=200000) ! works for IR, 30 bands
+
+      integer NbMAX
+      parameter (NbMAX=100)
+
+      integer Ngres
+      parameter (Ngres=200)
+
+      character*10 molec_names(1:Nmol_max)
+      double precision T(1:Nmax), P(1:Nmax), Q(1:Nmax)
+
+
+      double precision pi
+      parameter (pi=3.14159265)
+      double precision x
+      double precision y(1:Nq+2)
+
+      double precision nu_min(1:NbMAX) ! make allocatable?
+      double precision nu_max(1:NbMAX)
+
+      integer quad, band
+
+      double precision ktemp(1:Nq)
+      double precision w(1:Nq), gw(1:Nq)
+
+      double precision, allocatable :: kdist_temp(:)
+      double precision, allocatable :: kdist(:,:,:,:,:)
+
+      double precision nuband(1:Nkmax), kband(1:Nkmax), nuwband(1:Nkmax) ! better static I think
+      double precision nuwbtot
+
+      double precision gfine(1:Ngres)      
+      double precision klevs(1:Ngres)
+      double precision addline(1:Nkmax)
+
+      double precision kmax, kmin, lkmax, lkmin, dlogK, klev
+      integer ic, ib, ig, ik1, ik2
+
+      integer filerr
+      logical filexi
+
+      logical addCIA
+      integer iCO2
+      double precision k1,k2,kCIA,amg,Pp
+
+      real truemean, distmean, etot
+      
+
+      addCIA=.false.
+
+      print*,'Creating the GCM correlated-k data...'
+      print*,' '
+
+      !--------------------------------------------------------
+      ! load temperature, pressure, mixing ratio data
+      open(9,file='T.dat')
+      read(9,*) iT
+      do i=1,iT
+         read(9,*) T(i)
+      enddo
+      close(9)
+
+      open(10,file='p.dat')
+      read(10,*) iP
+      do i=1,iP
+         read(10,*) P(i)
+         P(i)=10.**P(i)  ! note we keep P in millibars for the conversion later
+      enddo
+      close(10)
+
+      open(11,file='Q.dat')
+      read(11,*) nmolec
+      do mol=1,nmolec
+         read(11,*) molec_names(mol)
+      enddo
+      read(11,*) iQ
+      do i=1,iQ
+         read(11,*) Q(i)
+      enddo
+      close(11)
+
+      Nlevs=iT*iP*iQ ! total number of layers
+
+      print*,'Temperature layers:  ',iT
+      print*,'Pressure layers:     ',iP
+      print*,'Mixing ratio layers: ',iQ
+      print*,'Total:               ',Nlevs
+
+
+      if(addCIA)then
+
+         if(nmolec.gt.2)then
+            print*,'I cant deal with this situation yet'
+            call abort
+         endif
+
+         iCO2=0
+         do mol=1,nmolec
+            if(molec_names(mol).eq.'CO2')then
+               iCO2=mol
+            endif
+         enddo
+
+         !if(iCO2.eq.1)then
+         print*,' '
+         print*,'--- Adding CO2 CIA ---'
+         !else
+         !   print*,'Warning, not CO2+H2O mixture, need CO2 mixing ratio'
+         !   call abort
+         !endif
+      endif
+
+      !--------------------------------------------------------
+      ! load spectral data
+      open(12,file='narrowbands.in')
+      read(12,*) Nb
+
+      do band=1,Nb
+         read(12,*) nu_min(band),nu_max(band)
+      enddo
+      close(12)
+
+      print*,' '
+      print*,'Number of spectral bands: ',Nb
+
+      print*,'Band limits:'
+      do band=1,Nb
+         print*,band,'-->',nu_min(band),nu_max(band),' cm^-1'
+      end do
+
+      !--------------------------------------------------------
+      ! create g-space data
+      do quad=0,Nq+1
+         x=dble(quad)/dble(Nq+2)
+         !y(quad+1)=sin(pi*x)*exp(-5*x)
+         !y(quad+1)=sin(pi*x)*exp(-9*x)  ! CO2_H2Ovar 38x36
+         y(quad+1)=sin(pi*x)*exp(-12*x)
+         !y(quad+1)=sin(pi*x)*exp(-15*x) ! CO2_CH4
+      enddo
+
+      do quad=1,Nq
+         w(quad)=y(quad+1)
+      enddo
+      w=w/sum(w)
+
+      print*,' '
+      print*,'Number of g-space intervals: ',Nq
+
+      print*,'g-space weighting:'
+      do quad=1,Nq
+         print*,quad,'-->',w(quad)
+      end do
+
+      ! write g-space data
+      open(14,file='g.dat')
+      write(14,*) Nq+1
+
+      do quad=1,Nq
+         write(14,*) w(quad)
+      enddo
+      write(14,*) 0.0
+      close(14)
+
+      ! cumulative sum for g-vector
+      gw(1)=w(1)
+      do quad=2,Nq
+         gw(quad)=gw(quad-1)+w(quad)
+      enddo
+
+      ! allocate 5D matrices
+      allocate(kdist_temp(Nq))
+      allocate(kdist(iT,iP,iQ,Nb,Nq+1))
+
+
+      nuT=0.0
+      do i=1,iQ
+         do j=1,iP
+
+
+            if(addCIA.and.(iCO2.eq.1))then 
+               Pp=P(j)*(1.0-Q(i))
+            else
+               Pp=P(j)*Q(i)
+            endif
+            !if(addCIA) Pp=P(j)*(1.0-Q(i))
+
+
+            do k=1,iT             
+               im = (i-1)*iP*iT + (j-1)*iT + k
+
+               !-----------------------------------------------
+               ! open kspectrum file
+               write(fnum,*) im
+               if(im<10)then
+                   fname='k00'//trim(adjustl(fnum))
+               elseif(im<100)then
+                   fname='k0'//trim(adjustl(fnum))
+               else
+                   fname='k'//trim(adjustl(fnum))
+               endif
+
+               ! check that the file exists
+               inquire(FILE='hires_spectrum/'//fname,EXIST=filexi)
+               if(.not.filexi) then
+                  write(*,*)'The file ',fname(1:LEN_TRIM(fname))
+                  write(*,*)'was not found in the folder hires_spectrum, exiting.'
+                  call abort
+               endif
+
+               print*,'Opening file ',fname(1:LEN_TRIM(fname))
+               open(17,file='hires_spectrum/'//fname)
+
+               nuT=0.0
+               do band=1,Nb
+               print*,'Band ---> ',band
+
+                  !--------------------------------------------
+                  ! write kdata to temporary band arrays
+                  ! and find max / min k-values in band
+                  do while (nuT.lt.nu_min(band))
+                      read(17,*,IOSTAT=filerr) nuT, sigT, kT
+                   ! ideally need to catch all errors here (ask Ehouarn)
+                      if(filerr.lt.0)then
+                         print*,    &
+                             'nu_min greater than highest value in file'
+                         print*,'IOSTAT=',filerr
+                         print*,'nu_min=',nu_min(band)
+                         print*,'nu_endoffile=',nuT
+                         call abort
+                      endif
+                  enddo
+
+                  ic=1
+                  kmin=kT
+                  kmax=kT
+                  nuband(:)=0
+                  kband(:)=0
+
+                  do while (nuT.lt.nu_max(band))
+
+                      nuband(ic)=nuT
+                      kband(ic)=kT
+
+                      ! insert CIA option here
+                      if(addCIA)then
+
+                         k1=0.0
+                         k2=0.0
+                         if(nuT.lt.500.0) call getspc(T(k),nuT,k1)
+                         if((nuT.gt.1000.0).and.(nuT.lt.1800.0)) call baranov(T(k),nuT,k2)
+                         ! cm^-1.amagat^2
+
+                         amg=273.15D+0/T(k)*(Pp/1013.25) ! amagats of CO2
+
+                         kCIA=(k1+k2)*1.0D+2*amg**2.0D+0 ! m^-1
+                         kband(ic)=kband(ic)+kCIA
+                   	 kT=kband(ic)
+
+                         !kband(ic)=kCIA
+			 !kT=kCIA
+			 !if(nuband(ic).gt.1250.0)then
+			 !	print*,'P=',P(i)
+			 !	print*,'T=',T(k)
+		         !	print*,'amg=',amg
+			 !	print*,'nu=',nuband(ic)
+                         !       print*,'k1=',k1
+                         !       print*,'k2=',k2
+                         !       print*,'kCIA=',kCIA
+		  	 !	call abort
+                         !endif
+
+                      endif
+
+                      if(kT.lt.kmin)then
+                        kmin=kT
+                      endif
+                      if(kT.gt.kmax)then ! bug corrected!
+                        kmax=kT
+                      endif
+
+                      read(17,*,IOSTAT=filerr) nuT, sigT, kT
+                      if(filerr.lt.0)then
+                         print*,    &
+                             'nu_max greater than highest value in file'
+                         print*,'IOSTAT=',filerr
+                         print*,'nu_max=',nu_max(band)
+                         print*,'nu_endoffile=',nuT
+                         call abort
+                      endif
+
+
+                      ic=ic+1
+                      
+                      if(ic.gt.Nkmax)then
+                         print*,'Spectral resolution too low for these bands, exiting!'
+                         print*,'Increase Nkmax in generate_kmatrix.F90.'
+                         call abort
+                      endif
+
+                  enddo
+                  nuband(ic)=nuT
+                  kband(ic)=kT
+
+                  if(kmax.le.0.0)then
+                  !if(kmax.le.1.0e-15)then
+                     print*,'kmax=',kmax
+                     print*,'Setting values to zero in this band.'
+                     kdist(k,j,i,band,1:(Nq+1))=0.0
+                  else
+
+                  if(kmin.lt.1e-30)then
+                     kmin=1.0e-30
+                  endif
+
+                  !--------------------------------------------
+                  ! calculate delta nu values
+                  nuwband(:)=0.0
+                  do ib=2,(ic-1)
+                      nuwband(ib)=(nuband(ib+1)-nuband(ib-1))/2
+                  enddo
+                  nuwband(1)=nuwband(2)
+                  nuwband(ic)=nuwband(ic-1) ! causes tiny boundary error; whatever
+                  nuwbtot=sum(nuwband)
+
+                  lkmax=log10(kmax)
+                  lkmin=log10(kmin)
+                  
+                  dlogK=(lkmax-lkmin)/(Ngres-1)                 
+
+                  !--------------------------------------------
+                  ! calculate the g function
+                  gfine(:)=0.0
+                  do ig=1,Ngres
+                    klev=lkmin + dble(ig)*dlogK
+                    klev=10**klev
+                    klevs(ig)=klev
+
+                    addline(:)=0
+                    do ib=1,ic
+                        if(kband(ib).lt.klev)then
+                           addline(ib)=1.0
+                        endif
+                    enddo
+                    gfine(ig)=sum(addline(:)*nuwband(:))/nuwbtot
+
+                  enddo
+                  print*,'gnorm    = ',gfine(Ngres)
+
+                  !--------------------------------------------
+                  ! invert the g function
+                  ik1=1
+                  ik2=1
+                  kdist_temp(:)=0.0
+                  do quad=1,Nq
+                    
+                    ik2=ik1
+
+                    gfind: do while (gfine(ik2).lt.gw(quad))
+                       ik2=ik2+1
+                       if(ik2.gt.Ngres)then
+                          print*,'g-inversion overflow...'
+                          ik2=Ngres
+                          exit gfind
+                       endif
+                    enddo gfind
+
+                    !if(ik2.gt.Ngres)then ! avoid out-of-bounds on final step
+                    !   ik2=Ngres
+                    !endif
+
+
+                     if(.not.(ik1.ge.ik2))then ! this could probably be improved
+                        !kdist_temp(quad)=sum(klevs(ik1:ik2))/(ik2-ik1) ! a bug was here!
+                        kdist_temp(quad)=sum(klevs(ik1:ik2))/(ik2+1-ik1)
+
+
+                     elseif(quad.ne.1)then
+                        kdist_temp(quad)=kdist_temp(quad-1)
+                     else
+                        kdist_temp(quad)=kmin
+                     endif
+
+                     !-----------------------------------------
+                     ! assign to 5D matrix and convert to cm^2 / molecule
+                     kdist(k,j,i,band,quad)=1.3807e-21 *               &
+                                kdist_temp(quad) * T(k)/P(j)
+
+                     ik1=ik2
+                  enddo ! g-space
+                  kdist(k,j,i,band,Nq+1)=0.0
+
+                  truemean = sum(kband(1:ic)*nuwband(1:ic))/sum(nuwband(1:ic))
+                  distmean = sum(kdist_temp(:)*w(:))/sum(w)
+                  etot     = 100*abs(truemean-distmean)/(distmean+truemean)
+                  print*,'truemean = ',truemean
+                  print*,'distmean = ',distmean
+                  !print*,'kdisttemp = ',kdist_temp(Nq)
+                  !print*,'kdistmax  = ',kmax
+                  print*,'etot (%) = ',etot
+                  !print*,'w  = ',w
+
+                  endif ! if kmax .le. 0.0 
+
+               enddo ! bands
+
+            enddo
+         enddo
+      enddo
+
+      !--------------------------------------------------------
+      ! save data and clean up
+      close(17)
+      open(14,file='corrk_gcm.dat',form='formatted')
+      write(14,*) kdist
+      close(14)
+      print*,' '
+      print*,'Correlated-k data saved in corrk_gcm.dat'
+      print*,' '
+      print*,'Now you must change the values of L_NTREF etc. in radinc_h.F90 (if necessary)'
+      print*,'and the variable "corrkdata" in callphys.def'
+
+      deallocate(kdist_temp)
+      deallocate(kdist)
+
+    end program generate_kmatrix
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/make_composition_gen.for
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/make_composition_gen.for	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/make_composition_gen.for	(revision 1644)
@@ -0,0 +1,161 @@
+      program make_composition_gen
+      implicit none
+
+!     -------------------------------------------------------------   
+!     Purpose: to create "composition.in" file readable by kspectrum
+!     Authour: Robin Wordsworth (2010)
+!     -------------------------------------------------------------
+
+      include 'max.inc'
+      include 'formats.inc'
+      integer strlen,nmolec,nlev_mf,mol,imf,ind,indf
+      integer i,j,k,im,m
+      integer nb,na,ne
+      double precision alt(1:Nmax)
+      double precision pres(1:Nmax)
+      double precision temp(1:Nmax)
+
+      double precision P_mf(1:Nmax)
+      double precision x(1:Nmax,1:Nmol_max)
+      double precision xlev(1:Nmol_max)
+      double precision xconst(1:Nmol_max)
+      character*100 composition_file,model_file
+      character*100 planet_descriptor
+      character*200 string
+      character*20 s
+      character*10 molec_names(1:Nmol_max),molname
+      character*1 spch
+
+      integer iP, iT, iQ
+      double precision P(1:Nmax), T(1:Nmax), Q(1:Nmax)
+
+      spch=' '
+
+      print*,'Name of atmosphere / planet:'
+      read*,planet_descriptor
+
+      composition_file='./composition.in'
+
+!     ! nmolec=2 ! total number of molecules
+
+      ! load temperature, pressure, mixing ratio data
+      open(9,file='T.dat')
+      read(9,*) iT
+      do i=1,iT
+         read(9,*) T(i)
+      enddo
+      close(9)
+
+      open(10,file='p.dat')
+      read(10,*) iP
+      do i=1,iP
+         read(10,*) P(i)
+         P(i)=10.**P(i)/1013.25
+      enddo
+      close(10)
+
+      open(11,file='Q.dat')
+      read(11,*) nmolec
+
+      print*,'nmolec=',nmolec
+
+      do mol=1,nmolec
+         read(11,*) molec_names(mol)
+      enddo
+      read(11,*) iQ
+      do i=1,iQ
+         read(11,*) Q(i)
+      enddo
+      close(11)
+
+      m=iP*iT*iQ ! total number of layers
+
+      print*,'Temperature layers:  ',iT
+      print*,'Pressure layers:     ',iP
+      print*,'Mixing ratio layers: ',iQ
+      print*,'Total:               ',m
+
+      do mol=1,nmolec-1
+         print*,'Please enter vmr of ',molec_names(mol)
+         read(*,*) xconst(mol)
+      end do
+
+     
+      do i=1,iQ
+         do j=1,iP              
+            do k=1,iT
+
+               im = (i-1)*iP*iT + (j-1)*iT + k
+
+               alt(im)=0.D0
+               pres(im)=P(j)
+               temp(im)=T(k)
+
+               do mol=1,nmolec-1
+                  x(im,mol)=xconst(mol)*(1.0-Q(i))
+               enddo
+               x(im,nmolec)=Q(i)
+
+            enddo
+         enddo
+      enddo
+
+      open(12,file=composition_file(1:strlen(composition_file)))
+      string='Atmospheric composition input '
+      string=string(1:strlen(string))//' data file for planet:'
+      string=string(1:strlen(string))//' '//
+
+     &     planet_descriptor(1:strlen(planet_descriptor))
+      write(12,'(a)') string(1:strlen(string))
+      write(12,39) 'Number of atmospheric levels: ',m
+      write(12,34) 'Number of molecules: ',nmolec
+      write(12,*) 
+      string='      z (km)     /    P (atm)     /     T (K) *'
+
+
+      do mol=1,nmolec
+
+         molname=molec_names(mol)
+
+         nb=5
+         if (strlen(molname).eq.1) then
+            na=7
+         else if (strlen(molname).eq.2) then
+            na=6
+         else if (strlen(molname).eq.3) then
+            na=5
+         endif
+         s='*'
+         do ne=1,nb
+            s=s(1:strlen(s)-1)//spch//'*'
+         enddo
+         s=s(1:strlen(s)-1)//'/*'
+         do ne=1,na
+            s=s(1:strlen(s)-1)//spch//'*'
+         enddo
+         
+         string=string(1:strlen(string)-1)
+     &        //s(1:strlen(s)-1)
+     &        //'x['
+     &        //molname(1:strlen(molname))
+     &        //']*'
+      enddo
+      write(12,*) string(1:strlen(string)-1)
+
+      do im=1,m
+
+         do mol=1,nmolec
+            xlev(mol)=x(im,mol)
+         enddo                  ! mol
+
+         write(12,50) alt(im),pres(im),temp(im),(xlev(mol),mol=1,nmolec)
+
+      enddo
+
+      write(12,*) 
+      close(12)
+
+      write(*,*) 'Output file successfully generated:'
+      write(*,*) composition_file(1:strlen(composition_file))
+      
+      end
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/max.inc
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/max.inc	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/max.inc	(revision 1644)
@@ -0,0 +1,23 @@
+          integer Nline_mx,Nmol_max,Niso_max,Nbmx,Nkmx,Nmax,Nlpnb_mx
+	    integer Nxtab_mx,Nacc_mx,Nmax_tab,Nytab_mx,Nktab_mx
+	    integer nfiles_mx,Nproc_mx,Nchunk_mx,Nc_mx,Nmax_vt,Nppc_max
+	    integer Nti_mx
+          parameter(Nline_mx=2000000)
+          parameter(Nmol_max=42)
+          parameter(Niso_max=15)
+	  parameter(Nbmx=10000)
+	  parameter(Nkmx=100000)
+	  parameter(Nmax=2000)
+	  parameter(Nlpnb_mx=500000)
+	  parameter(Nxtab_mx=100000)
+	  parameter(Nacc_mx=1000)
+	  parameter(Nmax_tab=1000000)
+	    parameter(Nytab_mx=210)
+	    parameter(Nktab_mx=1000000)
+	    parameter(nfiles_mx=100)
+	    parameter(Nproc_mx=1000)
+	    parameter(Nchunk_mx=1000)
+	    parameter(Nc_mx=9)
+	    parameter(Nmax_vt=1000000)
+	    parameter(Nppc_max=10000)
+	    parameter(Nti_mx=100000)
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/postkspectrum
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/postkspectrum	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/postkspectrum	(revision 1644)
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+DWORK_DIR=$RAD/CORRELATEDK/avec_robin_data
+KSPEC_DIR=$KSPECTRUM/kspec_run
+#BANDS_DIR=32x36
+BANDS_DIR=38x36
+
+### if hires_spectrum don't exist then create it, copy data from kspectrum
+DIRCHECK=hires_spectrum
+cd $DWORK_DIR/
+if [ -d $DIRCHECK ]; then
+    echo -en "Directory hires_spectrum already exists.\n"
+else
+    echo -en "Copying kspectrum data to its new home...\n"
+    cd $DWORK_DIR
+    mkdir hires_spectrum
+
+    mv $KSPEC_DIR/results/k* hires_spectrum/
+    cp $KSPEC_DIR/results/calculation_info.txt hires_spectrum/
+    cp $KSPEC_DIR/*in hires_spectrum/
+    cp $KSPEC_DIR/data/composition.in hires_spectrum/
+
+    # removing contents of 'optimizations' folder
+    rm -rf $KSPEC_DIR/optimizations
+    mkdir $KSPEC_DIR/optimizations
+
+    chmod 444 hires_spectrum/*
+fi
+
+cp ~/utilities/run_kmatrix .
+
+echo -en "\nNow you must submit the parallel job (>> llsubmit run_kmatrix)\n"
+
+exit 0
+
+#cp ~/utilities/generate_kmatrix.exe .
+### make kmatrix in the infrared and save it in a GCM-friendly format
+#cp $BANDS_DIR/narrowbands_IR.in narrowbands.in
+#generate_kmatrix.exe
+#mv corrk_gcm.dat $BANDS_DIR/corrk_gcm_IR.dat 
+#rm narrowbands.in
+### make kmatrix in the visible and save it in a GCM-friendly format
+#cp $BANDS_DIR/narrowbands_VI.in narrowbands.in
+#generate_kmatrix.exe
+#mv corrk_gcm.dat $BANDS_DIR/corrk_gcm_VI.dat 
+#rm narrowbands.in
+#rm generate_kmatrix.exe
+#exit 0
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/prekspectrum
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/prekspectrum	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/prekspectrum	(revision 1644)
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+#DWORK_DIR=$RAD/CORRELATEDK/premier_essai
+
+DWORK_DIR=$PWD
+KSPEC_DIR=$KSPECTRUM/kspec_run
+
+cd $DWORK_DIR
+
+# test for presence of k* in kspec results directory
+FILECHECK=$KSPEC_DIR/results/k001
+if [ -f $FILECHECK ]; then
+    echo -en "There is already k-data in the kspec directory "
+    echo -en $KSPEC_DIR
+    echo -en ", delete or move it before starting!\n"
+    exit 1
+fi
+
+make_composition_gen.exe
+cp composition.in $KSPEC_DIR/data/
+
+echo -en "kspectrum working directory is:\n"
+echo -en $KSPEC_DIR
+echo -en "\nNow you must submit the parallel job (>> llsubmit run_kspec)\n"
+
+cd $KSPEC_DIR
+
+exit 0
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/run_kmatrix
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/run_kmatrix	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/run_kmatrix	(revision 1644)
@@ -0,0 +1,28 @@
+# @ job_name=kmatrix
+# @ output = $(job_name).$(jobid)
+# @ error = $(output)
+# @ job_type = serial
+# @ class = B
+# @ queue
+
+BANDS_DIR=38x36
+
+cp $MOD/LMDZ.GENERIC/utilities/generate_kmatrix.exe .
+
+## make kmatrix in the infrared and save it in a GCM-friendly format
+cp $BANDS_DIR/narrowbands_IR.in narrowbands.in
+generate_kmatrix.exe > log.out
+mv corrk_gcm.dat $BANDS_DIR/corrk_gcm_IR.dat 
+mv log.out $BANDS_DIR/logIR.out 
+rm narrowbands.in
+
+## make kmatrix in the visible and save it in a GCM-friendly format
+cp $BANDS_DIR/narrowbands_VI.in narrowbands.in
+generate_kmatrix.exe > log.out
+mv corrk_gcm.dat $BANDS_DIR/corrk_gcm_VI.dat 
+mv log.out $BANDS_DIR/logVI.out 
+rm narrowbands.in
+
+rm generate_kmatrix.exe
+
+exit 0
Index: /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/strlen.for
===================================================================
--- /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/strlen.for	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/correlatedk_utilities/strlen.for	(revision 1644)
@@ -0,0 +1,10 @@
+      integer function strlen(st)
+      integer i
+      character st*(*)
+      i=len(st)
+      do while (st(i:i).eq.' ')
+         i=i-1
+      enddo
+      strlen=i
+      return
+      end
Index: /trunk/LMDZ.TITAN/utilities/extrapol_icefield.F90
===================================================================
--- /trunk/LMDZ.TITAN/utilities/extrapol_icefield.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/extrapol_icefield.F90	(revision 1644)
@@ -0,0 +1,499 @@
+PROGRAM	extrapol_icefield
+
+!--------------------------------------------------------------------------------------------------
+! This program is a tool to accelerate the calculation of ice fieds evolution.
+!
+! It uses data files (diagfi.nc) to extrapolate surface 
+! physical fields (ice fields typically) in time.
+!
+! 1. We load data file(s) 'diagfi.nc' and get dimensions (longitude,latitude,altitude,time).
+! 2. We get a surface field from the loaded 'diagfi.nc' file.
+! 3. We make the extrapolation.
+! 4. We load a start file 'startfi.nc' and copy it into a new start file 'startfi_extrapolated.nc'.
+! 5. We modify the 'startfi_extrapolated.nc' according to the extrapolation calculations.
+!
+! --> 'startfi_extrapolated.nc' is the interpolated new start file that can be used to run
+!
+!
+! Author : M. Turbet (2016) [Adapted from E. Millour previous work]
+!
+!
+!--------------------------------------------------------------------------------------------------
+
+use netcdf
+ 
+implicit none
+
+integer :: j,ig,t,flag
+
+! NetCDF variables
+integer :: status_d,inid,varid_d
+integer :: lat_dimid,lon_dimid,alt_dimid,time_dimid
+integer :: status_s,fileid,varid_s
+integer :: physical_points_dimid
+
+character(len=128) :: diag_file=""
+character(len=128) :: start_file_in=""
+character(len=128) :: start_file_out="startfi_extrapolated.nc"
+character(len=128) :: varname_d=""
+character(len=128) :: varname_s=""
+character(len=128) :: varname_area="area"
+ 
+real,dimension(:),allocatable :: longitude,latitude,altitude,time ! # dimensions
+integer lonlen,latlen,altlen,timelen ! # of grid points along longitude/latitude/altitude/time
+
+integer :: physical_points ! number of atmospheric columns (created)
+integer :: physical_points_s ! number of atmospheric columns (extracted from startfi file)
+
+real,dimension(:,:,:),allocatable :: field_3D ! LON x LAT x TIME field
+real,dimension(:,:),allocatable :: field_phys_3D ! Physical_points x Time field
+real,dimension(:),allocatable :: field_phys_3D_reduced ! Physical_points field
+real,allocatable :: surf_field_3D(:) ! Physical_points field
+real,allocatable :: area(:) ! to store the 1D field of the area
+
+real :: field_ini
+real :: field_fin
+
+integer :: nb_field
+integer :: datashape(3)
+
+integer :: n_years
+
+integer :: extrapolation_mode
+
+write(*,*) ""
+write(*,*) "Welcome in extrapol_icefield routine !"
+write(*,*) "This tool was designed to extrapolate ice field evolution."
+write(*,*) ""
+
+
+!===============================================================================
+!
+! I. INPUT FILES
+!
+!===============================================================================
+
+write(*,*) ""
+write(*,*) "Enter nectdf (diagfi.nc file type) data file name:"
+read(*,'(a128)') diag_file
+write(*,*) ""
+ 
+write(*,*) ""
+write(*,*) "Enter nectdf (startfi.nc file type) input file name:"
+read(*,'(a128)') start_file_in
+write(*,*) ""
+
+write(*,*) "Output file name is now ", start_file_out
+write(*,*) ""
+
+! We copy the startfi (input) file and work now with the startfi (output) file.
+CALL system ("cp "//trim(adjustl(start_file_in))//" "//trim(adjustl(start_file_out)))
+
+ 
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! I.1. Open diagfi.nc file
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+status_d=nf90_open(diag_file,NF90_NOWRITE,inid)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to open datafile ",trim(diag_file)
+  write(*,*)trim(nf90_strerror(status_d))
+ stop
+endif
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! I.2. Get grids for dimensions longitude,latitude,altitude and time
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+! Get latitudes.
+status_d=nf90_inq_dimid(inid,"latitude",lat_dimid)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find latitude dimension"
+  write(*,*)trim(nf90_strerror(status_d))
+ stop
+endif
+status_d=nf90_inquire_dimension(inid,lat_dimid,len=latlen)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find latitude length"
+  write(*,*)trim(nf90_strerror(status_d))
+endif
+allocate(latitude(latlen))
+status_d=nf90_inq_varid(inid,"latitude",varid_d)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to find latitude ID"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+status_d=nf90_get_var(inid,varid_d,latitude)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to load latitude"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+
+! Get longitudes.
+status_d=nf90_inq_dimid(inid,"longitude",lon_dimid)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find longitude dimension"
+  write(*,*)trim(nf90_strerror(status_d))
+ stop
+endif
+status_d=nf90_inquire_dimension(inid,lon_dimid,len=lonlen)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find longitude length"
+  write(*,*)trim(nf90_strerror(status_d))
+endif
+allocate(longitude(lonlen))
+status_d=nf90_inq_varid(inid,"longitude",varid_d)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to find longitude ID"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+status_d=nf90_get_var(inid,varid_d,longitude)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to load longitude"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+
+! Get times.
+status_d=nf90_inq_dimid(inid,"Time",time_dimid)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find Time dimension"
+  write(*,*)trim(nf90_strerror(status_d))
+ stop
+endif
+status_d=nf90_inquire_dimension(inid,time_dimid,len=timelen)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find Time length"
+  write(*,*)trim(nf90_strerror(status_d))
+endif
+allocate(time(timelen))
+status_d=nf90_inq_varid(inid,"Time",varid_d)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to find Time ID"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+status_d=nf90_get_var(inid,varid_d,time)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to load Time"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+
+! Get altitudes.
+status_d=nf90_inq_dimid(inid,"altitude",alt_dimid)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find altitude dimension"
+  write(*,*)trim(nf90_strerror(status_d))
+ stop
+endif
+status_d=nf90_inquire_dimension(inid,alt_dimid,len=altlen)
+if (status_d.ne.nf90_noerr) then
+  write(*,*)"Failed to find altitude length"
+  write(*,*)trim(nf90_strerror(status_d))
+endif
+allocate(altitude(altlen))
+status_d=nf90_inq_varid(inid,"altitude",varid_d)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to find altitude ID"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+status_d=nf90_get_var(inid,varid_d,altitude)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to load altitude"
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+endif
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! I.3. Get the data field.
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+ write(*,*) ""
+ write(*,*) "Enter surface tracer field (in diagfi.nc) to extrapolate"
+ read(*,'(a128)') varname_d
+ write(*,*) ""
+ 
+ write(*,*) ""
+ write(*,*) "Enter corresponding surface tracer field (in startfi.nc) to extrapolate"
+ read(*,'(a128)') varname_s
+ write(*,*) ""
+
+
+status_d=nf90_inq_varid(inid,trim(varname_d),varid_d)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to find variable ",trim(varname_d)," in ",trim(diag_file)
+  write(*,*)trim(nf90_strerror(status_d))
+  write(*,*) " Might as well stop here."
+  stop
+endif
+
+! Sanity checks on the variable.
+status_d=nf90_inquire_variable(inid,varid_d,ndims=nb_field,dimids=datashape)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to obtain information on variable ",trim(varname_d)
+  write(*,*)trim(nf90_strerror(status_d))
+  write(*,*) " Might as well stop here."
+  stop
+else
+  ! check that it is a 3D variable.
+  if (nb_field.ne.3) then
+    write(*,*) "Error, expected a 3D (lon-lat-time) variable!"
+    stop
+  endif
+  ! check that its dimensions are indeed lon,lat,time.
+  if (datashape(1).ne.lon_dimid) then
+    write(*,*) "Error, expected first dimension to be longitude!"
+    write(*,*) "Please check your diagfi.nc file"
+    stop
+  endif
+  if (datashape(2).ne.lat_dimid) then
+    write(*,*) "Error, expected second dimension to be latitude!"
+    write(*,*) "Please check your diagfi.nc file"
+    stop
+  endif
+  if (datashape(3).ne.time_dimid) then
+    write(*,*) "Error, expected third dimension to be time!"
+    write(*,*) "Please check your diagfi.nc file"
+    stop
+  endif
+endif
+
+allocate(field_3D(lonlen,latlen,timelen))
+
+! Load the data field.
+status_d=nf90_get_var(inid,varid_d,field_3D)
+if (status_d.ne.nf90_noerr) then
+  write(*,*) "Failed to load ",trim(varname_d)
+  write(*,*)trim(nf90_strerror(status_d))
+  stop
+else
+  write(*,*) "Loaded ",trim(varname_d)
+endif
+
+
+!===============================================================================
+!
+! II. MANIPULATION OF DATA FIELDS
+!
+!===============================================================================
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! II.1. Transfer the 2D data onto the "physics" 1-dimensional grid.
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! Calculate the physical 1D grid.
+physical_points=2+(latlen-2)*(lonlen-1)
+write(*,*) " lonlen=",lonlen," latlen=",latlen
+write(*,*) " physical_points=",physical_points
+
+allocate(field_phys_3D(physical_points,timelen))
+allocate(field_phys_3D_reduced(physical_points))
+
+! North pole :
+field_phys_3D(1,1:timelen)=field_3D(1,1,1:timelen)
+! South pole :
+field_phys_3D(physical_points,1:timelen)=field_3D(lonlen,latlen,1:timelen)
+! Rest of the world :
+do j=2,latlen-1
+  ig=2+(j-2)*(lonlen-1)
+  field_phys_3D(ig:ig+(lonlen-2),1:timelen)=field_3D(1:lonlen-1,j,1:timelen)
+enddo
+
+field_phys_3D_reduced(1:physical_points)=0.
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! II.2. Extrapolation of data
+!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+ write(*,*) ""
+ write(*,*) "Extrapolation/Speed Factor ?"
+ read(*,*) n_years
+ write(*,*) ""
+ 
+ write(*,*) ""
+ write(*,*) "Extrapolation Modes :"
+ write(*,*) "Mode 1 : We extrapolate using only the first value and the last value."
+ write(*,*) "Mode 2 : We extrapolate using the first value and the mean value."
+ write(*,*) ""
+ write(*,*) "Write the number of the mode you want :"
+ read(*,*) extrapolation_mode
+ write(*,*) ""
+
+
+if (extrapolation_mode .eq. 1) then
+
+   do ig = 1, physical_points 
+      flag = 0
+      do t = 1,timelen
+         if (field_phys_3D(ig,t) .eq. 0) flag = 1 ! Here, we remove the "seasonal" ice deposit.
+      enddo
+      if (flag .eq. 0) then
+         field_phys_3D_reduced(ig)=(field_phys_3D(ig,timelen)-field_phys_3D(ig,1))*n_years
+         if(field_phys_3D_reduced(ig) .lt. 0) field_phys_3D_reduced(ig) = 0   
+      else
+         field_phys_3D_reduced(ig)=0. ! Here, we remove the "seasonal" ice deposit.
+      endif
+   enddo
+   
+else if (extrapolation_mode .eq. 2) then
+
+   do ig = 1, physical_points 
+      flag = 0
+      do t = 1,timelen
+         if (field_phys_3D(ig,t) .eq. 0) flag = 1 ! Here, we remove the "seasonal" ice deposit.
+      enddo
+      if (flag .eq. 0) then
+         do t = 1,timelen
+            field_phys_3D_reduced(ig)=field_phys_3D_reduced(ig)+field_phys_3D(ig,t)
+         enddo
+         field_phys_3D_reduced(ig)=field_phys_3D_reduced(ig)/timelen
+         field_phys_3D_reduced(ig)=(field_phys_3D_reduced(ig)-field_phys_3D(ig,1))*2*n_years
+         if(field_phys_3D_reduced(ig) .lt. 0) field_phys_3D_reduced(ig) = 0   
+      else
+         field_phys_3D_reduced(ig)=0.
+      endif
+   enddo
+else
+    write(*,*) "Please check your extrapolation mode because "
+    write(*,*) "it does not match the possibilities !"
+    stop
+endif
+
+
+!===============================================================================
+!
+! III. CREATION OF THE EXTRAPOLATED STARTFI FILE
+!
+!===============================================================================
+
+
+! Open output file in read/write mode.
+status_s=nf90_open(start_file_out,NF90_WRITE,fileid)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to open output file ",trim(start_file_out)
+  write(*,*)trim(nf90_strerror(status_s))
+ stop
+endif
+write(*,*) "Reading output file: ",trim(start_file_out)
+
+! Get value of physical_points.
+status_s=nf90_inq_dimid(fileid,"physical_points",physical_points_dimid)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to find physical_points dimension"
+  write(*,*)trim(nf90_strerror(status_s))
+ stop
+endif
+
+status_s=nf90_inquire_dimension(fileid,physical_points_dimid,len=physical_points_s)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to find physical_points value"
+  write(*,*)trim(nf90_strerror(status_s))
+ stop
+else
+  write(*,*) " physical_points = ",physical_points_s
+endif
+
+if (physical_points_s .ne. physical_points) then
+   write(*,*) "the number of physical points in diagfi and startfi are not equal!"
+   stop
+endif
+
+! Load surface field
+allocate(surf_field_3D(physical_points))
+allocate(area(physical_points))
+
+! Get id of the area
+status_s=nf90_inq_varid(fileid,varname_area,varid_s)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to find ",trim(varname_area)," varid_s"
+  write(*,*)"Check that the area is included in your files"
+  write(*,*)trim(nf90_strerror(status_s))
+  stop
+endif
+
+! Read variable from file
+status_s=nf90_get_var(fileid,varid_s,area)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to load ",trim(varname_area)
+  write(*,*)trim(nf90_strerror(status_s))
+  stop
+else
+  write(*,*)"Loaded ",trim(varname_s)
+endif
+
+! Get id of variable
+status_s=nf90_inq_varid(fileid,varname_s,varid_s)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to find ",trim(varname_s)," varid_s"
+  write(*,*)trim(nf90_strerror(status_s))
+  stop
+endif
+
+! Read variable from file
+status_s=nf90_get_var(fileid,varid_s,surf_field_3D)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to load ",trim(varname_s)
+  write(*,*)trim(nf90_strerror(status_s))
+  stop
+else
+  write(*,*)"Loaded ",trim(varname_s)
+endif
+
+
+! Here, we calculate the final ice field.
+! In particular, we do some calculations to conserve the total amount of ice.
+
+field_ini=0.
+do ig=1,physical_points
+   field_ini = field_ini + area(ig)*surf_field_3D(ig)
+enddo
+
+surf_field_3D(1:physical_points)= surf_field_3D(1:physical_points) &
+   + field_phys_3D_reduced(1:physical_points)
+
+field_fin=0.
+do ig=1,physical_points
+   field_fin = field_fin + area(ig)*surf_field_3D(ig)
+enddo
+
+do ig=1, physical_points
+   surf_field_3D(ig) = surf_field_3D(ig)*field_ini/field_fin
+enddo
+
+
+! 3. Write the data to the startfi file
+status_s=nf90_put_var(fileid,varid_s,surf_field_3D)
+if (status_s.ne.nf90_noerr) then
+  write(*,*)"Failed to write ",trim(varname_s)
+  write(*,*)trim(nf90_strerror(status_s))
+  stop
+else
+  write(*,*)"Wrote ",trim(varname_s)
+endif
+
+! 4. Close file
+status_s=nf90_close(fileid)
+
+END PROGRAM extrapol_icefield
Index: /trunk/LMDZ.TITAN/utilities/extrapol_icefield.def
===================================================================
--- /trunk/LMDZ.TITAN/utilities/extrapol_icefield.def	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/extrapol_icefield.def	(revision 1644)
@@ -0,0 +1,6 @@
+diagfi.nc
+startfi.nc
+h2o_ice_surf
+h2o_ice
+10
+1
Index: /trunk/LMDZ.TITAN/utilities/streamfunction.F90
===================================================================
--- /trunk/LMDZ.TITAN/utilities/streamfunction.F90	(revision 1644)
+++ /trunk/LMDZ.TITAN/utilities/streamfunction.F90	(revision 1644)
@@ -0,0 +1,1152 @@
+module planet_const
+! planetary constants (set via init_planet_const routine)
+implicit none
+real :: a0 ! Mean planetary radius
+real :: g0 ! gravity
+real :: Rmean ! reduced gaz constant
+real :: omega ! rotation rate
+end module planet_const
+
+program streamfunction
+
+! ----------------------------------------------------------------------------
+! Program to calculate the stream function and the total angular momentum
+! from stats and diagfi files
+! input : diagfi.nc  / concat.nc / stats.nc kind of files
+! author: F. Gonzalez-Galindo
+!
+! Updates :
+! 
+! - 02/2016 (M. Turbet) : The code was adapted to work for any planet.
+!
+! ----------------------------------------------------------------------------
+
+use planet_const
+implicit none
+
+include "netcdf.inc" ! NetCDF definitions
+
+character (len=128) :: infile ! input file name (diagfi.nc or stats.nc format)
+character (len=128) :: infile2 ! second input file (may be needed for 'aire' and 'cv')
+character (len=64) :: text ! to store some text
+
+character (len=50), dimension(:), allocatable :: var
+! var(): name(s) of variable(s) that will be concatenated
+character (len=100) :: filename
+! filename(): output file name
+integer :: nid,ierr,miss
+! nid: [netcdf] file ID #
+! ierr: [netcdf] subroutine returned error code
+! miss: [netcdf] subroutine returned error code
+integer :: tmpvarid
+! varid: temporary store a variable ID #
+integer tmpdimid ! temporarily store a dimension ID
+integer infid ! NetCDF input file ID (of diagfi.nc or stats.nc format)
+integer infid2 ! NetCDF input file which contains 'phisini' dataset (diagfi.nc)
+integer nbvarinfile ! # of variables in input file
+real, dimension(:), allocatable:: lat,lon,alt,time
+! lat(): array, stores latitude coordinates
+! lon(): array, stores longitude coordinates
+! alt(): array, stores altitude coordinates
+! time(): array, stores time coordinates
+integer :: ilat,ilon,ialt,it,i
+! ilat: index for loops on latitude
+! ilon: index for loops on longitude 
+! ialt: index for loops on altitude
+! it: # index for loops on time
+! i: index for loops
+integer :: nout,latdimout,londimout,altdimout,timedimout,lonvarout,timevarout
+integer :: psivarout,momvarout,uvarout,vvarout,rhovarout,tempvarout
+integer :: psvarout, phisinitvarout
+! nout: [netcdf] output file ID
+! latdimout: [netcdf] output latitude (dimension) ID
+! londimout: [netcdf] output longitude (dimension) ID
+! altdimout: [netcdf] output altitude (dimension) ID
+! timedimout: [netcdf] output time (dimension) ID
+! lonvarout: [netcdf] ID of output "Time" variable
+integer lonlength ! # of grid points along longitude
+integer latlength ! # of grid points along latitude
+integer altlength ! # of grid point along altitude (of input datasets)
+integer timelength ! # of points along time
+real,dimension(:),allocatable :: aps,bps ! hybrid vertical coordinates
+real,dimension(:),allocatable :: sigma ! sigma levels
+real,dimension(:),allocatable :: lon_fake ! Fake longitude to be written
+real,dimension(:,:),allocatable :: aire ! Area of the box
+real,dimension(:,:),allocatable :: cv ! Conversion between natural and covariant v
+real,dimension(:,:),allocatable :: phisinit ! Ground geopotential
+real,dimension(:,:,:),allocatable :: ps ! GCM surface pressure
+real,dimension(:,:,:,:),allocatable :: press ! GCM atmospheric pressure 
+real,dimension(:,:,:,:),allocatable :: temp ! GCM atmospheric temperature
+real,dimension(:,:,:,:),allocatable :: u ! GCM zonal wind
+real,dimension(:,:,:,:),allocatable :: v ! GCM meridional wind
+real,dimension(:,:,:,:),allocatable :: rho ! GCM atmospheric density
+real,dimension(:,:,:),allocatable :: vcont ! Covariant meridional wind
+real,dimension(:,:),allocatable :: vcontcum ! Zonal mean covariant meridional wind
+real,dimension(:,:,:),allocatable :: plev ! Pressure from hybrid coordinates
+real,dimension(:,:,:),allocatable :: mass ! Mass in a grid box
+real,dimension(:,:,:),allocatable :: dmass ! Mass variation
+real,dimension(:,:),allocatable :: psi ! Stream function
+real,dimension(:,:,:),allocatable :: mom ! Angular momentum
+real,dimension(:,:),allocatable :: momave ! Zonally averaged angular momentum
+real,dimension(:,:,:),allocatable :: ucum ! Temporally averaged zonal wind
+real,dimension(:,:,:),allocatable :: vcum ! Temporally averaged meridional wind
+real,dimension(:,:,:),allocatable :: rhocum ! Temporally averaged density
+real,dimension(:,:,:),allocatable :: tempcum ! Temporally averaged zonal wind
+real,dimension(:,:),allocatable :: pscum ! Temporally averaged zonal wind
+real,dimension(:,:),allocatable :: uzm ! Zonally averaged zonal wind
+real,dimension(:,:),allocatable :: vzm ! Zonally averaged meridional wind
+real,dimension(:,:),allocatable :: rhozm ! Zonally averaged density
+real,dimension(:,:),allocatable :: tempzm ! Zonally averaged temperature
+real,dimension(:),allocatable :: pszm ! Zonally averaged surface pressure
+real,dimension(:),allocatable :: phisinitzm ! Zonally averaged ground geopotential
+
+!===============================================================================
+! 1.1 Input file
+!===============================================================================
+
+write(*,*) ""
+write(*,*) " Program valid for diagfi.nc, concatnc.nc and stats.nc files"
+write(*,*) "Enter input file name:"
+
+read(*,'(a128)') infile
+write(*,*) ""
+
+! open input file
+
+ierr = NF_OPEN(infile,NF_NOWRITE,infid)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'ERROR: Pb opening input file'
+   stop ""
+endif
+
+! load planet constants (radius, gravity, ...)
+
+call init_planet_const(infid)
+
+!===============================================================================
+! 1.2 Get grids in lon,lat,alt,time,
+!     as well as hybrid coordinates aps() and bps() (or sigma levels sigma())
+!     aire() and cv() from input file
+!===============================================================================
+
+! 1.2.1 longitude, latitude, altitude and time
+
+! latitude
+ierr=NF_INQ_DIMID(infid,"latitude",tmpdimid)
+if (ierr.ne.NF_NOERR) then
+  stop "Error: Failed to get latitude dimension ID"
+else
+  ierr=NF_INQ_VARID(infid,"latitude",tmpvarid)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed to get latitude ID"
+  else
+    ierr=NF_INQ_DIMLEN(infid,tmpdimid,latlength)
+    if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to get latitude length"
+    else
+      allocate(lat(latlength))
+      ierr=NF_GET_VAR_REAL(infid,tmpvarid,lat)
+      if (ierr.ne.NF_NOERR) then
+        stop "Error: Failed reading latitude"
+      endif
+    endif
+  endif
+endif
+
+! longitude
+ierr=NF_INQ_DIMID(infid,"longitude",tmpdimid)
+if (ierr.ne.NF_NOERR) then
+  stop "Error: Failed to get longitude dimension ID"
+else
+  ierr=NF_INQ_VARID(infid,"longitude",tmpvarid)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed to get longitude ID"
+  else
+    ierr=NF_INQ_DIMLEN(infid,tmpdimid,lonlength)
+    if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to get longitude length"
+    else
+      allocate(lon(lonlength))
+      ierr=NF_GET_VAR_REAL(infid,tmpvarid,lon)
+      if (ierr.ne.NF_NOERR) then
+        stop "Error: Failed reading longitude"
+      endif
+    endif
+  endif
+endif
+
+! time
+ierr=NF_INQ_DIMID(infid,"Time",tmpdimid)
+if (ierr.ne.NF_NOERR) then
+  stop "Error: Failed to get Time dimension ID"
+else
+  ierr=NF_INQ_VARID(infid,"Time",tmpvarid)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed to get Time ID"
+  else
+    ierr=NF_INQ_DIMLEN(infid,tmpdimid,timelength)
+    if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to get Time length"
+    else
+      allocate(time(timelength))
+      ierr=NF_GET_VAR_REAL(infid,tmpvarid,time)
+      if (ierr.ne.NF_NOERR) then
+        stop "Error: Failed reading Time"
+      endif
+    endif
+  endif
+endif
+
+! altlength
+ierr=NF_INQ_DIMID(infid,"altitude",tmpdimid)
+if (ierr.ne.NF_NOERR) then
+  stop "Error: Failed to get altitude dimension ID"
+else
+  ierr=NF_INQ_VARID(infid,"altitude",tmpvarid)
+  if (ierr.ne.NF_NOERR) then
+     stop "Error: Failed to get altitude length"
+  else
+     ierr=NF_INQ_DIMLEN(infid,tmpdimid,altlength)
+     if (ierr.ne.NF_NOERR) then
+        stop "Error: Failed to get altitude length"
+     else   
+        allocate(alt(altlength))
+        ierr=NF_GET_VAR_REAL(infid,tmpvarid,alt)
+        if (ierr.ne.NF_NOERR) then
+           stop "Error: Failed reading Altitude"
+        endif
+     endif
+  endif
+endif
+
+! 1.2.2 Get hybrid coordinates 
+
+! look for hybrid coordinates
+
+! hybrid coordinate aps
+ierr=NF_INQ_VARID(infid,"aps",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+   stop "Error: Failed to get aps ID"
+else
+   allocate(aps(altlength))
+   ierr=NF_GET_VAR_REAL(infid,tmpvarid,aps)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading aps"
+   endif
+endif
+
+! hybrid coordinate bps
+ierr=NF_INQ_VARID(infid,"bps",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+   stop "Error: Failed to get bps ID"
+else
+   allocate(bps(altlength))
+   ierr=NF_GET_VAR_REAL(infid,tmpvarid,bps)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading bps"
+   endif
+endif
+
+!surface pressure
+ierr=NF_INQ_VARID(infid,"ps",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+   stop "Error: Failed to get ps ID"
+else
+   allocate(ps(lonlength,latlength,timelength))
+   ierr=NF_GET_VAR_REAL(infid,tmpvarid,ps)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading ps"
+   endif
+endif
+
+
+!===============================================================================
+! 1.3 Reads variables in input file
+!===============================================================================
+
+ierr=NF_INQ_NVARS(infid,nbvarinfile)
+if (ierr.ne.NF_NOERR) then
+  write(*,*) 'ERROR: Failed geting number of variables from file'
+  stop
+endif
+
+!1.3.1 Zonal wind, meridional wind
+
+!Zonal wind
+ierr=NF_INQ_VARID(infid,"u",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+  stop "Error: Failed to get u ID"
+else
+  allocate(u(lonlength,latlength,altlength,timelength))
+  ierr=NF_GET_VAR_REAL(infid,tmpvarid,u)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed reading zonal wind"
+  endif
+endif
+
+!Meridional wind
+ierr=NF_INQ_VARID(infid,"v",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+  stop "Error: Failed to get v ID"
+else
+  allocate(v(lonlength,latlength,altlength,timelength))
+  ierr=NF_GET_VAR_REAL(infid,tmpvarid,v)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed reading zonal wind"
+  endif
+endif
+
+
+! 1.3.2 aire
+
+allocate(aire(lonlength,latlength))
+! look for 'aire' in current file
+ierr=NF_INQ_VARID(infid,"aire",tmpvarid) 
+if (ierr.ne.NF_NOERR) then
+  write(*,*) "Warning: Failed to get aire ID from file ",trim(infile)
+  infile2="diagfi.nc"
+  write(*,*) "         Trying file ",trim(infile2)
+  ierr=NF_OPEN(infile2,NF_NOWRITE,infid2)
+  if (ierr.ne.NF_NOERR) then
+     infile2="diagfi1.nc"
+     write(*,*) "         Trying file ",trim(infile2)
+     ierr=NF_OPEN(infile2,NF_NOWRITE,infid2)
+     if (ierr.ne.NF_NOERR) then
+        write(*,*) "Problem: Could not find/open these files"
+        stop "Might as well stop here"
+     endif
+  endif
+
+   ! Get ID for aire
+   ierr=NF_INQ_VARID(infid2,"aire",tmpvarid)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to get aire ID"
+   endif
+   ! Get aire
+   ierr=NF_GET_VAR_REAL(infid2,tmpvarid,aire)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading aire"
+   endif
+   ! Close file
+   write(*,*) 'OK, got aire'
+   ierr=NF_CLOSE(infid2)
+else
+   ierr=NF_GET_VAR_REAL(infid,tmpvarid,aire)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading aire"
+   endif
+endif
+
+
+! 1.3.3 phisinit
+
+allocate(phisinit(lonlength,latlength))
+! look for '' in current file
+ierr=NF_INQ_VARID(infid,"phisinit",tmpvarid) 
+if (ierr.ne.NF_NOERR) then
+  write(*,*) "Warning: Failed to get phisinit ID from file ",trim(infile)
+  infile2="diagfi.nc"
+  write(*,*) "         Trying file ",trim(infile2)
+  ierr=NF_OPEN(infile2,NF_NOWRITE,infid2)
+  if (ierr.ne.NF_NOERR) then
+     infile2="diagfi1.nc"
+     write(*,*) "         Trying file ",trim(infile2)
+     ierr=NF_OPEN(infile2,NF_NOWRITE,infid2)
+     if (ierr.ne.NF_NOERR) then
+        write(*,*) "Problem: Could not find/open these files"
+        stop "Might as well stop here"
+     endif
+  endif
+
+
+   ! Get ID for phisinit
+   ierr=NF_INQ_VARID(infid2,"phisinit",tmpvarid)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to get phisinit ID"
+   endif
+   ! Get phisinit
+   ierr=NF_GET_VAR_REAL(infid2,tmpvarid,phisinit)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading phisinit"
+   endif
+   ! Close file
+   write(*,*) 'OK, got phisinit'
+   ierr=NF_CLOSE(infid2)
+else
+   ierr=NF_GET_VAR_REAL(infid,tmpvarid,phisinit)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading phisinit"
+   endif
+endif
+
+
+! 1.3.4 cv
+
+allocate(cv(lonlength,latlength))
+! look for 'cv' in current file
+ierr=NF_INQ_VARID(infid,"cv",tmpvarid) 
+if (ierr.ne.NF_NOERR) then
+  write(*,*) "Warning: Failed to get cv ID from file ",trim(infile)
+  infile2="diagfi.nc"
+  write(*,*) "         Trying file ",trim(infile2)
+  ierr=NF_OPEN(infile2,NF_NOWRITE,infid2)
+  if (ierr.ne.NF_NOERR) then
+     infile2="diagfi1.nc"
+     write(*,*) "         Trying file ",trim(infile2)
+     ierr=NF_OPEN(infile2,NF_NOWRITE,infid2)
+     if (ierr.ne.NF_NOERR) then
+        write(*,*) "Problem: Could not find/open these files"
+        stop "Might as well stop here"
+     endif
+  endif
+
+
+   ! Get ID for cv
+   ierr=NF_INQ_VARID(infid2,"cv",tmpvarid)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to get cv ID"
+   endif
+   ! Get cv
+   ierr=NF_GET_VAR_REAL(infid2,tmpvarid,cv)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading cv"
+   endif
+   ! Close file
+   write(*,*) 'OK, got cv'
+   ierr=NF_CLOSE(infid2)
+else
+   ierr=NF_GET_VAR_REAL(infid,tmpvarid,cv)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed reading cv"
+   endif
+endif
+
+
+!Other variables: rho, temp
+
+ierr=NF_INQ_VARID(infid,"temp",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+  stop "Error: Failed to get temp ID"
+else
+  allocate(temp(lonlength,latlength,altlength,timelength))
+  ierr=NF_GET_VAR_REAL(infid,tmpvarid,temp)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed reading temperature"
+  endif
+endif
+
+ierr=NF_INQ_VARID(infid,"rho",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+  write(*,*) "Error: Failed to get rho ID"
+  write(*,*) "Let's compute it from temperature"
+  allocate(rho(lonlength,latlength,altlength,timelength))
+  
+  do it=1,timelength
+    do ilat=1,latlength
+      do ilon=1,lonlength
+        do ialt=1,altlength
+          rho(ilon,ilat,ialt,it)= (aps(ialt)+bps(ialt)*ps(ilon,ilat,it))/(Rmean*temp(ilon,ilat,ialt,it))
+        enddo
+      enddo
+    enddo
+  enddo
+else
+  allocate(rho(lonlength,latlength,altlength,timelength))
+  ierr=NF_GET_VAR_REAL(infid,tmpvarid,rho)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed reading mass density"
+  endif
+endif
+
+!==============================================================================
+! 1.4. Output file name
+!==============================================================================
+filename=infile(1:len_trim(infile)-3)//"_stream.nc"
+write(*,*)'The output file has name:'
+write(*,*) filename
+
+
+!==============================================================================
+! 2.1. Temporal averages
+!==============================================================================
+
+allocate(ucum(lonlength,latlength,altlength)) !Time mean zonal wind
+allocate(vcum(lonlength,latlength,altlength)) !Time mean meridional wind
+allocate(tempcum(lonlength,latlength,altlength)) !Time mean temperature
+allocate(rhocum(lonlength,latlength,altlength)) !Time mean density
+allocate(pscum(lonlength,latlength)) !Time mean surface pressure
+do ilat=1,latlength
+   do ilon=1,lonlength
+      pscum(ilon,ilat)=0.
+      do ialt=1,altlength
+            ucum(ilon,ilat,ialt)=0.
+            vcum(ilon,ilat,ialt)=0.
+            tempcum(ilon,ilat,ialt)=0.
+            rhocum(ilon,ilat,ialt)=0.
+            do it=1,timelength
+               ucum(ilon,ilat,ialt)=ucum(ilon,ilat,ialt)+u(ilon,ilat,ialt,it)
+               vcum(ilon,ilat,ialt)=vcum(ilon,ilat,ialt)+v(ilon,ilat,ialt,it)
+               tempcum(ilon,ilat,ialt)=tempcum(ilon,ilat,ialt)+temp(ilon,ilat,ialt,it)
+               rhocum(ilon,ilat,ialt)=rhocum(ilon,ilat,ialt)+rho(ilon,ilat,ialt,it)
+            enddo
+            ucum(ilon,ilat,ialt)=ucum(ilon,ilat,ialt)/timelength
+            vcum(ilon,ilat,ialt)=vcum(ilon,ilat,ialt)/timelength
+            tempcum(ilon,ilat,ialt)=tempcum(ilon,ilat,ialt)/timelength
+            rhocum(ilon,ilat,ialt)=rhocum(ilon,ilat,ialt)/timelength
+      enddo
+      do it=1,timelength
+         pscum(ilon,ilat)=pscum(ilon,ilat)+ps(ilon,ilat,it)
+      enddo
+      pscum(ilon,ilat)=pscum(ilon,ilat)/timelength
+   enddo
+enddo
+
+!==============================================================================
+! 2.2. Calculation of the stream function
+!==============================================================================
+
+!Contravariant meridional wind
+allocate(vcont(lonlength,latlength,altlength))
+do ilon=1,lonlength
+   do ialt=1,altlength
+      do ilat=1,latlength-1
+         vcont(ilon,ilat,ialt)=0.5*&
+              (vcum(ilon,ilat,ialt)+vcum(ilon,ilat+1,ialt))/cv(ilon,ilat)
+      enddo
+      vcont(ilon,latlength,ialt)=0.!vcont(ilon,latlength-1,ialt)
+   enddo
+enddo
+
+!Pressure from hybrid levels
+allocate(Plev(lonlength,latlength,altlength))
+do ilon=1,lonlength
+   do ilat=1,latlength
+      do ialt=1,altlength
+         Plev(ilon,ilat,ialt)=aps(ialt)+bps(ialt)*pscum(ilon,ilat)
+      enddo
+   enddo
+enddo
+
+!Mass in the box
+allocate(mass(lonlength,latlength,altlength))
+do ilon=1,lonlength
+   do ilat=1,latlength
+      do ialt=1,altlength
+         mass(ilon,ilat,ialt)=aire(ilon,ilat)*&
+              Plev(ilon,ilat,ialt)/g0
+      enddo
+   enddo
+enddo
+
+!Mass variation in the box
+allocate(dmass(lonlength,latlength,altlength))
+do ilon=1,lonlength
+   do ilat=1,latlength
+      do ialt=1,altlength-1
+         dmass(ilon,ilat,ialt)=mass(ilon,ilat,ialt)-&
+              mass(ilon,ilat,ialt+1)
+      enddo
+      dmass(ilon,ilat,altlength)=0.!dmass(ilon,ilat,altlength-1)
+   enddo
+enddo
+
+!Stream function
+allocate(psi(latlength,altlength))
+allocate(vcontcum(latlength,altlength))
+do ilat=1,latlength-1
+   psi(ilat,altlength)=0.
+   do ialt=altlength-1,1,-1
+      psi(ilat,ialt)=psi(ilat,ialt+1)
+      vcontcum(ilat,ialt)=0.
+      do ilon=1,lonlength
+         vcontcum(ilat,ialt)=vcontcum(ilat,ialt)+vcont(ilon,ilat,ialt)/lonlength
+         psi(ilat,ialt)=psi(ilat,ialt)-(vcont(ilon,ilat,ialt)&
+              *(dmass(ilon,ilat,ialt)+dmass(ilon,ilat+1,ialt)))
+      enddo
+      psi(latlength,ialt)=0.!psi(latlength-1,ialt)
+   enddo
+enddo
+
+!==============================================================================
+! 2.3. Calculation of the total angular momentum
+!==============================================================================
+
+!Angular momentum
+allocate(mom(lonlength,latlength,altlength))
+allocate(momave(latlength,altlength))
+do ilat=1,latlength
+   do ialt=1,altlength
+      momave(ilat,ialt)=0.
+      do ilon=1,lonlength
+!            mom(ilon,ilat,ialt,it)=dmass(ilon,ilat,ialt,it)*a0*&
+         mom(ilon,ilat,ialt)=a0*cos(lat(ilat)*3.141592/180.)*&
+              (omega*a0*cos(lat(ilat)*3.141592/180.)+ucum(ilon,ilat,ialt))
+         
+         momave(ilat,ialt)=momave(ilat,ialt)+mom(ilon,ilat,ialt)
+      enddo
+      momave(ilat,ialt)=momave(ilat,ialt)/lonlength
+   enddo
+enddo
+
+!==============================================================================
+! 2.4. Zonal mean winds, temperature and density
+!==============================================================================
+
+allocate(uzm(latlength,altlength)) !Zonal mean zonal wind
+allocate(vzm(latlength,altlength)) !Zonal mean meridional wind
+allocate(tempzm(latlength,altlength)) !Zonal mean temperature
+allocate(rhozm(latlength,altlength)) !Zonal mean density
+allocate(pszm(latlength)) !Zonal mean surface pressure
+allocate(phisinitzm(latlength)) !Zonal mean ground geopotential
+do ilat=1,latlength
+   phisinitzm(ilat)=0.
+   pszm(ilat)=0.
+   do ialt=1,altlength
+      uzm(ilat,ialt)=0.
+      vzm(ilat,ialt)=0.
+      tempzm(ilat,ialt)=0.
+      rhozm(ilat,ialt)=0.
+      do ilon=1,lonlength
+         uzm(ilat,ialt)=uzm(ilat,ialt)+ucum(ilon,ilat,ialt)
+         vzm(ilat,ialt)=vzm(ilat,ialt)+vcum(ilon,ilat,ialt)
+         tempzm(ilat,ialt)=tempzm(ilat,ialt)+tempcum(ilon,ilat,ialt)
+         rhozm(ilat,ialt)=rhozm(ilat,ialt)+rhocum(ilon,ilat,ialt)
+      enddo
+      uzm(ilat,ialt)=uzm(ilat,ialt)/lonlength
+      vzm(ilat,ialt)=vzm(ilat,ialt)/lonlength
+      tempzm(ilat,ialt)=tempzm(ilat,ialt)/lonlength
+      rhozm(ilat,ialt)=rhozm(ilat,ialt)/lonlength
+   enddo
+   do ilon=1,lonlength
+      pszm(ilat)=pszm(ilat)+pscum(ilon,ilat)
+      phisinitzm(ilat)=phisinitzm(ilat)+phisinit(ilon,ilat)
+   enddo
+   pszm(ilat)=pszm(ilat)/lonlength
+   phisinitzm(ilat)=phisinitzm(ilat)/lonlength  
+enddo
+
+
+!==============================================================================
+! 2.3. Recalculation of angular momentum using zonally averaged wind
+!==============================================================================
+
+do ilat=1,latlength
+   do ialt=1,altlength
+      momave(ilat,ialt)=a0*cos(lat(ilat)*3.141592/180.)*&
+           (omega*a0*cos(lat(ilat)*3.141592/180.)+uzm(ilat,ialt))
+   enddo
+enddo
+
+
+!==============================================================================
+! 3.1 Dimensions in output file
+!==============================================================================
+
+! 3.1.1 Initialize output file's lat,lon,alt and time dimensions
+call initiate (filename,lat,alt,time,nout,&
+     latdimout,londimout,altdimout,timedimout,lonvarout,timevarout)
+! Initialize output file's aps,bps variables
+call init2(infid,lonlength,latlength,altlength,&
+     nout,londimout,latdimout,altdimout)
+
+! 3.1.2 New longitude dimension/value in output file
+allocate(lon_fake(1))
+lon_fake(1)=0.
+#ifdef NC_DOUBLE
+        ierr= NF_PUT_VARA_DOUBLE(nout,lonvarout,1,1,lon_fake)
+#else
+        ierr= NF_PUT_VARA_REAL(nout,lonvarout,1,1,lon_fake)
+#endif
+
+! 3.1.3 New time dimension/value in output file
+#ifdef NC_DOUBLE
+        ierr= NF_PUT_VARA_DOUBLE(nout,timevarout,1,1,lon_fake)
+#else
+        ierr= NF_PUT_VARA_REAL(nout,timevarout,1,1,lon_fake)
+#endif
+
+
+!==============================================================================
+! 3.2 Write variables
+!==============================================================================
+
+!Define the dimensions of the variables to be written
+
+!!3.2.1 Stream function
+call def_var(nout,"psi","Stream function","",4,&
+             (/londimout,latdimout,altdimout,timedimout/),psivarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable psi'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,psivarout,psi)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable psi'
+   stop
+endif
+
+!3.2.2 Momentum
+call def_var(nout,"momave","Angular momentum","",4,&
+             (/londimout,latdimout,altdimout,timedimout/),momvarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable momave'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,momvarout,momave)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable momave'
+   stop
+endif
+
+
+!3.2.3 Zonal mean zonal wind
+call def_var(nout,"u","Zonal mean zonal wind","m/s",4,&
+             (/londimout,latdimout,altdimout,timedimout/),uvarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable u'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,uvarout,uzm)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable u'
+   stop
+endif
+
+
+!3.2.4 Zonal mean meridional wind
+call def_var(nout,"v","Zonal mean meridional wind","m/s",4,&
+             (/londimout,latdimout,altdimout,timedimout/),vvarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable v'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,vvarout,vzm)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable v'
+   stop
+endif
+
+!3.2.5 Zonal mean density
+call def_var(nout,"rho","Zonal mean atmospheric density","",4,&
+             (/londimout,latdimout,altdimout,timedimout/),rhovarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable rho'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,rhovarout,rhozm)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable rho'
+   stop
+endif
+
+!3.2.6 Zonal mean temperature
+call def_var(nout,"temp","Zonal mean temperature","K",4,&
+             (/londimout,latdimout,altdimout,timedimout/),tempvarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable temp'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,tempvarout,tempzm)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable temp'
+   stop
+endif
+
+!3.2.7 Zonal mean surface pressure
+call def_var(nout,"ps","Zonal mean surface pressure","Pa",3,&
+             (/londimout,latdimout,timedimout/),psvarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable ps'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,psvarout,pszm)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable ps'
+   stop
+endif
+
+
+!3.2.8 Zonal mean geopotential
+call def_var(nout,"phisinit","Zonal mean initial geopotential","",2,&
+             (/londimout,latdimout/),phisinitvarout,ierr)
+if (ierr.ne.NF_NOERR) then
+   write(*,*) 'Error, could not define variable phisinit'
+   stop ""
+endif
+
+!Write in the output file
+ierr=NF_PUT_VAR_REAL(nout,phisinitvarout,phisinitzm)
+if (ierr.ne.NF_NOERR) then
+   write(*,*)'Error, Failed to write variable phisinit'
+   stop
+endif
+
+! Close input file
+ierr=nf_close(nid)
+
+! Close output file
+ierr=NF_CLOSE(nout)
+
+contains
+
+!******************************************************************************
+Subroutine initiate (filename,lat,alt,time,&
+                     nout,latdimout,londimout,altdimout,timedimout,&
+                     lonvarout,timevarout)
+!==============================================================================
+! Purpose:
+! Create and initialize a data file (NetCDF format)
+!==============================================================================
+! Remarks:
+! The NetCDF file (created in this subroutine) remains open
+!==============================================================================
+
+implicit none
+
+include "netcdf.inc" ! NetCDF definitions
+
+!==============================================================================
+! Arguments:
+!==============================================================================
+character (len=*), intent(in):: filename
+! filename(): the file's name
+real, dimension(:), intent(in):: lat
+! lat(): latitude
+real, dimension(:), intent(in):: alt
+! alt(): altitude
+real, dimension(:), intent(in):: time
+! time(): Time
+integer, intent(out):: nout
+! nout: [netcdf] file ID
+integer, intent(out):: latdimout
+! latdimout: [netcdf] lat() (i.e.: latitude)  ID
+integer, intent(out):: londimout
+! londimout: [netcdf] lon()  ID
+integer, intent(out):: altdimout
+! altdimout: [netcdf] alt()  ID
+integer, intent(out):: timedimout
+! timedimout: [netcdf] "Time"  ID
+integer, intent(out):: lonvarout
+! timevarout: [netcdf] Longiture (considered as a variable) ID
+integer, intent(out):: timevarout
+! timevarout: [netcdf] Time (considered as a variable) ID
+
+!==============================================================================
+! Local variables:
+!==============================================================================
+!integer :: latdim,londim,altdim,timedim
+integer :: nvarid,ierr
+! nvarid: [netcdf] ID of a variable
+! ierr: [netcdf]  return error code (from called subroutines)
+
+!==============================================================================
+! 1. Create (and open) output file
+!==============================================================================
+write(*,*) "creating "//trim(adjustl(filename))//'...'
+ierr = NF_CREATE(filename,NF_CLOBBER,nout)
+! NB: setting NF_CLOBBER mode means that it's OK to overwrite an existing file
+if (ierr.NE.NF_NOERR) then
+   WRITE(*,*)'ERROR: Impossible to create the file.'
+   stop ""
+endif
+
+!==============================================================================
+! 2. Define/write "dimensions" and get their IDs
+!==============================================================================
+
+ierr = NF_DEF_DIM(nout, "latitude", size(lat), latdimout)
+!ierr = NF_DEF_DIM(nout, "longitude", NF_UNLIMITED, londimout)
+ierr = NF_DEF_DIM(nout, "longitude", 1, londimout)
+ierr = NF_DEF_DIM(nout, "altitude", size(alt), altdimout)
+ierr = NF_DEF_DIM(nout, "Time", 1, timedimout)
+
+! End netcdf define mode
+ierr = NF_ENDDEF(nout)
+
+!==============================================================================
+! 3. Write "Time" (attributes)
+!==============================================================================
+
+call def_var(nout,"Time","Time","years since 0000-00-0 00:00:00",1,&
+             (/timedimout/),timevarout,ierr)
+
+!==============================================================================
+! 4. Write "latitude" (data and attributes)
+!==============================================================================
+
+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
+
+!==============================================================================
+! 4. Write "longitude" (attributes)
+!==============================================================================
+
+call def_var(nout,"longitude","East longitude","degrees_east",1,&
+             (/londimout/),lonvarout,ierr)
+
+
+!==============================================================================
+! 4. Write "altitude" (data and attributes)
+!==============================================================================
+
+! Switch to netcdf define mode
+
+call def_var(nout,"altitude","Altitude","km",1,&
+             (/altdimout/),nvarid,ierr)
+
+#ifdef NC_DOUBLE
+ierr = NF_PUT_VAR_DOUBLE (nout,nvarid,alt)
+#else
+ierr = NF_PUT_VAR_REAL (nout,nvarid,alt)
+#endif 
+
+end Subroutine initiate
+!******************************************************************************
+subroutine init2(infid,lonlen,latlen,altlen, &
+                 outfid,londimout,latdimout,altdimout)
+!==============================================================================
+! Purpose:
+! Copy aps() and bps() from input file to outpout file
+!==============================================================================
+! Remarks:
+! The NetCDF files must be open
+!==============================================================================
+
+implicit none
+
+include "netcdf.inc" ! NetCDF definitions
+
+!==============================================================================
+! Arguments:
+!==============================================================================
+integer, intent(in) :: infid  ! NetCDF output file ID
+integer, intent(in) :: lonlen ! # of grid points along longitude
+integer, intent(in) :: latlen ! # of grid points along latitude
+integer, intent(in) :: altlen ! # of grid points along latitude
+integer, intent(in) :: outfid ! NetCDF output file ID
+integer, intent(in) :: londimout ! longitude dimension ID
+integer, intent(in) :: latdimout ! latitude dimension ID
+integer, intent(in) :: altdimout ! altitude dimension ID
+!==============================================================================
+! Local variables:
+!==============================================================================
+real,dimension(:),allocatable :: aps,bps ! hybrid vertical coordinates
+integer :: apsid,bpsid
+integer :: ierr
+integer :: tmpvarid ! temporary variable ID
+logical :: aps_ok, bps_ok ! are "phisinit" "aps" "bps" available ?
+
+
+!==============================================================================
+! 1. Read data from input file
+!==============================================================================
+
+! hybrid coordinate aps
+  allocate(aps(altlen))
+ierr=NF_INQ_VARID(infid,"aps",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+  write(*,*) "oops Failed to get aps ID. OK"
+  aps_ok=.false.
+else
+  ierr=NF_GET_VAR_REAL(infid,tmpvarid,aps)
+  if (ierr.ne.NF_NOERR) then
+   stop "error: Failed reading aps"
+  endif
+  aps_ok=.true.
+endif
+
+! hybrid coordinate bps
+  allocate(bps(altlen))
+ierr=NF_INQ_VARID(infid,"bps",tmpvarid)
+if (ierr.ne.NF_NOERR) then
+  write(*,*) "oops: Failed to get bps ID. OK"
+  bps_ok=.false.
+else
+  ierr=NF_GET_VAR_REAL(infid,tmpvarid,bps)
+  if (ierr.ne.NF_NOERR) then
+    stop "Error: Failed reading bps"
+  endif
+  bps_ok=.true.
+endif
+
+!==============================================================================
+! 2. Write
+!==============================================================================
+
+!==============================================================================
+! 2.2. Hybrid coordinates aps() and bps()
+!==============================================================================
+
+IF (aps_ok) then 
+   ! define aps
+   call def_var(nout,"aps","hybrid pressure at midlayers"," ",1,&
+        (/altdimout/),apsid,ierr)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to def_var aps"
+   endif
+
+   ! write aps
+#ifdef NC_DOUBLE
+   ierr=NF_PUT_VAR_DOUBLE(outfid,apsid,aps)
+#else
+   ierr=NF_PUT_VAR_REAL(outfid,apsid,aps)
+#endif
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to write aps"
+   endif
+ENDIF 
+
+IF (bps_ok) then 
+   ! define bps
+   call def_var(nout,"bps","hybrid sigma at midlayers"," ",1,&
+        (/altdimout/),bpsid,ierr)
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to def_var bps"
+   endif
+
+   ! write bps
+#ifdef NC_DOUBLE
+   ierr=NF_PUT_VAR_DOUBLE(outfid,bpsid,bps)
+#else
+   ierr=NF_PUT_VAR_REAL(outfid,bpsid,bps)
+#endif
+   if (ierr.ne.NF_NOERR) then
+      stop "Error: Failed to write bps"
+   endif
+ENDIF
+
+
+
+! Cleanup
+deallocate(aps)
+deallocate(bps)
+
+end subroutine init2
+!******************************************************************************
+subroutine def_var(nid,name,title,units,nbdim,dim,nvarid,ierr)
+!==============================================================================
+! Purpose: Write a variable (i.e: add a variable to a dataset)
+! called "name"; along with its attributes "title", "units"...
+! to a file (following the NetCDF format)
+!==============================================================================
+! Remarks:
+! The NetCDF file must be open
+!==============================================================================
+
+implicit none
+
+include "netcdf.inc" ! NetCDF definitions
+
+!==============================================================================
+! Arguments:
+!==============================================================================
+integer, intent(in) :: nid
+! nid: [netcdf] file ID #
+character (len=*), intent(in) :: name
+! name(): [netcdf] variable's name
+character (len=*), intent(in) :: title
+! title(): [netcdf] variable's "title" attribute
+character (len=*), intent(in) :: units
+! unit(): [netcdf] variable's "units" attribute
+integer, intent(in) :: nbdim
+! nbdim: number of dimensions of the variable
+integer, dimension(nbdim), intent(in) :: dim
+! dim(nbdim): [netcdf] dimension(s) ID(s)
+integer, intent(out) :: nvarid
+! nvarid: [netcdf] ID # of the variable
+integer, intent(out) :: ierr
+! ierr: [netcdf] subroutines returned error code
+
+! Switch to netcdf define mode
+ierr=NF_REDEF(nid)
+
+! Insert the definition of the variable
+#ifdef NC_DOUBLE
+ierr=NF_DEF_VAR(nid,adjustl(name),NF_DOUBLE,nbdim,dim,nvarid)
+#else
+ierr=NF_DEF_VAR(nid,adjustl(name),NF_FLOAT,nbdim,dim,nvarid)
+#endif
+
+! Write the attributes
+ierr=NF_PUT_ATT_TEXT(nid,nvarid,"title",len_trim(adjustl(title)),adjustl(title))
+ierr=NF_PUT_ATT_TEXT(nid,nvarid,"units",len_trim(adjustl(units)),adjustl(units))
+
+! End netcdf define mode
+ierr=NF_ENDDEF(nid)
+
+end subroutine def_var
+
+end program streamfunction
+
+subroutine init_planet_const(infid)
+! initialize planetary constants using the "controle" array in the file
+! if "controle" array not found in file, look for it in "diagfi.nc"
+use planet_const
+use netcdf
+implicit none
+
+integer,intent(in) :: infid ! input file ID
+
+! local variables
+character(len=100) :: varname
+integer :: varid ! variable ID
+integer :: status
+integer :: infid2 ! for an alternate input file
+real :: controle(100) ! to store "controle" array
+
+! look for "controle" in input file
+infid2=infid ! initialization
+varname="controle" 
+status=nf90_inq_varid(infid,trim(varname),varid)
+if (status.ne.nf90_noerr) then
+  write(*,*) "init_planet_const: Failed to find ",trim(varname)
+  write(*,*) " looking for it in file diagfi.nc"
+  status=nf90_open("diagfi.nc",NF90_NOWRITE,infid2)
+  if (status.ne.nf90_noerr) then
+    write(*,*) " no diafi.nc file ... looking for diagfi1.nc"
+    status=nf90_open("diagfi1.nc",NF90_NOWRITE,infid2)
+    if (status.ne.nf90_noerr) then
+      write(*,*) "might as well stop here..."
+      stop
+    endif
+  endif
+  status=nf90_inq_varid(infid2,trim(varname),varid)
+  if (status.ne.nf90_noerr) then
+    write(*,*) " Failed to find ",trim(varname)," in file!!"
+    stop
+  endif
+  write(*,*) "OK, found ",trim(varname)
+endif
+status=nf90_get_var(infid2,varid,controle)
+if (status.ne.nf90_noerr) then
+  write(*,*) "init_planet_const: Failed to load ",trim(varname)
+  stop
+endif
+
+! now that we have "controle"; extract relevent informations
+a0=controle(5) ! = radius of planet (m)
+g0=controle(7) ! = gravity (m.s-2) at a0
+Rmean=1000.*8.3144598/controle(8) ! controle(8)=mugaz = molar mass (g.mol-1) of atm.
+omega=controle(6) ! rotation rate (rad.s-1)
+
+end subroutine init_planet_const
