Skip to content

Changes to filename_template checks #1464

Draft
abishekg7 wants to merge 9 commits into
MPAS-Dev:developfrom
abishekg7:framework/new_filename_template_check
Draft

Changes to filename_template checks #1464
abishekg7 wants to merge 9 commits into
MPAS-Dev:developfrom
abishekg7:framework/new_filename_template_check

Conversation

@abishekg7
Copy link
Copy Markdown
Collaborator

@abishekg7 abishekg7 commented Jun 2, 2026

Previously, if two active, output stream definitions in the streams. file specified the same string as the filename_template attribute, the corresponding MPAS CORE would crash with an error message. This was also the case for when one of the streams, sharing the filename_template, included an inactive package, hence effectively making it inactive. The existing logic to perform stream uniqueness checks in src/framework/xml_stream_parser.c did not have the information about which packages associated with a stream were active, and hence did not account for inactive packages.

This PR introduces a new subroutine MPAS_stream_mgr_check_filename_template in src/framework/mpas_stream_manager.F to check for unique filename_templates only for streams that are both active, output streams and are not associated with packages that are currently inactive. This subroutine is called from within MPAS_stream_mgr_validate_streams.

The previous logic to check for unique filename_template attributes in src/framework/xml_stream_parser.c has been removed, while retaining the checks for unique stream names

Comment thread src/framework/mpas_stream_manager.F
Comment thread src/framework/mpas_stream_manager.F
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F
@abishekg7 abishekg7 requested a review from mgduda June 5, 2026 15:35
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F Outdated
Comment thread src/framework/mpas_stream_manager.F Outdated

stream2_pkg_active = stream_active_pkg_check(stream2_cursor)
stream2_output = (stream2_cursor % direction == MPAS_STREAM_OUTPUT) .or. &
(stream2_cursor % direction == MPAS_STREAM_INPUT_OUTPUT)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be misreading the logic, but it looks like we will only catch cases where two output (or input-output) streams share a filename_template. However, I think we would also want to catch cases where an active input stream shares a filename_template with an active output (or input-output) stream.

', in streams.<CORE>. This may result in file conflicts.'
call mpas_log_write(message, messageType=MPAS_LOG_ERR)
if (present(ierr)) ierr = MPAS_STREAM_MGR_ERROR
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than returning on the first pair of matching filename_template values, we could instead report all errors before returning. Admittedly, it may not be common for someone to define more than two streams that share a filename_template (or more than one pair of streams that conflict), but I think it's a small enough change to report all errors before returning that it's worth doing.

stream1_output = (stream1_cursor % direction == MPAS_STREAM_OUTPUT) .or. &
(stream1_cursor % direction == MPAS_STREAM_INPUT_OUTPUT)

if (.not. stream1_cursor % active_stream .or. .not. stream1_output .or. .not. stream1_pkg_active) then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it a bit more, perhaps we could also skip (for the purpose of finding duplicate filename_template values) streams whose input_interval or output_interval is none, since that stream -- although potentially active -- would never be read or written?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants