-
Notifications
You must be signed in to change notification settings - Fork 371
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
Add mostRecentAccessTime attribute to streams #4752
Add mostRecentAccessTime attribute to streams #4752
Conversation
This commit adds a mostRecentAccessTime attribute to all streams. For input, this corresponds to the time for which input was last read. For output, this corresponds to the time for which output was last written. Note that for output, there is an option to specify an output time that is not the current time; the value used here for mostRecentAccessTime uses the time actually sent to the file. This attribute is initialized to '9999-12-31_23:59:59' and will contain that value prior to the first access.
This commit modified the previous commit by removing the actualWhen argument to the MPAS_stream_mgr_read() routine and replacing it with an optional argument saveActualWhen. The actualWhen argument was ambiguous when MPAS_stream_mgr_read was called in a way such that multiple streams were read - the actualWhen value returned came from the final stream read and could possibly be wrong for the other streams that were read. Given the previous commit added the mostRecentAccessTime attribute to the MPAS_stream_list_type type, the actualTime argument was somewhat redundant anyway. Now, instead of being able to have the actualTime returned as an argument, there is the option to have the actual time saved to the new attribute. It can then be retrieved from the stream cursor as needed. The saveActualWhen argument is optional because some streams do not contain xtime and trying to obtain ‘actual when’ in those cases will cause the reading of the stream to fail. Therefore, it is important to be able to not seek this information if possible. If the saveActualWhen argument is not provided to MPAS_stream_mgr_read(), its value defaults to false. This commit also changes the land ice core to stop using actualWhen and replace it with saveActualWhen. Neither the ocean nor seaice cores use actualWhen so no other changes are necessary.
@mgduda , you may be interested in this small MPAS Framework PR. |
@trhille, could you put the full commit messages (possibly lightly edited) as the description of this PR? I think all that info is necessary to understand what's going on here. What kind of testing would you suggest to make sure this works as expected? I can certainly run some COMPASS and standard E3SM test cases. |
Thanks @xylar, I've added this to the PR description.
I think what we need is to write out xtime from the two most recent time levels to a log file, but I recognize that this is sort of a non-standard test requiring some extra code that wouldn't be part of the PR. @matthewhoffman, do you have other ideas for testing? |
Thanks, @trhille . For testing, can you report in a comment the testing you have done in your PR to confirm the new functionality works as expected? (and reference your PR in our repo as an example of usage) Because the ocean and sea ice cores do not use the functionality being modified, no specific testing needs to be done by them, but a standard set of COMPASS tests to confirm no harm was done is still appropriate. I think that would be sufficient. |
Thanks for tagging me, @matthewhoffman . Some of our code in MPAS-Atmosphere does make use of the |
@mgduda, from my reading of the changes in this PR and @matthewhoffman's description in a meeting we were in earlier today, it seems like |
@xylar Do you mean reading multiple streams with a single call to |
@mgduda, I'm not well versed enough in the I/O framework to address your question. My sense it that @matthewhoffman was referring to the former case. I would guess for the latter case, you would want, indeed, need to "iterate" over the one stream with a My understanding is that MPAS-Ocean and MPAS-Seaice don't use this functionality, so I'll leave further discussion up to the MALI and MPAS-Atmosphere folks. |
I tested this for MALI on https://github.com/trhille/E3SM/tree/0d1f47742a394d3fb24fc6c9c72f837d86419562. I wrote out xtime of the two most recent input times here: https://github.com/trhille/E3SM/blob/0d1f47742a394d3fb24fc6c9c72f837d86419562/components/mpas-albany-landice/src/mode_forward/mpas_li_calving.F#L1809-L1829 The input stream interval is one year (updated in July) in this case. This gave the expected behavior in log.landice.0000.out:
MALI usage example: MALI-Dev#18 |
@mgduda , you are absolutely right that with this change, you would no longer have the option to get the time that was read as an argument and instead would have to access the stream cursor to get the new attribute. I could certainly leave the existing functionality in place for backwards compatibility, but it would fail to address the issue that On a related note, the way I implemented it, one has to explicitly set the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm reviewing these changes mostly from a do-no-harm perspective. Since this is not a functionality that we currently use in MPAS-Ocean, nor that we have a short-term need for, I have not tried to understand all the nuances.
I tested the compass ocean pr
test suite on Anvil with Intel and Intel-MPI. All tests passed and matched bit-for-bit with a baseline created from a recent E3SM/master (3523b2b).
MPAS framework team discussed this PR today and decided that this functionality is unlikely to be used by ocean and sea ice, and maintaining identical framework to NCAR/MPAS-Atmosphere is not a requirement at this point, so we will proceed with the version implemented here, pending approval by remaining reviewers. Any of the modifications discussed above could be implemented in the future if needs arise. |
After talking with @trhille , we decided it would be a cleaner implementation to have the new attribute always saved and remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This passes the nightly regression suite with both intel and gnu on grizzly. I'm happy for this to be merged.
Just saw the previous comment by @matthewhoffman. I can review again after PR is updated. |
Having saving of the actualWhen time being optional could lead to confusion if one accesses the new mostRecentAccessTime attribute elsewhere. This commit makes it so the actualWhen time is always saved for all streams that are read. Hence the saveActualWhen argument is deleted.
@trhille , I've pushed a new commit that makes it so the |
Some streams do not have the xtime variable. In those cases, attempting to access xtime leads to an error. This commit uses a dummy value for actualWhen if xtime is not present in an input file.
… xtime" This reverts commit c7817c6. The attempt to parse i/o error codes was not reliable because tests always returned MPAS_IO_ERR_PIO instead of more specific, useful error codes. Thus it was not possible to differentiate between xtime being missing from a file and any other i/o error that should be treated as a real error.
This reverts commit 1baed5e. This revert goes with the revert in the previous commit. See commit message there for details.
Updated comments explain why the saveActualWhen argument is needed and why it is not possible to just always save the actualWhen time.
Update: after testing commits to make the actualWhen time always saved, we found that this change was unacceptable because it was not possible to reliably parse existing i/o error messages to identify if xtime was present or not. (The dreaded generic The code should now be identical to the version that Xylar and Mark tested earlier this week, but Trevor will retest his use case to be sure, and then it's probably best practice to have at least one of Xylar or Mark retest as well. |
Before this commit, a default value of '0000-01-01_00:00:00' was being saved to the new mostRecentAccessTime attribute on calls to mpas_stream_mgr_read() where a stream wasn't actually read because its alarm wasn't ringing. This commit initializes actualWhen_local to a non-time value in order to only set mostRecentAccessTime if actualWhen_local is successfully updated to a time by read_stream().
@xylar , @mark-petersen , @akturner , I have pushed one new commit to this PR that @trhille found during his final testing. Trevor has successfully tested this final version now, so the PR is ready for final review and then merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recompiled with the head with gnu, and this passes the MPAS-O nightly regression suite again. Thanks.
Thanks @mark-petersen. I don't feel the need to retest, so my approval stands. |
Thanks, Mark & Xylar. @akturner , do you still want to review this before we proceed? |
…-streams' into next (PR #4752) Add mostRecentAccessTime attribute to streams Add a new attribute to streams called 'mostRecentAccessTime', which is useful when multiple time-levels are needed at once from an input file. The actualWhen argument to the MPAS_stream_mgr_read() routine is replaced with an optional argument saveActualWhen. The actualWhen argument was ambiguous when MPAS_stream_mgr_read was called in a way such that multiple streams were read; the actualWhen value returned came from the final stream read and could possibly be wrong for the other streams that were read. This also changes the land ice core to stop using actualWhen and replace it with saveActualWhen. Neither the ocean nor seaice cores use actualWhen so no other changes are necessary. [BFB]
Passes SMS.T62_oQU120_ais20.MPAS_LISIO_TEST.chrysalis_intel, merged to next |
merged to master. @trhille please feel free to delete the branch from your fork |
Add a new attribute to streams called 'mostRecentAccessTime', which is useful when multiple time-levels are needed at once from an input file.
For input, this corresponds to the time for which input was last read. For output, this corresponds to the time for which output was last written. Note that for output, there is an option to specify an output time that is not the current time; the value used here for mostRecentAccessTime uses the time actually sent to the file.
The actualWhen argument to the MPAS_stream_mgr_read() routine is replaced with an optional argument saveActualWhen. The actualWhen argument was ambiguous when MPAS_stream_mgr_read was called in a way such that multiple streams were read; the actualWhen value returned came from the final stream read and could possibly be wrong for the other streams that were read.
Now, instead of being able to have the actualTime returned as an argument, there is the option to have the actual time saved to the new attribute. It can then be retrieved from the stream cursor as needed.
The saveActualWhen argument is optional because some streams do not contain xtime and trying to obtain ‘actual when’ in those cases will cause the reading of the stream to fail. Therefore, it is important to be able to not seek this information in these cases. If the saveActualWhen argument is not provided to MPAS_stream_mgr_read(), its value defaults to false.
This also changes the land ice core to stop using actualWhen and replace it with saveActualWhen. Neither the ocean nor seaice cores use actualWhen so no other changes are necessary.
[BFB]