-
Notifications
You must be signed in to change notification settings - Fork 405
Changes to filename_template checks #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
abishekg7
wants to merge
15
commits into
MPAS-Dev:develop
Choose a base branch
from
abishekg7:framework/new_filename_template_check
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+172
−7
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
30b74f7
first draft
abishekg7 42399bc
Only crash out if it's an output stream
abishekg7 74af38b
Rename subroutine and call from stream_mgr_validate_streams
abishekg7 8eb3e56
Remove commented lines
abishekg7 64e5856
Some cleanups addressing review comments
abishekg7 3bf5404
remove trailing whitespace
abishekg7 5c7a075
Negating if conditions, removing unused variables and whitespace fixes
abishekg7 97c6d25
Edits to pass ierr to calling routine
abishekg7 741c495
Fixes to address review comments, and cleanup of logging statements
abishekg7 035a4a7
Redoing logic
abishekg7 f5e7f5c
Using stream_mgr_get_num_alarms in the logic. And some cleanup
abishekg7 ff95f35
Modifying logic so inner loop starts with the outer loop iterator
abishekg7 5d54033
Make ierr in get_num_alarms optional and cleanup unused variables
abishekg7 a30e46c
Fixing whitespace, comment block and error messages
abishekg7 0376fed
Reducing number of variables + cleanup
abishekg7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -563,10 +563,134 @@ subroutine MPAS_stream_mgr_validate_streams(manager, streamID, ierr)!{{{ | |
| #endif | ||
|
|
||
| end do | ||
|
|
||
| ! Only check filename_template uniqueness when validating all streams | ||
| if (.not. present(streamID)) then | ||
| call MPAS_stream_mgr_check_filename_template(manager, ierr=err_local) | ||
| if (present(ierr)) ierr = err_local | ||
| end if | ||
|
|
||
| end subroutine MPAS_stream_mgr_validate_streams!}}} | ||
|
|
||
|
|
||
| !----------------------------------------------------------------------- | ||
| ! routine MPAS_stream_mgr_check_filename_template | ||
| ! | ||
| !> \brief Check for filename_template conflicts between active output and I/O streams. | ||
| !> \author Abishek Gopal | ||
| !> \date June 3 2026 | ||
| !> \details | ||
| !> Checks that there are no active output streams that share an identical | ||
| !> filename_template attribute with any other active input or output streams | ||
| !> in the stream manager, which may lead to file conflicts. An active stream | ||
| !> in this context is a stream with active_stream = .true. and is not | ||
| !> deactivated by an inactive package and is either an input or output | ||
| !> stream with at least one active alarm. | ||
| !> | ||
| !> If this routine detects any filename_template conflicts, an error message | ||
| !> is logged for each pair of conflicting streams, and an MPAS_STREAM_MGR_ERROR | ||
| !> error code is returned. In the case of a successful check, an | ||
| !> MPAS_STREAM_MGR_NOERR error code is returned. This routine can be called | ||
| !> from within MPAS_stream_mgr_validate_streams or separately as needed. | ||
| ! | ||
| !----------------------------------------------------------------------- | ||
| subroutine MPAS_stream_mgr_check_filename_template(manager, ierr)!{{{ | ||
|
|
||
| implicit none | ||
|
|
||
| type (MPAS_streamManager_type), intent(inout) :: manager | ||
| integer, intent(out), optional :: ierr | ||
|
mgduda marked this conversation as resolved.
|
||
|
|
||
| integer :: threadNum, err_local | ||
| character (len=StrKIND) :: message, streamID | ||
| type (MPAS_stream_list_type), pointer :: stream1_cursor, stream2_cursor | ||
| type (MPAS_TimeInterval_type) :: clock_interval | ||
| logical :: pkg_active | ||
| logical :: stream1_input, stream2_input | ||
| logical :: stream1_output, stream2_output | ||
| integer :: input_nalarms, output_nalarms | ||
|
|
||
| STREAM_DEBUG_WRITE('-- Called MPAS_stream_mgr_check_filename_template() for all streams') | ||
|
|
||
| if (present(ierr)) ierr = MPAS_STREAM_MGR_NOERR | ||
|
|
||
| threadNum = mpas_threading_get_thread_num() | ||
|
|
||
| if (threadNum == 0) then | ||
|
|
||
| streamID = '.*' ! query all streams | ||
|
|
||
| nullify(stream1_cursor) | ||
| do while (MPAS_stream_list_query(manager % streams, streamID, stream1_cursor)) | ||
|
mgduda marked this conversation as resolved.
|
||
|
|
||
| pkg_active = stream_active_pkg_check(stream1_cursor) | ||
|
|
||
| input_nalarms = MPAS_stream_mgr_get_num_alarms(manager, trim(stream1_cursor % name), & | ||
| MPAS_STREAM_INPUT) | ||
| output_nalarms = MPAS_stream_mgr_get_num_alarms(manager, trim(stream1_cursor % name), & | ||
| MPAS_STREAM_OUTPUT) | ||
|
|
||
| stream1_input = ((stream1_cursor % direction == MPAS_STREAM_INPUT .or. & | ||
| stream1_cursor % direction == MPAS_STREAM_INPUT_OUTPUT) .and. & | ||
| input_nalarms > 0) | ||
| stream1_output = ((stream1_cursor % direction == MPAS_STREAM_OUTPUT .or. & | ||
| stream1_cursor % direction == MPAS_STREAM_INPUT_OUTPUT) .and. & | ||
| output_nalarms > 0) | ||
|
|
||
| call mpas_log_write('Stream 1 '//trim(stream1_cursor % name)//' filename '//trim(stream1_cursor % filename_template)//' & | ||
| & active = $l input = $l output = $l packages_active $l',logicArgs=(/stream1_cursor % active_stream, stream1_input, stream1_output, pkg_active/)) | ||
|
|
||
| if (.not. stream1_cursor % active_stream & | ||
| .or. .not. (stream1_input .or. stream1_output) & | ||
| .or. .not. pkg_active) then | ||
| cycle | ||
| end if | ||
|
|
||
| nullify(stream2_cursor) | ||
| stream2_cursor => stream1_cursor | ||
| do while (MPAS_stream_list_query(manager % streams, streamID, stream2_cursor)) | ||
|
|
||
| input_nalarms = MPAS_stream_mgr_get_num_alarms(manager, trim(stream2_cursor % name), & | ||
| MPAS_STREAM_INPUT) | ||
| output_nalarms = MPAS_stream_mgr_get_num_alarms(manager, trim(stream2_cursor % name), & | ||
| MPAS_STREAM_OUTPUT) | ||
|
|
||
| pkg_active = stream_active_pkg_check(stream2_cursor) | ||
| stream2_input = ((stream2_cursor % direction == MPAS_STREAM_INPUT .or. & | ||
| stream2_cursor % direction == MPAS_STREAM_INPUT_OUTPUT) .and. & | ||
| input_nalarms > 0) | ||
| stream2_output = ((stream2_cursor % direction == MPAS_STREAM_OUTPUT .or. & | ||
| stream2_cursor % direction == MPAS_STREAM_INPUT_OUTPUT) .and. & | ||
| 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/)) | ||
|
|
||
| if (.not. stream2_cursor % active_stream & ! Skip if Stream 2 is not active | ||
| .or. .not. (stream2_input .or. stream2_output) & | ||
| .or. (stream1_input .and. stream2_input) & ! Skip if Streams 1 and 2 are both input streams | ||
| .or. .not. pkg_active) then ! Skip if Stream 2 is inactive due to inactive package | ||
| cycle | ||
| end if | ||
|
|
||
| if (trim(stream1_cursor % filename_template) == trim(stream2_cursor % filename_template)) then | ||
| message = 'Detected identical values of filename_template between an active output stream and an I/O stream' | ||
| call mpas_log_write(message) | ||
| message = 'Streams '// trim(stream1_cursor % name) // ' and ' // trim(stream2_cursor % name) // & | ||
| ' have identical filename_template attribute in streams.<CORE>. This may result in file conflicts.' | ||
| call mpas_log_write(message, messageType=MPAS_LOG_ERR) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message can be quite long when printed to a single line, e.g., It might be better to explicitly write a multi-line error message with multiple calls to |
||
| if (present(ierr)) ierr = MPAS_STREAM_MGR_ERROR | ||
| end if | ||
|
|
||
| end do | ||
|
|
||
| end do | ||
|
|
||
| end if | ||
|
|
||
| end subroutine MPAS_stream_mgr_check_filename_template!}}} | ||
|
|
||
|
|
||
| !----------------------------------------------------------------------- | ||
| ! routine MPAS_stream_mgr_destroy_stream | ||
| ! | ||
|
|
@@ -1771,6 +1895,54 @@ function MPAS_stream_mgr_get_stream_interval(manager, streamID, direction, ierr) | |
| end function MPAS_stream_mgr_get_stream_interval | ||
|
|
||
|
|
||
| !----------------------------------------------------------------------- | ||
| ! routine MPAS_stream_mgr_get_num_alarms | ||
| ! | ||
| !> \brief Returns the number of I/O alarms associated with a stream in a given direction | ||
| !> \author Abishek Gopal | ||
| !> \date 10 June 2026 | ||
| !> \details | ||
| !> Returns the number of I/O alarms associated with a stream in a given direction. | ||
| ! | ||
| !----------------------------------------------------------------------- | ||
| function MPAS_stream_mgr_get_num_alarms(manager, streamID, direction, ierr) result(numAlarms) | ||
|
|
||
| implicit none | ||
|
|
||
| integer :: numAlarms | ||
|
|
||
| type (MPAS_streamManager_type), intent(in) :: manager | ||
| character(len=*), intent(in) :: streamID | ||
| integer, intent(in) :: direction | ||
| integer, intent(out), optional :: ierr | ||
|
|
||
| type (mpas_stream_list_type), pointer :: streamCursor | ||
| integer :: err_local | ||
|
|
||
| numAlarms = 0 | ||
| err_local = MPAS_STREAM_MGR_NOERR | ||
| nullify(streamCursor) | ||
|
|
||
| if (mpas_stream_list_query(manager % streams, streamID, streamCursor)) then | ||
| if (direction == MPAS_STREAM_INPUT) then | ||
| numAlarms = MPAS_stream_list_length(streamCursor % alarmList_in, err_local) | ||
| else if (direction == MPAS_STREAM_OUTPUT) then | ||
| numAlarms = MPAS_stream_list_length(streamCursor % alarmList_out, err_local) | ||
| else | ||
| err_local = MPAS_STREAM_MGR_ERROR | ||
| call MPAS_stream_mesg(manager % errorLevel, 'Invalid direction encountered in MPAS_stream_mgr_get_num_alarms') | ||
| end if | ||
| else | ||
| err_local = MPAS_STREAM_MGR_ERROR | ||
| call MPAS_stream_mesg(manager % errorLevel, 'Stream ' // trim(streamID) // & | ||
| ' does not exist. Cannot retrieve number of alarms in stream.') | ||
| end if | ||
|
|
||
| if (present(ierr)) ierr = err_local | ||
|
|
||
| end function MPAS_stream_mgr_get_num_alarms | ||
|
|
||
|
|
||
| !----------------------------------------------------------------------- | ||
| ! routine MPAS_stream_mgr_set_property_int | ||
| ! | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.