normalize_namelists.py#
Normalizes style in eCLM namelist files so that diffs between runs are clean and human-readable.
What it does#
The script applies three transformations to every namelist file it finds:
Indentation — lines inside a
&group … /block are re-indented to exactly two spaces. Group header (&group) and closing (/) lines are left as-is.Quote style — string values delimited by double quotes are rewritten to use single quotes (
"value"→'value'). The value content is never modified.Continuation alignment — continuation lines of multi-line values are indented to align with the value start on the
key = valueline above:hist_fincl1 = 'SOILWATER_10CM', 'H2OSOI', 'SOILLIQ', 'SOILICE'
Lines outside a group (blank lines, comment blocks appended by
modify_case_namelists.py, etc.) are passed through unchanged.
Files processed#
The script looks for the following files in the target directory:
File |
Description |
|---|---|
|
Driver field list |
|
Driver namelist |
|
Land model namelist |
|
Data atmosphere namelist |
|
River routing namelist |
|
Per-component I/O namelists |
Files that are not present in the directory are silently skipped.
Usage#
# Normalize all namelist files in the current directory
python3 normalize_namelists.py
# Normalize files in a specific run directory
python3 normalize_namelists.py /path/to/rundir
# Preview which files would change without writing anything
python3 normalize_namelists.py --dry-run [rundir]
Options#
Option |
Description |
|---|---|
|
Path to the directory containing namelist files. Defaults to |
|
Print which files would be modified without writing any changes |
Output#
For each file the script reports one of three outcomes:
lnd_in: normalized # file was changed and written
drv_in: no changes # file was already normalized
datm_in: would be modified # --dry-run: file would change