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

Switch to using f90nml for reading namelists #874

Merged
merged 3 commits into from
Apr 20, 2022

Conversation

xylar
Copy link
Collaborator

@xylar xylar commented Apr 20, 2022

This is a more robust and general tool than what we have.

closes #871

@xylar xylar self-assigned this Apr 20, 2022
@xylar
Copy link
Collaborator Author

xylar commented Apr 20, 2022

Testing

I ran the test suite successfully on Anvil. Results are here:
https://web.lcrc.anl.gov/public/e3sm/diagnostic_output/ac.xylar/analysis_testing/anvil/use_f90nml/

@xylar
Copy link
Collaborator Author

xylar commented Apr 20, 2022

@changliao1025, I verified that this new parsing function was able to parse your example namelist:

#!/usr/bin/env python

from mpas_analysis.shared.io.namelist_streams_interface import \
    convert_namelist_to_dict


namelist = convert_namelist_to_dict('namelist.test', readonly=False)
print(namelist)

Here's the namelist (with a / added at the end):

&shr_strdata_nml
  datamode = "CLMNCEP"
  domainfile = "somepath"
  dtlimit = 1.5, 1.5, 1.5, 1.5, 1.5
  fillalgo = "nn", "nn", "nn", "nn", "nn"
  fillmask = "nomask", "nomask", "nomask", "nomask", "nomask"
  fillread = "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET"
  fillwrite = "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET"
  mapalgo = "bilinear", "bilinear", "bilinear", "bilinear", "bilinear"
  mapmask = "nomask", "nomask", "nomask", "nomask", "nomask"
  mapread = "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET"
  mapwrite = "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET", "NOT_SET"
  readmode = "single", "single", "single", "single", "single"
  streams = "datm.streams.txt.CLMGSWP3v1.Solar 1950 1950 2010",
      "datm.streams.txt.CLMGSWP3v1.Precip 1950 1950 2010",
      "datm.streams.txt.CLMGSWP3v1.TPQW 1950 1950 2010",
      "datm.streams.txt.presaero.clim_2000 1 1 1",
      "datm.streams.txt.topo.observed 1 1 1"
  taxmode = "cycle", "cycle", "cycle", "cycle", "cycle"
  tintalgo = "coszen", "nearest", "linear", "linear", "lower"
  vectors = "null"
/

The results is:

...
'streams': ['datm.streams.txt.CLMGSWP3v1.Solar 1950 1950 2010', 'datm.streams.txt.CLMGSWP3v1.Precip 1950 1950 2010', 'datm.streams.txt.CLMGSWP3v1.TPQW 1950 1950 2010', 'datm.streams.txt.presaero.clim_2000 1 1 1', 'datm.streams.txt.topo.observed 1 1 1']
...

So it seems to be working as I expected at least. A note that the entries in the dictionary are not always single strings as they used to be. They are now parsed into lists and integers, floats, strings or bools as appropriate.

@xylar xylar merged commit 165657d into MPAS-Dev:develop Apr 20, 2022
@xylar xylar deleted the use_f90nml branch April 20, 2022 18:26
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.

Convert namelist to dict function not working for datm_in
1 participant