Index: DZ6/branches/Amaury_dev/libf/dyn3d/addfi.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/addfi.F90	(revision 5185)
+++ 	(revision )
@@ -1,172 +1,0 @@
-! $Id$
-
-SUBROUTINE addfi(pdt, leapf, forward, pucov, pvcov, pteta, pq, pps, pdufi, pdvfi, pdhfi, pdqfi, pdpfi)
-
-  USE lmdz_infotrac, ONLY: nqtot
-  USE control_mod, ONLY: planet_type
-  USE lmdz_ssum_scopy, ONLY: ssum
-  USE lmdz_comgeom
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-
-  IMPLICIT NONE
-
-  !=======================================================================
-
-  !    Addition of the physical tendencies
-
-  !    Interface :
-  !    -----------
-
-  !  Input :
-  !  -------
-  !  pdt                    time step of integration
-  !  leapf                  logical
-  !  forward                logical
-  !  pucov(ip1jmp1,llm)     first component of the covariant velocity
-  !  pvcov(ip1ip1jm,llm)    second component of the covariant velocity
-  !  pteta(ip1jmp1,llm)     potential temperature
-  !  pts(ip1jmp1,llm)       surface temperature
-  !  pdufi(ip1jmp1,llm)     |
-  !  pdvfi(ip1jm,llm)       |   respective
-  !  pdhfi(ip1jmp1)         |      tendencies
-  !  pdtsfi(ip1jmp1)        |
-
-  !  Output :
-  !  --------
-  !  pucov
-  !  pvcov
-  !  ph
-  !  pts
-
-
-  !=======================================================================
-  !  !
-  !    Arguments :
-  !    -----------
-
-  REAL, INTENT(IN) :: pdt ! time step for the integration (s)
-
-  REAL, INTENT(INOUT) :: pvcov(ip1jm, llm) ! covariant meridional wind
-  REAL, INTENT(INOUT) :: pucov(ip1jmp1, llm) ! covariant zonal wind
-  REAL, INTENT(INOUT) :: pteta(ip1jmp1, llm) ! potential temperature
-  REAL, INTENT(INOUT) :: pq(ip1jmp1, llm, nqtot) ! tracers
-  REAL, INTENT(INOUT) :: pps(ip1jmp1) ! surface pressure (Pa)
-  ! respective tendencies (.../s) to add
-  REAL, INTENT(IN) :: pdvfi(ip1jm, llm)
-  REAL, INTENT(IN) :: pdufi(ip1jmp1, llm)
-  REAL, INTENT(IN) :: pdqfi(ip1jmp1, llm, nqtot)
-  REAL, INTENT(IN) :: pdhfi(ip1jmp1, llm)
-  REAL, INTENT(IN) :: pdpfi(ip1jmp1)
-
-  LOGICAL, INTENT(IN) :: leapf, forward ! not used
-
-
-  !    Local variables :
-  !    -----------------
-
-  REAL :: xpn(iim), xps(iim), tpn, tps
-  INTEGER :: j, k, iq, ij
-  REAL, PARAMETER :: qtestw = 1.0e-15
-  REAL, PARAMETER :: qtestt = 1.0e-40
-
-  !-----------------------------------------------------------------------
-
-  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
-  !
-
-  DO k = 1, llm
-    DO j = iip2, ip1jm
-      pucov(j, k) = pucov(j, k) + pdufi(j, k) * pdt
-    ENDDO
-  ENDDO
-
-  DO k = 1, llm
-    DO j = 1, ip1jm
-      pvcov(j, k) = pvcov(j, k) + pdvfi(j, k) * pdt
-    ENDDO
-  ENDDO
-
-
-  DO j = 1, ip1jmp1
-    pps(j) = pps(j) + pdpfi(j) * pdt
-  ENDDO
-
-  IF (planet_type=="earth") THEN
-    ! earth case, special treatment for first 2 tracers (water)
-    DO iq = 1, 2
-      DO k = 1, llm
-        DO j = 1, ip1jmp1
-          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
-          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestw)
-        ENDDO
-      ENDDO
-    ENDDO
-
-    DO iq = 3, nqtot
-      DO k = 1, llm
-        DO j = 1, ip1jmp1
-          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
-          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
-        ENDDO
-      ENDDO
-    ENDDO
-  else
-    ! general case, treat all tracers equally)
-    DO iq = 1, nqtot
-      DO k = 1, llm
-        DO j = 1, ip1jmp1
-          pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
-          pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
-        ENDDO
-      ENDDO
-    ENDDO
-  ENDIF ! of if (planet_type=="earth")
-
-  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
-
-  DO iq = 1, nqtot
-    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
-
-END SUBROUTINE addfi
Index: DZ6/branches/Amaury_dev/libf/dyn3d/advect.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/advect.F90	(revision 5185)
+++ 	(revision )
@@ -1,166 +1,0 @@
-! $Header$
-
-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
-  USE lmdz_ssum_scopy, ONLY: ssum
-  USE lmdz_comgeom
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-  !=======================================================================
-
-  !   Auteurs:  P. Le Van , Fr. Hourdin  .
-  !   -------
-
-  !   Objet:
-  !   ------
-
-  !   *************************************************************
-  !   .... calcul des termes d'advection vertic.pour u,v,teta,q ...
-  !   *************************************************************
-  !    ces termes sont ajoutes a du,dv,dteta et dq .
-  !  Modif F.Forget 03/94 : on retire q de advect
-
-  !=======================================================================
-  !-----------------------------------------------------------------------
-  !   Declarations:
-  !   -------------
-
-
-
-
-  !   Arguments:
-  !   ----------
-
-  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)
-
-  !   Local:
-  !   ------
-
-  REAL :: uav(ip1jmp1, llm), vav(ip1jm, llm), wsur2(ip1jmp1)
-  REAL :: unsaire2(ip1jmp1), ge(ip1jmp1)
-  REAL :: deuxjour, ww, gt, uu, vv
-
-  INTEGER :: ij, l
-
-  !-----------------------------------------------------------------------
-  !   2. Calculs preliminaires:
-  !   -------------------------
-
-  IF (conser)  THEN
-    deuxjour = 2. * daysec
-
-    DO   ij = 1, ip1jmp1
-      unsaire2(ij) = unsaire(ij) * unsaire(ij)
-    END DO
-  END IF
-
-
-  !------------------  -yy ----------------------------------------------
-  !   .  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
-
-  !------------------  -xx ----------------------------------------------
-  !   .  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
-
-  !-----------------------------------------------------------------------
-
-
-  DO l = 1, llmm1
-
-
-    ! ......   calcul de  - w/2.    au niveau  l+1   .......
-
-    DO ij = 1, ip1jmp1
-      wsur2(ij) = - 0.5 * w(ij, l + 1)
-    END DO
-
-
-    ! .....................     calcul pour  du     ..................
-
-    DO 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)
-    END DO
-
-    ! .....  correction pour  du(iip1,j,l)  ........
-    ! .....     du(iip1,j,l)= du(1,j,l)   .....
-
-    !DIR$ IVDEP
-    DO   ij = iip1 + iip1, ip1jm, iip1
-      du(ij, l) = du(ij - iim, l)
-      du(ij, l + 1) = du(ij - iim, l + 1)
-    END DO
-
-    ! .................    calcul pour   dv      .....................
-
-    DO 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)
-    END DO
-
-    !
-
-    ! ............................................................
-    ! ...............    calcul pour   dh      ...................
-    ! ............................................................
-
-    !                   ---z
-    !   calcul de  - d( teta  * w )      qu'on ajoute a   dh
-    !               ...............
-
-    DO 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
-    END DO
-
-    IF(conser)  THEN
-      DO ij = 1, ip1jmp1
-        ge(ij) = wsur2(ij) * wsur2(ij) * unsaire2(ij)
-      END DO
-      gt = SSUM(ip1jmp1, ge, 1)
-      gtot(l) = deuxjour * SQRT(gt / ip1jmp1)
-    END IF
-
-  END DO
-
-
-END SUBROUTINE advect
Index: DZ6/branches/Amaury_dev/libf/dyn3d/advtrac.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/advtrac.f90	(revision 5185)
+++ 	(revision )
@@ -1,358 +1,0 @@
-! $Id$
-
-SUBROUTINE advtrac(pbaru, pbarv, p, masse, q, iapptrac, teta, flxw, pk)
-  !     Auteur :  F. Hourdin
-
-  !     Modif. P. Le Van     (20/12/97)
-  !            F. Codron     (10/99)
-  !            D. Le Croller (07/2001)
-  !            M.A Filiberti (04/2002)
-
-  USE lmdz_infotrac, ONLY: nqtot, tracers, isoCheck
-  USE control_mod, ONLY: iapp_tracvl, day_step
-  USE comconst_mod, ONLY: dtvr
-  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
-  USE lmdz_strings, ONLY: int2str
-  USE lmdz_description, ONLY: descript
-  USE lmdz_libmath, ONLY: minmax
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_ssum_scopy, ONLY: scopy
-  USE lmdz_comdissip, ONLY: coefdis, tetavel, tetatemp, gamdissip, niterdis
-  USE lmdz_comgeom2
-  USE lmdz_groupe, ONLY: groupe
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-IMPLICIT NONE
-
-
-
-
-  !---------------------------------------------------------------------------
-  !     Arguments
-  !---------------------------------------------------------------------------
-  INTEGER, INTENT(OUT) :: iapptrac
-  REAL, INTENT(IN) :: pbaru(ip1jmp1, llm)
-  REAL, INTENT(IN) :: pbarv(ip1jm, llm)
-  REAL, INTENT(INOUT) :: q(ip1jmp1, llm, nqtot)
-  REAL, INTENT(IN) :: masse(ip1jmp1, llm)
-  REAL, INTENT(IN) :: p(ip1jmp1, llmp1)
-  REAL, INTENT(IN) :: teta(ip1jmp1, llm)
-  REAL, INTENT(IN) :: pk(ip1jmp1, llm)
-  REAL, INTENT(OUT) :: flxw(ip1jmp1, llm)
-  !---------------------------------------------------------------------------
-  !     Ajout PPM
-  !---------------------------------------------------------------------------
-  REAL :: massebx(ip1jmp1, llm), masseby(ip1jm, llm)
-  !---------------------------------------------------------------------------
-  !     Variables locales
-  !---------------------------------------------------------------------------
-  INTEGER :: ij, l, iq, iadv
-  !   REAL(KIND=KIND(1.d0)) :: t_initial, t_final, tps_cpu
-  REAL :: zdp(ip1jmp1), zdpmin, zdpmax
-  INTEGER, SAVE :: iadvtr = 0
-  REAL, DIMENSION(ip1jmp1, llm) :: pbaruc, pbarug, massem, wg
-  REAL, DIMENSION(ip1jm, llm) :: pbarvc, pbarvg
-  SAVE massem, pbaruc, pbarvc
-  !---------------------------------------------------------------------------
-  !     Rajouts pour PPM
-  !---------------------------------------------------------------------------
-  INTEGER indice, n
-  REAL :: dtbon                       ! Pas de temps adaptatif pour que CFL<1
-  REAL :: CFLmaxz, aaa, bbb           ! CFL maximum
-  REAL, DIMENSION(iim, jjp1, llm) :: unatppm, vnatppm, fluxwppm
-  REAL :: qppm(iim * jjp1, llm, nqtot)
-  REAL :: psppm(iim, jjp1)           ! pression  au sol
-  REAL, DIMENSION(llmp1) :: apppm, bpppm
-  LOGICAL, SAVE :: dum = .TRUE., fill = .TRUE.
-
-  INTEGER, SAVE :: countcfl = 0
-  REAL, DIMENSION(ip1jmp1, llm) :: cflx, cflz
-  REAL, DIMENSION(ip1jm, llm) :: cfly
-  REAL, DIMENSION(llm), SAVE :: cflxmax, cflymax, cflzmax
-
-  IF(iadvtr == 0) THEN
-    pbaruc(:, :) = 0
-    pbarvc(:, :) = 0
-  END IF
-
-  !--- Accumulation des flux de masse horizontaux
-  DO l = 1, llm
-    DO ij = 1, ip1jmp1
-      pbaruc(ij, l) = pbaruc(ij, l) + pbaru(ij, l)
-    END DO
-    DO ij = 1, ip1jm
-      pbarvc(ij, l) = pbarvc(ij, l) + pbarv(ij, l)
-    END DO
-  END DO
-
-  !--- Selection de la masse instantannee des mailles avant le transport.
-  IF(iadvtr == 0) THEN
-    CALL SCOPY(ip1jmp1 * llm, masse, 1, massem, 1)
-    ! CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 )
-  END IF
-
-  iadvtr = iadvtr + 1
-  iapptrac = iadvtr
-
-  !--- Test pour savoir si on advecte a ce pas de temps
-  IF(iadvtr /= iapp_tracvl) RETURN
-
-  !   ..  Modif P.Le Van  ( 20/12/97 )  ....
-
-  !   traitement des flux de masse avant advection.
-  !       1. calcul de w
-  !       2. groupement des mailles pres du pole.
-
-  CALL groupe(pbaruc, pbarvc, pbarug, pbarvg, wg)
-
-  !--- Flux de masse diaganostiques traceurs
-  flxw = wg / REAL(iapp_tracvl)
-
-  !--- 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) &
-              - pbarvg(ij - iip1, l) + pbarvg(ij, l) &
-              + wg(ij, l + 1) - wg(ij, l)
-    END DO
-    ! ym  ---> pourquoi jjm-1 et non jjm ? a cause du pole ?
-    CALL SCOPY(jjm - 1, zdp(iip1 + iip1), iip1, zdp(iip2), iip1)
-    DO ij = iip2, ip1jm
-      zdp(ij) = zdp(ij) * dtvr / massem(ij, l)
-    END DO
-
-    CALL minmax (ip1jm - iip1, zdp(iip2), zdpmin, zdpmax)
-
-    IF(MAX(ABS(zdpmin), ABS(zdpmax)) > 0.5) &
-            WRITE(*, *)'WARNING DP/P l=', l, '  MIN:', zdpmin, ' MAX:', zdpmax
-
-  END DO
-
-  !-------------------------------------------------------------------------
-  ! Calcul des criteres CFL en X, Y et Z
-  !-------------------------------------------------------------------------
-  IF(countcfl == 0.) THEN
-    cflxmax(:) = 0.
-    cflymax(:) = 0.
-    cflzmax(:) = 0.
-  END IF
-
-  countcfl = countcfl + iapp_tracvl
-  cflx(:, :) = 0.
-  cfly(:, :) = 0.
-  cflz(:, :) = 0.
-  DO l = 1, llm
-    DO ij = iip2, ip1jm - 1
-      IF(pbarug(ij, l)>=0.) THEN
-        cflx(ij, l) = pbarug(ij, l) * dtvr / masse(ij, l)
-      ELSE
-        cflx(ij, l) = -pbarug(ij, l) * dtvr / masse(ij + 1, l)
-      END IF
-    END DO
-  END DO
-
-  DO l = 1, llm
-    DO ij = iip2, ip1jm - 1, iip1
-      cflx(ij + iip1, l) = cflx(ij, l)
-    END DO
-  END DO
-
-  DO l = 1, llm
-    DO ij = 1, ip1jm
-      IF(pbarvg(ij, l)>=0.) THEN
-        cfly(ij, l) = pbarvg(ij, l) * dtvr / masse(ij, l)
-      ELSE
-        cfly(ij, l) = -pbarvg(ij, l) * dtvr / masse(ij + iip1, l)
-      END IF
-    END DO
-  END DO
-
-  DO l = 2, llm
-    DO ij = 1, ip1jm
-      IF(wg(ij, l) >= 0.) THEN
-        cflz(ij, l) = wg(ij, l) * dtvr / masse(ij, l)
-      ELSE
-        cflz(ij, l) = -wg(ij, l) * dtvr / masse(ij, l - 1)
-      END IF
-    END DO
-  END DO
-
-  DO l = 1, llm
-    cflxmax(l) = max(cflxmax(l), maxval(cflx(:, l)))
-    cflymax(l) = max(cflymax(l), maxval(cfly(:, l)))
-    cflzmax(l) = max(cflzmax(l), maxval(cflz(:, l)))
-  END DO
-
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  ! Par defaut, on sort le diagnostic des CFL tous les jours.
-  ! Si on veut le sortir a chaque pas d'advection en cas de plantage
-  !       IF(countcfl==iapp_tracvl) THEN
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  IF(countcfl==day_step) THEN
-    DO l = 1, llm
-      WRITE(lunout, *) 'L, CFL[xyz]max:', l, cflxmax(l), cflymax(l), cflzmax(l)
-    END DO
-    countcfl = 0
-  END IF
-
-  !---------------------------------------------------------------------------
-  !   Advection proprement dite (Modification Le Croller (07/2001)
-  !---------------------------------------------------------------------------
-
-  !---------------------------------------------------------------------------
-  !   Calcul des moyennes basees sur la masse
-  !---------------------------------------------------------------------------
-  CALL massbar(massem, massebx, masseby)
-
-  IF (CPPKEY_DEBUGIO) THEN
-    CALL WriteField_u('massem', massem)
-    CALL WriteField_u('wg', wg)
-    CALL WriteField_u('pbarug', pbarug)
-    CALL WriteField_v('pbarvg', pbarvg)
-    CALL WriteField_u('p_tmp', p)
-    CALL WriteField_u('pk_tmp', pk)
-    CALL WriteField_u('teta_tmp', teta)
-    DO iq = 1, nqtot
-      CALL WriteField_u('q_adv' // trim(int2str(iq)), q(:, :, iq))
-    END DO
-  END IF
-
-  IF(isoCheck) WRITE(*, *) 'advtrac 227'
-  CALL check_isotopes_seq(q, ip1jmp1, 'advtrac 162')
-
-  !-------------------------------------------------------------------------
-  !       Appel des sous programmes d'advection
-  !-------------------------------------------------------------------------
-  DO iq = 1, nqtot
-    !     CALL clock(t_initial)
-    IF(tracers(iq)%parent /= 'air') CYCLE
-    iadv = tracers(iq)%iadv
-    !-----------------------------------------------------------------------
-    SELECT CASE(iadv)
-      !-----------------------------------------------------------------------
-    CASE(0); CYCLE
-    !--------------------------------------------------------------------
-    CASE(10)  !--- Schema de Van Leer I MUSCL
-      !--------------------------------------------------------------------
-      !           WRITE(*,*) 'advtrac 239: iq,q(1721,19,:)=',iq,q(1721,19,:)
-      CALL vlsplt(q, 2., massem, wg, pbarug, pbarvg, dtvr, iq)
-
-      !--------------------------------------------------------------------
-    CASE(14)  !--- Schema "pseuDO amont" + test sur humidite specifique
-      !--- pour la vapeur d'eau. F. Codron
-      !--------------------------------------------------------------------
-      !           WRITE(*,*) 'advtrac 248: iq,q(1721,19,:)=',iq,q(1721,19,:)
-      CALL vlspltqs(q, 2., massem, wg, pbarug, pbarvg, dtvr, p, pk, teta, iq)
-
-      !--------------------------------------------------------------------
-    CASE(12)  !--- Schema de Frederic Hourdin
-      !--------------------------------------------------------------------
-      CALL adaptdt(iadv, dtbon, n, pbarug, massem)   ! pas de temps adaptatif
-      IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
-      DO indice = 1, n
-        CALL advn(q(1, 1, iq), massem, wg, pbarug, pbarvg, dtbon, 1)
-      END DO
-
-      !--------------------------------------------------------------------
-    CASE(13)  !--- Pas de temps adaptatif
-      !--------------------------------------------------------------------
-      CALL adaptdt(iadv, dtbon, n, pbarug, massem)
-      IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
-      DO indice = 1, n
-        CALL advn(q(1, 1, iq), massem, wg, pbarug, pbarvg, dtbon, 2)
-      END DO
-
-      !--------------------------------------------------------------------
-    CASE(20)  !--- Schema de pente SLOPES
-      !--------------------------------------------------------------------
-      CALL pentes_ini (q(1, 1, iq), wg, massem, pbarug, pbarvg, 0)
-
-      !--------------------------------------------------------------------
-    CASE(30)  !--- Schema de Prather
-      !--------------------------------------------------------------------
-      ! Pas de temps adaptatif
-      CALL adaptdt(iadv, dtbon, n, pbarug, massem)
-      IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
-      CALL prather(q(1, 1, iq), wg, massem, pbarug, pbarvg, n, dtbon)
-
-      !--------------------------------------------------------------------
-    CASE(11, 16, 17, 18)   !--- Schemas PPM Lin et Rood
-      !--------------------------------------------------------------------
-      ! Test sur le flux horizontal
-      CALL adaptdt(iadv, dtbon, n, pbarug, massem)   ! pas de temps adaptatif
-      IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
-      ! Test sur le flux vertical
-      CFLmaxz = 0.
-      DO l = 2, llm
-        DO ij = iip2, ip1jm
-          aaa = wg(ij, l) * dtvr / massem(ij, l)
-          CFLmaxz = max(CFLmaxz, aaa)
-          bbb = -wg(ij, l) * dtvr / massem(ij, l - 1)
-          CFLmaxz = max(CFLmaxz, bbb)
-        END DO
-      END DO
-      IF(CFLmaxz>=1) WRITE(*, *) 'WARNING vertical', 'CFLmaxz=', CFLmaxz
-      !----------------------------------------------------------------
-      !     Ss-prg interface LMDZ.4->PPM3d (ss-prg de Lin)
-      !----------------------------------------------------------------
-      CALL interpre(q(1, 1, iq), qppm(1, 1, iq), wg, fluxwppm, massem, &
-              apppm, bpppm, massebx, masseby, pbarug, pbarvg, &
-              unatppm, vnatppm, psppm)
-
-      !----------------------------------------------------------------
-      DO indice = 1, n     !--- VL (version PPM) horiz. et PPM vert.
-        !----------------------------------------------------------------
-        SELECT CASE(iadv)
-          !----------------------------------------------------------
-        CASE(11)
-          !----------------------------------------------------------
-          CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
-                  2, 2, 2, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
-          !----------------------------------------------------------
-        CASE(16) !--- Monotonic PPM
-          !----------------------------------------------------------
-          CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
-                  3, 3, 3, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
-          !----------------------------------------------------------
-        CASE(17) !--- Semi monotonic PPM
-          !----------------------------------------------------------
-          CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
-                  4, 4, 4, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
-          !----------------------------------------------------------
-        CASE(18) !--- Positive Definite PPM
-          !----------------------------------------------------------
-          CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
-                  5, 5, 5, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
-        END SELECT
-        !----------------------------------------------------------------
-      END DO
-      !----------------------------------------------------------------
-      !     Ss-prg interface PPM3d-LMDZ.4
-      !----------------------------------------------------------------
-      CALL interpost(q(1, 1, iq), qppm(1, 1, iq))
-      !----------------------------------------------------------------------
-    END SELECT
-    !----------------------------------------------------------------------
-
-    !----------------------------------------------------------------------
-    ! On impose une seule valeur du traceur au pole Sud j=jjm+1=jjp1 et Nord j=1
-    !----------------------------------------------------------------------
-    !  CALL traceurpole(q(1,1,iq),massem)
-
-    !--- Calcul du temps cpu pour un schema donne
-    !  CALL clock(t_final)
-    !ym  tps_cpu=t_final-t_initial
-    !ym  cpuadv(iq)=cpuadv(iq)+tps_cpu
-
-  END DO
-
-  IF(isoCheck) WRITE(*, *) 'advtrac 402'
-  CALL check_isotopes_seq(q, ip1jmp1, 'advtrac 397')
-
-  !-------------------------------------------------------------------------
-  !   on reinitialise a zero les flux de masse cumules
-  !-------------------------------------------------------------------------
-  iadvtr = 0
-
-END SUBROUTINE advtrac
Index: DZ6/branches/Amaury_dev/libf/dyn3d/bilan_dyn.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/bilan_dyn.F90	(revision 5185)
+++ 	(revision )
@@ -1,582 +1,0 @@
-! $Id$
-
-SUBROUTINE bilan_dyn(ntrac, dt_app, dt_cum, &
-        ps, masse, pk, flux_u, flux_v, teta, phi, ucov, vcov, trac)
-
-  !   AFAIRE
-  !   Prevoir en champ nq+1 le diagnostique de l'energie
-  !   en faisant Qzon=Cv T + L * ...
-  !             vQ..A=Cp T + L * ...
-
-  USE IOIPSL
-  USE comconst_mod, ONLY: pi, cpp
-  USE comvert_mod, ONLY: presnivs
-  USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comgeom2
-
-USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-
-
-
-  !====================================================================
-
-  !   Sous-programme consacre à des diagnostics dynamiques de base
-
-
-  !   De facon generale, les moyennes des scalaires Q sont ponderees par
-  !   la masse.
-
-  !   Les flux de masse sont eux simplement moyennes.
-
-  !====================================================================
-
-  !   Arguments :
-  !   ===========
-
-  INTEGER :: ntrac
-  REAL :: dt_app, dt_cum
-  REAL :: ps(iip1, jjp1)
-  REAL :: masse(iip1, jjp1, llm), pk(iip1, jjp1, llm)
-  REAL :: flux_u(iip1, jjp1, llm)
-  REAL :: flux_v(iip1, jjm, llm)
-  REAL :: teta(iip1, jjp1, llm)
-  REAL :: phi(iip1, jjp1, llm)
-  REAL :: ucov(iip1, jjp1, llm)
-  REAL :: vcov(iip1, jjm, llm)
-  REAL :: trac(iip1, jjp1, llm, ntrac)
-
-  !   Local :
-  !   =======
-
-  INTEGER :: icum, ncum
-  LOGICAL :: first
-  REAL :: zz, zqy, zfactv(jjm, llm)
-
-  INTEGER :: nQ
-  parameter (nQ = 7)
-
-
-  !ym      CHARACTER*6 nom(nQ)
-  !ym      CHARACTER*6 unites(nQ)
-  CHARACTER*6, save :: nom(nQ)
-  CHARACTER*6, save :: unites(nQ)
-
-  CHARACTER(LEN = 10) :: file
-  INTEGER :: ifile
-  parameter (ifile = 4)
-
-  INTEGER :: itemp, igeop, iecin, iang, iu, iovap, iun
-  INTEGER :: i_sortie
-
-  save first, icum, ncum
-  save itemp, igeop, iecin, iang, iu, iovap, iun
-  save i_sortie
-
-  REAL :: time
-  INTEGER :: itau
-  save time, itau
-  data time, itau/0., 0/
-
-  data first/.TRUE./
-  data itemp, igeop, iecin, iang, iu, iovap, iun/1, 2, 3, 4, 5, 6, 7/
-  data i_sortie/1/
-
-  REAL :: ww
-
-  !   variables dynamiques intermédiaires
-  REAL :: vcont(iip1, jjm, llm), ucont(iip1, jjp1, llm)
-  REAL :: ang(iip1, jjp1, llm), unat(iip1, jjp1, llm)
-  REAL :: massebx(iip1, jjp1, llm), masseby(iip1, jjm, llm)
-  REAL :: vorpot(iip1, jjm, llm)
-  REAL :: w(iip1, jjp1, llm), ecin(iip1, jjp1, llm), convm(iip1, jjp1, llm)
-  REAL :: bern(iip1, jjp1, llm)
-
-  !   champ contenant les scalaires advectés.
-  REAL :: Q(iip1, jjp1, llm, nQ)
-
-  !   champs cumulés
-  REAL :: ps_cum(iip1, jjp1)
-  REAL :: masse_cum(iip1, jjp1, llm)
-  REAL :: flux_u_cum(iip1, jjp1, llm)
-  REAL :: flux_v_cum(iip1, jjm, llm)
-  REAL :: Q_cum(iip1, jjp1, llm, nQ)
-  REAL :: flux_uQ_cum(iip1, jjp1, llm, nQ)
-  REAL :: flux_vQ_cum(iip1, jjm, llm, nQ)
-  REAL :: flux_wQ_cum(iip1, jjp1, llm, nQ)
-  REAL :: dQ(iip1, jjp1, llm, nQ)
-
-  save ps_cum, masse_cum, flux_u_cum, flux_v_cum
-  save Q_cum, flux_uQ_cum, flux_vQ_cum
-
-  !   champs de tansport en moyenne zonale
-  INTEGER :: ntr, itr
-  parameter (ntr = 5)
-
-  !ym      CHARACTER*10 znom(ntr,nQ)
-  !ym      CHARACTER*20 znoml(ntr,nQ)
-  !ym      CHARACTER*10 zunites(ntr,nQ)
-  CHARACTER*10, save :: znom(ntr, nQ)
-  CHARACTER*20, save :: znoml(ntr, nQ)
-  CHARACTER*10, save :: zunites(ntr, nQ)
-
-  INTEGER :: iave, itot, immc, itrs, istn
-  data iave, itot, immc, itrs, istn/1, 2, 3, 4, 5/
-  CHARACTER(LEN = 3) :: ctrs(ntr)
-  data ctrs/'  ', 'TOT', 'MMC', 'TRS', 'STN'/
-
-  REAL :: zvQ(jjm, llm, ntr, nQ), zvQtmp(jjm, llm)
-  REAL :: zavQ(jjm, ntr, nQ), psiQ(jjm, llm + 1, nQ)
-  REAL :: zmasse(jjm, llm), zamasse(jjm)
-
-  REAL :: zv(jjm, llm), psi(jjm, llm + 1)
-
-  INTEGER :: i, j, l, iQ
-
-
-  !   Initialisation du fichier contenant les moyennes zonales.
-  !   ---------------------------------------------------------
-
-  CHARACTER(LEN = 10) :: infile
-
-  INTEGER :: fileid
-  INTEGER :: thoriid, zvertiid
-  save fileid
-
-  INTEGER :: ndex3d(jjm * llm)
-
-  !   Variables locales
-
-  INTEGER :: tau0
-  REAL :: zjulian
-  CHARACTER(LEN = 3) :: str
-  CHARACTER(LEN = 10) :: ctrac
-  INTEGER :: ii, jj
-  INTEGER :: zan, dayref
-
-  REAL :: rlong(jjm), rlatg(jjm)
-
-
-
-  !=====================================================================
-  !   Initialisation
-  !=====================================================================
-
-  time = time + dt_app
-  itau = itau + 1
-  !IM
-  ndex3d = 0
-
-  IF (first) THEN
-    icum = 0
-    ! initialisation des fichiers
-    first = .FALSE.
-    !   ncum est la frequence de stokage en pas de temps
-    ncum = dt_cum / dt_app
-    IF (abs(ncum * dt_app - dt_cum)>1.e-5 * dt_app) THEN
-      WRITE(lunout, *) &
-              'Pb : le pas de cumule doit etre multiple du pas'
-      WRITE(lunout, *)'dt_app=', dt_app
-      WRITE(lunout, *)'dt_cum=', dt_cum
-      CALL abort_gcm('bilan_dyn', 'stopped', 1)
-    endif
-
-    IF (i_sortie==1) THEN
-      file = 'dynzon'
-      CALL inigrads(ifile, 1 &
-              , 0., 180. / pi, 0., 0., jjm, rlatv, -90., 90., 180. / pi &
-              , llm, presnivs, 1. &
-              , dt_cum, file, 'dyn_zon ')
-    endif
-
-    nom(itemp) = 'T'
-    nom(igeop) = 'gz'
-    nom(iecin) = 'K'
-    nom(iang) = 'ang'
-    nom(iu) = 'u'
-    nom(iovap) = 'ovap'
-    nom(iun) = 'un'
-
-    unites(itemp) = 'K'
-    unites(igeop) = 'm2/s2'
-    unites(iecin) = 'm2/s2'
-    unites(iang) = 'ang'
-    unites(iu) = 'm/s'
-    unites(iovap) = 'kg/kg'
-    unites(iun) = 'un'
-
-
-    !   Initialisation du fichier contenant les moyennes zonales.
-    !   ---------------------------------------------------------
-
-    infile = 'dynzon'
-
-    zan = annee_ref
-    dayref = day_ref
-    CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
-    tau0 = itau_dyn
-
-    rlong = 0.
-    rlatg = rlatv * 180. / pi
-
-    CALL histbeg(infile, 1, rlong, jjm, rlatg, &
-            1, 1, 1, jjm, &
-            tau0, zjulian, dt_cum, thoriid, fileid)
-
-
-    !  Appel a histvert pour la grille verticale
-
-    CALL histvert(fileid, 'presnivs', 'Niveaux sigma', 'mb', &
-            llm, presnivs, zvertiid)
-
-    !  Appels a histdef pour la definition des variables a sauvegarder
-    DO iQ = 1, nQ
-      DO itr = 1, ntr
-        IF(itr==1) THEN
-          znom(itr, iQ) = nom(iQ)
-          znoml(itr, iQ) = nom(iQ)
-          zunites(itr, iQ) = unites(iQ)
-        else
-          znom(itr, iQ) = ctrs(itr) // 'v' // nom(iQ)
-          znoml(itr, iQ) = 'transport : v * ' // nom(iQ) // ' ' // ctrs(itr)
-          zunites(itr, iQ) = 'm/s * ' // unites(iQ)
-        endif
-      enddo
-    enddo
-
-    !   Declarations des champs avec dimension verticale
-    ! PRINT*,'1HISTDEF'
-    DO iQ = 1, nQ
-      DO itr = 1, ntr
-        IF (prt_level > 5) &
-                WRITE(lunout, *)'var ', itr, iQ &
-                        , znom(itr, iQ), znoml(itr, iQ), zunites(itr, iQ)
-        CALL histdef(fileid, znom(itr, iQ), znoml(itr, iQ), &
-                zunites(itr, iQ), 1, jjm, thoriid, llm, 1, llm, zvertiid, &
-                32, 'ave(X)', dt_cum, dt_cum)
-      enddo
-      !   Declarations pour les fonctions de courant
-      ! PRINT*,'2HISTDEF'
-      CALL histdef(fileid, 'psi' // nom(iQ) &
-              , 'stream fn. ' // znoml(itot, iQ), &
-              zunites(itot, iQ), 1, jjm, thoriid, llm, 1, llm, zvertiid, &
-              32, 'ave(X)', dt_cum, dt_cum)
-    enddo
-
-
-    !   Declarations pour les champs de transport d'air
-    ! PRINT*,'3HISTDEF'
-    CALL histdef(fileid, 'masse', 'masse', &
-            'kg', 1, jjm, thoriid, llm, 1, llm, zvertiid, &
-            32, 'ave(X)', dt_cum, dt_cum)
-    CALL histdef(fileid, 'v', 'v', &
-            'm/s', 1, jjm, thoriid, llm, 1, llm, zvertiid, &
-            32, 'ave(X)', dt_cum, dt_cum)
-    !   Declarations pour les fonctions de courant
-    ! PRINT*,'4HISTDEF'
-    CALL histdef(fileid, 'psi', 'stream fn. MMC ', 'mega t/s', &
-            1, jjm, thoriid, llm, 1, llm, zvertiid, &
-            32, 'ave(X)', dt_cum, dt_cum)
-
-
-    !   Declaration des champs 1D de transport en latitude
-    ! PRINT*,'5HISTDEF'
-    DO iQ = 1, nQ
-      DO itr = 2, ntr
-        CALL histdef(fileid, 'a' // znom(itr, iQ), znoml(itr, iQ), &
-                zunites(itr, iQ), 1, jjm, thoriid, 1, 1, 1, -99, &
-                32, 'ave(X)', dt_cum, dt_cum)
-      enddo
-    enddo
-
-
-    ! PRINT*,'8HISTDEF'
-    CALL histend(fileid)
-
-  ENDIF
-
-
-  !=====================================================================
-  !   Calcul des champs dynamiques
-  !   ----------------------------
-
-  !   énergie cinétique
-  ucont(:, :, :) = 0
-  CALL covcont(llm, ucov, vcov, ucont, vcont)
-  CALL enercin(vcov, ucov, vcont, ucont, ecin)
-
-  !   moment cinétique
-  DO l = 1, llm
-    ang(:, :, l) = ucov(:, :, l) + constang(:, :)
-    unat(:, :, l) = ucont(:, :, l) * cu(:, :)
-  enddo
-
-  Q(:, :, :, itemp) = teta(:, :, :) * pk(:, :, :) / cpp
-  Q(:, :, :, igeop) = phi(:, :, :)
-  Q(:, :, :, iecin) = ecin(:, :, :)
-  Q(:, :, :, iang) = ang(:, :, :)
-  Q(:, :, :, iu) = unat(:, :, :)
-  Q(:, :, :, iovap) = trac(:, :, :, 1)
-  Q(:, :, :, iun) = 1.
-
-
-  !=====================================================================
-  !   Cumul
-  !=====================================================================
-
-  IF(icum==0) THEN
-    ps_cum = 0.
-    masse_cum = 0.
-    flux_u_cum = 0.
-    flux_v_cum = 0.
-    Q_cum = 0.
-    flux_vQ_cum = 0.
-    flux_uQ_cum = 0.
-  ENDIF
-
-  IF (prt_level > 5) &
-          WRITE(lunout, *)'dans bilan_dyn ', icum, '->', icum + 1
-  icum = icum + 1
-
-  !   accumulation des flux de masse horizontaux
-  ps_cum = ps_cum + ps
-  masse_cum = masse_cum + masse
-  flux_u_cum = flux_u_cum + flux_u
-  flux_v_cum = flux_v_cum + flux_v
-  DO iQ = 1, nQ
-    Q_cum(:, :, :, iQ) = Q_cum(:, :, :, iQ) + Q(:, :, :, iQ) * masse(:, :, :)
-  enddo
-
-  !=====================================================================
-  !  FLUX ET TENDANCES
-  !=====================================================================
-
-  !   Flux longitudinal
-  !   -----------------
-  DO iQ = 1, nQ
-    DO l = 1, llm
-      DO j = 1, jjp1
-        DO i = 1, iim
-          flux_uQ_cum(i, j, l, iQ) = flux_uQ_cum(i, j, l, iQ) &
-                  + flux_u(i, j, l) * 0.5 * (Q(i, j, l, iQ) + Q(i + 1, j, l, iQ))
-        enddo
-        flux_uQ_cum(iip1, j, l, iQ) = flux_uQ_cum(1, j, l, iQ)
-      enddo
-    enddo
-  enddo
-
-  !    flux méridien
-  !    -------------
-  DO iQ = 1, nQ
-    DO l = 1, llm
-      DO j = 1, jjm
-        DO i = 1, iip1
-          flux_vQ_cum(i, j, l, iQ) = flux_vQ_cum(i, j, l, iQ) &
-                  + flux_v(i, j, l) * 0.5 * (Q(i, j, l, iQ) + Q(i, j + 1, l, iQ))
-        enddo
-      enddo
-    enddo
-  enddo
-
-
-  !    tendances
-  !    ---------
-
-  !   convergence horizontale
-  CALL  convflu(flux_uQ_cum, flux_vQ_cum, llm * nQ, dQ)
-
-  !   calcul de la vitesse verticale
-  CALL convmas(flux_u_cum, flux_v_cum, convm)
-  CALL vitvert(convm, w)
-
-  DO iQ = 1, nQ
-    DO l = 1, llm - 1
-      DO j = 1, jjp1
-        DO i = 1, iip1
-          ww = -0.5 * w(i, j, l + 1) * (Q(i, j, l, iQ) + Q(i, j, l + 1, iQ))
-          dQ(i, j, l, iQ) = dQ(i, j, l, iQ) - ww
-          dQ(i, j, l + 1, iQ) = dQ(i, j, l + 1, iQ) + ww
-        enddo
-      enddo
-    enddo
-  enddo
-  IF (prt_level > 5) &
-          WRITE(lunout, *)'Apres les calculs fait a chaque pas'
-  !=====================================================================
-  !   PAS DE TEMPS D'ECRITURE
-  !=====================================================================
-  IF (icum==ncum) THEN
-    !=====================================================================
-
-    IF (prt_level > 5) &
-            WRITE(lunout, *)'Pas d ecriture'
-
-    !   Normalisation
-    DO iQ = 1, nQ
-      Q_cum(:, :, :, iQ) = Q_cum(:, :, :, iQ) / masse_cum(:, :, :)
-    enddo
-    zz = 1. / REAL(ncum)
-    ps_cum = ps_cum * zz
-    masse_cum = masse_cum * zz
-    flux_u_cum = flux_u_cum * zz
-    flux_v_cum = flux_v_cum * zz
-    flux_uQ_cum = flux_uQ_cum * zz
-    flux_vQ_cum = flux_vQ_cum * zz
-    dQ = dQ * zz
-
-
-    !   A retravailler eventuellement
-    !   division de dQ par la masse pour revenir aux bonnes grandeurs
-    DO iQ = 1, nQ
-      dQ(:, :, :, iQ) = dQ(:, :, :, iQ) / masse_cum(:, :, :)
-    enddo
-
-    !=====================================================================
-    !   Transport méridien
-    !=====================================================================
-
-    !   cumul zonal des masses des mailles
-    !   ----------------------------------
-    zv = 0.
-    zmasse = 0.
-    CALL massbar(masse_cum, massebx, masseby)
-    DO l = 1, llm
-      DO j = 1, jjm
-        DO i = 1, iim
-          zmasse(j, l) = zmasse(j, l) + masseby(i, j, l)
-          zv(j, l) = zv(j, l) + flux_v_cum(i, j, l)
-        enddo
-        zfactv(j, l) = cv(1, j) / zmasse(j, l)
-      enddo
-    enddo
-
-    ! PRINT*,'3OK'
-    !   --------------------------------------------------------------
-    !   calcul de la moyenne zonale du transport :
-    !   ------------------------------------------
-
-    !                                 --
-    ! TOT : la circulation totale       [ vq ]
-
-    !                                  -     -
-    ! MMC : mean meridional circulation [ v ] [ q ]
-
-    !                                 ----      --       - -
-    ! TRS : transitoires                [ v'q'] = [ vq ] - [ v q ]
-
-    !                                 - * - *       - -       -     -
-    ! STT : stationaires                [ v   q   ] = [ v q ] - [ v ] [ q ]
-
-    !                                          - -
-    !    on utilise aussi l'intermediaire TMP :  [ v q ]
-
-    !    la variable zfactv transforme un transport meridien cumule
-    !    en kg/s * unte-du-champ-transporte en m/s * unite-du-champ-transporte
-
-    !   --------------------------------------------------------------
-
-
-    !   ----------------------------------------
-    !   Transport dans le plan latitude-altitude
-    !   ----------------------------------------
-
-    zvQ = 0.
-    psiQ = 0.
-    DO iQ = 1, nQ
-      zvQtmp = 0.
-      DO l = 1, llm
-        DO j = 1, jjm
-          ! PRINT*,'j,l,iQ=',j,l,iQ
-          !   Calcul des moyennes zonales du transort total et de zvQtmp
-          DO i = 1, iim
-            zvQ(j, l, itot, iQ) = zvQ(j, l, itot, iQ) &
-                    + flux_vQ_cum(i, j, l, iQ)
-            zqy = 0.5 * (Q_cum(i, j, l, iQ) * masse_cum(i, j, l) + &
-                    Q_cum(i, j + 1, l, iQ) * masse_cum(i, j + 1, l))
-            zvQtmp(j, l) = zvQtmp(j, l) + flux_v_cum(i, j, l) * zqy &
-                    / (0.5 * (masse_cum(i, j, l) + masse_cum(i, j + 1, l)))
-            zvQ(j, l, iave, iQ) = zvQ(j, l, iave, iQ) + zqy
-          enddo
-          ! PRINT*,'aOK'
-          !   Decomposition
-          zvQ(j, l, iave, iQ) = zvQ(j, l, iave, iQ) / zmasse(j, l)
-          zvQ(j, l, itot, iQ) = zvQ(j, l, itot, iQ) * zfactv(j, l)
-          zvQtmp(j, l) = zvQtmp(j, l) * zfactv(j, l)
-          zvQ(j, l, immc, iQ) = zv(j, l) * zvQ(j, l, iave, iQ) * zfactv(j, l)
-          zvQ(j, l, itrs, iQ) = zvQ(j, l, itot, iQ) - zvQtmp(j, l)
-          zvQ(j, l, istn, iQ) = zvQtmp(j, l) - zvQ(j, l, immc, iQ)
-        enddo
-      enddo
-      !   fonction de courant meridienne pour la quantite Q
-      DO l = llm, 1, -1
-        DO j = 1, jjm
-          psiQ(j, l, iQ) = psiQ(j, l + 1, iQ) + zvQ(j, l, itot, iQ)
-        enddo
-      enddo
-    enddo
-
-    !   fonction de courant pour la circulation meridienne moyenne
-    psi = 0.
-    DO l = llm, 1, -1
-      DO j = 1, jjm
-        psi(j, l) = psi(j, l + 1) + zv(j, l)
-        zv(j, l) = zv(j, l) * zfactv(j, l)
-      enddo
-    enddo
-
-    ! PRINT*,'4OK'
-    !   sorties proprement dites
-    IF (i_sortie==1) THEN
-      DO iQ = 1, nQ
-        DO itr = 1, ntr
-          CALL histwrite(fileid, znom(itr, iQ), itau, zvQ(:, :, itr, iQ) &
-                  , jjm * llm, ndex3d)
-        enddo
-        CALL histwrite(fileid, 'psi' // nom(iQ), itau, psiQ(:, 1:llm, iQ) &
-                , jjm * llm, ndex3d)
-      enddo
-
-      CALL histwrite(fileid, 'masse', itau, zmasse &
-              , jjm * llm, ndex3d)
-      CALL histwrite(fileid, 'v', itau, zv &
-              , jjm * llm, ndex3d)
-      psi = psi * 1.e-9
-      CALL histwrite(fileid, 'psi', itau, psi(:, 1:llm), jjm * llm, ndex3d)
-
-    endif
-
-
-    !   -----------------
-    !   Moyenne verticale
-    !   -----------------
-
-    zamasse = 0.
-    DO l = 1, llm
-      zamasse(:) = zamasse(:) + zmasse(:, l)
-    enddo
-    zavQ = 0.
-    DO iQ = 1, nQ
-      DO itr = 2, ntr
-        DO l = 1, llm
-          zavQ(:, itr, iQ) = zavQ(:, itr, iQ) + zvQ(:, l, itr, iQ) * zmasse(:, l)
-        enddo
-        zavQ(:, itr, iQ) = zavQ(:, itr, iQ) / zamasse(:)
-        CALL histwrite(fileid, 'a' // znom(itr, iQ), itau, zavQ(:, itr, iQ) &
-                , jjm * llm, ndex3d)
-      enddo
-    enddo
-
-    ! on doit pouvoir tracer systematiquement la fonction de courant.
-
-    !=====================================================================
-    !/////////////////////////////////////////////////////////////////////
-    icum = 0                  !///////////////////////////////////////
-  ENDIF ! icum.EQ.ncum    !///////////////////////////////////////
-  !/////////////////////////////////////////////////////////////////////
-  !=====================================================================
-
-
-END SUBROUTINE  bilan_dyn
Index: DZ6/branches/Amaury_dev/libf/dyn3d/caladvtrac.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/caladvtrac.F90	(revision 5185)
+++ 	(revision )
@@ -1,120 +1,0 @@
-! $Id$
-
-
-
-SUBROUTINE caladvtrac(q, pbaru, pbarv, &
-        p, masse, dq, teta, &
-        flxw, pk)
-
-  USE lmdz_infotrac, ONLY: nqtot
-  USE control_mod, ONLY: iapp_tracvl, planet_type
-  USE comconst_mod, ONLY: dtvr
-  USE lmdz_filtreg, ONLY: filtreg
-  USE lmdz_ssum_scopy, ONLY: scopy
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  ! Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron
-
-  ! F.Codron (10/99) : ajout humidite specifique pour eau vapeur
-  !=======================================================================
-
-  !   Shema de  Van Leer
-
-  !=======================================================================
-
-
-
-
-  !   Arguments:
-  !   ----------
-  REAL :: pbaru(ip1jmp1, llm), pbarv(ip1jm, llm), masse(ip1jmp1, llm)
-  REAL :: p(ip1jmp1, llmp1), q(ip1jmp1, llm, nqtot)
-  REAL :: dq(ip1jmp1, llm, nqtot)
-  REAL :: teta(ip1jmp1, llm), pk(ip1jmp1, llm)
-  REAL :: flxw(ip1jmp1, llm)
-
-  !  ..................................................................
-
-  !  .. dq n'est utilise et dimensionne que pour l'eau  vapeur et liqu.
-
-  !  ..................................................................
-
-  !   Local:
-  !   ------
-
-  EXTERNAL  advtrac, minmaxq, qminimum
-  INTEGER :: ij, l, iq, iapptrac
-  REAL :: finmasse(ip1jmp1, llm), dtvrtrac
-
-  !c
-
-  ! Earth-specific stuff for the first 2 tracers (water)
-  IF (planet_type=="earth") THEN
-    ! initialisation
-    ! CRisi: il faut gérer tous les traceurs si on veut pouvoir faire des
-    ! isotopes
-    ! dq(:,:,1:2)=q(:,:,1:2)
-    dq(:, :, 1:nqtot) = q(:, :, 1:nqtot)
-
-    !  test des valeurs minmax
-    !c        CALL minmaxq(q(1,1,1),1.e33,-1.e33,'Eau vapeur (a) ')
-    !c        CALL minmaxq(q(1,1,2),1.e33,-1.e33,'Eau liquide(a) ')
-  ENDIF ! of if (planet_type.EQ."earth")
-  !   advection
-
-  CALL advtrac(pbaru, pbarv, &
-          p, masse, q, iapptrac, teta, &
-          flxw, pk)
-
-  !
-
-  IF(iapptrac==iapp_tracvl) THEN
-    IF (planet_type=="earth") THEN
-      ! Earth-specific treatment for the first 2 tracers (water)
-
-      !c          CALL minmaxq(q(1,1,1),1.e33,-1.e33,'Eau vapeur     ')
-      !c          CALL minmaxq(q(1,1,2),1.e33,-1.e33,'Eau liquide    ')
-
-      !c     ....  Calcul  de deltap  qu'on stocke dans finmasse   ...
-
-      DO l = 1, llm
-        DO ij = 1, ip1jmp1
-          finmasse(ij, l) = p(ij, l) - p(ij, l + 1)
-        ENDDO
-      ENDDO
-
-      !WRITE(*,*) 'caladvtrac 87'
-      CALL qminimum(q, nqtot, finmasse)
-      !WRITE(*,*) 'caladvtrac 89'
-
-      CALL SCOPY   (ip1jmp1 * llm, masse, 1, finmasse, 1)
-      CALL filtreg (finmasse, jjp1, llm, -2, 2, .TRUE., 1)
-
-      !   *****  Calcul de dq pour l'eau , pour le passer a la physique ******
-      !   ********************************************************************
-
-      dtvrtrac = iapp_tracvl * dtvr
-
-      DO iq = 1, nqtot
-        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
-
-    endif ! of if (planet_type.EQ."earth")
-  ELSE
-    IF (planet_type=="earth") THEN
-      ! Earth-specific treatment for the first 2 tracers (water)
-      dq(:, :, 1:nqtot) = 0.
-    endif ! of if (planet_type.EQ."earth")
-  ENDIF ! of IF( iapptrac.EQ.iapp_tracvl )
-
-END SUBROUTINE caladvtrac
-
-
Index: DZ6/branches/Amaury_dev/libf/dyn3d/caldyn.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/caldyn.F90	(revision 5185)
+++ 	(revision )
@@ -1,142 +1,0 @@
-! $Id$
-
-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
-  USE lmdz_comgeom
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  !=======================================================================
-
-  !  Auteur :  P. Le Van
-
-  !   Objet:
-  !   ------
-
-  !   Calcul des tendances dynamiques.
-
-  ! Modif 04/93 F.Forget
-  !=======================================================================
-
-  !-----------------------------------------------------------------------
-  !   0. Declarations:
-  !   ----------------
-
-
-
-
-  !   Arguments:
-  !   ----------
-
-  LOGICAL, INTENT(IN) :: conser ! triggers printing some diagnostics
-  INTEGER, INTENT(IN) :: itau ! time step index
-  REAL, INTENT(IN) :: vcov(ip1jm, llm) ! covariant meridional wind
-  REAL, INTENT(IN) :: ucov(ip1jmp1, llm) ! covariant zonal wind
-  REAL, INTENT(IN) :: teta(ip1jmp1, llm) ! potential temperature
-  REAL, INTENT(IN) :: ps(ip1jmp1) ! surface pressure
-  REAL, INTENT(IN) :: phis(ip1jmp1) ! geopotential at the surface
-  REAL, INTENT(IN) :: pk(ip1jmp1, llm) ! Exner at mid-layer
-  REAL, INTENT(IN) :: pkf(ip1jmp1, llm) ! filtered Exner
-  REAL, INTENT(IN) :: phi(ip1jmp1, llm) ! geopotential
-  REAL, INTENT(OUT) :: masse(ip1jmp1, llm) ! air mass
-  REAL, INTENT(OUT) :: dv(ip1jm, llm) ! tendency on vcov
-  REAL, INTENT(OUT) :: du(ip1jmp1, llm) ! tendency on ucov
-  REAL, INTENT(OUT) :: dteta(ip1jmp1, llm) ! tenddency on teta
-  REAL, INTENT(OUT) :: dp(ip1jmp1) ! tendency on ps
-  REAL, INTENT(OUT) :: w(ip1jmp1, llm) ! vertical velocity
-  REAL, INTENT(OUT) :: pbaru(ip1jmp1, llm) ! mass flux in the zonal direction
-  REAL, INTENT(OUT) :: pbarv(ip1jm, llm) ! mass flux in the meridional direction
-  REAL, INTENT(IN) :: time ! current time
-
-  !   Local:
-  !   ------
-
-  REAL :: vcont(ip1jm, llm), ucont(ip1jmp1, llm)
-  REAL :: ang(ip1jmp1, llm), p(ip1jmp1, llmp1)
-  REAL :: massebx(ip1jmp1, llm), masseby(ip1jm, llm), psexbarxy(ip1jm)
-  REAL :: vorpot(ip1jm, llm)
-  REAL :: ecin(ip1jmp1, llm), convm(ip1jmp1, llm)
-  REAL :: bern(ip1jmp1, llm)
-  REAL :: massebxy(ip1jm, llm)
-
-  INTEGER :: ij, l
-
-  !-----------------------------------------------------------------------
-  !   Compute dynamical tendencies:
-  !--------------------------------
-
-  ! compute contravariant winds ucont() and vcont
-  CALL covcont  (llm, ucov, vcov, ucont, vcont)
-  ! compute pressure p()
-  CALL pression (ip1jmp1, ap, bp, ps, p)
-  ! compute psexbarxy() XY-area weighted-averaged surface pressure (what for?)
-  CALL psextbar (ps, psexbarxy)
-  ! compute mass in each atmospheric mesh: masse()
-  CALL massdair (p, masse)
-  ! compute X and Y-averages of mass, massebx() and masseby()
-  CALL massbar  (masse, massebx, masseby)
-  ! compute XY-average of mass, massebxy()
-  CALL massbarxy(masse, massebxy)
-  ! compute mass fluxes pbaru() and pbarv()
-  CALL flumass  (massebx, masseby, vcont, ucont, pbaru, pbarv)
-  ! compute dteta() , horizontal converging flux of theta
-  CALL dteta1   (teta, pbaru, pbarv, dteta)
-  ! compute convm(), horizontal converging flux of mass
-  CALL convmas  (pbaru, pbarv, convm)
-
-  ! compute pressure variation due to mass convergence
-  DO ij = 1, ip1jmp1
-    dp(ij) = convm(ij, 1) / airesurg(ij)
-  ENDDO
-
-  ! compute vertical velocity w()
-  CALL vitvert (convm, w)
-  ! compute potential vorticity vorpot()
-  CALL tourpot (vcov, ucov, massebxy, vorpot)
-  ! compute rotation induced du() and dv()
-  CALL dudv1   (vorpot, pbaru, pbarv, du, dv)
-  ! compute kinetic energy ecin()
-  CALL enercin (vcov, ucov, vcont, ucont, ecin)
-  ! compute Bernouilli function bern()
-  CALL bernoui (ip1jmp1, llm, phi, ecin, bern)
-  ! compute and add du() and dv() contributions from Bernouilli and pressure
-  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
-
-  ! compute vertical advection contributions to du(), dv() and dteta()
-  CALL advect(ang, vcov, teta, w, massebx, masseby, du, dv, dteta)
-
-  !  WARNING probleme de peridocite de dv sur les PC/linux. Pb d'arrondi
-  ! probablement. Observe sur le code compile avec pgf90 3.0-1
-
-  DO l = 1, llm
-    DO ij = 1, ip1jm, iip1
-      IF(dv(ij, l)/=dv(ij + iim, l))  THEN
-        ! PRINT *,'!!!ATTENTION!!! probleme de periodicite sur vcov',
-        !    ,   ' dans caldyn'
-        ! PRINT *,' l,  ij = ', l, ij, ij+iim,dv(ij+iim,l),dv(ij,l)
-        dv(ij + iim, l) = dv(ij, l)
-      ENDIF
-    ENDDO
-  ENDDO
-
-  !-----------------------------------------------------------------------
-  !   Output some control variables:
-  !---------------------------------
-
-  IF(conser)  THEN
-    CALL sortvarc &
-            (itau, ucov, teta, ps, masse, pk, phis, vorpot, phi, bern, dp, time, vcov)
-  ENDIF
-
-END SUBROUTINE caldyn
Index: DZ6/branches/Amaury_dev/libf/dyn3d/check_isotopes.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/check_isotopes.F90	(revision 5185)
+++ 	(revision )
@@ -1,181 +1,0 @@
-SUBROUTINE check_isotopes_seq(q, ip1jmp1, err_msg)
-   USE lmdz_strings, ONLY: maxlen, msg, strIdx, strStack, int2str, real2str
-   USE lmdz_infotrac,    ONLY: nqtot, niso, nphas, isotope, isoCheck, iqIsoPha, isoSelect, &
-                          ntiso, iH2O, nzone, tracers, isoName,  itZonIso, getKey
-
-USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-   IMPLICIT NONE
-
-   REAL,             INTENT(INOUT) :: q(ip1jmp1,llm,nqtot)
-   INTEGER,          INTENT(IN)    :: ip1jmp1
-   CHARACTER(LEN=*), INTENT(IN)    :: err_msg    !--- Error message to display
-   CHARACTER(LEN=maxlen) :: modname, msg1, nm(2)
-   INTEGER :: ixt, ipha, k, i, iq, iiso, izon, ieau, iqeau, iqpar
-   INTEGER, ALLOCATABLE ::   ix(:)
-   REAL,    ALLOCATABLE, SAVE :: tnat(:)
-   REAL    :: xtractot, xiiso, deltaD, q1, q2
-   REAL, PARAMETER :: borne     = 1e19,  &
-                      errmax    = 1e-8,  &       !--- Max. absolute error
-                      errmaxrel = 1e-3,  &       !--- Max. relative error
-                      qmin      = 1e-11, &
-                      deltaDmax =1000.0, &
-                      deltaDmin =-999.0, &
-                      ridicule  = 1e-12
-   INTEGER, SAVE :: iso_eau, iso_HDO, iso_O18, &
-                             iso_O17, iso_HTO
-   LOGICAL, SAVE :: first=.TRUE.
-   LOGICAL, PARAMETER :: tnat1=.TRUE.
-
-   modname='check_isotopes'
-   IF(.NOT.isoCheck)    RETURN                   !--- No need to check => finished
-   IF(isoSelect('H2O')) RETURN                   !--- No H2O isotopes group found
-   IF(niso == 0)        RETURN                   !--- No isotopes => finished
-   IF(first) THEN
-      iso_eau = strIdx(isoName,'H216O')
-      iso_HDO = strIdx(isoName,'HDO')
-      iso_O18 = strIdx(isoName,'H218O')
-      iso_O17 = strIdx(isoName,'H217O')
-      iso_HTO = strIdx(isoName,'HTO')
-      IF (tnat1) THEN
-              tnat(:)=1.0
-      else
-         IF(getKey('tnat', tnat)) CALL abort_gcm(modname, 'missing isotopic parameter', 1)
-      endif
-      first = .FALSE.
-   END IF
-   CALL msg('31: err_msg='//TRIM(err_msg), modname)
-
-   !--- CHECK FOR NaNs (FOR ALL THE ISOTOPES, INCLUDING GEOGRAPHIC TAGGING TRACERS)
-   modname = 'check_isotopes:iso_verif_noNaN'
-   DO ixt = 1, ntiso
-      DO ipha = 1, nphas
-         iq = iqIsoPha(ixt,ipha)
-         DO k = 1, llm
-            DO i = 1, ip1jmp1
-               IF(ABS(q(i,k,iq)) < borne) CYCLE
-               WRITE(msg1,'(s,"(",i0,",",i0,",",i0,") = ",ES12.4)')TRIM(isoName(ixt)),i,k,iq,q(i,k,iq)
-               CALL msg(msg1, modname)
-               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
-            END DO
-         END DO
-      END DO
-   END DO
-
-   !--- CHECK CONSERVATION (MAIN ISOTOPE AND PARENT CONCENTRATIONS MUST BE EQUAL)
-   modname = 'check_isotopes:iso_verif_egalite'
-   ixt = iso_eau
-   IF(ixt /= 0) THEN
-      DO ipha = 1, nphas
-         iq = iqIsoPha(ixt,ipha)
-         iqpar = tracers(iq)%iqParent
-         DO k = 1, llm
-            DO i = 1, ip1jmp1
-               q1 = q(i,k,iqpar)
-               q2 = q(i,k,iq)
-!--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
-!    This would be probably required to sum from smallest to highest concentrations ; the corresponding
-!    indices vector can be computed once only (in the initializations stage), using mean concentrations.
-!              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
-               IF(ABS(q1-q2) <= errmax .OR. ABS(q1-q2)/MAX(MAX(ABS(q1),ABS(q2)),1e-18) <= errmaxrel) THEN
-                  q(i,k,iq) = q1                 !--- Bidouille pour convergence
-!                 q(i,k,tracers(iqPar)%iqDesc) = q(i,k,tracers(iqPar)%iqDesc) * q1 / q2
-                  CYCLE
-               END IF
-               CALL msg('ixt, iq = '//TRIM(strStack(int2str([ixt,iq]))), modname)
-               msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
-               CALL msg(TRIM(tracers(iqpar)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
-               CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
-               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
-            END DO
-         END DO
-      END DO
-   END IF
-
-   !--- CHECK DELTA ANOMALIES
-   modname = 'check_isotopes:iso_verif_aberrant'
-   ix = [ iso_HDO  ,   iso_O18 ]
-   nm = ['deltaD  ', 'deltaO18']
-   DO iiso = 1, SIZE(ix)
-      ixt = ix(iiso)
-      IF(ixt  == 0) CYCLE
-      DO ipha = 1, nphas
-         iq = iqIsoPha(ixt,ipha)
-         iqpar = tracers(iq)%iqParent
-         DO k = 1, llm
-            DO i = 1, ip1jmp1
-               q1 = q(i,k,iqpar)
-               q2 = q(i,k,iq)
-!--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
-!    This would be probably required to sum from smallest to highest concentrations ; the corresponding
-!    indices vector can be computed once only (in the initializations stage), using mean concentrations.
-!              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
-               IF(q2 <= qmin) CYCLE
-               deltaD = (q2/q1/tnat(ixt)-1.)*1000.
-               IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
-               CALL msg('ixt, iq = '//TRIM(strStack(int2str([ixt,iq]))), modname)
-               msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
-               CALL msg(TRIM(tracers(iqpar)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
-               CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
-               CALL msg(TRIM(nm(iiso))//TRIM(real2str(deltaD)), modname)
-               CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
-            END DO
-         END DO
-      END DO
-   END DO
-
-   IF(nzone == 0) RETURN
-
-   !--- CHECK FOR TAGGING TRACERS DELTAD ANOMALIES
-   modname = 'check_isotopes:iso_verif_aberrant'
-   IF(iso_eau /= 0 .AND. iso_HDO /= 0) THEN
-      DO izon = 1, nzone
-         ixt  = itZonIso(izon, iso_HDO)
-         ieau = itZonIso(izon, iso_eau)
-         DO ipha = 1, nphas
-            iq    = iqIsoPha(ixt,  ipha)
-            iqeau = iqIsoPha(ieau, ipha)
-            DO k = 1, llm
-               DO i = 1, ip1jmp1
-                  q1 = q(i,k,iqeau)
-                  q2 = q(i,k,iq)
-                  IF(q2<=qmin) CYCLE
-                  deltaD = (q2/q1/tnat(iso_HDO)-1.)*1000.
-                  IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
-                  CALL msg('izon, ipha = '//TRIM(strStack(int2str([izon, ipha]))), modname)
-                  CALL msg( 'ixt, ieau = '//TRIM(strStack(int2str([ ixt, ieau]))), modname)
-                  msg1 = '('//TRIM(strStack(int2str([i,k])))//')'
-                  CALL msg(TRIM(tracers(iqeau)%name)//TRIM(msg1)//' = '//TRIM(real2str(q1)), modname)
-                  CALL msg(TRIM(tracers(iq   )%name)//TRIM(msg1)//' = '//TRIM(real2str(q2)), modname)
-                  CALL msg('deltaD = '//TRIM(real2str(deltaD)), modname)
-                  CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
-               END DO
-            END DO
-         END DO
-      END DO
-   END IF
-
-   !--- CHECK FOR TAGGING TRACERS CONSERVATION (PARENT AND TAGGING TRACERS SUM OVER ALL REGIONS MUST BE EQUAL)
-   DO iiso = 1, niso
-      DO ipha = 1, nphas
-         iq = iqIsoPha(iiso, ipha)
-         DO k = 1, llm
-            DO i = 1, ip1jmp1
-               xiiso = q(i,k,iq)
-               xtractot = SUM(q(i, k, iqIsoPha(itZonIso(1:nzone,iiso), ipha)))
-               IF(ABS(xtractot-xiiso) > errmax .AND. ABS(xtractot-xiiso)/MAX(MAX(ABS(xtractot),ABS(xiiso)),1e-18) > errmaxrel) THEN
-                  CALL msg('Error in iso_verif_aberrant trac: '//TRIM(err_msg))
-                  CALL msg('iiso, ipha = '//TRIM(strStack(int2str([iiso, ipha]))), modname)
-                  CALL msg('q('//TRIM(strStack(int2str([i,k])))//',:) = '//TRIM(strStack(real2str(q(i,k,:)))), modname)
-                  CALL abort_gcm(modname, 'Error with isotopes: '//TRIM(err_msg), 1)
-               END IF
-               IF(ABS(xtractot) <= ridicule) CYCLE
-               DO izon = 1, nzone
-                  q(i,k,iq) = q(i,k,iq) / xtractot * xiiso !--- Bidouille pour convergence
-               END DO
-            END DO
-         END DO
-      END DO
-   END DO
-
-END SUBROUTINE check_isotopes_seq
-
Index: DZ6/branches/Amaury_dev/libf/dyn3d/conf_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/conf_gcm.f90	(revision 5185)
+++ 	(revision )
@@ -1,918 +1,0 @@
-! $Id$
-
-SUBROUTINE conf_gcm(tapedef, etatinit)
-
-  USE control_mod
-  USE IOIPSL
-  USE lmdz_infotrac, ONLY: type_trac
-  USE lmdz_assert, ONLY: assert
-  USE comconst_mod, ONLY: dissip_deltaz, dissip_factz, dissip_zref, &
-          iflag_top_bound, mode_top_bound, tau_top_bound, &
-          ngroup, maxlatfilter
-  USE logic_mod, ONLY: fxyhypb, iflag_phys, ok_etat0, ok_gradsfile, &
-          ok_guide, ok_limit, ok_strato, purmats, read_start, &
-          ysinus, read_orop, adv_qsat_liq
-  USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, &
-          alphax, alphay, taux, tauy
-  USE temps_mod, ONLY: calend, year_len
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
-          tetagrot, tetatemp, coefdis, vert_prof_dissip
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-  !-----------------------------------------------------------------------
-  !     Auteurs :   L. Fairhead , P. Le Van  .
-
-  !     Arguments :
-
-  !     tapedef   :
-  !     etatinit  :     = TRUE   , on ne  compare pas les valeurs des para-
-  !     -metres  du zoom  avec  celles lues sur le fichier start .
-
-  LOGICAL, INTENT(IN) :: etatinit
-  INTEGER, INTENT(IN) :: tapedef
-
-  !   Declarations :
-  !   --------------
-
-
-
-  !   local:
-  !   ------
-
-  REAL clonn, clatt, grossismxx, grossismyy
-  REAL dzoomxx, dzoomyy, tauxx, tauyy
-  LOGICAL  fxyhypbb, ysinuss
-
-  !  -------------------------------------------------------------------
-
-  !       .........     Version  du 29/04/97       ..........
-
-  !   Nouveaux parametres nitergdiv,nitergrot,niterh,tetagdiv,tetagrot,
-  !      tetatemp   ajoutes  pour la dissipation   .
-
-  !   Autre parametre ajoute en fin de liste de tapedef : ** fxyhypb ** 
-
-  !  Si fxyhypb = .TRUE. , choix de la fonction a derivee tangente hyperb.
-  !    Sinon , choix de fxynew  , a derivee sinusoidale  ..
-
-  !   ......  etatinit = . TRUE. si defrun  est appele dans ETAT0_LMD  ou
-  !         LIMIT_LMD  pour l'initialisation de start.dat (dic) et
-  !                de limit.dat ( dic)                        ...........
-  !           Sinon  etatinit = . FALSE .
-
-  !   Donc etatinit = .F.  si on veut comparer les valeurs de  grossismx ,
-  !    grossismy,clon,clat, fxyhypb  lues sur  le fichier  start  avec
-  !   celles passees  par run.def ,  au debut du gcm, apres l'appel a 
-  !    lectba .  
-  !   Ces parmetres definissant entre autres la grille et doivent etre
-  !   pareils et coherents , sinon il y aura  divergence du gcm .
-
-  !-----------------------------------------------------------------------
-  !   initialisations:
-  !   ----------------
-
-  !Config  Key  = lunout
-  !Config  Desc = unite de fichier pour les impressions
-  !Config  Def  = 6
-  !Config  Help = unite de fichier pour les impressions 
-  !Config         (defaut sortie standard = 6)
-  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
-
-  !Config  Key  = prt_level
-  !Config  Desc = niveau d'impressions de d\'ebogage
-  !Config  Def  = 0
-  !Config  Help = Niveau d'impression pour le d\'ebogage
-  !Config         (0 = minimum d'impression)
-  prt_level = 0
-  CALL getin('prt_level', prt_level)
-
-  !-----------------------------------------------------------------------
-  !  Parametres de controle du run:
-  !-----------------------------------------------------------------------
-  !Config  Key  = planet_type
-  !Config  Desc = planet type ("earth", "mars", "venus", ...)
-  !Config  Def  = earth
-  !Config  Help = this flag sets the type of atymosphere that is considered
-  planet_type = "earth"
-  CALL getin('planet_type', planet_type)
-
-  !Config  Key  = calend
-  !Config  Desc = type de calendrier utilise
-  !Config  Def  = earth_360d
-  !Config  Help = valeur possible: earth_360d, earth_365d, earth_366d
-  !Config         
-  calend = 'earth_360d'
-  CALL getin('calend', calend)
-  ! initialize year_len for aquaplanets and 1D
-  IF (calend == 'earth_360d') THEN
-    year_len = 360
-  ELSE IF (calend == 'earth_365d') THEN
-    year_len = 365
-  ELSE IF (calend == 'earth_366d') THEN
-    year_len = 366
-  ELSE
-    year_len = 1
-  ENDIF
-
-  !Config  Key  = dayref
-  !Config  Desc = Jour de l'etat initial
-  !Config  Def  = 1
-  !Config  Help = Jour de l'etat initial ( = 350  si 20 Decembre ,
-  !Config         par expl. ,comme ici ) ... A completer
-  dayref = 1
-  CALL getin('dayref', dayref)
-
-  !Config  Key  = anneeref
-  !Config  Desc = Annee de l'etat initial
-  !Config  Def  = 1998
-  !Config  Help = Annee de l'etat  initial 
-  !Config         (   avec  4  chiffres   ) ... A completer
-  anneeref = 1998
-  CALL getin('anneeref', anneeref)
-
-  !Config  Key  = raz_date
-  !Config  Desc = Remise a zero de la date initiale
-  !Config  Def  = 0 (pas de remise a zero)
-  !Config  Help = Remise a zero de la date initiale 
-  !Config         0 pas de remise a zero, on garde la date du fichier restart
-  !Config         1 prise en compte de la date de gcm.def avec remise a zero
-  !Config         des compteurs de pas de temps
-  raz_date = 0
-  CALL getin('raz_date', raz_date)
-
-  !Config  Key  = resetvarc
-  !Config  Desc = Reinit des variables de controle
-  !Config  Def  = n
-  !Config  Help = Reinit des variables de controle
-  resetvarc = .FALSE.
-  CALL getin('resetvarc', resetvarc)
-
-  !Config  Key  = nday
-  !Config  Desc = Nombre de jours d'integration
-  !Config  Def  = 10
-  !Config  Help = Nombre de jours d'integration
-  !Config         ... On pourait aussi permettre des mois ou des annees !
-  nday = 10
-  CALL getin('nday', nday)
-
-  !Config  Key  = starttime
-  !Config  Desc = Heure de depart de la simulation
-  !Config  Def  = 0
-  !Config  Help = Heure de depart de la simulation
-  !Config         en jour
-  starttime = 0
-  CALL getin('starttime', starttime)
-
-  !Config  Key  = day_step
-  !Config  Desc = nombre de pas par jour
-  !Config  Def  = 240 
-  !Config  Help = nombre de pas par jour (multiple de iperiod) (
-  !Config          ici pour  dt = 1 min ) 
-  day_step = 240
-  CALL getin('day_step', day_step)
-
-  !Config  Key  = nsplit_phys
-  nsplit_phys = 1
-  CALL getin('nsplit_phys', nsplit_phys)
-
-  !Config  Key  = iperiod
-  !Config  Desc = periode pour le pas Matsuno
-  !Config  Def  = 5
-  !Config  Help = periode pour le pas Matsuno (en pas de temps)
-  iperiod = 5
-  CALL getin('iperiod', iperiod)
-
-  !Config  Key  = iapp_tracvl
-  !Config  Desc = frequence du groupement des flux 
-  !Config  Def  = iperiod
-  !Config  Help = frequence du groupement des flux (en pas de temps) 
-  iapp_tracvl = iperiod
-  CALL getin('iapp_tracvl', iapp_tracvl)
-
-  !Config  Key  = iconser
-  !Config  Desc = periode de sortie des variables de controle
-  !Config  Def  = 240  
-  !Config  Help = periode de sortie des variables de controle
-  !Config         (En pas de temps)
-  iconser = 240
-  CALL getin('iconser', iconser)
-
-  !Config  Key  = iecri
-  !Config  Desc = periode d'ecriture du fichier histoire
-  !Config  Def  = 1
-  !Config  Help = periode d'ecriture du fichier histoire (en jour) 
-  iecri = 1
-  CALL getin('iecri', iecri)
-
-  !Config  Key  = periodav
-  !Config  Desc = periode de stockage fichier histmoy
-  !Config  Def  = 1
-  !Config  Help = periode de stockage fichier histmoy (en jour) 
-  periodav = 1.
-  CALL getin('periodav', periodav)
-
-  !Config  Key  = output_grads_dyn
-  !Config  Desc = output dynamics diagnostics in 'dyn.dat' file
-  !Config  Def  = n
-  !Config  Help = output dynamics diagnostics in Grads-readable 'dyn.dat' file
-  output_grads_dyn = .FALSE.
-  CALL getin('output_grads_dyn', output_grads_dyn)
-
-  !Config  Key  = dissip_period
-  !Config  Desc = periode de la dissipation 
-  !Config  Def  = 0
-  !Config  Help = periode de la dissipation 
-  !Config  dissip_period=0 => la valeur sera calcule dans inidissip       
-  !Config  dissip_period>0 => on prend cette valeur
-  dissip_period = 0
-  CALL getin('dissip_period', dissip_period)
-
-  !cc  ....   P. Le Van , modif le 29/04/97 .pour la dissipation  ...
-  !cc
-
-  !Config  Key  = lstardis
-  !Config  Desc = choix de l'operateur de dissipation
-  !Config  Def  = y
-  !Config  Help = choix de l'operateur de dissipation
-  !Config         'y' si on veut star et 'n' si on veut non-start !
-  !Config         Moi y en a pas comprendre ! 
-  lstardis = .TRUE.
-  CALL getin('lstardis', lstardis)
-
-  !Config  Key  = nitergdiv
-  !Config  Desc = Nombre d'iteration de gradiv
-  !Config  Def  = 1
-  !Config  Help = nombre d'iterations de l'operateur de dissipation 
-  !Config         gradiv
-  nitergdiv = 1
-  CALL getin('nitergdiv', nitergdiv)
-
-  !Config  Key  = nitergrot
-  !Config  Desc = nombre d'iterations de nxgradrot
-  !Config  Def  = 2
-  !Config  Help = nombre d'iterations de l'operateur de dissipation  
-  !Config         nxgradrot
-  nitergrot = 2
-  CALL getin('nitergrot', nitergrot)
-
-  !Config  Key  = niterh
-  !Config  Desc = nombre d'iterations de divgrad
-  !Config  Def  = 2
-  !Config  Help = nombre d'iterations de l'operateur de dissipation
-  !Config         divgrad
-  niterh = 2
-  CALL getin('niterh', niterh)
-
-  !Config  Key  = tetagdiv
-  !Config  Desc = temps de dissipation pour div
-  !Config  Def  = 7200
-  !Config  Help = temps de dissipation des plus petites longeur 
-  !Config         d'ondes pour u,v (gradiv)
-  tetagdiv = 7200.
-  CALL getin('tetagdiv', tetagdiv)
-
-  !Config  Key  = tetagrot
-  !Config  Desc = temps de dissipation pour grad
-  !Config  Def  = 7200
-  !Config  Help = temps de dissipation des plus petites longeur 
-  !Config         d'ondes pour u,v (nxgradrot)
-  tetagrot = 7200.
-  CALL getin('tetagrot', tetagrot)
-
-  !Config  Key  = tetatemp 
-  !Config  Desc = temps de dissipation pour h
-  !Config  Def  = 7200
-  !Config  Help =  temps de dissipation des plus petites longeur 
-  !Config         d'ondes pour h (divgrad)   
-  tetatemp = 7200.
-  CALL getin('tetatemp', tetatemp)
-
-  ! Parametres controlant la variation sur la verticale des constantes de
-  ! dissipation.
-  ! Pour le moment actifs uniquement dans la version a 39 niveaux
-  ! avec ok_strato=y
-
-  dissip_factz = 4.
-  dissip_deltaz = 10.
-  dissip_zref = 30.
-  CALL getin('dissip_factz', dissip_factz)
-  CALL getin('dissip_deltaz', dissip_deltaz)
-  CALL getin('dissip_zref', dissip_zref)
-
-  ! maxlatfilter
-  maxlatfilter = -1.0
-  CALL getin('maxlatfilter', maxlatfilter)
-  IF (maxlatfilter > 90) &
-          CALL abort_gcm("conf_gcm", 'maxlatfilter should be <=90', 1)
-
-
-  ! ngroup
-  ngroup = 3
-  CALL getin('ngroup', ngroup)
-
-  ! top_bound sponge: only active if ok_strato=.TRUE. and iflag_top_bound!=0
-  !                   iflag_top_bound=0 for no sponge
-  !                   iflag_top_bound=1 for sponge over 4 topmost layers
-  !                   iflag_top_bound=2 for sponge from top to ~1% of top layer pressure
-  iflag_top_bound = 1
-  CALL getin('iflag_top_bound', iflag_top_bound)
-  IF (iflag_top_bound < 0 .OR. iflag_top_bound > 2) &
-          CALL abort_gcm("conf_gcm", 'iflag_top_bound must be 0, 1 or 2', 1)
-
-  ! mode_top_bound : fields towards which sponge relaxation will be done:
-  !                  mode_top_bound=0: no relaxation
-  !                  mode_top_bound=1: u and v relax towards 0
-  !                  mode_top_bound=2: u and v relax towards their zonal mean
-  !                  mode_top_bound=3: u,v and pot. temp. relax towards their zonal mean
-  mode_top_bound = 3
-  CALL getin('mode_top_bound', mode_top_bound)
-
-  ! top_bound sponge : inverse of charactericstic relaxation time scale for sponge
-  tau_top_bound = 1.e-5
-  CALL getin('tau_top_bound', tau_top_bound)
-
-  !Config  Key  = coefdis
-  !Config  Desc = coefficient pour gamdissip
-  !Config  Def  = 0
-  !Config  Help = coefficient pour gamdissip  
-  coefdis = 0.
-  CALL getin('coefdis', coefdis)
-
-  !Config  Key  = purmats
-  !Config  Desc = Schema d'integration
-  !Config  Def  = n
-  !Config  Help = Choix du schema d'integration temporel.
-  !Config         y = pure Matsuno sinon c'est du Matsuno-leapfrog
-  purmats = .FALSE.
-  CALL getin('purmats', purmats)
-
-  !Config  Key  = ok_guide
-  !Config  Desc = Guidage
-  !Config  Def  = n
-  !Config  Help = Guidage
-  ok_guide = .FALSE.
-  CALL getin('ok_guide', ok_guide)
-
-  !Config  Key  =  read_start
-  !Config  Desc = Initialize model using a 'start.nc' file
-  !Config  Def  = y
-  !Config  Help = y: intialize dynamical fields using a 'start.nc' file
-  !               n: fields are initialized by 'iniacademic' routine
-  read_start = .TRUE.
-  CALL getin('read_start', read_start)
-
-  !Config  Key  = iflag_phys
-  !Config  Desc = Avec ls physique 
-  !Config  Def  = 1
-  !Config  Help = Permet de faire tourner le modele sans 
-  !Config         physique.
-  iflag_phys = 1
-  CALL getin('iflag_phys', iflag_phys)
-
-  !Config  Key  =  iphysiq
-  !Config  Desc = Periode de la physique
-  !Config  Def  = 5
-  !Config  Help = Periode de la physique en pas de temps de la dynamique.
-  iphysiq = 5
-  CALL getin('iphysiq', iphysiq)
-
-  !Config  Key  = ip_ebil_dyn
-  !Config  Desc = PRINT level for energy conserv. diag.
-  !Config  Def  = 0
-  !Config  Help = PRINT level for energy conservation diag. ;
-  !               les options suivantes existent :
-  !Config         0 pas de print
-  !Config         1 pas de print
-  !Config         2 print,
-  ip_ebil_dyn = 0
-  CALL getin('ip_ebil_dyn', ip_ebil_dyn)
-
-  !cc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
-  !     .........   (  modif  le 17/04/96 )   .........
-
-  test_etatinit: IF (.NOT. etatinit) THEN
-    !Config  Key  = clon
-    !Config  Desc = centre du zoom, longitude
-    !Config  Def  = 0
-    !Config  Help = longitude en degres du centre
-    !Config         du zoom
-    clonn = 0.
-    CALL getin('clon', clonn)
-
-    !Config  Key  = clat
-    !Config  Desc = centre du zoom, latitude
-    !Config  Def  = 0
-    !Config  Help = latitude en degres du centre du zoom
-    !Config
-    clatt = 0.
-    CALL getin('clat', clatt)
-
-    IF(ABS(clat - clatt)>= 0.001)  THEN
-      WRITE(lunout, *)'conf_gcm: La valeur de clat passee par run.def', &
-              ' est differente de celle lue sur le fichier  start '
-      CALL abort_gcm("conf_gcm", "stopped", 1)
-    ENDIF
-
-    !Config  Key  = grossismx
-    !Config  Desc = zoom en longitude
-    !Config  Def  = 1.0
-    !Config  Help = facteur de grossissement du zoom,
-    !Config         selon la longitude
-    grossismxx = 1.0
-    CALL getin('grossismx', grossismxx)
-
-    IF(ABS(grossismx - grossismxx)>= 0.001)  THEN
-      WRITE(lunout, *)'conf_gcm: La valeur de grossismx passee par ', &
-              'run.def est differente de celle lue sur le fichier  start '
-      CALL abort_gcm("conf_gcm", "stopped", 1)
-    ENDIF
-
-    !Config  Key  = grossismy
-    !Config  Desc = zoom en latitude
-    !Config  Def  = 1.0
-    !Config  Help = facteur de grossissement du zoom,
-    !Config         selon la latitude
-    grossismyy = 1.0
-    CALL getin('grossismy', grossismyy)
-
-    IF(ABS(grossismy - grossismyy)>= 0.001)  THEN
-      WRITE(lunout, *)'conf_gcm: La valeur de grossismy passee par ', &
-              'run.def est differente de celle lue sur le fichier  start '
-      CALL abort_gcm("conf_gcm", "stopped", 1)
-    ENDIF
-
-    IF(grossismx<1.)  THEN
-      WRITE(lunout, *) &
-              'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
-      CALL abort_gcm("conf_gcm", "stopped", 1)
-    ELSE
-      alphax = 1. - 1. / grossismx
-    ENDIF
-
-    IF(grossismy<1.)  THEN
-      WRITE(lunout, *) &
-              'conf_gcm: ***  ATTENTION !! grossismy < 1 .   *** '
-      CALL abort_gcm("conf_gcm", "stopped", 1)
-    ELSE
-      alphay = 1. - 1. / grossismy
-    ENDIF
-
-    WRITE(lunout, *)'conf_gcm: alphax alphay', alphax, alphay
-
-    !    alphax et alphay sont les anciennes formulat. des grossissements
-
-    !Config  Key  = fxyhypb
-    !Config  Desc = Fonction  hyperbolique
-    !Config  Def  = y
-    !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
-    !Config         sinon  sinusoidale
-    fxyhypbb = .TRUE.
-    CALL getin('fxyhypb', fxyhypbb)
-
-    IF(.NOT.fxyhypb)  THEN
-      IF(fxyhypbb)     THEN
-        WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
-        WRITE(lunout, *)' *** fxyhypb lu sur le fichier start est ', &
-                'F alors  qu il est  T  sur  run.def  ***'
-        CALL abort_gcm("conf_gcm", "stopped", 1)
-      ENDIF
-    ELSE
-      IF(.NOT.fxyhypbb)   THEN
-        WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
-        WRITE(lunout, *)' ***  fxyhypb lu sur le fichier start est ', &
-                'T alors  qu il est  F  sur  run.def  ****  '
-        CALL abort_gcm("conf_gcm", "stopped", 1)
-      ENDIF
-    ENDIF
-
-    !Config  Key  = dzoomx
-    !Config  Desc = extension en longitude
-    !Config  Def  = 0
-    !Config  Help = extension en longitude  de la zone du zoom
-    !Config         ( fraction de la zone totale)
-    dzoomxx = 0.0
-    CALL getin('dzoomx', dzoomxx)
-
-    IF(fxyhypb)  THEN
-      IF(ABS(dzoomx - dzoomxx)>= 0.001)  THEN
-        WRITE(lunout, *)'conf_gcm: La valeur de dzoomx passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm", "stopped", 1)
-      ENDIF
-    ENDIF
-
-    !Config  Key  = dzoomy
-    !Config  Desc = extension en latitude
-    !Config  Def  = 0
-    !Config  Help = extension en latitude de la zone  du zoom
-    !Config         ( fraction de la zone totale)
-    dzoomyy = 0.0
-    CALL getin('dzoomy', dzoomyy)
-
-    IF(fxyhypb)  THEN
-      IF(ABS(dzoomy - dzoomyy)>= 0.001)  THEN
-        WRITE(lunout, *)'conf_gcm: La valeur de dzoomy passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm", "stopped", 1)
-      ENDIF
-    ENDIF
-
-    !Config  Key  = taux
-    !Config  Desc = raideur du zoom en  X
-    !Config  Def  = 3
-    !Config  Help = raideur du zoom en  X
-    tauxx = 3.0
-    CALL getin('taux', tauxx)
-
-    IF(fxyhypb)  THEN
-      IF(ABS(taux - tauxx)>= 0.001)  THEN
-        WRITE(lunout, *)'conf_gcm: La valeur de taux passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm", "stopped", 1)
-      ENDIF
-    ENDIF
-
-    !Config  Key  = tauyy
-    !Config  Desc = raideur du zoom en  Y
-    !Config  Def  = 3
-    !Config  Help = raideur du zoom en  Y
-    tauyy = 3.0
-    CALL getin('tauy', tauyy)
-
-    IF(fxyhypb)  THEN
-      IF(ABS(tauy - tauyy)>= 0.001)  THEN
-        WRITE(lunout, *)'conf_gcm: La valeur de tauy passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm", "stopped", 1)
-      ENDIF
-    ENDIF
-
-    !c
-    IF(.NOT.fxyhypb)  THEN
-
-      !Config  Key  = ysinus
-      !Config  IF   = !fxyhypb
-      !Config  Desc = Fonction en Sinus
-      !Config  Def  = y
-      !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
-      !Config         sinon y = latit.
-      ysinuss = .TRUE.
-      CALL getin('ysinus', ysinuss)
-
-      IF(.NOT.ysinus)  THEN
-        IF(ysinuss)     THEN
-          WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
-          WRITE(lunout, *)' *** ysinus lu sur le fichier start est F', &
-                  ' alors  qu il est  T  sur  run.def  ***'
-          CALL abort_gcm("conf_gcm", "stopped", 1)
-        ENDIF
-      ELSE
-        IF(.NOT.ysinuss)   THEN
-          WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
-          WRITE(lunout, *)' *** ysinus lu sur le fichier start est T', &
-                  ' alors  qu il est  F  sur  run.def  ****  '
-          CALL abort_gcm("conf_gcm", "stopped", 1)
-        ENDIF
-      ENDIF
-    ENDIF ! of IF( .NOT.fxyhypb  )
-
-    !Config  Key  = offline
-    !Config  Desc = Nouvelle eau liquide
-    !Config  Def  = n
-    !Config  Help = Permet de mettre en route la
-    !Config         nouvelle parametrisation de l'eau liquide !
-    offline = .FALSE.
-    CALL getin('offline', offline)
-
-    !Config  Key  = type_trac
-    !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
-    !Config  Def  = lmdz
-    !Config  Help =
-    !Config         'lmdz' = pas de couplage, pur LMDZ
-    !Config         'inca' = model de chime INCA
-    !Config         'repr' = model de chime REPROBUS
-    !Config         'inco' = INCA + CO2i (temporaire)
-    type_trac = 'lmdz'
-    CALL getin('type_trac', type_trac)
-
-
-    !Config  Key  = adv_qsat_liq
-    !Config  Desc = option for qsat calculation in the dynamics
-    !Config  Def  = n
-    !Config  Help = controls which phase is considered for qsat calculation
-    !Config
-    adv_qsat_liq = .FALSE.
-    CALL getin('adv_qsat_liq', adv_qsat_liq)
-
-    !Config  Key  = ok_dynzon
-    !Config  Desc = calcul et sortie des transports
-    !Config  Def  = n
-    !Config  Help = Permet de mettre en route le calcul des transports
-    !Config
-    ok_dynzon = .FALSE.
-    CALL getin('ok_dynzon', ok_dynzon)
-
-    !Config  Key  = ok_dyn_ins
-    !Config  Desc = sorties instantanees dans la dynamique
-    !Config  Def  = n
-    !Config  Help =
-    !Config
-    ok_dyn_ins = .FALSE.
-    CALL getin('ok_dyn_ins', ok_dyn_ins)
-
-    !Config  Key  = ok_dyn_ave
-    !Config  Desc = sorties moyennes dans la dynamique
-    !Config  Def  = n
-    !Config  Help =
-    !Config
-    ok_dyn_ave = .FALSE.
-    CALL getin('ok_dyn_ave', ok_dyn_ave)
-
-    WRITE(lunout, *)' #########################################'
-    WRITE(lunout, *)' Configuration des parametres du gcm: '
-    WRITE(lunout, *)' planet_type = ', planet_type
-    WRITE(lunout, *)' calend = ', calend
-    WRITE(lunout, *)' dayref = ', dayref
-    WRITE(lunout, *)' anneeref = ', anneeref
-    WRITE(lunout, *)' nday = ', nday
-    WRITE(lunout, *)' day_step = ', day_step
-    WRITE(lunout, *)' iperiod = ', iperiod
-    WRITE(lunout, *)' nsplit_phys = ', nsplit_phys
-    WRITE(lunout, *)' iconser = ', iconser
-    WRITE(lunout, *)' iecri = ', iecri
-    WRITE(lunout, *)' periodav = ', periodav
-    WRITE(lunout, *)' output_grads_dyn = ', output_grads_dyn
-    WRITE(lunout, *)' dissip_period = ', dissip_period
-    WRITE(lunout, *)' lstardis = ', lstardis
-    WRITE(lunout, *)' nitergdiv = ', nitergdiv
-    WRITE(lunout, *)' nitergrot = ', nitergrot
-    WRITE(lunout, *)' niterh = ', niterh
-    WRITE(lunout, *)' tetagdiv = ', tetagdiv
-    WRITE(lunout, *)' tetagrot = ', tetagrot
-    WRITE(lunout, *)' tetatemp = ', tetatemp
-    WRITE(lunout, *)' coefdis = ', coefdis
-    WRITE(lunout, *)' purmats = ', purmats
-    WRITE(lunout, *)' read_start = ', read_start
-    WRITE(lunout, *)' iflag_phys = ', iflag_phys
-    WRITE(lunout, *)' iphysiq = ', iphysiq
-    WRITE(lunout, *)' clonn = ', clonn
-    WRITE(lunout, *)' clatt = ', clatt
-    WRITE(lunout, *)' grossismx = ', grossismx
-    WRITE(lunout, *)' grossismy = ', grossismy
-    WRITE(lunout, *)' fxyhypbb = ', fxyhypbb
-    WRITE(lunout, *)' dzoomxx = ', dzoomxx
-    WRITE(lunout, *)' dzoomy = ', dzoomyy
-    WRITE(lunout, *)' tauxx = ', tauxx
-    WRITE(lunout, *)' tauyy = ', tauyy
-    WRITE(lunout, *)' offline = ', offline
-    WRITE(lunout, *)' type_trac = ', type_trac
-    WRITE(lunout, *)' ok_dynzon = ', ok_dynzon
-    WRITE(lunout, *)' ok_dyn_ins = ', ok_dyn_ins
-    WRITE(lunout, *)' ok_dyn_ave = ', ok_dyn_ave
-    WRITE(lunout, *)' adv_qsat_liq = ', adv_qsat_liq
-  ELSE
-    !Config  Key  = clon
-    !Config  Desc = centre du zoom, longitude
-    !Config  Def  = 0
-    !Config  Help = longitude en degres du centre
-    !Config         du zoom
-    clon = 0.
-    CALL getin('clon', clon)
-
-    !Config  Key  = clat
-    !Config  Desc = centre du zoom, latitude
-    !Config  Def  = 0
-    !Config  Help = latitude en degres du centre du zoom
-    !Config
-    clat = 0.
-    CALL getin('clat', clat)
-
-    !Config  Key  = grossismx
-    !Config  Desc = zoom en longitude
-    !Config  Def  = 1.0
-    !Config  Help = facteur de grossissement du zoom,
-    !Config         selon la longitude
-    grossismx = 1.0
-    CALL getin('grossismx', grossismx)
-
-    !Config  Key  = grossismy
-    !Config  Desc = zoom en latitude
-    !Config  Def  = 1.0
-    !Config  Help = facteur de grossissement du zoom,
-    !Config         selon la latitude
-    grossismy = 1.0
-    CALL getin('grossismy', grossismy)
-
-    IF(grossismx<1.)  THEN
-      WRITE(lunout, *) &
-              'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
-      CALL abort_gcm("conf_gcm", "stopped", 1)
-    ELSE
-      alphax = 1. - 1. / grossismx
-    ENDIF
-
-    IF(grossismy<1.)  THEN
-      WRITE(lunout, *) 'conf_gcm: ***ATTENTION !! grossismy < 1 . *** '
-      CALL abort_gcm("conf_gcm", "stopped", 1)
-    ELSE
-      alphay = 1. - 1. / grossismy
-    ENDIF
-
-    WRITE(lunout, *)'conf_gcm: alphax alphay ', alphax, alphay
-
-    !    alphax et alphay sont les anciennes formulat. des grossissements
-
-    !Config  Key  = fxyhypb
-    !Config  Desc = Fonction  hyperbolique
-    !Config  Def  = y
-    !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
-    !Config         sinon  sinusoidale
-    fxyhypb = .TRUE.
-    CALL getin('fxyhypb', fxyhypb)
-
-    !Config  Key  = dzoomx
-    !Config  Desc = extension en longitude
-    !Config  Def  = 0
-    !Config  Help = extension en longitude  de la zone du zoom
-    !Config         ( fraction de la zone totale)
-    dzoomx = 0.2
-    CALL getin('dzoomx', dzoomx)
-    CALL assert(dzoomx < 1, "conf_gcm: dzoomx must be < 1")
-
-    !Config  Key  = dzoomy
-    !Config  Desc = extension en latitude
-    !Config  Def  = 0
-    !Config  Help = extension en latitude de la zone  du zoom
-    !Config         ( fraction de la zone totale)
-    dzoomy = 0.2
-    CALL getin('dzoomy', dzoomy)
-    CALL assert(dzoomy < 1, "conf_gcm: dzoomy must be < 1")
-
-    !Config  Key  = taux
-    !Config  Desc = raideur du zoom en  X
-    !Config  Def  = 3
-    !Config  Help = raideur du zoom en  X
-    taux = 3.0
-    CALL getin('taux', taux)
-
-    !Config  Key  = tauy
-    !Config  Desc = raideur du zoom en  Y
-    !Config  Def  = 3
-    !Config  Help = raideur du zoom en  Y
-    tauy = 3.0
-    CALL getin('tauy', tauy)
-
-    !Config  Key  = ysinus
-    !Config  IF   = !fxyhypb
-    !Config  Desc = Fonction en Sinus
-    !Config  Def  = y
-    !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
-    !Config         sinon y = latit.
-    ysinus = .TRUE.
-    CALL getin('ysinus', ysinus)
-
-    !Config  Key  = offline
-    !Config  Desc = Nouvelle eau liquide
-    !Config  Def  = n
-    !Config  Help = Permet de mettre en route la
-    !Config         nouvelle parametrisation de l'eau liquide !
-    offline = .FALSE.
-    CALL getin('offline', offline)
-
-    !Config  Key  = type_trac
-    !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
-    !Config  Def  = lmdz
-    !Config  Help =
-    !Config         'lmdz' = pas de couplage, pur LMDZ
-    !Config         'inca' = model de chime INCA
-    !Config         'repr' = model de chime REPROBUS
-    !Config         'inco' = INCA + CO2i (temporaire)
-    type_trac = 'lmdz'
-    CALL getin('type_trac', type_trac)
-
-    !Config  Key  = ok_dynzon
-    !Config  Desc = sortie des transports zonaux dans la dynamique
-    !Config  Def  = n
-    !Config  Help = Permet de mettre en route le calcul des transports
-    !Config
-    ok_dynzon = .FALSE.
-    CALL getin('ok_dynzon', ok_dynzon)
-
-    !Config  Key  = ok_dyn_ins
-    !Config  Desc = sorties instantanees dans la dynamique
-    !Config  Def  = n
-    !Config  Help =
-    !Config
-    ok_dyn_ins = .FALSE.
-    CALL getin('ok_dyn_ins', ok_dyn_ins)
-
-    !Config  Key  = ok_dyn_ave
-    !Config  Desc = sorties moyennes dans la dynamique
-    !Config  Def  = n
-    !Config  Help =
-    !Config
-    ok_dyn_ave = .FALSE.
-    CALL getin('ok_dyn_ave', ok_dyn_ave)
-
-    !Config key = ok_strato
-    !Config  Desc = activation de la version strato
-    !Config  Def  = .FALSE.
-    !Config  Help = active la version stratosph\'erique de LMDZ de F. Lott
-
-    ok_strato = .FALSE.
-    CALL getin('ok_strato', ok_strato)
-
-    vert_prof_dissip = merge(1, 0, ok_strato .AND. llm==39)
-    CALL getin('vert_prof_dissip', vert_prof_dissip)
-    CALL assert(vert_prof_dissip == 0 .OR. vert_prof_dissip ==  1, &
-            "bad value for vert_prof_dissip")
-
-    !Config  Key  = ok_gradsfile
-    !Config  Desc = activation des sorties grads du guidage
-    !Config  Def  = n
-    !Config  Help = active les sorties grads du guidage
-
-    ok_gradsfile = .FALSE.
-    CALL getin('ok_gradsfile', ok_gradsfile)
-
-    !Config  Key  = ok_limit
-    !Config  Desc = creation des fichiers limit dans create_etat0_limit
-    !Config  Def  = y
-    !Config  Help = production du fichier limit.nc requise
-
-    ok_limit = .TRUE.
-    CALL getin('ok_limit', ok_limit)
-
-    !Config  Key  = ok_etat0
-    !Config  Desc = creation des fichiers etat0 dans create_etat0_limit
-    !Config  Def  = y
-    !Config  Help = production des fichiers start.nc, startphy.nc requise
-
-    ok_etat0 = .TRUE.
-    CALL getin('ok_etat0', ok_etat0)
-
-    !Config  Key  = read_orop
-    !Config  Desc = lecture du fichier de params orographiques sous maille
-    !Config  Def  = f
-    !Config  Help = lecture fichier plutot que grid_noro
-
-    read_orop = .FALSE.
-    CALL getin('read_orop', read_orop)
-
-    WRITE(lunout, *)' #########################################'
-    WRITE(lunout, *)' Configuration des parametres de cel0_limit: '
-    WRITE(lunout, *)' planet_type = ', planet_type
-    WRITE(lunout, *)' calend = ', calend
-    WRITE(lunout, *)' dayref = ', dayref
-    WRITE(lunout, *)' anneeref = ', anneeref
-    WRITE(lunout, *)' nday = ', nday
-    WRITE(lunout, *)' day_step = ', day_step
-    WRITE(lunout, *)' iperiod = ', iperiod
-    WRITE(lunout, *)' iconser = ', iconser
-    WRITE(lunout, *)' iecri = ', iecri
-    WRITE(lunout, *)' periodav = ', periodav
-    WRITE(lunout, *)' output_grads_dyn = ', output_grads_dyn
-    WRITE(lunout, *)' dissip_period = ', dissip_period
-    WRITE(lunout, *)' lstardis = ', lstardis
-    WRITE(lunout, *)' nitergdiv = ', nitergdiv
-    WRITE(lunout, *)' nitergrot = ', nitergrot
-    WRITE(lunout, *)' niterh = ', niterh
-    WRITE(lunout, *)' tetagdiv = ', tetagdiv
-    WRITE(lunout, *)' tetagrot = ', tetagrot
-    WRITE(lunout, *)' tetatemp = ', tetatemp
-    WRITE(lunout, *)' coefdis = ', coefdis
-    WRITE(lunout, *)' purmats = ', purmats
-    WRITE(lunout, *)' read_start = ', read_start
-    WRITE(lunout, *)' iflag_phys = ', iflag_phys
-    WRITE(lunout, *)' iphysiq = ', iphysiq
-    WRITE(lunout, *)' clon = ', clon
-    WRITE(lunout, *)' clat = ', clat
-    WRITE(lunout, *)' grossismx = ', grossismx
-    WRITE(lunout, *)' grossismy = ', grossismy
-    WRITE(lunout, *)' fxyhypb = ', fxyhypb
-    WRITE(lunout, *)' dzoomx = ', dzoomx
-    WRITE(lunout, *)' dzoomy = ', dzoomy
-    WRITE(lunout, *)' taux = ', taux
-    WRITE(lunout, *)' tauy = ', tauy
-    WRITE(lunout, *)' offline = ', offline
-    WRITE(lunout, *)' type_trac = ', type_trac
-    WRITE(lunout, *)' ok_dynzon = ', ok_dynzon
-    WRITE(lunout, *)' ok_dyn_ins = ', ok_dyn_ins
-    WRITE(lunout, *)' ok_dyn_ave = ', ok_dyn_ave
-    WRITE(lunout, *)' ok_strato = ', ok_strato
-    WRITE(lunout, *)' ok_gradsfile = ', ok_gradsfile
-    WRITE(lunout, *)' ok_limit = ', ok_limit
-    WRITE(lunout, *)' ok_etat0 = ', ok_etat0
-    WRITE(lunout, *)' ok_guide = ', ok_guide
-    WRITE(lunout, *)' read_orop = ', read_orop
-  ENDIF test_etatinit
-
-END SUBROUTINE conf_gcm
Index: DZ6/branches/Amaury_dev/libf/dyn3d/covnat.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/covnat.F90	(revision 5185)
+++ 	(revision )
@@ -1,50 +1,0 @@
-! $Header$
-
-SUBROUTINE covnat(klevel, ucov, vcov, unat, vnat)
-  USE lmdz_comgeom
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  !=======================================================================
-
-  !   Auteur:  F Hourdin Phu LeVan
-  !   -------
-
-  !   Objet:
-  !   ------
-
-  !  *********************************************************************
-  !    calcul des compos. naturelles a partir des comp.covariantes
-  !  ********************************************************************
-
-  !=======================================================================
-
-
-
-
-  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
-
-END SUBROUTINE covnat
Index: DZ6/branches/Amaury_dev/libf/dyn3d/dissip.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/dissip.F90	(revision 5185)
+++ 	(revision )
@@ -1,145 +1,0 @@
-! $Id$
-
-SUBROUTINE dissip(vcov, ucov, teta, p, dv, du, dh)
-  USE comconst_mod, ONLY: dtdiss
-  USE lmdz_comdissipn, ONLY: tetaudiv, tetaurot, tetah, cdivu, crot, cdivh
-  USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
-          tetagrot, tetatemp, coefdis, vert_prof_dissip
-  USE lmdz_comgeom
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-
-  ! ..  Avec nouveaux operateurs star :  gradiv2 , divgrad2, nxgraro2  ...
-  ! (  10/01/98  )
-
-  !=======================================================================
-
-  !   Auteur:  P. Le Van
-  !   -------
-
-  !   Objet:
-  !   ------
-
-  !   Dissipation horizontale
-
-  !=======================================================================
-  !-----------------------------------------------------------------------
-  !   Declarations:
-  !   -------------
-
-
-
-
-  !   Arguments:
-  !   ----------
-
-  REAL, INTENT(IN) :: vcov(ip1jm, llm) ! covariant meridional wind
-  REAL, INTENT(IN) :: ucov(ip1jmp1, llm) ! covariant zonal wind
-  REAL, INTENT(IN) :: teta(ip1jmp1, llm) ! potential temperature
-  REAL, INTENT(IN) :: p(ip1jmp1, llmp1) ! pressure
-  ! tendencies (.../s) on covariant winds and potential temperature
-  REAL, INTENT(OUT) :: dv(ip1jm, llm)
-  REAL, INTENT(OUT) :: du(ip1jmp1, llm)
-  REAL, INTENT(OUT) :: dh(ip1jmp1, llm)
-
-  !   Local:
-  !   ------
-
-  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
-
-  !-----------------------------------------------------------------------
-  !   initialisations:
-  !   ----------------
-
-  DO l = 1, llm
-    te1dt(l) = tetaudiv(l) * dtdiss
-    te2dt(l) = tetaurot(l) * dtdiss
-    te3dt(l) = tetah(l) * dtdiss
-  ENDDO
-  du = 0.
-  dv = 0.
-  dh = 0.
-
-  !-----------------------------------------------------------------------
-  !   Calcul de la dissipation:
-  !   -------------------------
-
-  !   Calcul de la partie   grad  ( div ) :
-  !   -------------------------------------
-
-  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
-
-  !   calcul de la partie   n X grad ( rot ):
-  !   ---------------------------------------
-
-  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
-
-  !   calcul de la partie   div ( grad ):
-  !   -----------------------------------
-
-  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
-
-
-END SUBROUTINE dissip
Index: DZ6/branches/Amaury_dev/libf/dyn3d/dteta1.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/dteta1.F90	(revision 5185)
+++ 	(revision )
@@ -1,66 +1,0 @@
-! $Header$
-
-SUBROUTINE dteta1(teta, pbaru, pbarv, dteta)
-  USE lmdz_filtreg, ONLY: filtreg
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  !=======================================================================
-
-  !   Auteur:  P. Le Van
-  !   -------
-  ! Modif F.Forget 03/94 (on retire q et dq  pour construire dteta1)
-
-  !   ********************************************************************
-  !   ... calcul du terme de convergence horizontale du flux d'enthalpie
-  !    potentielle   ......
-  !   ********************************************************************
-  !  .. teta,pbaru et pbarv sont des arguments d'entree  pour le s-pg ....
-  ! dteta               sont des arguments de sortie pour le s-pg ....
-
-  !=======================================================================
-
-
-
-
-  REAL :: teta(ip1jmp1, llm), pbaru(ip1jmp1, llm), pbarv(ip1jm, llm)
-  REAL :: dteta(ip1jmp1, llm)
-  INTEGER :: l, ij
-
-  REAL :: hbyv(ip1jm, llm), hbxu(ip1jmp1, llm)
-
-  !
-
-  DO l = 1, llm
-
-    DO ij = iip2, ip1jm - 1
-      hbxu(ij, l) = pbaru(ij, l) * 0.5 * (teta(ij, l) + teta(ij + 1, l))
-    END DO
-
-    !    .... correction pour  hbxu(iip1,j,l)  .....
-    !    ....   hbxu(iip1,j,l)= hbxu(1,j,l) ....
-
-    !DIR$ IVDEP
-    DO ij = iip1 + iip1, ip1jm, iip1
-      hbxu(ij, l) = hbxu(ij - iim, l)
-    END DO
-
-    DO ij = 1, ip1jm
-      hbyv(ij, l) = pbarv(ij, l) * 0.5 * (teta(ij, l) + teta(ij + iip1, l))
-    END DO
-
-  END DO
-
-  CALL  convflu (hbxu, hbyv, llm, dteta)
-
-
-  !    stockage dans  dh de la convergence horizont. filtree' du  flux
-  ! ....                           ...........
-  ! d'enthalpie potentielle .
-
-  CALL filtreg(dteta, jjp1, llm, 2, 2, .TRUE., 1)
-
-  !
-
-END SUBROUTINE dteta1
Index: DZ6/branches/Amaury_dev/libf/dyn3d/dudv1.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/dudv1.F90	(revision 5185)
+++ 	(revision )
@@ -1,54 +1,0 @@
-! $Header$
-
-SUBROUTINE dudv1(vorpot, pbaru, pbarv, du, dv)
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  !-----------------------------------------------------------------------
-
-  !   Auteur:   P. Le Van
-  !   -------
-
-  !   Objet:
-  !   ------
-  !   calcul du terme de  rotation
-  !   ce terme est ajoute a  d(ucov)/dt et a d(vcov)/dt  ..
-  !   vorpot, pbaru et pbarv sont des arguments d'entree  pour le s-pg ..
-  !   du  et dv              sont des arguments de sortie pour le s-pg ..
-
-  !-----------------------------------------------------------------------
-
-
-
-
-  REAL :: vorpot(ip1jm, llm), pbaru(ip1jmp1, llm), &
-          pbarv(ip1jm, llm), du(ip1jmp1, llm), dv(ip1jm, llm)
-  INTEGER :: l, ij
-
-
-  DO l = 1, llm
-
-    DO 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))
-    END DO
-
-    DO 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))
-    END DO
-
-    !    .... correction  pour  dv( 1,j,l )  .....
-    !    ....   dv(1,j,l)= dv(iip1,j,l) ....
-
-    !DIR$ IVDEP
-    DO ij = 1, ip1jm, iip1
-      dv(ij, l) = dv(ij + iim, l)
-    END DO
-
-  END DO
-
-END SUBROUTINE dudv1
Index: DZ6/branches/Amaury_dev/libf/dyn3d/dudv2.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/dudv2.F90	(revision 5185)
+++ 	(revision )
@@ -1,63 +1,0 @@
-! $Header$
-
-SUBROUTINE dudv2(teta, pkf, bern, du, dv)
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  !=======================================================================
-
-  !   Auteur:  P. Le Van
-  !   -------
-
-  !   Objet:
-  !   ------
-
-  !   *****************************************************************
-  !   ..... calcul du terme de pression (gradient de p/densite )   et
-  !      du terme de ( -gradient de la fonction de Bernouilli ) ...
-  !   *****************************************************************
-  !      Ces termes sont ajoutes a  d(ucov)/dt et a d(vcov)/dt  ..
-
-
-  !    teta , pkf, bern  sont des arguments d'entree  pour le s-pg  ....
-  !    du et dv          sont des arguments de sortie pour le s-pg  ....
-
-  !=======================================================================
-  !
-
-
-
-  REAL :: teta(ip1jmp1, llm), pkf(ip1jmp1, llm), bern(ip1jmp1, llm), &
-          du(ip1jmp1, llm), dv(ip1jm, llm)
-  INTEGER :: l, ij
-
-
-  DO l = 1, llm
-
-    DO 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)
-    END DO
-
-
-    !    .....  correction  pour du(iip1,j,l),  j=2,jjm   ......
-    !    ...          du(iip1,j,l) = du(1,j,l)                 ...
-
-    !DIR$ IVDEP
-    DO ij = iip1 + iip1, ip1jm, iip1
-      du(ij, l) = du(ij - iim, l)
-    END DO
-
-
-    DO 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)
-    END DO
-
-  END DO
-  !
-
-END SUBROUTINE dudv2
Index: DZ6/branches/Amaury_dev/libf/dyn3d/dynredem.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/dynredem.F90	(revision 5185)
+++ 	(revision )
@@ -1,246 +1,0 @@
-SUBROUTINE dynredem0(fichnom, iday_end, phis)
-
-  !-------------------------------------------------------------------------------
-  ! Write the NetCDF restart file (initialization).
-  !-------------------------------------------------------------------------------
-  USE IOIPSL
-  USE lmdz_strings, ONLY: maxlen
-  USE lmdz_infotrac, ONLY: nqtot, tracers
-  USE netcdf, ONLY: nf90_create, nf90_def_dim, nf90_inq_varid, nf90_global, &
-          nf90_close, nf90_put_att, nf90_unlimited, nf90_clobber, &
-          nf90_64bit_offset
-  USE dynredem_mod, ONLY: cre_var, put_var1, put_var2, err, modname, fil
-  USE comvert_mod, ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs
-  USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad
-  USE logic_mod, ONLY: fxyhypb, ysinus
-  USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, &
-          taux, tauy
-  USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itaufin, start_time
-  USE ener_mod, ONLY: etot0, ptot0, ztot0, stot0, ang0
-  USE lmdz_description, ONLY: descript
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comgeom2
-
-USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-
-  !===============================================================================
-  ! Arguments:
-  CHARACTER(LEN = *), INTENT(IN) :: fichnom          !--- FILE NAME
-  INTEGER, INTENT(IN) :: iday_end         !---
-  REAL, INTENT(IN) :: phis(iip1, jjp1) !--- GROUND GEOPOTENTIAL
-  !===============================================================================
-  ! Local variables:
-  INTEGER :: iq
-  INTEGER, PARAMETER :: length = 100
-  REAL :: tab_cntrl(length)                     !--- RUN PARAMETERS TABLE
-  !   For NetCDF:
-  CHARACTER(LEN = maxlen) :: unites
-  INTEGER :: indexID
-  INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID
-  INTEGER :: sID, sigID, nID, timID
-  INTEGER :: yyears0, jjour0, mmois0
-  REAL :: zjulian, hours
-  !===============================================================================
-  modname = 'dynredem0'; fil = fichnom
-  CALL ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian)
-  CALL ju2ymds(zjulian, yyears0, mmois0, jjour0, hours)
-
-  tab_cntrl(:) = 0.
-  tab_cntrl(1) = REAL(iim)
-  tab_cntrl(2) = REAL(jjm)
-  tab_cntrl(3) = REAL(llm)
-  tab_cntrl(4) = REAL(day_ref)
-  tab_cntrl(5) = REAL(annee_ref)
-  tab_cntrl(6) = rad
-  tab_cntrl(7) = omeg
-  tab_cntrl(8) = g
-  tab_cntrl(9) = cpp
-  tab_cntrl(10) = kappa
-  tab_cntrl(11) = daysec
-  tab_cntrl(12) = dtvr
-  tab_cntrl(13) = etot0
-  tab_cntrl(14) = ptot0
-  tab_cntrl(15) = ztot0
-  tab_cntrl(16) = stot0
-  tab_cntrl(17) = ang0
-  tab_cntrl(18) = pa
-  tab_cntrl(19) = preff
-
-  !    .....    parameters for zoom    ......
-  tab_cntrl(20) = clon
-  tab_cntrl(21) = clat
-  tab_cntrl(22) = grossismx
-  tab_cntrl(23) = grossismy
-
-  IF (fxyhypb)   THEN
-    tab_cntrl(24) = 1.
-    tab_cntrl(25) = dzoomx
-    tab_cntrl(26) = dzoomy
-    tab_cntrl(27) = 0.
-    tab_cntrl(28) = taux
-    tab_cntrl(29) = tauy
-  ELSE
-    tab_cntrl(24) = 0.
-    tab_cntrl(25) = dzoomx
-    tab_cntrl(26) = dzoomy
-    tab_cntrl(27) = 0.
-    tab_cntrl(28) = 0.
-    tab_cntrl(29) = 0.
-    IF(ysinus)  tab_cntrl(27) = 1.
-  END IF
-  tab_cntrl(30) = REAL(iday_end)
-  tab_cntrl(31) = REAL(itau_dyn + itaufin)
-  ! start_time: start_time of simulation (not necessarily 0.)
-  tab_cntrl(32) = start_time
-
-  !--- File creation
-  CALL err(nf90_create(fichnom, IOR(nf90_clobber, nf90_64bit_offset), nid))
-
-  !--- Some global attributes
-  CALL err(nf90_put_att(nid, nf90_global, "title", "Fichier demarrage dynamique"))
-
-  !--- Dimensions
-  CALL err(nf90_def_dim(nid, "index", length, indexID))
-  CALL err(nf90_def_dim(nid, "rlonu", iip1, rlonuID))
-  CALL err(nf90_def_dim(nid, "rlatu", jjp1, rlatuID))
-  CALL err(nf90_def_dim(nid, "rlonv", iip1, rlonvID))
-  CALL err(nf90_def_dim(nid, "rlatv", jjm, rlatvID))
-  CALL err(nf90_def_dim(nid, "sigs", llm, sID))
-  CALL err(nf90_def_dim(nid, "sig", llmp1, sigID))
-  CALL err(nf90_def_dim(nid, "temps", nf90_unlimited, timID))
-
-  !--- Define and save invariant fields
-  CALL put_var1(nid, "controle", "Parametres de controle", [indexID], tab_cntrl)
-  CALL put_var1(nid, "rlonu", "Longitudes des points U", [rlonuID], rlonu)
-  CALL put_var1(nid, "rlatu", "Latitudes des points U", [rlatuID], rlatu)
-  CALL put_var1(nid, "rlonv", "Longitudes des points V", [rlonvID], rlonv)
-  CALL put_var1(nid, "rlatv", "Latitudes des points V", [rlatvID], rlatv)
-  CALL put_var1(nid, "nivsigs", "Numero naturel des couches s", [sID], nivsigs)
-  CALL put_var1(nid, "nivsig", "Numero naturel des couches sigma", [sigID], nivsig)
-  CALL put_var1(nid, "ap", "Coefficient A pour hybride", [sigID], ap)
-  CALL put_var1(nid, "bp", "Coefficient B pour hybride", [sigID], bp)
-  CALL put_var1(nid, "presnivs", "", [sID], presnivs)
-  ! covariant <-> contravariant <-> natural conversion coefficients
-  CALL put_var2(nid, "cu", "Coefficient de passage pour U", [rlonuID, rlatuID], cu)
-  CALL put_var2(nid, "cv", "Coefficient de passage pour V", [rlonvID, rlatvID], cv)
-  CALL put_var2(nid, "aire", "Aires de chaque maille", [rlonvID, rlatuID], aire)
-  CALL put_var2(nid, "phisinit", "Geopotentiel au sol", [rlonvID, rlatuID], phis)
-
-  !--- Define fields saved later
-  WRITE(unites, "('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") &
-          yyears0, mmois0, jjour0
-  CALL cre_var(nid, "temps", "Temps de simulation", [timID], unites)
-  CALL cre_var(nid, "ucov", "Vitesse U", [rlonuID, rlatuID, sID, timID])
-  CALL cre_var(nid, "vcov", "Vitesse V", [rlonvID, rlatvID, sID, timID])
-  CALL cre_var(nid, "teta", "Temperature", [rlonvID, rlatuID, sID, timID])
-  DO iq = 1, nqtot
-    CALL cre_var(nid, tracers(iq)%name, tracers(iq)%longName, [rlonvID, rlatuID, sID, timID])
-  END DO
-  CALL cre_var(nid, "masse", "Masse d air", [rlonvID, rlatuID, sID, timID])
-  CALL cre_var(nid, "ps", "Pression au sol", [rlonvID, rlatuID, timID])
-  CALL err(nf90_close (nid))
-
-  WRITE(lunout, *)TRIM(modname) // ': iim,jjm,llm,iday_end', iim, jjm, llm, iday_end
-  WRITE(lunout, *)TRIM(modname) // ': rad,omeg,g,cpp,kappa', rad, omeg, g, cpp, kappa
-
-END SUBROUTINE dynredem0
-
-!-------------------------------------------------------------------------------
-
-
-!-------------------------------------------------------------------------------
-
-SUBROUTINE dynredem1(fichnom, time, vcov, ucov, teta, q, masse, ps)
-
-  !-------------------------------------------------------------------------------
-  ! Purpose: Write the NetCDF restart file (append).
-  !-------------------------------------------------------------------------------
-  USE lmdz_strings, ONLY: maxlen
-  USE lmdz_infotrac, ONLY: nqtot, tracers, type_trac
-  USE control_mod
-  USE netcdf, ONLY: nf90_open, nf90_nowrite, nf90_get_var, nf90_inq_varid, &
-          nf90_close, nf90_write, nf90_put_var, nf90_noerr
-  USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, &
-          err, modname, fil, msg
-  USE temps_mod, ONLY: itau_dyn, itaufin
-  USE lmdz_description, ONLY: descript
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comgeom
-
-USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-
-  !===============================================================================
-  ! Arguments:
-  CHARACTER(LEN = *), INTENT(IN) :: fichnom              !-- FILE NAME
-  REAL, INTENT(IN) :: time                         !-- TIME
-  REAL, INTENT(IN) :: vcov(iip1, jjm, llm)          !-- V COVARIANT WIND
-  REAL, INTENT(IN) :: ucov(iip1, jjp1, llm)          !-- U COVARIANT WIND
-  REAL, INTENT(IN) :: teta(iip1, jjp1, llm)          !-- POTENTIAL TEMPERATURE
-  REAL, INTENT(INOUT) :: q(iip1, jjp1, llm, nqtot)    !-- TRACERS
-  REAL, INTENT(IN) :: masse(iip1, jjp1, llm)          !-- MASS PER CELL
-  REAL, INTENT(IN) :: ps(iip1, jjp1)              !-- GROUND PRESSURE
-  !===============================================================================
-  ! Local variables:
-  INTEGER :: iq, nid, vID, ierr, nid_trac, vID_trac
-  INTEGER, SAVE :: nb = 0
-  INTEGER, PARAMETER :: length = 100
-  REAL :: tab_cntrl(length) ! tableau des parametres du run
-  CHARACTER(LEN = maxlen) :: var, dum
-  LOGICAL :: lread_inca
-  !===============================================================================
-
-  modname = 'dynredem1'; fil = fichnom
-  CALL err(nf90_open(fil, nf90_write, nid), "open", fil)
-
-  !--- Write/extend time coordinate
-  nb = nb + 1
-  var = "temps"
-  CALL err(nf90_inq_varid(nid, var, vID), "inq", var)
-  CALL err(nf90_put_var(nid, vID, [time]), "put", var)
-  WRITE(lunout, *)TRIM(modname) // ": Saving for ", nb, time
-
-  !--- Rewrite control table (itaufin undefined in dynredem0)
-  var = "controle"
-  CALL err(nf90_inq_varid(nid, var, vID), "inq", var)
-  CALL err(nf90_get_var(nid, vID, tab_cntrl), "get", var)
-  tab_cntrl(31) = DBLE(itau_dyn + itaufin)
-  CALL err(nf90_inq_varid(nid, var, vID), "inq", var)
-  CALL err(nf90_put_var(nid, vID, tab_cntrl), "put", var)
-
-  !--- Save fields
-  CALL dynredem_write_u(nid, "ucov", ucov, llm)
-  CALL dynredem_write_v(nid, "vcov", vcov, llm)
-  CALL dynredem_write_u(nid, "teta", teta, llm)
-  CALL dynredem_write_u(nid, "masse", masse, llm)
-  CALL dynredem_write_u(nid, "ps", ps, 1)
-
-  !--- Tracers in file "start_trac.nc" (added by Anne)
-  lread_inca = .FALSE.; fil = "start_trac.nc"
-  IF(ANY(type_trac == ['inca', 'inco'])) INQUIRE(FILE = fil, EXIST = lread_inca)
-  IF(lread_inca) CALL err(nf90_open(fil, nf90_nowrite, nid_trac), "open")
-
-  !--- Save tracers
-  DO iq = 1, nqtot; var = TRIM(tracers(iq)%name); ierr = -1
-  IF(lread_inca) THEN                  !--- Possibly read from "start_trac.nc"
-    fil = "start_trac.nc"
-    ierr = nf90_inq_varid(nid_trac, var, vID_trac)
-    dum = 'inq'; IF(ierr==nf90_noerr) dum = 'fnd'
-    WRITE(lunout, *)msg(dum, var)
-
-    IF(ierr==nf90_noerr) CALL dynredem_read_u(nid_trac, var, q(:, :, :, iq), llm)
-  END IF
-  fil = fichnom
-  CALL dynredem_write_u(nid, var, q(:, :, :, iq), llm)
-  END DO
-  CALL err(nf90_close(nid), "close")
-  fil = "start_trac.nc"
-  IF(lread_inca) CALL err(nf90_close(nid_trac), "close")
-
-END SUBROUTINE dynredem1
-
Index: DZ6/branches/Amaury_dev/libf/dyn3d/gcm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.F90	(revision 5185)
+++ 	(revision )
@@ -1,440 +1,0 @@
-! $Id$
-
-
-
-PROGRAM gcm
-
-  USE IOIPSL
-  USE lmdz_wxios  ! ug Pour les sorties XIOS
-
-  USE lmdz_filtreg, ONLY: inifilr
-  USE lmdz_infotrac, ONLY: nqtot, init_infotrac
-  USE control_mod
-  USE mod_const_mpi, ONLY: COMM_LMDZ
-  USE temps_mod, ONLY: calend, start_time, annee_ref, day_ref, &
-          itau_dyn, itau_phy, day_ini, jD_ref, jH_ref, day_end
-  USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, r, rad
-  USE logic_mod, ONLY: ecripar, iflag_phys, read_start
-
-  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
-  USE lmdz_description, ONLY: descript
-  USE lmdz_dynetat0, ONLY: dynetat0
-
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
-  ! A nettoyer. On ne veut qu'une ou deux routines d'interface 
-  ! dynamique -> physique pour l'initialisation
-  ! AB 2024/07/20: remplace CPP key by fortran logical, but ^ still relevant, see later use of iniphys later on
-  USE iniphysiq_mod, ONLY: iniphysiq
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
-          tetagrot, tetatemp, coefdis, vert_prof_dissip
-  USE lmdz_comgeom
-  USE lmdz_tracstoke
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  !      ......   Version  du 10/01/98    ..........
-
-  !             avec  coordonnees  verticales hybrides
-  !   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
-
-  !=======================================================================
-
-  !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
-  !   -------
-
-  !   Objet:
-  !   ------
-
-  !   GCM LMD nouvelle grille
-
-  !=======================================================================
-
-  !  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
-  !      et possibilite d'appeler une fonction f(y)  a derivee tangente
-  !      hyperbolique a la  place de la fonction a derivee sinusoidale.
-  !  ... Possibilite de choisir le schema pour l'advection de
-  !        q  , en modifiant iadv dans traceur.def  (MAF,10/02) .
-
-  !      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
-  !      Pour Van-Leer iadv=10
-
-  !-----------------------------------------------------------------------
-  !   Declarations:
-  !   -------------
-
-
-
-
-  REAL zdtvr
-
-  !   variables dynamiques
-  REAL vcov(ip1jm, llm), ucov(ip1jmp1, llm) ! vents covariants
-  REAL teta(ip1jmp1, llm)                 ! temperature potentielle
-  REAL, ALLOCATABLE, DIMENSION(:, :, :) :: q! champs advectes
-  REAL ps(ip1jmp1)                       ! pression  au sol
-  !  REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.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
-
-  ! variables dynamiques intermediaire pour le transport
-
-  !   variables pour le fichier histoire
-  REAL dtav      ! intervalle de temps elementaire
-
-  REAL time_0
-
-  LOGICAL lafin
-
-  REAL time_step, t_wrt, t_ops
-
-  !      LOGICAL call_iniphys
-  !      data call_iniphys/.TRUE./
-
-  !+jld variables test conservation energie
-  !      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
-  !     Tendance de la temp. potentiel d (theta)/ d t due a la 
-  !     tansformation d'energie cinetique en energie thermique
-  !     cree par la dissipation
-  !  REAL dhecdt(ip1jmp1,llm)
-  !      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
-  !      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
-  !  CHARACTER (len=15) :: ztit
-  !-jld 
-
-  CHARACTER (LEN = 80) :: dynhist_file, dynhistave_file
-  CHARACTER (LEN = 20) :: modname
-  CHARACTER (LEN = 80) :: abort_message
-  ! locales pour gestion du temps
-  INTEGER :: an, mois, jour
-  REAL :: heure
-  LOGICAL use_filtre_fft
-
-  !-----------------------------------------------------------------------
-  !   Initialisations:
-  !   ----------------
-
-  abort_message = 'last timestep reached'
-  modname = 'gcm'
-  descript = 'Run GCM LMDZ'
-  lafin = .FALSE.
-  dynhist_file = 'dyn_hist.nc'
-  dynhistave_file = 'dyn_hist_ave.nc'
-
-
-
-  !----------------------------------------------------------------------
-  !  lecture des fichiers gcm.def ou run.def
-  !  ---------------------------------------
-
-  CALL conf_gcm(99, .TRUE.)
-
-  IF (mod(iphysiq, iperiod) /= 0) CALL abort_gcm("conf_gcm", &
-          "iphysiq must be a multiple of iperiod", 1)
-
-  use_filtre_fft = .FALSE.
-  CALL getin('use_filtre_fft', use_filtre_fft)
-  IF (use_filtre_fft) CALL abort_gcm("gcm", 'FFT filter is not available in ' &
-          // 'the sequential version of the dynamics.', 1)
-
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  ! Initialisation de XIOS
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-  IF (using_xios) THEN
-    CALL wxios_init("LMDZ")
-  ENDIF
-
-
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  ! FH 2008/05/02
-  ! A nettoyer. On ne veut qu'une ou deux routines d'interface 
-  ! dynamique -> physique pour l'initialisation
-  !#ifdef CPP_PHYS
-  !  CALL Init_Phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/))
-  !  !      CALL InitComgeomphy ! now done in iniphysiq
-  !#endif
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  !-----------------------------------------------------------------------
-  !   Choix du calendrier
-  !   -------------------
-
-  !      calend = 'earth_365d'
-
-  IF (calend == 'earth_360d') THEN
-    CALL ioconf_calendar('360_day')
-    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
-  ELSE IF (calend == 'earth_365d') THEN
-    CALL ioconf_calendar('noleap')
-    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
-  ELSE IF (calend == 'gregorian') THEN
-    CALL ioconf_calendar('gregorian')
-    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre bissextile'
-  else
-    abort_message = 'Mauvais choix de calendrier'
-    CALL abort_gcm(modname, abort_message, 1)
-  ENDIF
-  !-----------------------------------------------------------------------
-
-
-  !------------------------------------
-  !   Initialisation partie parallele
-  !------------------------------------
-
-
-  !-----------------------------------------------------------------------
-  !   Initialisation des traceurs
-  !   ---------------------------
-  !  Choix du nombre de traceurs et du schema pour l'advection
-  !  dans fichier traceur.def, par default ou via INCA
-  CALL init_infotrac
-
-  ! Allocation de la tableau q : champs advectes   
-  allocate(q(ip1jmp1, llm, nqtot))
-
-  !-----------------------------------------------------------------------
-  !   Lecture de l'etat initial :
-  !   ---------------------------
-
-  !  lecture du fichier start.nc
-  IF (read_start) THEN
-    ! we still need to run iniacademic to initialize some
-    ! constants & fields, if we run the 'newtonian' or 'SW' cases:
-    IF (iflag_phys/=1) THEN
-      CALL iniacademic(vcov, ucov, teta, q, masse, ps, phis, time_0)
-    endif
-
-    !        if (planet_type.EQ."earth") THEN
-    ! Load an Earth-format start file
-    CALL dynetat0("start.nc", vcov, ucov, teta, q, masse, ps, phis, time_0)
-    !        endif ! of if (planet_type.EQ."earth")
-
-    !       WRITE(73,*) 'ucov',ucov
-    !       WRITE(74,*) 'vcov',vcov
-    !       WRITE(75,*) 'teta',teta
-    !       WRITE(76,*) 'ps',ps
-    !       WRITE(77,*) 'q',q
-
-  ENDIF ! of if (read_start)
-
-
-  ! le cas echeant, creation d un etat initial
-  IF (prt_level > 9) WRITE(lunout, *) &
-          'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
-  IF (.NOT.read_start) THEN
-    start_time = 0.
-    annee_ref = anneeref
-    CALL iniacademic(vcov, ucov, teta, q, masse, ps, phis, time_0)
-  ENDIF
-
-
-  !-----------------------------------------------------------------------
-  !   Lecture des parametres de controle pour la simulation :
-  !   -------------------------------------------------------
-  !  on recalcule eventuellement le pas de temps
-
-  IF(MOD(day_step, iperiod)/=0) THEN
-    abort_message = &
-            'Il faut choisir un nb de pas par jour multiple de iperiod'
-    CALL abort_gcm(modname, abort_message, 1)
-  ENDIF
-
-  IF(MOD(day_step, iphysiq)/=0) THEN
-    abort_message = &
-            'Il faut choisir un nb de pas par jour multiple de iphysiq'
-    CALL abort_gcm(modname, abort_message, 1)
-  ENDIF
-
-  zdtvr = daysec / REAL(day_step)
-  IF(dtvr/=zdtvr) THEN
-    WRITE(lunout, *) &
-            'WARNING!!! changement de pas de temps', dtvr, '>', zdtvr
-  ENDIF
-
-  ! on remet le calendrier \`a zero si demande
-
-  IF (start_time /= starttime) THEN
-    WRITE(lunout, *)' GCM: Attention l''heure de depart lue dans le' &
-            , ' fichier restart ne correspond pas a celle lue dans le run.def'
-    IF (raz_date == 1) THEN
-      WRITE(lunout, *)'Je prends l''heure lue dans run.def'
-      start_time = starttime
-    ELSE
-      CALL abort_gcm("gcm", "'Je m''arrete'", 1)
-    ENDIF
-  ENDIF
-  IF (raz_date == 1) THEN
-    annee_ref = anneeref
-    day_ref = dayref
-    day_ini = dayref
-    itau_dyn = 0
-    itau_phy = 0
-    time_0 = 0.
-    WRITE(lunout, *) &
-            'GCM: On reinitialise a la date lue dans gcm.def'
-  ELSE IF (annee_ref /= anneeref .OR. day_ref /= dayref) THEN
-    WRITE(lunout, *) &
-            'GCM: Attention les dates initiales lues dans le fichier'
-    WRITE(lunout, *) &
-            ' restart ne correspondent pas a celles lues dans '
-    WRITE(lunout, *)' gcm.def'
-    WRITE(lunout, *)' annee_ref=', annee_ref, " anneeref=", anneeref
-    WRITE(lunout, *)' day_ref=', day_ref, " dayref=", dayref
-    WRITE(lunout, *)' Pas de remise a zero'
-  ENDIF
-
-  !      if (annee_ref .NE. anneeref .OR. day_ref .NE. dayref) THEN
-  !        WRITE(lunout,*)
-  !     .  'GCM: Attention les dates initiales lues dans le fichier'
-  !        WRITE(lunout,*)
-  !     .  ' restart ne correspondent pas a celles lues dans '
-  !        WRITE(lunout,*)' gcm.def'
-  !        WRITE(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
-  !        WRITE(lunout,*)' day_ref=',day_ref," dayref=",dayref
-  !        if (raz_date .NE. 1) THEN
-  !          WRITE(lunout,*)
-  !     .    'GCM: On garde les dates du fichier restart'
-  !        else
-  !          annee_ref = anneeref
-  !          day_ref = dayref
-  !          day_ini = dayref
-  !          itau_dyn = 0
-  !          itau_phy = 0
-  !          time_0 = 0.
-  !          WRITE(lunout,*)
-  !     .   'GCM: On reinitialise a la date lue dans gcm.def'
-  !        endif
-  !      ELSE
-  !        raz_date = 0
-  !      endif
-
-  mois = 1
-  heure = 0.
-  CALL ymds2ju(annee_ref, mois, day_ref, heure, jD_ref)
-  jH_ref = jD_ref - int(jD_ref)
-  jD_ref = int(jD_ref)
-
-  CALL ioconf_startdate(INT(jD_ref), jH_ref)
-
-  WRITE(lunout, *)'DEBUG'
-  WRITE(lunout, *)'annee_ref, mois, day_ref, heure, jD_ref'
-  WRITE(lunout, *)annee_ref, mois, day_ref, heure, jD_ref
-  CALL ju2ymds(jD_ref + jH_ref, an, mois, jour, heure)
-  WRITE(lunout, *)'jD_ref+jH_ref,an, mois, jour, heure'
-  WRITE(lunout, *)jD_ref + jH_ref, an, mois, jour, heure
-
-  IF (iflag_phys==1) THEN
-    ! these initialisations have already been done (via iniacademic)
-    ! if running in SW or Newtonian mode
-    !-----------------------------------------------------------------------
-    !   Initialisation des constantes dynamiques :
-    !   ------------------------------------------
-    dtvr = zdtvr
-    CALL iniconst
-
-    !-----------------------------------------------------------------------
-    !   Initialisation de la geometrie :
-    !   --------------------------------
-    CALL inigeom
-
-    !-----------------------------------------------------------------------
-    !   Initialisation du filtre :
-    !   --------------------------
-    CALL inifilr
-  ENDIF ! of if (iflag_phys.EQ.1)
-
-  !-----------------------------------------------------------------------
-  !   Initialisation de la dissipation :
-  !   ----------------------------------
-
-  CALL inidissip(lstardis, nitergdiv, nitergrot, niterh, &
-          tetagdiv, tetagrot, tetatemp, vert_prof_dissip)
-
-  !  numero de stockage pour les fichiers de redemarrage:
-
-  !-----------------------------------------------------------------------
-  !   Initialisation des I/O :
-  !   ------------------------
-
-  IF (nday>=0) THEN
-    day_end = day_ini + nday
-  else
-    day_end = day_ini - nday / day_step
-  ENDIF
-  WRITE(lunout, 300)day_ini, day_end
-  300 FORMAT('1'/, 15x, 'run du jour', i7, 2x, 'au jour', i7//)
-
-  CALL ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
-  write (lunout, 301)jour, mois, an
-  CALL ju2ymds(jD_ref + day_end - day_ref, an, mois, jour, heure)
-  write (lunout, 302)jour, mois, an
-  301 FORMAT('1'/, 15x, 'run du ', i2, '/', i2, '/', i4)
-  302 FORMAT('1'/, 15x, '    au ', i2, '/', i2, '/', i4)
-
-  !-----------------------------------------------------------------------
-  !   Initialisation de la physique :
-  !   -------------------------------
-
-  IF ((iflag_phys==1).OR.(iflag_phys>=100)) THEN
-    ! Physics:
-    IF (CPPKEY_PHYS) THEN
-      CALL iniphysiq(iim, jjm, llm, &
-              (jjm - 1) * iim + 2, comm_lmdz, &
-              daysec, day_ini, dtphys / nsplit_phys, &
-              rlatu, rlatv, rlonu, rlonv, aire, cu, cv, rad, g, r, cpp, &
-              iflag_phys)
-    END IF
-  ENDIF ! of IF ((iflag_phys==1).OR.(iflag_phys>=100))
-
-  !      if (planet_type.EQ."earth") THEN
-  ! Write an Earth-format restart file
-
-  CALL dynredem0("restart.nc", day_end, phis)
-  !      endif
-
-  ecripar = .TRUE.
-
-  time_step = zdtvr
-  IF (ok_dyn_ins) THEN
-    ! initialize output file for instantaneous outputs
-    ! t_ops = iecri * daysec ! do operations every t_ops
-    t_ops = ((1.0 * iecri) / day_step) * daysec
-    t_wrt = daysec ! iecri * daysec ! write output every t_wrt
-    CALL inithist(day_ref, annee_ref, time_step, &
-            t_ops, t_wrt)
-  ENDIF
-
-  IF (ok_dyn_ave) THEN
-    ! initialize output file for averaged outputs
-    t_ops = iperiod * time_step ! do operations every t_ops
-    t_wrt = periodav * daysec   ! write output every t_wrt
-    CALL initdynav(day_ref, annee_ref, time_step, &
-            t_ops, t_wrt)
-  END IF
-  dtav = iperiod * dtvr / daysec
-
-  !  Choix des frequences de stokage pour le offline
-  !      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
-  !      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
-  istdyn = day_step / 4     ! stockage toutes les 6h=1jour/12
-  istphy = istdyn / iphysiq
-
-  !-----------------------------------------------------------------------
-  !   Integration temporelle du modele :
-  !   ----------------------------------
-
-  !       WRITE(78,*) 'ucov',ucov
-  !       WRITE(78,*) 'vcov',vcov
-  !       WRITE(78,*) 'teta',teta
-  !       WRITE(78,*) 'ps',ps
-  !       WRITE(78,*) 'q',q
-
-  CALL leapfrog(ucov, vcov, teta, ps, masse, phis, q, time_0)
-
-END PROGRAM gcm
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/gcm.f90	(revision 5186)
@@ -0,0 +1,444 @@
+! $Id$
+
+
+
+PROGRAM gcm
+
+  USE IOIPSL
+  USE lmdz_wxios  ! ug Pour les sorties XIOS
+
+  USE lmdz_filtreg, ONLY: inifilr
+  USE lmdz_infotrac, ONLY: nqtot, init_infotrac
+  USE control_mod
+  USE mod_const_mpi, ONLY: COMM_LMDZ
+  USE temps_mod, ONLY: calend, start_time, annee_ref, day_ref, &
+          itau_dyn, itau_phy, day_ini, jD_ref, jH_ref, day_end
+  USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, r, rad
+  USE logic_mod, ONLY: ecripar, iflag_phys, read_start
+
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
+  USE lmdz_description, ONLY: descript
+  USE lmdz_dynetat0, ONLY: dynetat0
+
+  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
+  ! A nettoyer. On ne veut qu'une ou deux routines d'interface 
+  ! dynamique -> physique pour l'initialisation
+  ! AB 2024/07/20: remplace CPP key by fortran logical, but ^ still relevant, see later use of iniphys later on
+  USE iniphysiq_mod, ONLY: iniphysiq
+  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  USE lmdz_iniprint, ONLY: lunout, prt_level
+  USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
+          tetagrot, tetatemp, coefdis, vert_prof_dissip
+  USE lmdz_comgeom
+  USE lmdz_tracstoke
+
+  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+  USE lmdz_paramet
+  USE lmdz_leapfrog, ONLY: leapfrog
+  USE lmdz_conf_gcm, ONLY: conf_gcm
+  USE lmdz_dynredem, ONLY: dynredem0
+
+  IMPLICIT NONE
+
+  !      ......   Version  du 10/01/98    ..........
+
+  !             avec  coordonnees  verticales hybrides
+  !   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
+
+  !=======================================================================
+
+  !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
+  !   -------
+
+  !   Objet:
+  !   ------
+
+  !   GCM LMD nouvelle grille
+
+  !=======================================================================
+
+  !  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
+  !      et possibilite d'appeler une fonction f(y)  a derivee tangente
+  !      hyperbolique a la  place de la fonction a derivee sinusoidale.
+  !  ... Possibilite de choisir le schema pour l'advection de
+  !        q  , en modifiant iadv dans traceur.def  (MAF,10/02) .
+
+  !      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
+  !      Pour Van-Leer iadv=10
+
+  !-----------------------------------------------------------------------
+  !   Declarations:
+  !   -------------
+
+
+
+
+  REAL zdtvr
+
+  !   variables dynamiques
+  REAL vcov(ip1jm, llm), ucov(ip1jmp1, llm) ! vents covariants
+  REAL teta(ip1jmp1, llm)                 ! temperature potentielle
+  REAL, ALLOCATABLE, DIMENSION(:, :, :) :: q! champs advectes
+  REAL ps(ip1jmp1)                       ! pression  au sol
+  !  REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.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
+
+  ! variables dynamiques intermediaire pour le transport
+
+  !   variables pour le fichier histoire
+  REAL dtav      ! intervalle de temps elementaire
+
+  REAL time_0
+
+  LOGICAL lafin
+
+  REAL time_step, t_wrt, t_ops
+
+  !      LOGICAL call_iniphys
+  !      data call_iniphys/.TRUE./
+
+  !+jld variables test conservation energie
+  !      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
+  !     Tendance de la temp. potentiel d (theta)/ d t due a la 
+  !     tansformation d'energie cinetique en energie thermique
+  !     cree par la dissipation
+  !  REAL dhecdt(ip1jmp1,llm)
+  !      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
+  !      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
+  !  CHARACTER (len=15) :: ztit
+  !-jld 
+
+  CHARACTER (LEN = 80) :: dynhist_file, dynhistave_file
+  CHARACTER (LEN = 20) :: modname
+  CHARACTER (LEN = 80) :: abort_message
+  ! locales pour gestion du temps
+  INTEGER :: an, mois, jour
+  REAL :: heure
+  LOGICAL use_filtre_fft
+
+  !-----------------------------------------------------------------------
+  !   Initialisations:
+  !   ----------------
+
+  abort_message = 'last timestep reached'
+  modname = 'gcm'
+  descript = 'Run GCM LMDZ'
+  lafin = .FALSE.
+  dynhist_file = 'dyn_hist.nc'
+  dynhistave_file = 'dyn_hist_ave.nc'
+
+
+
+  !----------------------------------------------------------------------
+  !  lecture des fichiers gcm.def ou run.def
+  !  ---------------------------------------
+
+  CALL conf_gcm(99, .TRUE.)
+
+  IF (mod(iphysiq, iperiod) /= 0) CALL abort_gcm("conf_gcm", &
+          "iphysiq must be a multiple of iperiod", 1)
+
+  use_filtre_fft = .FALSE.
+  CALL getin('use_filtre_fft', use_filtre_fft)
+  IF (use_filtre_fft) CALL abort_gcm("gcm", 'FFT filter is not available in ' &
+          // 'the sequential version of the dynamics.', 1)
+
+  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  ! Initialisation de XIOS
+  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  IF (using_xios) THEN
+    CALL wxios_init("LMDZ")
+  ENDIF
+
+
+  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  ! FH 2008/05/02
+  ! A nettoyer. On ne veut qu'une ou deux routines d'interface 
+  ! dynamique -> physique pour l'initialisation
+  !#ifdef CPP_PHYS
+  !  CALL Init_Phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/))
+  !  !      CALL InitComgeomphy ! now done in iniphysiq
+  !#endif
+  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  !-----------------------------------------------------------------------
+  !   Choix du calendrier
+  !   -------------------
+
+  !      calend = 'earth_365d'
+
+  IF (calend == 'earth_360d') THEN
+    CALL ioconf_calendar('360_day')
+    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
+  ELSE IF (calend == 'earth_365d') THEN
+    CALL ioconf_calendar('noleap')
+    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
+  ELSE IF (calend == 'gregorian') THEN
+    CALL ioconf_calendar('gregorian')
+    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre bissextile'
+  else
+    abort_message = 'Mauvais choix de calendrier'
+    CALL abort_gcm(modname, abort_message, 1)
+  ENDIF
+  !-----------------------------------------------------------------------
+
+
+  !------------------------------------
+  !   Initialisation partie parallele
+  !------------------------------------
+
+
+  !-----------------------------------------------------------------------
+  !   Initialisation des traceurs
+  !   ---------------------------
+  !  Choix du nombre de traceurs et du schema pour l'advection
+  !  dans fichier traceur.def, par default ou via INCA
+  CALL init_infotrac
+
+  ! Allocation de la tableau q : champs advectes   
+  allocate(q(ip1jmp1, llm, nqtot))
+
+  !-----------------------------------------------------------------------
+  !   Lecture de l'etat initial :
+  !   ---------------------------
+
+  !  lecture du fichier start.nc
+  IF (read_start) THEN
+    ! we still need to run iniacademic to initialize some
+    ! constants & fields, if we run the 'newtonian' or 'SW' cases:
+    IF (iflag_phys/=1) THEN
+      CALL iniacademic(vcov, ucov, teta, q, masse, ps, phis, time_0)
+    endif
+
+    !        if (planet_type.EQ."earth") THEN
+    ! Load an Earth-format start file
+    CALL dynetat0("start.nc", vcov, ucov, teta, q, masse, ps, phis, time_0)
+    !        endif ! of if (planet_type.EQ."earth")
+
+    !       WRITE(73,*) 'ucov',ucov
+    !       WRITE(74,*) 'vcov',vcov
+    !       WRITE(75,*) 'teta',teta
+    !       WRITE(76,*) 'ps',ps
+    !       WRITE(77,*) 'q',q
+
+  ENDIF ! of if (read_start)
+
+
+  ! le cas echeant, creation d un etat initial
+  IF (prt_level > 9) WRITE(lunout, *) &
+          'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
+  IF (.NOT.read_start) THEN
+    start_time = 0.
+    annee_ref = anneeref
+    CALL iniacademic(vcov, ucov, teta, q, masse, ps, phis, time_0)
+  ENDIF
+
+
+  !-----------------------------------------------------------------------
+  !   Lecture des parametres de controle pour la simulation :
+  !   -------------------------------------------------------
+  !  on recalcule eventuellement le pas de temps
+
+  IF(MOD(day_step, iperiod)/=0) THEN
+    abort_message = &
+            'Il faut choisir un nb de pas par jour multiple de iperiod'
+    CALL abort_gcm(modname, abort_message, 1)
+  ENDIF
+
+  IF(MOD(day_step, iphysiq)/=0) THEN
+    abort_message = &
+            'Il faut choisir un nb de pas par jour multiple de iphysiq'
+    CALL abort_gcm(modname, abort_message, 1)
+  ENDIF
+
+  zdtvr = daysec / REAL(day_step)
+  IF(dtvr/=zdtvr) THEN
+    WRITE(lunout, *) &
+            'WARNING!!! changement de pas de temps', dtvr, '>', zdtvr
+  ENDIF
+
+  ! on remet le calendrier \`a zero si demande
+
+  IF (start_time /= starttime) THEN
+    WRITE(lunout, *)' GCM: Attention l''heure de depart lue dans le' &
+            , ' fichier restart ne correspond pas a celle lue dans le run.def'
+    IF (raz_date == 1) THEN
+      WRITE(lunout, *)'Je prends l''heure lue dans run.def'
+      start_time = starttime
+    ELSE
+      CALL abort_gcm("gcm", "'Je m''arrete'", 1)
+    ENDIF
+  ENDIF
+  IF (raz_date == 1) THEN
+    annee_ref = anneeref
+    day_ref = dayref
+    day_ini = dayref
+    itau_dyn = 0
+    itau_phy = 0
+    time_0 = 0.
+    WRITE(lunout, *) &
+            'GCM: On reinitialise a la date lue dans gcm.def'
+  ELSE IF (annee_ref /= anneeref .OR. day_ref /= dayref) THEN
+    WRITE(lunout, *) &
+            'GCM: Attention les dates initiales lues dans le fichier'
+    WRITE(lunout, *) &
+            ' restart ne correspondent pas a celles lues dans '
+    WRITE(lunout, *)' gcm.def'
+    WRITE(lunout, *)' annee_ref=', annee_ref, " anneeref=", anneeref
+    WRITE(lunout, *)' day_ref=', day_ref, " dayref=", dayref
+    WRITE(lunout, *)' Pas de remise a zero'
+  ENDIF
+
+  !      if (annee_ref .NE. anneeref .OR. day_ref .NE. dayref) THEN
+  !        WRITE(lunout,*)
+  !     .  'GCM: Attention les dates initiales lues dans le fichier'
+  !        WRITE(lunout,*)
+  !     .  ' restart ne correspondent pas a celles lues dans '
+  !        WRITE(lunout,*)' gcm.def'
+  !        WRITE(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
+  !        WRITE(lunout,*)' day_ref=',day_ref," dayref=",dayref
+  !        if (raz_date .NE. 1) THEN
+  !          WRITE(lunout,*)
+  !     .    'GCM: On garde les dates du fichier restart'
+  !        else
+  !          annee_ref = anneeref
+  !          day_ref = dayref
+  !          day_ini = dayref
+  !          itau_dyn = 0
+  !          itau_phy = 0
+  !          time_0 = 0.
+  !          WRITE(lunout,*)
+  !     .   'GCM: On reinitialise a la date lue dans gcm.def'
+  !        endif
+  !      ELSE
+  !        raz_date = 0
+  !      endif
+
+  mois = 1
+  heure = 0.
+  CALL ymds2ju(annee_ref, mois, day_ref, heure, jD_ref)
+  jH_ref = jD_ref - int(jD_ref)
+  jD_ref = int(jD_ref)
+
+  CALL ioconf_startdate(INT(jD_ref), jH_ref)
+
+  WRITE(lunout, *)'DEBUG'
+  WRITE(lunout, *)'annee_ref, mois, day_ref, heure, jD_ref'
+  WRITE(lunout, *)annee_ref, mois, day_ref, heure, jD_ref
+  CALL ju2ymds(jD_ref + jH_ref, an, mois, jour, heure)
+  WRITE(lunout, *)'jD_ref+jH_ref,an, mois, jour, heure'
+  WRITE(lunout, *)jD_ref + jH_ref, an, mois, jour, heure
+
+  IF (iflag_phys==1) THEN
+    ! these initialisations have already been done (via iniacademic)
+    ! if running in SW or Newtonian mode
+    !-----------------------------------------------------------------------
+    !   Initialisation des constantes dynamiques :
+    !   ------------------------------------------
+    dtvr = zdtvr
+    CALL iniconst
+
+    !-----------------------------------------------------------------------
+    !   Initialisation de la geometrie :
+    !   --------------------------------
+    CALL inigeom
+
+    !-----------------------------------------------------------------------
+    !   Initialisation du filtre :
+    !   --------------------------
+    CALL inifilr
+  ENDIF ! of if (iflag_phys.EQ.1)
+
+  !-----------------------------------------------------------------------
+  !   Initialisation de la dissipation :
+  !   ----------------------------------
+
+  CALL inidissip(lstardis, nitergdiv, nitergrot, niterh, &
+          tetagdiv, tetagrot, tetatemp, vert_prof_dissip)
+
+  !  numero de stockage pour les fichiers de redemarrage:
+
+  !-----------------------------------------------------------------------
+  !   Initialisation des I/O :
+  !   ------------------------
+
+  IF (nday>=0) THEN
+    day_end = day_ini + nday
+  else
+    day_end = day_ini - nday / day_step
+  ENDIF
+  WRITE(lunout, 300)day_ini, day_end
+  300 FORMAT('1'/, 15x, 'run du jour', i7, 2x, 'au jour', i7//)
+
+  CALL ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
+  write (lunout, 301)jour, mois, an
+  CALL ju2ymds(jD_ref + day_end - day_ref, an, mois, jour, heure)
+  write (lunout, 302)jour, mois, an
+  301 FORMAT('1'/, 15x, 'run du ', i2, '/', i2, '/', i4)
+  302 FORMAT('1'/, 15x, '    au ', i2, '/', i2, '/', i4)
+
+  !-----------------------------------------------------------------------
+  !   Initialisation de la physique :
+  !   -------------------------------
+
+  IF ((iflag_phys==1).OR.(iflag_phys>=100)) THEN
+    ! Physics:
+    IF (CPPKEY_PHYS) THEN
+      CALL iniphysiq(iim, jjm, llm, &
+              (jjm - 1) * iim + 2, comm_lmdz, &
+              daysec, day_ini, dtphys / nsplit_phys, &
+              rlatu, rlatv, rlonu, rlonv, aire, cu, cv, rad, g, r, cpp, &
+              iflag_phys)
+    END IF
+  ENDIF ! of IF ((iflag_phys==1).OR.(iflag_phys>=100))
+
+  !      if (planet_type.EQ."earth") THEN
+  ! Write an Earth-format restart file
+
+  CALL dynredem0("restart.nc", day_end, phis)
+  !      endif
+
+  ecripar = .TRUE.
+
+  time_step = zdtvr
+  IF (ok_dyn_ins) THEN
+    ! initialize output file for instantaneous outputs
+    ! t_ops = iecri * daysec ! do operations every t_ops
+    t_ops = ((1.0 * iecri) / day_step) * daysec
+    t_wrt = daysec ! iecri * daysec ! write output every t_wrt
+    CALL inithist(day_ref, annee_ref, time_step, &
+            t_ops, t_wrt)
+  ENDIF
+
+  IF (ok_dyn_ave) THEN
+    ! initialize output file for averaged outputs
+    t_ops = iperiod * time_step ! do operations every t_ops
+    t_wrt = periodav * daysec   ! write output every t_wrt
+    CALL initdynav(day_ref, annee_ref, time_step, &
+            t_ops, t_wrt)
+  END IF
+  dtav = iperiod * dtvr / daysec
+
+  !  Choix des frequences de stokage pour le offline
+  !      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
+  !      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
+  istdyn = day_step / 4     ! stockage toutes les 6h=1jour/12
+  istphy = istdyn / iphysiq
+
+  !-----------------------------------------------------------------------
+  !   Integration temporelle du modele :
+  !   ----------------------------------
+
+  !       WRITE(78,*) 'ucov',ucov
+  !       WRITE(78,*) 'vcov',vcov
+  !       WRITE(78,*) 'teta',teta
+  !       WRITE(78,*) 'ps',ps
+  !       WRITE(78,*) 'q',q
+
+  CALL leapfrog(ucov, vcov, teta, ps, masse, phis, q, time_0)
+
+END PROGRAM gcm
Index: DZ6/branches/Amaury_dev/libf/dyn3d/ini_paramLMDZ_dyn.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/ini_paramLMDZ_dyn.h	(revision 5185)
+++ 	(revision )
@@ -1,214 +1,0 @@
-c
-      dt_cum = dtvr*day_step
-
-!      zan = annee_ref
-!      dayref = day_ref
-!      CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
-      tau0 = itau_dyn
-c
-       pi = 4.0 * ATAN(1.0)
-       degres = 180./pi
-       rlong = rlonu * degres
-       rlatg = rlatu * degres
-c
-      CALL histbeg("paramLMDZ_dyn.nc", 
-     .                 iip1,rlong, jjp1,rlatg,
-     .                 1,1,1,1,
-     .                 tau0, jD_ref+jH_ref , dt_cum,
-     .                 thoriid, nid_ctesGCM)
-c
-         CALL histdef(nid_ctesGCM, "prt_level", 
-     .        "Niveau impression debuggage dynamique",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "dayref", 
-     .        "Jour de l etat initial ( = 350  si 20 Decembre par ex.)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "anneeref", 
-     .        "Annee de l etat initial",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "anneelim", 
-     .        "Annee du fichier limitxxxx.nc  si  ok_limitvrai =y",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "raz_date", 
-     .   "Remise a zero (raz) date init.: 0 pas de raz;1=date gcm.def",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "nday", 
-     .   "Nombre de jours d integration",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "day_step", 
-     .   "nombre de pas par jour pour dt = 1 min",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "iperiod", 
-     .   "periode pour le pas Matsuno (en pas de temps)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "iapp_tracvl", 
-     .   "frequence du groupement des flux (en pas de temps)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "iconser", 
-     .  "periode de sortie des variables de controle (en pas de temps)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "iecri", 
-     .  "periode d ecriture du fichier histoire (en jour)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "periodav", 
-     .  "periode de stockage fichier histmoy (en jour)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "dissip_period", 
-     .  "periode de la dissipation (en pas) ... a completer",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "lstardis", 
-     .  "choix de l operateur de dissipation: 1= star,0=non-star ??",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "nitergdiv", 
-     .  "nombre d iterations de l operateur de dissipation gradiv",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "nitergrot", 
-     .  "nombre d iterations de l operateur de dissipation nxgradrot",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "niterh", 
-     .  "nombre d iterations de l operateur de dissipation divgrad",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "tetagdiv", 
-     ."temps dissipation des + petites long. d ondes pour u,v (gradiv)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "tetagrot", 
-     ."temps diss. des + petites long. d ondes pour u,v (nxgradrot)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "tetatemp", 
-     ."temps diss. des + petites long. d ondes pour h (divgrad)",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "coefdis", 
-     ."coefficient pour gamdissip",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "purmats", 
-     ."Choix schema integration temporel: 1=Matsuno,0=Matsuno-leapfrog",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "ok_guide", 
-     ."Guidage: 1=true ,0=false",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "true_calendar", 
-     ."Choix du calendrier",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "guide_calend", 
-     ."Guidage calendrier gregorien: 1=oui ,0=non",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "iflag_phys", 
-     ."Permet de faire tourner le modele sans physique: 1=avec ,0=sans",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "iphysiq", 
-     ."Periode de la physique en pas de temps de la dynamique",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "clon", 
-     ."longitude en degres du centre du zoom",
-     .                "deg",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "clat", 
-     ."latitude en degres du centre du zoom",
-     .                "deg",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "grossismx", 
-     ."facteur de grossissement du zoom, selon la longitude",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "grossismy", 
-     ."facteur de grossissement du zoom, selon la latitude",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "fxyhypb", 
-     ."Fonction f(y) hyperbolique  si true=1, sinusoidale si false=0",
-     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "dzoomx", 
-     ."extension en longitude de la zone du zoom (fraction zone totale)"
-     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "dzoomy", 
-     ."extension en latitude de la zone du zoom (fraction zone totale)"
-     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "taux", 
-     ."raideur du zoom en  X"
-     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "tauy", 
-     ."raideur du zoom en  Y"
-     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "ysinus", 
-     ."ysinus=1: Ftion f(y) avec y=Sin(latit.)/ ysinus=0: y = latit"
-     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
-     .                "once", dt_cum,dt_cum)
-c
-         CALL histdef(nid_ctesGCM, "ip_ebil_dyn", 
-     ."PRINTlevel for energy conservation diag.; 0/1= pas de print,
-     . 2= print","-",iip1,jjp1,thoriid, 1,1,1, -99, 32,
-     .                "once", dt_cum,dt_cum)
-c
-c=================================================================
-c
-         CALL histend(nid_ctesGCM)
-c
-c=================================================================
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/iniacademic.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/iniacademic.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/iniacademic.F90	(revision 5186)
@@ -28,4 +28,6 @@
   USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
   USE lmdz_paramet
+  USE lmdz_check_isotopes, ONLY: check_isotopes_seq
+
   IMPLICIT NONE
 
@@ -340,5 +342,5 @@
       endif ! of if (planet_type=="earth")
 
-      CALL check_isotopes_seq(q, 1, ip1jmp1, 'iniacademic_loc')
+      CALL check_isotopes_seq(q, ip1jmp1, 'iniacademic_loc')
 
       ! add random perturbation to temperature
Index: DZ6/branches/Amaury_dev/libf/dyn3d/leapfrog.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/leapfrog.F90	(revision 5185)
+++ 	(revision )
@@ -1,834 +1,0 @@
-! $Id$
-
-
-
-SUBROUTINE leapfrog(ucov, vcov, teta, ps, masse, phis, q, time_0)
-
-
-  !IM : pour sortir les param. du modele dans un fis. netcdf 110106
-  USE IOIPSL
-  USE lmdz_infotrac, ONLY: nqtot, isoCheck
-  USE guide_mod, ONLY: guide_main
-  USE lmdz_write_field, ONLY: writefield
-  USE control_mod, ONLY: nday, day_step, planet_type, offline, &
-          iconser, iphysiq, iperiod, dissip_period, &
-          iecri, ip_ebil_dyn, ok_dynzon, ok_dyn_ins, &
-          periodav, ok_dyn_ave, output_grads_dyn
-  USE exner_hyb_m, ONLY: exner_hyb
-  USE exner_milieu_m, ONLY: exner_milieu
-  USE comvert_mod, ONLY: ap, bp, pressure_exner, presnivs
-  USE comconst_mod, ONLY: cpp, dtphys, dtvr, pi, ihf
-  USE logic_mod, ONLY: iflag_phys, ok_guide, forward, leapf, apphys, &
-          statcl, conser, apdiss, purmats, ok_strato
-  USE temps_mod, ONLY: jD_ref, jH_ref, itaufin, day_ini, day_ref, &
-          start_time, dt
-  USE lmdz_strings, ONLY: msg
-  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
-  USE lmdz_description, ONLY: descript
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_ssum_scopy, ONLY: scopy, ssum
-  USE lmdz_academic, ONLY: tetarappel, knewt_t, kfrict, knewt_g, clat4
-  USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
-          tetagrot, tetatemp, coefdis, vert_prof_dissip
-  USE lmdz_comgeom
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  ! ......   Version  du 10/01/98    ..........
-
-  !        avec  coordonnees  verticales hybrides
-  !   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
-
-  !=======================================================================
-
-  !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
-  !   -------
-
-  !   Objet:
-  !   ------
-
-  !   GCM LMD nouvelle grille
-
-  !=======================================================================
-
-  !  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
-  !  et possibilite d'appeler une fonction f(y)  a derivee tangente
-  !  hyperbolique a la  place de la fonction a derivee sinusoidale.
-
-  !  ... Possibilite de choisir le shema pour l'advection de
-  !    q  , en modifiant iadv dans traceur.def  (10/02) .
-
-  !  Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
-  !  Pour Van-Leer iadv=10
-
-  !-----------------------------------------------------------------------
-  !   Declarations:
-  !   -------------
-
-
-
-
-  REAL, INTENT(IN) :: time_0 ! not used
-
-  !   dynamical variables:
-  REAL, INTENT(INOUT) :: ucov(ip1jmp1, llm)    ! zonal covariant wind
-  REAL, INTENT(INOUT) :: vcov(ip1jm, llm)      ! meridional covariant wind
-  REAL, INTENT(INOUT) :: teta(ip1jmp1, llm)    ! potential temperature
-  REAL, INTENT(INOUT) :: ps(ip1jmp1)          ! surface pressure (Pa)
-  REAL, INTENT(INOUT) :: masse(ip1jmp1, llm)   ! air mass
-  REAL, INTENT(INOUT) :: phis(ip1jmp1)        ! geopotentiat at the surface
-  REAL, INTENT(INOUT) :: q(ip1jmp1, llm, nqtot) ! advected tracers
-
-  REAL :: p (ip1jmp1, llmp1)               ! interlayer pressure
-  REAL :: pks(ip1jmp1)                      ! exner at the surface
-  REAL :: pk(ip1jmp1, llm)                   ! exner at mid-layer
-  REAL :: pkf(ip1jmp1, llm)                  ! filtered exner at mid-layer
-  REAL :: phi(ip1jmp1, llm)                  ! geopotential
-  REAL :: w(ip1jmp1, llm)                    ! vertical velocity
-
-  REAL :: zqmin, zqmax
-
-  ! variables dynamiques intermediaire pour le transport
-  REAL :: pbaru(ip1jmp1, llm), pbarv(ip1jm, llm) !flux de masse
-
-  !   variables dynamiques au pas -1
-  REAL :: vcovm1(ip1jm, llm), ucovm1(ip1jmp1, llm)
-  REAL :: tetam1(ip1jmp1, llm), psm1(ip1jmp1)
-  REAL :: massem1(ip1jmp1, llm)
-
-  !   tendances dynamiques
-  REAL :: dv(ip1jm, llm), du(ip1jmp1, llm)
-  REAL :: dteta(ip1jmp1, llm), dq(ip1jmp1, llm, nqtot), dp(ip1jmp1)
-
-  !   tendances de la dissipation
-  REAL :: dvdis(ip1jm, llm), dudis(ip1jmp1, llm)
-  REAL :: dtetadis(ip1jmp1, llm)
-
-  !   tendances physiques
-  REAL :: dvfi(ip1jm, llm), dufi(ip1jmp1, llm)
-  REAL :: dtetafi(ip1jmp1, llm), dqfi(ip1jmp1, llm, nqtot), dpfi(ip1jmp1)
-
-  !   variables pour le fichier histoire
-  REAL :: dtav      ! intervalle de temps elementaire
-
-  REAL :: tppn(iim), tpps(iim), tpn, tps
-
-  INTEGER :: itau, itaufinp1, iav
-  ! INTEGER  iday ! jour julien
-  REAL :: time
-
-  ! REAL finvmaold(ip1jmp1,llm)
-
-  !ym      LOGICAL  lafin
-  LOGICAL :: lafin = .FALSE.
-  INTEGER :: ij, iq, l
-  INTEGER :: ik
-
-  REAL :: time_step, t_wrt, t_ops
-
-  ! REAL rdayvrai,rdaym_ini
-  ! jD_cur: jour julien courant
-  ! jH_cur: heure julienne courante
-  REAL :: jD_cur, jH_cur
-  INTEGER :: an, mois, jour
-  REAL :: secondes
-
-  LOGICAL :: first, callinigrads
-  !IM : pour sortir les param. du modele dans un fis. netcdf 110106
-  save first
-  data first/.TRUE./
-  REAL :: dt_cum
-  CHARACTER(LEN = 10) :: infile
-  INTEGER :: zan, tau0, thoriid
-  INTEGER :: nid_ctesGCM
-  save nid_ctesGCM
-  REAL :: degres
-  REAL :: rlong(iip1), rlatg(jjp1)
-  REAL :: zx_tmp_2d(iip1, jjp1)
-  INTEGER :: ndex2d(iip1 * jjp1)
-  LOGICAL :: ok_sync
-  parameter (ok_sync = .TRUE.)
-  LOGICAL :: physic
-
-  data callinigrads/.TRUE./
-  CHARACTER(LEN = 10) :: string10
-
-  REAL :: flxw(ip1jmp1, llm)  ! flux de masse verticale
-
-  !+jld variables test conservation energie
-  REAL :: ecin(ip1jmp1, llm), ecin0(ip1jmp1, llm)
-  ! Tendance de la temp. potentiel d (theta)/ d t due a la
-  ! tansformation d'energie cinetique en energie thermique
-  ! cree par la dissipation
-  REAL :: dtetaecdt(ip1jmp1, llm)
-  REAL :: vcont(ip1jm, llm), ucont(ip1jmp1, llm)
-  REAL :: vnat(ip1jm, llm), unat(ip1jmp1, llm)
-  REAL :: d_h_vcol, d_qt, d_qw, d_ql, d_ec
-  CHARACTER(len = 15) :: ztit
-  !IM   INTEGER   ip_ebil_dyn  ! PRINT level for energy conserv. diag.
-  !IM   SAVE      ip_ebil_dyn
-  !IM   DATA      ip_ebil_dyn/0/
-  !-jld
-
-  CHARACTER(LEN = 80) :: dynhist_file, dynhistave_file
-  CHARACTER(LEN = *), parameter :: modname = "leapfrog"
-  CHARACTER(LEN = 80) :: abort_message
-
-  LOGICAL :: dissip_conservative
-  save dissip_conservative
-  data dissip_conservative/.TRUE./
-
-  LOGICAL :: prem
-  save prem
-  DATA prem/.TRUE./
-  INTEGER :: testita
-  PARAMETER (testita = 9)
-
-  logical, parameter :: flag_verif = .FALSE.
-
-  INTEGER :: itau_w   ! pas de temps ecriture = itap + itau_phy
-
-  IF (nday>=0) THEN
-    itaufin = nday * day_step
-  else
-    itaufin = -nday
-  ENDIF
-  itaufinp1 = itaufin + 1
-  itau = 0
-  physic = .TRUE.
-  IF (iflag_phys==0.OR.iflag_phys==2) physic = .FALSE.
-
-  ! iday = day_ini+itau/day_step
-  ! time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
-  !    IF(time.GT.1.) THEN
-  !     time = time-1.
-  !     iday = iday+1
-  !    ENDIF
-
-
-  !-----------------------------------------------------------------------
-  !   On initialise la pression et la fonction d'Exner :
-  !   --------------------------------------------------
-
-  dq(:, :, :) = 0.
-  CALL pression (ip1jmp1, ap, bp, ps, p)
-  IF (pressure_exner) THEN
-    CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
-  else
-    CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
-  ENDIF
-
-  !-----------------------------------------------------------------------
-  !   Debut de l'integration temporelle:
-  !   ----------------------------------
-
-  1   CONTINUE ! Matsuno Forward step begins here
-
-  !   date: (NB: date remains unchanged for Backward step)
-  !   -----
-
-  jD_cur = jD_ref + day_ini - day_ref + &
-          (itau + 1) / day_step
-  jH_cur = jH_ref + start_time + &
-          mod(itau + 1, day_step) / float(day_step)
-  jD_cur = jD_cur + int(jH_cur)
-  jH_cur = jH_cur - int(jH_cur)
-
-  CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 321')
-
-  IF (ok_guide) THEN
-    CALL guide_main(itau, ucov, vcov, teta, q, masse, ps)
-  ENDIF
-
-
-
-  ! 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
-  !
-
-  ! Save fields obtained at previous time step as '...m1'
-  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
-
-  !   ...    P.Le Van .26/04/94  ....
-  ! Ehouarn: finvmaold is actually not used
-  ! CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
-  ! CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
-
-  CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 400')
-
-  2   CONTINUE ! Matsuno backward or leapfrog step begins here
-
-  !-----------------------------------------------------------------------
-
-  !   date: (NB: only leapfrog step requires recomputing date)
-  !   -----
-
-  IF (leapf) THEN
-    jD_cur = jD_ref + day_ini - day_ref + &
-            (itau + 1) / day_step
-    jH_cur = jH_ref + start_time + &
-            mod(itau + 1, day_step) / float(day_step)
-    jD_cur = jD_cur + int(jH_cur)
-    jH_cur = jH_cur - int(jH_cur)
-  ENDIF
-
-
-  !   gestion des appels de la physique et des dissipations:
-  !   ------------------------------------------------------
-
-  !   ...    P.Le Van  ( 6/02/95 )  ....
-
-  apphys = .FALSE.
-  statcl = .FALSE.
-  conser = .FALSE.
-  apdiss = .FALSE.
-
-  IF(purmats) THEN
-    ! Purely Matsuno time stepping
-    IF(MOD(itau, iconser) ==0.AND.  forward) conser = .TRUE.
-    IF(MOD(itau, dissip_period)==0.AND..NOT.forward) &
-            apdiss = .TRUE.
-    IF(MOD(itau, iphysiq)==0.AND..NOT.forward &
-            .AND. physic) apphys = .TRUE.
-  ELSE
-    ! Leapfrog/Matsuno time stepping
-    IF(MOD(itau, iconser) == 0) conser = .TRUE.
-    IF(MOD(itau + 1, dissip_period)==0 .AND. .NOT. forward) &
-            apdiss = .TRUE.
-    IF(MOD(itau + 1, iphysiq)==0.AND.physic) apphys = .TRUE.
-  END IF
-
-  ! Ehouarn: for Shallow Water case (ie: 1 vertical layer),
-  ! supress dissipation step
-  IF (llm==1) THEN
-    apdiss = .FALSE.
-  ENDIF
-
-  CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 589')
-
-  !-----------------------------------------------------------------------
-  !   calcul des tendances dynamiques:
-  !   --------------------------------
-
-  ! compute geopotential phi()
-  CALL geopot  (ip1jmp1, teta, pk, pks, phis, phi)
-
-  time = jD_cur + jH_cur
-  CALL caldyn &
-          (itau, ucov, vcov, teta, ps, masse, pk, pkf, phis, &
-          phi, conser, du, dv, dteta, dp, w, pbaru, pbarv, time)
-
-
-  !-----------------------------------------------------------------------
-  !   calcul des tendances advection des traceurs (dont l'humidite)
-  !   -------------------------------------------------------------
-
-  CALL check_isotopes_seq(q, ip1jmp1, &
-          'leapfrog 686: avant caladvtrac')
-
-  IF(forward .OR.  leapf)  THEN
-    ! Ehouarn: NB: fields sent to advtrac are those at the beginning of the time step
-    CALL caladvtrac(q, pbaru, pbarv, &
-            p, masse, dq, teta, &
-            flxw, pk)
-    !WRITE(*,*) 'caladvtrac 346'
-
-    IF (offline) THEN
-      !maf stokage du flux de masse pour traceurs OFF-LINE
-
-      CALL fluxstokenc(pbaru, pbarv, masse, teta, phi, phis, &
-              dtvr, itau)
-
-    ENDIF ! of IF (offline)
-
-  ENDIF ! of IF( forward .OR.  leapf )
-
-
-  !-----------------------------------------------------------------------
-  !   integrations dynamique et traceurs:
-  !   ----------------------------------
-
-  CALL msg('720', modname, isoCheck)
-  CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 756')
-
-  CALL integrd (nqtot, vcovm1, ucovm1, tetam1, psm1, massem1, &
-          dv, du, dteta, dq, dp, vcov, ucov, teta, q, ps, masse, phis)
-  ! $              finvmaold                                    )
-
-  CALL msg('724', modname, isoCheck)
-  CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 762')
-
-  ! .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
-
-  !-----------------------------------------------------------------------
-  !   calcul des tendances physiques:
-  !   -------------------------------
-  !    ########   P.Le Van ( Modif le  6/02/95 )   ###########
-
-  IF(purmats)  THEN
-    IF(itau==itaufin.AND..NOT.forward) lafin = .TRUE.
-  ELSE
-    IF(itau + 1 == itaufin)              lafin = .TRUE.
-  ENDIF
-
-
-  IF(apphys)  THEN
-
-    ! .......   Ajout   P.Le Van ( 17/04/96 )   ...........
-    !
-
-    CALL pression (ip1jmp1, ap, bp, ps, p)
-    IF (pressure_exner) THEN
-      CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
-    else
-      CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
-    endif
-
-    ! Appel a geopot ajoute le 2014/05/08 pour garantir la convergence numerique
-    ! avec dyn3dmem
-    CALL geopot  (ip1jmp1, teta, pk, pks, phis, phi)
-
-    ! rdaym_ini  = itau * dtvr / daysec
-    ! rdayvrai   = rdaym_ini  + day_ini
-    ! jD_cur = jD_ref + day_ini - day_ref
-    ! $        + int (itau * dtvr / daysec)
-    !       jH_cur = jH_ref +                                            &
-    ! &              (itau * dtvr / daysec - int(itau * dtvr / daysec))
-    jD_cur = jD_ref + day_ini - day_ref + &
-            (itau + 1) / day_step
-
-    IF (planet_type =="generic") THEN
-      ! AS: we make jD_cur to be pday
-      jD_cur = int(day_ini + itau / day_step)
-    ENDIF
-
-    jH_cur = jH_ref + start_time + &
-            mod(itau + 1, day_step) / float(day_step)
-    jD_cur = jD_cur + int(jH_cur)
-    jH_cur = jH_cur - int(jH_cur)
-    ! WRITE(lunout,*)'itau, jD_cur = ', itau, jD_cur, jH_cur
-    ! CALL ju2ymds(jD_cur+jH_cur, an, mois, jour, secondes)
-    ! WRITE(lunout,*)'current date = ',an, mois, jour, secondes
-
-    ! rajout debug
-    ! lafin = .TRUE.
-
-
-    !   Inbterface avec les routines de phylmd (phymars ... )
-    !   -----------------------------------------------------
-
-    !+jld
-
-    !  Diagnostique de conservation de l'energie : initialisation
-    IF (ip_ebil_dyn>=1) THEN
-      ztit = 'bil dyn'
-      ! Ehouarn: be careful, diagedyn is Earth-specific!
-      IF (planet_type=="earth") THEN
-        CALL diagedyn(ztit, 2, 1, 1, dtphys &
-                , ucov, vcov, ps, p, pk, teta, q(:, :, 1), q(:, :, 2))
-      ENDIF
-    ENDIF ! of IF (ip_ebil_dyn.ge.1 )
-    IF (CPPKEY_PHYS) THEN
-      CALL calfis(lafin, jD_cur, jH_cur, &
-              ucov, vcov, teta, q, masse, ps, p, pk, phis, phi, &
-              du, dv, dteta, dq, &
-              flxw, dufi, dvfi, dtetafi, dqfi, dpfi)
-    END IF
-    ! ajout des tendances physiques:
-    ! ------------------------------
-    CALL addfi(dtphys, leapf, forward, &
-            ucov, vcov, teta, q, ps, &
-            dufi, dvfi, dtetafi, dqfi, dpfi)
-    ! since addfi updates ps(), also update p(), masse() and pk()
-    CALL pression (ip1jmp1, ap, bp, ps, p)
-    CALL massdair(p, masse)
-    IF (pressure_exner) THEN
-      CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
-    else
-      CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
-    endif
-
-    IF (ok_strato) THEN
-      CALL top_bound(vcov, ucov, teta, masse, dtphys)
-    ENDIF
-
-
-    !  Diagnostique de conservation de l'energie : difference
-    IF (ip_ebil_dyn>=1) THEN
-      ztit = 'bil phys'
-      IF (planet_type=="earth") THEN
-        CALL diagedyn(ztit, 2, 1, 1, dtphys &
-                , ucov, vcov, ps, p, pk, teta, q(:, :, 1), q(:, :, 2))
-      ENDIF
-    ENDIF ! of IF (ip_ebil_dyn.ge.1 )
-
-  ENDIF ! of IF( apphys )
-
-  IF(iflag_phys==2) THEN ! "Newtonian" case
-    !   Academic case : Simple friction and Newtonan relaxation
-    !   -------------------------------------------------------
-    DO l = 1, llm
-      DO ij = 1, ip1jmp1
-        teta(ij, l) = teta(ij, l) - dtvr * &
-                (teta(ij, l) - tetarappel(ij, l)) * (knewt_g + knewt_t(l) * clat4(ij))
-      ENDDO
-    ENDDO ! of DO l=1,llm
-
-    IF (planet_type=="giant") THEN
-      ! add an intrinsic heat flux at the base of the atmosphere
-      teta(:, 1) = teta(:, 1) + dtvr * aire(:) * ihf / cpp / masse(:, 1)
-    endif
-
-    CALL friction(ucov, vcov, dtvr)
-
-    ! Sponge layer (if any)
-    IF (ok_strato) THEN
-      ! dufi(:,:)=0.
-      ! dvfi(:,:)=0.
-      ! dtetafi(:,:)=0.
-      ! dqfi(:,:,:)=0.
-      !          dpfi(:)=0.
-      ! CALL top_bound(vcov,ucov,teta,masse,dufi,dvfi,dtetafi)
-      CALL top_bound(vcov, ucov, teta, masse, dtvr)
-      ! CALL addfi( dtvr, leapf, forward   ,
-      ! $                  ucov, vcov, teta , q   ,ps ,
-      ! $                 dufi, dvfi, dtetafi , dqfi ,dpfi  )
-    ENDIF ! of IF (ok_strato)
-  ENDIF ! of IF (iflag_phys.EQ.2)
-
-
-  !-jld
-
-  CALL pression (ip1jmp1, ap, bp, ps, p)
-  IF (pressure_exner) THEN
-    CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
-  else
-    CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
-  ENDIF
-  CALL massdair(p, masse)
-
-  CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1196')
-
-  !-----------------------------------------------------------------------
-  !   dissipation horizontale et verticale  des petites echelles:
-  !   ----------------------------------------------------------
-
-  IF(apdiss) THEN
-
-
-    !   calcul de l'energie cinetique avant dissipation
-    CALL covcont(llm, ucov, vcov, ucont, vcont)
-    CALL enercin(vcov, ucov, vcont, ucont, ecin0)
-
-    !   dissipation
-    CALL dissip(vcov, ucov, teta, p, dvdis, dudis, dtetadis)
-    ucov = ucov + dudis
-    vcov = vcov + dvdis
-    ! teta=teta+dtetadis
-
-
-    !------------------------------------------------------------------------
-    IF (dissip_conservative) THEN
-      ! On rajoute la tendance due a la transform. Ec -> E therm. cree
-      ! lors de la dissipation
-      CALL covcont(llm, ucov, vcov, ucont, vcont)
-      CALL enercin(vcov, ucov, vcont, ucont, ecin)
-      dtetaecdt = (ecin0 - ecin) / pk
-      ! teta=teta+dtetaecdt
-      dtetadis = dtetadis + dtetaecdt
-    endif
-    teta = teta + dtetadis
-    !------------------------------------------------------------------------
-
-
-    !    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
-    !   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
-    !
-
-    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
-
-    IF (1 == 0) THEN
-      !!! Ehouarn: lines here 1) kill 1+1=2 in the dynamics
-      !!!                     2) should probably not be here anyway
-      !!! but are kept for those who would want to revert to previous behaviour
-      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 ! of if (1 == 0)
-
-  END IF ! of IF(apdiss)
-
-  ! ajout debug
-  ! IF( lafin ) THEN
-  !   abort_message = 'Simulation finished'
-  !   CALL abort_gcm(modname,abort_message,0)
-  ! ENDIF
-
-  !   ********************************************************************
-  !   ********************************************************************
-  !   .... fin de l'integration dynamique  et physique pour le pas itau ..
-  !   ********************************************************************
-  !   ********************************************************************
-
-  !   preparation du pas d'integration suivant  ......
-
-  CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1509')
-
-  IF (.NOT.purmats) THEN
-    ! ........................................................
-    ! ..............  schema matsuno + leapfrog  ..............
-    ! ........................................................
-
-    IF(forward .OR. leapf) THEN
-      itau = itau + 1
-      ! iday= day_ini+itau/day_step
-      ! time= REAL(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 == itaufinp1) THEN
-      IF (flag_verif) THEN
-        WRITE(79, *) 'ucov', ucov
-        WRITE(80, *) 'vcov', vcov
-        WRITE(81, *) 'teta', teta
-        WRITE(82, *) 'ps', ps
-        WRITE(83, *) 'q', q
-        WRITE(85, *) 'q1 = ', q(:, :, 1)
-        WRITE(86, *) 'q3 = ', q(:, :, 3)
-      endif
-
-      abort_message = 'Simulation finished'
-
-      CALL abort_gcm(modname, abort_message, 0)
-    ENDIF
-    !-----------------------------------------------------------------------
-    !   ecriture du fichier histoire moyenne:
-    !   -------------------------------------
-
-    IF(MOD(itau, iperiod)==0 .OR. itau==itaufin) THEN
-      IF(itau==itaufin) THEN
-        iav = 1
-      ELSE
-        iav = 0
-      ENDIF
-
-      ! Ehouarn: re-compute geopotential for outputs
-      CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
-
-      IF (ok_dynzon) THEN
-        CALL bilan_dyn(2, dtvr * iperiod, dtvr * day_step * periodav, &
-                ps, masse, pk, pbaru, pbarv, teta, phi, ucov, vcov, q)
-      END IF
-      IF (ok_dyn_ave) THEN
-        CALL writedynav(itau, vcov, &
-                ucov, teta, pk, phi, q, masse, ps, phis)
-      ENDIF
-
-    ENDIF ! of IF((MOD(itau,iperiod).EQ.0).OR.(itau.EQ.itaufin))
-
-    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1584')
-
-    !-----------------------------------------------------------------------
-    !   ecriture de la bande histoire:
-    !   ------------------------------
-
-    IF(MOD(itau, iecri)==0) THEN
-      ! ! Ehouarn: output only during LF or Backward Matsuno
-      IF (leapf.OR.(.NOT.leapf.AND.(.NOT.forward))) THEN
-        CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
-        unat = 0.
-        DO l = 1, llm
-          unat(iip2:ip1jm, l) = ucov(iip2:ip1jm, l) / cu(iip2:ip1jm)
-          vnat(:, l) = vcov(:, l) / cv(:)
-        enddo
-        IF (ok_dyn_ins) THEN
-          ! WRITE(lunout,*) "leapfrog: CALL writehist, itau=",itau
-          CALL writehist(itau, vcov, ucov, teta, phi, q, masse, ps, phis)
-          ! CALL WriteField('ucov',reshape(ucov,(/iip1,jmp1,llm/)))
-          ! CALL WriteField('vcov',reshape(vcov,(/iip1,jjm,llm/)))
-          ! CALL WriteField('teta',reshape(teta,(/iip1,jmp1,llm/)))
-          !  CALL WriteField('ps',reshape(ps,(/iip1,jmp1/)))
-          !  CALL WriteField('masse',reshape(masse,(/iip1,jmp1,llm/)))
-        endif ! of if (ok_dyn_ins)
-        ! For some Grads outputs of fields
-        IF (output_grads_dyn) THEN
-          INCLUDE "write_grads_dyn.h"
-        endif
-      endif ! of if (leapf.OR.(.NOT.leapf.AND.(.NOT.forward)))
-    ENDIF ! of IF(MOD(itau,iecri).EQ.0)
-
-    IF(itau==itaufin) THEN
-
-
-      ! if (planet_type.EQ."earth") THEN
-      ! Write an Earth-format restart file
-      CALL dynredem1("restart.nc", start_time, &
-              vcov, ucov, teta, q, masse, ps)
-      ! END IF ! of if (planet_type.EQ."earth")
-
-      CLOSE(99)
-      IF (ok_guide) THEN
-        ! ! set ok_guide to false to avoid extra output
-        ! ! in following forward step
-        ok_guide = .FALSE.
-      endif
-      ! !!! Ehouarn: Why not stop here and now?
-    ENDIF ! of IF (itau.EQ.itaufin)
-
-    !-----------------------------------------------------------------------
-    !   gestion de l'integration temporelle:
-    !   ------------------------------------
-
-    IF(MOD(itau, iperiod)==0)    THEN
-      GO TO 1
-    ELSE IF (MOD(itau - 1, iperiod) == 0) THEN
-
-      IF(forward)  THEN
-        ! fin du pas forward et debut du pas backward
-
-        forward = .FALSE.
-        leapf = .FALSE.
-        GO TO 2
-
-      ELSE
-        ! fin du pas backward et debut du premier pas leapfrog
-
-        leapf = .TRUE.
-        dt = 2. * dtvr
-        GO TO 2
-      END IF ! of IF (forward)
-    ELSE
-
-      ! ......   pas leapfrog  .....
-
-      leapf = .TRUE.
-      dt = 2. * dtvr
-      GO TO 2
-    END IF ! of IF (MOD(itau,iperiod).EQ.0)
-    ! !    ELSEIF (MOD(itau-1,iperiod).EQ.0)
-
-  ELSE ! of IF (.NOT.purmats)
-
-    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1664')
-
-    ! ........................................................
-    ! ..............       schema  matsuno        ...............
-    ! ........................................................
-    IF(forward)  THEN
-
-      itau = itau + 1
-      ! iday = day_ini+itau/day_step
-      ! time = REAL(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 == itaufinp1) THEN
-        abort_message = 'Simulation finished'
-        CALL abort_gcm(modname, abort_message, 0)
-      ENDIF
-      GO TO 2
-
-    ELSE ! of IF(forward) i.e. backward step
-
-      CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1698')
-
-      IF(MOD(itau, iperiod)==0 .OR. itau==itaufin) THEN
-        IF(itau==itaufin) THEN
-          iav = 1
-        ELSE
-          iav = 0
-        ENDIF
-
-        ! ! Ehouarn: re-compute geopotential for outputs
-        CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
-
-        IF (ok_dynzon) THEN
-          CALL bilan_dyn(2, dtvr * iperiod, dtvr * day_step * periodav, &
-                  ps, masse, pk, pbaru, pbarv, teta, phi, ucov, vcov, q)
-        ENDIF
-        IF (ok_dyn_ave) THEN
-          CALL writedynav(itau, vcov, &
-                  ucov, teta, pk, phi, q, masse, ps, phis)
-        ENDIF
-
-      ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
-
-      IF(MOD(itau, iecri)==0) THEN
-        ! IF(MOD(itau,iecri*day_step).EQ.0) THEN
-        CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
-        unat = 0.
-        DO l = 1, llm
-          unat(iip2:ip1jm, l) = ucov(iip2:ip1jm, l) / cu(iip2:ip1jm)
-          vnat(:, l) = vcov(:, l) / cv(:)
-        enddo
-        IF (ok_dyn_ins) THEN
-          ! WRITE(lunout,*) "leapfrog: CALL writehist (b)",
-          ! &                        itau,iecri
-          CALL writehist(itau, vcov, ucov, teta, phi, q, masse, ps, phis)
-        endif ! of if (ok_dyn_ins)
-        ! For some Grads outputs
-        IF (output_grads_dyn) THEN
-          INCLUDE "write_grads_dyn.h"
-        endif
-
-      ENDIF ! of IF(MOD(itau,iecri         ).EQ.0)
-
-      IF(itau==itaufin) THEN
-        ! if (planet_type.EQ."earth") THEN
-        CALL dynredem1("restart.nc", start_time, &
-                vcov, ucov, teta, q, masse, ps)
-        ! END IF ! of if (planet_type.EQ."earth")
-        IF (ok_guide) THEN
-          ! ! set ok_guide to false to avoid extra output
-          ! ! in following forward step
-          ok_guide = .FALSE.
-        endif
-      ENDIF ! of IF(itau.EQ.itaufin)
-
-      forward = .TRUE.
-      GO TO  1
-
-    ENDIF ! of IF (forward)
-
-  END IF ! of IF(.NOT.purmats)
-
-END SUBROUTINE leapfrog
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_addfi.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_addfi.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_addfi.f90	(revision 5186)
@@ -0,0 +1,176 @@
+MODULE lmdz_addfi
+  IMPLICIT NONE; PRIVATE
+  PUBLIC addfi
+
+CONTAINS
+
+  SUBROUTINE addfi(pdt, leapf, forward, pucov, pvcov, pteta, pq, pps, pdufi, pdvfi, pdhfi, pdqfi, pdpfi)
+
+    USE lmdz_infotrac, ONLY: nqtot
+    USE control_mod, ONLY: planet_type
+    USE lmdz_ssum_scopy, ONLY: ssum
+    USE lmdz_comgeom
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+
+    IMPLICIT NONE
+
+    !=======================================================================
+
+    !    Addition of the physical tendencies
+
+    !    Interface :
+    !    -----------
+
+    !  Input :
+    !  -------
+    !  pdt                    time step of integration
+    !  leapf                  logical
+    !  forward                logical
+    !  pucov(ip1jmp1,llm)     first component of the covariant velocity
+    !  pvcov(ip1ip1jm,llm)    second component of the covariant velocity
+    !  pteta(ip1jmp1,llm)     potential temperature
+    !  pts(ip1jmp1,llm)       surface temperature
+    !  pdufi(ip1jmp1,llm)     |
+    !  pdvfi(ip1jm,llm)       |   respective
+    !  pdhfi(ip1jmp1)         |      tendencies
+    !  pdtsfi(ip1jmp1)        |
+
+    !  Output :
+    !  --------
+    !  pucov
+    !  pvcov
+    !  ph
+    !  pts
+
+
+    !=======================================================================
+    !  !
+    !    Arguments :
+    !    -----------
+
+    REAL, INTENT(IN) :: pdt ! time step for the integration (s)
+
+    REAL, INTENT(INOUT) :: pvcov(ip1jm, llm) ! covariant meridional wind
+    REAL, INTENT(INOUT) :: pucov(ip1jmp1, llm) ! covariant zonal wind
+    REAL, INTENT(INOUT) :: pteta(ip1jmp1, llm) ! potential temperature
+    REAL, INTENT(INOUT) :: pq(ip1jmp1, llm, nqtot) ! tracers
+    REAL, INTENT(INOUT) :: pps(ip1jmp1) ! surface pressure (Pa)
+    ! respective tendencies (.../s) to add
+    REAL, INTENT(IN) :: pdvfi(ip1jm, llm)
+    REAL, INTENT(IN) :: pdufi(ip1jmp1, llm)
+    REAL, INTENT(IN) :: pdqfi(ip1jmp1, llm, nqtot)
+    REAL, INTENT(IN) :: pdhfi(ip1jmp1, llm)
+    REAL, INTENT(IN) :: pdpfi(ip1jmp1)
+
+    LOGICAL, INTENT(IN) :: leapf, forward ! not used
+
+
+    !    Local variables :
+    !    -----------------
+
+    REAL :: xpn(iim), xps(iim), tpn, tps
+    INTEGER :: j, k, iq, ij
+    REAL, PARAMETER :: qtestw = 1.0e-15
+    REAL, PARAMETER :: qtestt = 1.0e-40
+
+    !-----------------------------------------------------------------------
+
+    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
+    !
+
+    DO k = 1, llm
+      DO j = iip2, ip1jm
+        pucov(j, k) = pucov(j, k) + pdufi(j, k) * pdt
+      ENDDO
+    ENDDO
+
+    DO k = 1, llm
+      DO j = 1, ip1jm
+        pvcov(j, k) = pvcov(j, k) + pdvfi(j, k) * pdt
+      ENDDO
+    ENDDO
+
+    DO j = 1, ip1jmp1
+      pps(j) = pps(j) + pdpfi(j) * pdt
+    ENDDO
+
+    IF (planet_type=="earth") THEN
+      ! earth case, special treatment for first 2 tracers (water)
+      DO iq = 1, 2
+        DO k = 1, llm
+          DO j = 1, ip1jmp1
+            pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
+            pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestw)
+          ENDDO
+        ENDDO
+      ENDDO
+
+      DO iq = 3, nqtot
+        DO k = 1, llm
+          DO j = 1, ip1jmp1
+            pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
+            pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
+          ENDDO
+        ENDDO
+      ENDDO
+    else
+      ! general case, treat all tracers equally)
+      DO iq = 1, nqtot
+        DO k = 1, llm
+          DO j = 1, ip1jmp1
+            pq(j, k, iq) = pq(j, k, iq) + pdqfi(j, k, iq) * pdt
+            pq(j, k, iq) = AMAX1(pq(j, k, iq), qtestt)
+          ENDDO
+        ENDDO
+      ENDDO
+    ENDIF ! of if (planet_type=="earth")
+
+    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
+
+    DO iq = 1, nqtot
+      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
+
+  END SUBROUTINE addfi
+END MODULE lmdz_addfi
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_advect.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_advect.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_advect.f90	(revision 5186)
@@ -0,0 +1,170 @@
+MODULE lmdz_advect
+  IMPLICIT NONE; PRIVATE
+  PUBLIC advect
+
+CONTAINS
+
+  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
+    USE lmdz_ssum_scopy, ONLY: ssum
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+    !=======================================================================
+
+    !   Auteurs:  P. Le Van , Fr. Hourdin  .
+    !   -------
+
+    !   Objet:
+    !   ------
+
+    !   *************************************************************
+    !   .... calcul des termes d'advection vertic.pour u,v,teta,q ...
+    !   *************************************************************
+    !    ces termes sont ajoutes a du,dv,dteta et dq .
+    !  Modif F.Forget 03/94 : on retire q de advect
+
+    !=======================================================================
+    !-----------------------------------------------------------------------
+    !   Declarations:
+    !   -------------
+
+
+
+
+    !   Arguments:
+    !   ----------
+
+    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)
+
+    !   Local:
+    !   ------
+
+    REAL :: uav(ip1jmp1, llm), vav(ip1jm, llm), wsur2(ip1jmp1)
+    REAL :: unsaire2(ip1jmp1), ge(ip1jmp1)
+    REAL :: deuxjour, ww, gt, uu, vv
+
+    INTEGER :: ij, l
+
+    !-----------------------------------------------------------------------
+    !   2. Calculs preliminaires:
+    !   -------------------------
+
+    IF (conser)  THEN
+      deuxjour = 2. * daysec
+
+      DO   ij = 1, ip1jmp1
+        unsaire2(ij) = unsaire(ij) * unsaire(ij)
+      END DO
+    END IF
+
+
+    !------------------  -yy ----------------------------------------------
+    !   .  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
+
+    !------------------  -xx ----------------------------------------------
+    !   .  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
+
+    !-----------------------------------------------------------------------
+
+    DO l = 1, llmm1
+
+
+      ! ......   calcul de  - w/2.    au niveau  l+1   .......
+
+      DO ij = 1, ip1jmp1
+        wsur2(ij) = - 0.5 * w(ij, l + 1)
+      END DO
+
+
+      ! .....................     calcul pour  du     ..................
+
+      DO 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)
+      END DO
+
+      ! .....  correction pour  du(iip1,j,l)  ........
+      ! .....     du(iip1,j,l)= du(1,j,l)   .....
+
+      !DIR$ IVDEP
+      DO   ij = iip1 + iip1, ip1jm, iip1
+        du(ij, l) = du(ij - iim, l)
+        du(ij, l + 1) = du(ij - iim, l + 1)
+      END DO
+
+      ! .................    calcul pour   dv      .....................
+
+      DO 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)
+      END DO
+
+      !
+
+      ! ............................................................
+      ! ...............    calcul pour   dh      ...................
+      ! ............................................................
+
+      !                   ---z
+      !   calcul de  - d( teta  * w )      qu'on ajoute a   dh
+      !               ...............
+
+      DO 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
+      END DO
+
+      IF(conser)  THEN
+        DO ij = 1, ip1jmp1
+          ge(ij) = wsur2(ij) * wsur2(ij) * unsaire2(ij)
+        END DO
+        gt = SSUM(ip1jmp1, ge, 1)
+        gtot(l) = deuxjour * SQRT(gt / ip1jmp1)
+      END IF
+
+    END DO
+
+  END SUBROUTINE advect
+
+END MODULE lmdz_advect
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_advtrac.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_advtrac.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_advtrac.f90	(revision 5186)
@@ -0,0 +1,366 @@
+MODULE lmdz_advtrac
+  IMPLICIT NONE; PRIVATE
+  PUBLIC advtrac
+
+CONTAINS
+
+  SUBROUTINE advtrac(pbaru, pbarv, p, masse, q, iapptrac, teta, flxw, pk)
+    !     Auteur :  F. Hourdin
+
+    !     Modif. P. Le Van     (20/12/97)
+    !            F. Codron     (10/99)
+    !            D. Le Croller (07/2001)
+    !            M.A Filiberti (04/2002)
+
+    USE lmdz_infotrac, ONLY: nqtot, tracers, isoCheck
+    USE control_mod, ONLY: iapp_tracvl, day_step
+    USE comconst_mod, ONLY: dtvr
+    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
+    USE lmdz_strings, ONLY: int2str
+    USE lmdz_description, ONLY: descript
+    USE lmdz_libmath, ONLY: minmax
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_ssum_scopy, ONLY: scopy
+    USE lmdz_comdissip, ONLY: coefdis, tetavel, tetatemp, gamdissip, niterdis
+    USE lmdz_comgeom2
+    USE lmdz_groupe, ONLY: groupe
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    USE lmdz_check_isotopes, ONLY: check_isotopes_seq
+
+    IMPLICIT NONE
+
+
+
+
+    !---------------------------------------------------------------------------
+    !     Arguments
+    !---------------------------------------------------------------------------
+    INTEGER, INTENT(OUT) :: iapptrac
+    REAL, INTENT(IN) :: pbaru(ip1jmp1, llm)
+    REAL, INTENT(IN) :: pbarv(ip1jm, llm)
+    REAL, INTENT(INOUT) :: q(ip1jmp1, llm, nqtot)
+    REAL, INTENT(IN) :: masse(ip1jmp1, llm)
+    REAL, INTENT(IN) :: p(ip1jmp1, llmp1)
+    REAL, INTENT(IN) :: teta(ip1jmp1, llm)
+    REAL, INTENT(IN) :: pk(ip1jmp1, llm)
+    REAL, INTENT(OUT) :: flxw(ip1jmp1, llm)
+    !---------------------------------------------------------------------------
+    !     Ajout PPM
+    !---------------------------------------------------------------------------
+    REAL :: massebx(ip1jmp1, llm), masseby(ip1jm, llm)
+    !---------------------------------------------------------------------------
+    !     Variables locales
+    !---------------------------------------------------------------------------
+    INTEGER :: ij, l, iq, iadv
+    !   REAL(KIND=KIND(1.d0)) :: t_initial, t_final, tps_cpu
+    REAL :: zdp(ip1jmp1), zdpmin, zdpmax
+    INTEGER, SAVE :: iadvtr = 0
+    REAL, DIMENSION(ip1jmp1, llm) :: pbaruc, pbarug, massem, wg
+    REAL, DIMENSION(ip1jm, llm) :: pbarvc, pbarvg
+    SAVE massem, pbaruc, pbarvc
+    !---------------------------------------------------------------------------
+    !     Rajouts pour PPM
+    !---------------------------------------------------------------------------
+    INTEGER indice, n
+    REAL :: dtbon                       ! Pas de temps adaptatif pour que CFL<1
+    REAL :: CFLmaxz, aaa, bbb           ! CFL maximum
+    REAL, DIMENSION(iim, jjp1, llm) :: unatppm, vnatppm, fluxwppm
+    REAL :: qppm(iim * jjp1, llm, nqtot)
+    REAL :: psppm(iim, jjp1)           ! pression  au sol
+    REAL, DIMENSION(llmp1) :: apppm, bpppm
+    LOGICAL, SAVE :: dum = .TRUE., fill = .TRUE.
+
+    INTEGER, SAVE :: countcfl = 0
+    REAL, DIMENSION(ip1jmp1, llm) :: cflx, cflz
+    REAL, DIMENSION(ip1jm, llm) :: cfly
+    REAL, DIMENSION(llm), SAVE :: cflxmax, cflymax, cflzmax
+
+    IF(iadvtr == 0) THEN
+      pbaruc(:, :) = 0
+      pbarvc(:, :) = 0
+    END IF
+
+    !--- Accumulation des flux de masse horizontaux
+    DO l = 1, llm
+      DO ij = 1, ip1jmp1
+        pbaruc(ij, l) = pbaruc(ij, l) + pbaru(ij, l)
+      END DO
+      DO ij = 1, ip1jm
+        pbarvc(ij, l) = pbarvc(ij, l) + pbarv(ij, l)
+      END DO
+    END DO
+
+    !--- Selection de la masse instantannee des mailles avant le transport.
+    IF(iadvtr == 0) THEN
+      CALL SCOPY(ip1jmp1 * llm, masse, 1, massem, 1)
+      ! CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 )
+    END IF
+
+    iadvtr = iadvtr + 1
+    iapptrac = iadvtr
+
+    !--- Test pour savoir si on advecte a ce pas de temps
+    IF(iadvtr /= iapp_tracvl) RETURN
+
+    !   ..  Modif P.Le Van  ( 20/12/97 )  ....
+
+    !   traitement des flux de masse avant advection.
+    !       1. calcul de w
+    !       2. groupement des mailles pres du pole.
+
+    CALL groupe(pbaruc, pbarvc, pbarug, pbarvg, wg)
+
+    !--- Flux de masse diaganostiques traceurs
+    flxw = wg / REAL(iapp_tracvl)
+
+    !--- 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) &
+                - pbarvg(ij - iip1, l) + pbarvg(ij, l) &
+                + wg(ij, l + 1) - wg(ij, l)
+      END DO
+      ! ym  ---> pourquoi jjm-1 et non jjm ? a cause du pole ?
+      CALL SCOPY(jjm - 1, zdp(iip1 + iip1), iip1, zdp(iip2), iip1)
+      DO ij = iip2, ip1jm
+        zdp(ij) = zdp(ij) * dtvr / massem(ij, l)
+      END DO
+
+      CALL minmax (ip1jm - iip1, zdp(iip2), zdpmin, zdpmax)
+
+      IF(MAX(ABS(zdpmin), ABS(zdpmax)) > 0.5) &
+              WRITE(*, *)'WARNING DP/P l=', l, '  MIN:', zdpmin, ' MAX:', zdpmax
+
+    END DO
+
+    !-------------------------------------------------------------------------
+    ! Calcul des criteres CFL en X, Y et Z
+    !-------------------------------------------------------------------------
+    IF(countcfl == 0.) THEN
+      cflxmax(:) = 0.
+      cflymax(:) = 0.
+      cflzmax(:) = 0.
+    END IF
+
+    countcfl = countcfl + iapp_tracvl
+    cflx(:, :) = 0.
+    cfly(:, :) = 0.
+    cflz(:, :) = 0.
+    DO l = 1, llm
+      DO ij = iip2, ip1jm - 1
+        IF(pbarug(ij, l)>=0.) THEN
+          cflx(ij, l) = pbarug(ij, l) * dtvr / masse(ij, l)
+        ELSE
+          cflx(ij, l) = -pbarug(ij, l) * dtvr / masse(ij + 1, l)
+        END IF
+      END DO
+    END DO
+
+    DO l = 1, llm
+      DO ij = iip2, ip1jm - 1, iip1
+        cflx(ij + iip1, l) = cflx(ij, l)
+      END DO
+    END DO
+
+    DO l = 1, llm
+      DO ij = 1, ip1jm
+        IF(pbarvg(ij, l)>=0.) THEN
+          cfly(ij, l) = pbarvg(ij, l) * dtvr / masse(ij, l)
+        ELSE
+          cfly(ij, l) = -pbarvg(ij, l) * dtvr / masse(ij + iip1, l)
+        END IF
+      END DO
+    END DO
+
+    DO l = 2, llm
+      DO ij = 1, ip1jm
+        IF(wg(ij, l) >= 0.) THEN
+          cflz(ij, l) = wg(ij, l) * dtvr / masse(ij, l)
+        ELSE
+          cflz(ij, l) = -wg(ij, l) * dtvr / masse(ij, l - 1)
+        END IF
+      END DO
+    END DO
+
+    DO l = 1, llm
+      cflxmax(l) = max(cflxmax(l), maxval(cflx(:, l)))
+      cflymax(l) = max(cflymax(l), maxval(cfly(:, l)))
+      cflzmax(l) = max(cflzmax(l), maxval(cflz(:, l)))
+    END DO
+
+    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    ! Par defaut, on sort le diagnostic des CFL tous les jours.
+    ! Si on veut le sortir a chaque pas d'advection en cas de plantage
+    !       IF(countcfl==iapp_tracvl) THEN
+    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    IF(countcfl==day_step) THEN
+      DO l = 1, llm
+        WRITE(lunout, *) 'L, CFL[xyz]max:', l, cflxmax(l), cflymax(l), cflzmax(l)
+      END DO
+      countcfl = 0
+    END IF
+
+    !---------------------------------------------------------------------------
+    !   Advection proprement dite (Modification Le Croller (07/2001)
+    !---------------------------------------------------------------------------
+
+    !---------------------------------------------------------------------------
+    !   Calcul des moyennes basees sur la masse
+    !---------------------------------------------------------------------------
+    CALL massbar(massem, massebx, masseby)
+
+    IF (CPPKEY_DEBUGIO) THEN
+      CALL WriteField_u('massem', massem)
+      CALL WriteField_u('wg', wg)
+      CALL WriteField_u('pbarug', pbarug)
+      CALL WriteField_v('pbarvg', pbarvg)
+      CALL WriteField_u('p_tmp', p)
+      CALL WriteField_u('pk_tmp', pk)
+      CALL WriteField_u('teta_tmp', teta)
+      DO iq = 1, nqtot
+        CALL WriteField_u('q_adv' // trim(int2str(iq)), q(:, :, iq))
+      END DO
+    END IF
+
+    IF(isoCheck) WRITE(*, *) 'advtrac 227'
+    CALL check_isotopes_seq(q, ip1jmp1, 'advtrac 162')
+
+    !-------------------------------------------------------------------------
+    !       Appel des sous programmes d'advection
+    !-------------------------------------------------------------------------
+    DO iq = 1, nqtot
+      !     CALL clock(t_initial)
+      IF(tracers(iq)%parent /= 'air') CYCLE
+      iadv = tracers(iq)%iadv
+      !-----------------------------------------------------------------------
+      SELECT CASE(iadv)
+        !-----------------------------------------------------------------------
+      CASE(0); CYCLE
+      !--------------------------------------------------------------------
+      CASE(10)  !--- Schema de Van Leer I MUSCL
+        !--------------------------------------------------------------------
+        !           WRITE(*,*) 'advtrac 239: iq,q(1721,19,:)=',iq,q(1721,19,:)
+        CALL vlsplt(q, 2., massem, wg, pbarug, pbarvg, dtvr, iq)
+
+        !--------------------------------------------------------------------
+      CASE(14)  !--- Schema "pseuDO amont" + test sur humidite specifique
+        !--- pour la vapeur d'eau. F. Codron
+        !--------------------------------------------------------------------
+        !           WRITE(*,*) 'advtrac 248: iq,q(1721,19,:)=',iq,q(1721,19,:)
+        CALL vlspltqs(q, 2., massem, wg, pbarug, pbarvg, dtvr, p, pk, teta, iq)
+
+        !--------------------------------------------------------------------
+      CASE(12)  !--- Schema de Frederic Hourdin
+        !--------------------------------------------------------------------
+        CALL adaptdt(iadv, dtbon, n, pbarug, massem)   ! pas de temps adaptatif
+        IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
+        DO indice = 1, n
+          CALL advn(q(1, 1, iq), massem, wg, pbarug, pbarvg, dtbon, 1)
+        END DO
+
+        !--------------------------------------------------------------------
+      CASE(13)  !--- Pas de temps adaptatif
+        !--------------------------------------------------------------------
+        CALL adaptdt(iadv, dtbon, n, pbarug, massem)
+        IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
+        DO indice = 1, n
+          CALL advn(q(1, 1, iq), massem, wg, pbarug, pbarvg, dtbon, 2)
+        END DO
+
+        !--------------------------------------------------------------------
+      CASE(20)  !--- Schema de pente SLOPES
+        !--------------------------------------------------------------------
+        CALL pentes_ini (q(1, 1, iq), wg, massem, pbarug, pbarvg, 0)
+
+        !--------------------------------------------------------------------
+      CASE(30)  !--- Schema de Prather
+        !--------------------------------------------------------------------
+        ! Pas de temps adaptatif
+        CALL adaptdt(iadv, dtbon, n, pbarug, massem)
+        IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
+        CALL prather(q(1, 1, iq), wg, massem, pbarug, pbarvg, n, dtbon)
+
+        !--------------------------------------------------------------------
+      CASE(11, 16, 17, 18)   !--- Schemas PPM Lin et Rood
+        !--------------------------------------------------------------------
+        ! Test sur le flux horizontal
+        CALL adaptdt(iadv, dtbon, n, pbarug, massem)   ! pas de temps adaptatif
+        IF(n > 1) WRITE(*, *) 'WARNING horizontal dt=', dtbon, 'dtvr=', dtvr, 'n=', n
+        ! Test sur le flux vertical
+        CFLmaxz = 0.
+        DO l = 2, llm
+          DO ij = iip2, ip1jm
+            aaa = wg(ij, l) * dtvr / massem(ij, l)
+            CFLmaxz = max(CFLmaxz, aaa)
+            bbb = -wg(ij, l) * dtvr / massem(ij, l - 1)
+            CFLmaxz = max(CFLmaxz, bbb)
+          END DO
+        END DO
+        IF(CFLmaxz>=1) WRITE(*, *) 'WARNING vertical', 'CFLmaxz=', CFLmaxz
+        !----------------------------------------------------------------
+        !     Ss-prg interface LMDZ.4->PPM3d (ss-prg de Lin)
+        !----------------------------------------------------------------
+        CALL interpre(q(1, 1, iq), qppm(1, 1, iq), wg, fluxwppm, massem, &
+                apppm, bpppm, massebx, masseby, pbarug, pbarvg, &
+                unatppm, vnatppm, psppm)
+
+        !----------------------------------------------------------------
+        DO indice = 1, n     !--- VL (version PPM) horiz. et PPM vert.
+          !----------------------------------------------------------------
+          SELECT CASE(iadv)
+            !----------------------------------------------------------
+          CASE(11)
+            !----------------------------------------------------------
+            CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
+                    2, 2, 2, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
+            !----------------------------------------------------------
+          CASE(16) !--- Monotonic PPM
+            !----------------------------------------------------------
+            CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
+                    3, 3, 3, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
+            !----------------------------------------------------------
+          CASE(17) !--- Semi monotonic PPM
+            !----------------------------------------------------------
+            CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
+                    4, 4, 4, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
+            !----------------------------------------------------------
+          CASE(18) !--- Positive Definite PPM
+            !----------------------------------------------------------
+            CALL ppm3d(1, qppm(1, 1, iq), psppm, psppm, unatppm, vnatppm, fluxwppm, dtbon, &
+                    5, 5, 5, 1, iim, jjp1, 2, llm, apppm, bpppm, 0.01, 6400000, fill, dum, 220.)
+          END SELECT
+          !----------------------------------------------------------------
+        END DO
+        !----------------------------------------------------------------
+        !     Ss-prg interface PPM3d-LMDZ.4
+        !----------------------------------------------------------------
+        CALL interpost(q(1, 1, iq), qppm(1, 1, iq))
+        !----------------------------------------------------------------------
+      END SELECT
+      !----------------------------------------------------------------------
+
+      !----------------------------------------------------------------------
+      ! On impose une seule valeur du traceur au pole Sud j=jjm+1=jjp1 et Nord j=1
+      !----------------------------------------------------------------------
+      !  CALL traceurpole(q(1,1,iq),massem)
+
+      !--- Calcul du temps cpu pour un schema donne
+      !  CALL clock(t_final)
+      !ym  tps_cpu=t_final-t_initial
+      !ym  cpuadv(iq)=cpuadv(iq)+tps_cpu
+
+    END DO
+
+    IF(isoCheck) WRITE(*, *) 'advtrac 402'
+    CALL check_isotopes_seq(q, ip1jmp1, 'advtrac 397')
+
+    !-------------------------------------------------------------------------
+    !   on reinitialise a zero les flux de masse cumules
+    !-------------------------------------------------------------------------
+    iadvtr = 0
+
+  END SUBROUTINE advtrac
+
+END MODULE lmdz_advtrac
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_bilan_dyn.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_bilan_dyn.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_bilan_dyn.f90	(revision 5186)
@@ -0,0 +1,588 @@
+MODULE lmdz_bilan_dyn
+  IMPLICIT NONE; PRIVATE
+  PUBLIC bilan_dyn
+
+CONTAINS
+
+
+  SUBROUTINE bilan_dyn(ntrac, dt_app, dt_cum, &
+          ps, masse, pk, flux_u, flux_v, teta, phi, ucov, vcov, trac)
+
+    !   AFAIRE
+    !   Prevoir en champ nq+1 le diagnostique de l'energie
+    !   en faisant Qzon=Cv T + L * ...
+    !             vQ..A=Cp T + L * ...
+
+    USE IOIPSL
+    USE comconst_mod, ONLY: pi, cpp
+    USE comvert_mod, ONLY: presnivs
+    USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_comgeom2
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+
+
+
+    !====================================================================
+
+    !   Sous-programme consacre à des diagnostics dynamiques de base
+
+
+    !   De facon generale, les moyennes des scalaires Q sont ponderees par
+    !   la masse.
+
+    !   Les flux de masse sont eux simplement moyennes.
+
+    !====================================================================
+
+    !   Arguments :
+    !   ===========
+
+    INTEGER :: ntrac
+    REAL :: dt_app, dt_cum
+    REAL :: ps(iip1, jjp1)
+    REAL :: masse(iip1, jjp1, llm), pk(iip1, jjp1, llm)
+    REAL :: flux_u(iip1, jjp1, llm)
+    REAL :: flux_v(iip1, jjm, llm)
+    REAL :: teta(iip1, jjp1, llm)
+    REAL :: phi(iip1, jjp1, llm)
+    REAL :: ucov(iip1, jjp1, llm)
+    REAL :: vcov(iip1, jjm, llm)
+    REAL :: trac(iip1, jjp1, llm, ntrac)
+
+    !   Local :
+    !   =======
+
+    INTEGER :: icum, ncum
+    LOGICAL :: first
+    REAL :: zz, zqy, zfactv(jjm, llm)
+
+    INTEGER :: nQ
+    parameter (nQ = 7)
+
+
+    !ym      CHARACTER*6 nom(nQ)
+    !ym      CHARACTER*6 unites(nQ)
+    CHARACTER*6, save :: nom(nQ)
+    CHARACTER*6, save :: unites(nQ)
+
+    CHARACTER(LEN = 10) :: file
+    INTEGER :: ifile
+    parameter (ifile = 4)
+
+    INTEGER :: itemp, igeop, iecin, iang, iu, iovap, iun
+    INTEGER :: i_sortie
+
+    save first, icum, ncum
+    save itemp, igeop, iecin, iang, iu, iovap, iun
+    save i_sortie
+
+    REAL :: time
+    INTEGER :: itau
+    save time, itau
+    data time, itau/0., 0/
+
+    data first/.TRUE./
+    data itemp, igeop, iecin, iang, iu, iovap, iun/1, 2, 3, 4, 5, 6, 7/
+    data i_sortie/1/
+
+    REAL :: ww
+
+    !   variables dynamiques intermédiaires
+    REAL :: vcont(iip1, jjm, llm), ucont(iip1, jjp1, llm)
+    REAL :: ang(iip1, jjp1, llm), unat(iip1, jjp1, llm)
+    REAL :: massebx(iip1, jjp1, llm), masseby(iip1, jjm, llm)
+    REAL :: vorpot(iip1, jjm, llm)
+    REAL :: w(iip1, jjp1, llm), ecin(iip1, jjp1, llm), convm(iip1, jjp1, llm)
+    REAL :: bern(iip1, jjp1, llm)
+
+    !   champ contenant les scalaires advectés.
+    REAL :: Q(iip1, jjp1, llm, nQ)
+
+    !   champs cumulés
+    REAL :: ps_cum(iip1, jjp1)
+    REAL :: masse_cum(iip1, jjp1, llm)
+    REAL :: flux_u_cum(iip1, jjp1, llm)
+    REAL :: flux_v_cum(iip1, jjm, llm)
+    REAL :: Q_cum(iip1, jjp1, llm, nQ)
+    REAL :: flux_uQ_cum(iip1, jjp1, llm, nQ)
+    REAL :: flux_vQ_cum(iip1, jjm, llm, nQ)
+    REAL :: flux_wQ_cum(iip1, jjp1, llm, nQ)
+    REAL :: dQ(iip1, jjp1, llm, nQ)
+
+    save ps_cum, masse_cum, flux_u_cum, flux_v_cum
+    save Q_cum, flux_uQ_cum, flux_vQ_cum
+
+    !   champs de tansport en moyenne zonale
+    INTEGER :: ntr, itr
+    parameter (ntr = 5)
+
+    !ym      CHARACTER*10 znom(ntr,nQ)
+    !ym      CHARACTER*20 znoml(ntr,nQ)
+    !ym      CHARACTER*10 zunites(ntr,nQ)
+    CHARACTER*10, save :: znom(ntr, nQ)
+    CHARACTER*20, save :: znoml(ntr, nQ)
+    CHARACTER*10, save :: zunites(ntr, nQ)
+
+    INTEGER :: iave, itot, immc, itrs, istn
+    data iave, itot, immc, itrs, istn/1, 2, 3, 4, 5/
+    CHARACTER(LEN = 3) :: ctrs(ntr)
+    data ctrs/'  ', 'TOT', 'MMC', 'TRS', 'STN'/
+
+    REAL :: zvQ(jjm, llm, ntr, nQ), zvQtmp(jjm, llm)
+    REAL :: zavQ(jjm, ntr, nQ), psiQ(jjm, llm + 1, nQ)
+    REAL :: zmasse(jjm, llm), zamasse(jjm)
+
+    REAL :: zv(jjm, llm), psi(jjm, llm + 1)
+
+    INTEGER :: i, j, l, iQ
+
+
+    !   Initialisation du fichier contenant les moyennes zonales.
+    !   ---------------------------------------------------------
+
+    CHARACTER(LEN = 10) :: infile
+
+    INTEGER :: fileid
+    INTEGER :: thoriid, zvertiid
+    save fileid
+
+    INTEGER :: ndex3d(jjm * llm)
+
+    !   Variables locales
+
+    INTEGER :: tau0
+    REAL :: zjulian
+    CHARACTER(LEN = 3) :: str
+    CHARACTER(LEN = 10) :: ctrac
+    INTEGER :: ii, jj
+    INTEGER :: zan, dayref
+
+    REAL :: rlong(jjm), rlatg(jjm)
+
+
+
+    !=====================================================================
+    !   Initialisation
+    !=====================================================================
+
+    time = time + dt_app
+    itau = itau + 1
+    !IM
+    ndex3d = 0
+
+    IF (first) THEN
+      icum = 0
+      ! initialisation des fichiers
+      first = .FALSE.
+      !   ncum est la frequence de stokage en pas de temps
+      ncum = dt_cum / dt_app
+      IF (abs(ncum * dt_app - dt_cum)>1.e-5 * dt_app) THEN
+        WRITE(lunout, *) &
+                'Pb : le pas de cumule doit etre multiple du pas'
+        WRITE(lunout, *)'dt_app=', dt_app
+        WRITE(lunout, *)'dt_cum=', dt_cum
+        CALL abort_gcm('bilan_dyn', 'stopped', 1)
+      endif
+
+      IF (i_sortie==1) THEN
+        file = 'dynzon'
+        CALL inigrads(ifile, 1 &
+                , 0., 180. / pi, 0., 0., jjm, rlatv, -90., 90., 180. / pi &
+                , llm, presnivs, 1. &
+                , dt_cum, file, 'dyn_zon ')
+      endif
+
+      nom(itemp) = 'T'
+      nom(igeop) = 'gz'
+      nom(iecin) = 'K'
+      nom(iang) = 'ang'
+      nom(iu) = 'u'
+      nom(iovap) = 'ovap'
+      nom(iun) = 'un'
+
+      unites(itemp) = 'K'
+      unites(igeop) = 'm2/s2'
+      unites(iecin) = 'm2/s2'
+      unites(iang) = 'ang'
+      unites(iu) = 'm/s'
+      unites(iovap) = 'kg/kg'
+      unites(iun) = 'un'
+
+
+      !   Initialisation du fichier contenant les moyennes zonales.
+      !   ---------------------------------------------------------
+
+      infile = 'dynzon'
+
+      zan = annee_ref
+      dayref = day_ref
+      CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
+      tau0 = itau_dyn
+
+      rlong = 0.
+      rlatg = rlatv * 180. / pi
+
+      CALL histbeg(infile, 1, rlong, jjm, rlatg, &
+              1, 1, 1, jjm, &
+              tau0, zjulian, dt_cum, thoriid, fileid)
+
+
+      !  Appel a histvert pour la grille verticale
+
+      CALL histvert(fileid, 'presnivs', 'Niveaux sigma', 'mb', &
+              llm, presnivs, zvertiid)
+
+      !  Appels a histdef pour la definition des variables a sauvegarder
+      DO iQ = 1, nQ
+        DO itr = 1, ntr
+          IF(itr==1) THEN
+            znom(itr, iQ) = nom(iQ)
+            znoml(itr, iQ) = nom(iQ)
+            zunites(itr, iQ) = unites(iQ)
+          else
+            znom(itr, iQ) = ctrs(itr) // 'v' // nom(iQ)
+            znoml(itr, iQ) = 'transport : v * ' // nom(iQ) // ' ' // ctrs(itr)
+            zunites(itr, iQ) = 'm/s * ' // unites(iQ)
+          endif
+        enddo
+      enddo
+
+      !   Declarations des champs avec dimension verticale
+      ! PRINT*,'1HISTDEF'
+      DO iQ = 1, nQ
+        DO itr = 1, ntr
+          IF (prt_level > 5) &
+                  WRITE(lunout, *)'var ', itr, iQ &
+                          , znom(itr, iQ), znoml(itr, iQ), zunites(itr, iQ)
+          CALL histdef(fileid, znom(itr, iQ), znoml(itr, iQ), &
+                  zunites(itr, iQ), 1, jjm, thoriid, llm, 1, llm, zvertiid, &
+                  32, 'ave(X)', dt_cum, dt_cum)
+        enddo
+        !   Declarations pour les fonctions de courant
+        ! PRINT*,'2HISTDEF'
+        CALL histdef(fileid, 'psi' // nom(iQ) &
+                , 'stream fn. ' // znoml(itot, iQ), &
+                zunites(itot, iQ), 1, jjm, thoriid, llm, 1, llm, zvertiid, &
+                32, 'ave(X)', dt_cum, dt_cum)
+      enddo
+
+
+      !   Declarations pour les champs de transport d'air
+      ! PRINT*,'3HISTDEF'
+      CALL histdef(fileid, 'masse', 'masse', &
+              'kg', 1, jjm, thoriid, llm, 1, llm, zvertiid, &
+              32, 'ave(X)', dt_cum, dt_cum)
+      CALL histdef(fileid, 'v', 'v', &
+              'm/s', 1, jjm, thoriid, llm, 1, llm, zvertiid, &
+              32, 'ave(X)', dt_cum, dt_cum)
+      !   Declarations pour les fonctions de courant
+      ! PRINT*,'4HISTDEF'
+      CALL histdef(fileid, 'psi', 'stream fn. MMC ', 'mega t/s', &
+              1, jjm, thoriid, llm, 1, llm, zvertiid, &
+              32, 'ave(X)', dt_cum, dt_cum)
+
+
+      !   Declaration des champs 1D de transport en latitude
+      ! PRINT*,'5HISTDEF'
+      DO iQ = 1, nQ
+        DO itr = 2, ntr
+          CALL histdef(fileid, 'a' // znom(itr, iQ), znoml(itr, iQ), &
+                  zunites(itr, iQ), 1, jjm, thoriid, 1, 1, 1, -99, &
+                  32, 'ave(X)', dt_cum, dt_cum)
+        enddo
+      enddo
+
+
+      ! PRINT*,'8HISTDEF'
+      CALL histend(fileid)
+
+    ENDIF
+
+
+    !=====================================================================
+    !   Calcul des champs dynamiques
+    !   ----------------------------
+
+    !   énergie cinétique
+    ucont(:, :, :) = 0
+    CALL covcont(llm, ucov, vcov, ucont, vcont)
+    CALL enercin(vcov, ucov, vcont, ucont, ecin)
+
+    !   moment cinétique
+    DO l = 1, llm
+      ang(:, :, l) = ucov(:, :, l) + constang(:, :)
+      unat(:, :, l) = ucont(:, :, l) * cu(:, :)
+    enddo
+
+    Q(:, :, :, itemp) = teta(:, :, :) * pk(:, :, :) / cpp
+    Q(:, :, :, igeop) = phi(:, :, :)
+    Q(:, :, :, iecin) = ecin(:, :, :)
+    Q(:, :, :, iang) = ang(:, :, :)
+    Q(:, :, :, iu) = unat(:, :, :)
+    Q(:, :, :, iovap) = trac(:, :, :, 1)
+    Q(:, :, :, iun) = 1.
+
+
+    !=====================================================================
+    !   Cumul
+    !=====================================================================
+
+    IF(icum==0) THEN
+      ps_cum = 0.
+      masse_cum = 0.
+      flux_u_cum = 0.
+      flux_v_cum = 0.
+      Q_cum = 0.
+      flux_vQ_cum = 0.
+      flux_uQ_cum = 0.
+    ENDIF
+
+    IF (prt_level > 5) &
+            WRITE(lunout, *)'dans bilan_dyn ', icum, '->', icum + 1
+    icum = icum + 1
+
+    !   accumulation des flux de masse horizontaux
+    ps_cum = ps_cum + ps
+    masse_cum = masse_cum + masse
+    flux_u_cum = flux_u_cum + flux_u
+    flux_v_cum = flux_v_cum + flux_v
+    DO iQ = 1, nQ
+      Q_cum(:, :, :, iQ) = Q_cum(:, :, :, iQ) + Q(:, :, :, iQ) * masse(:, :, :)
+    enddo
+
+    !=====================================================================
+    !  FLUX ET TENDANCES
+    !=====================================================================
+
+    !   Flux longitudinal
+    !   -----------------
+    DO iQ = 1, nQ
+      DO l = 1, llm
+        DO j = 1, jjp1
+          DO i = 1, iim
+            flux_uQ_cum(i, j, l, iQ) = flux_uQ_cum(i, j, l, iQ) &
+                    + flux_u(i, j, l) * 0.5 * (Q(i, j, l, iQ) + Q(i + 1, j, l, iQ))
+          enddo
+          flux_uQ_cum(iip1, j, l, iQ) = flux_uQ_cum(1, j, l, iQ)
+        enddo
+      enddo
+    enddo
+
+    !    flux méridien
+    !    -------------
+    DO iQ = 1, nQ
+      DO l = 1, llm
+        DO j = 1, jjm
+          DO i = 1, iip1
+            flux_vQ_cum(i, j, l, iQ) = flux_vQ_cum(i, j, l, iQ) &
+                    + flux_v(i, j, l) * 0.5 * (Q(i, j, l, iQ) + Q(i, j + 1, l, iQ))
+          enddo
+        enddo
+      enddo
+    enddo
+
+
+    !    tendances
+    !    ---------
+
+    !   convergence horizontale
+    CALL  convflu(flux_uQ_cum, flux_vQ_cum, llm * nQ, dQ)
+
+    !   calcul de la vitesse verticale
+    CALL convmas(flux_u_cum, flux_v_cum, convm)
+    CALL vitvert(convm, w)
+
+    DO iQ = 1, nQ
+      DO l = 1, llm - 1
+        DO j = 1, jjp1
+          DO i = 1, iip1
+            ww = -0.5 * w(i, j, l + 1) * (Q(i, j, l, iQ) + Q(i, j, l + 1, iQ))
+            dQ(i, j, l, iQ) = dQ(i, j, l, iQ) - ww
+            dQ(i, j, l + 1, iQ) = dQ(i, j, l + 1, iQ) + ww
+          enddo
+        enddo
+      enddo
+    enddo
+    IF (prt_level > 5) &
+            WRITE(lunout, *)'Apres les calculs fait a chaque pas'
+    !=====================================================================
+    !   PAS DE TEMPS D'ECRITURE
+    !=====================================================================
+    IF (icum==ncum) THEN
+      !=====================================================================
+
+      IF (prt_level > 5) &
+              WRITE(lunout, *)'Pas d ecriture'
+
+      !   Normalisation
+      DO iQ = 1, nQ
+        Q_cum(:, :, :, iQ) = Q_cum(:, :, :, iQ) / masse_cum(:, :, :)
+      enddo
+      zz = 1. / REAL(ncum)
+      ps_cum = ps_cum * zz
+      masse_cum = masse_cum * zz
+      flux_u_cum = flux_u_cum * zz
+      flux_v_cum = flux_v_cum * zz
+      flux_uQ_cum = flux_uQ_cum * zz
+      flux_vQ_cum = flux_vQ_cum * zz
+      dQ = dQ * zz
+
+
+      !   A retravailler eventuellement
+      !   division de dQ par la masse pour revenir aux bonnes grandeurs
+      DO iQ = 1, nQ
+        dQ(:, :, :, iQ) = dQ(:, :, :, iQ) / masse_cum(:, :, :)
+      enddo
+
+      !=====================================================================
+      !   Transport méridien
+      !=====================================================================
+
+      !   cumul zonal des masses des mailles
+      !   ----------------------------------
+      zv = 0.
+      zmasse = 0.
+      CALL massbar(masse_cum, massebx, masseby)
+      DO l = 1, llm
+        DO j = 1, jjm
+          DO i = 1, iim
+            zmasse(j, l) = zmasse(j, l) + masseby(i, j, l)
+            zv(j, l) = zv(j, l) + flux_v_cum(i, j, l)
+          enddo
+          zfactv(j, l) = cv(1, j) / zmasse(j, l)
+        enddo
+      enddo
+
+      ! PRINT*,'3OK'
+      !   --------------------------------------------------------------
+      !   calcul de la moyenne zonale du transport :
+      !   ------------------------------------------
+
+      !                                 --
+      ! TOT : la circulation totale       [ vq ]
+
+      !                                  -     -
+      ! MMC : mean meridional circulation [ v ] [ q ]
+
+      !                                 ----      --       - -
+      ! TRS : transitoires                [ v'q'] = [ vq ] - [ v q ]
+
+      !                                 - * - *       - -       -     -
+      ! STT : stationaires                [ v   q   ] = [ v q ] - [ v ] [ q ]
+
+      !                                          - -
+      !    on utilise aussi l'intermediaire TMP :  [ v q ]
+
+      !    la variable zfactv transforme un transport meridien cumule
+      !    en kg/s * unte-du-champ-transporte en m/s * unite-du-champ-transporte
+
+      !   --------------------------------------------------------------
+
+
+      !   ----------------------------------------
+      !   Transport dans le plan latitude-altitude
+      !   ----------------------------------------
+
+      zvQ = 0.
+      psiQ = 0.
+      DO iQ = 1, nQ
+        zvQtmp = 0.
+        DO l = 1, llm
+          DO j = 1, jjm
+            ! PRINT*,'j,l,iQ=',j,l,iQ
+            !   Calcul des moyennes zonales du transort total et de zvQtmp
+            DO i = 1, iim
+              zvQ(j, l, itot, iQ) = zvQ(j, l, itot, iQ) &
+                      + flux_vQ_cum(i, j, l, iQ)
+              zqy = 0.5 * (Q_cum(i, j, l, iQ) * masse_cum(i, j, l) + &
+                      Q_cum(i, j + 1, l, iQ) * masse_cum(i, j + 1, l))
+              zvQtmp(j, l) = zvQtmp(j, l) + flux_v_cum(i, j, l) * zqy &
+                      / (0.5 * (masse_cum(i, j, l) + masse_cum(i, j + 1, l)))
+              zvQ(j, l, iave, iQ) = zvQ(j, l, iave, iQ) + zqy
+            enddo
+            ! PRINT*,'aOK'
+            !   Decomposition
+            zvQ(j, l, iave, iQ) = zvQ(j, l, iave, iQ) / zmasse(j, l)
+            zvQ(j, l, itot, iQ) = zvQ(j, l, itot, iQ) * zfactv(j, l)
+            zvQtmp(j, l) = zvQtmp(j, l) * zfactv(j, l)
+            zvQ(j, l, immc, iQ) = zv(j, l) * zvQ(j, l, iave, iQ) * zfactv(j, l)
+            zvQ(j, l, itrs, iQ) = zvQ(j, l, itot, iQ) - zvQtmp(j, l)
+            zvQ(j, l, istn, iQ) = zvQtmp(j, l) - zvQ(j, l, immc, iQ)
+          enddo
+        enddo
+        !   fonction de courant meridienne pour la quantite Q
+        DO l = llm, 1, -1
+          DO j = 1, jjm
+            psiQ(j, l, iQ) = psiQ(j, l + 1, iQ) + zvQ(j, l, itot, iQ)
+          enddo
+        enddo
+      enddo
+
+      !   fonction de courant pour la circulation meridienne moyenne
+      psi = 0.
+      DO l = llm, 1, -1
+        DO j = 1, jjm
+          psi(j, l) = psi(j, l + 1) + zv(j, l)
+          zv(j, l) = zv(j, l) * zfactv(j, l)
+        enddo
+      enddo
+
+      ! PRINT*,'4OK'
+      !   sorties proprement dites
+      IF (i_sortie==1) THEN
+        DO iQ = 1, nQ
+          DO itr = 1, ntr
+            CALL histwrite(fileid, znom(itr, iQ), itau, zvQ(:, :, itr, iQ) &
+                    , jjm * llm, ndex3d)
+          enddo
+          CALL histwrite(fileid, 'psi' // nom(iQ), itau, psiQ(:, 1:llm, iQ) &
+                  , jjm * llm, ndex3d)
+        enddo
+
+        CALL histwrite(fileid, 'masse', itau, zmasse &
+                , jjm * llm, ndex3d)
+        CALL histwrite(fileid, 'v', itau, zv &
+                , jjm * llm, ndex3d)
+        psi = psi * 1.e-9
+        CALL histwrite(fileid, 'psi', itau, psi(:, 1:llm), jjm * llm, ndex3d)
+
+      endif
+
+
+      !   -----------------
+      !   Moyenne verticale
+      !   -----------------
+
+      zamasse = 0.
+      DO l = 1, llm
+        zamasse(:) = zamasse(:) + zmasse(:, l)
+      enddo
+      zavQ = 0.
+      DO iQ = 1, nQ
+        DO itr = 2, ntr
+          DO l = 1, llm
+            zavQ(:, itr, iQ) = zavQ(:, itr, iQ) + zvQ(:, l, itr, iQ) * zmasse(:, l)
+          enddo
+          zavQ(:, itr, iQ) = zavQ(:, itr, iQ) / zamasse(:)
+          CALL histwrite(fileid, 'a' // znom(itr, iQ), itau, zavQ(:, itr, iQ) &
+                  , jjm * llm, ndex3d)
+        enddo
+      enddo
+
+      ! on doit pouvoir tracer systematiquement la fonction de courant.
+
+      !=====================================================================
+      !/////////////////////////////////////////////////////////////////////
+      icum = 0                  !///////////////////////////////////////
+    ENDIF ! icum.EQ.ncum    !///////////////////////////////////////
+    !/////////////////////////////////////////////////////////////////////
+    !=====================================================================
+
+  END SUBROUTINE  bilan_dyn
+
+END MODULE lmdz_bilan_dyn
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_caladvtrac.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_caladvtrac.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_caladvtrac.f90	(revision 5186)
@@ -0,0 +1,125 @@
+MODULE lmdz_caladvtrac
+  IMPLICIT NONE; PRIVATE
+  PUBLIC caladvtrac
+
+CONTAINS
+
+  SUBROUTINE caladvtrac(q, pbaru, pbarv, &
+          p, masse, dq, teta, &
+          flxw, pk)
+
+    USE lmdz_infotrac, ONLY: nqtot
+    USE control_mod, ONLY: iapp_tracvl, planet_type
+    USE comconst_mod, ONLY: dtvr
+    USE lmdz_filtreg, ONLY: filtreg
+    USE lmdz_ssum_scopy, ONLY: scopy
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    USE lmdz_advtrac, ONLY: advtrac
+
+    IMPLICIT NONE
+
+    ! Auteurs:   F.Hourdin , P.Le Van, F.Forget, F.Codron
+
+    ! F.Codron (10/99) : ajout humidite specifique pour eau vapeur
+    !=======================================================================
+
+    !   Shema de  Van Leer
+
+    !=======================================================================
+
+
+
+
+    !   Arguments:
+    !   ----------
+    REAL :: pbaru(ip1jmp1, llm), pbarv(ip1jm, llm), masse(ip1jmp1, llm)
+    REAL :: p(ip1jmp1, llmp1), q(ip1jmp1, llm, nqtot)
+    REAL :: dq(ip1jmp1, llm, nqtot)
+    REAL :: teta(ip1jmp1, llm), pk(ip1jmp1, llm)
+    REAL :: flxw(ip1jmp1, llm)
+
+    !  ..................................................................
+
+    !  .. dq n'est utilise et dimensionne que pour l'eau  vapeur et liqu.
+
+    !  ..................................................................
+
+    !   Local:
+    !   ------
+
+    EXTERNAL  minmaxq, qminimum
+    INTEGER :: ij, l, iq, iapptrac
+    REAL :: finmasse(ip1jmp1, llm), dtvrtrac
+
+    !c
+
+    ! Earth-specific stuff for the first 2 tracers (water)
+    IF (planet_type=="earth") THEN
+      ! initialisation
+      ! CRisi: il faut gérer tous les traceurs si on veut pouvoir faire des
+      ! isotopes
+      ! dq(:,:,1:2)=q(:,:,1:2)
+      dq(:, :, 1:nqtot) = q(:, :, 1:nqtot)
+
+      !  test des valeurs minmax
+      !c        CALL minmaxq(q(1,1,1),1.e33,-1.e33,'Eau vapeur (a) ')
+      !c        CALL minmaxq(q(1,1,2),1.e33,-1.e33,'Eau liquide(a) ')
+    ENDIF ! of if (planet_type.EQ."earth")
+    !   advection
+
+    CALL advtrac(pbaru, pbarv, &
+            p, masse, q, iapptrac, teta, &
+            flxw, pk)
+
+    !
+
+    IF(iapptrac==iapp_tracvl) THEN
+      IF (planet_type=="earth") THEN
+        ! Earth-specific treatment for the first 2 tracers (water)
+
+        !c          CALL minmaxq(q(1,1,1),1.e33,-1.e33,'Eau vapeur     ')
+        !c          CALL minmaxq(q(1,1,2),1.e33,-1.e33,'Eau liquide    ')
+
+        !c     ....  Calcul  de deltap  qu'on stocke dans finmasse   ...
+
+        DO l = 1, llm
+          DO ij = 1, ip1jmp1
+            finmasse(ij, l) = p(ij, l) - p(ij, l + 1)
+          ENDDO
+        ENDDO
+
+        !WRITE(*,*) 'caladvtrac 87'
+        CALL qminimum(q, nqtot, finmasse)
+        !WRITE(*,*) 'caladvtrac 89'
+
+        CALL SCOPY   (ip1jmp1 * llm, masse, 1, finmasse, 1)
+        CALL filtreg (finmasse, jjp1, llm, -2, 2, .TRUE., 1)
+
+        !   *****  Calcul de dq pour l'eau , pour le passer a la physique ******
+        !   ********************************************************************
+
+        dtvrtrac = iapp_tracvl * dtvr
+
+        DO iq = 1, nqtot
+          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
+
+      endif ! of if (planet_type.EQ."earth")
+    ELSE
+      IF (planet_type=="earth") THEN
+        ! Earth-specific treatment for the first 2 tracers (water)
+        dq(:, :, 1:nqtot) = 0.
+      endif ! of if (planet_type.EQ."earth")
+    ENDIF ! of IF( iapptrac.EQ.iapp_tracvl )
+
+  END SUBROUTINE caladvtrac
+
+
+END MODULE lmdz_caladvtrac
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_caldyn.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_caldyn.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_caldyn.f90	(revision 5186)
@@ -0,0 +1,153 @@
+MODULE lmdz_caldyn
+  IMPLICIT NONE; PRIVATE
+  PUBLIC caldyn
+
+CONTAINS
+
+  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
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    USE lmdz_advect, ONLY: advect
+    USE lmdz_dteta1, ONLY: dteta1
+    USE lmdz_dudv1, ONLY: dudv1
+    USE lmdz_dudv2, ONLY: dudv2
+
+    IMPLICIT NONE
+
+    !=======================================================================
+
+    !  Auteur :  P. Le Van
+
+    !   Objet:
+    !   ------
+
+    !   Calcul des tendances dynamiques.
+
+    ! Modif 04/93 F.Forget
+    !=======================================================================
+
+    !-----------------------------------------------------------------------
+    !   0. Declarations:
+    !   ----------------
+
+
+
+
+    !   Arguments:
+    !   ----------
+
+    LOGICAL, INTENT(IN) :: conser ! triggers printing some diagnostics
+    INTEGER, INTENT(IN) :: itau ! time step index
+    REAL, INTENT(IN) :: vcov(ip1jm, llm) ! covariant meridional wind
+    REAL, INTENT(IN) :: ucov(ip1jmp1, llm) ! covariant zonal wind
+    REAL, INTENT(IN) :: teta(ip1jmp1, llm) ! potential temperature
+    REAL, INTENT(IN) :: ps(ip1jmp1) ! surface pressure
+    REAL, INTENT(IN) :: phis(ip1jmp1) ! geopotential at the surface
+    REAL, INTENT(IN) :: pk(ip1jmp1, llm) ! Exner at mid-layer
+    REAL, INTENT(IN) :: pkf(ip1jmp1, llm) ! filtered Exner
+    REAL, INTENT(IN) :: phi(ip1jmp1, llm) ! geopotential
+    REAL, INTENT(OUT) :: masse(ip1jmp1, llm) ! air mass
+    REAL, INTENT(OUT) :: dv(ip1jm, llm) ! tendency on vcov
+    REAL, INTENT(OUT) :: du(ip1jmp1, llm) ! tendency on ucov
+    REAL, INTENT(OUT) :: dteta(ip1jmp1, llm) ! tenddency on teta
+    REAL, INTENT(OUT) :: dp(ip1jmp1) ! tendency on ps
+    REAL, INTENT(OUT) :: w(ip1jmp1, llm) ! vertical velocity
+    REAL, INTENT(OUT) :: pbaru(ip1jmp1, llm) ! mass flux in the zonal direction
+    REAL, INTENT(OUT) :: pbarv(ip1jm, llm) ! mass flux in the meridional direction
+    REAL, INTENT(IN) :: time ! current time
+
+    !   Local:
+    !   ------
+
+    REAL :: vcont(ip1jm, llm), ucont(ip1jmp1, llm)
+    REAL :: ang(ip1jmp1, llm), p(ip1jmp1, llmp1)
+    REAL :: massebx(ip1jmp1, llm), masseby(ip1jm, llm), psexbarxy(ip1jm)
+    REAL :: vorpot(ip1jm, llm)
+    REAL :: ecin(ip1jmp1, llm), convm(ip1jmp1, llm)
+    REAL :: bern(ip1jmp1, llm)
+    REAL :: massebxy(ip1jm, llm)
+
+    INTEGER :: ij, l
+
+    !-----------------------------------------------------------------------
+    !   Compute dynamical tendencies:
+    !--------------------------------
+
+    ! compute contravariant winds ucont() and vcont
+    CALL covcont  (llm, ucov, vcov, ucont, vcont)
+    ! compute pressure p()
+    CALL pression (ip1jmp1, ap, bp, ps, p)
+    ! compute psexbarxy() XY-area weighted-averaged surface pressure (what for?)
+    CALL psextbar (ps, psexbarxy)
+    ! compute mass in each atmospheric mesh: masse()
+    CALL massdair (p, masse)
+    ! compute X and Y-averages of mass, massebx() and masseby()
+    CALL massbar  (masse, massebx, masseby)
+    ! compute XY-average of mass, massebxy()
+    CALL massbarxy(masse, massebxy)
+    ! compute mass fluxes pbaru() and pbarv()
+    CALL flumass  (massebx, masseby, vcont, ucont, pbaru, pbarv)
+    ! compute dteta() , horizontal converging flux of theta
+    CALL dteta1   (teta, pbaru, pbarv, dteta)
+    ! compute convm(), horizontal converging flux of mass
+    CALL convmas  (pbaru, pbarv, convm)
+
+    ! compute pressure variation due to mass convergence
+    DO ij = 1, ip1jmp1
+      dp(ij) = convm(ij, 1) / airesurg(ij)
+    ENDDO
+
+    ! compute vertical velocity w()
+    CALL vitvert (convm, w)
+    ! compute potential vorticity vorpot()
+    CALL tourpot (vcov, ucov, massebxy, vorpot)
+    ! compute rotation induced du() and dv()
+    CALL dudv1   (vorpot, pbaru, pbarv, du, dv)
+    ! compute kinetic energy ecin()
+    CALL enercin (vcov, ucov, vcont, ucont, ecin)
+    ! compute Bernouilli function bern()
+    CALL bernoui (ip1jmp1, llm, phi, ecin, bern)
+    ! compute and add du() and dv() contributions from Bernouilli and pressure
+    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
+
+    ! compute vertical advection contributions to du(), dv() and dteta()
+    CALL advect(ang, vcov, teta, w, massebx, masseby, du, dv, dteta)
+
+    !  WARNING probleme de peridocite de dv sur les PC/linux. Pb d'arrondi
+    ! probablement. Observe sur le code compile avec pgf90 3.0-1
+
+    DO l = 1, llm
+      DO ij = 1, ip1jm, iip1
+        IF(dv(ij, l)/=dv(ij + iim, l))  THEN
+          ! PRINT *,'!!!ATTENTION!!! probleme de periodicite sur vcov',
+          !    ,   ' dans caldyn'
+          ! PRINT *,' l,  ij = ', l, ij, ij+iim,dv(ij+iim,l),dv(ij,l)
+          dv(ij + iim, l) = dv(ij, l)
+        ENDIF
+      ENDDO
+    ENDDO
+
+    !-----------------------------------------------------------------------
+    !   Output some control variables:
+    !---------------------------------
+
+    IF(conser)  THEN
+      CALL sortvarc &
+              (itau, ucov, teta, ps, masse, pk, phis, vorpot, phi, bern, dp, time, vcov)
+    ENDIF
+
+  END SUBROUTINE caldyn
+
+END MODULE lmdz_caldyn
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_check_isotopes.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_check_isotopes.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_check_isotopes.f90	(revision 5186)
@@ -0,0 +1,190 @@
+MODULE lmdz_check_isotopes
+  IMPLICIT NONE; PRIVATE
+  PUBLIC check_isotopes_seq
+
+CONTAINS
+
+
+  SUBROUTINE check_isotopes_seq(q, ip1jmp1, err_msg)
+    USE lmdz_strings, ONLY: maxlen, msg, strIdx, strStack, int2str, real2str
+    USE lmdz_infotrac, ONLY: nqtot, niso, nphas, isotope, isoCheck, iqIsoPha, isoSelect, &
+            ntiso, iH2O, nzone, tracers, isoName, itZonIso, getKey
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    IMPLICIT NONE
+
+    REAL, INTENT(INOUT) :: q(ip1jmp1, llm, nqtot)
+    INTEGER, INTENT(IN) :: ip1jmp1
+    CHARACTER(LEN = *), INTENT(IN) :: err_msg    !--- Error message to display
+    CHARACTER(LEN = maxlen) :: modname, msg1, nm(2)
+    INTEGER :: ixt, ipha, k, i, iq, iiso, izon, ieau, iqeau, iqpar
+    INTEGER, ALLOCATABLE :: ix(:)
+    REAL, ALLOCATABLE, SAVE :: tnat(:)
+    REAL :: xtractot, xiiso, deltaD, q1, q2
+    REAL, PARAMETER :: borne = 1e19, &
+            errmax = 1e-8, &       !--- Max. absolute error
+            errmaxrel = 1e-3, &       !--- Max. relative error
+            qmin = 1e-11, &
+            deltaDmax = 1000.0, &
+            deltaDmin = -999.0, &
+            ridicule = 1e-12
+    INTEGER, SAVE :: iso_eau, iso_HDO, iso_O18, &
+            iso_O17, iso_HTO
+    LOGICAL, SAVE :: first = .TRUE.
+    LOGICAL, PARAMETER :: tnat1 = .TRUE.
+
+    modname = 'check_isotopes'
+    IF(.NOT.isoCheck)    RETURN                   !--- No need to check => finished
+    IF(isoSelect('H2O')) RETURN                   !--- No H2O isotopes group found
+    IF(niso == 0)        RETURN                   !--- No isotopes => finished
+    IF(first) THEN
+      iso_eau = strIdx(isoName, 'H216O')
+      iso_HDO = strIdx(isoName, 'HDO')
+      iso_O18 = strIdx(isoName, 'H218O')
+      iso_O17 = strIdx(isoName, 'H217O')
+      iso_HTO = strIdx(isoName, 'HTO')
+      IF (tnat1) THEN
+        tnat(:) = 1.0
+      else
+        IF(getKey('tnat', tnat)) CALL abort_gcm(modname, 'missing isotopic parameter', 1)
+      endif
+      first = .FALSE.
+    END IF
+    CALL msg('31: err_msg=' // TRIM(err_msg), modname)
+
+    !--- CHECK FOR NaNs (FOR ALL THE ISOTOPES, INCLUDING GEOGRAPHIC TAGGING TRACERS)
+    modname = 'check_isotopes:iso_verif_noNaN'
+    DO ixt = 1, ntiso
+      DO ipha = 1, nphas
+        iq = iqIsoPha(ixt, ipha)
+        DO k = 1, llm
+          DO i = 1, ip1jmp1
+            IF(ABS(q(i, k, iq)) < borne) CYCLE
+            WRITE(msg1, '(s,"(",i0,",",i0,",",i0,") = ",ES12.4)')TRIM(isoName(ixt)), i, k, iq, q(i, k, iq)
+            CALL msg(msg1, modname)
+            CALL abort_gcm(modname, 'Error with isotopes: ' // TRIM(err_msg), 1)
+          END DO
+        END DO
+      END DO
+    END DO
+
+    !--- CHECK CONSERVATION (MAIN ISOTOPE AND PARENT CONCENTRATIONS MUST BE EQUAL)
+    modname = 'check_isotopes:iso_verif_egalite'
+    ixt = iso_eau
+    IF(ixt /= 0) THEN
+      DO ipha = 1, nphas
+        iq = iqIsoPha(ixt, ipha)
+        iqpar = tracers(iq)%iqParent
+        DO k = 1, llm
+          DO i = 1, ip1jmp1
+            q1 = q(i, k, iqpar)
+            q2 = q(i, k, iq)
+            !--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
+            !    This would be probably required to sum from smallest to highest concentrations ; the corresponding
+            !    indices vector can be computed once only (in the initializations stage), using mean concentrations.
+            !              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
+            IF(ABS(q1 - q2) <= errmax .OR. ABS(q1 - q2) / MAX(MAX(ABS(q1), ABS(q2)), 1e-18) <= errmaxrel) THEN
+              q(i, k, iq) = q1                 !--- Bidouille pour convergence
+              !                 q(i,k,tracers(iqPar)%iqDesc) = q(i,k,tracers(iqPar)%iqDesc) * q1 / q2
+              CYCLE
+            END IF
+            CALL msg('ixt, iq = ' // TRIM(strStack(int2str([ixt, iq]))), modname)
+            msg1 = '(' // TRIM(strStack(int2str([i, k]))) // ')'
+            CALL msg(TRIM(tracers(iqpar)%name) // TRIM(msg1) // ' = ' // TRIM(real2str(q1)), modname)
+            CALL msg(TRIM(tracers(iq)%name) // TRIM(msg1) // ' = ' // TRIM(real2str(q2)), modname)
+            CALL abort_gcm(modname, 'Error with isotopes: ' // TRIM(err_msg), 1)
+          END DO
+        END DO
+      END DO
+    END IF
+
+    !--- CHECK DELTA ANOMALIES
+    modname = 'check_isotopes:iso_verif_aberrant'
+    ix = [ iso_HDO, iso_O18 ]
+    nm = ['deltaD  ', 'deltaO18']
+    DO iiso = 1, SIZE(ix)
+      ixt = ix(iiso)
+      IF(ixt  == 0) CYCLE
+      DO ipha = 1, nphas
+        iq = iqIsoPha(ixt, ipha)
+        iqpar = tracers(iq)%iqParent
+        DO k = 1, llm
+          DO i = 1, ip1jmp1
+            q1 = q(i, k, iqpar)
+            q2 = q(i, k, iq)
+            !--- IMPROVEMENT in case at least one isotope is not negligible compared to the main isotopic form.
+            !    This would be probably required to sum from smallest to highest concentrations ; the corresponding
+            !    indices vector can be computed once only (in the initializations stage), using mean concentrations.
+            !              q2 = SUM(q(i,k,tracers(iqPar)%iqDesc), DIM=3)
+            IF(q2 <= qmin) CYCLE
+            deltaD = (q2 / q1 / tnat(ixt) - 1.) * 1000.
+            IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
+            CALL msg('ixt, iq = ' // TRIM(strStack(int2str([ixt, iq]))), modname)
+            msg1 = '(' // TRIM(strStack(int2str([i, k]))) // ')'
+            CALL msg(TRIM(tracers(iqpar)%name) // TRIM(msg1) // ' = ' // TRIM(real2str(q1)), modname)
+            CALL msg(TRIM(tracers(iq)%name) // TRIM(msg1) // ' = ' // TRIM(real2str(q2)), modname)
+            CALL msg(TRIM(nm(iiso)) // TRIM(real2str(deltaD)), modname)
+            CALL abort_gcm(modname, 'Error with isotopes: ' // TRIM(err_msg), 1)
+          END DO
+        END DO
+      END DO
+    END DO
+
+    IF(nzone == 0) RETURN
+
+    !--- CHECK FOR TAGGING TRACERS DELTAD ANOMALIES
+    modname = 'check_isotopes:iso_verif_aberrant'
+    IF(iso_eau /= 0 .AND. iso_HDO /= 0) THEN
+      DO izon = 1, nzone
+        ixt = itZonIso(izon, iso_HDO)
+        ieau = itZonIso(izon, iso_eau)
+        DO ipha = 1, nphas
+          iq = iqIsoPha(ixt, ipha)
+          iqeau = iqIsoPha(ieau, ipha)
+          DO k = 1, llm
+            DO i = 1, ip1jmp1
+              q1 = q(i, k, iqeau)
+              q2 = q(i, k, iq)
+              IF(q2<=qmin) CYCLE
+              deltaD = (q2 / q1 / tnat(iso_HDO) - 1.) * 1000.
+              IF(deltaD <= deltaDmax .AND. deltaD >= deltaDmin) CYCLE
+              CALL msg('izon, ipha = ' // TRIM(strStack(int2str([izon, ipha]))), modname)
+              CALL msg('ixt, ieau = ' // TRIM(strStack(int2str([ ixt, ieau]))), modname)
+              msg1 = '(' // TRIM(strStack(int2str([i, k]))) // ')'
+              CALL msg(TRIM(tracers(iqeau)%name) // TRIM(msg1) // ' = ' // TRIM(real2str(q1)), modname)
+              CALL msg(TRIM(tracers(iq)%name) // TRIM(msg1) // ' = ' // TRIM(real2str(q2)), modname)
+              CALL msg('deltaD = ' // TRIM(real2str(deltaD)), modname)
+              CALL abort_gcm(modname, 'Error with isotopes: ' // TRIM(err_msg), 1)
+            END DO
+          END DO
+        END DO
+      END DO
+    END IF
+
+    !--- CHECK FOR TAGGING TRACERS CONSERVATION (PARENT AND TAGGING TRACERS SUM OVER ALL REGIONS MUST BE EQUAL)
+    DO iiso = 1, niso
+      DO ipha = 1, nphas
+        iq = iqIsoPha(iiso, ipha)
+        DO k = 1, llm
+          DO i = 1, ip1jmp1
+            xiiso = q(i, k, iq)
+            xtractot = SUM(q(i, k, iqIsoPha(itZonIso(1:nzone, iiso), ipha)))
+            IF(ABS(xtractot - xiiso) > errmax .AND. ABS(xtractot - xiiso) / MAX(MAX(ABS(xtractot), ABS(xiiso)), 1e-18) > errmaxrel) THEN
+              CALL msg('Error in iso_verif_aberrant trac: ' // TRIM(err_msg))
+              CALL msg('iiso, ipha = ' // TRIM(strStack(int2str([iiso, ipha]))), modname)
+              CALL msg('q(' // TRIM(strStack(int2str([i, k]))) // ',:) = ' // TRIM(strStack(real2str(q(i, k, :)))), modname)
+              CALL abort_gcm(modname, 'Error with isotopes: ' // TRIM(err_msg), 1)
+            END IF
+            IF(ABS(xtractot) <= ridicule) CYCLE
+            DO izon = 1, nzone
+              q(i, k, iq) = q(i, k, iq) / xtractot * xiiso !--- Bidouille pour convergence
+            END DO
+          END DO
+        END DO
+      END DO
+    END DO
+
+  END SUBROUTINE check_isotopes_seq
+
+
+END MODULE lmdz_check_isotopes
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_conf_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_conf_gcm.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_conf_gcm.f90	(revision 5186)
@@ -0,0 +1,925 @@
+MODULE lmdz_conf_gcm
+  IMPLICIT NONE; PRIVATE
+  PUBLIC conf_gcm
+
+CONTAINS
+
+  SUBROUTINE conf_gcm(tapedef, etatinit)
+
+    USE control_mod
+    USE IOIPSL
+    USE lmdz_infotrac, ONLY: type_trac
+    USE lmdz_assert, ONLY: assert
+    USE comconst_mod, ONLY: dissip_deltaz, dissip_factz, dissip_zref, &
+            iflag_top_bound, mode_top_bound, tau_top_bound, &
+            ngroup, maxlatfilter
+    USE logic_mod, ONLY: fxyhypb, iflag_phys, ok_etat0, ok_gradsfile, &
+            ok_guide, ok_limit, ok_strato, purmats, read_start, &
+            ysinus, read_orop, adv_qsat_liq
+    USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, &
+            alphax, alphay, taux, tauy
+    USE temps_mod, ONLY: calend, year_len
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
+            tetagrot, tetatemp, coefdis, vert_prof_dissip
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+    !-----------------------------------------------------------------------
+    !     Auteurs :   L. Fairhead , P. Le Van  .
+
+    !     Arguments :
+
+    !     tapedef   :
+    !     etatinit  :     = TRUE   , on ne  compare pas les valeurs des para-
+    !     -metres  du zoom  avec  celles lues sur le fichier start .
+
+    LOGICAL, INTENT(IN) :: etatinit
+    INTEGER, INTENT(IN) :: tapedef
+
+    !   Declarations :
+    !   --------------
+
+
+
+    !   local:
+    !   ------
+
+    REAL clonn, clatt, grossismxx, grossismyy
+    REAL dzoomxx, dzoomyy, tauxx, tauyy
+    LOGICAL  fxyhypbb, ysinuss
+
+    !  -------------------------------------------------------------------
+
+    !       .........     Version  du 29/04/97       ..........
+
+    !   Nouveaux parametres nitergdiv,nitergrot,niterh,tetagdiv,tetagrot,
+    !      tetatemp   ajoutes  pour la dissipation   .
+
+    !   Autre parametre ajoute en fin de liste de tapedef : ** fxyhypb **
+
+    !  Si fxyhypb = .TRUE. , choix de la fonction a derivee tangente hyperb.
+    !    Sinon , choix de fxynew  , a derivee sinusoidale  ..
+
+    !   ......  etatinit = . TRUE. si defrun  est appele dans ETAT0_LMD  ou
+    !         LIMIT_LMD  pour l'initialisation de start.dat (dic) et
+    !                de limit.dat ( dic)                        ...........
+    !           Sinon  etatinit = . FALSE .
+
+    !   Donc etatinit = .F.  si on veut comparer les valeurs de  grossismx ,
+    !    grossismy,clon,clat, fxyhypb  lues sur  le fichier  start  avec
+    !   celles passees  par run.def ,  au debut du gcm, apres l'appel a
+    !    lectba .
+    !   Ces parmetres definissant entre autres la grille et doivent etre
+    !   pareils et coherents , sinon il y aura  divergence du gcm .
+
+    !-----------------------------------------------------------------------
+    !   initialisations:
+    !   ----------------
+
+    !Config  Key  = lunout
+    !Config  Desc = unite de fichier pour les impressions
+    !Config  Def  = 6
+    !Config  Help = unite de fichier pour les impressions
+    !Config         (defaut sortie standard = 6)
+    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
+
+    !Config  Key  = prt_level
+    !Config  Desc = niveau d'impressions de d\'ebogage
+    !Config  Def  = 0
+    !Config  Help = Niveau d'impression pour le d\'ebogage
+    !Config         (0 = minimum d'impression)
+    prt_level = 0
+    CALL getin('prt_level', prt_level)
+
+    !-----------------------------------------------------------------------
+    !  Parametres de controle du run:
+    !-----------------------------------------------------------------------
+    !Config  Key  = planet_type
+    !Config  Desc = planet type ("earth", "mars", "venus", ...)
+    !Config  Def  = earth
+    !Config  Help = this flag sets the type of atymosphere that is considered
+    planet_type = "earth"
+    CALL getin('planet_type', planet_type)
+
+    !Config  Key  = calend
+    !Config  Desc = type de calendrier utilise
+    !Config  Def  = earth_360d
+    !Config  Help = valeur possible: earth_360d, earth_365d, earth_366d
+    !Config
+    calend = 'earth_360d'
+    CALL getin('calend', calend)
+    ! initialize year_len for aquaplanets and 1D
+    IF (calend == 'earth_360d') THEN
+      year_len = 360
+    ELSE IF (calend == 'earth_365d') THEN
+      year_len = 365
+    ELSE IF (calend == 'earth_366d') THEN
+      year_len = 366
+    ELSE
+      year_len = 1
+    ENDIF
+
+    !Config  Key  = dayref
+    !Config  Desc = Jour de l'etat initial
+    !Config  Def  = 1
+    !Config  Help = Jour de l'etat initial ( = 350  si 20 Decembre ,
+    !Config         par expl. ,comme ici ) ... A completer
+    dayref = 1
+    CALL getin('dayref', dayref)
+
+    !Config  Key  = anneeref
+    !Config  Desc = Annee de l'etat initial
+    !Config  Def  = 1998
+    !Config  Help = Annee de l'etat  initial
+    !Config         (   avec  4  chiffres   ) ... A completer
+    anneeref = 1998
+    CALL getin('anneeref', anneeref)
+
+    !Config  Key  = raz_date
+    !Config  Desc = Remise a zero de la date initiale
+    !Config  Def  = 0 (pas de remise a zero)
+    !Config  Help = Remise a zero de la date initiale
+    !Config         0 pas de remise a zero, on garde la date du fichier restart
+    !Config         1 prise en compte de la date de gcm.def avec remise a zero
+    !Config         des compteurs de pas de temps
+    raz_date = 0
+    CALL getin('raz_date', raz_date)
+
+    !Config  Key  = resetvarc
+    !Config  Desc = Reinit des variables de controle
+    !Config  Def  = n
+    !Config  Help = Reinit des variables de controle
+    resetvarc = .FALSE.
+    CALL getin('resetvarc', resetvarc)
+
+    !Config  Key  = nday
+    !Config  Desc = Nombre de jours d'integration
+    !Config  Def  = 10
+    !Config  Help = Nombre de jours d'integration
+    !Config         ... On pourait aussi permettre des mois ou des annees !
+    nday = 10
+    CALL getin('nday', nday)
+
+    !Config  Key  = starttime
+    !Config  Desc = Heure de depart de la simulation
+    !Config  Def  = 0
+    !Config  Help = Heure de depart de la simulation
+    !Config         en jour
+    starttime = 0
+    CALL getin('starttime', starttime)
+
+    !Config  Key  = day_step
+    !Config  Desc = nombre de pas par jour
+    !Config  Def  = 240
+    !Config  Help = nombre de pas par jour (multiple de iperiod) (
+    !Config          ici pour  dt = 1 min )
+    day_step = 240
+    CALL getin('day_step', day_step)
+
+    !Config  Key  = nsplit_phys
+    nsplit_phys = 1
+    CALL getin('nsplit_phys', nsplit_phys)
+
+    !Config  Key  = iperiod
+    !Config  Desc = periode pour le pas Matsuno
+    !Config  Def  = 5
+    !Config  Help = periode pour le pas Matsuno (en pas de temps)
+    iperiod = 5
+    CALL getin('iperiod', iperiod)
+
+    !Config  Key  = iapp_tracvl
+    !Config  Desc = frequence du groupement des flux
+    !Config  Def  = iperiod
+    !Config  Help = frequence du groupement des flux (en pas de temps)
+    iapp_tracvl = iperiod
+    CALL getin('iapp_tracvl', iapp_tracvl)
+
+    !Config  Key  = iconser
+    !Config  Desc = periode de sortie des variables de controle
+    !Config  Def  = 240
+    !Config  Help = periode de sortie des variables de controle
+    !Config         (En pas de temps)
+    iconser = 240
+    CALL getin('iconser', iconser)
+
+    !Config  Key  = iecri
+    !Config  Desc = periode d'ecriture du fichier histoire
+    !Config  Def  = 1
+    !Config  Help = periode d'ecriture du fichier histoire (en jour)
+    iecri = 1
+    CALL getin('iecri', iecri)
+
+    !Config  Key  = periodav
+    !Config  Desc = periode de stockage fichier histmoy
+    !Config  Def  = 1
+    !Config  Help = periode de stockage fichier histmoy (en jour)
+    periodav = 1.
+    CALL getin('periodav', periodav)
+
+    !Config  Key  = output_grads_dyn
+    !Config  Desc = output dynamics diagnostics in 'dyn.dat' file
+    !Config  Def  = n
+    !Config  Help = output dynamics diagnostics in Grads-readable 'dyn.dat' file
+    output_grads_dyn = .FALSE.
+    CALL getin('output_grads_dyn', output_grads_dyn)
+
+    !Config  Key  = dissip_period
+    !Config  Desc = periode de la dissipation
+    !Config  Def  = 0
+    !Config  Help = periode de la dissipation
+    !Config  dissip_period=0 => la valeur sera calcule dans inidissip
+    !Config  dissip_period>0 => on prend cette valeur
+    dissip_period = 0
+    CALL getin('dissip_period', dissip_period)
+
+    !cc  ....   P. Le Van , modif le 29/04/97 .pour la dissipation  ...
+    !cc
+
+    !Config  Key  = lstardis
+    !Config  Desc = choix de l'operateur de dissipation
+    !Config  Def  = y
+    !Config  Help = choix de l'operateur de dissipation
+    !Config         'y' si on veut star et 'n' si on veut non-start !
+    !Config         Moi y en a pas comprendre !
+    lstardis = .TRUE.
+    CALL getin('lstardis', lstardis)
+
+    !Config  Key  = nitergdiv
+    !Config  Desc = Nombre d'iteration de gradiv
+    !Config  Def  = 1
+    !Config  Help = nombre d'iterations de l'operateur de dissipation
+    !Config         gradiv
+    nitergdiv = 1
+    CALL getin('nitergdiv', nitergdiv)
+
+    !Config  Key  = nitergrot
+    !Config  Desc = nombre d'iterations de nxgradrot
+    !Config  Def  = 2
+    !Config  Help = nombre d'iterations de l'operateur de dissipation
+    !Config         nxgradrot
+    nitergrot = 2
+    CALL getin('nitergrot', nitergrot)
+
+    !Config  Key  = niterh
+    !Config  Desc = nombre d'iterations de divgrad
+    !Config  Def  = 2
+    !Config  Help = nombre d'iterations de l'operateur de dissipation
+    !Config         divgrad
+    niterh = 2
+    CALL getin('niterh', niterh)
+
+    !Config  Key  = tetagdiv
+    !Config  Desc = temps de dissipation pour div
+    !Config  Def  = 7200
+    !Config  Help = temps de dissipation des plus petites longeur
+    !Config         d'ondes pour u,v (gradiv)
+    tetagdiv = 7200.
+    CALL getin('tetagdiv', tetagdiv)
+
+    !Config  Key  = tetagrot
+    !Config  Desc = temps de dissipation pour grad
+    !Config  Def  = 7200
+    !Config  Help = temps de dissipation des plus petites longeur
+    !Config         d'ondes pour u,v (nxgradrot)
+    tetagrot = 7200.
+    CALL getin('tetagrot', tetagrot)
+
+    !Config  Key  = tetatemp
+    !Config  Desc = temps de dissipation pour h
+    !Config  Def  = 7200
+    !Config  Help =  temps de dissipation des plus petites longeur
+    !Config         d'ondes pour h (divgrad)
+    tetatemp = 7200.
+    CALL getin('tetatemp', tetatemp)
+
+    ! Parametres controlant la variation sur la verticale des constantes de
+    ! dissipation.
+    ! Pour le moment actifs uniquement dans la version a 39 niveaux
+    ! avec ok_strato=y
+
+    dissip_factz = 4.
+    dissip_deltaz = 10.
+    dissip_zref = 30.
+    CALL getin('dissip_factz', dissip_factz)
+    CALL getin('dissip_deltaz', dissip_deltaz)
+    CALL getin('dissip_zref', dissip_zref)
+
+    ! maxlatfilter
+    maxlatfilter = -1.0
+    CALL getin('maxlatfilter', maxlatfilter)
+    IF (maxlatfilter > 90) &
+            CALL abort_gcm("conf_gcm", 'maxlatfilter should be <=90', 1)
+
+
+    ! ngroup
+    ngroup = 3
+    CALL getin('ngroup', ngroup)
+
+    ! top_bound sponge: only active if ok_strato=.TRUE. and iflag_top_bound!=0
+    !                   iflag_top_bound=0 for no sponge
+    !                   iflag_top_bound=1 for sponge over 4 topmost layers
+    !                   iflag_top_bound=2 for sponge from top to ~1% of top layer pressure
+    iflag_top_bound = 1
+    CALL getin('iflag_top_bound', iflag_top_bound)
+    IF (iflag_top_bound < 0 .OR. iflag_top_bound > 2) &
+            CALL abort_gcm("conf_gcm", 'iflag_top_bound must be 0, 1 or 2', 1)
+
+    ! mode_top_bound : fields towards which sponge relaxation will be done:
+    !                  mode_top_bound=0: no relaxation
+    !                  mode_top_bound=1: u and v relax towards 0
+    !                  mode_top_bound=2: u and v relax towards their zonal mean
+    !                  mode_top_bound=3: u,v and pot. temp. relax towards their zonal mean
+    mode_top_bound = 3
+    CALL getin('mode_top_bound', mode_top_bound)
+
+    ! top_bound sponge : inverse of charactericstic relaxation time scale for sponge
+    tau_top_bound = 1.e-5
+    CALL getin('tau_top_bound', tau_top_bound)
+
+    !Config  Key  = coefdis
+    !Config  Desc = coefficient pour gamdissip
+    !Config  Def  = 0
+    !Config  Help = coefficient pour gamdissip
+    coefdis = 0.
+    CALL getin('coefdis', coefdis)
+
+    !Config  Key  = purmats
+    !Config  Desc = Schema d'integration
+    !Config  Def  = n
+    !Config  Help = Choix du schema d'integration temporel.
+    !Config         y = pure Matsuno sinon c'est du Matsuno-leapfrog
+    purmats = .FALSE.
+    CALL getin('purmats', purmats)
+
+    !Config  Key  = ok_guide
+    !Config  Desc = Guidage
+    !Config  Def  = n
+    !Config  Help = Guidage
+    ok_guide = .FALSE.
+    CALL getin('ok_guide', ok_guide)
+
+    !Config  Key  =  read_start
+    !Config  Desc = Initialize model using a 'start.nc' file
+    !Config  Def  = y
+    !Config  Help = y: intialize dynamical fields using a 'start.nc' file
+    !               n: fields are initialized by 'iniacademic' routine
+    read_start = .TRUE.
+    CALL getin('read_start', read_start)
+
+    !Config  Key  = iflag_phys
+    !Config  Desc = Avec ls physique
+    !Config  Def  = 1
+    !Config  Help = Permet de faire tourner le modele sans
+    !Config         physique.
+    iflag_phys = 1
+    CALL getin('iflag_phys', iflag_phys)
+
+    !Config  Key  =  iphysiq
+    !Config  Desc = Periode de la physique
+    !Config  Def  = 5
+    !Config  Help = Periode de la physique en pas de temps de la dynamique.
+    iphysiq = 5
+    CALL getin('iphysiq', iphysiq)
+
+    !Config  Key  = ip_ebil_dyn
+    !Config  Desc = PRINT level for energy conserv. diag.
+    !Config  Def  = 0
+    !Config  Help = PRINT level for energy conservation diag. ;
+    !               les options suivantes existent :
+    !Config         0 pas de print
+    !Config         1 pas de print
+    !Config         2 print,
+    ip_ebil_dyn = 0
+    CALL getin('ip_ebil_dyn', ip_ebil_dyn)
+
+    !cc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
+    !     .........   (  modif  le 17/04/96 )   .........
+
+    test_etatinit: IF (.NOT. etatinit) THEN
+      !Config  Key  = clon
+      !Config  Desc = centre du zoom, longitude
+      !Config  Def  = 0
+      !Config  Help = longitude en degres du centre
+      !Config         du zoom
+      clonn = 0.
+      CALL getin('clon', clonn)
+
+      !Config  Key  = clat
+      !Config  Desc = centre du zoom, latitude
+      !Config  Def  = 0
+      !Config  Help = latitude en degres du centre du zoom
+      !Config
+      clatt = 0.
+      CALL getin('clat', clatt)
+
+      IF(ABS(clat - clatt)>= 0.001)  THEN
+        WRITE(lunout, *)'conf_gcm: La valeur de clat passee par run.def', &
+                ' est differente de celle lue sur le fichier  start '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ENDIF
+
+      !Config  Key  = grossismx
+      !Config  Desc = zoom en longitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la longitude
+      grossismxx = 1.0
+      CALL getin('grossismx', grossismxx)
+
+      IF(ABS(grossismx - grossismxx)>= 0.001)  THEN
+        WRITE(lunout, *)'conf_gcm: La valeur de grossismx passee par ', &
+                'run.def est differente de celle lue sur le fichier  start '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ENDIF
+
+      !Config  Key  = grossismy
+      !Config  Desc = zoom en latitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la latitude
+      grossismyy = 1.0
+      CALL getin('grossismy', grossismyy)
+
+      IF(ABS(grossismy - grossismyy)>= 0.001)  THEN
+        WRITE(lunout, *)'conf_gcm: La valeur de grossismy passee par ', &
+                'run.def est differente de celle lue sur le fichier  start '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ENDIF
+
+      IF(grossismx<1.)  THEN
+        WRITE(lunout, *) &
+                'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphax = 1. - 1. / grossismx
+      ENDIF
+
+      IF(grossismy<1.)  THEN
+        WRITE(lunout, *) &
+                'conf_gcm: ***  ATTENTION !! grossismy < 1 .   *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphay = 1. - 1. / grossismy
+      ENDIF
+
+      WRITE(lunout, *)'conf_gcm: alphax alphay', alphax, alphay
+
+      !    alphax et alphay sont les anciennes formulat. des grossissements
+
+      !Config  Key  = fxyhypb
+      !Config  Desc = Fonction  hyperbolique
+      !Config  Def  = y
+      !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
+      !Config         sinon  sinusoidale
+      fxyhypbb = .TRUE.
+      CALL getin('fxyhypb', fxyhypbb)
+
+      IF(.NOT.fxyhypb)  THEN
+        IF(fxyhypbb)     THEN
+          WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+          WRITE(lunout, *)' *** fxyhypb lu sur le fichier start est ', &
+                  'F alors  qu il est  T  sur  run.def  ***'
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ELSE
+        IF(.NOT.fxyhypbb)   THEN
+          WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+          WRITE(lunout, *)' ***  fxyhypb lu sur le fichier start est ', &
+                  'T alors  qu il est  F  sur  run.def  ****  '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = dzoomx
+      !Config  Desc = extension en longitude
+      !Config  Def  = 0
+      !Config  Help = extension en longitude  de la zone du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomxx = 0.0
+      CALL getin('dzoomx', dzoomxx)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(dzoomx - dzoomxx)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de dzoomx passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = dzoomy
+      !Config  Desc = extension en latitude
+      !Config  Def  = 0
+      !Config  Help = extension en latitude de la zone  du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomyy = 0.0
+      CALL getin('dzoomy', dzoomyy)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(dzoomy - dzoomyy)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de dzoomy passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = taux
+      !Config  Desc = raideur du zoom en  X
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  X
+      tauxx = 3.0
+      CALL getin('taux', tauxx)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(taux - tauxx)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de taux passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = tauyy
+      !Config  Desc = raideur du zoom en  Y
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  Y
+      tauyy = 3.0
+      CALL getin('tauy', tauyy)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(tauy - tauyy)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de tauy passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !c
+      IF(.NOT.fxyhypb)  THEN
+
+        !Config  Key  = ysinus
+        !Config  IF   = !fxyhypb
+        !Config  Desc = Fonction en Sinus
+        !Config  Def  = y
+        !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
+        !Config         sinon y = latit.
+        ysinuss = .TRUE.
+        CALL getin('ysinus', ysinuss)
+
+        IF(.NOT.ysinus)  THEN
+          IF(ysinuss)     THEN
+            WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+            WRITE(lunout, *)' *** ysinus lu sur le fichier start est F', &
+                    ' alors  qu il est  T  sur  run.def  ***'
+            CALL abort_gcm("conf_gcm", "stopped", 1)
+          ENDIF
+        ELSE
+          IF(.NOT.ysinuss)   THEN
+            WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+            WRITE(lunout, *)' *** ysinus lu sur le fichier start est T', &
+                    ' alors  qu il est  F  sur  run.def  ****  '
+            CALL abort_gcm("conf_gcm", "stopped", 1)
+          ENDIF
+        ENDIF
+      ENDIF ! of IF( .NOT.fxyhypb  )
+
+      !Config  Key  = offline
+      !Config  Desc = Nouvelle eau liquide
+      !Config  Def  = n
+      !Config  Help = Permet de mettre en route la
+      !Config         nouvelle parametrisation de l'eau liquide !
+      offline = .FALSE.
+      CALL getin('offline', offline)
+
+      !Config  Key  = type_trac
+      !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
+      !Config  Def  = lmdz
+      !Config  Help =
+      !Config         'lmdz' = pas de couplage, pur LMDZ
+      !Config         'inca' = model de chime INCA
+      !Config         'repr' = model de chime REPROBUS
+      !Config         'inco' = INCA + CO2i (temporaire)
+      type_trac = 'lmdz'
+      CALL getin('type_trac', type_trac)
+
+
+      !Config  Key  = adv_qsat_liq
+      !Config  Desc = option for qsat calculation in the dynamics
+      !Config  Def  = n
+      !Config  Help = controls which phase is considered for qsat calculation
+      !Config
+      adv_qsat_liq = .FALSE.
+      CALL getin('adv_qsat_liq', adv_qsat_liq)
+
+      !Config  Key  = ok_dynzon
+      !Config  Desc = calcul et sortie des transports
+      !Config  Def  = n
+      !Config  Help = Permet de mettre en route le calcul des transports
+      !Config
+      ok_dynzon = .FALSE.
+      CALL getin('ok_dynzon', ok_dynzon)
+
+      !Config  Key  = ok_dyn_ins
+      !Config  Desc = sorties instantanees dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ins = .FALSE.
+      CALL getin('ok_dyn_ins', ok_dyn_ins)
+
+      !Config  Key  = ok_dyn_ave
+      !Config  Desc = sorties moyennes dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ave = .FALSE.
+      CALL getin('ok_dyn_ave', ok_dyn_ave)
+
+      WRITE(lunout, *)' #########################################'
+      WRITE(lunout, *)' Configuration des parametres du gcm: '
+      WRITE(lunout, *)' planet_type = ', planet_type
+      WRITE(lunout, *)' calend = ', calend
+      WRITE(lunout, *)' dayref = ', dayref
+      WRITE(lunout, *)' anneeref = ', anneeref
+      WRITE(lunout, *)' nday = ', nday
+      WRITE(lunout, *)' day_step = ', day_step
+      WRITE(lunout, *)' iperiod = ', iperiod
+      WRITE(lunout, *)' nsplit_phys = ', nsplit_phys
+      WRITE(lunout, *)' iconser = ', iconser
+      WRITE(lunout, *)' iecri = ', iecri
+      WRITE(lunout, *)' periodav = ', periodav
+      WRITE(lunout, *)' output_grads_dyn = ', output_grads_dyn
+      WRITE(lunout, *)' dissip_period = ', dissip_period
+      WRITE(lunout, *)' lstardis = ', lstardis
+      WRITE(lunout, *)' nitergdiv = ', nitergdiv
+      WRITE(lunout, *)' nitergrot = ', nitergrot
+      WRITE(lunout, *)' niterh = ', niterh
+      WRITE(lunout, *)' tetagdiv = ', tetagdiv
+      WRITE(lunout, *)' tetagrot = ', tetagrot
+      WRITE(lunout, *)' tetatemp = ', tetatemp
+      WRITE(lunout, *)' coefdis = ', coefdis
+      WRITE(lunout, *)' purmats = ', purmats
+      WRITE(lunout, *)' read_start = ', read_start
+      WRITE(lunout, *)' iflag_phys = ', iflag_phys
+      WRITE(lunout, *)' iphysiq = ', iphysiq
+      WRITE(lunout, *)' clonn = ', clonn
+      WRITE(lunout, *)' clatt = ', clatt
+      WRITE(lunout, *)' grossismx = ', grossismx
+      WRITE(lunout, *)' grossismy = ', grossismy
+      WRITE(lunout, *)' fxyhypbb = ', fxyhypbb
+      WRITE(lunout, *)' dzoomxx = ', dzoomxx
+      WRITE(lunout, *)' dzoomy = ', dzoomyy
+      WRITE(lunout, *)' tauxx = ', tauxx
+      WRITE(lunout, *)' tauyy = ', tauyy
+      WRITE(lunout, *)' offline = ', offline
+      WRITE(lunout, *)' type_trac = ', type_trac
+      WRITE(lunout, *)' ok_dynzon = ', ok_dynzon
+      WRITE(lunout, *)' ok_dyn_ins = ', ok_dyn_ins
+      WRITE(lunout, *)' ok_dyn_ave = ', ok_dyn_ave
+      WRITE(lunout, *)' adv_qsat_liq = ', adv_qsat_liq
+    ELSE
+      !Config  Key  = clon
+      !Config  Desc = centre du zoom, longitude
+      !Config  Def  = 0
+      !Config  Help = longitude en degres du centre
+      !Config         du zoom
+      clon = 0.
+      CALL getin('clon', clon)
+
+      !Config  Key  = clat
+      !Config  Desc = centre du zoom, latitude
+      !Config  Def  = 0
+      !Config  Help = latitude en degres du centre du zoom
+      !Config
+      clat = 0.
+      CALL getin('clat', clat)
+
+      !Config  Key  = grossismx
+      !Config  Desc = zoom en longitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la longitude
+      grossismx = 1.0
+      CALL getin('grossismx', grossismx)
+
+      !Config  Key  = grossismy
+      !Config  Desc = zoom en latitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la latitude
+      grossismy = 1.0
+      CALL getin('grossismy', grossismy)
+
+      IF(grossismx<1.)  THEN
+        WRITE(lunout, *) &
+                'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphax = 1. - 1. / grossismx
+      ENDIF
+
+      IF(grossismy<1.)  THEN
+        WRITE(lunout, *) 'conf_gcm: ***ATTENTION !! grossismy < 1 . *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphay = 1. - 1. / grossismy
+      ENDIF
+
+      WRITE(lunout, *)'conf_gcm: alphax alphay ', alphax, alphay
+
+      !    alphax et alphay sont les anciennes formulat. des grossissements
+
+      !Config  Key  = fxyhypb
+      !Config  Desc = Fonction  hyperbolique
+      !Config  Def  = y
+      !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
+      !Config         sinon  sinusoidale
+      fxyhypb = .TRUE.
+      CALL getin('fxyhypb', fxyhypb)
+
+      !Config  Key  = dzoomx
+      !Config  Desc = extension en longitude
+      !Config  Def  = 0
+      !Config  Help = extension en longitude  de la zone du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomx = 0.2
+      CALL getin('dzoomx', dzoomx)
+      CALL assert(dzoomx < 1, "conf_gcm: dzoomx must be < 1")
+
+      !Config  Key  = dzoomy
+      !Config  Desc = extension en latitude
+      !Config  Def  = 0
+      !Config  Help = extension en latitude de la zone  du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomy = 0.2
+      CALL getin('dzoomy', dzoomy)
+      CALL assert(dzoomy < 1, "conf_gcm: dzoomy must be < 1")
+
+      !Config  Key  = taux
+      !Config  Desc = raideur du zoom en  X
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  X
+      taux = 3.0
+      CALL getin('taux', taux)
+
+      !Config  Key  = tauy
+      !Config  Desc = raideur du zoom en  Y
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  Y
+      tauy = 3.0
+      CALL getin('tauy', tauy)
+
+      !Config  Key  = ysinus
+      !Config  IF   = !fxyhypb
+      !Config  Desc = Fonction en Sinus
+      !Config  Def  = y
+      !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
+      !Config         sinon y = latit.
+      ysinus = .TRUE.
+      CALL getin('ysinus', ysinus)
+
+      !Config  Key  = offline
+      !Config  Desc = Nouvelle eau liquide
+      !Config  Def  = n
+      !Config  Help = Permet de mettre en route la
+      !Config         nouvelle parametrisation de l'eau liquide !
+      offline = .FALSE.
+      CALL getin('offline', offline)
+
+      !Config  Key  = type_trac
+      !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
+      !Config  Def  = lmdz
+      !Config  Help =
+      !Config         'lmdz' = pas de couplage, pur LMDZ
+      !Config         'inca' = model de chime INCA
+      !Config         'repr' = model de chime REPROBUS
+      !Config         'inco' = INCA + CO2i (temporaire)
+      type_trac = 'lmdz'
+      CALL getin('type_trac', type_trac)
+
+      !Config  Key  = ok_dynzon
+      !Config  Desc = sortie des transports zonaux dans la dynamique
+      !Config  Def  = n
+      !Config  Help = Permet de mettre en route le calcul des transports
+      !Config
+      ok_dynzon = .FALSE.
+      CALL getin('ok_dynzon', ok_dynzon)
+
+      !Config  Key  = ok_dyn_ins
+      !Config  Desc = sorties instantanees dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ins = .FALSE.
+      CALL getin('ok_dyn_ins', ok_dyn_ins)
+
+      !Config  Key  = ok_dyn_ave
+      !Config  Desc = sorties moyennes dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ave = .FALSE.
+      CALL getin('ok_dyn_ave', ok_dyn_ave)
+
+      !Config key = ok_strato
+      !Config  Desc = activation de la version strato
+      !Config  Def  = .FALSE.
+      !Config  Help = active la version stratosph\'erique de LMDZ de F. Lott
+
+      ok_strato = .FALSE.
+      CALL getin('ok_strato', ok_strato)
+
+      vert_prof_dissip = merge(1, 0, ok_strato .AND. llm==39)
+      CALL getin('vert_prof_dissip', vert_prof_dissip)
+      CALL assert(vert_prof_dissip == 0 .OR. vert_prof_dissip ==  1, &
+              "bad value for vert_prof_dissip")
+
+      !Config  Key  = ok_gradsfile
+      !Config  Desc = activation des sorties grads du guidage
+      !Config  Def  = n
+      !Config  Help = active les sorties grads du guidage
+
+      ok_gradsfile = .FALSE.
+      CALL getin('ok_gradsfile', ok_gradsfile)
+
+      !Config  Key  = ok_limit
+      !Config  Desc = creation des fichiers limit dans create_etat0_limit
+      !Config  Def  = y
+      !Config  Help = production du fichier limit.nc requise
+
+      ok_limit = .TRUE.
+      CALL getin('ok_limit', ok_limit)
+
+      !Config  Key  = ok_etat0
+      !Config  Desc = creation des fichiers etat0 dans create_etat0_limit
+      !Config  Def  = y
+      !Config  Help = production des fichiers start.nc, startphy.nc requise
+
+      ok_etat0 = .TRUE.
+      CALL getin('ok_etat0', ok_etat0)
+
+      !Config  Key  = read_orop
+      !Config  Desc = lecture du fichier de params orographiques sous maille
+      !Config  Def  = f
+      !Config  Help = lecture fichier plutot que grid_noro
+
+      read_orop = .FALSE.
+      CALL getin('read_orop', read_orop)
+
+      WRITE(lunout, *)' #########################################'
+      WRITE(lunout, *)' Configuration des parametres de cel0_limit: '
+      WRITE(lunout, *)' planet_type = ', planet_type
+      WRITE(lunout, *)' calend = ', calend
+      WRITE(lunout, *)' dayref = ', dayref
+      WRITE(lunout, *)' anneeref = ', anneeref
+      WRITE(lunout, *)' nday = ', nday
+      WRITE(lunout, *)' day_step = ', day_step
+      WRITE(lunout, *)' iperiod = ', iperiod
+      WRITE(lunout, *)' iconser = ', iconser
+      WRITE(lunout, *)' iecri = ', iecri
+      WRITE(lunout, *)' periodav = ', periodav
+      WRITE(lunout, *)' output_grads_dyn = ', output_grads_dyn
+      WRITE(lunout, *)' dissip_period = ', dissip_period
+      WRITE(lunout, *)' lstardis = ', lstardis
+      WRITE(lunout, *)' nitergdiv = ', nitergdiv
+      WRITE(lunout, *)' nitergrot = ', nitergrot
+      WRITE(lunout, *)' niterh = ', niterh
+      WRITE(lunout, *)' tetagdiv = ', tetagdiv
+      WRITE(lunout, *)' tetagrot = ', tetagrot
+      WRITE(lunout, *)' tetatemp = ', tetatemp
+      WRITE(lunout, *)' coefdis = ', coefdis
+      WRITE(lunout, *)' purmats = ', purmats
+      WRITE(lunout, *)' read_start = ', read_start
+      WRITE(lunout, *)' iflag_phys = ', iflag_phys
+      WRITE(lunout, *)' iphysiq = ', iphysiq
+      WRITE(lunout, *)' clon = ', clon
+      WRITE(lunout, *)' clat = ', clat
+      WRITE(lunout, *)' grossismx = ', grossismx
+      WRITE(lunout, *)' grossismy = ', grossismy
+      WRITE(lunout, *)' fxyhypb = ', fxyhypb
+      WRITE(lunout, *)' dzoomx = ', dzoomx
+      WRITE(lunout, *)' dzoomy = ', dzoomy
+      WRITE(lunout, *)' taux = ', taux
+      WRITE(lunout, *)' tauy = ', tauy
+      WRITE(lunout, *)' offline = ', offline
+      WRITE(lunout, *)' type_trac = ', type_trac
+      WRITE(lunout, *)' ok_dynzon = ', ok_dynzon
+      WRITE(lunout, *)' ok_dyn_ins = ', ok_dyn_ins
+      WRITE(lunout, *)' ok_dyn_ave = ', ok_dyn_ave
+      WRITE(lunout, *)' ok_strato = ', ok_strato
+      WRITE(lunout, *)' ok_gradsfile = ', ok_gradsfile
+      WRITE(lunout, *)' ok_limit = ', ok_limit
+      WRITE(lunout, *)' ok_etat0 = ', ok_etat0
+      WRITE(lunout, *)' ok_guide = ', ok_guide
+      WRITE(lunout, *)' read_orop = ', read_orop
+    ENDIF test_etatinit
+
+  END SUBROUTINE conf_gcm
+
+
+END MODULE lmdz_conf_gcm
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dissip.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dissip.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dissip.f90	(revision 5186)
@@ -0,0 +1,151 @@
+MODULE lmdz_dissip
+  IMPLICIT NONE; PRIVATE
+  PUBLIC dissip
+
+CONTAINS
+
+  SUBROUTINE dissip(vcov, ucov, teta, p, dv, du, dh)
+    USE comconst_mod, ONLY: dtdiss
+    USE lmdz_comdissipn, ONLY: tetaudiv, tetaurot, tetah, cdivu, crot, cdivh
+    USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
+            tetagrot, tetatemp, coefdis, vert_prof_dissip
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+
+    ! ..  Avec nouveaux operateurs star :  gradiv2 , divgrad2, nxgraro2  ...
+    ! (  10/01/98  )
+
+    !=======================================================================
+
+    !   Auteur:  P. Le Van
+    !   -------
+
+    !   Objet:
+    !   ------
+
+    !   Dissipation horizontale
+
+    !=======================================================================
+    !-----------------------------------------------------------------------
+    !   Declarations:
+    !   -------------
+
+
+
+
+    !   Arguments:
+    !   ----------
+
+    REAL, INTENT(IN) :: vcov(ip1jm, llm) ! covariant meridional wind
+    REAL, INTENT(IN) :: ucov(ip1jmp1, llm) ! covariant zonal wind
+    REAL, INTENT(IN) :: teta(ip1jmp1, llm) ! potential temperature
+    REAL, INTENT(IN) :: p(ip1jmp1, llmp1) ! pressure
+    ! tendencies (.../s) on covariant winds and potential temperature
+    REAL, INTENT(OUT) :: dv(ip1jm, llm)
+    REAL, INTENT(OUT) :: du(ip1jmp1, llm)
+    REAL, INTENT(OUT) :: dh(ip1jmp1, llm)
+
+    !   Local:
+    !   ------
+
+    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
+
+    !-----------------------------------------------------------------------
+    !   initialisations:
+    !   ----------------
+
+    DO l = 1, llm
+      te1dt(l) = tetaudiv(l) * dtdiss
+      te2dt(l) = tetaurot(l) * dtdiss
+      te3dt(l) = tetah(l) * dtdiss
+    ENDDO
+    du = 0.
+    dv = 0.
+    dh = 0.
+
+    !-----------------------------------------------------------------------
+    !   Calcul de la dissipation:
+    !   -------------------------
+
+    !   Calcul de la partie   grad  ( div ) :
+    !   -------------------------------------
+
+    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
+
+    !   calcul de la partie   n X grad ( rot ):
+    !   ---------------------------------------
+
+    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
+
+    !   calcul de la partie   div ( grad ):
+    !   -----------------------------------
+
+    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
+
+  END SUBROUTINE dissip
+
+
+END MODULE lmdz_dissip
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dteta1.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dteta1.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dteta1.f90	(revision 5186)
@@ -0,0 +1,71 @@
+MODULE lmdz_dteta1
+  IMPLICIT NONE; PRIVATE
+  PUBLIC dteta1
+
+CONTAINS
+
+
+  SUBROUTINE dteta1(teta, pbaru, pbarv, dteta)
+    USE lmdz_filtreg, ONLY: filtreg
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+    !=======================================================================
+
+    !   Auteur:  P. Le Van
+    !   -------
+    ! Modif F.Forget 03/94 (on retire q et dq  pour construire dteta1)
+
+    !   ********************************************************************
+    !   ... calcul du terme de convergence horizontale du flux d'enthalpie
+    !    potentielle   ......
+    !   ********************************************************************
+    !  .. teta,pbaru et pbarv sont des arguments d'entree  pour le s-pg ....
+    ! dteta               sont des arguments de sortie pour le s-pg ....
+
+    !=======================================================================
+
+    REAL :: teta(ip1jmp1, llm), pbaru(ip1jmp1, llm), pbarv(ip1jm, llm)
+    REAL :: dteta(ip1jmp1, llm)
+    INTEGER :: l, ij
+
+    REAL :: hbyv(ip1jm, llm), hbxu(ip1jmp1, llm)
+
+    !
+
+    DO l = 1, llm
+
+      DO ij = iip2, ip1jm - 1
+        hbxu(ij, l) = pbaru(ij, l) * 0.5 * (teta(ij, l) + teta(ij + 1, l))
+      END DO
+
+      !    .... correction pour  hbxu(iip1,j,l)  .....
+      !    ....   hbxu(iip1,j,l)= hbxu(1,j,l) ....
+
+      !DIR$ IVDEP
+      DO ij = iip1 + iip1, ip1jm, iip1
+        hbxu(ij, l) = hbxu(ij - iim, l)
+      END DO
+
+      DO ij = 1, ip1jm
+        hbyv(ij, l) = pbarv(ij, l) * 0.5 * (teta(ij, l) + teta(ij + iip1, l))
+      END DO
+
+    END DO
+
+    CALL  convflu (hbxu, hbyv, llm, dteta)
+
+
+    !    stockage dans  dh de la convergence horizont. filtree' du  flux
+    ! ....                           ...........
+    ! d'enthalpie potentielle .
+
+    CALL filtreg(dteta, jjp1, llm, 2, 2, .TRUE., 1)
+
+    !
+
+  END SUBROUTINE dteta1
+
+
+END MODULE lmdz_dteta1
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dudv1.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dudv1.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dudv1.f90	(revision 5186)
@@ -0,0 +1,58 @@
+MODULE lmdz_dudv1
+  IMPLICIT NONE; PRIVATE
+  PUBLIC dudv1
+
+CONTAINS
+
+
+  SUBROUTINE dudv1(vorpot, pbaru, pbarv, du, dv)
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+    !-----------------------------------------------------------------------
+
+    !   Auteur:   P. Le Van
+    !   -------
+
+    !   Objet:
+    !   ------
+    !   calcul du terme de  rotation
+    !   ce terme est ajoute a  d(ucov)/dt et a d(vcov)/dt  ..
+    !   vorpot, pbaru et pbarv sont des arguments d'entree  pour le s-pg ..
+    !   du  et dv              sont des arguments de sortie pour le s-pg ..
+
+    !-----------------------------------------------------------------------
+
+    REAL :: vorpot(ip1jm, llm), pbaru(ip1jmp1, llm), &
+            pbarv(ip1jm, llm), du(ip1jmp1, llm), dv(ip1jm, llm)
+    INTEGER :: l, ij
+
+    DO l = 1, llm
+
+      DO 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))
+      END DO
+
+      DO 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))
+      END DO
+
+      !    .... correction  pour  dv( 1,j,l )  .....
+      !    ....   dv(1,j,l)= dv(iip1,j,l) ....
+
+      !DIR$ IVDEP
+      DO ij = 1, ip1jm, iip1
+        dv(ij, l) = dv(ij + iim, l)
+      END DO
+
+    END DO
+
+  END SUBROUTINE dudv1
+
+
+END MODULE lmdz_dudv1
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dudv2.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dudv2.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dudv2.f90	(revision 5186)
@@ -0,0 +1,66 @@
+MODULE lmdz_dudv2
+  IMPLICIT NONE; PRIVATE
+  PUBLIC dudv2
+
+CONTAINS
+
+  SUBROUTINE dudv2(teta, pkf, bern, du, dv)
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+    !=======================================================================
+
+    !   Auteur:  P. Le Van
+    !   -------
+
+    !   Objet:
+    !   ------
+
+    !   *****************************************************************
+    !   ..... calcul du terme de pression (gradient de p/densite )   et
+    !      du terme de ( -gradient de la fonction de Bernouilli ) ...
+    !   *****************************************************************
+    !      Ces termes sont ajoutes a  d(ucov)/dt et a d(vcov)/dt  ..
+
+
+    !    teta , pkf, bern  sont des arguments d'entree  pour le s-pg  ....
+    !    du et dv          sont des arguments de sortie pour le s-pg  ....
+
+    !=======================================================================
+    !
+
+    REAL :: teta(ip1jmp1, llm), pkf(ip1jmp1, llm), bern(ip1jmp1, llm), &
+            du(ip1jmp1, llm), dv(ip1jm, llm)
+    INTEGER :: l, ij
+
+    DO l = 1, llm
+
+      DO 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)
+      END DO
+
+
+      !    .....  correction  pour du(iip1,j,l),  j=2,jjm   ......
+      !    ...          du(iip1,j,l) = du(1,j,l)                 ...
+
+      !DIR$ IVDEP
+      DO ij = iip1 + iip1, ip1jm, iip1
+        du(ij, l) = du(ij - iim, l)
+      END DO
+
+      DO 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)
+      END DO
+
+    END DO
+    !
+
+  END SUBROUTINE dudv2
+
+
+END MODULE lmdz_dudv2
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dynredem.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dynredem.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_dynredem.f90	(revision 5186)
@@ -0,0 +1,254 @@
+MODULE lmdz_dynredem
+  IMPLICIT NONE; PRIVATE
+  PUBLIC dynredem0, dynredem1
+
+
+CONTAINS
+
+  SUBROUTINE dynredem0(fichnom, iday_end, phis)
+
+    !-------------------------------------------------------------------------------
+    ! Write the NetCDF restart file (initialization).
+    !-------------------------------------------------------------------------------
+    USE IOIPSL
+    USE lmdz_strings, ONLY: maxlen
+    USE lmdz_infotrac, ONLY: nqtot, tracers
+    USE netcdf, ONLY: nf90_create, nf90_def_dim, nf90_inq_varid, nf90_global, &
+            nf90_close, nf90_put_att, nf90_unlimited, nf90_clobber, &
+            nf90_64bit_offset
+    USE dynredem_mod, ONLY: cre_var, put_var1, put_var2, err, modname, fil
+    USE comvert_mod, ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs
+    USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad
+    USE logic_mod, ONLY: fxyhypb, ysinus
+    USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, &
+            taux, tauy
+    USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itaufin, start_time
+    USE ener_mod, ONLY: etot0, ptot0, ztot0, stot0, ang0
+    USE lmdz_description, ONLY: descript
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_comgeom2
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+
+    !===============================================================================
+    ! Arguments:
+    CHARACTER(LEN = *), INTENT(IN) :: fichnom          !--- FILE NAME
+    INTEGER, INTENT(IN) :: iday_end         !---
+    REAL, INTENT(IN) :: phis(iip1, jjp1) !--- GROUND GEOPOTENTIAL
+    !===============================================================================
+    ! Local variables:
+    INTEGER :: iq
+    INTEGER, PARAMETER :: length = 100
+    REAL :: tab_cntrl(length)                     !--- RUN PARAMETERS TABLE
+    !   For NetCDF:
+    CHARACTER(LEN = maxlen) :: unites
+    INTEGER :: indexID
+    INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID
+    INTEGER :: sID, sigID, nID, timID
+    INTEGER :: yyears0, jjour0, mmois0
+    REAL :: zjulian, hours
+    !===============================================================================
+    modname = 'dynredem0'; fil = fichnom
+    CALL ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian)
+    CALL ju2ymds(zjulian, yyears0, mmois0, jjour0, hours)
+
+    tab_cntrl(:) = 0.
+    tab_cntrl(1) = REAL(iim)
+    tab_cntrl(2) = REAL(jjm)
+    tab_cntrl(3) = REAL(llm)
+    tab_cntrl(4) = REAL(day_ref)
+    tab_cntrl(5) = REAL(annee_ref)
+    tab_cntrl(6) = rad
+    tab_cntrl(7) = omeg
+    tab_cntrl(8) = g
+    tab_cntrl(9) = cpp
+    tab_cntrl(10) = kappa
+    tab_cntrl(11) = daysec
+    tab_cntrl(12) = dtvr
+    tab_cntrl(13) = etot0
+    tab_cntrl(14) = ptot0
+    tab_cntrl(15) = ztot0
+    tab_cntrl(16) = stot0
+    tab_cntrl(17) = ang0
+    tab_cntrl(18) = pa
+    tab_cntrl(19) = preff
+
+    !    .....    parameters for zoom    ......
+    tab_cntrl(20) = clon
+    tab_cntrl(21) = clat
+    tab_cntrl(22) = grossismx
+    tab_cntrl(23) = grossismy
+
+    IF (fxyhypb)   THEN
+      tab_cntrl(24) = 1.
+      tab_cntrl(25) = dzoomx
+      tab_cntrl(26) = dzoomy
+      tab_cntrl(27) = 0.
+      tab_cntrl(28) = taux
+      tab_cntrl(29) = tauy
+    ELSE
+      tab_cntrl(24) = 0.
+      tab_cntrl(25) = dzoomx
+      tab_cntrl(26) = dzoomy
+      tab_cntrl(27) = 0.
+      tab_cntrl(28) = 0.
+      tab_cntrl(29) = 0.
+      IF(ysinus)  tab_cntrl(27) = 1.
+    END IF
+    tab_cntrl(30) = REAL(iday_end)
+    tab_cntrl(31) = REAL(itau_dyn + itaufin)
+    ! start_time: start_time of simulation (not necessarily 0.)
+    tab_cntrl(32) = start_time
+
+    !--- File creation
+    CALL err(nf90_create(fichnom, IOR(nf90_clobber, nf90_64bit_offset), nid))
+
+    !--- Some global attributes
+    CALL err(nf90_put_att(nid, nf90_global, "title", "Fichier demarrage dynamique"))
+
+    !--- Dimensions
+    CALL err(nf90_def_dim(nid, "index", length, indexID))
+    CALL err(nf90_def_dim(nid, "rlonu", iip1, rlonuID))
+    CALL err(nf90_def_dim(nid, "rlatu", jjp1, rlatuID))
+    CALL err(nf90_def_dim(nid, "rlonv", iip1, rlonvID))
+    CALL err(nf90_def_dim(nid, "rlatv", jjm, rlatvID))
+    CALL err(nf90_def_dim(nid, "sigs", llm, sID))
+    CALL err(nf90_def_dim(nid, "sig", llmp1, sigID))
+    CALL err(nf90_def_dim(nid, "temps", nf90_unlimited, timID))
+
+    !--- Define and save invariant fields
+    CALL put_var1(nid, "controle", "Parametres de controle", [indexID], tab_cntrl)
+    CALL put_var1(nid, "rlonu", "Longitudes des points U", [rlonuID], rlonu)
+    CALL put_var1(nid, "rlatu", "Latitudes des points U", [rlatuID], rlatu)
+    CALL put_var1(nid, "rlonv", "Longitudes des points V", [rlonvID], rlonv)
+    CALL put_var1(nid, "rlatv", "Latitudes des points V", [rlatvID], rlatv)
+    CALL put_var1(nid, "nivsigs", "Numero naturel des couches s", [sID], nivsigs)
+    CALL put_var1(nid, "nivsig", "Numero naturel des couches sigma", [sigID], nivsig)
+    CALL put_var1(nid, "ap", "Coefficient A pour hybride", [sigID], ap)
+    CALL put_var1(nid, "bp", "Coefficient B pour hybride", [sigID], bp)
+    CALL put_var1(nid, "presnivs", "", [sID], presnivs)
+    ! covariant <-> contravariant <-> natural conversion coefficients
+    CALL put_var2(nid, "cu", "Coefficient de passage pour U", [rlonuID, rlatuID], cu)
+    CALL put_var2(nid, "cv", "Coefficient de passage pour V", [rlonvID, rlatvID], cv)
+    CALL put_var2(nid, "aire", "Aires de chaque maille", [rlonvID, rlatuID], aire)
+    CALL put_var2(nid, "phisinit", "Geopotentiel au sol", [rlonvID, rlatuID], phis)
+
+    !--- Define fields saved later
+    WRITE(unites, "('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") &
+            yyears0, mmois0, jjour0
+    CALL cre_var(nid, "temps", "Temps de simulation", [timID], unites)
+    CALL cre_var(nid, "ucov", "Vitesse U", [rlonuID, rlatuID, sID, timID])
+    CALL cre_var(nid, "vcov", "Vitesse V", [rlonvID, rlatvID, sID, timID])
+    CALL cre_var(nid, "teta", "Temperature", [rlonvID, rlatuID, sID, timID])
+    DO iq = 1, nqtot
+      CALL cre_var(nid, tracers(iq)%name, tracers(iq)%longName, [rlonvID, rlatuID, sID, timID])
+    END DO
+    CALL cre_var(nid, "masse", "Masse d air", [rlonvID, rlatuID, sID, timID])
+    CALL cre_var(nid, "ps", "Pression au sol", [rlonvID, rlatuID, timID])
+    CALL err(nf90_close (nid))
+
+    WRITE(lunout, *)TRIM(modname) // ': iim,jjm,llm,iday_end', iim, jjm, llm, iday_end
+    WRITE(lunout, *)TRIM(modname) // ': rad,omeg,g,cpp,kappa', rad, omeg, g, cpp, kappa
+
+  END SUBROUTINE dynredem0
+
+  !-------------------------------------------------------------------------------
+
+
+  !-------------------------------------------------------------------------------
+
+  SUBROUTINE dynredem1(fichnom, time, vcov, ucov, teta, q, masse, ps)
+
+    !-------------------------------------------------------------------------------
+    ! Purpose: Write the NetCDF restart file (append).
+    !-------------------------------------------------------------------------------
+    USE lmdz_strings, ONLY: maxlen
+    USE lmdz_infotrac, ONLY: nqtot, tracers, type_trac
+    USE control_mod
+    USE netcdf, ONLY: nf90_open, nf90_nowrite, nf90_get_var, nf90_inq_varid, &
+            nf90_close, nf90_write, nf90_put_var, nf90_noerr
+    USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, &
+            err, modname, fil, msg
+    USE temps_mod, ONLY: itau_dyn, itaufin
+    USE lmdz_description, ONLY: descript
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+
+    !===============================================================================
+    ! Arguments:
+    CHARACTER(LEN = *), INTENT(IN) :: fichnom              !-- FILE NAME
+    REAL, INTENT(IN) :: time                         !-- TIME
+    REAL, INTENT(IN) :: vcov(iip1, jjm, llm)          !-- V COVARIANT WIND
+    REAL, INTENT(IN) :: ucov(iip1, jjp1, llm)          !-- U COVARIANT WIND
+    REAL, INTENT(IN) :: teta(iip1, jjp1, llm)          !-- POTENTIAL TEMPERATURE
+    REAL, INTENT(INOUT) :: q(iip1, jjp1, llm, nqtot)    !-- TRACERS
+    REAL, INTENT(IN) :: masse(iip1, jjp1, llm)          !-- MASS PER CELL
+    REAL, INTENT(IN) :: ps(iip1, jjp1)              !-- GROUND PRESSURE
+    !===============================================================================
+    ! Local variables:
+    INTEGER :: iq, nid, vID, ierr, nid_trac, vID_trac
+    INTEGER, SAVE :: nb = 0
+    INTEGER, PARAMETER :: length = 100
+    REAL :: tab_cntrl(length) ! tableau des parametres du run
+    CHARACTER(LEN = maxlen) :: var, dum
+    LOGICAL :: lread_inca
+    !===============================================================================
+
+    modname = 'dynredem1'; fil = fichnom
+    CALL err(nf90_open(fil, nf90_write, nid), "open", fil)
+
+    !--- Write/extend time coordinate
+    nb = nb + 1
+    var = "temps"
+    CALL err(nf90_inq_varid(nid, var, vID), "inq", var)
+    CALL err(nf90_put_var(nid, vID, [time]), "put", var)
+    WRITE(lunout, *)TRIM(modname) // ": Saving for ", nb, time
+
+    !--- Rewrite control table (itaufin undefined in dynredem0)
+    var = "controle"
+    CALL err(nf90_inq_varid(nid, var, vID), "inq", var)
+    CALL err(nf90_get_var(nid, vID, tab_cntrl), "get", var)
+    tab_cntrl(31) = DBLE(itau_dyn + itaufin)
+    CALL err(nf90_inq_varid(nid, var, vID), "inq", var)
+    CALL err(nf90_put_var(nid, vID, tab_cntrl), "put", var)
+
+    !--- Save fields
+    CALL dynredem_write_u(nid, "ucov", ucov, llm)
+    CALL dynredem_write_v(nid, "vcov", vcov, llm)
+    CALL dynredem_write_u(nid, "teta", teta, llm)
+    CALL dynredem_write_u(nid, "masse", masse, llm)
+    CALL dynredem_write_u(nid, "ps", ps, 1)
+
+    !--- Tracers in file "start_trac.nc" (added by Anne)
+    lread_inca = .FALSE.; fil = "start_trac.nc"
+    IF(ANY(type_trac == ['inca', 'inco'])) INQUIRE(FILE = fil, EXIST = lread_inca)
+    IF(lread_inca) CALL err(nf90_open(fil, nf90_nowrite, nid_trac), "open")
+
+    !--- Save tracers
+    DO iq = 1, nqtot; var = TRIM(tracers(iq)%name); ierr = -1
+    IF(lread_inca) THEN                  !--- Possibly read from "start_trac.nc"
+      fil = "start_trac.nc"
+      ierr = nf90_inq_varid(nid_trac, var, vID_trac)
+      dum = 'inq'; IF(ierr==nf90_noerr) dum = 'fnd'
+      WRITE(lunout, *)msg(dum, var)
+
+      IF(ierr==nf90_noerr) CALL dynredem_read_u(nid_trac, var, q(:, :, :, iq), llm)
+    END IF
+    fil = fichnom
+    CALL dynredem_write_u(nid, var, q(:, :, :, iq), llm)
+    END DO
+    CALL err(nf90_close(nid), "close")
+    fil = "start_trac.nc"
+    IF(lread_inca) CALL err(nf90_close(nid_trac), "close")
+
+  END SUBROUTINE dynredem1
+
+END MODULE lmdz_dynredem
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_leapfrog.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_leapfrog.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/lmdz_leapfrog.f90	(revision 5186)
@@ -0,0 +1,844 @@
+MODULE lmdz_leapfrog
+
+  IMPLICIT NONE; PRIVATE
+  PUBLIC leapfrog
+
+CONTAINS
+
+  SUBROUTINE leapfrog(ucov, vcov, teta, ps, masse, phis, q, time_0)
+
+    !IM : pour sortir les param. du modele dans un fis. netcdf 110106
+    USE IOIPSL
+    USE lmdz_infotrac, ONLY: nqtot, isoCheck
+    USE guide_mod, ONLY: guide_main
+    USE lmdz_write_field, ONLY: writefield
+    USE control_mod, ONLY: nday, day_step, planet_type, offline, &
+            iconser, iphysiq, iperiod, dissip_period, &
+            iecri, ip_ebil_dyn, ok_dynzon, ok_dyn_ins, &
+            periodav, ok_dyn_ave, output_grads_dyn
+    USE exner_hyb_m, ONLY: exner_hyb
+    USE exner_milieu_m, ONLY: exner_milieu
+    USE comvert_mod, ONLY: ap, bp, pressure_exner, presnivs
+    USE comconst_mod, ONLY: cpp, dtphys, dtvr, pi, ihf
+    USE logic_mod, ONLY: iflag_phys, ok_guide, forward, leapf, apphys, &
+            statcl, conser, apdiss, purmats, ok_strato
+    USE temps_mod, ONLY: jD_ref, jH_ref, itaufin, day_ini, day_ref, &
+            start_time, dt
+    USE lmdz_strings, ONLY: msg
+    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
+    USE lmdz_description, ONLY: descript
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_ssum_scopy, ONLY: scopy, ssum
+    USE lmdz_academic, ONLY: tetarappel, knewt_t, kfrict, knewt_g, clat4
+    USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
+            tetagrot, tetatemp, coefdis, vert_prof_dissip
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    USE lmdz_addfi, ONLY: addfi
+    USE lmdz_caldyn, ONLY: caldyn
+    USE lmdz_caladvtrac, ONLY: caladvtrac
+    USE lmdz_bilan_dyn, ONLY: bilan_dyn
+    USE lmdz_check_isotopes, ONLY: check_isotopes_seq
+    USE lmdz_writedynav, ONLY: writedynav
+    USE lmdz_writehist, ONLY: writehist
+    USE lmdz_dissip, ONLY: dissip
+    USE lmdz_dynredem, ONLY: dynredem1
+
+    IMPLICIT NONE
+
+    ! ......   Version  du 10/01/98    ..........
+
+    !        avec  coordonnees  verticales hybrides
+    !   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
+
+    !=======================================================================
+
+    !   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
+    !   -------
+
+    !   Objet:
+    !   ------
+
+    !   GCM LMD nouvelle grille
+
+    !=======================================================================
+
+    !  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
+    !  et possibilite d'appeler une fonction f(y)  a derivee tangente
+    !  hyperbolique a la  place de la fonction a derivee sinusoidale.
+
+    !  ... Possibilite de choisir le shema pour l'advection de
+    !    q  , en modifiant iadv dans traceur.def  (10/02) .
+
+    !  Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
+    !  Pour Van-Leer iadv=10
+
+    !-----------------------------------------------------------------------
+    !   Declarations:
+    !   -------------
+
+    REAL, INTENT(IN) :: time_0 ! not used
+
+    !   dynamical variables:
+    REAL, INTENT(INOUT) :: ucov(ip1jmp1, llm)    ! zonal covariant wind
+    REAL, INTENT(INOUT) :: vcov(ip1jm, llm)      ! meridional covariant wind
+    REAL, INTENT(INOUT) :: teta(ip1jmp1, llm)    ! potential temperature
+    REAL, INTENT(INOUT) :: ps(ip1jmp1)          ! surface pressure (Pa)
+    REAL, INTENT(INOUT) :: masse(ip1jmp1, llm)   ! air mass
+    REAL, INTENT(INOUT) :: phis(ip1jmp1)        ! geopotentiat at the surface
+    REAL, INTENT(INOUT) :: q(ip1jmp1, llm, nqtot) ! advected tracers
+
+    REAL :: p (ip1jmp1, llmp1)               ! interlayer pressure
+    REAL :: pks(ip1jmp1)                      ! exner at the surface
+    REAL :: pk(ip1jmp1, llm)                   ! exner at mid-layer
+    REAL :: pkf(ip1jmp1, llm)                  ! filtered exner at mid-layer
+    REAL :: phi(ip1jmp1, llm)                  ! geopotential
+    REAL :: w(ip1jmp1, llm)                    ! vertical velocity
+
+    REAL :: zqmin, zqmax
+
+    ! variables dynamiques intermediaire pour le transport
+    REAL :: pbaru(ip1jmp1, llm), pbarv(ip1jm, llm) !flux de masse
+
+    !   variables dynamiques au pas -1
+    REAL :: vcovm1(ip1jm, llm), ucovm1(ip1jmp1, llm)
+    REAL :: tetam1(ip1jmp1, llm), psm1(ip1jmp1)
+    REAL :: massem1(ip1jmp1, llm)
+
+    !   tendances dynamiques
+    REAL :: dv(ip1jm, llm), du(ip1jmp1, llm)
+    REAL :: dteta(ip1jmp1, llm), dq(ip1jmp1, llm, nqtot), dp(ip1jmp1)
+
+    !   tendances de la dissipation
+    REAL :: dvdis(ip1jm, llm), dudis(ip1jmp1, llm)
+    REAL :: dtetadis(ip1jmp1, llm)
+
+    !   tendances physiques
+    REAL :: dvfi(ip1jm, llm), dufi(ip1jmp1, llm)
+    REAL :: dtetafi(ip1jmp1, llm), dqfi(ip1jmp1, llm, nqtot), dpfi(ip1jmp1)
+
+    !   variables pour le fichier histoire
+    REAL :: dtav      ! intervalle de temps elementaire
+
+    REAL :: tppn(iim), tpps(iim), tpn, tps
+
+    INTEGER :: itau, itaufinp1, iav
+    ! INTEGER  iday ! jour julien
+    REAL :: time
+
+    ! REAL finvmaold(ip1jmp1,llm)
+
+    !ym      LOGICAL  lafin
+    LOGICAL :: lafin = .FALSE.
+    INTEGER :: ij, iq, l
+    INTEGER :: ik
+
+    REAL :: time_step, t_wrt, t_ops
+
+    ! REAL rdayvrai,rdaym_ini
+    ! jD_cur: jour julien courant
+    ! jH_cur: heure julienne courante
+    REAL :: jD_cur, jH_cur
+    INTEGER :: an, mois, jour
+    REAL :: secondes
+
+    LOGICAL :: first, callinigrads
+    !IM : pour sortir les param. du modele dans un fis. netcdf 110106
+    save first
+    data first/.TRUE./
+    REAL :: dt_cum
+    CHARACTER(LEN = 10) :: infile
+    INTEGER :: zan, tau0, thoriid
+    INTEGER :: nid_ctesGCM
+    save nid_ctesGCM
+    REAL :: degres
+    REAL :: rlong(iip1), rlatg(jjp1)
+    REAL :: zx_tmp_2d(iip1, jjp1)
+    INTEGER :: ndex2d(iip1 * jjp1)
+    LOGICAL :: ok_sync
+    parameter (ok_sync = .TRUE.)
+    LOGICAL :: physic
+
+    data callinigrads/.TRUE./
+    CHARACTER(LEN = 10) :: string10
+
+    REAL :: flxw(ip1jmp1, llm)  ! flux de masse verticale
+
+    !+jld variables test conservation energie
+    REAL :: ecin(ip1jmp1, llm), ecin0(ip1jmp1, llm)
+    ! Tendance de la temp. potentiel d (theta)/ d t due a la
+    ! tansformation d'energie cinetique en energie thermique
+    ! cree par la dissipation
+    REAL :: dtetaecdt(ip1jmp1, llm)
+    REAL :: vcont(ip1jm, llm), ucont(ip1jmp1, llm)
+    REAL :: vnat(ip1jm, llm), unat(ip1jmp1, llm)
+    REAL :: d_h_vcol, d_qt, d_qw, d_ql, d_ec
+    CHARACTER(len = 15) :: ztit
+    !IM   INTEGER   ip_ebil_dyn  ! PRINT level for energy conserv. diag.
+    !IM   SAVE      ip_ebil_dyn
+    !IM   DATA      ip_ebil_dyn/0/
+    !-jld
+
+    CHARACTER(LEN = 80) :: dynhist_file, dynhistave_file
+    CHARACTER(LEN = *), parameter :: modname = "leapfrog"
+    CHARACTER(LEN = 80) :: abort_message
+
+    LOGICAL :: dissip_conservative
+    save dissip_conservative
+    data dissip_conservative/.TRUE./
+
+    LOGICAL :: prem
+    save prem
+    DATA prem/.TRUE./
+    INTEGER :: testita
+    PARAMETER (testita = 9)
+
+    logical, parameter :: flag_verif = .FALSE.
+
+    INTEGER :: itau_w   ! pas de temps ecriture = itap + itau_phy
+
+    IF (nday>=0) THEN
+      itaufin = nday * day_step
+    else
+      itaufin = -nday
+    ENDIF
+    itaufinp1 = itaufin + 1
+    itau = 0
+    physic = .TRUE.
+    IF (iflag_phys==0.OR.iflag_phys==2) physic = .FALSE.
+
+    ! iday = day_ini+itau/day_step
+    ! time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
+    !    IF(time.GT.1.) THEN
+    !     time = time-1.
+    !     iday = iday+1
+    !    ENDIF
+
+
+    !-----------------------------------------------------------------------
+    !   On initialise la pression et la fonction d'Exner :
+    !   --------------------------------------------------
+
+    dq(:, :, :) = 0.
+    CALL pression (ip1jmp1, ap, bp, ps, p)
+    IF (pressure_exner) THEN
+      CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
+    else
+      CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
+    ENDIF
+
+    !-----------------------------------------------------------------------
+    !   Debut de l'integration temporelle:
+    !   ----------------------------------
+
+    1   CONTINUE ! Matsuno Forward step begins here
+
+    !   date: (NB: date remains unchanged for Backward step)
+    !   -----
+
+    jD_cur = jD_ref + day_ini - day_ref + &
+            (itau + 1) / day_step
+    jH_cur = jH_ref + start_time + &
+            mod(itau + 1, day_step) / float(day_step)
+    jD_cur = jD_cur + int(jH_cur)
+    jH_cur = jH_cur - int(jH_cur)
+
+    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 321')
+
+    IF (ok_guide) THEN
+      CALL guide_main(itau, ucov, vcov, teta, q, masse, ps)
+    ENDIF
+
+
+
+    ! 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
+    !
+
+    ! Save fields obtained at previous time step as '...m1'
+    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
+
+    !   ...    P.Le Van .26/04/94  ....
+    ! Ehouarn: finvmaold is actually not used
+    ! CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
+    ! CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
+
+    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 400')
+
+    2   CONTINUE ! Matsuno backward or leapfrog step begins here
+
+    !-----------------------------------------------------------------------
+
+    !   date: (NB: only leapfrog step requires recomputing date)
+    !   -----
+
+    IF (leapf) THEN
+      jD_cur = jD_ref + day_ini - day_ref + &
+              (itau + 1) / day_step
+      jH_cur = jH_ref + start_time + &
+              mod(itau + 1, day_step) / float(day_step)
+      jD_cur = jD_cur + int(jH_cur)
+      jH_cur = jH_cur - int(jH_cur)
+    ENDIF
+
+
+    !   gestion des appels de la physique et des dissipations:
+    !   ------------------------------------------------------
+
+    !   ...    P.Le Van  ( 6/02/95 )  ....
+
+    apphys = .FALSE.
+    statcl = .FALSE.
+    conser = .FALSE.
+    apdiss = .FALSE.
+
+    IF(purmats) THEN
+      ! Purely Matsuno time stepping
+      IF(MOD(itau, iconser) ==0.AND.  forward) conser = .TRUE.
+      IF(MOD(itau, dissip_period)==0.AND..NOT.forward) &
+              apdiss = .TRUE.
+      IF(MOD(itau, iphysiq)==0.AND..NOT.forward &
+              .AND. physic) apphys = .TRUE.
+    ELSE
+      ! Leapfrog/Matsuno time stepping
+      IF(MOD(itau, iconser) == 0) conser = .TRUE.
+      IF(MOD(itau + 1, dissip_period)==0 .AND. .NOT. forward) &
+              apdiss = .TRUE.
+      IF(MOD(itau + 1, iphysiq)==0.AND.physic) apphys = .TRUE.
+    END IF
+
+    ! Ehouarn: for Shallow Water case (ie: 1 vertical layer),
+    ! supress dissipation step
+    IF (llm==1) THEN
+      apdiss = .FALSE.
+    ENDIF
+
+    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 589')
+
+    !-----------------------------------------------------------------------
+    !   calcul des tendances dynamiques:
+    !   --------------------------------
+
+    ! compute geopotential phi()
+    CALL geopot  (ip1jmp1, teta, pk, pks, phis, phi)
+
+    time = jD_cur + jH_cur
+    CALL caldyn &
+            (itau, ucov, vcov, teta, ps, masse, pk, pkf, phis, &
+            phi, conser, du, dv, dteta, dp, w, pbaru, pbarv, time)
+
+
+    !-----------------------------------------------------------------------
+    !   calcul des tendances advection des traceurs (dont l'humidite)
+    !   -------------------------------------------------------------
+
+    CALL check_isotopes_seq(q, ip1jmp1, &
+            'leapfrog 686: avant caladvtrac')
+
+    IF(forward .OR.  leapf)  THEN
+      ! Ehouarn: NB: fields sent to advtrac are those at the beginning of the time step
+      CALL caladvtrac(q, pbaru, pbarv, &
+              p, masse, dq, teta, &
+              flxw, pk)
+      !WRITE(*,*) 'caladvtrac 346'
+
+      IF (offline) THEN
+        !maf stokage du flux de masse pour traceurs OFF-LINE
+
+        CALL fluxstokenc(pbaru, pbarv, masse, teta, phi, phis, &
+                dtvr, itau)
+
+      ENDIF ! of IF (offline)
+
+    ENDIF ! of IF( forward .OR.  leapf )
+
+
+    !-----------------------------------------------------------------------
+    !   integrations dynamique et traceurs:
+    !   ----------------------------------
+
+    CALL msg('720', modname, isoCheck)
+    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 756')
+
+    CALL integrd (nqtot, vcovm1, ucovm1, tetam1, psm1, massem1, &
+            dv, du, dteta, dq, dp, vcov, ucov, teta, q, ps, masse, phis)
+    ! $              finvmaold                                    )
+
+    CALL msg('724', modname, isoCheck)
+    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 762')
+
+    ! .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
+
+    !-----------------------------------------------------------------------
+    !   calcul des tendances physiques:
+    !   -------------------------------
+    !    ########   P.Le Van ( Modif le  6/02/95 )   ###########
+
+    IF(purmats)  THEN
+      IF(itau==itaufin.AND..NOT.forward) lafin = .TRUE.
+    ELSE
+      IF(itau + 1 == itaufin)              lafin = .TRUE.
+    ENDIF
+
+    IF(apphys)  THEN
+
+      ! .......   Ajout   P.Le Van ( 17/04/96 )   ...........
+      !
+
+      CALL pression (ip1jmp1, ap, bp, ps, p)
+      IF (pressure_exner) THEN
+        CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
+      else
+        CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
+      endif
+
+      ! Appel a geopot ajoute le 2014/05/08 pour garantir la convergence numerique
+      ! avec dyn3dmem
+      CALL geopot  (ip1jmp1, teta, pk, pks, phis, phi)
+
+      ! rdaym_ini  = itau * dtvr / daysec
+      ! rdayvrai   = rdaym_ini  + day_ini
+      ! jD_cur = jD_ref + day_ini - day_ref
+      ! $        + int (itau * dtvr / daysec)
+      !       jH_cur = jH_ref +                                            &
+      ! &              (itau * dtvr / daysec - int(itau * dtvr / daysec))
+      jD_cur = jD_ref + day_ini - day_ref + &
+              (itau + 1) / day_step
+
+      IF (planet_type =="generic") THEN
+        ! AS: we make jD_cur to be pday
+        jD_cur = int(day_ini + itau / day_step)
+      ENDIF
+
+      jH_cur = jH_ref + start_time + &
+              mod(itau + 1, day_step) / float(day_step)
+      jD_cur = jD_cur + int(jH_cur)
+      jH_cur = jH_cur - int(jH_cur)
+      ! WRITE(lunout,*)'itau, jD_cur = ', itau, jD_cur, jH_cur
+      ! CALL ju2ymds(jD_cur+jH_cur, an, mois, jour, secondes)
+      ! WRITE(lunout,*)'current date = ',an, mois, jour, secondes
+
+      ! rajout debug
+      ! lafin = .TRUE.
+
+
+      !   Inbterface avec les routines de phylmd (phymars ... )
+      !   -----------------------------------------------------
+
+      !+jld
+
+      !  Diagnostique de conservation de l'energie : initialisation
+      IF (ip_ebil_dyn>=1) THEN
+        ztit = 'bil dyn'
+        ! Ehouarn: be careful, diagedyn is Earth-specific!
+        IF (planet_type=="earth") THEN
+          CALL diagedyn(ztit, 2, 1, 1, dtphys &
+                  , ucov, vcov, ps, p, pk, teta, q(:, :, 1), q(:, :, 2))
+        ENDIF
+      ENDIF ! of IF (ip_ebil_dyn.ge.1 )
+      IF (CPPKEY_PHYS) THEN
+        CALL calfis(lafin, jD_cur, jH_cur, &
+                ucov, vcov, teta, q, masse, ps, p, pk, phis, phi, &
+                du, dv, dteta, dq, &
+                flxw, dufi, dvfi, dtetafi, dqfi, dpfi)
+      END IF
+      ! ajout des tendances physiques:
+      ! ------------------------------
+      CALL addfi(dtphys, leapf, forward, &
+              ucov, vcov, teta, q, ps, &
+              dufi, dvfi, dtetafi, dqfi, dpfi)
+      ! since addfi updates ps(), also update p(), masse() and pk()
+      CALL pression (ip1jmp1, ap, bp, ps, p)
+      CALL massdair(p, masse)
+      IF (pressure_exner) THEN
+        CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
+      else
+        CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
+      endif
+
+      IF (ok_strato) THEN
+        CALL top_bound(vcov, ucov, teta, masse, dtphys)
+      ENDIF
+
+
+      !  Diagnostique de conservation de l'energie : difference
+      IF (ip_ebil_dyn>=1) THEN
+        ztit = 'bil phys'
+        IF (planet_type=="earth") THEN
+          CALL diagedyn(ztit, 2, 1, 1, dtphys &
+                  , ucov, vcov, ps, p, pk, teta, q(:, :, 1), q(:, :, 2))
+        ENDIF
+      ENDIF ! of IF (ip_ebil_dyn.ge.1 )
+
+    ENDIF ! of IF( apphys )
+
+    IF(iflag_phys==2) THEN ! "Newtonian" case
+      !   Academic case : Simple friction and Newtonan relaxation
+      !   -------------------------------------------------------
+      DO l = 1, llm
+        DO ij = 1, ip1jmp1
+          teta(ij, l) = teta(ij, l) - dtvr * &
+                  (teta(ij, l) - tetarappel(ij, l)) * (knewt_g + knewt_t(l) * clat4(ij))
+        ENDDO
+      ENDDO ! of DO l=1,llm
+
+      IF (planet_type=="giant") THEN
+        ! add an intrinsic heat flux at the base of the atmosphere
+        teta(:, 1) = teta(:, 1) + dtvr * aire(:) * ihf / cpp / masse(:, 1)
+      endif
+
+      CALL friction(ucov, vcov, dtvr)
+
+      ! Sponge layer (if any)
+      IF (ok_strato) THEN
+        ! dufi(:,:)=0.
+        ! dvfi(:,:)=0.
+        ! dtetafi(:,:)=0.
+        ! dqfi(:,:,:)=0.
+        !          dpfi(:)=0.
+        ! CALL top_bound(vcov,ucov,teta,masse,dufi,dvfi,dtetafi)
+        CALL top_bound(vcov, ucov, teta, masse, dtvr)
+        ! CALL addfi( dtvr, leapf, forward   ,
+        ! $                  ucov, vcov, teta , q   ,ps ,
+        ! $                 dufi, dvfi, dtetafi , dqfi ,dpfi  )
+      ENDIF ! of IF (ok_strato)
+    ENDIF ! of IF (iflag_phys.EQ.2)
+
+
+    !-jld
+
+    CALL pression (ip1jmp1, ap, bp, ps, p)
+    IF (pressure_exner) THEN
+      CALL exner_hyb(ip1jmp1, ps, p, pks, pk, pkf)
+    else
+      CALL exner_milieu(ip1jmp1, ps, p, pks, pk, pkf)
+    ENDIF
+    CALL massdair(p, masse)
+
+    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1196')
+
+    !-----------------------------------------------------------------------
+    !   dissipation horizontale et verticale  des petites echelles:
+    !   ----------------------------------------------------------
+
+    IF(apdiss) THEN
+
+
+      !   calcul de l'energie cinetique avant dissipation
+      CALL covcont(llm, ucov, vcov, ucont, vcont)
+      CALL enercin(vcov, ucov, vcont, ucont, ecin0)
+
+      !   dissipation
+      CALL dissip(vcov, ucov, teta, p, dvdis, dudis, dtetadis)
+      ucov = ucov + dudis
+      vcov = vcov + dvdis
+      ! teta=teta+dtetadis
+
+
+      !------------------------------------------------------------------------
+      IF (dissip_conservative) THEN
+        ! On rajoute la tendance due a la transform. Ec -> E therm. cree
+        ! lors de la dissipation
+        CALL covcont(llm, ucov, vcov, ucont, vcont)
+        CALL enercin(vcov, ucov, vcont, ucont, ecin)
+        dtetaecdt = (ecin0 - ecin) / pk
+        ! teta=teta+dtetaecdt
+        dtetadis = dtetadis + dtetaecdt
+      endif
+      teta = teta + dtetadis
+      !------------------------------------------------------------------------
+
+
+      !    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
+      !   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
+      !
+
+      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
+
+      IF (1 == 0) THEN
+        !!! Ehouarn: lines here 1) kill 1+1=2 in the dynamics
+        !!!                     2) should probably not be here anyway
+        !!! but are kept for those who would want to revert to previous behaviour
+        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 ! of if (1 == 0)
+
+    END IF ! of IF(apdiss)
+
+    ! ajout debug
+    ! IF( lafin ) THEN
+    !   abort_message = 'Simulation finished'
+    !   CALL abort_gcm(modname,abort_message,0)
+    ! ENDIF
+
+    !   ********************************************************************
+    !   ********************************************************************
+    !   .... fin de l'integration dynamique  et physique pour le pas itau ..
+    !   ********************************************************************
+    !   ********************************************************************
+
+    !   preparation du pas d'integration suivant  ......
+
+    CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1509')
+
+    IF (.NOT.purmats) THEN
+      ! ........................................................
+      ! ..............  schema matsuno + leapfrog  ..............
+      ! ........................................................
+
+      IF(forward .OR. leapf) THEN
+        itau = itau + 1
+        ! iday= day_ini+itau/day_step
+        ! time= REAL(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 == itaufinp1) THEN
+        IF (flag_verif) THEN
+          WRITE(79, *) 'ucov', ucov
+          WRITE(80, *) 'vcov', vcov
+          WRITE(81, *) 'teta', teta
+          WRITE(82, *) 'ps', ps
+          WRITE(83, *) 'q', q
+          WRITE(85, *) 'q1 = ', q(:, :, 1)
+          WRITE(86, *) 'q3 = ', q(:, :, 3)
+        endif
+
+        abort_message = 'Simulation finished'
+
+        CALL abort_gcm(modname, abort_message, 0)
+      ENDIF
+      !-----------------------------------------------------------------------
+      !   ecriture du fichier histoire moyenne:
+      !   -------------------------------------
+
+      IF(MOD(itau, iperiod)==0 .OR. itau==itaufin) THEN
+        IF(itau==itaufin) THEN
+          iav = 1
+        ELSE
+          iav = 0
+        ENDIF
+
+        ! Ehouarn: re-compute geopotential for outputs
+        CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
+
+        IF (ok_dynzon) THEN
+          CALL bilan_dyn(2, dtvr * iperiod, dtvr * day_step * periodav, &
+                  ps, masse, pk, pbaru, pbarv, teta, phi, ucov, vcov, q)
+        END IF
+        IF (ok_dyn_ave) THEN
+          CALL writedynav(itau, vcov, &
+                  ucov, teta, pk, phi, q, masse, ps, phis)
+        ENDIF
+
+      ENDIF ! of IF((MOD(itau,iperiod).EQ.0).OR.(itau.EQ.itaufin))
+
+      CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1584')
+
+      !-----------------------------------------------------------------------
+      !   ecriture de la bande histoire:
+      !   ------------------------------
+
+      IF(MOD(itau, iecri)==0) THEN
+        ! ! Ehouarn: output only during LF or Backward Matsuno
+        IF (leapf.OR.(.NOT.leapf.AND.(.NOT.forward))) THEN
+          CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
+          unat = 0.
+          DO l = 1, llm
+            unat(iip2:ip1jm, l) = ucov(iip2:ip1jm, l) / cu(iip2:ip1jm)
+            vnat(:, l) = vcov(:, l) / cv(:)
+          enddo
+          IF (ok_dyn_ins) THEN
+            ! WRITE(lunout,*) "leapfrog: CALL writehist, itau=",itau
+            CALL writehist(itau, vcov, ucov, teta, phi, q, masse, ps, phis)
+            ! CALL WriteField('ucov',reshape(ucov,(/iip1,jmp1,llm/)))
+            ! CALL WriteField('vcov',reshape(vcov,(/iip1,jjm,llm/)))
+            ! CALL WriteField('teta',reshape(teta,(/iip1,jmp1,llm/)))
+            !  CALL WriteField('ps',reshape(ps,(/iip1,jmp1/)))
+            !  CALL WriteField('masse',reshape(masse,(/iip1,jmp1,llm/)))
+          endif ! of if (ok_dyn_ins)
+          ! For some Grads outputs of fields
+          IF (output_grads_dyn) THEN
+            INCLUDE "write_grads_dyn.h"
+          endif
+        endif ! of if (leapf.OR.(.NOT.leapf.AND.(.NOT.forward)))
+      ENDIF ! of IF(MOD(itau,iecri).EQ.0)
+
+      IF(itau==itaufin) THEN
+
+
+        ! if (planet_type.EQ."earth") THEN
+        ! Write an Earth-format restart file
+        CALL dynredem1("restart.nc", start_time, &
+                vcov, ucov, teta, q, masse, ps)
+        ! END IF ! of if (planet_type.EQ."earth")
+
+        CLOSE(99)
+        IF (ok_guide) THEN
+          ! ! set ok_guide to false to avoid extra output
+          ! ! in following forward step
+          ok_guide = .FALSE.
+        endif
+        ! !!! Ehouarn: Why not stop here and now?
+      ENDIF ! of IF (itau.EQ.itaufin)
+
+      !-----------------------------------------------------------------------
+      !   gestion de l'integration temporelle:
+      !   ------------------------------------
+
+      IF(MOD(itau, iperiod)==0)    THEN
+        GO TO 1
+      ELSE IF (MOD(itau - 1, iperiod) == 0) THEN
+
+        IF(forward)  THEN
+          ! fin du pas forward et debut du pas backward
+
+          forward = .FALSE.
+          leapf = .FALSE.
+          GO TO 2
+
+        ELSE
+          ! fin du pas backward et debut du premier pas leapfrog
+
+          leapf = .TRUE.
+          dt = 2. * dtvr
+          GO TO 2
+        END IF ! of IF (forward)
+      ELSE
+
+        ! ......   pas leapfrog  .....
+
+        leapf = .TRUE.
+        dt = 2. * dtvr
+        GO TO 2
+      END IF ! of IF (MOD(itau,iperiod).EQ.0)
+      ! !    ELSEIF (MOD(itau-1,iperiod).EQ.0)
+
+    ELSE ! of IF (.NOT.purmats)
+
+      CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1664')
+
+      ! ........................................................
+      ! ..............       schema  matsuno        ...............
+      ! ........................................................
+      IF(forward)  THEN
+
+        itau = itau + 1
+        ! iday = day_ini+itau/day_step
+        ! time = REAL(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 == itaufinp1) THEN
+          abort_message = 'Simulation finished'
+          CALL abort_gcm(modname, abort_message, 0)
+        ENDIF
+        GO TO 2
+
+      ELSE ! of IF(forward) i.e. backward step
+
+        CALL check_isotopes_seq(q, ip1jmp1, 'leapfrog 1698')
+
+        IF(MOD(itau, iperiod)==0 .OR. itau==itaufin) THEN
+          IF(itau==itaufin) THEN
+            iav = 1
+          ELSE
+            iav = 0
+          ENDIF
+
+          ! ! Ehouarn: re-compute geopotential for outputs
+          CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
+
+          IF (ok_dynzon) THEN
+            CALL bilan_dyn(2, dtvr * iperiod, dtvr * day_step * periodav, &
+                    ps, masse, pk, pbaru, pbarv, teta, phi, ucov, vcov, q)
+          ENDIF
+          IF (ok_dyn_ave) THEN
+            CALL writedynav(itau, vcov, &
+                    ucov, teta, pk, phi, q, masse, ps, phis)
+          ENDIF
+
+        ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
+
+        IF(MOD(itau, iecri)==0) THEN
+          ! IF(MOD(itau,iecri*day_step).EQ.0) THEN
+          CALL geopot(ip1jmp1, teta, pk, pks, phis, phi)
+          unat = 0.
+          DO l = 1, llm
+            unat(iip2:ip1jm, l) = ucov(iip2:ip1jm, l) / cu(iip2:ip1jm)
+            vnat(:, l) = vcov(:, l) / cv(:)
+          enddo
+          IF (ok_dyn_ins) THEN
+            ! WRITE(lunout,*) "leapfrog: CALL writehist (b)",
+            ! &                        itau,iecri
+            CALL writehist(itau, vcov, ucov, teta, phi, q, masse, ps, phis)
+          endif ! of if (ok_dyn_ins)
+          ! For some Grads outputs
+          IF (output_grads_dyn) THEN
+            INCLUDE "write_grads_dyn.h"
+          endif
+
+        ENDIF ! of IF(MOD(itau,iecri         ).EQ.0)
+
+        IF(itau==itaufin) THEN
+          ! if (planet_type.EQ."earth") THEN
+          CALL dynredem1("restart.nc", start_time, &
+                  vcov, ucov, teta, q, masse, ps)
+          ! END IF ! of if (planet_type.EQ."earth")
+          IF (ok_guide) THEN
+            ! ! set ok_guide to false to avoid extra output
+            ! ! in following forward step
+            ok_guide = .FALSE.
+          endif
+        ENDIF ! of IF(itau.EQ.itaufin)
+
+        forward = .TRUE.
+        GO TO  1
+
+      ENDIF ! of IF (forward)
+
+    END IF ! of IF(.NOT.purmats)
+
+  END SUBROUTINE leapfrog
+
+END MODULE lmdz_leapfrog
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/qminimum.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/qminimum.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/qminimum.F90	(revision 5186)
@@ -10,4 +10,6 @@
   USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
   USE lmdz_paramet
+  USE lmdz_check_isotopes, ONLY: check_isotopes_seq
+
   IMPLICIT NONE
 
@@ -15,6 +17,4 @@
   !         pour l'eau vapeur et l'eau liquide
   !
-
-
 
   INTEGER :: nqtot
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d/replay3d.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d/replay3d.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d/replay3d.F90	(revision 5186)
@@ -1,3 +1,2 @@
-
 ! $Id: gcm.F90 3579 2019-10-09 13:11:07Z fairhead $
 
@@ -6,18 +5,15 @@
 PROGRAM replay3d
 
-
-
-USE comvert_mod, ONLY:  preff, pa
-USE inigeomphy_mod, ONLY: inigeomphy
-
+  USE comvert_mod, ONLY: preff, pa
+  USE inigeomphy_mod, ONLY: inigeomphy
 
   USE control_mod
-  USE temps_mod, ONLY: calend,start_time,annee_ref,day_ref, &
-                     itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end
+  USE temps_mod, ONLY: calend, start_time, annee_ref, day_ref, &
+          itau_dyn, itau_phy, day_ini, jD_ref, jH_ref, day_end
   USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, r, rad
   USE logic_mod, ONLY: ecripar, iflag_phys, read_start
 
-  USE serre_mod, ONLY: clon,clat,transx,transy,alphax,alphay,pxo,pyo,              &
-        grossismx, grossismy, dzoomx, dzoomy,taux,tauy
+  USE serre_mod, ONLY: clon, clat, transx, transy, alphax, alphay, pxo, pyo, &
+          grossismx, grossismy, dzoomx, dzoomy, taux, tauy
   USE mod_const_mpi, ONLY: comm_lmdz
   USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
@@ -27,4 +23,6 @@
   USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
   USE lmdz_paramet
+  USE lmdz_conf_gcm, ONLY: conf_gcm
+
   IMPLICIT NONE
 
@@ -59,7 +57,4 @@
   !   -------------
 
-
-
-
   REAL zdtvr
 
@@ -74,5 +69,5 @@
   LOGICAL lafin
 
-  INTEGER :: ntime=10000,it,klon,klev
+  INTEGER :: ntime = 10000, it, klon, klev
 
 
@@ -89,24 +84,24 @@
   !  ---------------------------------------
 
-preff=101325.
- pa=50000.
- clon=0.
- clat=0.
- taux=3.
- tauy=3.
- dzoomx=0.1
- dzoomy=0.1
- grossismx=1.
- grossismx=1.
- transx=0.
- transy=0.
+  preff = 101325.
+  pa = 50000.
+  clon = 0.
+  clat = 0.
+  taux = 3.
+  tauy = 3.
+  dzoomx = 0.1
+  dzoomy = 0.1
+  grossismx = 1.
+  grossismx = 1.
+  transx = 0.
+  transy = 0.
 
-  CALL conf_gcm( 99, .TRUE.)
+  CALL conf_gcm(99, .TRUE.)
 
   IF (mod(iphysiq, iperiod) /= 0) CALL abort_gcm("conf_gcm", &
-       "iphysiq must be a multiple of iperiod", 1)
+          "iphysiq must be a multiple of iperiod", 1)
 
- rad=6400000
-g=9.81
+  rad = 6400000
+  g = 9.81
 
 
@@ -128,59 +123,52 @@
   !  on recalcule eventuellement le pas de temps
 
-
-  zdtvr    = daysec/REAL(day_step)
+  zdtvr = daysec / REAL(day_step)
 
   ! on remet le calendrier \`a zero si demande
 
-     annee_ref = anneeref
-     day_ref = dayref
-     day_ini = dayref
-     itau_dyn = 0
-     itau_phy = 0
-     time_0 = 0.
+  annee_ref = anneeref
+  day_ref = dayref
+  day_ini = dayref
+  itau_dyn = 0
+  itau_phy = 0
+  time_0 = 0.
 
   mois = 1
   heure = 0.
-! CALL ymds2ju(annee_ref, mois, day_ref, heure, jD_ref)
+  ! CALL ymds2ju(annee_ref, mois, day_ref, heure, jD_ref)
   jH_ref = jD_ref - int(jD_ref)
   jD_ref = int(jD_ref)
 
+  dtvr = zdtvr
+  CALL iniconst
+  PRINT*, 'APRES inisconst'
+  CALL inigeom
 
+  CALL inigeomphy(iim, jjm, llm, &
+          1, comm_lmdz, &
+          rlatu, rlatv, &
+          rlonu, rlonv, &
+          aire, cu, cv)
 
-     dtvr = zdtvr
-     CALL iniconst
-     PRINT*,'APRES inisconst'
-     CALL inigeom
+  CALL suphel
+  !open(82,file='dump_param.bin',form='unformatted',status='old')
 
+  CALL iophys_ini(900.)
+  PRINT*, 'Rlatu=', rlatu
+  klon = 2 + iim * (jjm - 1)
+  klev = llm
 
-  CALL inigeomphy(iim,jjm,llm, &
-               1, comm_lmdz, &
-               rlatu,rlatv, &
-               rlonu,rlonv, &
-               aire,cu,cv)
+  !---------------------------------------------------------------------
+  ! Initialisation de la parametrisation
+  !---------------------------------------------------------------------
+  CALL call_ini_replay
 
-CALL suphel
-!open(82,file='dump_param.bin',form='unformatted',status='old')
-
-
-
-     CALL iophys_ini(900.)
-PRINT*,'Rlatu=',rlatu
-klon=2+iim*(jjm-1)
-klev=llm
-
-!---------------------------------------------------------------------
-! Initialisation de la parametrisation
-!---------------------------------------------------------------------
-      CALL call_ini_replay
-
-!---------------------------------------------------------------------
-! Boucle en temps sur l'appel à la parametrisation
-!---------------------------------------------------------------------
-      DO it=1,ntime
-         PRINT*,'Pas de temps ',it,klon,klev
-         CALL call_param_replay(klon,klev)
-      ENDDO
-
+  !---------------------------------------------------------------------
+  ! Boucle en temps sur l'appel à la parametrisation
+  !---------------------------------------------------------------------
+  DO it = 1, ntime
+    PRINT*, 'Pas de temps ', it, klon, klev
+    CALL call_param_replay(klon, klev)
+  ENDDO
 
 END PROGRAM replay3d
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/grilles_gcm_netcdf_sub.F90	(revision 5186)
@@ -17,9 +17,9 @@
   USE lmdz_comgeom
 
-USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
   USE lmdz_paramet
+  USE lmdz_conf_gcm, ONLY: conf_gcm
+
   IMPLICIT NONE
-
-
 
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_covnat.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_covnat.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_covnat.f90	(revision 5186)
@@ -0,0 +1,54 @@
+MODULE lmdz_covnat
+  IMPLICIT NONE; PRIVATE
+  PUBLIC covnat
+
+CONTAINS
+
+  SUBROUTINE covnat(klevel, ucov, vcov, unat, vnat)
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+
+    !=======================================================================
+
+    !   Auteur:  F Hourdin Phu LeVan
+    !   -------
+
+    !   Objet:
+    !   ------
+
+    !  *********************************************************************
+    !    calcul des compos. naturelles a partir des comp.covariantes
+    !  ********************************************************************
+
+    !=======================================================================
+
+    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
+
+  END SUBROUTINE covnat
+
+
+END MODULE lmdz_covnat
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_writedynav.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_writedynav.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_writedynav.f90	(revision 5186)
@@ -0,0 +1,135 @@
+MODULE lmdz_writedynav
+  IMPLICIT NONE; PRIVATE
+  PUBLIC writedynav
+
+CONTAINS
+
+  SUBROUTINE writedynav(time, vcov, ucov, teta, ppk, phi, q, masse, ps, phis)
+
+    USE ioipsl
+    USE lmdz_infotrac, ONLY: nqtot
+    USE com_io_dyn_mod, ONLY: histaveid, histvaveid, histuaveid
+    USE comconst_mod, ONLY: cpp
+    USE temps_mod, ONLY: itau_dyn
+    USE lmdz_description, ONLY: descript
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    USE lmdz_covnat, ONLY: covnat
+
+    IMPLICIT NONE
+
+    !   Ecriture du fichier histoire au format IOIPSL
+
+    !   Appels succesifs des routines: histwrite
+
+    !   Entree:
+    !      time: temps de l'ecriture
+    !      vcov: vents v covariants
+    !      ucov: vents u covariants
+    !      teta: temperature potentielle
+    !      phi : geopotentiel instantane
+    !      q   : traceurs
+    !      masse: masse
+    !      ps   :pression au sol
+    !      phis : geopotentiel au sol
+
+    !   L. Fairhead, LMD, 03/99
+
+    !   Arguments
+
+    REAL vcov(ip1jm, llm), ucov(ip1jmp1, llm)
+    REAL teta(ip1jmp1 * llm), phi(ip1jmp1, llm), ppk(ip1jmp1 * llm)
+    REAL ps(ip1jmp1), masse(ip1jmp1, llm)
+    REAL phis(ip1jmp1)
+    REAL q(ip1jmp1, llm, nqtot)
+    INTEGER time
+
+    ! This routine needs IOIPSL to work
+    !   Variables locales
+
+    INTEGER ndex2d(ip1jmp1), ndexu(ip1jmp1 * llm), ndexv(ip1jm * llm)
+    INTEGER iq, ii, ll
+    REAL tm(ip1jmp1 * llm)
+    REAL vnat(ip1jm, llm), unat(ip1jmp1, llm)
+    LOGICAL ok_sync
+    INTEGER itau_w
+
+    !-----------------------------------------------------------------
+
+    !  Initialisations
+
+    ndexu = 0
+    ndexv = 0
+    ndex2d = 0
+    ok_sync = .TRUE.
+    tm = 999.999
+    vnat = 999.999
+    unat = 999.999
+    itau_w = itau_dyn + time
+
+    ! Passage aux composantes naturelles du vent
+    CALL covnat(llm, ucov, vcov, unat, vnat)
+
+    !  Appels a histwrite pour l'ecriture des variables a sauvegarder
+
+    !  Vents U
+
+    CALL histwrite(histuaveid, 'u', itau_w, unat, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Vents V
+
+    CALL histwrite(histvaveid, 'v', itau_w, vnat, &
+            iip1 * jjm * llm, ndexv)
+
+    !  Temperature potentielle moyennee
+
+    CALL histwrite(histaveid, 'theta', itau_w, teta, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Temperature moyennee
+
+    DO ii = 1, ijp1llm
+      tm(ii) = teta(ii) * ppk(ii) / cpp
+    enddo
+    CALL histwrite(histaveid, 'temp', itau_w, tm, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Geopotentiel
+
+    CALL histwrite(histaveid, 'phi', itau_w, phi, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Traceurs
+
+    !  DO iq=1, nqtot
+    !       CALL histwrite(histaveid, tracers(iq)%longName, itau_w, &
+    !                   q(:, :, iq), iip1*jjp1*llm, ndexu)
+    ! enddo
+
+    !  Masse
+
+    CALL histwrite(histaveid, 'masse', itau_w, masse, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Pression au sol
+
+    CALL histwrite(histaveid, 'ps', itau_w, ps, iip1 * jjp1, ndex2d)
+
+    ! Geopotentiel au sol
+
+    ! CALL histwrite(histaveid, 'phis', itau_w, phis, iip1*jjp1, ndex2d)
+
+    IF (ok_sync) THEN
+      CALL histsync(histaveid)
+      CALL histsync(histvaveid)
+      CALL histsync(histuaveid)
+    ENDIF
+
+  END SUBROUTINE  writedynav
+
+
+END MODULE lmdz_writedynav
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_writehist.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_writehist.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/lmdz_writehist.f90	(revision 5186)
@@ -0,0 +1,133 @@
+MODULE lmdz_writehist
+  IMPLICIT NONE; PRIVATE
+  PUBLIC writehist
+
+CONTAINS
+
+  SUBROUTINE writehist(time, vcov, ucov, teta, phi, q, masse, ps, phis)
+
+    USE ioipsl
+    USE lmdz_infotrac, ONLY: nqtot
+    USE com_io_dyn_mod, ONLY: histid, histvid, histuid
+    USE temps_mod, ONLY: itau_dyn
+    USE lmdz_description, ONLY: descript
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_comgeom
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    USE lmdz_covnat, ONLY: covnat
+
+    IMPLICIT NONE
+
+
+    !   Ecriture du fichier histoire au format IOIPSL
+
+    !   Appels succesifs des routines: histwrite
+
+    !   Entree:
+    !  time: temps de l'ecriture
+    !  vcov: vents v covariants
+    !  ucov: vents u covariants
+    !  teta: temperature potentielle
+    !  phi : geopotentiel instantane
+    !  q   : traceurs
+    !  masse: masse
+    !  ps   :pression au sol
+    !  phis : geopotentiel au sol
+
+
+    !   L. Fairhead, LMD, 03/99
+
+    ! =====================================================================
+
+    !   Declarations
+
+
+
+
+    !   Arguments
+    !
+
+    REAL :: vcov(ip1jm, llm), ucov(ip1jmp1, llm)
+    REAL :: teta(ip1jmp1, llm), phi(ip1jmp1, llm)
+    REAL :: ps(ip1jmp1), masse(ip1jmp1, llm)
+    REAL :: phis(ip1jmp1)
+    REAL :: q(ip1jmp1, llm, nqtot)
+    INTEGER :: time
+
+
+    ! This routine needs IOIPSL to work
+    !   Variables locales
+
+    INTEGER :: iq, ii, ll
+    INTEGER :: ndexu(ip1jmp1 * llm), ndexv(ip1jm * llm), ndex2d(ip1jmp1)
+    LOGICAL :: ok_sync
+    INTEGER :: itau_w
+    REAL :: vnat(ip1jm, llm), unat(ip1jmp1, llm)
+
+
+    !  Initialisations
+
+    ndexu = 0
+    ndexv = 0
+    ndex2d = 0
+    ok_sync = .TRUE.
+    itau_w = itau_dyn + time
+    !  Passage aux composantes naturelles du vent
+    CALL covnat(llm, ucov, vcov, unat, vnat)
+
+    !  Appels a histwrite pour l'ecriture des variables a sauvegarder
+
+    !  Vents U
+
+    CALL histwrite(histuid, 'u', itau_w, unat, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Vents V
+
+    CALL histwrite(histvid, 'v', itau_w, vnat, &
+            iip1 * jjm * llm, ndexv)
+
+
+    !  Temperature potentielle
+
+    CALL histwrite(histid, 'teta', itau_w, teta, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Geopotentiel
+
+    CALL histwrite(histid, 'phi', itau_w, phi, &
+            iip1 * jjp1 * llm, ndexu)
+
+    !  Traceurs
+
+    !    DO iq=1,nqtot
+    !      CALL histwrite(histid, tracers(iq)%longName, itau_w,
+    ! .                   q(:,:,iq), iip1*jjp1*llm, ndexu)
+    !    enddo
+    !C
+    !  Masse
+
+    CALL histwrite(histid, 'masse', itau_w, masse, iip1 * jjp1 * llm, ndexu)
+
+    !  Pression au sol
+
+    CALL histwrite(histid, 'ps', itau_w, ps, iip1 * jjp1, ndex2d)
+
+    !  Geopotentiel au sol
+
+    !  CALL histwrite(histid, 'phis', itau_w, phis, iip1*jjp1, ndex2d)
+
+    !  Fin
+
+    IF (ok_sync) THEN
+      CALL histsync(histid)
+      CALL histsync(histvid)
+      CALL histsync(histuid)
+    ENDIF
+    RETURN
+  END SUBROUTINE writehist
+
+
+END MODULE lmdz_writehist
Index: DZ6/branches/Amaury_dev/libf/dyn3d_common/writedynav.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/writedynav.F90	(revision 5185)
+++ 	(revision )
@@ -1,126 +1,0 @@
-! $Id$
-
-SUBROUTINE writedynav(time, vcov, ucov, teta, ppk, phi, q, masse, ps, phis)
-
-  USE ioipsl
-  USE lmdz_infotrac, ONLY: nqtot
-  USE com_io_dyn_mod, ONLY: histaveid, histvaveid, histuaveid
-  USE comconst_mod, ONLY: cpp
-  USE temps_mod, ONLY: itau_dyn
-  USE lmdz_description, ONLY: descript
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comgeom
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-  !   Ecriture du fichier histoire au format IOIPSL
-
-  !   Appels succesifs des routines: histwrite
-
-  !   Entree:
-  !      time: temps de l'ecriture
-  !      vcov: vents v covariants
-  !      ucov: vents u covariants
-  !      teta: temperature potentielle
-  !      phi : geopotentiel instantane
-  !      q   : traceurs
-  !      masse: masse
-  !      ps   :pression au sol
-  !      phis : geopotentiel au sol
-
-  !   L. Fairhead, LMD, 03/99
-
-  !   Arguments
-
-  REAL vcov(ip1jm, llm), ucov(ip1jmp1, llm)
-  REAL teta(ip1jmp1 * llm), phi(ip1jmp1, llm), ppk(ip1jmp1 * llm)
-  REAL ps(ip1jmp1), masse(ip1jmp1, llm)
-  REAL phis(ip1jmp1)
-  REAL q(ip1jmp1, llm, nqtot)
-  INTEGER time
-
-  ! This routine needs IOIPSL to work
-  !   Variables locales
-
-  INTEGER ndex2d(ip1jmp1), ndexu(ip1jmp1 * llm), ndexv(ip1jm * llm)
-  INTEGER iq, ii, ll
-  REAL tm(ip1jmp1 * llm)
-  REAL vnat(ip1jm, llm), unat(ip1jmp1, llm)
-  LOGICAL ok_sync
-  INTEGER itau_w
-
-  !-----------------------------------------------------------------
-
-  !  Initialisations
-
-  ndexu = 0
-  ndexv = 0
-  ndex2d = 0
-  ok_sync = .TRUE.
-  tm = 999.999
-  vnat = 999.999
-  unat = 999.999
-  itau_w = itau_dyn + time
-
-  ! Passage aux composantes naturelles du vent
-  CALL covnat(llm, ucov, vcov, unat, vnat)
-
-  !  Appels a histwrite pour l'ecriture des variables a sauvegarder
-
-  !  Vents U
-
-  CALL histwrite(histuaveid, 'u', itau_w, unat, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Vents V
-
-  CALL histwrite(histvaveid, 'v', itau_w, vnat, &
-          iip1 * jjm * llm, ndexv)
-
-  !  Temperature potentielle moyennee
-
-  CALL histwrite(histaveid, 'theta', itau_w, teta, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Temperature moyennee
-
-  DO ii = 1, ijp1llm
-    tm(ii) = teta(ii) * ppk(ii) / cpp
-  enddo
-  CALL histwrite(histaveid, 'temp', itau_w, tm, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Geopotentiel
-
-  CALL histwrite(histaveid, 'phi', itau_w, phi, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Traceurs
-
-  !  DO iq=1, nqtot
-  !       CALL histwrite(histaveid, tracers(iq)%longName, itau_w, &
-  !                   q(:, :, iq), iip1*jjp1*llm, ndexu)
-  ! enddo
-
-  !  Masse
-
-  CALL histwrite(histaveid, 'masse', itau_w, masse, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Pression au sol
-
-  CALL histwrite(histaveid, 'ps', itau_w, ps, iip1 * jjp1, ndex2d)
-
-  ! Geopotentiel au sol
-
-  ! CALL histwrite(histaveid, 'phis', itau_w, phis, iip1*jjp1, ndex2d)
-
-  IF (ok_sync) THEN
-    CALL histsync(histaveid)
-    CALL histsync(histvaveid)
-    CALL histsync(histuaveid)
-  ENDIF
-
-END SUBROUTINE  writedynav
Index: DZ6/branches/Amaury_dev/libf/dyn3d_common/writehist.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/writehist.f90	(revision 5185)
+++ 	(revision )
@@ -1,124 +1,0 @@
-! $Id$
-
-SUBROUTINE writehist(time, vcov, ucov, teta, phi, q, masse, ps, phis)
-
-  USE ioipsl
-  USE lmdz_infotrac, ONLY: nqtot
-  USE com_io_dyn_mod, ONLY: histid, histvid, histuid
-  USE temps_mod, ONLY: itau_dyn
-  USE lmdz_description, ONLY: descript
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comgeom
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-
-
-  !   Ecriture du fichier histoire au format IOIPSL
-
-  !   Appels succesifs des routines: histwrite
-
-  !   Entree:
-  !  time: temps de l'ecriture
-  !  vcov: vents v covariants
-  !  ucov: vents u covariants
-  !  teta: temperature potentielle
-  !  phi : geopotentiel instantane
-  !  q   : traceurs
-  !  masse: masse
-  !  ps   :pression au sol
-  !  phis : geopotentiel au sol
-
-
-  !   L. Fairhead, LMD, 03/99
-
-  ! =====================================================================
-
-  !   Declarations
-
-
-
-
-  !   Arguments
-  !
-
-  REAL :: vcov(ip1jm, llm), ucov(ip1jmp1, llm)
-  REAL :: teta(ip1jmp1, llm), phi(ip1jmp1, llm)
-  REAL :: ps(ip1jmp1), masse(ip1jmp1, llm)
-  REAL :: phis(ip1jmp1)
-  REAL :: q(ip1jmp1, llm, nqtot)
-  INTEGER :: time
-
-
-  ! This routine needs IOIPSL to work
-  !   Variables locales
-
-  INTEGER :: iq, ii, ll
-  INTEGER :: ndexu(ip1jmp1 * llm), ndexv(ip1jm * llm), ndex2d(ip1jmp1)
-  LOGICAL :: ok_sync
-  INTEGER :: itau_w
-  REAL :: vnat(ip1jm, llm), unat(ip1jmp1, llm)
-
-
-  !  Initialisations
-
-  ndexu = 0
-  ndexv = 0
-  ndex2d = 0
-  ok_sync = .TRUE.
-  itau_w = itau_dyn + time
-  !  Passage aux composantes naturelles du vent
-  CALL covnat(llm, ucov, vcov, unat, vnat)
-
-  !  Appels a histwrite pour l'ecriture des variables a sauvegarder
-
-  !  Vents U
-
-  CALL histwrite(histuid, 'u', itau_w, unat, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Vents V
-
-  CALL histwrite(histvid, 'v', itau_w, vnat, &
-          iip1 * jjm * llm, ndexv)
-
-
-  !  Temperature potentielle
-
-  CALL histwrite(histid, 'teta', itau_w, teta, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Geopotentiel
-
-  CALL histwrite(histid, 'phi', itau_w, phi, &
-          iip1 * jjp1 * llm, ndexu)
-
-  !  Traceurs
-
-  !    DO iq=1,nqtot
-  !      CALL histwrite(histid, tracers(iq)%longName, itau_w,
-  ! .                   q(:,:,iq), iip1*jjp1*llm, ndexu)
-  !    enddo
-  !C
-  !  Masse
-
-  CALL histwrite(histid, 'masse', itau_w, masse, iip1 * jjp1 * llm, ndexu)
-
-  !  Pression au sol
-
-  CALL histwrite(histid, 'ps', itau_w, ps, iip1 * jjp1, ndex2d)
-
-  !  Geopotentiel au sol
-
-  !  CALL histwrite(histid, 'phis', itau_w, phis, iip1*jjp1, ndex2d)
-
-  !  Fin
-
-  IF (ok_sync) THEN
-    CALL histsync(histid)
-    CALL histsync(histvid)
-    CALL histsync(histuid)
-  ENDIF
-  RETURN
-END SUBROUTINE writehist
Index: DZ6/branches/Amaury_dev/libf/dyn3dmem/conf_gcm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/conf_gcm.F90	(revision 5185)
+++ 	(revision )
@@ -1,1026 +1,0 @@
-
-! $Id$
-
-SUBROUTINE conf_gcm( tapedef, etatinit )
-
-  USE control_mod
-  USE IOIPSL
-  USE misc_mod
-  USE lmdz_filtre_fft, ONLY: use_filtre_fft
-  USE lmdz_filtre_fft_loc, ONLY: use_filtre_fft_loc=>use_filtre_fft
-  USE mod_hallo, ONLY: use_mpi_alloc
-  USE lmdz_infotrac, ONLY: type_trac
-  USE lmdz_assert, ONLY: assert
-  USE comconst_mod, ONLY: dissip_deltaz, dissip_factz, dissip_zref, &
-                          iflag_top_bound, mode_top_bound, tau_top_bound, &
-                          ngroup, maxlatfilter
-  USE logic_mod, ONLY: fxyhypb, iflag_phys, ok_etat0, ok_gradsfile, &
-                       ok_guide, ok_limit, ok_strato, purmats, read_start, &
-                       ysinus, read_orop, adv_qsat_liq
-  USE serre_mod, ONLY: clon,clat,grossismx,grossismy,dzoomx,dzoomy, &
-                       alphax,alphay,taux,tauy
-  USE temps_mod, ONLY: calend, year_len, offline_time
-  USE lmdz_iniprint, ONLY: lunout, prt_level
-  USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
-          tetagrot, tetatemp, coefdis, vert_prof_dissip
-
-  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
-  USE lmdz_paramet
-  IMPLICIT NONE
-  !-----------------------------------------------------------------------
-  !     Auteurs :   L. Fairhead , P. Le Van  .
-
-  !     Arguments :
-
-  !     tapedef   :
-  !     etatinit  :     = TRUE   , on ne  compare pas les valeurs des para-
-  !     -metres  du zoom  avec  celles lues sur le fichier start .
-
-  LOGICAL,INTENT(IN) :: etatinit
-  INTEGER,INTENT(IN) :: tapedef
-
-  !   Declarations :
-  !   --------------
-
-
-
-  !   local:
-  !   ------
-
-  CHARACTER ch1*72,ch2*72,ch3*72,ch4*12
-  REAL clonn,clatt,grossismxx,grossismyy
-  REAL dzoomxx,dzoomyy, tauxx,tauyy
-  LOGICAL  fxyhypbb, ysinuss
-  INTEGER i
-  CHARACTER(len=*), PARAMETER :: modname="conf_gcm"
-  CHARACTER(len=80) :: abort_message
-#ifdef CPP_OMP
-  INTEGER, EXTERNAL :: OMP_GET_NUM_THREADS
-#endif
-
-  !  -------------------------------------------------------------------
-
-  !       .........     Version  du 29/04/97       ..........
-
-  !   Nouveaux parametres nitergdiv,nitergrot,niterh,tetagdiv,tetagrot,
-  !      tetatemp   ajoutes  pour la dissipation   .
-
-  !   Autre parametre ajoute en fin de liste de tapedef : ** fxyhypb ** 
-
-  !  Si fxyhypb = .TRUE. , choix de la fonction a derivee tangente hyperb.
-  !    Sinon , choix de fxynew  , a derivee sinusoidale  ..
-
-  !   ......  etatinit = . TRUE. si defrun  est appele dans ETAT0_LMD  ou
-  !         LIMIT_LMD  pour l'initialisation de start.dat (dic) et
-  !                de limit.dat ( dic)                        ...........
-  !           Sinon  etatinit = . FALSE .
-
-  !   Donc etatinit = .F.  si on veut comparer les valeurs de  grossismx ,
-  !    grossismy,clon,clat, fxyhypb  lues sur  le fichier  start  avec
-  !   celles passees  par run.def ,  au debut du gcm, apres l'appel a 
-  !    lectba .  
-  !   Ces parmetres definissant entre autres la grille et doivent etre
-  !   pareils et coherents , sinon il y aura  divergence du gcm .
-
-  !-----------------------------------------------------------------------
-  !   initialisations:
-  !   ----------------
-
-  !Config  Key  = lunout
-  !Config  Desc = unite de fichier pour les impressions
-  !Config  Def  = 6
-  !Config  Help = unite de fichier pour les impressions 
-  !Config         (defaut sortie standard = 6)
-  lunout=6
-  CALL getin('lunout', lunout)
-  IF (lunout /= 5 .AND. lunout /= 6) THEN
-     OPEN(UNIT=lunout,FILE='lmdz.out_0000',ACTION='write',  &
-          STATUS='unknown',FORM='formatted')
-  ENDIF
-
-  adjust=.FALSE.
-  CALL getin('adjust',adjust)
-
-#ifdef CPP_OMP
-  ! adjust=y not implemented in case of OpenMP threads...
-  !$OMP PARALLEL
-  IF ((OMP_GET_NUM_THREADS()>1).AND.adjust) THEN
-     WRITE(lunout,*)'conf_gcm: Error, adjust should be set to n' &
-          ,' when running with OpenMP threads'
-     abort_message = 'Wrong value for adjust'
-     CALL abort_gcm(modname,abort_message,1)
-  ENDIF
-  !$OMP END PARALLEL         
-#endif
-
-  itaumax=0
-  CALL getin('itaumax',itaumax);
-  IF (itaumax<=0) itaumax=HUGE(itaumax)
-
-  !Config  Key  = prt_level
-  !Config  Desc = niveau d'impressions de débogage
-  !Config  Def  = 0
-  !Config  Help = Niveau d'impression pour le débogage
-  !Config         (0 = minimum d'impression)
-  prt_level = 0
-  CALL getin('prt_level',prt_level)
-
-  !-----------------------------------------------------------------------
-  !  Parametres de controle du run:
-  !-----------------------------------------------------------------------
-  !Config  Key  = planet_type
-  !Config  Desc = planet type ("earth", "mars", "venus", ...)
-  !Config  Def  = earth
-  !Config  Help = this flag sets the type of atymosphere that is considered
-  planet_type="earth"
-  CALL getin('planet_type',planet_type)
-
-  !Config  Key  = calend
-  !Config  Desc = type de calendrier utilise
-  !Config  Def  = earth_360d
-  !Config  Help = valeur possible: earth_360d, earth_365d, earth_366d
-  !Config         
-  calend = 'earth_360d'
-! initialize year_len for aquaplanets and 1D
-  CALL getin('calend', calend)
-  IF (calend == 'earth_360d') THEN
-    year_len=360
-  ELSE IF (calend == 'earth_365d') THEN
-    year_len=365
-  ELSE IF (calend == 'earth_366d') THEN
-    year_len=366
-  ELSE
-    year_len=1
-  ENDIF
-
-  !Config  Key  = dayref
-  !Config  Desc = Jour de l'etat initial
-  !Config  Def  = 1
-  !Config  Help = Jour de l'etat initial ( = 350  si 20 Decembre ,
-  !Config         par expl. ,comme ici ) ... A completer
-  dayref=1
-  CALL getin('dayref', dayref)
-
-  !Config  Key  = anneeref
-  !Config  Desc = Annee de l'etat initial
-  !Config  Def  = 1998
-  !Config  Help = Annee de l'etat  initial 
-  !Config         (   avec  4  chiffres   ) ... A completer
-  anneeref = 1998
-  CALL getin('anneeref',anneeref)
-
-  !Config  Key  = raz_date
-  !Config  Desc = Remise a zero de la date initiale
-  !Config  Def  = 0 (pas de remise a zero)
-  !Config  Help = Remise a zero de la date initiale 
-  !Config         0 pas de remise a zero, on garde la date du fichier restart
-  !Config         1 prise en compte de la date de gcm.def avec remise a zero
-  !Config         des compteurs de pas de temps
-  raz_date = 0
-  CALL getin('raz_date', raz_date)
-
-  !Config  Key  = resetvarc
-  !Config  Desc = Reinit des variables de controle
-  !Config  Def  = n
-  !Config  Help = Reinit des variables de controle
-  resetvarc = .FALSE.
-  CALL getin('resetvarc',resetvarc)
-
-  !Config  Key  = nday
-  !Config  Desc = Nombre de jours d'integration
-  !Config  Def  = 10
-  !Config  Help = Nombre de jours d'integration
-  !Config         ... On pourait aussi permettre des mois ou des annees !
-  nday = 10
-  CALL getin('nday',nday)
-
-  !Config  Key  = starttime
-  !Config  Desc = Heure de depart de la simulation
-  !Config  Def  = 0
-  !Config  Help = Heure de depart de la simulation
-  !Config         en jour
-  starttime = 0
-  CALL getin('starttime',starttime)
-
-  !Config  Key  = day_step
-  !Config  Desc = nombre de pas par jour
-  !Config  Def  = 240 
-  !Config  Help = nombre de pas par jour (multiple de iperiod) (
-  !Config          ici pour  dt = 1 min ) 
-  day_step = 240 
-  CALL getin('day_step',day_step)
-
-  !Config  Key  = nsplit_phys
-  nsplit_phys = 1 
-  CALL getin('nsplit_phys',nsplit_phys)
-
-  !Config  Key  = iperiod
-  !Config  Desc = periode pour le pas Matsuno
-  !Config  Def  = 5
-  !Config  Help = periode pour le pas Matsuno (en pas de temps)
-  iperiod = 5
-  CALL getin('iperiod',iperiod)
-
-  !Config  Key  = iapp_tracvl
-  !Config  Desc = frequence du groupement des flux 
-  !Config  Def  = iperiod
-  !Config  Help = frequence du groupement des flux (en pas de temps) 
-  iapp_tracvl = iperiod
-  CALL getin('iapp_tracvl',iapp_tracvl)
-
-  !Config  Key  = iconser
-  !Config  Desc = periode de sortie des variables de controle
-  !Config  Def  = 240  
-  !Config  Help = periode de sortie des variables de controle
-  !Config         (En pas de temps)
-  iconser = 240  
-  CALL getin('iconser', iconser)
-
-  !Config  Key  = iecri
-  !Config  Desc = periode d'ecriture du fichier histoire
-  !Config  Def  = 1
-  !Config  Help = periode d'ecriture du fichier histoire (en jour) 
-  iecri = 1
-  CALL getin('iecri',iecri)
-
-  !Config  Key  = periodav
-  !Config  Desc = periode de stockage fichier histmoy
-  !Config  Def  = 1
-  !Config  Help = periode de stockage fichier histmoy (en jour) 
-  periodav = 1.
-  CALL getin('periodav',periodav)
-
-  !Config  Key  = output_grads_dyn
-  !Config  Desc = output dynamics diagnostics in 'dyn.dat' file
-  !Config  Def  = n
-  !Config  Help = output dynamics diagnostics in Grads-readable 'dyn.dat' file
-  output_grads_dyn=.FALSE.
-  CALL getin('output_grads_dyn',output_grads_dyn)
-
-  !Config  Key  = dissip_period
-  !Config  Desc = periode de la dissipation 
-  !Config  Def  = 0
-  !Config  Help = periode de la dissipation 
-  !Config  dissip_period=0 => la valeur sera calcule dans inidissip       
-  !Config  dissip_period>0 => on prend cette valeur
-  dissip_period = 0
-  CALL getin('dissip_period',dissip_period)
-
-  !cc  ....   P. Le Van , modif le 29/04/97 .pour la dissipation  ...
-  !cc
-
-  !Config  Key  = lstardis
-  !Config  Desc = choix de l'operateur de dissipation
-  !Config  Def  = y
-  !Config  Help = choix de l'operateur de dissipation
-  !Config         'y' si on veut star et 'n' si on veut non-start !
-  !Config         Moi y en a pas comprendre ! 
-  lstardis = .TRUE.
-  CALL getin('lstardis',lstardis)
-
-  !Config  Key  = nitergdiv
-  !Config  Desc = Nombre d'iteration de gradiv
-  !Config  Def  = 1
-  !Config  Help = nombre d'iterations de l'operateur de dissipation 
-  !Config         gradiv
-  nitergdiv = 1
-  CALL getin('nitergdiv',nitergdiv)
-
-  !Config  Key  = nitergrot
-  !Config  Desc = nombre d'iterations de nxgradrot
-  !Config  Def  = 2
-  !Config  Help = nombre d'iterations de l'operateur de dissipation  
-  !Config         nxgradrot
-  nitergrot = 2
-  CALL getin('nitergrot',nitergrot)
-
-  !Config  Key  = niterh
-  !Config  Desc = nombre d'iterations de divgrad
-  !Config  Def  = 2
-  !Config  Help = nombre d'iterations de l'operateur de dissipation
-  !Config         divgrad
-  niterh = 2
-  CALL getin('niterh',niterh)
-
-  !Config  Key  = tetagdiv
-  !Config  Desc = temps de dissipation pour div
-  !Config  Def  = 7200
-  !Config  Help = temps de dissipation des plus petites longeur 
-  !Config         d'ondes pour u,v (gradiv)
-  tetagdiv = 7200.
-  CALL getin('tetagdiv',tetagdiv)
-
-  !Config  Key  = tetagrot
-  !Config  Desc = temps de dissipation pour grad
-  !Config  Def  = 7200
-  !Config  Help = temps de dissipation des plus petites longeur 
-  !Config         d'ondes pour u,v (nxgradrot)
-  tetagrot = 7200.
-  CALL getin('tetagrot',tetagrot)
-
-  !Config  Key  = tetatemp 
-  !Config  Desc = temps de dissipation pour h
-  !Config  Def  = 7200
-  !Config  Help =  temps de dissipation des plus petites longeur 
-  !Config         d'ondes pour h (divgrad)   
-  tetatemp  = 7200.
-  CALL getin('tetatemp',tetatemp )
-
-  ! Parametres controlant la variation sur la verticale des constantes de
-  ! dissipation.
-  ! Pour le moment actifs uniquement dans la version a 39 niveaux
-  ! avec ok_strato=y
-
-  dissip_factz=4.
-  dissip_deltaz=10.
-  dissip_zref=30.
-  CALL getin('dissip_factz',dissip_factz )
-  CALL getin('dissip_deltaz',dissip_deltaz )
-  CALL getin('dissip_zref',dissip_zref )
-
-
-  !maxlatfilter
-  maxlatfilter = -1.0
-  CALL getin('maxlatfilter',maxlatfilter)
-  IF (maxlatfilter > 90) &
-       CALL abort_gcm("conf_gcm", 'maxlatfilter should be <=90', 1)
-  
-
-  ! ngroup
-  ngroup=3
-  CALL getin('ngroup',ngroup)
-  IF (mod(iim, 2**ngroup) /= 0) &
-       CALL abort_gcm("conf_gcm", 'iim must be multiple of 2**ngroup', 1)
-  IF (2**ngroup > jjm + 1) &
-       CALL abort_gcm("conf_gcm", '2**ngroup must be <= jjm + 1', 1)
-
-  ! mode_top_bound : fields towards which sponge relaxation will be done:
-  ! top_bound sponge: only active if ok_strato=.TRUE. and iflag_top_bound!=0
-  !                   iflag_top_bound=0 for no sponge
-  !                   iflag_top_bound=1 for sponge over 4 topmost layers
-  !                   iflag_top_bound=2 for sponge from top to ~1% of top layer pressure
-  iflag_top_bound=1
-  CALL getin('iflag_top_bound',iflag_top_bound)
-  IF (iflag_top_bound < 0 .OR. iflag_top_bound > 2) &
-       CALL abort_gcm("conf_gcm", 'iflag_top_bound must be 0, 1 or 2', 1)
-
-  ! mode_top_bound : fields towards which sponge relaxation will be done:
-  !                  mode_top_bound=0: no relaxation
-  !                  mode_top_bound=1: u and v relax towards 0
-  !                  mode_top_bound=2: u and v relax towards their zonal mean
-  !                  mode_top_bound=3: u,v and pot. temp. relax towards their zonal mean
-  mode_top_bound=3
-  CALL getin('mode_top_bound',mode_top_bound)
-
-  ! top_bound sponge : inverse of charactericstic relaxation time scale for sponge
-  tau_top_bound=1.e-5
-  CALL getin('tau_top_bound',tau_top_bound)
-
-  !Config  Key  = coefdis
-  !Config  Desc = coefficient pour gamdissip
-  !Config  Def  = 0
-  !Config  Help = coefficient pour gamdissip  
-  coefdis = 0.
-  CALL getin('coefdis',coefdis)
-
-  !Config  Key  = purmats
-  !Config  Desc = Schema d'integration
-  !Config  Def  = n
-  !Config  Help = Choix du schema d'integration temporel.
-  !Config         y = pure Matsuno sinon c'est du Matsuno-leapfrog
-  purmats = .FALSE.
-  CALL getin('purmats',purmats)
-
-  !Config  Key  = ok_guide
-  !Config  Desc = Guidage
-  !Config  Def  = n
-  !Config  Help = Guidage
-  ok_guide = .FALSE.
-  CALL getin('ok_guide',ok_guide)
-
-  IF (ok_guide .AND. adjust) CALL abort_gcm("conf_gcm", &
-       "adjust does not work with ok_guide", 1)
-
-  !Config  Key  =  read_start
-  !Config  Desc = Initialize model using a 'start.nc' file
-  !Config  Def  = y
-  !Config  Help = y: intialize dynamical fields using a 'start.nc' file
-  !               n: fields are initialized by 'iniacademic' routine
-  read_start= .TRUE.
-  CALL getin('read_start',read_start)
-
-  !Config  Key  = iflag_phys
-  !Config  Desc = Avec ls physique 
-  !Config  Def  = 1
-  !Config  Help = Permet de faire tourner le modele sans 
-  !Config         physique.
-  iflag_phys = 1
-  CALL getin('iflag_phys',iflag_phys)
-
-  !Config  Key  =  iphysiq
-  !Config  Desc = Periode de la physique
-  !Config  Def  = 5
-  !Config  Help = Periode de la physique en pas de temps de la dynamique.
-  iphysiq = 5
-  CALL getin('iphysiq', iphysiq)
-
-  !Config  Key  = ip_ebil_dyn
-  !Config  Desc = PRINT level for energy conserv. diag.
-  !Config  Def  = 0
-  !Config  Help = PRINT level for energy conservation diag. ;
-  !               les options suivantes existent :
-  !Config         0 pas de print
-  !Config         1 pas de print
-  !Config         2 print,
-  ip_ebil_dyn = 0
-  CALL getin('ip_ebil_dyn',ip_ebil_dyn)
-
-  !cc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
-  !     .........   (  modif  le 17/04/96 )   .........
-
-  test_etatinit: IF (.NOT. etatinit) THEN
-     !Config  Key  = clon
-     !Config  Desc = centre du zoom, longitude
-     !Config  Def  = 0
-     !Config  Help = longitude en degres du centre 
-     !Config         du zoom
-     clonn = 0.
-     CALL getin('clon',clonn)
-
-     !Config  Key  = clat
-     !Config  Desc = centre du zoom, latitude
-     !Config  Def  = 0
-     !Config  Help = latitude en degres du centre du zoom
-     !Config         
-     clatt = 0.
-     CALL getin('clat',clatt)
-
-     IF( ABS(clat - clatt)>= 0.001 )  THEN
-        WRITE(lunout,*)'conf_gcm: La valeur de clat passee par run.def', &
-             ' est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm","stopped",1)
-     ENDIF
-
-     !Config  Key  = grossismx 
-     !Config  Desc = zoom en longitude
-     !Config  Def  = 1.0
-     !Config  Help = facteur de grossissement du zoom,
-     !Config         selon la longitude
-     grossismxx = 1.0
-     CALL getin('grossismx',grossismxx)
-
-     IF( ABS(grossismx - grossismxx)>= 0.001 )  THEN
-        WRITE(lunout,*)'conf_gcm: La valeur de grossismx passee par ', &
-             'run.def est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm","stopped",1)
-      ENDIF
-
-     !Config  Key  = grossismy
-     !Config  Desc = zoom en latitude
-     !Config  Def  = 1.0
-     !Config  Help = facteur de grossissement du zoom,
-     !Config         selon la latitude
-     grossismyy = 1.0
-     CALL getin('grossismy',grossismyy)
-
-     IF( ABS(grossismy - grossismyy)>= 0.001 )  THEN
-        WRITE(lunout,*)'conf_gcm: La valeur de grossismy passee par ', &
-             'run.def est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm","stopped",1)
-     ENDIF
-
-     IF( grossismx<1. )  THEN
-        WRITE(lunout,*) &
-             'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
-        CALL abort_gcm("conf_gcm","stopped",1)
-     ELSE
-        alphax = 1. - 1./ grossismx
-     ENDIF
-
-     IF( grossismy<1. )  THEN
-        WRITE(lunout,*) &
-             'conf_gcm: ***  ATTENTION !! grossismy < 1 .   *** '
-        CALL abort_gcm("conf_gcm","stopped",1)
-     ELSE
-        alphay = 1. - 1./ grossismy
-     ENDIF
-
-     WRITE(lunout,*)'conf_gcm: alphax alphay',alphax,alphay
-
-     !    alphax et alphay sont les anciennes formulat. des grossissements
-
-     !Config  Key  = fxyhypb
-     !Config  Desc = Fonction  hyperbolique
-     !Config  Def  = y
-     !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
-     !Config         sinon  sinusoidale
-     fxyhypbb = .TRUE.
-     CALL getin('fxyhypb',fxyhypbb)
-
-     IF( .NOT.fxyhypb )  THEN
-        IF( fxyhypbb )     THEN
-           WRITE(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-           WRITE(lunout,*)' *** fxyhypb lu sur le fichier start est ', &
-                'F alors  qu il est  T  sur  run.def  ***'
-           CALL abort_gcm("conf_gcm","stopped",1)
-        ENDIF
-     ELSE
-        IF( .NOT.fxyhypbb )   THEN
-           WRITE(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-           WRITE(lunout,*)' ***  fxyhypb lu sur le fichier start est ', &
-                'T alors  qu il est  F  sur  run.def  ****  '
-           CALL abort_gcm("conf_gcm","stopped",1)
-        ENDIF
-     ENDIF
-
-     !Config  Key  = dzoomx
-     !Config  Desc = extension en longitude
-     !Config  Def  = 0
-     !Config  Help = extension en longitude  de la zone du zoom  
-     !Config         ( fraction de la zone totale)
-     dzoomxx = 0.0
-     CALL getin('dzoomx',dzoomxx)
-
-     IF( fxyhypb )  THEN
-        IF( ABS(dzoomx - dzoomxx)>= 0.001 )  THEN
-           WRITE(lunout,*)'conf_gcm: La valeur de dzoomx passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-           CALL abort_gcm("conf_gcm","stopped",1)
-        ENDIF
-     ENDIF
-
-     !Config  Key  = dzoomy
-     !Config  Desc = extension en latitude
-     !Config  Def  = 0
-     !Config  Help = extension en latitude de la zone  du zoom  
-     !Config         ( fraction de la zone totale)
-     dzoomyy = 0.0
-     CALL getin('dzoomy',dzoomyy)
-
-     IF( fxyhypb )  THEN
-        IF( ABS(dzoomy - dzoomyy)>= 0.001 )  THEN
-           WRITE(lunout,*)'conf_gcm: La valeur de dzoomy passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-           CALL abort_gcm("conf_gcm","stopped",1)
-        ENDIF
-     ENDIF
-
-     !Config  Key  = taux
-     !Config  Desc = raideur du zoom en  X
-     !Config  Def  = 3
-     !Config  Help = raideur du zoom en  X
-     tauxx = 3.0
-     CALL getin('taux',tauxx)
-
-     IF( fxyhypb )  THEN
-        IF( ABS(taux - tauxx)>= 0.001 )  THEN
-           WRITE(lunout,*)'conf_gcm: La valeur de taux passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-           CALL abort_gcm("conf_gcm","stopped",1)
-        ENDIF
-     ENDIF
-
-     !Config  Key  = tauyy
-     !Config  Desc = raideur du zoom en  Y
-     !Config  Def  = 3
-     !Config  Help = raideur du zoom en  Y
-     tauyy = 3.0
-     CALL getin('tauy',tauyy)
-
-     IF( fxyhypb )  THEN
-        IF( ABS(tauy - tauyy)>= 0.001 )  THEN
-           WRITE(lunout,*)'conf_gcm: La valeur de tauy passee par ', &
-                'run.def est differente de celle lue sur le fichier  start '
-        CALL abort_gcm("conf_gcm","stopped",1)
-        ENDIF
-     ENDIF
-
-     !c
-     IF( .NOT.fxyhypb  )  THEN
-
-        !Config  Key  = ysinus
-        !Config  IF   = !fxyhypb
-        !Config  Desc = Fonction en Sinus
-        !Config  Def  = y
-        !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
-        !Config         sinon y = latit.
-        ysinuss = .TRUE.
-        CALL getin('ysinus',ysinuss)
-
-        IF( .NOT.ysinus )  THEN
-           IF( ysinuss )     THEN
-              WRITE(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-              WRITE(lunout,*)' *** ysinus lu sur le fichier start est F', &
-                   ' alors  qu il est  T  sur  run.def  ***'
-              CALL abort_gcm("conf_gcm","stopped",1)
-           ENDIF
-        ELSE
-           IF( .NOT.ysinuss )   THEN
-              WRITE(lunout,*)' ********  PBS DANS  CONF_GCM  ******** '
-              WRITE(lunout,*)' *** ysinus lu sur le fichier start est T', &
-                   ' alors  qu il est  F  sur  run.def  ****  '
-              CALL abort_gcm("conf_gcm","stopped",1)
-           ENDIF
-        ENDIF
-     ENDIF ! of IF( .NOT.fxyhypb  )
-
-     !Config  Key  = offline
-     !Config  Desc = ecriture des flux de masse
-     !Config  Def  = n
-     !Config  Help = Permet de sortir les flux de masse sur la grille plev 
-     offline = .FALSE.
-     CALL getin('offline',offline)
-
-     !Config Key  = offline_time
-     !Config Desc =  Choix des frequences de stockage pour le offline
-     !Config Def  = 8
-     !Config Help = offline_time=12     ! stockage toutes les 2h=1jour/12
-     !Config Help = offline_time=8      ! stockage toutes les 3h=1jour/8
-     offline_time = 8
-     CALL getin('offline_time',offline_time)
-
-     IF (offline .AND. adjust) THEN
-        WRITE(lunout,*)  &
-             'WARNING : option offline does not work with adjust=y :'
-        WRITE(lunout,*) 'the files defstoke.nc, fluxstoke.nc ',  &
-             'and fluxstokev.nc will not be created'
-        WRITE(lunout,*)  &
-             'only the file phystoke.nc will still be created ' 
-     ENDIF
-
-     !Config  Key  = type_trac
-     !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
-     !Config  Def  = lmdz
-     !Config  Help = 
-     !Config         'lmdz' = pas de couplage, pur LMDZ
-     !Config         'inca' = model de chime INCA 
-     !Config         'repr' = model de chime REPROBUS
-     type_trac = 'lmdz'
-     CALL getin('type_trac',type_trac)
-
-
-     !Config  Key  = adv_qsat_liq
-     !Config  Desc = option for qsat calculation in the dynamics
-     !Config  Def  = n 
-     !Config  Help = controls which phase is considered for qsat calculation 
-     !Config          
-     adv_qsat_liq = .FALSE.
-     CALL getin('adv_qsat_liq',adv_qsat_liq)
-
-     !Config  Key  = ok_dynzon 
-     !Config  Desc = calcul et sortie des transports 
-     !Config  Def  = n 
-     !Config  Help = Permet de mettre en route le calcul des transports 
-     !Config          
-     ok_dynzon = .FALSE. 
-     CALL getin('ok_dynzon',ok_dynzon) 
-
-     !Config  Key  = ok_dyn_ins
-     !Config  Desc = sorties instantanees dans la dynamique
-     !Config  Def  = n 
-     !Config  Help = 
-     !Config          
-     ok_dyn_ins = .FALSE. 
-     CALL getin('ok_dyn_ins',ok_dyn_ins) 
-
-     !Config  Key  = ok_dyn_ave
-     !Config  Desc = sorties moyennes dans la dynamique
-     !Config  Def  = n 
-     !Config  Help = 
-     !Config          
-     ok_dyn_ave = .FALSE. 
-     CALL getin('ok_dyn_ave',ok_dyn_ave) 
-
-     !Config  Key  = ok_dyn_xios
-     !Config  Desc = sorties moyennes dans la dynamique
-     !Config  Def  = n 
-     !Config  Help = 
-     !Config          
-     ok_dyn_xios = .FALSE. 
-     CALL getin('ok_dyn_xios',ok_dyn_xios) 
-
-     WRITE(lunout,*)' #########################################'
-     WRITE(lunout,*)' Configuration des parametres du gcm: '
-     WRITE(lunout,*)' planet_type = ', planet_type
-     WRITE(lunout,*)' calend = ', calend
-     WRITE(lunout,*)' dayref = ', dayref
-     WRITE(lunout,*)' anneeref = ', anneeref
-     WRITE(lunout,*)' nday = ', nday
-     WRITE(lunout,*)' day_step = ', day_step
-     WRITE(lunout,*)' iperiod = ', iperiod
-     WRITE(lunout,*)' nsplit_phys = ', nsplit_phys
-     WRITE(lunout,*)' iconser = ', iconser
-     WRITE(lunout,*)' iecri = ', iecri
-     WRITE(lunout,*)' periodav = ', periodav
-     WRITE(lunout,*)' output_grads_dyn = ', output_grads_dyn
-     WRITE(lunout,*)' dissip_period = ', dissip_period
-     WRITE(lunout,*)' lstardis = ', lstardis
-     WRITE(lunout,*)' nitergdiv = ', nitergdiv
-     WRITE(lunout,*)' nitergrot = ', nitergrot
-     WRITE(lunout,*)' niterh = ', niterh
-     WRITE(lunout,*)' tetagdiv = ', tetagdiv
-     WRITE(lunout,*)' tetagrot = ', tetagrot
-     WRITE(lunout,*)' tetatemp = ', tetatemp
-     WRITE(lunout,*)' coefdis = ', coefdis
-     WRITE(lunout,*)' purmats = ', purmats
-     WRITE(lunout,*)' read_start = ', read_start
-     WRITE(lunout,*)' iflag_phys = ', iflag_phys
-     WRITE(lunout,*)' iphysiq = ', iphysiq
-     WRITE(lunout,*)' clonn = ', clonn
-     WRITE(lunout,*)' clatt = ', clatt
-     WRITE(lunout,*)' grossismx = ', grossismx
-     WRITE(lunout,*)' grossismy = ', grossismy
-     WRITE(lunout,*)' fxyhypbb = ', fxyhypbb
-     WRITE(lunout,*)' dzoomxx = ', dzoomxx
-     WRITE(lunout,*)' dzoomy = ', dzoomyy
-     WRITE(lunout,*)' tauxx = ', tauxx
-     WRITE(lunout,*)' tauyy = ', tauyy
-     WRITE(lunout,*)' offline = ', offline
-     WRITE(lunout,*)' offline_time = ', offline_time
-     WRITE(lunout,*)' type_trac = ', type_trac
-     WRITE(lunout,*)' ok_dynzon = ', ok_dynzon
-     WRITE(lunout,*)' ok_dyn_ins = ', ok_dyn_ins
-     WRITE(lunout,*)' ok_dyn_ave = ', ok_dyn_ave
-     WRITE(lunout,*)' ok_dyn_xios = ', ok_dyn_xios
-     WRITE(lunout,*)' adv_qsat_liq = ', adv_qsat_liq
-  else
-     !Config  Key  = clon
-     !Config  Desc = centre du zoom, longitude
-     !Config  Def  = 0
-     !Config  Help = longitude en degres du centre 
-     !Config         du zoom
-     clon = 0.
-     CALL getin('clon',clon)
-
-     !Config  Key  = clat
-     !Config  Desc = centre du zoom, latitude
-     !Config  Def  = 0
-     !Config  Help = latitude en degres du centre du zoom
-     !Config         
-     clat = 0.
-     CALL getin('clat',clat)
-
-     !Config  Key  = grossismx 
-     !Config  Desc = zoom en longitude
-     !Config  Def  = 1.0
-     !Config  Help = facteur de grossissement du zoom,
-     !Config         selon la longitude
-     grossismx = 1.0
-     CALL getin('grossismx',grossismx)
-
-     !Config  Key  = grossismy
-     !Config  Desc = zoom en latitude
-     !Config  Def  = 1.0
-     !Config  Help = facteur de grossissement du zoom,
-     !Config         selon la latitude
-     grossismy = 1.0
-     CALL getin('grossismy',grossismy)
-
-     IF( grossismx<1. )  THEN
-        WRITE(lunout,*) 'conf_gcm: ***ATTENTION !! grossismx < 1 . *** '
-        CALL abort_gcm("conf_gcm","stopped",1)
-     ELSE
-        alphax = 1. - 1./ grossismx
-     ENDIF
-
-     IF( grossismy<1. )  THEN
-        WRITE(lunout,*) 'conf_gcm: ***ATTENTION !! grossismy < 1 . *** '
-        CALL abort_gcm("conf_gcm","stopped",1)
-     ELSE
-        alphay = 1. - 1./ grossismy
-     ENDIF
-
-     WRITE(lunout,*) 'conf_gcm: alphax alphay ',alphax,alphay
-
-     !    alphax et alphay sont les anciennes formulat. des grossissements
-
-     !Config  Key  = fxyhypb
-     !Config  Desc = Fonction  hyperbolique
-     !Config  Def  = y
-     !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
-     !Config         sinon  sinusoidale
-     fxyhypb = .TRUE.
-     CALL getin('fxyhypb',fxyhypb)
-
-     !Config  Key  = dzoomx
-     !Config  Desc = extension en longitude
-     !Config  Def  = 0
-     !Config  Help = extension en longitude  de la zone du zoom  
-     !Config         ( fraction de la zone totale)
-     dzoomx = 0.2
-     CALL getin('dzoomx',dzoomx)
-     CALL assert(dzoomx < 1, "conf_gcm: dzoomx must be < 1")
-
-     !Config  Key  = dzoomy
-     !Config  Desc = extension en latitude
-     !Config  Def  = 0
-     !Config  Help = extension en latitude de la zone  du zoom  
-     !Config         ( fraction de la zone totale)
-     dzoomy = 0.2
-     CALL getin('dzoomy',dzoomy)
-     CALL assert(dzoomy < 1, "conf_gcm: dzoomy must be < 1")
-
-     !Config  Key  = taux
-     !Config  Desc = raideur du zoom en  X
-     !Config  Def  = 3
-     !Config  Help = raideur du zoom en  X
-     taux = 3.0
-     CALL getin('taux',taux)
-
-     !Config  Key  = tauy
-     !Config  Desc = raideur du zoom en  Y
-     !Config  Def  = 3
-     !Config  Help = raideur du zoom en  Y
-     tauy = 3.0
-     CALL getin('tauy',tauy)
-
-     !Config  Key  = ysinus
-     !Config  IF   = !fxyhypb
-     !Config  Desc = Fonction en Sinus
-     !Config  Def  = y
-     !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
-     !Config         sinon y = latit.
-     ysinus = .TRUE.
-     CALL getin('ysinus',ysinus)
-
-     !Config  Key  = offline
-     !Config  Desc = Nouvelle eau liquide
-     !Config  Def  = n
-     !Config  Help = Permet de mettre en route la
-     !Config         nouvelle parametrisation de l'eau liquide !
-     offline = .FALSE.
-     CALL getin('offline',offline)
-     IF (offline .AND. adjust) THEN
-        WRITE(lunout,*)  &
-             'WARNING : option offline does not work with adjust=y :'
-        WRITE(lunout,*) 'the files defstoke.nc, fluxstoke.nc ',  &
-             'and fluxstokev.nc will not be created'
-        WRITE(lunout,*)  &
-             'only the file phystoke.nc will still be created ' 
-     ENDIF
-
-     !Config  Key  = type_trac
-     !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
-     !Config  Def  = lmdz
-     !Config  Help = 
-     !Config         'lmdz' = pas de couplage, pur LMDZ
-     !Config         'inca' = model de chime INCA 
-     !Config         'repr' = model de chime REPROBUS
-     type_trac = 'lmdz'
-     CALL getin('type_trac',type_trac)
-
-     !Config  Key  = ok_dynzon 
-     !Config  Desc = sortie des transports zonaux dans la dynamique
-     !Config  Def  = n 
-     !Config  Help = Permet de mettre en route le calcul des transports 
-     !Config          
-     ok_dynzon = .FALSE. 
-     CALL getin('ok_dynzon',ok_dynzon) 
-
-     !Config  Key  = ok_dyn_ins
-     !Config  Desc = sorties instantanees dans la dynamique
-     !Config  Def  = n 
-     !Config  Help = 
-     !Config          
-     ok_dyn_ins = .FALSE. 
-     CALL getin('ok_dyn_ins',ok_dyn_ins) 
-
-     !Config  Key  = ok_dyn_ave
-     !Config  Desc = sorties moyennes dans la dynamique
-     !Config  Def  = n 
-     !Config  Help = 
-     !Config          
-     ok_dyn_ave = .FALSE. 
-     CALL getin('ok_dyn_ave',ok_dyn_ave) 
-
-     !Config  Key  = ok_dyn_xios
-     !Config  Desc = sorties moyennes dans la dynamique
-     !Config  Def  = n 
-     !Config  Help = 
-     !Config          
-     ok_dyn_xios = .FALSE. 
-     CALL getin('ok_dyn_xios',ok_dyn_xios) 
-
-     !Config  Key  = use_filtre_fft
-     !Config  Desc = flag to activate FFTs for the filter
-     !Config  Def  = false
-     !Config  Help = enables to use FFts to do the longitudinal polar 
-     !Config         filtering around the poles.
-     use_filtre_fft=.FALSE.
-     CALL getin('use_filtre_fft',use_filtre_fft)
-     IF (use_filtre_fft .AND. grossismx /= 1.0) THEN
-        WRITE(lunout,*)'WARNING !!! '
-        WRITE(lunout,*)"A zoom in longitude is not compatible", &
-             " with the FFT filter ", &
-             "---> FFT filter deactivated"
-        use_filtre_fft=.FALSE.
-     ENDIF
-     use_filtre_fft_loc=use_filtre_fft
-
-     !Config  Key  = use_mpi_alloc
-     !Config  Desc = Utilise un buffer MPI en mémoire globale
-     !Config  Def  = false
-     !Config  Help = permet d'activer l'utilisation d'un buffer MPI
-     !Config         en mémoire globale a l'aide de la fonction MPI_ALLOC.
-     !Config         Cela peut améliorer la bande passante des transferts MPI
-     !Config         d'un facteur 2  
-     use_mpi_alloc=.FALSE.
-     CALL getin('use_mpi_alloc',use_mpi_alloc)
-
-     !Config key = ok_strato
-     !Config  Desc = activation de la version strato
-     !Config  Def  = .FALSE.
-     !Config  Help = active la version stratosphérique de LMDZ de F. Lott
-
-     ok_strato=.FALSE.
-     CALL getin('ok_strato',ok_strato)
-
-     vert_prof_dissip = merge(1, 0, ok_strato .AND. llm==39)
-     CALL getin('vert_prof_dissip', vert_prof_dissip)
-     CALL assert(vert_prof_dissip == 0 .OR. vert_prof_dissip ==  1, &
-          "bad value for vert_prof_dissip")
-
-     !Config  Key  = ok_gradsfile
-     !Config  Desc = activation des sorties grads du guidage
-     !Config  Def  = n
-     !Config  Help = active les sorties grads du guidage
-
-     ok_gradsfile = .FALSE.
-     CALL getin('ok_gradsfile',ok_gradsfile)
-
-     !Config  Key  = ok_limit
-     !Config  Desc = creation des fichiers limit dans create_etat0_limit
-     !Config  Def  = y
-     !Config  Help = production du fichier limit.nc requise
-
-     ok_limit = .TRUE.
-     CALL getin('ok_limit',ok_limit)
-
-     !Config  Key  = ok_etat0
-     !Config  Desc = creation des fichiers etat0 dans create_etat0_limit
-     !Config  Def  = y
-     !Config  Help = production des fichiers start.nc, startphy.nc requise
-
-     ok_etat0 = .TRUE.
-     CALL getin('ok_etat0',ok_etat0)
-
-     !Config  Key  = read_orop
-     !Config  Desc = lecture du fichier de params orographiques sous maille
-     !Config  Def  = f
-     !Config  Help = lecture fichier plutot que grid_noro
-
-     read_orop = .FALSE.
-     CALL getin('read_orop',read_orop)
-
-     WRITE(lunout,*)' #########################################'
-     WRITE(lunout,*)' Configuration des parametres de cel0_limit: '
-     WRITE(lunout,*)' planet_type = ', planet_type
-     WRITE(lunout,*)' calend = ', calend
-     WRITE(lunout,*)' dayref = ', dayref
-     WRITE(lunout,*)' anneeref = ', anneeref
-     WRITE(lunout,*)' nday = ', nday
-     WRITE(lunout,*)' day_step = ', day_step
-     WRITE(lunout,*)' iperiod = ', iperiod
-     WRITE(lunout,*)' iconser = ', iconser
-     WRITE(lunout,*)' iecri = ', iecri
-     WRITE(lunout,*)' periodav = ', periodav
-     WRITE(lunout,*)' output_grads_dyn = ', output_grads_dyn
-     WRITE(lunout,*)' dissip_period = ', dissip_period
-     WRITE(lunout,*)' lstardis = ', lstardis
-     WRITE(lunout,*)' nitergdiv = ', nitergdiv
-     WRITE(lunout,*)' nitergrot = ', nitergrot
-     WRITE(lunout,*)' niterh = ', niterh
-     WRITE(lunout,*)' tetagdiv = ', tetagdiv
-     WRITE(lunout,*)' tetagrot = ', tetagrot
-     WRITE(lunout,*)' tetatemp = ', tetatemp
-     WRITE(lunout,*)' coefdis = ', coefdis
-     WRITE(lunout,*)' purmats = ', purmats
-     WRITE(lunout,*)' read_start = ', read_start
-     WRITE(lunout,*)' iflag_phys = ', iflag_phys
-     WRITE(lunout,*)' iphysiq = ', iphysiq
-     WRITE(lunout,*)' clon = ', clon
-     WRITE(lunout,*)' clat = ', clat
-     WRITE(lunout,*)' grossismx = ', grossismx
-     WRITE(lunout,*)' grossismy = ', grossismy
-     WRITE(lunout,*)' fxyhypb = ', fxyhypb
-     WRITE(lunout,*)' dzoomx = ', dzoomx
-     WRITE(lunout,*)' dzoomy = ', dzoomy
-     WRITE(lunout,*)' taux = ', taux
-     WRITE(lunout,*)' tauy = ', tauy
-     WRITE(lunout,*)' offline = ', offline
-     WRITE(lunout,*)' type_trac = ', type_trac
-     WRITE(lunout,*)' ok_dynzon = ', ok_dynzon
-     WRITE(lunout,*)' ok_dyn_ins = ', ok_dyn_ins
-     WRITE(lunout,*)' ok_dyn_ave = ', ok_dyn_ave
-     WRITE(lunout,*)' ok_dyn_xios = ', ok_dyn_xios
-     WRITE(lunout,*)' use_filtre_fft = ', use_filtre_fft
-     WRITE(lunout,*)' use_mpi_alloc = ', use_mpi_alloc
-     WRITE(lunout,*)' ok_strato = ', ok_strato
-     WRITE(lunout,*)' ok_gradsfile = ', ok_gradsfile
-     WRITE(lunout,*)' ok_limit = ', ok_limit
-     WRITE(lunout,*)' ok_etat0 = ', ok_etat0
-     WRITE(lunout,*)' ok_guide = ', ok_guide
-     WRITE(lunout,*)' read_orop = ', read_orop
-  ENDIF test_etatinit
-
-END SUBROUTINE conf_gcm
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/gcm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/gcm.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/gcm.F90	(revision 5186)
@@ -1,3 +1,2 @@
-
 ! $Id$
 
@@ -14,5 +13,4 @@
   USE control_mod
 
-
   USE iniphysiq_mod, ONLY: iniphysiq
   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
@@ -20,7 +18,7 @@
   USE comconst_mod, ONLY: cpp, daysec, dtphys, dtvr, g, r, rad
   USE logic_mod ! all of it, because of copyin clause when calling leapfrog
-  USE temps_mod, ONLY: calend,start_time,annee_ref,day_ref, &
-                       itau_dyn,itau_phy,day_ini,jD_ref,jH_ref,day_end, &
-                       dt,hour_ini,itaufin
+  USE temps_mod, ONLY: calend, start_time, annee_ref, day_ref, &
+          itau_dyn, itau_phy, day_ini, jD_ref, jH_ref, day_end, &
+          dt, hour_ini, itaufin
   USE mod_xios_dyn3dmem, ONLY: xios_dyn3dmem_init
   USE lmdz_filtreg, ONLY: inifilr
@@ -34,4 +32,6 @@
   USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
   USE lmdz_paramet
+  USE lmdz_conf_gcm, ONLY: conf_gcm
+
   IMPLICIT NONE
 
@@ -66,16 +66,14 @@
   !   -------------
 
-
-
   REAL zdtvr
 
   !   variables dynamiques
-  REAL,ALLOCATABLE,SAVE  :: vcov(:,:),ucov(:,:) ! vents covariants
-  REAL,ALLOCATABLE,SAVE  :: teta(:,:)     ! temperature potentielle 
-  REAL, ALLOCATABLE,SAVE :: q(:,:,:)      ! champs advectes
-  REAL,ALLOCATABLE,SAVE  :: ps(:)         ! pression  au sol
+  REAL, ALLOCATABLE, SAVE :: vcov(:, :), ucov(:, :) ! vents covariants
+  REAL, ALLOCATABLE, SAVE :: teta(:, :)     ! temperature potentielle
+  REAL, ALLOCATABLE, SAVE :: q(:, :, :)      ! champs advectes
+  REAL, ALLOCATABLE, SAVE :: ps(:)         ! pression  au sol
   !      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
-  REAL,ALLOCATABLE,SAVE  :: masse(:,:)    ! masse d'air
-  REAL,ALLOCATABLE,SAVE  :: phis(:)       ! geopotentiel au sol
+  REAL, ALLOCATABLE, SAVE :: masse(:, :)    ! masse d'air
+  REAL, ALLOCATABLE, SAVE :: phis(:)       ! geopotentiel au sol
   !      REAL phi(ip1jmp1,llm)                  ! geopotentiel
   !      REAL w(ip1jmp1,llm)                    ! vitesse verticale
@@ -103,16 +101,15 @@
   !-jld 
 
-
-  CHARACTER (LEN=80) :: dynhist_file, dynhistave_file
-  CHARACTER (LEN=20) :: modname
-  CHARACTER (LEN=80) :: abort_message
+  CHARACTER (LEN = 80) :: dynhist_file, dynhistave_file
+  CHARACTER (LEN = 20) :: modname
+  CHARACTER (LEN = 80) :: abort_message
   ! locales pour gestion du temps
   INTEGER :: an, mois, jour
   REAL :: heure
   ! needed for xios interface
-  CHARACTER (LEN=10) :: xios_cal_type
+  CHARACTER (LEN = 10) :: xios_cal_type
   INTEGER :: anref, moisref, jourref
   REAL :: heureref
-  
+
 
 
@@ -124,5 +121,5 @@
   modname = 'gcm'
   descript = 'Run GCM LMDZ'
-  lafin    = .FALSE.
+  lafin = .FALSE.
   dynhist_file = 'dyn_hist'
   dynhistave_file = 'dyn_hist_ave'
@@ -134,7 +131,7 @@
   !  ---------------------------------------
 
-  CALL conf_gcm( 99, .TRUE. )
+  CALL conf_gcm(99, .TRUE.)
   IF (mod(iphysiq, iperiod) /= 0) CALL abort_gcm("conf_gcm", &
-       "iphysiq must be a multiple of iperiod", 1)
+          "iphysiq must be a multiple of iperiod", 1)
 
 
@@ -147,11 +144,11 @@
   CALL Read_Distrib
 
-!#ifdef CPP_PHYS
-!  CALL Init_Phys_lmdz(iim,jjp1,llm,mpi_size,distrib_phys)
+  !#ifdef CPP_PHYS
+  !  CALL Init_Phys_lmdz(iim,jjp1,llm,mpi_size,distrib_phys)
   !#endif
   !      CALL set_bands
   !#ifdef CPP_PHYS
-!  CALL Init_interface_dyn_phys
-!#endif
+  !  CALL Init_interface_dyn_phys
+  !#endif
   CALL barrier
 
@@ -177,18 +174,18 @@
 
   IF (calend == 'earth_360d') THEN
-     CALL ioconf_calendar('360_day')
-     WRITE(lunout,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
-     xios_cal_type='d360'
+    CALL ioconf_calendar('360_day')
+    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
+    xios_cal_type = 'd360'
   ELSE IF (calend == 'earth_365d') THEN
-     CALL ioconf_calendar('noleap')
-     WRITE(lunout,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
-     xios_cal_type='noleap'
+    CALL ioconf_calendar('noleap')
+    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
+    xios_cal_type = 'noleap'
   ELSE IF (calend == 'gregorian') THEN
-     CALL ioconf_calendar('gregorian')
-     WRITE(lunout,*)'CALENDRIER CHOISI: Terrestre bissextile'
-     xios_cal_type='gregorian'
+    CALL ioconf_calendar('gregorian')
+    WRITE(lunout, *)'CALENDRIER CHOISI: Terrestre bissextile'
+    xios_cal_type = 'gregorian'
   else
-     abort_message = 'Mauvais choix de calendrier'
-     CALL abort_gcm(modname,abort_message,1)
+    abort_message = 'Mauvais choix de calendrier'
+    CALL abort_gcm(modname, abort_message, 1)
   ENDIF
 
@@ -202,11 +199,11 @@
 
   ! Allocation de la tableau q : champs advectes   
-  ALLOCATE(ucov(ijb_u:ije_u,llm))
-  ALLOCATE(vcov(ijb_v:ije_v,llm))
-  ALLOCATE(teta(ijb_u:ije_u,llm))
-  ALLOCATE(masse(ijb_u:ije_u,llm))
+  ALLOCATE(ucov(ijb_u:ije_u, llm))
+  ALLOCATE(vcov(ijb_v:ije_v, llm))
+  ALLOCATE(teta(ijb_u:ije_u, llm))
+  ALLOCATE(masse(ijb_u:ije_u, llm))
   ALLOCATE(ps(ijb_u:ije_u))
   ALLOCATE(phis(ijb_u:ije_u))
-  ALLOCATE(q(ijb_u:ije_u,llm,nqtot))
+  ALLOCATE(q(ijb_u:ije_u, llm, nqtot))
 
   !-----------------------------------------------------------------------
@@ -216,31 +213,31 @@
   !  lecture du fichier start.nc
   IF (read_start) THEN
-     ! we still need to run iniacademic to initialize some
-     ! constants & fields, if we run the 'newtonian' or 'SW' cases:
-     IF (iflag_phys/=1) THEN
-        CALL iniacademic_loc(vcov,ucov,teta,q,masse,ps,phis,time_0)
-     endif
-
-     !        if (planet_type.EQ."earth") THEN
-     ! Load an Earth-format start file
-     CALL dynetat0_loc("start.nc",vcov,ucov, &
-          teta,q,masse,ps,phis, time_0)
-     !        endif ! of if (planet_type.EQ."earth")
-
-     !       WRITE(73,*) 'ucov',ucov
-     !       WRITE(74,*) 'vcov',vcov
-     !       WRITE(75,*) 'teta',teta
-     !       WRITE(76,*) 'ps',ps
-     !       WRITE(77,*) 'q',q
+    ! we still need to run iniacademic to initialize some
+    ! constants & fields, if we run the 'newtonian' or 'SW' cases:
+    IF (iflag_phys/=1) THEN
+      CALL iniacademic_loc(vcov, ucov, teta, q, masse, ps, phis, time_0)
+    endif
+
+    !        if (planet_type.EQ."earth") THEN
+    ! Load an Earth-format start file
+    CALL dynetat0_loc("start.nc", vcov, ucov, &
+            teta, q, masse, ps, phis, time_0)
+    !        endif ! of if (planet_type.EQ."earth")
+
+    !       WRITE(73,*) 'ucov',ucov
+    !       WRITE(74,*) 'vcov',vcov
+    !       WRITE(75,*) 'teta',teta
+    !       WRITE(76,*) 'ps',ps
+    !       WRITE(77,*) 'q',q
 
   ENDIF ! of if (read_start)
 
   ! le cas echeant, creation d un etat initial
-  IF (prt_level > 9) WRITE(lunout,*) &
-       'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
+  IF (prt_level > 9) WRITE(lunout, *) &
+          'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
   IF (.NOT.read_start) THEN
-     start_time=0.
-     annee_ref=anneeref
-     CALL iniacademic_loc(vcov,ucov,teta,q,masse,ps,phis,time_0)
+    start_time = 0.
+    annee_ref = anneeref
+    CALL iniacademic_loc(vcov, ucov, teta, q, masse, ps, phis, time_0)
   ENDIF
 
@@ -250,20 +247,20 @@
   !  on recalcule eventuellement le pas de temps
 
-  IF(MOD(day_step,iperiod)/=0) THEN
-     abort_message =  &
-          'Il faut choisir un nb de pas par jour multiple de iperiod'
-     CALL abort_gcm(modname,abort_message,1)
-  ENDIF
-
-  IF(MOD(day_step,iphysiq)/=0) THEN
-     abort_message =  &
-          'Il faut choisir un nb de pas par jour multiple de iphysiq'
-     CALL abort_gcm(modname,abort_message,1)
-  ENDIF
-
-  zdtvr    = daysec/REAL(day_step)
+  IF(MOD(day_step, iperiod)/=0) THEN
+    abort_message = &
+            'Il faut choisir un nb de pas par jour multiple de iperiod'
+    CALL abort_gcm(modname, abort_message, 1)
+  ENDIF
+
+  IF(MOD(day_step, iphysiq)/=0) THEN
+    abort_message = &
+            'Il faut choisir un nb de pas par jour multiple de iphysiq'
+    CALL abort_gcm(modname, abort_message, 1)
+  ENDIF
+
+  zdtvr = daysec / REAL(day_step)
   IF(dtvr/=zdtvr) THEN
-     WRITE(lunout,*) &
-          'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
+    WRITE(lunout, *) &
+            'WARNING!!! changement de pas de temps', dtvr, '>', zdtvr
   ENDIF
 
@@ -271,32 +268,32 @@
 
   IF (start_time /= starttime) THEN
-     WRITE(lunout,*)' GCM: Attention l''heure de depart lue dans le' &
-          ,' fichier restart ne correspond pas a celle lue dans le run.def'
-     IF (raz_date == 1) THEN
-        WRITE(lunout,*)'Je prends l''heure lue dans run.def'
-        start_time = starttime
-     ELSE
-        WRITE(lunout,*)'Je m''arrete'
-        CALL abort
-     ENDIF
+    WRITE(lunout, *)' GCM: Attention l''heure de depart lue dans le' &
+            , ' fichier restart ne correspond pas a celle lue dans le run.def'
+    IF (raz_date == 1) THEN
+      WRITE(lunout, *)'Je prends l''heure lue dans run.def'
+      start_time = starttime
+    ELSE
+      WRITE(lunout, *)'Je m''arrete'
+      CALL abort
+    ENDIF
   ENDIF
   IF (raz_date == 1) THEN
-     annee_ref = anneeref
-     day_ref = dayref
-     day_ini = dayref
-     itau_dyn = 0
-     itau_phy = 0
-     time_0 = 0.
-     WRITE(lunout,*) &
-          'GCM: On reinitialise a la date lue dans gcm.def'
+    annee_ref = anneeref
+    day_ref = dayref
+    day_ini = dayref
+    itau_dyn = 0
+    itau_phy = 0
+    time_0 = 0.
+    WRITE(lunout, *) &
+            'GCM: On reinitialise a la date lue dans gcm.def'
   ELSE IF (annee_ref /= anneeref .OR. day_ref /= dayref) THEN
-     WRITE(lunout,*) &
-          'GCM: Attention les dates initiales lues dans le fichier'
-     WRITE(lunout,*) &
-          ' restart ne correspondent pas a celles lues dans '
-     WRITE(lunout,*)' gcm.def'
-     WRITE(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
-     WRITE(lunout,*)' day_ref=',day_ref," dayref=",dayref
-     WRITE(lunout,*)' Pas de remise a zero'
+    WRITE(lunout, *) &
+            'GCM: Attention les dates initiales lues dans le fichier'
+    WRITE(lunout, *) &
+            ' restart ne correspondent pas a celles lues dans '
+    WRITE(lunout, *)' gcm.def'
+    WRITE(lunout, *)' annee_ref=', annee_ref, " anneeref=", anneeref
+    WRITE(lunout, *)' day_ref=', day_ref, " dayref=", dayref
+    WRITE(lunout, *)' Pas de remise a zero'
   ENDIF
   !      if (annee_ref .NE. anneeref .OR. day_ref .NE. dayref) THEN
@@ -333,29 +330,29 @@
   CALL ioconf_startdate(INT(jD_ref), jH_ref)
 
-  WRITE(lunout,*)'DEBUG'
-  WRITE(lunout,*)'annee_ref, mois, day_ref, heure, jD_ref'
-  WRITE(lunout,*)annee_ref, mois, day_ref, heure, jD_ref
-  CALL ju2ymds(jD_ref+jH_ref,anref, moisref, jourref, heureref)
-  WRITE(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
-  WRITE(lunout,*)jD_ref+jH_ref,anref, moisref, jourref, heureref
+  WRITE(lunout, *)'DEBUG'
+  WRITE(lunout, *)'annee_ref, mois, day_ref, heure, jD_ref'
+  WRITE(lunout, *)annee_ref, mois, day_ref, heure, jD_ref
+  CALL ju2ymds(jD_ref + jH_ref, anref, moisref, jourref, heureref)
+  WRITE(lunout, *)'jD_ref+jH_ref,an, mois, jour, heure'
+  WRITE(lunout, *)jD_ref + jH_ref, anref, moisref, jourref, heureref
 
   IF (iflag_phys==1) THEN
-     ! these initialisations have already been done (via iniacademic)
-     ! if running in SW or Newtonian mode
-     !-----------------------------------------------------------------------
-     !   Initialisation des constantes dynamiques :
-     !   ------------------------------------------
-     dtvr = zdtvr
-     CALL iniconst
-
-     !-----------------------------------------------------------------------
-     !   Initialisation de la geometrie :
-     !   --------------------------------
-     CALL inigeom
-
-     !-----------------------------------------------------------------------
-     !   Initialisation du filtre :
-     !   --------------------------
-     CALL inifilr
+    ! these initialisations have already been done (via iniacademic)
+    ! if running in SW or Newtonian mode
+    !-----------------------------------------------------------------------
+    !   Initialisation des constantes dynamiques :
+    !   ------------------------------------------
+    dtvr = zdtvr
+    CALL iniconst
+
+    !-----------------------------------------------------------------------
+    !   Initialisation de la geometrie :
+    !   --------------------------------
+    CALL inigeom
+
+    !-----------------------------------------------------------------------
+    !   Initialisation du filtre :
+    !   --------------------------
+    CALL inifilr
   ENDIF ! of if (iflag_phys.EQ.1)
 
@@ -364,6 +361,6 @@
   !   ----------------------------------
 
-  CALL inidissip( lstardis, nitergdiv, nitergrot, niterh   , &
-       tetagdiv, tetagrot , tetatemp, vert_prof_dissip)
+  CALL inidissip(lstardis, nitergdiv, nitergrot, niterh, &
+          tetagdiv, tetagrot, tetatemp, vert_prof_dissip)
 
   !-----------------------------------------------------------------------
@@ -371,20 +368,19 @@
   !   ------------------------
 
-
   IF (nday>=0) THEN
-     day_end = day_ini + nday
+    day_end = day_ini + nday
   else
-     day_end = day_ini - nday/day_step
-  ENDIF
-
-  WRITE(lunout,300)day_ini,day_end
-300 FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
+    day_end = day_ini - nday / day_step
+  ENDIF
+
+  WRITE(lunout, 300)day_ini, day_end
+  300 FORMAT('1'/, 15x, 'run du jour', i7, 2x, 'au jour', i7//)
 
   CALL ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
-  write (lunout,301)jour, mois, an
+  write (lunout, 301)jour, mois, an
   CALL ju2ymds(jD_ref + day_end - day_ref, an, mois, jour, heure)
-  write (lunout,302)jour, mois, an
-301 FORMAT('1'/,15x,'run du ', i2,'/',i2,'/',i4)
-302 FORMAT('1'/,15x,'    au ', i2,'/',i2,'/',i4)
+  write (lunout, 302)jour, mois, an
+  301 FORMAT('1'/, 15x, 'run du ', i2, '/', i2, '/', i4)
+  302 FORMAT('1'/, 15x, '    au ', i2, '/', i2, '/', i4)
 
   !-----------------------------------------------------------------------
@@ -395,15 +391,15 @@
   !      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
   !      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
-  istdyn=day_step/8     ! stockage toutes les 6h=1jour/12
-  istphy=istdyn/iphysiq
+  istdyn = day_step / 8     ! stockage toutes les 6h=1jour/12
+  istphy = istdyn / iphysiq
 
   IF ((iflag_phys==1).OR.(iflag_phys>=100)) THEN
-     ! Physics:
+    ! Physics:
     IF (CPPKEY_PHYS) THEN
-      CALL iniphysiq(iim,jjm,llm, &
-            distrib_phys(mpi_rank),comm_lmdz, &
-            daysec,day_ini,dtphys/nsplit_phys, &
-            rlatu,rlatv,rlonu,rlonv,aire,cu,cv,rad,g,r,cpp, &
-            iflag_phys)
+      CALL iniphysiq(iim, jjm, llm, &
+              distrib_phys(mpi_rank), comm_lmdz, &
+              daysec, day_ini, dtphys / nsplit_phys, &
+              rlatu, rlatv, rlonu, rlonv, aire, cu, cv, rad, g, r, cpp, &
+              iflag_phys)
     END IF
   ENDIF ! of IF ((iflag_phys==1).OR.(iflag_phys>=100))
@@ -418,25 +414,25 @@
 
   time_step = zdtvr
-     IF (ok_dyn_ins) THEN
-        ! initialize output file for instantaneous outputs
-        ! t_ops = iecri * daysec ! do operations every t_ops
-        t_ops =((1.0*iecri)/day_step) * daysec
-        t_wrt = daysec ! iecri * daysec ! write output every t_wrt
-        CALL inithist_loc(day_ref,annee_ref,time_step, &
-             t_ops,t_wrt)
-     endif
-
-     IF (ok_dyn_ave) THEN
-        ! initialize output file for averaged outputs
-        t_ops = iperiod * time_step ! do operations every t_ops
-        t_wrt = periodav * daysec   ! write output every t_wrt
-        CALL initdynav_loc(day_ref,annee_ref,time_step,t_ops,t_wrt)
-     END IF
-  dtav = iperiod*dtvr/daysec
-
-! setting up DYN3D/XIOS inerface
+  IF (ok_dyn_ins) THEN
+    ! initialize output file for instantaneous outputs
+    ! t_ops = iecri * daysec ! do operations every t_ops
+    t_ops = ((1.0 * iecri) / day_step) * daysec
+    t_wrt = daysec ! iecri * daysec ! write output every t_wrt
+    CALL inithist_loc(day_ref, annee_ref, time_step, &
+            t_ops, t_wrt)
+  endif
+
+  IF (ok_dyn_ave) THEN
+    ! initialize output file for averaged outputs
+    t_ops = iperiod * time_step ! do operations every t_ops
+    t_wrt = periodav * daysec   ! write output every t_wrt
+    CALL initdynav_loc(day_ref, annee_ref, time_step, t_ops, t_wrt)
+  END IF
+  dtav = iperiod * dtvr / daysec
+
+  ! setting up DYN3D/XIOS inerface
   IF (ok_dyn_xios) THEN
-      CALL xios_dyn3dmem_init(xios_cal_type, anref, moisref, jourref,heureref, an,   &
-          mois, jour, heure, zdtvr)
+    CALL xios_dyn3dmem_init(xios_cal_type, anref, moisref, jourref, heureref, an, &
+            mois, jour, heure, zdtvr)
   ENDIF
 
@@ -460,5 +456,5 @@
   !$OMP COPYIN(ok_strato,ok_gradsfile,ok_limit,ok_etat0) &
   !$OMP COPYIN(iflag_phys,iflag_trac,adv_qsat_liq)
-  CALL leapfrog_loc(ucov,vcov,teta,ps,masse,phis,q,time_0)
+  CALL leapfrog_loc(ucov, vcov, teta, ps, masse, phis, q, time_0)
   !$OMP END PARALLEL
 
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/lmdz_conf_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/lmdz_conf_gcm.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3dmem/lmdz_conf_gcm.f90	(revision 5186)
@@ -0,0 +1,1032 @@
+MODULE lmdz_conf_gcm
+  IMPLICIT NONE; PRIVATE
+  PUBLIC conf_gcm
+
+CONTAINS
+
+  SUBROUTINE conf_gcm(tapedef, etatinit)
+
+    USE control_mod
+    USE IOIPSL
+    USE misc_mod
+    USE lmdz_filtre_fft, ONLY: use_filtre_fft
+    USE lmdz_filtre_fft_loc, ONLY: use_filtre_fft_loc => use_filtre_fft
+    USE mod_hallo, ONLY: use_mpi_alloc
+    USE lmdz_infotrac, ONLY: type_trac
+    USE lmdz_assert, ONLY: assert
+    USE comconst_mod, ONLY: dissip_deltaz, dissip_factz, dissip_zref, &
+            iflag_top_bound, mode_top_bound, tau_top_bound, &
+            ngroup, maxlatfilter
+    USE logic_mod, ONLY: fxyhypb, iflag_phys, ok_etat0, ok_gradsfile, &
+            ok_guide, ok_limit, ok_strato, purmats, read_start, &
+            ysinus, read_orop, adv_qsat_liq
+    USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, &
+            alphax, alphay, taux, tauy
+    USE temps_mod, ONLY: calend, year_len, offline_time
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    USE lmdz_comdissnew, ONLY: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &
+            tetagrot, tetatemp, coefdis, vert_prof_dissip
+
+    USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+    USE lmdz_paramet
+    IMPLICIT NONE
+    !-----------------------------------------------------------------------
+    !     Auteurs :   L. Fairhead , P. Le Van  .
+
+    !     Arguments :
+
+    !     tapedef   :
+    !     etatinit  :     = TRUE   , on ne  compare pas les valeurs des para-
+    !     -metres  du zoom  avec  celles lues sur le fichier start .
+
+    LOGICAL, INTENT(IN) :: etatinit
+    INTEGER, INTENT(IN) :: tapedef
+
+    !   Declarations :
+    !   --------------
+
+
+
+    !   local:
+    !   ------
+
+    CHARACTER ch1*72, ch2*72, ch3*72, ch4*12
+    REAL clonn, clatt, grossismxx, grossismyy
+    REAL dzoomxx, dzoomyy, tauxx, tauyy
+    LOGICAL  fxyhypbb, ysinuss
+    INTEGER i
+    CHARACTER(len = *), PARAMETER :: modname = "conf_gcm"
+    CHARACTER(len = 80) :: abort_message
+#ifdef CPP_OMP
+  INTEGER, EXTERNAL :: OMP_GET_NUM_THREADS
+#endif
+
+    !  -------------------------------------------------------------------
+
+    !       .........     Version  du 29/04/97       ..........
+
+    !   Nouveaux parametres nitergdiv,nitergrot,niterh,tetagdiv,tetagrot,
+    !      tetatemp   ajoutes  pour la dissipation   .
+
+    !   Autre parametre ajoute en fin de liste de tapedef : ** fxyhypb **
+
+    !  Si fxyhypb = .TRUE. , choix de la fonction a derivee tangente hyperb.
+    !    Sinon , choix de fxynew  , a derivee sinusoidale  ..
+
+    !   ......  etatinit = . TRUE. si defrun  est appele dans ETAT0_LMD  ou
+    !         LIMIT_LMD  pour l'initialisation de start.dat (dic) et
+    !                de limit.dat ( dic)                        ...........
+    !           Sinon  etatinit = . FALSE .
+
+    !   Donc etatinit = .F.  si on veut comparer les valeurs de  grossismx ,
+    !    grossismy,clon,clat, fxyhypb  lues sur  le fichier  start  avec
+    !   celles passees  par run.def ,  au debut du gcm, apres l'appel a
+    !    lectba .
+    !   Ces parmetres definissant entre autres la grille et doivent etre
+    !   pareils et coherents , sinon il y aura  divergence du gcm .
+
+    !-----------------------------------------------------------------------
+    !   initialisations:
+    !   ----------------
+
+    !Config  Key  = lunout
+    !Config  Desc = unite de fichier pour les impressions
+    !Config  Def  = 6
+    !Config  Help = unite de fichier pour les impressions
+    !Config         (defaut sortie standard = 6)
+    lunout = 6
+    CALL getin('lunout', lunout)
+    IF (lunout /= 5 .AND. lunout /= 6) THEN
+      OPEN(UNIT = lunout, FILE = 'lmdz.out_0000', ACTION = 'write', &
+              STATUS = 'unknown', FORM = 'formatted')
+    ENDIF
+
+    adjust = .FALSE.
+    CALL getin('adjust', adjust)
+
+#ifdef CPP_OMP
+  ! adjust=y not implemented in case of OpenMP threads...
+  !$OMP PARALLEL
+  IF ((OMP_GET_NUM_THREADS()>1).AND.adjust) THEN
+     WRITE(lunout,*)'conf_gcm: Error, adjust should be set to n' &
+          ,' when running with OpenMP threads'
+     abort_message = 'Wrong value for adjust'
+     CALL abort_gcm(modname,abort_message,1)
+  ENDIF
+  !$OMP END PARALLEL         
+#endif
+
+    itaumax = 0
+    CALL getin('itaumax', itaumax);
+    IF (itaumax<=0) itaumax = HUGE(itaumax)
+
+    !Config  Key  = prt_level
+    !Config  Desc = niveau d'impressions de débogage
+    !Config  Def  = 0
+    !Config  Help = Niveau d'impression pour le débogage
+    !Config         (0 = minimum d'impression)
+    prt_level = 0
+    CALL getin('prt_level', prt_level)
+
+    !-----------------------------------------------------------------------
+    !  Parametres de controle du run:
+    !-----------------------------------------------------------------------
+    !Config  Key  = planet_type
+    !Config  Desc = planet type ("earth", "mars", "venus", ...)
+    !Config  Def  = earth
+    !Config  Help = this flag sets the type of atymosphere that is considered
+    planet_type = "earth"
+    CALL getin('planet_type', planet_type)
+
+    !Config  Key  = calend
+    !Config  Desc = type de calendrier utilise
+    !Config  Def  = earth_360d
+    !Config  Help = valeur possible: earth_360d, earth_365d, earth_366d
+    !Config
+    calend = 'earth_360d'
+    ! initialize year_len for aquaplanets and 1D
+    CALL getin('calend', calend)
+    IF (calend == 'earth_360d') THEN
+      year_len = 360
+    ELSE IF (calend == 'earth_365d') THEN
+      year_len = 365
+    ELSE IF (calend == 'earth_366d') THEN
+      year_len = 366
+    ELSE
+      year_len = 1
+    ENDIF
+
+    !Config  Key  = dayref
+    !Config  Desc = Jour de l'etat initial
+    !Config  Def  = 1
+    !Config  Help = Jour de l'etat initial ( = 350  si 20 Decembre ,
+    !Config         par expl. ,comme ici ) ... A completer
+    dayref = 1
+    CALL getin('dayref', dayref)
+
+    !Config  Key  = anneeref
+    !Config  Desc = Annee de l'etat initial
+    !Config  Def  = 1998
+    !Config  Help = Annee de l'etat  initial
+    !Config         (   avec  4  chiffres   ) ... A completer
+    anneeref = 1998
+    CALL getin('anneeref', anneeref)
+
+    !Config  Key  = raz_date
+    !Config  Desc = Remise a zero de la date initiale
+    !Config  Def  = 0 (pas de remise a zero)
+    !Config  Help = Remise a zero de la date initiale
+    !Config         0 pas de remise a zero, on garde la date du fichier restart
+    !Config         1 prise en compte de la date de gcm.def avec remise a zero
+    !Config         des compteurs de pas de temps
+    raz_date = 0
+    CALL getin('raz_date', raz_date)
+
+    !Config  Key  = resetvarc
+    !Config  Desc = Reinit des variables de controle
+    !Config  Def  = n
+    !Config  Help = Reinit des variables de controle
+    resetvarc = .FALSE.
+    CALL getin('resetvarc', resetvarc)
+
+    !Config  Key  = nday
+    !Config  Desc = Nombre de jours d'integration
+    !Config  Def  = 10
+    !Config  Help = Nombre de jours d'integration
+    !Config         ... On pourait aussi permettre des mois ou des annees !
+    nday = 10
+    CALL getin('nday', nday)
+
+    !Config  Key  = starttime
+    !Config  Desc = Heure de depart de la simulation
+    !Config  Def  = 0
+    !Config  Help = Heure de depart de la simulation
+    !Config         en jour
+    starttime = 0
+    CALL getin('starttime', starttime)
+
+    !Config  Key  = day_step
+    !Config  Desc = nombre de pas par jour
+    !Config  Def  = 240
+    !Config  Help = nombre de pas par jour (multiple de iperiod) (
+    !Config          ici pour  dt = 1 min )
+    day_step = 240
+    CALL getin('day_step', day_step)
+
+    !Config  Key  = nsplit_phys
+    nsplit_phys = 1
+    CALL getin('nsplit_phys', nsplit_phys)
+
+    !Config  Key  = iperiod
+    !Config  Desc = periode pour le pas Matsuno
+    !Config  Def  = 5
+    !Config  Help = periode pour le pas Matsuno (en pas de temps)
+    iperiod = 5
+    CALL getin('iperiod', iperiod)
+
+    !Config  Key  = iapp_tracvl
+    !Config  Desc = frequence du groupement des flux
+    !Config  Def  = iperiod
+    !Config  Help = frequence du groupement des flux (en pas de temps)
+    iapp_tracvl = iperiod
+    CALL getin('iapp_tracvl', iapp_tracvl)
+
+    !Config  Key  = iconser
+    !Config  Desc = periode de sortie des variables de controle
+    !Config  Def  = 240
+    !Config  Help = periode de sortie des variables de controle
+    !Config         (En pas de temps)
+    iconser = 240
+    CALL getin('iconser', iconser)
+
+    !Config  Key  = iecri
+    !Config  Desc = periode d'ecriture du fichier histoire
+    !Config  Def  = 1
+    !Config  Help = periode d'ecriture du fichier histoire (en jour)
+    iecri = 1
+    CALL getin('iecri', iecri)
+
+    !Config  Key  = periodav
+    !Config  Desc = periode de stockage fichier histmoy
+    !Config  Def  = 1
+    !Config  Help = periode de stockage fichier histmoy (en jour)
+    periodav = 1.
+    CALL getin('periodav', periodav)
+
+    !Config  Key  = output_grads_dyn
+    !Config  Desc = output dynamics diagnostics in 'dyn.dat' file
+    !Config  Def  = n
+    !Config  Help = output dynamics diagnostics in Grads-readable 'dyn.dat' file
+    output_grads_dyn = .FALSE.
+    CALL getin('output_grads_dyn', output_grads_dyn)
+
+    !Config  Key  = dissip_period
+    !Config  Desc = periode de la dissipation
+    !Config  Def  = 0
+    !Config  Help = periode de la dissipation
+    !Config  dissip_period=0 => la valeur sera calcule dans inidissip
+    !Config  dissip_period>0 => on prend cette valeur
+    dissip_period = 0
+    CALL getin('dissip_period', dissip_period)
+
+    !cc  ....   P. Le Van , modif le 29/04/97 .pour la dissipation  ...
+    !cc
+
+    !Config  Key  = lstardis
+    !Config  Desc = choix de l'operateur de dissipation
+    !Config  Def  = y
+    !Config  Help = choix de l'operateur de dissipation
+    !Config         'y' si on veut star et 'n' si on veut non-start !
+    !Config         Moi y en a pas comprendre !
+    lstardis = .TRUE.
+    CALL getin('lstardis', lstardis)
+
+    !Config  Key  = nitergdiv
+    !Config  Desc = Nombre d'iteration de gradiv
+    !Config  Def  = 1
+    !Config  Help = nombre d'iterations de l'operateur de dissipation
+    !Config         gradiv
+    nitergdiv = 1
+    CALL getin('nitergdiv', nitergdiv)
+
+    !Config  Key  = nitergrot
+    !Config  Desc = nombre d'iterations de nxgradrot
+    !Config  Def  = 2
+    !Config  Help = nombre d'iterations de l'operateur de dissipation
+    !Config         nxgradrot
+    nitergrot = 2
+    CALL getin('nitergrot', nitergrot)
+
+    !Config  Key  = niterh
+    !Config  Desc = nombre d'iterations de divgrad
+    !Config  Def  = 2
+    !Config  Help = nombre d'iterations de l'operateur de dissipation
+    !Config         divgrad
+    niterh = 2
+    CALL getin('niterh', niterh)
+
+    !Config  Key  = tetagdiv
+    !Config  Desc = temps de dissipation pour div
+    !Config  Def  = 7200
+    !Config  Help = temps de dissipation des plus petites longeur
+    !Config         d'ondes pour u,v (gradiv)
+    tetagdiv = 7200.
+    CALL getin('tetagdiv', tetagdiv)
+
+    !Config  Key  = tetagrot
+    !Config  Desc = temps de dissipation pour grad
+    !Config  Def  = 7200
+    !Config  Help = temps de dissipation des plus petites longeur
+    !Config         d'ondes pour u,v (nxgradrot)
+    tetagrot = 7200.
+    CALL getin('tetagrot', tetagrot)
+
+    !Config  Key  = tetatemp
+    !Config  Desc = temps de dissipation pour h
+    !Config  Def  = 7200
+    !Config  Help =  temps de dissipation des plus petites longeur
+    !Config         d'ondes pour h (divgrad)
+    tetatemp = 7200.
+    CALL getin('tetatemp', tetatemp)
+
+    ! Parametres controlant la variation sur la verticale des constantes de
+    ! dissipation.
+    ! Pour le moment actifs uniquement dans la version a 39 niveaux
+    ! avec ok_strato=y
+
+    dissip_factz = 4.
+    dissip_deltaz = 10.
+    dissip_zref = 30.
+    CALL getin('dissip_factz', dissip_factz)
+    CALL getin('dissip_deltaz', dissip_deltaz)
+    CALL getin('dissip_zref', dissip_zref)
+
+
+    !maxlatfilter
+    maxlatfilter = -1.0
+    CALL getin('maxlatfilter', maxlatfilter)
+    IF (maxlatfilter > 90) &
+            CALL abort_gcm("conf_gcm", 'maxlatfilter should be <=90', 1)
+
+
+    ! ngroup
+    ngroup = 3
+    CALL getin('ngroup', ngroup)
+    IF (mod(iim, 2**ngroup) /= 0) &
+            CALL abort_gcm("conf_gcm", 'iim must be multiple of 2**ngroup', 1)
+    IF (2**ngroup > jjm + 1) &
+            CALL abort_gcm("conf_gcm", '2**ngroup must be <= jjm + 1', 1)
+
+    ! mode_top_bound : fields towards which sponge relaxation will be done:
+    ! top_bound sponge: only active if ok_strato=.TRUE. and iflag_top_bound!=0
+    !                   iflag_top_bound=0 for no sponge
+    !                   iflag_top_bound=1 for sponge over 4 topmost layers
+    !                   iflag_top_bound=2 for sponge from top to ~1% of top layer pressure
+    iflag_top_bound = 1
+    CALL getin('iflag_top_bound', iflag_top_bound)
+    IF (iflag_top_bound < 0 .OR. iflag_top_bound > 2) &
+            CALL abort_gcm("conf_gcm", 'iflag_top_bound must be 0, 1 or 2', 1)
+
+    ! mode_top_bound : fields towards which sponge relaxation will be done:
+    !                  mode_top_bound=0: no relaxation
+    !                  mode_top_bound=1: u and v relax towards 0
+    !                  mode_top_bound=2: u and v relax towards their zonal mean
+    !                  mode_top_bound=3: u,v and pot. temp. relax towards their zonal mean
+    mode_top_bound = 3
+    CALL getin('mode_top_bound', mode_top_bound)
+
+    ! top_bound sponge : inverse of charactericstic relaxation time scale for sponge
+    tau_top_bound = 1.e-5
+    CALL getin('tau_top_bound', tau_top_bound)
+
+    !Config  Key  = coefdis
+    !Config  Desc = coefficient pour gamdissip
+    !Config  Def  = 0
+    !Config  Help = coefficient pour gamdissip
+    coefdis = 0.
+    CALL getin('coefdis', coefdis)
+
+    !Config  Key  = purmats
+    !Config  Desc = Schema d'integration
+    !Config  Def  = n
+    !Config  Help = Choix du schema d'integration temporel.
+    !Config         y = pure Matsuno sinon c'est du Matsuno-leapfrog
+    purmats = .FALSE.
+    CALL getin('purmats', purmats)
+
+    !Config  Key  = ok_guide
+    !Config  Desc = Guidage
+    !Config  Def  = n
+    !Config  Help = Guidage
+    ok_guide = .FALSE.
+    CALL getin('ok_guide', ok_guide)
+
+    IF (ok_guide .AND. adjust) CALL abort_gcm("conf_gcm", &
+            "adjust does not work with ok_guide", 1)
+
+    !Config  Key  =  read_start
+    !Config  Desc = Initialize model using a 'start.nc' file
+    !Config  Def  = y
+    !Config  Help = y: intialize dynamical fields using a 'start.nc' file
+    !               n: fields are initialized by 'iniacademic' routine
+    read_start = .TRUE.
+    CALL getin('read_start', read_start)
+
+    !Config  Key  = iflag_phys
+    !Config  Desc = Avec ls physique
+    !Config  Def  = 1
+    !Config  Help = Permet de faire tourner le modele sans
+    !Config         physique.
+    iflag_phys = 1
+    CALL getin('iflag_phys', iflag_phys)
+
+    !Config  Key  =  iphysiq
+    !Config  Desc = Periode de la physique
+    !Config  Def  = 5
+    !Config  Help = Periode de la physique en pas de temps de la dynamique.
+    iphysiq = 5
+    CALL getin('iphysiq', iphysiq)
+
+    !Config  Key  = ip_ebil_dyn
+    !Config  Desc = PRINT level for energy conserv. diag.
+    !Config  Def  = 0
+    !Config  Help = PRINT level for energy conservation diag. ;
+    !               les options suivantes existent :
+    !Config         0 pas de print
+    !Config         1 pas de print
+    !Config         2 print,
+    ip_ebil_dyn = 0
+    CALL getin('ip_ebil_dyn', ip_ebil_dyn)
+
+    !cc  ....   P. Le Van , ajout  le 7/03/95 .pour le zoom ...
+    !     .........   (  modif  le 17/04/96 )   .........
+
+    test_etatinit: IF (.NOT. etatinit) THEN
+      !Config  Key  = clon
+      !Config  Desc = centre du zoom, longitude
+      !Config  Def  = 0
+      !Config  Help = longitude en degres du centre
+      !Config         du zoom
+      clonn = 0.
+      CALL getin('clon', clonn)
+
+      !Config  Key  = clat
+      !Config  Desc = centre du zoom, latitude
+      !Config  Def  = 0
+      !Config  Help = latitude en degres du centre du zoom
+      !Config
+      clatt = 0.
+      CALL getin('clat', clatt)
+
+      IF(ABS(clat - clatt)>= 0.001)  THEN
+        WRITE(lunout, *)'conf_gcm: La valeur de clat passee par run.def', &
+                ' est differente de celle lue sur le fichier  start '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ENDIF
+
+      !Config  Key  = grossismx
+      !Config  Desc = zoom en longitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la longitude
+      grossismxx = 1.0
+      CALL getin('grossismx', grossismxx)
+
+      IF(ABS(grossismx - grossismxx)>= 0.001)  THEN
+        WRITE(lunout, *)'conf_gcm: La valeur de grossismx passee par ', &
+                'run.def est differente de celle lue sur le fichier  start '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ENDIF
+
+      !Config  Key  = grossismy
+      !Config  Desc = zoom en latitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la latitude
+      grossismyy = 1.0
+      CALL getin('grossismy', grossismyy)
+
+      IF(ABS(grossismy - grossismyy)>= 0.001)  THEN
+        WRITE(lunout, *)'conf_gcm: La valeur de grossismy passee par ', &
+                'run.def est differente de celle lue sur le fichier  start '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ENDIF
+
+      IF(grossismx<1.)  THEN
+        WRITE(lunout, *) &
+                'conf_gcm: ***  ATTENTION !! grossismx < 1 .   *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphax = 1. - 1. / grossismx
+      ENDIF
+
+      IF(grossismy<1.)  THEN
+        WRITE(lunout, *) &
+                'conf_gcm: ***  ATTENTION !! grossismy < 1 .   *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphay = 1. - 1. / grossismy
+      ENDIF
+
+      WRITE(lunout, *)'conf_gcm: alphax alphay', alphax, alphay
+
+      !    alphax et alphay sont les anciennes formulat. des grossissements
+
+      !Config  Key  = fxyhypb
+      !Config  Desc = Fonction  hyperbolique
+      !Config  Def  = y
+      !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
+      !Config         sinon  sinusoidale
+      fxyhypbb = .TRUE.
+      CALL getin('fxyhypb', fxyhypbb)
+
+      IF(.NOT.fxyhypb)  THEN
+        IF(fxyhypbb)     THEN
+          WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+          WRITE(lunout, *)' *** fxyhypb lu sur le fichier start est ', &
+                  'F alors  qu il est  T  sur  run.def  ***'
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ELSE
+        IF(.NOT.fxyhypbb)   THEN
+          WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+          WRITE(lunout, *)' ***  fxyhypb lu sur le fichier start est ', &
+                  'T alors  qu il est  F  sur  run.def  ****  '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = dzoomx
+      !Config  Desc = extension en longitude
+      !Config  Def  = 0
+      !Config  Help = extension en longitude  de la zone du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomxx = 0.0
+      CALL getin('dzoomx', dzoomxx)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(dzoomx - dzoomxx)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de dzoomx passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = dzoomy
+      !Config  Desc = extension en latitude
+      !Config  Def  = 0
+      !Config  Help = extension en latitude de la zone  du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomyy = 0.0
+      CALL getin('dzoomy', dzoomyy)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(dzoomy - dzoomyy)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de dzoomy passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = taux
+      !Config  Desc = raideur du zoom en  X
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  X
+      tauxx = 3.0
+      CALL getin('taux', tauxx)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(taux - tauxx)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de taux passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !Config  Key  = tauyy
+      !Config  Desc = raideur du zoom en  Y
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  Y
+      tauyy = 3.0
+      CALL getin('tauy', tauyy)
+
+      IF(fxyhypb)  THEN
+        IF(ABS(tauy - tauyy)>= 0.001)  THEN
+          WRITE(lunout, *)'conf_gcm: La valeur de tauy passee par ', &
+                  'run.def est differente de celle lue sur le fichier  start '
+          CALL abort_gcm("conf_gcm", "stopped", 1)
+        ENDIF
+      ENDIF
+
+      !c
+      IF(.NOT.fxyhypb)  THEN
+
+        !Config  Key  = ysinus
+        !Config  IF   = !fxyhypb
+        !Config  Desc = Fonction en Sinus
+        !Config  Def  = y
+        !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
+        !Config         sinon y = latit.
+        ysinuss = .TRUE.
+        CALL getin('ysinus', ysinuss)
+
+        IF(.NOT.ysinus)  THEN
+          IF(ysinuss)     THEN
+            WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+            WRITE(lunout, *)' *** ysinus lu sur le fichier start est F', &
+                    ' alors  qu il est  T  sur  run.def  ***'
+            CALL abort_gcm("conf_gcm", "stopped", 1)
+          ENDIF
+        ELSE
+          IF(.NOT.ysinuss)   THEN
+            WRITE(lunout, *)' ********  PBS DANS  CONF_GCM  ******** '
+            WRITE(lunout, *)' *** ysinus lu sur le fichier start est T', &
+                    ' alors  qu il est  F  sur  run.def  ****  '
+            CALL abort_gcm("conf_gcm", "stopped", 1)
+          ENDIF
+        ENDIF
+      ENDIF ! of IF( .NOT.fxyhypb  )
+
+      !Config  Key  = offline
+      !Config  Desc = ecriture des flux de masse
+      !Config  Def  = n
+      !Config  Help = Permet de sortir les flux de masse sur la grille plev
+      offline = .FALSE.
+      CALL getin('offline', offline)
+
+      !Config Key  = offline_time
+      !Config Desc =  Choix des frequences de stockage pour le offline
+      !Config Def  = 8
+      !Config Help = offline_time=12     ! stockage toutes les 2h=1jour/12
+      !Config Help = offline_time=8      ! stockage toutes les 3h=1jour/8
+      offline_time = 8
+      CALL getin('offline_time', offline_time)
+
+      IF (offline .AND. adjust) THEN
+        WRITE(lunout, *)  &
+                'WARNING : option offline does not work with adjust=y :'
+        WRITE(lunout, *) 'the files defstoke.nc, fluxstoke.nc ', &
+                'and fluxstokev.nc will not be created'
+        WRITE(lunout, *)  &
+                'only the file phystoke.nc will still be created '
+      ENDIF
+
+      !Config  Key  = type_trac
+      !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
+      !Config  Def  = lmdz
+      !Config  Help =
+      !Config         'lmdz' = pas de couplage, pur LMDZ
+      !Config         'inca' = model de chime INCA
+      !Config         'repr' = model de chime REPROBUS
+      type_trac = 'lmdz'
+      CALL getin('type_trac', type_trac)
+
+
+      !Config  Key  = adv_qsat_liq
+      !Config  Desc = option for qsat calculation in the dynamics
+      !Config  Def  = n
+      !Config  Help = controls which phase is considered for qsat calculation
+      !Config
+      adv_qsat_liq = .FALSE.
+      CALL getin('adv_qsat_liq', adv_qsat_liq)
+
+      !Config  Key  = ok_dynzon
+      !Config  Desc = calcul et sortie des transports
+      !Config  Def  = n
+      !Config  Help = Permet de mettre en route le calcul des transports
+      !Config
+      ok_dynzon = .FALSE.
+      CALL getin('ok_dynzon', ok_dynzon)
+
+      !Config  Key  = ok_dyn_ins
+      !Config  Desc = sorties instantanees dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ins = .FALSE.
+      CALL getin('ok_dyn_ins', ok_dyn_ins)
+
+      !Config  Key  = ok_dyn_ave
+      !Config  Desc = sorties moyennes dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ave = .FALSE.
+      CALL getin('ok_dyn_ave', ok_dyn_ave)
+
+      !Config  Key  = ok_dyn_xios
+      !Config  Desc = sorties moyennes dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_xios = .FALSE.
+      CALL getin('ok_dyn_xios', ok_dyn_xios)
+
+      WRITE(lunout, *)' #########################################'
+      WRITE(lunout, *)' Configuration des parametres du gcm: '
+      WRITE(lunout, *)' planet_type = ', planet_type
+      WRITE(lunout, *)' calend = ', calend
+      WRITE(lunout, *)' dayref = ', dayref
+      WRITE(lunout, *)' anneeref = ', anneeref
+      WRITE(lunout, *)' nday = ', nday
+      WRITE(lunout, *)' day_step = ', day_step
+      WRITE(lunout, *)' iperiod = ', iperiod
+      WRITE(lunout, *)' nsplit_phys = ', nsplit_phys
+      WRITE(lunout, *)' iconser = ', iconser
+      WRITE(lunout, *)' iecri = ', iecri
+      WRITE(lunout, *)' periodav = ', periodav
+      WRITE(lunout, *)' output_grads_dyn = ', output_grads_dyn
+      WRITE(lunout, *)' dissip_period = ', dissip_period
+      WRITE(lunout, *)' lstardis = ', lstardis
+      WRITE(lunout, *)' nitergdiv = ', nitergdiv
+      WRITE(lunout, *)' nitergrot = ', nitergrot
+      WRITE(lunout, *)' niterh = ', niterh
+      WRITE(lunout, *)' tetagdiv = ', tetagdiv
+      WRITE(lunout, *)' tetagrot = ', tetagrot
+      WRITE(lunout, *)' tetatemp = ', tetatemp
+      WRITE(lunout, *)' coefdis = ', coefdis
+      WRITE(lunout, *)' purmats = ', purmats
+      WRITE(lunout, *)' read_start = ', read_start
+      WRITE(lunout, *)' iflag_phys = ', iflag_phys
+      WRITE(lunout, *)' iphysiq = ', iphysiq
+      WRITE(lunout, *)' clonn = ', clonn
+      WRITE(lunout, *)' clatt = ', clatt
+      WRITE(lunout, *)' grossismx = ', grossismx
+      WRITE(lunout, *)' grossismy = ', grossismy
+      WRITE(lunout, *)' fxyhypbb = ', fxyhypbb
+      WRITE(lunout, *)' dzoomxx = ', dzoomxx
+      WRITE(lunout, *)' dzoomy = ', dzoomyy
+      WRITE(lunout, *)' tauxx = ', tauxx
+      WRITE(lunout, *)' tauyy = ', tauyy
+      WRITE(lunout, *)' offline = ', offline
+      WRITE(lunout, *)' offline_time = ', offline_time
+      WRITE(lunout, *)' type_trac = ', type_trac
+      WRITE(lunout, *)' ok_dynzon = ', ok_dynzon
+      WRITE(lunout, *)' ok_dyn_ins = ', ok_dyn_ins
+      WRITE(lunout, *)' ok_dyn_ave = ', ok_dyn_ave
+      WRITE(lunout, *)' ok_dyn_xios = ', ok_dyn_xios
+      WRITE(lunout, *)' adv_qsat_liq = ', adv_qsat_liq
+    else
+      !Config  Key  = clon
+      !Config  Desc = centre du zoom, longitude
+      !Config  Def  = 0
+      !Config  Help = longitude en degres du centre
+      !Config         du zoom
+      clon = 0.
+      CALL getin('clon', clon)
+
+      !Config  Key  = clat
+      !Config  Desc = centre du zoom, latitude
+      !Config  Def  = 0
+      !Config  Help = latitude en degres du centre du zoom
+      !Config
+      clat = 0.
+      CALL getin('clat', clat)
+
+      !Config  Key  = grossismx
+      !Config  Desc = zoom en longitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la longitude
+      grossismx = 1.0
+      CALL getin('grossismx', grossismx)
+
+      !Config  Key  = grossismy
+      !Config  Desc = zoom en latitude
+      !Config  Def  = 1.0
+      !Config  Help = facteur de grossissement du zoom,
+      !Config         selon la latitude
+      grossismy = 1.0
+      CALL getin('grossismy', grossismy)
+
+      IF(grossismx<1.)  THEN
+        WRITE(lunout, *) 'conf_gcm: ***ATTENTION !! grossismx < 1 . *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphax = 1. - 1. / grossismx
+      ENDIF
+
+      IF(grossismy<1.)  THEN
+        WRITE(lunout, *) 'conf_gcm: ***ATTENTION !! grossismy < 1 . *** '
+        CALL abort_gcm("conf_gcm", "stopped", 1)
+      ELSE
+        alphay = 1. - 1. / grossismy
+      ENDIF
+
+      WRITE(lunout, *) 'conf_gcm: alphax alphay ', alphax, alphay
+
+      !    alphax et alphay sont les anciennes formulat. des grossissements
+
+      !Config  Key  = fxyhypb
+      !Config  Desc = Fonction  hyperbolique
+      !Config  Def  = y
+      !Config  Help = Fonction  f(y)  hyperbolique  si = .TRUE.
+      !Config         sinon  sinusoidale
+      fxyhypb = .TRUE.
+      CALL getin('fxyhypb', fxyhypb)
+
+      !Config  Key  = dzoomx
+      !Config  Desc = extension en longitude
+      !Config  Def  = 0
+      !Config  Help = extension en longitude  de la zone du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomx = 0.2
+      CALL getin('dzoomx', dzoomx)
+      CALL assert(dzoomx < 1, "conf_gcm: dzoomx must be < 1")
+
+      !Config  Key  = dzoomy
+      !Config  Desc = extension en latitude
+      !Config  Def  = 0
+      !Config  Help = extension en latitude de la zone  du zoom
+      !Config         ( fraction de la zone totale)
+      dzoomy = 0.2
+      CALL getin('dzoomy', dzoomy)
+      CALL assert(dzoomy < 1, "conf_gcm: dzoomy must be < 1")
+
+      !Config  Key  = taux
+      !Config  Desc = raideur du zoom en  X
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  X
+      taux = 3.0
+      CALL getin('taux', taux)
+
+      !Config  Key  = tauy
+      !Config  Desc = raideur du zoom en  Y
+      !Config  Def  = 3
+      !Config  Help = raideur du zoom en  Y
+      tauy = 3.0
+      CALL getin('tauy', tauy)
+
+      !Config  Key  = ysinus
+      !Config  IF   = !fxyhypb
+      !Config  Desc = Fonction en Sinus
+      !Config  Def  = y
+      !Config  Help = Fonction  f(y) avec y = Sin(latit.) si = .TRUE.
+      !Config         sinon y = latit.
+      ysinus = .TRUE.
+      CALL getin('ysinus', ysinus)
+
+      !Config  Key  = offline
+      !Config  Desc = Nouvelle eau liquide
+      !Config  Def  = n
+      !Config  Help = Permet de mettre en route la
+      !Config         nouvelle parametrisation de l'eau liquide !
+      offline = .FALSE.
+      CALL getin('offline', offline)
+      IF (offline .AND. adjust) THEN
+        WRITE(lunout, *)  &
+                'WARNING : option offline does not work with adjust=y :'
+        WRITE(lunout, *) 'the files defstoke.nc, fluxstoke.nc ', &
+                'and fluxstokev.nc will not be created'
+        WRITE(lunout, *)  &
+                'only the file phystoke.nc will still be created '
+      ENDIF
+
+      !Config  Key  = type_trac
+      !Config  Desc = Choix de couplage avec model de chimie INCA ou REPROBUS
+      !Config  Def  = lmdz
+      !Config  Help =
+      !Config         'lmdz' = pas de couplage, pur LMDZ
+      !Config         'inca' = model de chime INCA
+      !Config         'repr' = model de chime REPROBUS
+      type_trac = 'lmdz'
+      CALL getin('type_trac', type_trac)
+
+      !Config  Key  = ok_dynzon
+      !Config  Desc = sortie des transports zonaux dans la dynamique
+      !Config  Def  = n
+      !Config  Help = Permet de mettre en route le calcul des transports
+      !Config
+      ok_dynzon = .FALSE.
+      CALL getin('ok_dynzon', ok_dynzon)
+
+      !Config  Key  = ok_dyn_ins
+      !Config  Desc = sorties instantanees dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ins = .FALSE.
+      CALL getin('ok_dyn_ins', ok_dyn_ins)
+
+      !Config  Key  = ok_dyn_ave
+      !Config  Desc = sorties moyennes dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_ave = .FALSE.
+      CALL getin('ok_dyn_ave', ok_dyn_ave)
+
+      !Config  Key  = ok_dyn_xios
+      !Config  Desc = sorties moyennes dans la dynamique
+      !Config  Def  = n
+      !Config  Help =
+      !Config
+      ok_dyn_xios = .FALSE.
+      CALL getin('ok_dyn_xios', ok_dyn_xios)
+
+      !Config  Key  = use_filtre_fft
+      !Config  Desc = flag to activate FFTs for the filter
+      !Config  Def  = false
+      !Config  Help = enables to use FFts to do the longitudinal polar
+      !Config         filtering around the poles.
+      use_filtre_fft = .FALSE.
+      CALL getin('use_filtre_fft', use_filtre_fft)
+      IF (use_filtre_fft .AND. grossismx /= 1.0) THEN
+        WRITE(lunout, *)'WARNING !!! '
+        WRITE(lunout, *)"A zoom in longitude is not compatible", &
+                " with the FFT filter ", &
+                "---> FFT filter deactivated"
+        use_filtre_fft = .FALSE.
+      ENDIF
+      use_filtre_fft_loc = use_filtre_fft
+
+      !Config  Key  = use_mpi_alloc
+      !Config  Desc = Utilise un buffer MPI en mémoire globale
+      !Config  Def  = false
+      !Config  Help = permet d'activer l'utilisation d'un buffer MPI
+      !Config         en mémoire globale a l'aide de la fonction MPI_ALLOC.
+      !Config         Cela peut améliorer la bande passante des transferts MPI
+      !Config         d'un facteur 2
+      use_mpi_alloc = .FALSE.
+      CALL getin('use_mpi_alloc', use_mpi_alloc)
+
+      !Config key = ok_strato
+      !Config  Desc = activation de la version strato
+      !Config  Def  = .FALSE.
+      !Config  Help = active la version stratosphérique de LMDZ de F. Lott
+
+      ok_strato = .FALSE.
+      CALL getin('ok_strato', ok_strato)
+
+      vert_prof_dissip = merge(1, 0, ok_strato .AND. llm==39)
+      CALL getin('vert_prof_dissip', vert_prof_dissip)
+      CALL assert(vert_prof_dissip == 0 .OR. vert_prof_dissip ==  1, &
+              "bad value for vert_prof_dissip")
+
+      !Config  Key  = ok_gradsfile
+      !Config  Desc = activation des sorties grads du guidage
+      !Config  Def  = n
+      !Config  Help = active les sorties grads du guidage
+
+      ok_gradsfile = .FALSE.
+      CALL getin('ok_gradsfile', ok_gradsfile)
+
+      !Config  Key  = ok_limit
+      !Config  Desc = creation des fichiers limit dans create_etat0_limit
+      !Config  Def  = y
+      !Config  Help = production du fichier limit.nc requise
+
+      ok_limit = .TRUE.
+      CALL getin('ok_limit', ok_limit)
+
+      !Config  Key  = ok_etat0
+      !Config  Desc = creation des fichiers etat0 dans create_etat0_limit
+      !Config  Def  = y
+      !Config  Help = production des fichiers start.nc, startphy.nc requise
+
+      ok_etat0 = .TRUE.
+      CALL getin('ok_etat0', ok_etat0)
+
+      !Config  Key  = read_orop
+      !Config  Desc = lecture du fichier de params orographiques sous maille
+      !Config  Def  = f
+      !Config  Help = lecture fichier plutot que grid_noro
+
+      read_orop = .FALSE.
+      CALL getin('read_orop', read_orop)
+
+      WRITE(lunout, *)' #########################################'
+      WRITE(lunout, *)' Configuration des parametres de cel0_limit: '
+      WRITE(lunout, *)' planet_type = ', planet_type
+      WRITE(lunout, *)' calend = ', calend
+      WRITE(lunout, *)' dayref = ', dayref
+      WRITE(lunout, *)' anneeref = ', anneeref
+      WRITE(lunout, *)' nday = ', nday
+      WRITE(lunout, *)' day_step = ', day_step
+      WRITE(lunout, *)' iperiod = ', iperiod
+      WRITE(lunout, *)' iconser = ', iconser
+      WRITE(lunout, *)' iecri = ', iecri
+      WRITE(lunout, *)' periodav = ', periodav
+      WRITE(lunout, *)' output_grads_dyn = ', output_grads_dyn
+      WRITE(lunout, *)' dissip_period = ', dissip_period
+      WRITE(lunout, *)' lstardis = ', lstardis
+      WRITE(lunout, *)' nitergdiv = ', nitergdiv
+      WRITE(lunout, *)' nitergrot = ', nitergrot
+      WRITE(lunout, *)' niterh = ', niterh
+      WRITE(lunout, *)' tetagdiv = ', tetagdiv
+      WRITE(lunout, *)' tetagrot = ', tetagrot
+      WRITE(lunout, *)' tetatemp = ', tetatemp
+      WRITE(lunout, *)' coefdis = ', coefdis
+      WRITE(lunout, *)' purmats = ', purmats
+      WRITE(lunout, *)' read_start = ', read_start
+      WRITE(lunout, *)' iflag_phys = ', iflag_phys
+      WRITE(lunout, *)' iphysiq = ', iphysiq
+      WRITE(lunout, *)' clon = ', clon
+      WRITE(lunout, *)' clat = ', clat
+      WRITE(lunout, *)' grossismx = ', grossismx
+      WRITE(lunout, *)' grossismy = ', grossismy
+      WRITE(lunout, *)' fxyhypb = ', fxyhypb
+      WRITE(lunout, *)' dzoomx = ', dzoomx
+      WRITE(lunout, *)' dzoomy = ', dzoomy
+      WRITE(lunout, *)' taux = ', taux
+      WRITE(lunout, *)' tauy = ', tauy
+      WRITE(lunout, *)' offline = ', offline
+      WRITE(lunout, *)' type_trac = ', type_trac
+      WRITE(lunout, *)' ok_dynzon = ', ok_dynzon
+      WRITE(lunout, *)' ok_dyn_ins = ', ok_dyn_ins
+      WRITE(lunout, *)' ok_dyn_ave = ', ok_dyn_ave
+      WRITE(lunout, *)' ok_dyn_xios = ', ok_dyn_xios
+      WRITE(lunout, *)' use_filtre_fft = ', use_filtre_fft
+      WRITE(lunout, *)' use_mpi_alloc = ', use_mpi_alloc
+      WRITE(lunout, *)' ok_strato = ', ok_strato
+      WRITE(lunout, *)' ok_gradsfile = ', ok_gradsfile
+      WRITE(lunout, *)' ok_limit = ', ok_limit
+      WRITE(lunout, *)' ok_etat0 = ', ok_etat0
+      WRITE(lunout, *)' ok_guide = ', ok_guide
+      WRITE(lunout, *)' read_orop = ', read_orop
+    ENDIF test_etatinit
+
+  END SUBROUTINE conf_gcm
+
+
+END MODULE lmdz_conf_gcm
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/ce0l.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/ce0l.F90	(revision 5186)
@@ -50,10 +50,10 @@
   USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
   USE lmdz_paramet
+  USE lmdz_conf_gcm, ONLY: conf_gcm
+
   IMPLICIT NONE
 
   !-------------------------------------------------------------------------------
   ! Local variables:
-
-
 
   REAL :: masque(iip1, jjp1)             !--- CONTINENTAL MASK
Index: /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/dynphy_lonlat/phylmd/etat0dyn_netcdf.F90	(revision 5186)
@@ -82,4 +82,7 @@
     USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA
     USE lmdz_q_sat, ONLY: q_sat
+#ifndef CPP_PARA
+    USE lmdz_dynredem, ONLY: dynredem0, dynredem1
+#endif
     IMPLICIT NONE
     !-------------------------------------------------------------------------------
Index: /LMDZ6/branches/Amaury_dev/libf/obsolete/ini_paramLMDZ_dyn.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/obsolete/ini_paramLMDZ_dyn.h	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/obsolete/ini_paramLMDZ_dyn.h	(revision 5186)
@@ -0,0 +1,214 @@
+c
+      dt_cum = dtvr*day_step
+
+!      zan = annee_ref
+!      dayref = day_ref
+!      CALL ymds2ju(zan, 1, dayref, 0.0, zjulian)
+      tau0 = itau_dyn
+c
+       pi = 4.0 * ATAN(1.0)
+       degres = 180./pi
+       rlong = rlonu * degres
+       rlatg = rlatu * degres
+c
+      CALL histbeg("paramLMDZ_dyn.nc", 
+     .                 iip1,rlong, jjp1,rlatg,
+     .                 1,1,1,1,
+     .                 tau0, jD_ref+jH_ref , dt_cum,
+     .                 thoriid, nid_ctesGCM)
+c
+         CALL histdef(nid_ctesGCM, "prt_level", 
+     .        "Niveau impression debuggage dynamique",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "dayref", 
+     .        "Jour de l etat initial ( = 350  si 20 Decembre par ex.)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "anneeref", 
+     .        "Annee de l etat initial",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "anneelim", 
+     .        "Annee du fichier limitxxxx.nc  si  ok_limitvrai =y",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "raz_date", 
+     .   "Remise a zero (raz) date init.: 0 pas de raz;1=date gcm.def",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "nday", 
+     .   "Nombre de jours d integration",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "day_step", 
+     .   "nombre de pas par jour pour dt = 1 min",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "iperiod", 
+     .   "periode pour le pas Matsuno (en pas de temps)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "iapp_tracvl", 
+     .   "frequence du groupement des flux (en pas de temps)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "iconser", 
+     .  "periode de sortie des variables de controle (en pas de temps)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "iecri", 
+     .  "periode d ecriture du fichier histoire (en jour)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "periodav", 
+     .  "periode de stockage fichier histmoy (en jour)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "dissip_period", 
+     .  "periode de la dissipation (en pas) ... a completer",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "lstardis", 
+     .  "choix de l operateur de dissipation: 1= star,0=non-star ??",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "nitergdiv", 
+     .  "nombre d iterations de l operateur de dissipation gradiv",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "nitergrot", 
+     .  "nombre d iterations de l operateur de dissipation nxgradrot",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "niterh", 
+     .  "nombre d iterations de l operateur de dissipation divgrad",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "tetagdiv", 
+     ."temps dissipation des + petites long. d ondes pour u,v (gradiv)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "tetagrot", 
+     ."temps diss. des + petites long. d ondes pour u,v (nxgradrot)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "tetatemp", 
+     ."temps diss. des + petites long. d ondes pour h (divgrad)",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "coefdis", 
+     ."coefficient pour gamdissip",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "purmats", 
+     ."Choix schema integration temporel: 1=Matsuno,0=Matsuno-leapfrog",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "ok_guide", 
+     ."Guidage: 1=true ,0=false",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "true_calendar", 
+     ."Choix du calendrier",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "guide_calend", 
+     ."Guidage calendrier gregorien: 1=oui ,0=non",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "iflag_phys", 
+     ."Permet de faire tourner le modele sans physique: 1=avec ,0=sans",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "iphysiq", 
+     ."Periode de la physique en pas de temps de la dynamique",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "clon", 
+     ."longitude en degres du centre du zoom",
+     .                "deg",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "clat", 
+     ."latitude en degres du centre du zoom",
+     .                "deg",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "grossismx", 
+     ."facteur de grossissement du zoom, selon la longitude",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "grossismy", 
+     ."facteur de grossissement du zoom, selon la latitude",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "fxyhypb", 
+     ."Fonction f(y) hyperbolique  si true=1, sinusoidale si false=0",
+     .                "-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "dzoomx", 
+     ."extension en longitude de la zone du zoom (fraction zone totale)"
+     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "dzoomy", 
+     ."extension en latitude de la zone du zoom (fraction zone totale)"
+     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "taux", 
+     ."raideur du zoom en  X"
+     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "tauy", 
+     ."raideur du zoom en  Y"
+     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "ysinus", 
+     ."ysinus=1: Ftion f(y) avec y=Sin(latit.)/ ysinus=0: y = latit"
+     .                ,"-",iip1,jjp1,thoriid, 1,1,1, -99, 32, 
+     .                "once", dt_cum,dt_cum)
+c
+         CALL histdef(nid_ctesGCM, "ip_ebil_dyn", 
+     ."PRINTlevel for energy conservation diag.; 0/1= pas de print,
+     . 2= print","-",iip1,jjp1,thoriid, 1,1,1, -99, 32,
+     .                "once", dt_cum,dt_cum)
+c
+c=================================================================
+c
+         CALL histend(nid_ctesGCM)
+c
+c=================================================================
Index: DZ6/branches/Amaury_dev/libf/phylmd/dyn1d/conf_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/conf_gcm.f90	(revision 5185)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../dyn3d/conf_gcm.f90
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_conf_gcm.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_conf_gcm.f90	(revision 5186)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_conf_gcm.f90	(revision 5186)
@@ -0,0 +1,1 @@
+link ../../dyn3d/lmdz_conf_gcm.f90
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_lmdz1d.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_lmdz1d.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_old_lmdz1d.F90	(revision 5186)
@@ -61,4 +61,6 @@
 
 USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
+      USE lmdz_conf_gcm, ONLY: conf_gcm
+
     IMPLICIT NONE
 
Index: /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_scm.F90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_scm.F90	(revision 5185)
+++ /LMDZ6/branches/Amaury_dev/libf/phylmd/dyn1d/lmdz_scm.F90	(revision 5186)
@@ -53,4 +53,5 @@
     USE lmdz_compar1d
     USE lmdz_date_cas, ONLY: year_ini_cas, mth_ini_cas, day_deb, heure_ini_cas, pdt_cas, day_ju_ini_cas
+  USE lmdz_conf_gcm, ONLY: conf_gcm
 
 
