Index: NEMO/branches/UKMO/r12083_restart_datestamp/cfgs/SHARED/namelist_ref
===================================================================
--- NEMO/branches/UKMO/r12083_restart_datestamp/cfgs/SHARED/namelist_ref	(revision 12466)
+++ NEMO/branches/UKMO/r12083_restart_datestamp/cfgs/SHARED/namelist_ref	(revision 12477)
@@ -42,4 +42,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/r12083_restart_datestamp/src/ICE/icerst.F90
===================================================================
--- NEMO/branches/UKMO/r12083_restart_datestamp/src/ICE/icerst.F90	(revision 12466)
+++ NEMO/branches/UKMO/r12083_restart_datestamp/src/ICE/icerst.F90	(revision 12477)
@@ -23,4 +23,5 @@
    USE in_out_manager ! I/O manager
    USE iom            ! I/O manager library
+   USE ioipsl  , ONLY : ju2ymds    ! for calendar
    USE lib_mpp        ! MPP library
    USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
@@ -46,4 +47,7 @@
       !! ** purpose  :   open restart file
       !!----------------------------------------------------------------------
+      INTEGER             ::   iyear, imonth, iday  
+      REAL (wp)           ::   zsec  
+      REAL (wp)           ::   zfjulday      !!
       INTEGER, INTENT(in) ::   kt       ! number of iteration
       !
@@ -63,6 +67,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/r12083_restart_datestamp/src/OCE/DOM/daymod.F90
===================================================================
--- NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/DOM/daymod.F90	(revision 12466)
+++ NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/DOM/daymod.F90	(revision 12477)
@@ -282,5 +282,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/r12083_restart_datestamp/src/OCE/DOM/domain.F90
===================================================================
--- NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/DOM/domain.F90	(revision 12466)
+++ NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/DOM/domain.F90	(revision 12477)
@@ -292,5 +292,5 @@
          &             nn_it000, nn_itend , nn_date0    , nn_time0     , nn_leapy  , nn_istate ,     &
          &             nn_stock, nn_write , ln_mskland  , ln_clobber   , nn_chunksz, nn_euler  ,     &
-         &             ln_cfmeta, ln_iscpl, ln_xios_read, nn_wxios
+         &             ln_cfmeta, ln_iscpl, ln_xios_read, nn_wxios     , ln_rstdate
       NAMELIST/namdom/ ln_linssh, rn_isfhmin, rn_rdt, rn_atfp, ln_crs, ln_meshmask
 #if defined key_netcdf4
@@ -323,4 +323,5 @@
          WRITE(numout,*) '      restart output directory        cn_ocerst_outdir= ', TRIM( 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/r12083_restart_datestamp/src/OCE/IOM/in_out_manager.F90
===================================================================
--- NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/IOM/in_out_manager.F90	(revision 12466)
+++ NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/IOM/in_out_manager.F90	(revision 12477)
@@ -78,4 +78,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/r12083_restart_datestamp/src/OCE/IOM/restart.F90
===================================================================
--- NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/IOM/restart.F90	(revision 12466)
+++ NEMO/branches/UKMO/r12083_restart_datestamp/src/OCE/IOM/restart.F90	(revision 12477)
@@ -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
    USE lib_mpp         ! distribued memory computing library
 
@@ -47,5 +49,5 @@
 CONTAINS
 
-   SUBROUTINE rst_opn( kt )
+   SUBROUTINE rst_opn( kt, ndastp )
       !!---------------------------------------------------------------------
       !!                   ***  ROUTINE rst_opn  ***
@@ -58,8 +60,12 @@
       !!----------------------------------------------------------------------
       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
       CHARACTER(LEN=52)   ::   clpname   ! ocean output restart file name including prefix for AGRIF
       CHARACTER(LEN=256)  ::   clinfo    ! info character
@@ -90,6 +96,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
Index: NEMO/branches/UKMO/r12083_restart_datestamp/src/TOP/trcrst.F90
===================================================================
--- NEMO/branches/UKMO/r12083_restart_datestamp/src/TOP/trcrst.F90	(revision 12466)
+++ NEMO/branches/UKMO/r12083_restart_datestamp/src/TOP/trcrst.F90	(revision 12477)
@@ -20,6 +20,10 @@
    !!----------------------------------------------------------------------
    USE oce_trc
+   USE dom_oce, ONLY: fjulday 
+   USE phycst, ONLY: rday 
+   USE in_out_manager, ONLY: ln_rstdate
    USE trc
    USE iom
+   USE ioipsl, ONLY: ju2ymds
    USE daymod
    USE lib_mpp
@@ -47,4 +51,7 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt       ! number of iteration
+      INTEGER             ::   iyear, imonth, iday 
+      REAL (wp)           ::   zsec 
+      REAL (wp)           ::   zfjulday
       !
       CHARACTER(LEN=20)   ::   clkt     ! ocean time-step define as a character
@@ -78,8 +85,15 @@
       ! we open and define the tracer restart file one tracer time step before writing the data (-> at nitrst - 2*nn_dttrc + 1)
       ! except if we write tracer restart files every tracer time step or if a tracer restart file was writen at nitend - 2*nn_dttrc + 1
-      IF( kt == nitrst - 2*nn_dttrc .OR. nn_stock == nn_dttrc .OR. ( kt == nitend - nn_dttrc .AND. .NOT. lrst_trc ) ) THEN
-         ! beware of the format used to write kt (default is i8.8, that should be large enough)
-         IF( nitrst > 1.0e9 ) THEN   ;   WRITE(clkt,*       ) nitrst
-         ELSE                        ;   WRITE(clkt,'(i8.8)') nitrst
+      IF( kt == nitrst - 2*nn_dttrc + 1 .OR. nstock == nn_dttrc .OR. ( kt == nitend - nn_dttrc .AND. .NOT. lrst_trc ) ) THEN 
+         if ( ln_rstdate ) THEN 
+            zfjulday = fjulday + rdttrc(1) / 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 
+            ! beware of the format used to write kt (default is i8.8, that should be large enough) 
+            IF( nitrst > 1.0e9 ) THEN   ;   WRITE(clkt,*       ) nitrst 
+            ELSE                        ;   WRITE(clkt,'(i8.8)') nitrst 
+            ENDIF
          ENDIF
          ! create the file
