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

Generalized subroutine to read the state variables from the namelist (parse_variables) #783

Merged
merged 49 commits into from
Feb 4, 2025

Conversation

mjs2369
Copy link
Contributor

@mjs2369 mjs2369 commented Dec 18, 2024

Description:

There are many variations in the model_mods of the subroutine to take the table of state variables read in from the namelist and put the info into various data structures, which can then be passed into add domain. A new variation of this subroutine would need to be written every time a new model is added to DART.

This PR creates two generalized subroutines that convert the table of state variables to a state_var_type :
parse_variables reads netcdf variable name, dart qty, and update values from the nml
parse_variables_clamp reads netcdf variable name, dart qty, clamp_values, and update values from the nml

Alternate versions for this subroutine were replaced with get_state_variables in the models MOM6, wrf_hydro, aether_lat-lon, cam-fv, cam-se, POP, and cice

New dev test test_parse_variables added

Fixes issue

Fixes #448

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Documentation changes needed?

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.

Tests

Compiled all models with updated model_mods
Build_everything runs as expected with all compilers
Bitwise tested with CAM-FV
New dev test runs successfully and reports pass/fails correctly

Checklist for merging

  • Updated changelog entry
  • Documentation updated
  • Update conf.py

Checklist for release

  • Merge into main
  • Create release from the main branch with appropriate tag
  • Delete feature-branch

Testing Datasets

  • Dataset needed for testing available upon request
  • Dataset download instructions included
  • No dataset needed

…nto a table and verify its contents; putting it in the default_model_mod
Updating the generic routine by including the type state_vars_type and
storing the contents of the nml entry here

Including a conditional use_clamping that tells whether or not the
model's nml entry includes clamping values; executing a separate do
loop over the rows if true to allow for reading in these values
its functionality.

Adding checks against known values with fortran-test-anything
…del_mod

This model is the perfect example of how we can have separate calls to
get_state_variables for each file domain instead of having the domain
included in the state_variables nml item.
@hkershaw-brown
Copy link
Member

@mjs2369 Do you have restart files so you can test the changed model_mods?

Copy link
Member

@hkershaw-brown hkershaw-brown left a comment

Choose a reason for hiding this comment

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

Hi Marlee,

Good work finding all the model_mods routines that can be switched out by this.

I've put some comments in. The thing to sort out first, is the get_state_variables routine.

  1. Does the overloading and having to set clamping = .true. make. sense? '
  2. Can you keep state_vars type private, so the model_mod does not access the internals (see the comments on add_domain)?

The 3d template model_mod needs updating to use the new routines, since this is what is used when the 'new_model.sh' script is run.

Documentation for routine also needs adding, maybe 'adding a new model' is the best place for this, I'm not sure.

I think the tests should comprehensively test the whole table read - if we are running the test, should test all the values.

@mjs2369
Copy link
Contributor Author

mjs2369 commented Dec 18, 2024

@mjs2369 Do you have restart files so you can test the changed model_mods?

Only for cam-fv and pop - do you want me to test that all models are bitwise?

@hkershaw-brown
Copy link
Member

@mjs2369 Do you have restart files so you can test the changed model_mods?

Only for cam-fv and pop - do you want me to test that all models are bitwise?

If you're changing the model_mod then yes, check that the new code does the expected.
Bitwise model_mod_check, or pmo, or filter if you have test cases set up - with clamping.
Or compare the domain info.

- Make the name of the function parse_variables
- Remove interface to create two distinct functions: parse_variables and parse_variables_clamp
- Remove use_clamping and max_state_vars arguments
- Update the calls to the function in all edited model_mods
@hkershaw-brown
Copy link
Member

Marlee still testing this.

@mjs2369
Copy link
Contributor Author

mjs2369 commented Jan 30, 2025

Tested and ready to merge @hkershaw-brown

Cam-fv: bitwise filter executions
Cam-se, Aether_lat-lon, wrf_hydro: bitwise model_mod_check executions
POP, MOM6, CICE: domain_info in the state_structure after the call to add_domain is identical to the main branch

@hkershaw-brown
Copy link
Member

@mjs2369 can you point me to where your test restart files are on Derecho, thanks!

MAX_STATE_VARIABLE_FIELDS_CLAMP

type :: state_var_type
integer :: nvars
Copy link
Member

Choose a reason for hiding this comment

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

note for chat today
nvars = -1

@mjs2369
Copy link
Contributor Author

mjs2369 commented Feb 4, 2025

@mjs2369 can you point me to where your test restart files are on Derecho, thanks!

@hkershaw-brown
Sorry, just seeing this particular comment:

/glade/work/masmith/test_cases/

"big" for models currently in the repo
Default value for nvars = -1 (rather than unset) in that state_var_type
Copy link
Member

@hkershaw-brown hkershaw-brown left a comment

Choose a reason for hiding this comment

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

Great work on this Marlee,

I added the error check for nvars vs. MAX_STATE_VARIABLES in parse_variables, and parse_variables_clamp, if you can double check those that would be great.

Feel free to release when you're ready!

Cheers,
Helen

Edit: parse_variables -> parse_variables_clamp

@hkershaw-brown hkershaw-brown added release! bundle with next release and removed release+1 bundle with release after next labels Feb 4, 2025
@mjs2369 mjs2369 changed the title Generalized subroutine to read the state variables from the namelist (get_state_variables) Generalized subroutine to read the state variables from the namelist (parse_variables) Feb 4, 2025
@mjs2369 mjs2369 merged commit f4b2a58 into main Feb 4, 2025
5 checks passed
@mjs2369 mjs2369 deleted the get_state_variables branch February 4, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release! bundle with next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: routine to read a table of state variables from namelist
3 participants