Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/addfi.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/addfi.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/addfi.F	(revision 1446)
@@ -1,4 +1,4 @@
 !
-! $Header$
+! $Id$
 !
       SUBROUTINE addfi(pdt, leapf, forward,
@@ -7,4 +7,5 @@
 
       USE infotrac, ONLY : nqtot
+      USE control_mod, ONLY : planet_type
       IMPLICIT NONE
 c
@@ -116,5 +117,7 @@
       ENDDO
  
-      DO iq = 1, 2
+      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
@@ -123,7 +126,7 @@
             ENDDO
          ENDDO
-      ENDDO
+       ENDDO
 
-      DO iq = 3, nqtot
+       DO iq = 3, nqtot
          DO k = 1,llm
             DO j = 1,ip1jmp1
@@ -132,5 +135,16 @@
             ENDDO
          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")
 
 
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/advtrac.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/advtrac.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/advtrac.F	(revision 1446)
@@ -236,5 +236,4 @@
             call vlsplt(q(1,1,iq),2.,massem,wg,pbarug,pbarvg,dtvr)
 
-
 c   ----------------------------------------------------------------
 c   Schema "pseudo amont" + test sur humidite specifique
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/caladvtrac.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/caladvtrac.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/caladvtrac.F	(revision 1446)
@@ -8,6 +8,6 @@
      *                   flxw, pk)
 c
-      USE infotrac
-      USE control_mod
+      USE infotrac, ONLY : nqtot
+      USE control_mod, ONLY : iapp_tracvl,planet_type
  
       IMPLICIT NONE
@@ -30,5 +30,6 @@
 c   ----------
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm),masse(ip1jmp1,llm)
-      REAL p( ip1jmp1,llmp1),q( ip1jmp1,llm,nqtot),dq( ip1jmp1,llm,2 )
+      REAL p( ip1jmp1,llmp1),q( ip1jmp1,llm,nqtot)
+      real :: dq(ip1jmp1,llm,nqtot)
       REAL teta( ip1jmp1,llm),pk( ip1jmp1,llm)
       REAL               :: flxw(ip1jmp1,llm)
@@ -49,13 +50,13 @@
 cc
 c
+! Earth-specific stuff for the first 2 tracers (water)
+      if (planet_type.eq."earth") then
 C initialisation
-        dq = 0.
-
-        CALL SCOPY( 2 * ijp1llm, q, 1, dq, 1 )
-
+        dq(:,:,1:2)=q(:,:,1:2)
+       
 c  test des valeurs minmax
 cc        CALL minmaxq(q(1,1,1),1.e33,-1.e33,'Eau vapeur (a) ')
 cc        CALL minmaxq(q(1,1,2),1.e33,-1.e33,'Eau liquide(a) ')
-
+      endif ! of if (planet_type.eq."earth")
 c   advection
 
@@ -63,7 +64,10 @@
      *       p,  masse,q,iapptrac, teta,
      .       flxw, pk)
+
 c
 
-         IF( iapptrac.EQ.iapp_tracvl ) THEN
+      IF( iapptrac.EQ.iapp_tracvl ) THEN
+        if (planet_type.eq."earth") then
+! Earth-specific treatment for the first 2 tracers (water)
 c
 cc          CALL minmaxq(q(1,1,1),1.e33,-1.e33,'Eau vapeur     ')
@@ -78,8 +82,5 @@
           ENDDO
           
-	  if (planet_type.eq."earth") then
-! Earth-specific treatment of first 2 tracers (water)
-            CALL qminimum( q, 2, finmasse )
-	  endif
+          CALL qminimum( q, 2, finmasse )
 
           CALL SCOPY   ( ip1jmp1*llm, masse, 1, finmasse,       1 )
@@ -100,22 +101,12 @@
            ENDDO
 c
-         ELSE
-           DO iq = 1 , 2
-           DO l  = 1, llm
-             DO ij = 1,ip1jmp1
-              dq(ij,l,iq)  = 0.
-             ENDDO
-           ENDDO
-           ENDDO
+        endif ! of if (planet_type.eq."earth")
+      ELSE
+        if (planet_type.eq."earth") then
+! Earth-specific treatment for the first 2 tracers (water)
+          dq(:,:,1:2)=0.
+        endif ! of if (planet_type.eq."earth")
+      ENDIF ! of IF( iapptrac.EQ.iapp_tracvl )
 
-
-         ENDIF
-
-c
-
-c  ... On appelle  qminimum uniquement  pour l'eau vapeur et liquide  ..
-
- 
-      RETURN
       END
 
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/gcm.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/gcm.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/gcm.F	(revision 1446)
@@ -249,18 +249,9 @@
         endif
 
-        if (planet_type.eq."earth") then
-#ifdef CPP_EARTH
+!        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)
-#else
-        ! SW model also has Earth-format start files
-        ! (but can be used without the CPP_EARTH directive)
-          if (iflag_phys.eq.0) then
-            CALL dynetat0("start.nc",vcov,ucov,
-     &              teta,q,masse,ps,phis, time_0)
-          endif
-#endif
-        endif ! of if (planet_type.eq."earth")
+!        endif ! of if (planet_type.eq."earth")
         
 c       write(73,*) 'ucov',ucov
@@ -468,7 +459,8 @@
 #endif
 
-      if (planet_type.eq."earth") then
+!      if (planet_type.eq."earth") then
+! Write an Earth-format restart file
         CALL dynredem0("restart.nc", day_end, phis)
-      endif
+!      endif
 
       ecripar = .TRUE.
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/infotrac.F90
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/infotrac.F90	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/infotrac.F90	(revision 1446)
@@ -65,5 +65,6 @@
     INTEGER :: nqtrue  ! number of tracers read from tracer.def, without higer order of moment
     INTEGER :: iq, new_iq, iiq, jq, ierr
- 
+
+    character(len=*),parameter :: modname="infotrac_init"
 !-----------------------------------------------------------------------
 ! Initialization :
@@ -99,13 +100,19 @@
        OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
        IF(ierr.EQ.0) THEN
-          WRITE(lunout,*) 'Open traceur.def : ok'
+          WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
           READ(90,*) nqtrue
        ELSE 
-          WRITE(lunout,*) 'Problem in opening traceur.def'
-          WRITE(lunout,*) 'ATTENTION using defaut values'
+          WRITE(lunout,*) trim(modname),': Problem in opening traceur.def'
+          WRITE(lunout,*) trim(modname),': WARNING using defaut values'
           nqtrue=4 ! Defaut value
        END IF
-       ! Attention! Only for planet_type=='earth'
-       nbtr=nqtrue-2
+       if ( planet_type=='earth') then
+         ! For Earth, water vapour & liquid tracers are not in the physics
+         nbtr=nqtrue-2
+       else
+         ! Other planets (for now); we have the same number of tracers
+         ! in the dynamics than in the physics
+         nbtr=nqtrue
+       endif
     ELSE
        ! nbtr has been read from INCA by init_cont_lmdz() in gcm.F 
@@ -113,6 +120,6 @@
     END IF
 
-    IF (nqtrue < 2) THEN
-       WRITE(lunout,*) 'nqtrue=',nqtrue, ' is not allowded. 2 tracers is the minimum'
+    IF ((planet_type=="earth").and.(nqtrue < 2)) THEN
+       WRITE(lunout,*) trim(modname),': nqtrue=',nqtrue, ' is not allowded. 2 tracers is the minimum'
        CALL abort_gcm('infotrac_init','Not enough tracers',1)
     END IF
@@ -158,5 +165,6 @@
           END DO
           CLOSE(90)  
-       ELSE ! Without tracer.def
+       ELSE ! Without tracer.def, set default values (for Earth!)
+         if ((nqtrue==4).and.(planet_type=="earth")) then
           hadv(1) = 14
           vadv(1) = 14
@@ -171,8 +179,15 @@
           vadv(4) = 10
           tnom_0(4) = 'PB'
+         else
+           ! Error message, we need a traceur.def file
+           write(lunout,*) trim(modname),&
+           ': Cannot set default tracer names!'
+           write(lunout,*) trim(modname),' Make a traceur.def file!!!'
+           CALL abort_gcm('infotrac_init','Need a traceur.def file!',1)
+         endif ! of if (nqtrue==4)
        END IF
        
-       WRITE(lunout,*) 'Valeur de traceur.def :'
-       WRITE(lunout,*) 'nombre de traceurs ',nqtrue
+       WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
+       WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
        DO iq=1,nqtrue
           WRITE(lunout,*) hadv(iq),vadv(iq),tnom_0(iq)
@@ -216,5 +231,5 @@
           new_iq=new_iq+10 ! 9 tracers added
        ELSE
-          WRITE(lunout,*) 'This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
+          WRITE(lunout,*) trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
           CALL abort_gcm('infotrac_init','Bad choice of advection schema - 1',1)
        END IF
@@ -226,8 +241,8 @@
        nqtot = new_iq
 
-       WRITE(lunout,*) 'The choice of advection schema for one or more tracers'
+       WRITE(lunout,*) trim(modname),': The choice of advection schema for one or more tracers'
        WRITE(lunout,*) 'makes it necessary to add tracers'
-       WRITE(lunout,*) nqtrue,' is the number of true tracers'
-       WRITE(lunout,*) nqtot, ' is the total number of tracers needed'
+       WRITE(lunout,*) trim(modname)//': ',nqtrue,' is the number of true tracers'
+       WRITE(lunout,*) trim(modname)//': ',nqtot, ' is the total number of tracers needed'
 
     ELSE
@@ -257,5 +272,5 @@
           iadv(new_iq)=11
        ELSE
-          WRITE(lunout,*)'This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
+          WRITE(lunout,*)trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
 
           CALL abort_gcm('infotrac_init','Bad choice of advection schema - 2',1)
@@ -303,8 +318,9 @@
 
 
-    WRITE(lunout,*) 'Information stored in infotrac :'
-    WRITE(lunout,*) 'iadv  niadv tname  ttext :'
+    WRITE(lunout,*) trim(modname),': Information stored in infotrac :'
+    WRITE(lunout,*) trim(modname),': iadv  niadv tname  ttext :'
     DO iq=1,nqtot
-       WRITE(lunout,*) iadv(iq),niadv(iq), tname(iq), ttext(iq)
+       WRITE(lunout,*) iadv(iq),niadv(iq),&
+       ' ',trim(tname(iq)),' ',trim(ttext(iq))
     END DO
 
@@ -315,8 +331,8 @@
     DO iq=1,nqtot
        IF (iadv(iq)/=10 .AND. iadv(iq)/=14 .AND. iadv(iq)/=0) THEN
-          WRITE(lunout,*)'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
+          WRITE(lunout,*)trim(modname),' STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
           CALL abort_gcm('infotrac_init','In this version only iadv=10 and iadv=14 is tested!',1)
        ELSE IF (iadv(iq)==14 .AND. iq/=1) THEN
-          WRITE(lunout,*)'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
+          WRITE(lunout,*)trim(modname),'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
           CALL abort_gcm('infotrac_init','In this version iadv=14 is only permitted for water vapour!',1)
        END IF
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/iniacademic.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/iniacademic.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/iniacademic.F	(revision 1446)
@@ -8,5 +8,5 @@
       USE filtreg_mod
       USE infotrac, ONLY : nqtot
-      USE control_mod
+      USE control_mod, ONLY: day_step,planet_type
 #ifdef CPP_IOIPSL
       USE IOIPSL
@@ -95,5 +95,4 @@
 ! 1. Initializations for Earth-like case
 ! --------------------------------------
-      if (planet_type=="earth") then
 c
         ! initialize planet radius, rotation rate,...
@@ -128,7 +127,5 @@
           if (.not.read_start) then
             phis(:)=0.
-            q(:,:,1)=1.e-10
-            q(:,:,2)=1.e-15
-            q(:,:,3:nqtot)=0.
+            q(:,:,:)=0
             CALL sw_case_williamson91_6(vcov,ucov,teta,masse,ps)
           endif
@@ -138,4 +135,6 @@
           ! initializations for the academic case
           
+!         if (planet_type=="earth") then
+
           ! 1. local parameters
           ! by convention, winter is in the southern hemisphere
@@ -219,4 +218,11 @@
           enddo
 
+
+!         else
+!          write(lunout,*)"iniacademic: planet types other than earth",
+!     &                   " not implemented (yet)."
+!          stop
+!         endif ! of if (planet_type=="earth")
+
           ! 3. Initialize fields (if necessary)
           IF (.NOT. read_start) THEN
@@ -245,9 +251,14 @@
             
             ! bulk initialization of tracers
-            do i=1,nqtot
-              if (i.eq.1) q(:,:,i)=1.e-10
-              if (i.eq.2) q(:,:,i)=1.e-15
-              if (i.gt.2) q(:,:,i)=0.
-            enddo
+            if (planet_type=="earth") then
+              ! Earth: first two tracers will be water
+              do i=1,nqtot
+                if (i.eq.1) q(:,:,i)=1.e-10
+                if (i.eq.2) q(:,:,i)=1.e-15
+                if (i.gt.2) q(:,:,i)=0.
+              enddo
+            else
+              q(:,:,:)=0
+            endif ! of if (planet_type=="earth")
 
             ! add random perturbation to temperature
@@ -261,4 +272,5 @@
             enddo
 
+            ! maintain periodicity in longitude
             do l=1,llm
               do ij=1,ip1jmp1,iip1
@@ -267,24 +279,7 @@
             enddo
 
-c     PRINT *,' Appel test_period avec tetarappel '
-c     CALL  test_period ( ucov,vcov,tetarappel,q,p,phis )
-c     PRINT *,' Appel test_period avec teta '
-c     CALL  test_period ( ucov,vcov,teta,q,p,phis )
-
-           ! initialize a traceur on one column
-!          j=jjp1*3/4
-!          i=iip1/2
-!          ij=(j-1)*iip1+i
-!          q(ij,:,3)=1.
-
           ENDIF ! of IF (.NOT. read_start)
         endif ! of if (iflag_phys.eq.2)
         
-      else
-        write(lunout,*)"iniacademic: planet types other than earth",
-     &                 " not implemented (yet)."
-        stop
-      endif ! of if (planet_type=="earth")
-      return
       END
 c-----------------------------------------------------------------------
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/integrd.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/integrd.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/integrd.F	(revision 1446)
@@ -6,5 +6,5 @@
      $     dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis,finvmaold )
 
-      USE control_mod
+      use control_mod, only : planet_type
 
       IMPLICIT NONE
@@ -81,8 +81,8 @@
       CALL SCOPY(ip1jmp1*llm, masse, 1, massescr, 1)
 
-      DO 2 ij = 1,ip1jmp1
+      DO ij = 1,ip1jmp1
        pscr (ij)    = ps(ij)
        ps (ij)      = psm1(ij) + dt * dp(ij)
-   2  CONTINUE
+      ENDDO
 c
       DO ij = 1,ip1jmp1
@@ -115,45 +115,45 @@
 c    ............   integration  de  ucov, vcov,  h     ..............
 
-      DO 10 l = 1,llm
-
-      DO 4 ij = iip2,ip1jm
-      uscr( ij )   =  ucov( ij,l )
-      ucov( ij,l ) = ucovm1( ij,l ) + dt * du( ij,l )
-   4  CONTINUE
-
-      DO 5 ij = 1,ip1jm
-      vscr( ij )   =  vcov( ij,l )
-      vcov( ij,l ) = vcovm1( ij,l ) + dt * dv( ij,l )
-   5  CONTINUE
-
-      DO 6 ij = 1,ip1jmp1
-      hscr( ij )    =  teta(ij,l)
-      teta ( ij,l ) = tetam1(ij,l) *  massem1(ij,l) / masse(ij,l) 
-     $                + dt * dteta(ij,l) / masse(ij,l)
-   6  CONTINUE
+      DO l = 1,llm
+
+       DO ij = iip2,ip1jm
+        uscr( ij )   =  ucov( ij,l )
+        ucov( ij,l ) = ucovm1( ij,l ) + dt * du( ij,l )
+       ENDDO
+
+       DO ij = 1,ip1jm
+        vscr( ij )   =  vcov( ij,l )
+        vcov( ij,l ) = vcovm1( ij,l ) + dt * dv( ij,l )
+       ENDDO
+
+       DO ij = 1,ip1jmp1
+        hscr( ij )    =  teta(ij,l)
+        teta ( ij,l ) = tetam1(ij,l) *  massem1(ij,l) / masse(ij,l) 
+     &                + dt * dteta(ij,l) / masse(ij,l)
+       ENDDO
 
 c   ....  Calcul de la valeur moyenne, unique  aux poles pour  teta    ......
 c
 c
-      DO  ij   = 1, iim
+       DO  ij   = 1, iim
         tppn(ij) = aire(   ij   ) * teta(  ij    ,l)
         tpps(ij) = aire(ij+ip1jm) * teta(ij+ip1jm,l)
-      ENDDO
+       ENDDO
         tpn      = SSUM(iim,tppn,1)/apoln
         tps      = SSUM(iim,tpps,1)/apols
 
-      DO ij   = 1, iip1
+       DO ij   = 1, iip1
         teta(   ij   ,l)  = tpn
         teta(ij+ip1jm,l)  = tps
-      ENDDO
-c
-
-      IF(leapf)  THEN
+       ENDDO
+c
+
+       IF(leapf)  THEN
          CALL SCOPY ( ip1jmp1, uscr(1), 1, ucovm1(1, l), 1 )
          CALL SCOPY (   ip1jm, vscr(1), 1, vcovm1(1, l), 1 )
          CALL SCOPY ( ip1jmp1, hscr(1), 1, tetam1(1, l), 1 )
-      END IF
-
-  10  CONTINUE
+       END IF
+
+      ENDDO ! of DO l = 1,llm
 
 
@@ -185,14 +185,13 @@
 c$$$      ENDIF
 
-	 if (planet_type.eq."earth") then
+      if (planet_type.eq."earth") then
 ! Earth-specific treatment of first 2 tracers (water)
-          DO l = 1, llm
-           DO ij = 1, ip1jmp1
+        DO l = 1, llm
+          DO ij = 1, ip1jmp1
             deltap(ij,l) =  p(ij,l) - p(ij,l+1) 
-           ENDDO
           ENDDO
-
-          CALL qminimum( q, nq, deltap )
-	 endif ! of if (planet_type.eq."earth")
+        ENDDO
+
+        CALL qminimum( q, nq, deltap )
 
 c
@@ -200,5 +199,5 @@
 c
 
-      DO iq = 1, nq
+       DO iq = 1, nq
         DO l = 1, llm
 
@@ -216,13 +215,13 @@
 
         ENDDO
-      ENDDO
-
-
-         CALL  SCOPY( ijp1llm , finvmasse, 1, finvmaold, 1 )
+       ENDDO
+
+
+      CALL  SCOPY( ijp1llm , finvmasse, 1, finvmaold, 1 )
+
+      endif ! of if (planet_type.eq."earth")
 c
 c
 c     .....   FIN  de l'integration  de   q    .......
-
-15    continue
 
 c    .................................................................
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/leapfrog.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/leapfrog.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3d/leapfrog.F	(revision 1446)
@@ -209,5 +209,5 @@
 c   --------------------------------------------------
 
-      dq=0.
+      dq(:,:,:)=0.
       CALL pression ( ip1jmp1, ap, bp, ps, p       )
       CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
@@ -253,7 +253,4 @@
       CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
       CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
-
-! Ehouarn: what is this for? zqmin & zqmax are not used anyway ...
-!      call minmax(ijp1llm,q(:,:,3),zqmin,zqmax)
 
    2  CONTINUE
@@ -632,9 +629,9 @@
 
 
-              if (planet_type.eq."earth") then
+!              if (planet_type.eq."earth") then
 ! Write an Earth-format restart file
                 CALL dynredem1("restart.nc",0.0,
      &                         vcov,ucov,teta,q,masse,ps)
-              endif ! of if (planet_type.eq."earth")
+!              endif ! of if (planet_type.eq."earth")
 
               CLOSE(99)
@@ -744,8 +741,8 @@
 
               IF(itau.EQ.itaufin) THEN
-                if (planet_type.eq."earth") then
+!                if (planet_type.eq."earth") then
                   CALL dynredem1("restart.nc",0.0,
      &                           vcov,ucov,teta,q,masse,ps)
-                endif ! of if (planet_type.eq."earth")
+!                endif ! of if (planet_type.eq."earth")
               ENDIF ! of IF(itau.EQ.itaufin)
 
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/addfi_p.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/addfi_p.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/addfi_p.F	(revision 1446)
@@ -1,4 +1,4 @@
 !
-! $Header$
+! $Id$
 !
       SUBROUTINE addfi_p(pdt, leapf, forward,
@@ -7,4 +7,5 @@
       USE parallel
       USE infotrac, ONLY : nqtot
+      USE control_mod, ONLY : planet_type
       IMPLICIT NONE
 c
@@ -154,5 +155,7 @@
 c$OMP END MASTER
  
-      DO iq = 1, 2
+      if (planet_type=="earth") then
+      ! earth case, special treatment for first 2 tracers (water)
+       DO iq = 1, 2
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
          DO k = 1,llm
@@ -163,7 +166,7 @@
          ENDDO
 c$OMP END DO NOWAIT
-      ENDDO
-
-      DO iq = 3, nqtot
+       ENDDO
+
+       DO iq = 3, nqtot
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
          DO k = 1,llm
@@ -174,5 +177,18 @@
          ENDDO
 c$OMP END DO NOWAIT
-      ENDDO
+       ENDDO
+      else
+      ! general case, treat all tracers equally)
+       DO iq = 1, nqtot
+c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
+         DO k = 1,llm
+            DO j = ijb,ije
+               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
+c$OMP END DO NOWAIT
+       ENDDO
+      endif ! of if (planet_type=="earth")
 
 c$OMP MASTER
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/advtrac_p.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/advtrac_p.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/advtrac_p.F	(revision 1446)
@@ -132,5 +132,5 @@
 ccc         CALL filtreg ( massem ,jjp1, llm,-2, 2, .TRUE., 1 )
 c
-      ENDIF
+      ENDIF ! of IF(iadvtr.EQ.0)
 
       iadvtr   = iadvtr+1
@@ -266,5 +266,5 @@
 cym      ----> Revérifier lors de la parallélisation des autres schemas
    
-cym          call massbar_p(massem,massebx,masseby)          
+cym          call massbar_p(massem,massebx,masseby)  
 
           call vlspltgen_p( q,iadv, 2., massem, wg ,
@@ -452,16 +452,18 @@
 c$OMP BARRIER
 
-      ijb=ij_begin
-      ije=ij_end
+      if (planet_type=="earth") then
+
+        ijb=ij_begin
+        ije=ij_end
 
 c$OMP DO SCHEDULE(STATIC,OMP_CHUNK)      
-       DO l = 1, llm
+        DO l = 1, llm
          DO ij = ijb, ije
            finmasse(ij,l) =  p(ij,l) - p(ij,l+1) 
          ENDDO
-       ENDDO
+        ENDDO
 c$OMP END DO
 
-       CALL qminimum_p( q, 2, finmasse )
+        CALL qminimum_p( q, 2, finmasse )
 
 c------------------------------------------------------------------
@@ -496,4 +498,5 @@
 c$OMP BARRIER	
           iadvtr=0
+      endif ! of if (planet_type=="earth")
        ENDIF ! if iadvtr.EQ.iapp_tracvl
 
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/caladvtrac_p.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/caladvtrac_p.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/caladvtrac_p.F	(revision 1446)
@@ -8,6 +8,6 @@
      *                   flxw, pk, iapptrac)
       USE parallel
-      USE infotrac
-      USE control_mod
+      USE infotrac, ONLY : nqtot
+      USE control_mod, ONLY : iapp_tracvl,planet_type
 c
       IMPLICIT NONE
@@ -30,5 +30,6 @@
 c   ----------
       REAL pbaru( ip1jmp1,llm ),pbarv( ip1jm,llm),masse(ip1jmp1,llm)
-      REAL p( ip1jmp1,llmp1),q( ip1jmp1,llm,nqtot),dq( ip1jmp1,llm,2 )
+      REAL p( ip1jmp1,llmp1),q( ip1jmp1,llm,nqtot)
+      real :: dq( ip1jmp1,llm,nqtot)
       REAL teta( ip1jmp1,llm),pk( ip1jmp1,llm)
       REAL               :: flxw(ip1jmp1,llm)
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/gcm.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/gcm.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/gcm.F	(revision 1446)
@@ -276,18 +276,10 @@
         endif
 
-        if (planet_type.eq."earth") then
-#ifdef CPP_EARTH
+!        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)
-#else
-        ! SW model also has Earth-format start files
-        ! (but can be used without the CPP_EARTH directive)
-          if (iflag_phys.eq.0) then
-            CALL dynetat0("start.nc",vcov,ucov,
-     &              teta,q,masse,ps,phis, time_0)
-          endif
-#endif
-        endif ! of if (planet_type.eq."earth")
+!        endif ! of if (planet_type.eq."earth")
+
 c       write(73,*) 'ucov',ucov
 c       write(74,*) 'vcov',vcov
@@ -494,7 +486,8 @@
 #endif
 
-      if (planet_type.eq."earth") then
+!      if (planet_type.eq."earth") then
+! Write an Earth-format restart file
         CALL dynredem0_p("restart.nc", day_end, phis)
-      endif
+!      endif
 
       ecripar = .TRUE.
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/infotrac.F90
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/infotrac.F90	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/infotrac.F90	(revision 1446)
@@ -65,5 +65,6 @@
     INTEGER :: nqtrue  ! number of tracers read from tracer.def, without higer order of moment
     INTEGER :: iq, new_iq, iiq, jq, ierr
- 
+
+    character(len=*),parameter :: modname="infotrac_init"
 !-----------------------------------------------------------------------
 ! Initialization :
@@ -99,13 +100,19 @@
        OPEN(90,file='traceur.def',form='formatted',status='old', iostat=ierr)
        IF(ierr.EQ.0) THEN
-          WRITE(lunout,*) 'Open traceur.def : ok'
+          WRITE(lunout,*) trim(modname),': Open traceur.def : ok'
           READ(90,*) nqtrue
        ELSE 
-          WRITE(lunout,*) 'Problem in opening traceur.def'
-          WRITE(lunout,*) 'ATTENTION using defaut values'
+          WRITE(lunout,*) trim(modname),': Problem in opening traceur.def'
+          WRITE(lunout,*) trim(modname),': WARNING using defaut values'
           nqtrue=4 ! Defaut value
        END IF
-       ! Attention! Only for planet_type=='earth'
-       nbtr=nqtrue-2
+       if ( planet_type=='earth') then
+         ! For Earth, water vapour & liquid tracers are not in the physics
+         nbtr=nqtrue-2
+       else
+         ! Other planets (for now); we have the same number of tracers
+         ! in the dynamics than in the physics
+         nbtr=nqtrue
+       endif
     ELSE
        ! nbtr has been read from INCA by init_cont_lmdz() in gcm.F 
@@ -113,6 +120,6 @@
     END IF
 
-    IF (nqtrue < 2) THEN
-       WRITE(lunout,*) 'nqtrue=',nqtrue, ' is not allowded. 2 tracers is the minimum'
+    IF ((planet_type=="earth").and.(nqtrue < 2)) THEN
+       WRITE(lunout,*) trim(modname),': nqtrue=',nqtrue, ' is not allowded. 2 tracers is the minimum'
        CALL abort_gcm('infotrac_init','Not enough tracers',1)
     END IF
@@ -158,5 +165,6 @@
           END DO
           CLOSE(90)  
-       ELSE ! Without tracer.def
+       ELSE ! Without tracer.def, set default values (for Earth!)
+         if ((nqtrue==4).and.(planet_type=="earth")) then
           hadv(1) = 14
           vadv(1) = 14
@@ -171,8 +179,15 @@
           vadv(4) = 10
           tnom_0(4) = 'PB'
+         else
+           ! Error message, we need a traceur.def file
+           write(lunout,*) trim(modname),&
+           ': Cannot set default tracer names!'
+           write(lunout,*) trim(modname),' Make a traceur.def file!!!'
+           CALL abort_gcm('infotrac_init','Need a traceur.def file!',1)
+         endif ! of if (nqtrue==4)
        END IF
        
-       WRITE(lunout,*) 'Valeur de traceur.def :'
-       WRITE(lunout,*) 'nombre de traceurs ',nqtrue
+       WRITE(lunout,*) trim(modname),': Valeur de traceur.def :'
+       WRITE(lunout,*) trim(modname),': nombre de traceurs ',nqtrue
        DO iq=1,nqtrue
           WRITE(lunout,*) hadv(iq),vadv(iq),tnom_0(iq)
@@ -216,5 +231,5 @@
           new_iq=new_iq+10 ! 9 tracers added
        ELSE
-          WRITE(lunout,*) 'This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
+          WRITE(lunout,*) trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
           CALL abort_gcm('infotrac_init','Bad choice of advection schema - 1',1)
        END IF
@@ -226,8 +241,8 @@
        nqtot = new_iq
 
-       WRITE(lunout,*) 'The choice of advection schema for one or more tracers'
+       WRITE(lunout,*) trim(modname),': The choice of advection schema for one or more tracers'
        WRITE(lunout,*) 'makes it necessary to add tracers'
-       WRITE(lunout,*) nqtrue,' is the number of true tracers'
-       WRITE(lunout,*) nqtot, ' is the total number of tracers needed'
+       WRITE(lunout,*) trim(modname)//': ',nqtrue,' is the number of true tracers'
+       WRITE(lunout,*) trim(modname)//': ',nqtot, ' is the total number of tracers needed'
 
     ELSE
@@ -257,5 +272,5 @@
           iadv(new_iq)=11
        ELSE
-          WRITE(lunout,*)'This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
+          WRITE(lunout,*)trim(modname),': This choice of advection schema is not available',iq,hadv(iq),vadv(iq)
 
           CALL abort_gcm('infotrac_init','Bad choice of advection schema - 2',1)
@@ -303,8 +318,9 @@
 
 
-    WRITE(lunout,*) 'Information stored in infotrac :'
-    WRITE(lunout,*) 'iadv  niadv tname  ttext :'
+    WRITE(lunout,*) trim(modname),': Information stored in infotrac :'
+    WRITE(lunout,*) trim(modname),': iadv  niadv tname  ttext :'
     DO iq=1,nqtot
-       WRITE(lunout,*) iadv(iq),niadv(iq), tname(iq), ttext(iq)
+       WRITE(lunout,*) iadv(iq),niadv(iq),&
+       ' ',trim(tname(iq)),' ',trim(ttext(iq))
     END DO
 
@@ -315,8 +331,8 @@
     DO iq=1,nqtot
        IF (iadv(iq)/=10 .AND. iadv(iq)/=14 .AND. iadv(iq)/=0) THEN
-          WRITE(lunout,*)'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
+          WRITE(lunout,*)trim(modname),' STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
           CALL abort_gcm('infotrac_init','In this version only iadv=10 and iadv=14 is tested!',1)
        ELSE IF (iadv(iq)==14 .AND. iq/=1) THEN
-          WRITE(lunout,*)'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
+          WRITE(lunout,*)trim(modname),'STOP : The option iadv=',iadv(iq),' is not tested in this version of LMDZ'
           CALL abort_gcm('infotrac_init','In this version iadv=14 is only permitted for water vapour!',1)
        END IF
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/iniacademic.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/iniacademic.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/iniacademic.F	(revision 1446)
@@ -8,5 +8,5 @@
       USE filtreg_mod
       USE infotrac, ONLY : nqtot
-      USE control_mod
+      USE control_mod, ONLY: day_step,planet_type
 #ifdef CPP_IOIPSL
       USE IOIPSL
@@ -95,5 +95,4 @@
 ! 1. Initializations for Earth-like case
 ! --------------------------------------
-      if (planet_type=="earth") then
 c
         ! initialize planet radius, rotation rate,...
@@ -128,7 +127,5 @@
           if (.not.read_start) then
             phis(:)=0.
-            q(:,:,1)=1.e-10
-            q(:,:,2)=1.e-15
-            q(:,:,3:nqtot)=0.
+            q(:,:,:)=0
             CALL sw_case_williamson91_6(vcov,ucov,teta,masse,ps)
           endif
@@ -138,4 +135,6 @@
           ! initializations for the academic case
           
+!         if (planet_type=="earth") then
+
           ! 1. local parameters
           ! by convention, winter is in the southern hemisphere
@@ -219,4 +218,11 @@
           enddo
 
+
+!         else
+!          write(lunout,*)"iniacademic: planet types other than earth",
+!     &                   " not implemented (yet)."
+!          stop
+!         endif ! of if (planet_type=="earth")
+
           ! 3. Initialize fields (if necessary)
           IF (.NOT. read_start) THEN
@@ -245,9 +251,14 @@
             
             ! bulk initialization of tracers
-            do i=1,nqtot
-              if (i.eq.1) q(:,:,i)=1.e-10
-              if (i.eq.2) q(:,:,i)=1.e-15
-              if (i.gt.2) q(:,:,i)=0.
-            enddo
+            if (planet_type=="earth") then
+              ! Earth: first two tracers will be water
+              do i=1,nqtot
+                if (i.eq.1) q(:,:,i)=1.e-10
+                if (i.eq.2) q(:,:,i)=1.e-15
+                if (i.gt.2) q(:,:,i)=0.
+              enddo
+            else
+              q(:,:,:)=0
+            endif ! of if (planet_type=="earth")
 
             ! add random perturbation to temperature
@@ -261,4 +272,5 @@
             enddo
 
+            ! maintain periodicity in longitude
             do l=1,llm
               do ij=1,ip1jmp1,iip1
@@ -267,24 +279,7 @@
             enddo
 
-c     PRINT *,' Appel test_period avec tetarappel '
-c     CALL  test_period ( ucov,vcov,tetarappel,q,p,phis )
-c     PRINT *,' Appel test_period avec teta '
-c     CALL  test_period ( ucov,vcov,teta,q,p,phis )
-
-           ! initialize a traceur on one column
-!          j=jjp1*3/4
-!          i=iip1/2
-!          ij=(j-1)*iip1+i
-!          q(ij,:,3)=1.
-
           ENDIF ! of IF (.NOT. read_start)
         endif ! of if (iflag_phys.eq.2)
         
-      else
-        write(lunout,*)"iniacademic: planet types other than earth",
-     &                 " not implemented (yet)."
-        stop
-      endif ! of if (planet_type=="earth")
-      return
       END
 c-----------------------------------------------------------------------
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/integrd_p.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/integrd_p.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/integrd_p.F	(revision 1446)
@@ -6,5 +6,5 @@
      $     dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps0,masse,phis,finvmaold)
       USE parallel
-      USE control_mod
+      USE control_mod, only : planet_type
       IMPLICIT NONE
 
@@ -279,5 +279,4 @@
 
           CALL qminimum_p( q, nq, deltap )
-	 endif ! of if (planet_type.eq."earth")
 c
 c    .....  Calcul de la valeur moyenne, unique  aux poles pour  q .....
@@ -337,4 +336,7 @@
       ENDDO
 c$OMP END DO NOWAIT
+
+      endif ! of if (planet_type.eq."earth")
+
 c
 c
Index: /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/leapfrog_p.F
===================================================================
--- /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/leapfrog_p.F	(revision 1445)
+++ /LMDZ5/branches/LMDZ5V1.0-dev/libf/dyn3dpar/leapfrog_p.F	(revision 1446)
@@ -234,5 +234,5 @@
 
 c$OMP MASTER
-      dq=0.
+      dq(:,:,:)=0.
       CALL pression ( ip1jmp1, ap, bp, ps, p       )
       CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
@@ -1488,9 +1488,9 @@
 c$OMP MASTER
 
-              if (planet_type.eq."earth") then
+!              if (planet_type.eq."earth") then
 ! Write an Earth-format restart file
                 CALL dynredem1_p("restart.nc",0.0,
      &                           vcov,ucov,teta,q,masse,ps)
-              endif ! of if (planet_type.eq."earth")
+!              endif ! of if (planet_type.eq."earth")
 
 !              CLOSE(99)
@@ -1681,10 +1681,10 @@
 
               IF(itau.EQ.itaufin) THEN
-                if (planet_type.eq."earth") then
+!                if (planet_type.eq."earth") then
 c$OMP MASTER
                    CALL dynredem1_p("restart.nc",0.0,
      .                               vcov,ucov,teta,q,masse,ps)
 c$OMP END MASTER
-                endif ! of if (planet_type.eq."earth")
+!                endif ! of if (planet_type.eq."earth")
               ENDIF ! of IF(itau.EQ.itaufin)
 
