<p><b>mpetersen@lanl.gov</b> 2012-05-14 16:34:03 -0600 (Mon, 14 May 2012)</p><p>BRANCH COMMIT: Add logic so that mpas_output_state_finalize is called for all output files that are opened.  This was tested by compiling with all cores.  Functionality was tested using the ocean core 120km global, and the first output file was not written, when config_write_initial_output = .false., as expected (test p90w).<br>
</p><hr noshade><pre><font color="gray">Modified: branches/ocean_projects/first_output_optional/src/core_hyd_atmos/mpas_atmh_mpas_core.F
===================================================================
--- branches/ocean_projects/first_output_optional/src/core_hyd_atmos/mpas_atmh_mpas_core.F        2012-05-14 21:26:59 UTC (rev 1909)
+++ branches/ocean_projects/first_output_optional/src/core_hyd_atmos/mpas_atmh_mpas_core.F        2012-05-14 22:34:03 UTC (rev 1910)
@@ -72,6 +72,7 @@
       type (MPAS_Time_Type) :: currTime
       character(len=StrKIND) :: timeStamp
       integer :: ierr
+      logical :: first_output
    
       ! Eventually, dt should be domain specific
       dt = config_dt
@@ -86,6 +87,7 @@
    
       ! During integration, time level 1 stores the model state at the beginning of the
       !   time step, and time level 2 stores the state advanced dt in time by timestep(...)
+      first_output = .true.
       do while (.not. mpas_is_clock_stop_time(clock))
 
          call mpas_advance_clock(clock)
@@ -105,7 +107,7 @@
             call mpas_reset_clock_alarm(clock, outputAlarmID, ierr=ierr)
             ! output_frame will always be &gt; 1 here unless it was reset after the maximum number of frames per outfile was reached
             if(output_frame == 1) then
-               if (config_write_initial_output) then
+               if (config_write_initial_output.or.(.not.first_output)) then
                   call mpas_output_state_finalize(output_obj, domain % dminfo)
                end if
                call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp)) 

Modified: branches/ocean_projects/first_output_optional/src/core_nhyd_atmos/mpas_atm_mpas_core.F
===================================================================
--- branches/ocean_projects/first_output_optional/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2012-05-14 21:26:59 UTC (rev 1909)
+++ branches/ocean_projects/first_output_optional/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2012-05-14 22:34:03 UTC (rev 1910)
@@ -245,6 +245,7 @@
       character(len=StrKIND) :: timeStamp
       integer :: itimestep
       integer :: ierr
+      logical :: first_output
 
       ! Eventually, dt should be domain specific
       dt = config_dt
@@ -256,6 +257,7 @@
       ! During integration, time level 1 stores the model state at the beginning of the
       !   time step, and time level 2 stores the state advanced dt in time by timestep(...)
       itimestep = 1
+      first_output = .true.
       do while (.not. mpas_is_clock_stop_time(clock))
 
          currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
@@ -289,7 +291,7 @@
             call mpas_reset_clock_alarm(clock, outputAlarmID, ierr=ierr)
             ! output_frame will always be &gt; 1 here unless it was reset after the maximum number of frames per outfile was reached
             if(output_frame == 1) then
-               if (config_write_initial_output) then
+               if (config_write_initial_output.or.(.not.first_output)) then
                   call mpas_output_state_finalize(output_obj, domain % dminfo)
                end if
                call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp))

Modified: branches/ocean_projects/first_output_optional/src/core_ocean/mpas_ocn_mpas_core.F
===================================================================
--- branches/ocean_projects/first_output_optional/src/core_ocean/mpas_ocn_mpas_core.F        2012-05-14 21:26:59 UTC (rev 1909)
+++ branches/ocean_projects/first_output_optional/src/core_ocean/mpas_ocn_mpas_core.F        2012-05-14 22:34:03 UTC (rev 1910)
@@ -343,6 +343,7 @@
       type (MPAS_Time_Type) :: currTime
       character(len=StrKIND) :: timeStamp
       integer :: ierr
+      logical :: first_output
    
       ! Eventually, dt should be domain specific
       dt = config_dt
@@ -365,6 +366,7 @@
       ! During integration, time level 1 stores the model state at the beginning of the
       !   time step, and time level 2 stores the state advanced dt in time by timestep(...)
       itimestep = 0
+      first_output = .true.
       do while (.not. mpas_is_clock_stop_time(clock))
 
          itimestep = itimestep + 1
@@ -389,12 +391,15 @@
       
          if (mpas_is_alarm_ringing(clock, outputAlarmID, ierr=ierr)) then
             call mpas_reset_clock_alarm(clock, outputAlarmID, ierr=ierr)
-            ! output_frame will always be &gt; 1 here unless it was reset after the maximum number of frames per outfile was reached
+            ! output_frame will always be &gt; 1 here unless it was reset after 
+            ! the maximum number of frames per outfile was reached
+
             if(output_frame == 1) then
-               if (config_write_initial_output) then
+               if (config_write_initial_output.or.(.not.first_output)) then
                   call mpas_output_state_finalize(output_obj, domain % dminfo)
                end if
                call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp))
+               first_output = .false.
             end if
 
             block_ptr =&gt; domain % blocklist

Modified: branches/ocean_projects/first_output_optional/src/core_sw/mpas_sw_mpas_core.F
===================================================================
--- branches/ocean_projects/first_output_optional/src/core_sw/mpas_sw_mpas_core.F        2012-05-14 21:26:59 UTC (rev 1909)
+++ branches/ocean_projects/first_output_optional/src/core_sw/mpas_sw_mpas_core.F        2012-05-14 22:34:03 UTC (rev 1910)
@@ -160,6 +160,7 @@
       type (MPAS_Time_Type) :: currTime
       character(len=StrKIND) :: timeStamp
       integer :: ierr
+      logical :: first_output
    
       ! Eventually, dt should be domain specific
       dt = config_dt
@@ -175,6 +176,7 @@
       ! During integration, time level 1 stores the model state at the beginning of the
       !   time step, and time level 2 stores the state advanced dt in time by timestep(...)
       itimestep = 0
+      first_output = .true.
       do while (.not. mpas_is_clock_stop_time(clock))
 
          itimestep = itimestep + 1
@@ -197,7 +199,7 @@
             call mpas_reset_clock_alarm(clock, outputAlarmID, ierr=ierr)
             ! output_frame will always be &gt; 1 here unless it was reset after the maximum number of frames per outfile was reached
             if(output_frame == 1) then
-               if (config_write_initial_output) then
+               if (config_write_initial_output.or.(.not.first_output)) then
                   call mpas_output_state_finalize(output_obj, domain % dminfo)
                end if
                call mpas_output_state_init(output_obj, domain, &quot;OUTPUT&quot;, trim(timeStamp))

</font>
</pre>