<p><b>mhoffman@lanl.gov</b> 2013-03-08 14:56:29 -0700 (Fri, 08 Mar 2013)</p><p>BRANCH COMMIT - land ice <br>
<br>
Adding a Registry option to output the initial time level or not.<br>
Also added logic that if you are doing a restart then the initial time level is automatically NOT written out, regardless of namelist options.<br>
</p><hr noshade><pre><font color="gray">Modified: branches/land_ice_projects/implement_core/src/core_land_ice/Registry
===================================================================
--- branches/land_ice_projects/implement_core/src/core_land_ice/Registry        2013-03-08 17:10:33 UTC (rev 2572)
+++ branches/land_ice_projects/implement_core/src/core_land_ice/Registry        2013-03-08 21:56:29 UTC (rev 2573)
@@ -11,6 +11,7 @@
namelist character land_ice_model config_stop_time none
namelist character land_ice_model config_run_duration none
namelist integer land_ice_model config_stats_interval 1
+namelist logical land_ice_model config_write_output_on_startup .true.
% config_stats_interval is how many time steps before calculating & outputting stats via the global_diagnostics module (which has not yet been setup to do much)
namelist logical land_ice_model config_write_initial_stats true
% config_write_initial_stats determines if stats are written at the initial time
Modified: branches/land_ice_projects/implement_core/src/core_land_ice/mpas_land_ice_mpas_core.F
===================================================================
--- branches/land_ice_projects/implement_core/src/core_land_ice/mpas_land_ice_mpas_core.F        2013-03-08 17:10:33 UTC (rev 2572)
+++ branches/land_ice_projects/implement_core/src/core_land_ice/mpas_land_ice_mpas_core.F        2013-03-08 21:56:29 UTC (rev 2573)
@@ -54,6 +54,11 @@
dt = config_dt_years * SecondsInYear
endif
+ ! If this is a restart, then do not output the intial time level, even if the namelist file says to
+ if (config_do_restart) then
+ config_write_output_on_startup = .false.
+ endif
+
call simulation_clock_init(domain, dt, startTimeStamp)
call mpas_timer_init(domain)
@@ -300,6 +305,7 @@
integer, intent(inout) :: output_frame
integer :: itimestep
+ integer :: ioutputfile ! A counter for how many output files have been generated.
type (block_type), pointer :: block_ptr
type (MPAS_Time_Type) :: currTime
@@ -310,10 +316,14 @@
currTime = mpas_get_clock_time(clock, MPAS_NOW, ierr)
call mpas_get_time(curr_time=currTime, dateTimeString=timeStamp, ierr=ierr)
- call mpas_timer_start("write output frame")
- call write_output_frame(output_obj, output_frame, domain)
- call mpas_timer_stop("write output frame")
+ ioutputfile = 1 ! We always start with a file open because framework opens the first output file
+ if (config_write_output_on_startup) then
+ call mpas_timer_start("write output frame")
+ call write_output_frame(output_obj, output_frame, ioutputfile, domain)
+ call mpas_timer_stop("write output frame")
+ endif
+
! 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
@@ -348,11 +358,14 @@
call mpas_timer_start("write output")
call mpas_reset_clock_alarm(clock, outputAlarmID, ierr=ierr)
! output_frame will always be > 1 here unless it was reset after the maximum number of frames per outfile was reached
- if(output_frame == 1) then
- call mpas_output_state_finalize(output_obj, domain % dminfo)
+ ! if output_frame == 1 we may need to init a new output file, but only under certain circumstances
+ ! If config_frames_per_outfile is 0 then we never need to do this because there is only one output file for the whole run
+ ! We also don't need to do this on the first file of the simulation because that file is inited by default in framework
+ ! Therefore we need to check if we are on the first file or not (using the counter variable ioutputfile).
+ if ( (output_frame == 1) .and. (config_frames_per_outfile /= 0) .and. (ioutputfile > 1) ) then
call mpas_output_state_init(output_obj, domain, "OUTPUT", trim(timeStamp))
end if
- call write_output_frame(output_obj, output_frame, domain)
+ call write_output_frame(output_obj, output_frame, ioutputfile, domain)
call mpas_timer_stop("write output")
end if
@@ -373,7 +386,7 @@
end subroutine mpas_core_run
- subroutine write_output_frame(output_obj, output_frame, domain)
+ subroutine write_output_frame(output_obj, output_frame, ioutputfile, domain)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Compute diagnostic fields for a domain and write model state to output file
!
@@ -388,6 +401,7 @@
type (io_output_object), intent(inout) :: output_obj
integer, intent(inout) :: output_frame
+ integer, intent(inout) :: ioutputfile
type (domain_type), intent(inout) :: domain
integer :: i, j, k
@@ -407,8 +421,10 @@
if (config_frames_per_outfile > 0) then
current_outfile_frames = current_outfile_frames + 1
if(current_outfile_frames >= config_frames_per_outfile) then
+ call mpas_output_state_finalize(output_obj, domain % dminfo)
current_outfile_frames = 0
output_frame = 1
+ ioutputfile = ioutputfile + 1
end if
end if
</font>
</pre>