<p><b>croesch@ucar.edu</b> 2011-10-26 16:13:47 -0600 (Wed, 26 Oct 2011)</p><p>TRUNK COMMIT<br>
<br>
Update all cores to write each restart frame to a unique restart file labeled by date/time<br>
</p><hr noshade><pre><font color="gray">Modified: trunk/mpas/src/core_hyd_atmos/mpas_atmh_mpas_core.F
===================================================================
--- trunk/mpas/src/core_hyd_atmos/mpas_atmh_mpas_core.F        2011-10-26 20:50:04 UTC (rev 1147)
+++ trunk/mpas/src/core_hyd_atmos/mpas_atmh_mpas_core.F        2011-10-26 22:13:47 UTC (rev 1148)
@@ -4,7 +4,6 @@
    use mpas_timekeeping
 
    type (io_output_object) :: restart_obj
-   integer :: restart_frame
 
    integer :: current_outfile_frames
 
@@ -48,7 +47,6 @@
          block =&gt; block % next
       end do
 
-      restart_frame = 1
       current_outfile_frames = 0
 
    end subroutine mpas_core_init
@@ -108,9 +106,11 @@
 
          if (mpas_is_alarm_ringing(clock, restartAlarmID, ierr=ierr)) then
             call mpas_reset_clock_alarm(clock, restartAlarmID, ierr=ierr)
-            if (restart_frame == 1) call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;)
-            call mpas_output_state_for_domain(restart_obj, domain, restart_frame)
-            restart_frame = restart_frame + 1
+
+            ! Write one restart time per file
+            call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;, trim(timeStamp))
+            call mpas_output_state_for_domain(restart_obj, domain, 1)
+            call mpas_output_state_finalize(restart_obj, domain % dminfo)
          end if
 
       end do
@@ -124,12 +124,9 @@
    
       implicit none
   
+      type (domain_type), intent(inout) :: domain 
       integer :: ierr
  
-      type (domain_type), intent(inout) :: domain 
-
-      if (restart_frame &gt; 1) call mpas_output_state_finalize(restart_obj, domain % dminfo)
-
       call mpas_destroy_clock(clock, ierr)
 
    end subroutine mpas_core_finalize

Modified: trunk/mpas/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- trunk/mpas/src/core_ocean/mpas_ocn_mpas_core.F        2011-10-26 20:50:04 UTC (rev 1147)
+++ trunk/mpas/src/core_ocean/mpas_ocn_mpas_core.F        2011-10-26 22:13:47 UTC (rev 1148)
@@ -24,7 +24,6 @@
    use ocn_vmix
 
    type (io_output_object) :: restart_obj
-   integer :: restart_frame
 
    integer :: current_outfile_frames
 
@@ -133,7 +132,6 @@
    !   call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;)
    !   call write_output_frame(output_obj, domain)
 
-      restart_frame = 1
       current_outfile_frames = 0
 
    end subroutine mpas_core_init!}}}
@@ -329,9 +327,11 @@
 
          if (mpas_is_alarm_ringing(clock, restartAlarmID, ierr=ierr)) then
             call mpas_reset_clock_alarm(clock, restartAlarmID, ierr=ierr)
-            if (restart_frame == 1) call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;)
-            call mpas_output_state_for_domain(restart_obj, domain, restart_frame)
-            restart_frame = restart_frame + 1
+
+            ! Write one restart time per file
+            call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;, trim(timeStamp))
+            call mpas_output_state_for_domain(restart_obj, domain, 1)
+            call mpas_output_state_finalize(restart_obj, domain % dminfo)
          end if
 
       end do
@@ -748,12 +748,9 @@
    
       implicit none
 
+      type (domain_type), intent(inout) :: domain 
       integer :: ierr
 
-      type (domain_type), intent(inout) :: domain 
-
-      if (restart_frame &gt; 1) call mpas_output_state_finalize(restart_obj, domain % dminfo)
-
       call mpas_destroy_clock(clock, ierr)
 
    end subroutine mpas_core_finalize!}}}

Modified: trunk/mpas/src/core_sw/mpas_sw_mpas_core.F
===================================================================
--- trunk/mpas/src/core_sw/mpas_sw_mpas_core.F        2011-10-26 20:50:04 UTC (rev 1147)
+++ trunk/mpas/src/core_sw/mpas_sw_mpas_core.F        2011-10-26 22:13:47 UTC (rev 1148)
@@ -4,7 +4,6 @@
    use mpas_timekeeping
 
    type (io_output_object) :: restart_obj
-   integer :: restart_frame
    integer :: current_outfile_frames
 
    type (MPAS_Clock_type) :: clock
@@ -46,7 +45,6 @@
          block =&gt; block % next
       end do
 
-      restart_frame = 1
       current_outfile_frames = 0
 
    end subroutine mpas_core_init
@@ -200,9 +198,11 @@
 
          if (mpas_is_alarm_ringing(clock, restartAlarmID, ierr=ierr)) then
             call mpas_reset_clock_alarm(clock, restartAlarmID, ierr=ierr)
-            if (restart_frame == 1) call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;)
-            call mpas_output_state_for_domain(restart_obj, domain, restart_frame)
-            restart_frame = restart_frame + 1
+
+            ! Write one restart time per file
+            call mpas_output_state_init(restart_obj, domain, &quot;RESTART&quot;, trim(timeStamp))
+            call mpas_output_state_for_domain(restart_obj, domain, 1)
+            call mpas_output_state_finalize(restart_obj, domain % dminfo)
          end if
 
       end do
@@ -337,14 +337,11 @@
    
       implicit none
 
+      type (domain_type), intent(inout) :: domain 
       integer :: ierr

+     call mpas_destroy_clock(clock, ierr)
 
-      type (domain_type), intent(inout) :: domain 
-
-      if (restart_frame &gt; 1) call mpas_output_state_finalize(restart_obj, domain % dminfo)
-
-      call mpas_destroy_clock(clock, ierr)
-
    end subroutine mpas_core_finalize
 
 

Modified: trunk/mpas/src/framework/mpas_io_input.F
===================================================================
--- trunk/mpas/src/framework/mpas_io_input.F        2011-10-26 20:50:04 UTC (rev 1147)
+++ trunk/mpas/src/framework/mpas_io_input.F        2011-10-26 22:13:47 UTC (rev 1148)
@@ -128,9 +128,17 @@
       type (MPAS_TimeInterval_type) :: timeDiff
       type (MPAS_TimeInterval_type) :: minTimeDiff
       character(len=32) :: timeStamp
+      character(len=1024) :: filename
 
       if (config_do_restart) then
-         input_obj % filename = trim(config_restart_name)
+
+         ! this get followed by set is to ensure that the time is in standard format
+         call mpas_set_time(curr_time=startTime, dateTimeString=config_start_time)
+         call mpas_get_time(curr_time=startTime, dateTimeString=timeStamp)
+
+         call mpas_insert_string_suffix(trim(config_restart_name), timeStamp, filename)
+
+         input_obj % filename = trim(filename)
          input_obj % stream = STREAM_RESTART
       else
          input_obj % filename = trim(config_input_name)
@@ -772,6 +780,12 @@
                end if
             end do
 
+            ! require restart time to exactly match start time (this error should never be reached as we have by this point opened the restart file with a name containing the startTime)
+            if(sliceTime /= startTime) then
+               write(0,*) &quot;Error: restart file &quot;, filename, &quot; did not contain time &quot;, config_start_time
+               call mpas_dmpar_abort(domain % dminfo)
+            end if
+
             timeStamp = xtime % array(input_obj % time)
 
             deallocate(xtime % ioinfo)
@@ -1004,6 +1018,29 @@
    end subroutine mpas_input_state_for_domain
 
 
+   !CR:TODO: an identical subroutine is found in module_io_output - merge
+   subroutine mpas_insert_string_suffix(stream, suffix, filename)
+
+      implicit none
+
+      character (len=*), intent(in) :: stream
+      character (len=*), intent(in) :: suffix
+      character (len=*), intent(out) :: filename
+      integer :: length, i
+
+      filename = trim(stream) // '.' // trim(suffix)
+
+      length = len_trim(stream)
+      do i=length-1,1,-1
+         if(stream(i:i) == '.') then
+            filename = trim(stream(:i)) // trim(suffix) // trim(stream(i:))
+            exit
+         end if
+      end do
+
+   end subroutine mpas_insert_string_suffix
+
+
    subroutine mpas_read_and_distribute_fields(dminfo, input_obj, block, &amp;
                                      readCellsStart, readCellsCount, &amp;
                                      readEdgesStart, readEdgesCount, &amp;

Modified: trunk/mpas/src/framework/mpas_io_output.F
===================================================================
--- trunk/mpas/src/framework/mpas_io_output.F        2011-10-26 20:50:04 UTC (rev 1147)
+++ trunk/mpas/src/framework/mpas_io_output.F        2011-10-26 22:13:47 UTC (rev 1148)
@@ -94,7 +94,12 @@
          output_obj % filename = trim(tempfilename)
          output_obj % stream = OUTPUT
       else if (trim(stream) == 'RESTART') then
-         output_obj % filename = trim(config_restart_name)
+         if(present(outputSuffix)) then
+            call mpas_insert_string_suffix(config_restart_name, outputSuffix, tempfilename)
+         else
+            tempfilename = config_restart_name
+         end if
+         output_obj % filename = trim(tempfilename)
          output_obj % stream = RESTART
       else if (trim(stream) == 'SFC') then
          ! Keep filename as whatever was set by the user

</font>
</pre>