Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/abort_gcm.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/abort_gcm.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/abort_gcm.F	(revision 1222)
@@ -8,4 +8,7 @@
 #ifdef CPP_IOIPSL
       USE IOIPSL
+#else
+! if not using IOIPSL, we still need to use (a local version of) getin_dump
+      USE ioipsl_getincom
 #endif
 #include "iniprint.h"
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/caladvtrac.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/caladvtrac.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/caladvtrac.F	(revision 1222)
@@ -76,6 +76,9 @@
            ENDDO
           ENDDO
-
-          CALL qminimum( q, 2, finmasse )
+          
+	  if (planet_type.eq."earth") then
+! Earth-specific treatment of first 2 tracers (water)
+            CALL qminimum( q, 2, finmasse )
+	  endif
 
           CALL SCOPY   ( ip1jmp1*llm, masse, 1, finmasse,       1 )
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/calfis.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/calfis.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/calfis.F	(revision 1222)
@@ -177,6 +177,8 @@
 c    --------------------
 c
-
-      IF (ngridmx.NE.2+(jjm-1)*iim) THEN
+c
+      IF ( firstcal )  THEN
+        debut = .TRUE.
+        IF (ngridmx.NE.2+(jjm-1)*iim) THEN
          PRINT*,'STOP dans calfis'
          PRINT*,'La dimension ngridmx doit etre egale a 2 + (jjm-1)*iim'
@@ -184,16 +186,8 @@
          PRINT*,ngridmx,jjm,iim
          STOP
-      ENDIF
-
-c-----------------------------------------------------------------------
-c   latitude, longitude et aires des mailles pour la physique:
-c   ----------------------------------------------------------
-
-c
-      IF ( firstcal )  THEN
-          debut = .TRUE.
+        ENDIF
       ELSE
-          debut = .FALSE.
-      ENDIF
+        debut = .FALSE.
+      ENDIF ! of IF (firstcal)
 
 c
@@ -290,6 +284,7 @@
 
 c   convergence dynamique pour les traceurs "EAU"
-
-      DO iq=1,2
+! Earth-specific treatment of first 2 tracers (water)
+       if (planet_type=="earth") then
+        DO iq=1,2
          DO l=1,llm
             pcvgq(1,l,iq)= pdq(1,1,l,iq) / pmasse(1,1,l)
@@ -303,5 +298,6 @@
             pcvgq(ig0,l,iq)= pdq(1,jjp1,l,iq) / pmasse(1,jjp1,l)
          ENDDO
-      ENDDO
+        ENDDO
+       endif ! of if (planet_type=="earth")
 
 
@@ -428,8 +424,12 @@
       ENDDO
 c
+      if (planet_type=="earth") then
+#ifdef CPP_EARTH
 cIM calcul PV a teta=350, 380, 405K
       CALL PVtheta(ngridmx,llm,pucov,pvcov,pteta,
      $           ztfi,zplay,zplev,
      $           ntetaSTD,rtetaSTD,PVteta)
+#endif
+      endif
 c
 c On change de grille, dynamique vers physiq, pour le flux de masse verticale
@@ -441,4 +441,6 @@
 
 
+      if (planet_type=="earth") then
+#ifdef CPP_EARTH
       CALL physiq (ngridmx,
      .             llm,
@@ -467,4 +469,6 @@
      .             pducov,
      .             PVteta)
+#endif
+      endif !of if (planet_type=="earth")
 
 500   CONTINUE
@@ -502,25 +506,25 @@
 c   62. humidite specifique
 c   ---------------------
-
-      DO iq=1,nqtot
-         DO l=1,llm
-            DO i=1,iip1
-               pdqfi(i,1,l,iq)    = zdqfi(1,l,iq)
-               pdqfi(i,jjp1,l,iq) = zdqfi(ngridmx,l,iq)
-            ENDDO
-            DO j=2,jjm
-               ig0=1+(j-2)*iim
-               DO i=1,iim
-                  pdqfi(i,j,l,iq) = zdqfi(ig0+i,l,iq)
-               ENDDO
-               pdqfi(iip1,j,l,iq) = pdqfi(1,j,l,iq)
-            ENDDO
-         ENDDO
-      ENDDO
+! Ehouarn: removed this useless bit: was overwritten at step 63 anyways
+!      DO iq=1,nqtot
+!         DO l=1,llm
+!            DO i=1,iip1
+!               pdqfi(i,1,l,iq)    = zdqfi(1,l,iq)
+!               pdqfi(i,jjp1,l,iq) = zdqfi(ngridmx,l,iq)
+!            ENDDO
+!            DO j=2,jjm
+!               ig0=1+(j-2)*iim
+!               DO i=1,iim
+!                  pdqfi(i,j,l,iq) = zdqfi(ig0+i,l,iq)
+!               ENDDO
+!               pdqfi(iip1,j,l,iq) = pdqfi(1,j,l,iq)
+!            ENDDO
+!         ENDDO
+!      ENDDO
 
 c   63. traceurs
 c   ------------
 C     initialisation des tendances
-      pdqfi=0.
+      pdqfi(:,:,:,:)=0.
 C
       DO iq=1,nqtot
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/create_etat0_limit.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/create_etat0_limit.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/create_etat0_limit.F	(revision 1222)
@@ -1,6 +1,8 @@
 !
-! $Header$
+! $Id$
 !
        PROGRAM create_etat0_limit
+#ifdef CPP_EARTH
+! This prog. is designed to work for Earth
        USE dimphy
        USE comgeomphy
@@ -67,4 +69,6 @@
 1     FORMAT(//)
 
+#endif
+! of #ifdef CPP_EARTH
       STOP
       END
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/fluxstokenc.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/fluxstokenc.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/fluxstokenc.F	(revision 1222)
@@ -1,4 +1,9 @@
+!
+! $Id$
+!
       SUBROUTINE fluxstokenc(pbaru,pbarv,masse,teta,phi,phis,
      . time_step,itau )
+#ifdef CPP_EARTH
+! This routine is designed to work for Earth and with ioipsl
 
        USE IOIPSL
@@ -18,4 +23,5 @@
 #include "tracstoke.h"
 #include "temps.h"
+#include "iniprint.h"
 
       REAL time_step,t_wrt, t_ops
@@ -159,4 +165,9 @@
       ENDIF ! if iadvtr.EQ.istdyn
 
+#else
+      write(lunout,*)
+     & 'fluxstokenc: Needs Earth physics (and ioipsl) to function'
+#endif
+! of #ifdef CPP_EARTH
       RETURN
       END
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/gcm.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/gcm.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/gcm.F	(revision 1222)
@@ -307,4 +307,6 @@
      .  ' 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,*)
@@ -324,4 +326,5 @@
       endif
 
+#ifdef CPP_IOIPSL
       mois = 1
       heure = 0.
@@ -330,7 +333,5 @@
       jD_ref = int(jD_ref)
 
-#ifdef CPP_IOIPSL
       call ioconf_startdate(annee_ref,1,day_ref, 0.)
-#endif
 
       write(lunout,*)'DEBUG'
@@ -340,4 +341,11 @@
       write(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
       write(lunout,*)jD_ref+jH_ref,an, mois, jour, heure
+#else
+! Ehouarn: we still need to define JD_ref and JH_ref
+! and since we don't know how many days there are in a year
+! we set JD_ref to 0 (this should be improved ...)
+      jD_ref=0
+      jH_ref=0
+#endif
 
 c  nombre d'etats dans les fichiers demarrage et histoire
@@ -413,4 +421,6 @@
       WRITE(lunout,300)day_ini,day_end
  300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
+
+#ifdef CPP_IOIPSL
       call ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
       write (lunout,301)jour, mois, an
@@ -419,9 +429,8 @@
  301  FORMAT('1'/,15x,'run du ', i2,'/',i2,'/',i4)
  302  FORMAT('1'/,15x,'    au ', i2,'/',i2,'/',i4)
+#endif
 
       if (planet_type.eq."earth") then
-#ifdef CPP_EARTH
-      CALL dynredem0("restart.nc", day_end, phis)
-#endif
+        CALL dynredem0("restart.nc", day_end, phis)
       endif
 
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/iniacademic.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/iniacademic.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/iniacademic.F	(revision 1222)
@@ -83,4 +83,6 @@
 c
         time_0=0.
+        day_ref=0
+	annee_ref=0
 
         im         = iim
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/integrd.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/integrd.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/integrd.F	(revision 1222)
@@ -1,4 +1,4 @@
 !
-! $Header$
+! $Id$
 !
       SUBROUTINE integrd
@@ -32,4 +32,5 @@
 #include "temps.h"
 #include "serre.h"
+#include "control.h"
 
 c   Arguments:
@@ -183,11 +184,15 @@
 c$$$      ENDIF
 
-         DO l = 1, llm
-          DO ij = 1, ip1jmp1
-           deltap(ij,l) =  p(ij,l) - p(ij,l+1) 
+	 if (planet_type.eq."earth") then
+! Earth-specific treatment of first 2 tracers (water)
+          DO l = 1, llm
+           DO ij = 1, ip1jmp1
+            deltap(ij,l) =  p(ij,l) - p(ij,l+1) 
+           ENDDO
           ENDDO
-         ENDDO
-
-         CALL qminimum( q, nq, deltap )
+
+          CALL qminimum( q, nq, deltap )
+	 endif ! of if (planet_type.eq."earth")
+
 c
 c    .....  Calcul de la valeur moyenne, unique  aux poles pour  q .....
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/leapfrog.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/leapfrog.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/leapfrog.F	(revision 1222)
@@ -597,9 +597,7 @@
 
               if (planet_type.eq."earth") then
-#ifdef CPP_EARTH
 ! Write an Earth-format restart file
                 CALL dynredem1("restart.nc",0.0,
      &                         vcov,ucov,teta,q,masse,ps)
-#endif
               endif ! of if (planet_type.eq."earth")
 
@@ -704,8 +702,6 @@
               IF(itau.EQ.itaufin) THEN
                 if (planet_type.eq."earth") then
-#ifdef CPP_EARTH
                   CALL dynredem1("restart.nc",0.0,
      &                           vcov,ucov,teta,q,masse,ps)
-#endif
                 endif ! of if (planet_type.eq."earth")
               ENDIF ! of IF(itau.EQ.itaufin)
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/limit_netcdf.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/limit_netcdf.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/limit_netcdf.F	(revision 1222)
@@ -1,8 +1,10 @@
 !
-! $Header$
+! $Id$
 !
 C
 C
       SUBROUTINE limit_netcdf(interbar, extrap, oldice, masque)
+#ifdef CPP_EARTH
+! This routine is designed to work for Earth
       USE dimphy
       use phys_state_var_mod , ONLY : pctsrf
@@ -33,4 +35,5 @@
 cy#include "dimphy.h"
 #include "indicesol.h"
+#include "iniprint.h"
 c
 c-----------------------------------------------------------------------
@@ -1323,4 +1326,9 @@
       ierr = NF_CLOSE(nid)
 c
+#else
+      WRITE(lunout,*)
+     & 'limit_netcdf: Earth-specific routine, needs Earth physics'
+#endif
+! of #ifdef CPP_EARTH
       STOP
       END
Index: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/startvar.F
===================================================================
--- LMDZ4/branches/LMDZ4-dev/libf/dyn3d/startvar.F	(revision 1220)
+++ LMDZ4/branches/LMDZ4-dev/libf/dyn3d/startvar.F	(revision 1222)
@@ -1,8 +1,8 @@
 !
-! $Header$
+! $Id$
 !
-C
-C
       MODULE startvar
+#ifdef CPP_EARTH
+! This module is designed to work for Earth (and with ioipsl)
     !
     !
@@ -1189,3 +1189,5 @@
       END SUBROUTINE start_inter_3d
     !
+#endif
+! of #ifdef CPP_EARTH
       END MODULE startvar
