Index: LMDZ4/trunk/libf/dyn3d/gcm.F
===================================================================
--- LMDZ4/trunk/libf/dyn3d/gcm.F	(revision 1147)
+++ LMDZ4/trunk/libf/dyn3d/gcm.F	(revision 1279)
@@ -1,2 +1,5 @@
+!
+! $Id$
+!
 c
 c
@@ -110,5 +113,4 @@
       real time_step, t_wrt, t_ops
 
-      REAL rdayvrai,rdaym_ini,rday_ecri
       LOGICAL first
 
@@ -132,8 +134,8 @@
       character (len=20) :: modname
       character (len=80) :: abort_message
-
-C Calendrier
-      LOGICAL true_calendar
-      PARAMETER (true_calendar = .false.)
+! locales pour gestion du temps
+      INTEGER :: an, mois, jour
+      REAL :: heure
+
 
 c-----------------------------------------------------------------------
@@ -160,15 +162,4 @@
 
 
-c-----------------------------------------------------------------------
-c   Choix du calendrier
-c   -------------------
-
-#ifdef CPP_IOIPSL
-      if (true_calendar) then
-        call ioconf_calendar('gregorian')
-      else
-        call ioconf_calendar('360d')
-      endif
-#endif
 c----------------------------------------------------------------------
 c  lecture des fichiers gcm.def ou run.def
@@ -194,4 +185,26 @@
       endif
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+c-----------------------------------------------------------------------
+c   Choix du calendrier
+c   -------------------
+
+c      calend = 'earth_365d'
+
+#ifdef CPP_IOIPSL
+      if (calend == 'earth_360d') then
+        call ioconf_calendar('360d')
+        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 == 'earth_366d') 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
+#endif
+c-----------------------------------------------------------------------
 
       IF (config_inca /= 'none') THEN
@@ -294,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,*)
@@ -310,8 +325,27 @@
         raz_date = 0
       endif
+
 #ifdef CPP_IOIPSL
-      call ioconf_startdate(annee_ref,0,day_ref, 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
+#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
@@ -388,8 +422,15 @@
  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
+      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)
+#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
 
@@ -401,13 +442,13 @@
       t_ops = iecri * daysec
       t_wrt = iecri * daysec
-      CALL inithist(dynhist_file,day_ref,annee_ref,time_step,
-     .              t_ops, t_wrt, histid, histvid)
-
-      IF (ok_dynzon) THEN 
-         t_ops = iperiod * time_step
-         t_wrt = periodav * daysec
-         CALL initdynav(dynhistave_file,day_ref,annee_ref,time_step,
-     .        t_ops, t_wrt, histaveid)
-      END IF
+!      CALL inithist(dynhist_file,day_ref,annee_ref,time_step,
+!    .              t_ops, t_wrt, histid, histvid)
+
+!     IF (ok_dynzon) THEN 
+!        t_ops = iperiod * time_step
+!        t_wrt = periodav * daysec
+!        CALL initdynav(dynhistave_file,day_ref,annee_ref,time_step,
+!    .        t_ops, t_wrt, histaveid)
+!     END IF
       dtav = iperiod*dtvr/daysec
       endif
