Index: branches/UKMO/CO6_KD490/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90
===================================================================
--- branches/UKMO/CO6_KD490/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90	(revision 6610)
+++ branches/UKMO/CO6_KD490/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90	(revision 6939)
@@ -21,6 +21,6 @@
    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 ioipsl, ONLY : ju2ymds    ! for calendar 
    USE netcdf         ! netcdf routines for IO
    USE icb_oce        ! define iceberg arrays
@@ -66,6 +66,6 @@
                                                                                             ! start and count arrays
       LOGICAL                      ::   ll_found_restart
-      CHARACTER(len=256)  :: cl_path 
-      CHARACTER(len=256)  :: cl_filename 
+      CHARACTER(len=256)           ::   cl_path
+      CHARACTER(len=256)           ::   cl_filename
       CHARACTER(len=NF90_MAX_NAME) ::   cl_dname
       TYPE(iceberg)                ::   localberg ! NOT a pointer but an actual local variable
@@ -233,10 +233,9 @@
       INTEGER ::   jn   ! dummy loop index
       INTEGER ::   ix_dim, iy_dim, ik_dim, in_dim
-      CHARACTER(len=256)     :: cl_path
-      CHARACTER(len=256)     :: cl_filename
-      INTEGER             ::   iyear, imonth, iday 
-      REAL (wp)           ::   zsec 
-      CHARACTER(len=256)  :: cl_path 
-      CHARACTER(len=256)  :: cl_filename 
+      INTEGER             ::   iyear, imonth, iday
+      REAL (wp)           ::   zsec
+      REAL (wp)           ::   zfjulday
+      CHARACTER(len=256)  :: cl_path
+      CHARACTER(len=256)  :: cl_filename
       CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
       TYPE(iceberg), POINTER :: this
@@ -247,16 +246,18 @@
       cl_path = TRIM(cn_ocerst_outdir)
       IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/'
-      IF ( ln_rstdate ) THEN 
-         CALL ju2ymds( fjulday + rdttra(1) / rday, 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 ( ln_rstdate ) THEN
+         zfjulday = fjulday + rdttra(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
+         IF( kt > 999999999 ) THEN   ;   WRITE(clkt, *       ) kt
+         ELSE                        ;   WRITE(clkt, '(i8.8)') kt
+         ENDIF
+      ENDIF
       IF( lk_mpp ) THEN
-         WRITE(cl_filename,'(A,"_icebergs_",A,"_restart_",I4.4,".nc")') TRIM(cexper), TRIM(ADJUSTL(clkt)), 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_",A,"_restart.nc")') TRIM(cexper), TRIM(ADJUSTL(clkt)) 
+         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: branches/UKMO/CO6_KD490/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- branches/UKMO/CO6_KD490/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 6610)
+++ branches/UKMO/CO6_KD490/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 6939)
@@ -55,6 +55,7 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt     ! ocean time-step
-      INTEGER             ::   iyear, imonth, iday 
-      REAL (wp)           ::   zsec 
+      INTEGER             ::   iyear, imonth, iday
+      REAL (wp)           ::   zsec
+      REAL (wp)           ::   zfjulday
       !!
       CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character
@@ -84,12 +85,14 @@
       IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
          IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
-            IF ( ln_rstdate ) THEN 
-              CALL ju2ymds( fjulday + rdttra(1) / rday, 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 > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst 
-              ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst 
-              ENDIF 
+            IF ( ln_rstdate ) THEN
+               zfjulday = fjulday + rdttra(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 > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
+               ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
+               ENDIF
             ENDIF
             ! create the file
