Index: /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 10764)
+++ /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 10765)
@@ -34,4 +34,5 @@
    nn_leapy    =       0   !  Leap year calendar (1) or not (0)
    ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   ln_rstdate  = .false.   !  add a datestamp in the restart file name
       nn_euler    =    1            !  = 0 : start with forward time step if ln_rstart=T
       nn_rstctl   =    0            !  restart control ==> activated only if ln_rstart=T
Index: /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90
===================================================================
--- /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 10764)
+++ /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/LIM_SRC_3/limrst.F90	(revision 10765)
@@ -22,4 +22,5 @@
    USE sbc_ice        ! Surface boundary condition: ice fields
    USE in_out_manager ! I/O manager
+   USE ioipsl  , ONLY : ju2ymds    ! for calendar
    USE iom            ! I/O library
    USE lib_mpp        ! MPP library
@@ -51,4 +52,7 @@
       !! ** purpose  :   output of sea-ice variable in a netcdf file
       !!----------------------------------------------------------------------
+      INTEGER             ::   iyear, imonth, iday 
+      REAL (wp)           ::   zsec 
+      REAL (wp)           ::   zfjulday      !!
       INTEGER, INTENT(in) ::   kt       ! number of iteration
       !
@@ -67,6 +71,15 @@
          IF( nitrst <= nitend .AND. nitrst > 0 ) THEN
             ! beware of the format used to write kt (default is i8.8, that should be large enough...)
-            IF( nitrst > 99999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
-            ELSE                           ;   WRITE(clkt, '(i8.8)') nitrst
+            IF ( ln_rstdate ) THEN 
+               zfjulday = fjulday + rdt / rday 
+               IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday )   zfjulday = REAL(NINT(zfjulday),wp)   ! avoid truncation error 
+               CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec )            
+               WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday  
+            ELSE 
+              IF( nitrst > 999999999 ) THEN    
+                WRITE(clkt, *       ) nitrst 
+              ELSE               
+                WRITE(clkt, '(i8.8)') nitrst 
+              ENDIF
             ENDIF
             ! create the file
Index: /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
===================================================================
--- /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 10764)
+++ /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 10765)
@@ -274,5 +274,5 @@
       ENDIF
 
-      IF( .NOT. l_offline ) CALL rst_opn( kt )               ! Open the restart file if needed and control lrst_oce
+      IF( .NOT. l_offline ) CALL rst_opn( kt, ndastp )        ! Open the restart file if needed and control lrst_oce
       IF( lrst_oce         ) CALL day_rst( kt, 'WRITE' )      ! write day restart information
       !
Index: /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 10764)
+++ /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 10765)
@@ -281,5 +281,5 @@
       !!----------------------------------------------------------------------
       USE ioipsl
-      NAMELIST/namrun/ cn_ocerst_indir, cn_ocerst_outdir, nn_stocklist, ln_rst_list,                 &
+      NAMELIST/namrun/ cn_ocerst_indir, cn_ocerst_outdir, nn_stocklist, ln_rst_list, ln_rstdate,     &
          &             nn_no   , cn_exp   , cn_ocerst_in, cn_ocerst_out, ln_rstart , nn_rstctl ,     &
          &             nn_it000, nn_itend , nn_date0    , nn_time0     , nn_leapy  , nn_istate ,     &
@@ -314,4 +314,5 @@
          WRITE(numout,*) '      restart output directory        cn_ocerst_outdir= ', cn_ocerst_outdir
          WRITE(numout,*) '      restart logical                 ln_rstart  = ', ln_rstart
+         WRITE(numout,*) '           use date in restart name     ln_rstdate   = ', ln_rstdate
          WRITE(numout,*) '      start with forward time step    nn_euler   = ', nn_euler
          WRITE(numout,*) '      control of time step            nn_rstctl  = ', nn_rstctl
Index: /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90
===================================================================
--- /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90	(revision 10764)
+++ /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90	(revision 10765)
@@ -20,6 +20,8 @@
    !!----------------------------------------------------------------------
    USE par_oce        ! NEMO parameters
+   USE phycst         ! for rday
    USE dom_oce        ! NEMO domain
    USE in_out_manager ! NEMO IO routines
+   USE ioipsl, ONLY : ju2ymds    ! for calendar
    USE lib_mpp        ! NEMO MPI library, lk_mpp in particular
    USE netcdf         ! netcdf routines for IO
@@ -161,4 +163,8 @@
       CHARACTER(len=256)     :: cl_filename
       TYPE(iceberg), POINTER :: this
+      INTEGER                :: iyear, imonth, iday 
+      REAL (wp)              :: zsec 
+      REAL (wp)              :: zfjulday 
+      CHARACTER(LEN=20)      :: clkt     ! ocean time-step define as a character      TYPE(iceberg), POINTER :: this
       TYPE(point)  , POINTER :: pt
       !!----------------------------------------------------------------------
@@ -167,8 +173,19 @@
       cl_path = TRIM(cn_ocerst_outdir)
       IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/'
+      IF ( ln_rstdate ) THEN 
+         zfjulday = fjulday + rdt / rday 
+         IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday )   zfjulday = REAL(NINT(zfjulday),wp)   ! avoid truncation error 
+         CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec )            
+         WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday 
+      ELSE 
+         IF( kt > 999999999 ) THEN   ;   WRITE(clkt, *       ) kt 
+         ELSE                        ;   WRITE(clkt, '(i8.8)') kt 
+         ENDIF 
+      ENDIF
+
       IF( lk_mpp ) THEN
-         WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart_",I4.4,".nc")') TRIM(cexper), kt, narea-1
+         WRITE(cl_filename,'(A,"_icebergs_",A,"_restart_",I4.4,".nc")') TRIM(cexper), TRIM(ADJUSTL(clkt)), narea-1
       ELSE
-         WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart.nc")') TRIM(cexper), kt
+         WRITE(cl_filename,'(A,"_icebergs_",A,"_restart.nc")') TRIM(cexper), TRIM(ADJUSTL(clkt))
       ENDIF
       IF (nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ',TRIM(cl_path)//TRIM(cl_filename)
Index: /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 10764)
+++ /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 10765)
@@ -77,4 +77,5 @@
    INTEGER       ::   nitend                      !: index of the last time step
    INTEGER       ::   ndate0                      !: initial calendar date aammjj
+   LOGICAL       ::   ln_rstdate = .FALSE.        !: Use calendar date rather than time-step in restart
    INTEGER       ::   nleapy                      !: Leap year calendar flag (0/1 or 30)
    INTEGER       ::   ninist                      !: initial state output flag (0/1)
Index: /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 10764)
+++ /NEMO/branches/UKMO/r8395_restart_datestamp/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 10765)
@@ -27,5 +27,7 @@
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O module
+   USE ioipsl, ONLY : ju2ymds    ! for calendar
    USE diurnal_bulk
+   USE sbc_oce         ! for icesheet freshwater input variables
    
    IMPLICIT NONE
@@ -46,5 +48,5 @@
 CONTAINS
 
-   SUBROUTINE rst_opn( kt )
+   SUBROUTINE rst_opn( kt, ndastp )
       !!---------------------------------------------------------------------
       !!                   ***  ROUTINE rst_opn  ***
@@ -57,8 +59,13 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      INTEGER, INTENT(in) ::   ndastp ! ocean date
       !!
+
+      INTEGER             ::   iyear, imonth, iday 
+      REAL (wp)           ::   zsec 
+      REAL (wp)           ::   zfjulday      !!
       CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
       CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
-      CHARACTER(lc)       ::   clpath   ! full path to ocean output restart file
+      CHARACTER(LEN=150)  ::   clpath   ! full path to ocean output restart file
       !!----------------------------------------------------------------------
       !
@@ -85,6 +92,15 @@
          IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
             ! beware of the format used to write kt (default is i8.8, that should be large enough...)
-            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
-            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+            IF ( ln_rstdate ) THEN 
+               zfjulday = fjulday + rdt / rday 
+               IF( ABS(zfjulday - REAL(NINT(zfjulday),wp)) < 0.1 / rday )   zfjulday = REAL(NINT(zfjulday),wp)   ! avoid truncation error 
+               CALL ju2ymds( zfjulday, iyear, imonth, iday, zsec )            
+               WRITE(clkt, '(i4.4,2i2.2)') iyear, imonth, iday  
+            ELSE 
+               IF( nitrst > 999999999 ) THEN    
+                  WRITE(clkt, *       ) nitrst 
+               ELSE               
+                  WRITE(clkt, '(i8.8)') nitrst 
+               ENDIF
             ENDIF
             ! create the file
