Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 5872)
@@ -29,5 +29,5 @@
    nn_itend    =    5475   !  last  time step (std 5475)
    nn_date0    =  010101   !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
-   nn_time0    =       0   !  initial time of day in hours
+   nn_time0    =       0   !  initial time of day in hhmm
    nn_leapy    =       0   !  Leap year calendar (1) or not (0)
    ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 5872)
@@ -11,5 +11,6 @@
    !!             -   ! 2010-05  (D. Lea)  add calc_month_len routine based on day_init 
    !!            3.4  ! 2012-10  (A. Weaver and K. Mogensen) Fix for direct initialization
-   !!                 ! 2014-09  (D. Lea)  local calc_date removed use routine from OBS
+   !!                 ! 2014-09  (D. Lea)  Local calc_date removed use routine from OBS
+   !!                 ! 2015-11  (D. Lea)  Handle non-zero initial time of day
    !!----------------------------------------------------------------------
 
@@ -378,5 +379,5 @@
          ENDIF
 
-         IF (     ( z_inc_dateb < ndastp + nn_time0*0.01_wp ) &
+         IF (     ( z_inc_dateb < ndastp + nn_time0*0.0001_wp ) &
             & .OR.( z_inc_datef > ditend_date ) ) &
             & CALL ctl_warn( ' Validity time of assimilation increments is ', &
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90	(revision 5872)
@@ -11,4 +11,5 @@
    !!                 ! 2004-01  (A.M. Treguier) new calculation based on adatrj
    !!                 ! 2006-08  (G. Madec)  surface module major update
+   !!                 ! 2015-11  (D. Lea) Allow non-zero initial time of day
    !!----------------------------------------------------------------------
 
@@ -90,5 +91,8 @@
       nday    =   ndastp - (nyear * 10000) - ( nmonth * 100 )
 
-      CALL ymds2ju( nyear, nmonth, nday, nn_time0*3600._wp, fjulday )  
+      nhour   =   nn_time0 / 100
+      nminute = ( nn_time0 - nhour * 100 )
+
+      CALL ymds2ju( nyear, nmonth, nday, nhour*3600._wp+nminute*60._wp, fjulday )  
       IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < 0.1 / rday )   fjulday = REAL(NINT(fjulday),wp)   ! avoid truncation error
       IF( nn_time0*3600 - ndt05 .lt. 0 ) fjulday = fjulday + 1.                    ! move back to the day at nit000 (and not at nit000 - 1)
@@ -118,15 +122,15 @@
 
       ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step
-      IF (nn_time0*3600-ndt05 .gt. 0) THEN
+      IF (nhour*3600+nminute*60-ndt05 .gt. 0) THEN
          ! 1 timestep before current middle of first time step is still the same day
-         nsec_year  = (nday_year-1) * nsecd + nn_time0*3600._wp - ndt05 
-         nsec_month = (nday-1)      * nsecd + nn_time0*3600._wp - ndt05    
+         nsec_year  = (nday_year-1) * nsecd + nhour*3600+nminute*60 - ndt05 
+         nsec_month = (nday-1)      * nsecd + nhour*3600+nminute*60 - ndt05    
       ELSE
          ! 1 time step before the middle of the first time step is the previous day 
-         nsec_year  = nday_year * nsecd + nn_time0*3600._wp - ndt05 
-         nsec_month = nday      * nsecd + nn_time0*3600._wp - ndt05   
-      ENDIF
-      nsec_week  = idweek    * nsecd + nn_time0*3600._wp - ndt05
-      nsec_day   =             nn_time0*3600._wp - ndt05 
+         nsec_year  = nday_year * nsecd + nhour*3600+nminute*60 - ndt05 
+         nsec_month = nday      * nsecd + nhour*3600+nminute*60 - ndt05   
+      ENDIF
+      nsec_week  = idweek    * nsecd + nhour*3600+nminute*60 - ndt05
+      nsec_day   =             nhour*3600+nminute*60 - ndt05 
       IF( nsec_day .lt. 0 ) nsec_day = nsec_day + nsecd
       IF( nsec_week .lt. 0 ) nsec_week = nsec_week + nsecd*7
@@ -313,5 +317,6 @@
       CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
       !
-      REAL(wp) ::   zkt, zndastp
+      REAL(wp) ::   zkt, zndastp, zdayfrac, ksecs, ktime
+      INTEGER  ::   ihour, iminute
       !!----------------------------------------------------------------------
 
@@ -342,8 +347,34 @@
                ndastp = NINT( zndastp )
                CALL iom_get( numror, 'adatrj', adatrj  )
+	       CALL iom_get( numror, 'ntime', ktime )
+	       nn_time0=INT(ktime)
+               ! calculate start time in hours and minutes
+	       zdayfrac=adatrj-INT(adatrj)
+	       ksecs = NINT(zdayfrac*86400)	       ! Nearest second to catch rounding errors in adatrj	       
+	       ihour = INT(ksecs/3600)
+	       iminute = ksecs/60-ihour*60
+ 	        
+               ! Add to nn_time0
+               nhour   =   nn_time0 / 100
+               nminute = ( nn_time0 - nhour * 100 )
+	       nminute=nminute+iminute
+	       
+	       IF( nminute >= 60 ) THEN
+	          nminute=nminute-60
+		  nhour=nhour+1
+	       ENDIF
+	       nhour=nhour+ihour
+	       IF( nhour >= 24 ) THEN
+		  nhour=nhour-24
+	          adatrj=adatrj+1
+	       ENDIF	       
+	       nn_time0 = nhour * 100 + nminute
+	       adatrj = INT(adatrj)                    ! adatrj set to integer as nn_time0 updated	       
             ELSE
                ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day)
                ndastp = ndate0        ! ndate0 read in the namelist in dom_nam
-               IF( nn_time0*3600-ndt05 .lt. 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0)
+               nhour   =   nn_time0 / 100
+               nminute = ( nn_time0 - nhour * 100 )
+               IF( nhour*3600+nminute*60-ndt05 .lt. 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0)
                adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday
                ! note this is wrong if time step has changed during run
@@ -352,5 +383,7 @@
             ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day)
             ndastp = ndate0           ! ndate0 read in the namelist in dom_nam
-            IF( nn_time0*3600-ndt05 .lt. 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0)
+            nhour   =   nn_time0 / 100
+	    nminute = ( nn_time0 - nhour * 100 )
+            IF( nhour*3600+nminute*60-ndt05 .lt. 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0)
             adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday
          ENDIF
@@ -361,4 +394,5 @@
             WRITE(numout,*) '   date ndastp                                      : ', ndastp
             WRITE(numout,*) '   number of elapsed days since the begining of run : ', adatrj
+	    WRITE(numout,*) '   nn_time0                                         : ',nn_time0
             WRITE(numout,*)
          ENDIF
@@ -376,4 +410,5 @@
          CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj            )   ! number of elapsed days since
          !                                                                     ! the begining of the run [s]
+	 CALL iom_rstput( kt, nitrst, numrow, 'ntime'  , REAL( nn_time0, wp) ) ! time
       ENDIF
       !
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 5872)
@@ -276,4 +276,6 @@
    INTEGER , PUBLIC ::   nmonth        !: current month
    INTEGER , PUBLIC ::   nday          !: current day of the month
+   INTEGER , PUBLIC ::   nhour         !: current hour
+   INTEGER , PUBLIC ::   nminute       !: current minute
    INTEGER , PUBLIC ::   ndastp        !: time step date in yyyymmdd format
    INTEGER , PUBLIC ::   nday_year     !: current day counted from jan 1st of the current year
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 5872)
@@ -177,5 +177,5 @@
          WRITE(numout,*) '      number of the last time step    nn_itend   = ', nn_itend
          WRITE(numout,*) '      initial calendar date aammjj    nn_date0   = ', nn_date0
-         WRITE(numout,*) '      initial time of day in hours    nn_time0   = ', nn_time0
+         WRITE(numout,*) '      initial time of day in hhmm     nn_time0   = ', nn_time0
          WRITE(numout,*) '      leap year calendar (0/1)        nn_leapy   = ', nn_leapy
          WRITE(numout,*) '      initial state output            nn_istate  = ', nn_istate
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90	(revision 5872)
@@ -34,5 +34,5 @@
    INTEGER       ::   nn_itend         !: index of the last time step
    INTEGER       ::   nn_date0         !: initial calendar date aammjj
-   INTEGER       ::   nn_time0         !: initial time of day in hours
+   INTEGER       ::   nn_time0         !: initial time of day in hhmm
    INTEGER       ::   nn_leapy         !: Leap year calendar flag (0/1 or 30)
    INTEGER       ::   nn_istate        !: initial state output flag (0/1)
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90	(revision 5872)
@@ -1452,5 +1452,5 @@
       !!        !  06-10  (G. Smith) Calculates initial date the same as method for final date
       !!        !  10-05  (D. Lea) Update to month length calculation for NEMO vn3.2
-      !!        !  2014-09  (D. Lea) New generic routine now deals with arbitrary start hour 
+      !!        !  2014-09  (D. Lea) New generic routine now deals with arbitrary initial time of day
       !!----------------------------------------------------------------------
       USE phycst, ONLY : &            ! Physical constants
@@ -1484,6 +1484,6 @@
       imon = ( ndate0 - iyea * 10000 ) / 100
       iday =   ndate0 - iyea * 10000 - imon * 100
-      ihou = nn_time0
-      imin = 0
+      ihou =   nn_time0 / 100
+      imin = ( nn_time0 - ihou * 100 ) 
 
       !!----------------------------------------------------------------------
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90	(revision 5872)
@@ -125,6 +125,6 @@
       imon0 = ( ndate0 - iyea0 * 10000 ) / 100
       iday0 =   ndate0 - iyea0 * 10000 - imon0 * 100
-      ihou0 = nn_time0
-      imin0 = 0
+      ihou0 =   nn_time0 / 100
+      imin0 = ( nn_time0 - ihou0 * 100 )
 
       icycle = no     ! Assimilation cycle
@@ -397,6 +397,6 @@
       imon0 = ( ndate0 - iyea0 * 10000 ) / 100
       iday0 =   ndate0 - iyea0 * 10000 - imon0 * 100
-      ihou0 = nn_time0
-      imin0 = 0
+      ihou0 =   nn_time0 / 100
+      imin0 = ( nn_time0 - ihou0 * 100 )
 
       icycle = no     ! Assimilation cycle
@@ -585,6 +585,6 @@
       imon0 = ( ndate0 - iyea0 * 10000 ) / 100
       iday0 =   ndate0 - iyea0 * 10000 - imon0 * 100
-      ihou0 = nn_time0
-      imin0 = 0
+      ihou0 =   nn_time0 / 100
+      imin0 = ( nn_time0 - ihou0 * 100 )
 
       icycle = no     ! Assimilation cycle
@@ -770,6 +770,6 @@
       imon0 = ( ndate0 - iyea0 * 10000 ) / 100
       iday0 =   ndate0 - iyea0 * 10000 - imon0 * 100
-      ihou0 = nn_time0
-      imin0 = 0
+      ihou0 =   nn_time0 / 100
+      imin0 = ( nn_time0 - ihou0 * 100 )
 
       icycle = no     ! Assimilation cycle
@@ -968,6 +968,6 @@
       imon0 = ( ndate0 - iyea0 * 10000 ) / 100
       iday0 =   ndate0 - iyea0 * 10000 - imon0 * 100
-      ihou0 = nn_time0
-      imin0 = 0
+      ihou0 =   nn_time0 / 100
+      imin0 = ( nn_time0 - ihou0 * 100 )
 
       icycle = no     ! Assimilation cycle
Index: /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/SETTE/sette.sh
===================================================================
--- /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/SETTE/sette.sh	(revision 5871)
+++ /branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/SETTE/sette.sh	(revision 5872)
@@ -637,4 +637,7 @@
     ## Restartability tests for ORCA2_LIM3
     export TEST_NAME="LONG"
+    NUMTS=150
+    NUMTSD2=$(( NUMTS/2 ))
+    NUMTSD2_STR=$(printf "%08d" $NUMTSD2)
     cd ${CONFIG_DIR}
     . ./makenemo -m ${CMP_NAM} -n ORCA2LIM3_LONG -r ORCA2_LIM3 -j 8 del_key ${DEL_KEYS}
@@ -649,6 +652,6 @@
     set_namelist namelist_cfg cn_exp \"O2L3_LONG\"
     set_namelist namelist_cfg nn_it000 1
-    set_namelist namelist_cfg nn_itend 150
-    set_namelist namelist_cfg nn_stock 75
+    set_namelist namelist_cfg nn_itend $NUMTS
+    set_namelist namelist_cfg nn_stock $NUMTSD2
     set_namelist namelist_cfg ln_clobber .true.
     set_namelist namelist_cfg nn_fwb 0
@@ -670,7 +673,7 @@
     cd ${EXE_DIR}
     set_namelist namelist_cfg cn_exp \"O2L3_SHORT\"
-    set_namelist namelist_cfg nn_it000 76
-    set_namelist namelist_cfg nn_itend 150
-    set_namelist namelist_cfg nn_stock 75
+    set_namelist namelist_cfg nn_it000 $(( NUMTSD2+1 ))
+    set_namelist namelist_cfg nn_itend $NUMTS
+    set_namelist namelist_cfg nn_stock $NUMTSD2
     set_namelist namelist_cfg ln_rstart .true.
     set_namelist namelist_cfg nn_rstctl 2
@@ -681,11 +684,11 @@
     set_namelist namelist_cfg jpnij 4
     set_namelist namelist_cfg nn_solv 2
-    set_namelist namelist_cfg cn_ocerst_in \"O2L3_LONG_00000075_restart\"
-    set_namelist namelist_ice_cfg cn_icerst_in \"O2L3_LONG_00000075_restart_ice\"
+    set_namelist namelist_cfg cn_ocerst_in \"O2L3_LONG_${NUMTSD2_STR}_restart\"
+    set_namelist namelist_ice_cfg cn_icerst_in \"O2L3_LONG_${NUMTSD2_STR}_restart_ice\"
     for (( i=1; i<=$NPROC; i++)) ; do
         L_NPROC=$(( $i - 1 ))
         L_NPROC=`printf "%04d\n" ${L_NPROC}`
-        ln -sf ../LONG/O2L3_LONG_00000075_restart_${L_NPROC}.nc .
-        ln -sf ../LONG/O2L3_LONG_00000075_restart_ice_${L_NPROC}.nc .
+        ln -sf ../LONG/O2L3_LONG_${NUMTSD2_STR}_restart_${L_NPROC}.nc .
+        ln -sf ../LONG/O2L3_LONG_${NUMTSD2_STR}_restart_ice_${L_NPROC}.nc .
     done
     if [ ${USING_MPMD} == "yes" ] ; then
@@ -764,4 +767,7 @@
     ## Restartability tests for AMM12
     export TEST_NAME="LONG"
+    NUMTS=576
+    NUMTSD2=$(( numts/2 ))
+    NUMTSD2_STR=$(printf "%08d" $NUMTSD2)
     cd ${CONFIG_DIR}
     . ./makenemo -m ${CMP_NAM} -n AMM12_LONG -r AMM12 -j 8 add_key "key_tide" del_key ${DEL_KEYS}
@@ -775,6 +781,6 @@
     cd ${EXE_DIR}
     set_namelist namelist_cfg nn_it000 1
-    set_namelist namelist_cfg nn_itend 576
-    set_namelist namelist_cfg nn_stock 288
+    set_namelist namelist_cfg nn_itend $NUMTS
+    set_namelist namelist_cfg nn_stock $NUMTSD2
     set_namelist namelist_cfg nn_fwb 0
     set_namelist namelist_cfg ln_ctl .false.
@@ -795,6 +801,6 @@
     . ./prepare_exe_dir.sh
     cd ${EXE_DIR}
-    set_namelist namelist_cfg nn_it000 289
-    set_namelist namelist_cfg nn_itend 576
+    set_namelist namelist_cfg nn_it000 $(( NUMTSD2+1 ))
+    set_namelist namelist_cfg nn_itend $NUMTS
     set_namelist namelist_cfg nn_fwb 0
     set_namelist namelist_cfg ln_ctl .false.
@@ -805,10 +811,10 @@
     set_namelist namelist_cfg ln_rstart .true.
     set_namelist namelist_cfg nn_rstctl 2
-    set_namelist namelist_cfg cn_ocerst_in \"AMM12_00000288_restart_oce_out\"
+    set_namelist namelist_cfg cn_ocerst_in \"AMM12_${NUMTSD2_STR}_restart_oce_out\"
     set_namelist namelist_cfg nn_date0 20120102
     for (( i=1; i<=$NPROC; i++)) ; do
         L_NPROC=$(( $i - 1 ))
         L_NPROC=`printf "%04d\n" ${L_NPROC}`
-        ln -sf ../LONG/AMM12_00000288_restart_oce_out_${L_NPROC}.nc .
+        ln -sf ../LONG/AMM12_${NUMTSD2_STR}_restart_oce_out_${L_NPROC}.nc .
     done
     if [ ${USING_MPMD} == "yes" ] ; then
