Conversation
|
I've run a few quick tests, and it looks like the core logic is now functioning as expected. I had just a couple of ideas that might clean up the implementation:
|
I've incorporated the 2nd idea in the most recent commit. But having either the outer loop or the inner loop consider only output streams, appears to miss some filename conflicts, due to the directionality introduced by idea #2. |
| message = 'Found identical values of the filename_template attribute for multiple active output streams, ' & | ||
| // trim(stream1_cursor % name) // ' and ' // trim(stream2_cursor % name) // & | ||
| ', in streams.<CORE>. This may result in file conflicts.' | ||
| call mpas_log_write(message, messageType=MPAS_LOG_ERR) |
There was a problem hiding this comment.
The error message can be quite long when printed to a single line, e.g.,
ERROR: Found identical values of the filename_template attribute for multiple active output streams, restart and output, in streams.<CORE>. This may result in file conflicts.
It might be better to explicitly write a multi-line error message with multiple calls to mpas_log_write.
There was a problem hiding this comment.
@abishekg7 It looks like this suggestion is still pending.
There was a problem hiding this comment.
The previous message has actually been modified slightly, and it is split up into two calls to mpas_log_write. Let me know if it needs further changes.
|
I have addressed the remaining suggestions in the last few commits. |
|
@abishekg7 As of now, there are quite a few messages that are written to the log file even when there are no issues with the streams. For example, here's what I get from the log file for the Could you update the PR so that these messages are not written? |
Done. |
| output_nalarms > 0) | ||
|
|
||
| call mpas_log_write('Stream 2 '//trim(stream2_cursor % name)//' filename '//trim(stream2_cursor % filename_template)//' & | ||
| & active = $l input = $l output = $l pkg_active: $l',logicArgs=(/stream2_cursor % active_stream, stream2_input, stream2_output, pkg_active/)) |
There was a problem hiding this comment.
I wonder if we might be better off omitting these messages from the log file. As they are now, they might not be particularly valuable to most users. Here's what I'm seeing in a run of the init_atmosphere core:
Stream 2 output filename init.nc active = T input = F output = T pkg_active: T
Stream 2 ugwp_oro_data filename ugwp_oro_data.nc active = T input = F output = T pkg_active: F
Stream 2 surface filename sfc_update.nc active = T input = F output = T pkg_active: F
Stream 2 lbc filename lbc.**-**-**_**.**.**.nc active = T input = F output = T pkg_active: F
Stream 2 ugwp_oro_data filename ugwp_oro_data.nc active = T input = F output = T pkg_active: F
Stream 2 surface filename sfc_update.nc active = T input = F output = T pkg_active: F
Stream 2 lbc filename lbc.**-**-**_**.**.**.nc active = T input = F output = T pkg_active: F
There was a problem hiding this comment.
I left this in for debugging purposes until this PR reaches the approval stage. Can remove it if there are no other changes to the main logic required.
There was a problem hiding this comment.
It's possible that the logic may still need some adjustment. When I have the following two streams defined
<immutable_stream name="restart"
type="input;output"
filename_template="restart.$Y-$M-$D_$h.$m.$s.nc"
input_interval="initial_only"
output_interval="6:00:00" />
<stream name="foo"
type="input"
filename_template="restart.$Y-$M-$D_$h.$m.$s.nc"
input_interval="6:00:00" >
<file name="stream_list.atmosphere.output"/>
</stream>
I don't get any runtime errors, though I would have expected there to be since the restart stream is an input;output stream and it shares a filename_template with the foo stream.
This commit addresses an issue with file conflicts when one stream is declared as MPAS_STREAM_INPUT_OUTPUT, and the second stream sharing the same filename_template attribute is declared as MPAS_STREAM_INPUT. Presently, if streams 1 and 2 are both input streams, then the checks are passed and the model can (incorrectly) allow Stream 2 to read from the same file that Stream 1 is writing out to. By removing MPAS_STREAM_INPUT_OUTPUT from the evaluation of whether a stream is only an input stream, this issue is fixed.
Issue:
Previously, if two active, output stream definitions in the streams. file specified the same string as the
filename_templateattribute, the corresponding MPAS CORE would crash with an error message. This was also the case for when one of the streams, sharing thefilename_template, included an inactive package, hence effectively making it inactive. The existing logic to perform stream uniqueness checks insrc/framework/xml_stream_parser.cdid not have the information about which packages associated with a stream were active, and hence did not account for inactive packages.Solution
This PR introduces a new subroutine
MPAS_stream_mgr_check_filename_templateinsrc/framework/mpas_stream_manager.Fto check whether two active streams might potentially be accessing the same file (viafilename_template) resulting in file conflicts. More specifically, this subroutine checks that there are no active output streams that share an identicalfilename_templateattribute with any other active input or output streams in the stream manager. An active stream in this context is a stream with attributeactive_stream = .true.and is not deactivated by an inactive package and is either an input or output stream with at least one active alarm. This routine can be called from withinMPAS_stream_mgr_validate_streamsor separately as needed.This PR also introduces a new function 'MPAS_stream_mgr_get_num_alarms', which returns the number of active alarms for a given stream in the specified direction.
The previous logic to check for unique
filename_templateattributes insrc/framework/xml_stream_parser.chas been removed, while retaining the checks for unique stream names in the same location. Note that the previous logic only check for conflicts between two output streams, whereas the new logic also checks for potential conflicts between an input stream and an output stream accessing the same file.