Skip to content

Commit

Permalink
Fix a few bugs and add more info to log file
Browse files Browse the repository at this point in the history
The new functionality now works as expected for a simple test.
  • Loading branch information
matthewhoffman committed Jul 15, 2021
1 parent ed19e59 commit 6301c56
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/mpas-albany-landice/src/mode_forward/mpas_li_core.F
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ function li_core_init(domain, startTimeStamp) result(err)
err = ior(err, err_tmp)

if (config_do_restart) then
call mpas_log_write("This is a restart: read stream 'restart'.")
call mpas_stream_mgr_read(domain % streamManager, streamID='restart', ierr=err_tmp)
err = ior(err, err_tmp)
else
call mpas_log_write("This is not a restart: read stream 'input'.")
call mpas_stream_mgr_read(domain % streamManager, streamID='input', ierr=err_tmp)
err = ior(err, err_tmp)
end if
Expand All @@ -145,6 +147,7 @@ function li_core_init(domain, startTimeStamp) result(err)
!
! Read the remaining input streams
!
call mpas_log_write("Looking for other input streams set for 'initial_only'.")
call mpas_timer_start('io_read', .false.)
call mpas_stream_mgr_read(domain % streamManager, ierr=err_tmp)
err = ior(err, err_tmp)
Expand All @@ -153,6 +156,7 @@ function li_core_init(domain, startTimeStamp) result(err)
call mpas_stream_mgr_reset_alarms(domain % streamManager, direction=MPAS_STREAM_INPUT, ierr=err_tmp)
err = ior(err, err_tmp)
call mpas_timer_stop('reset_io_alarms')
call mpas_log_write("Finished reading 'initial_only' input streams.")

!
! Read time-varying inputs, if present (i.e., forcing)
Expand All @@ -161,6 +165,7 @@ function li_core_init(domain, startTimeStamp) result(err)
! But in general, we want that behavior - we do not want to have to wait a whole time step (or input_interval)
! before having forcing applied. Therefore, we must force those streams to be read here.
call mpas_timer_start('io_read', .false.)
call mpas_log_write("Looking for recurring input streams (forcing) that should be forced to be read at the initial time.")
stream_cursor => domain % streamManager % streams % head
do while (associated(stream_cursor))
if (stream_cursor % direction == MPAS_STREAM_INPUT) then
Expand All @@ -169,6 +174,7 @@ function li_core_init(domain, startTimeStamp) result(err)
(trim(stream_cursor % name) == 'restart')) then
! Don't attempt to interact with these two special streams
! (even though restart is not type input, including to be safe)
stream_cursor => stream_cursor % next
cycle
endif
! Only force a read of streams that are recurring. To find out if a stream is recurring, we need to
Expand All @@ -181,22 +187,23 @@ function li_core_init(domain, startTimeStamp) result(err)
! Force a read of this stream, and use the latest before time available in the file
call mpas_stream_mgr_read(domain % streamManager, streamID = stream_cursor % name, rightNow = .true., &
whence = MPAS_STREAM_LATEST_BEFORE, actualWhen=actualWhen, ierr=err_tmp)
call mpas_log_write("Forced an initial read of input stream '" // stream_cursor%name //"' from time: " // &
trim(actualWhen))
call mpas_log_write(" * Forced an initial read of input stream '" // trim(stream_cursor%name) // &
"' from time: " // trim(actualWhen))
err = ior(err, err_tmp)
endif
exit ! skip the rest of this loop - we processed the alarm we were looking for
endif
alarm_cursor => alarm_cursor % next
end do
stream_cursor => stream_cursor % next
end if ! if stream direction is INPUT
stream_cursor => stream_cursor % next
end do
call mpas_timer_stop('io_read')
call mpas_timer_start('reset_io_alarms', .false.)
call mpas_stream_mgr_reset_alarms(domain % streamManager, direction=MPAS_STREAM_INPUT, ierr=err_tmp)
err = ior(err, err_tmp)
call mpas_timer_stop('reset_io_alarms')
call mpas_log_write("Finished processing recurring input streams at initial time.")
! ===
! Initialize some time stuff on each block
Expand Down

0 comments on commit 6301c56

Please sign in to comment.