Skip to content
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

Allow real-valued attributes to be read with different precision using SMIOL #1091

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

mgduda
Copy link
Contributor

@mgduda mgduda commented Jun 28, 2023

This PR allows real-valued attributes to be read with a different precision from
MPAS's native precision when using SMIOL.

Previously, the mpas_io_get_att_real0d() routine relied on its 'precision'
optional argument to determine whether to attempt to read real-valued attributes
in a precision different from MPAS's native precision. However, in some parts of
the MPAS framework (specifically, in mpas_bootstrap_framework_phase1()), the
MPAS_io_get_att() routine is called without the 'precision' argument, leading to
problems in reading, e.g., 'sphere_radius' when the precision of the input file
is not the MPAS native precision.

Now, the mpas_io_get_att_real0d() routine first tries to read an attribute in
MPAS's native precision; if that fails, a second attempt is made to read the
attribute using the opposite precision (single vs. double). If both attempts
fail, the attribute argument is set to a fill value and an error code is
returned. This allows MPAS to read real-valued attributes using SMIOL during the
bootstrapping process regardless of the precision of the input file.

…g SMIOL

Previously, the mpas_io_get_att_real0d() routine relied on its 'precision'
optional argument to determine whether to attempt to read real-valued attributes
in a precision different from MPAS's native precision. However, in some parts of
the MPAS framework (specifically, in mpas_bootstrap_framework_phase1()), the
MPAS_io_get_att() routine is called without the 'precision' argument, leading to
problems in reading, e.g., 'sphere_radius' when the precision of the input file
is not the MPAS native precision.

Now, the mpas_io_get_att_real0d() routine first tries to read an attribute in
MPAS's native precision; if that fails, a second attempt is made to read the
attribute using the opposite precision (single vs. double). If both attempts
fail, the attribute argument is set to a fill value and an error code is
returned. This allows MPAS to read real-valued attributes using SMIOL during the
bootstrapping process regardless of the precision of the input file.
@mgduda mgduda force-pushed the framework/smiol_real_att_fix branch from bdd5382 to 4a2f1bf Compare June 29, 2023 00:08
@mgduda mgduda marked this pull request as ready for review June 29, 2023 00:12
@mgduda mgduda requested a review from gdicker1 June 29, 2023 00:17
@mgduda
Copy link
Contributor Author

mgduda commented Jun 29, 2023

For an example of the problem that this PR addresses, here are the warnings we get in a log file when the init_atmosphere core is compiled in double-precision (the default) and when we read a single-precision static file (which definitely has a sphere_radius attribute):

WARNING: Attribute sphere_radius not found in x1.10242.static.nc
WARNING:    Setting sphere_radius to 1.0

@mgduda
Copy link
Contributor Author

mgduda commented Jun 29, 2023

@gdicker1 The diff may look a bit complicated, since the calls to read attributes using PIO and SMIOL were previously interleaved, necessitating multiple sets of preprocessing directives. I thought it would be cleaner to just separate the PIO and SMIOL sections of the mpas_io_get_att_real0d routine so that each I/O layer has a contiguous chunk of code.

Copy link
Collaborator

@gdicker1 gdicker1 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Generating initial conditions with a single-precision init_atmosphere core and then running with double-precision atmosphere core was successful. There were no warnings/messages like @mgduda mentioned above.

@mgduda mgduda merged commit 8cfac6a into MPAS-Dev:hotfix-v8.0.1 Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants