forked from HPSCTerrSys/eCLM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed parsing errors and incorrectly set namelist parameters (HPSCTer…
…rSys#6) Commit summary: - f0fc1a6 Set default case_name to filename; bumped script version to 0.4 - 96ec507 Fixed eclm runtime errors due to namelist errors - 95dfb47 Renamed cesm.exe to eclm.exe - 8405cba Allowed stream file paths to be modified by user - 128117b Added namelist validator script - 5737064 Fixed discrepancies in drv_in - 1fcc7ab Fixed discrepancies in datm, mosart, and modelio namelists
- Loading branch information
Showing
43 changed files
with
314 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
"""clm5nl-check - CLM5 namelist validator | ||
Checks if the specified directory contains valid CLM5 namelists. | ||
Usage: | ||
clm5nl-check [DIR] | ||
Arguments: | ||
DIR Directory to check. Defaults to current directory | ||
if not specified. | ||
Options: | ||
-h --help Show this screen. | ||
-v --version Show version. | ||
""" | ||
from docopt import docopt | ||
import os, re, sys | ||
|
||
__version__ = "0.1" | ||
args = docopt(__doc__, version="clm5nl-check v" + __version__) | ||
|
||
errors = [] | ||
case_dir = os.path.abspath(args["DIR"]) if args["DIR"] else os.getcwd() | ||
if os.path.isdir(case_dir): | ||
os.chdir(case_dir) | ||
nl_pio = [f"{c}_modelio.nml" for c in ["atm", "cpl", "esp", "glc", "ice", "lnd", "ocn", "rof", "wav"]] | ||
nl_all = ["lnd_in", "datm_in", "drv_in", "drv_flds_in", "mosart_in", "seq_maps.rc"] | ||
nl_all.extend(nl_pio) | ||
if os.path.isfile("datm_in"): | ||
s_params = "".join(l for l in open("datm_in", "r").readlines() if "datm.streams.txt" in l) | ||
s_files = re.compile(r"[^('|\")]*datm.streams.txt[^\s]*").findall(s_params, re.MULTILINE) | ||
if s_files: nl_all.extend(f.strip() for f in s_files) | ||
for nl in nl_all: | ||
if not os.path.isfile(nl): | ||
errors.append(f"'{nl}' is missing") | ||
else: | ||
errors.append(f"{case_dir} does not exist") | ||
|
||
if len(errors) > 0: | ||
print("clm5nl-check errors:") | ||
for msg in errors: print(f" {msg}") | ||
sys.exit(1) | ||
|
||
|
||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.