Skip to content

Commit f70b449

Browse files
authored
Merge Pull Request #3014 from E3SM-Project/scream/bartgol/eamxx/atmmanip-any
Automatically Merged using E3SM Pull Request AutoTester PR Title: Change handling of multiple matches in atmchange/atmquery PR Author: bartgol PR LABELS: enhancement, AT: AUTOMERGE, scripts
2 parents 1b7eb5b + fa3ff46 commit f70b449

File tree

10 files changed

+242
-149
lines changed

10 files changed

+242
-149
lines changed

components/eamxx/cime_config/eamxx_buildnml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def perform_consistency_checks(case, xml):
126126
>>> case = MockCase({'ATM_NCPL':'24', 'REST_N':2, 'REST_OPTION':'nsteps'})
127127
>>> perform_consistency_checks(case,xml)
128128
Traceback (most recent call last):
129-
CIME.utils.CIMEError: ERROR: rrtmgp::rad_frequency incompatible with restart frequency.
129+
CIME.utils.CIMEError: ERROR: rrtmgp::rad_frequency (3 steps) incompatible with restart frequency (2 steps).
130130
Please, ensure restart happens on a step when rad is ON
131131
>>> case = MockCase({'ATM_NCPL':'24', 'REST_N':10800, 'REST_OPTION':'nseconds'})
132132
>>> perform_consistency_checks(case,xml)
@@ -970,7 +970,7 @@ def create_input_data_list_file(case,caseroot):
970970
permissions = stat.filemode(file_stat.st_mode)
971971

972972
except Exception as e:
973-
raise RuntimeError(f"Error retrieving file info for '{file_path}': {e}")
973+
raise RuntimeError(f"Error retrieving file info for '{file_path}': {e}") from e
974974

975975
curr_user = getpass.getuser()
976976
user_info = pwd.getpwnam(curr_user)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
$CIMEROOT/../components/eamxx/scripts/atmchange --all internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b
1+
$CIMEROOT/../components/eamxx/scripts/atmchange ANY::internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b
22
./xmlchange POSTRUN_SCRIPT="$CIMEROOT/../components/eamxx/scripts/check-hashes-ers"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
./xmlchange --append SCREAM_CMAKE_OPTIONS='SCREAM_SMALL_KERNELS On'
2-
$CIMEROOT/../components/eamxx/scripts/atmchange --all internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b
2+
$CIMEROOT/../components/eamxx/scripts/atmchange ANY::internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
./xmlchange --append SCREAM_CMAKE_OPTIONS='SCREAM_P3_SMALL_KERNELS On'
2-
$CIMEROOT/../components/eamxx/scripts/atmchange --all internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b
2+
$CIMEROOT/../components/eamxx/scripts/atmchange ANY::internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
./xmlchange --append SCREAM_CMAKE_OPTIONS='SCREAM_SHOC_SMALL_KERNELS On'
2-
$CIMEROOT/../components/eamxx/scripts/atmchange --all internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b
2+
$CIMEROOT/../components/eamxx/scripts/atmchange ANY::internal_diagnostics_level=1 atmosphere_processes::internal_diagnostics_level=0 -b

components/eamxx/docs/user/model_input.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ scoped name, which allows `atmchange` to uniquely identify the XML node to modif
148148
$ ./atmquery homme::number_of_subcycles
149149
namelist_defaults::atmosphere_processes::homme::number_of_subcycles: 1
150150
$ ./atmchange number_of_subcycles=10
151-
ERROR: number_of_subcycles is ambiguous (use --all to change all matches), matches:
151+
ERROR: internal_diagnostics_level is ambiguous. Use ANY in the node path to allow multiple matches. Matches:
152152
namelist_defaults::atmosphere_processes::number_of_subcycles
153153
namelist_defaults::atmosphere_processes::sc_import::number_of_subcycles
154154
namelist_defaults::atmosphere_processes::homme::number_of_subcycles
@@ -157,6 +157,7 @@ ERROR: number_of_subcycles is ambiguous (use --all to change all matches), match
157157
namelist_defaults::atmosphere_processes::physics::mac_aero_mic::tms::number_of_subcycles
158158
namelist_defaults::atmosphere_processes::physics::mac_aero_mic::shoc::number_of_subcycles
159159
namelist_defaults::atmosphere_processes::physics::mac_aero_mic::cldFraction::number_of_subcycles
160+
namelist_defaults::atmosphere_processes::physics::mac_aero_mic::spa::internal_diagnostics_level
160161
namelist_defaults::atmosphere_processes::physics::mac_aero_mic::p3::number_of_subcycles
161162
namelist_defaults::atmosphere_processes::physics::rrtmgp::number_of_subcycles
162163
namelist_defaults::atmosphere_processes::sc_export::number_of_subcycles
@@ -167,7 +168,7 @@ $ ./atmquery homme::number_of_subcycles
167168
```
168169

169170
In some cases, the user may be interested in changing _all_ nodes with a given name. In that case,
170-
the `--all` flag can be used:
171+
you can use 'ANY' as a node name:
171172

172173
```shell
173174
$ ./atmquery --grep number_of_subcycles
@@ -183,7 +184,7 @@ $ ./atmquery --grep number_of_subcycles
183184
p3::number_of_subcycles: 1
184185
rrtmgp::number_of_subcycles: 1
185186
sc_export::number_of_subcycles: 1
186-
$ ./atmchange --all number_of_subcycles=3
187+
$ ./atmchange ANY::number_of_subcycles=3
187188
Regenerating /path/to/namelist_scream.xml. Manual edits will be lost.
188189
$ ./atmquery --grep number_of_subcycles
189190
atmosphere_processes::number_of_subcycles: 3
@@ -199,6 +200,24 @@ $ ./atmquery --grep number_of_subcycles
199200
rrtmgp::number_of_subcycles: 3
200201
sc_export::number_of_subcycles: 3
201202
```
203+
In addition, "ANY" can be used in a "scoped" string, to limit the set of matches:
204+
```shell
205+
$ ./atmchange mac_aero_mic::ANY::number_of_subcycles=1
206+
Regenerating /path/to/namelist_scream.xml. Manual edits will be lost.
207+
$ ./atmquery --grep number_of_subcycles
208+
atmosphere_processes::number_of_subcycles: 3
209+
sc_import::number_of_subcycles: 3
210+
homme::number_of_subcycles: 3
211+
physics::number_of_subcycles: 3
212+
mac_aero_mic::number_of_subcycles: 1
213+
tms::number_of_subcycles: 1
214+
shoc::number_of_subcycles: 1
215+
cldFraction::number_of_subcycles: 1
216+
spa::number_of_subcycles: 1
217+
p3::number_of_subcycles: 1
218+
rrtmgp::number_of_subcycles: 3
219+
sc_export::number_of_subcycles: 3
220+
```
202221

203222
Since the XML file stores constraints on the parameter value (like its type or valid values), attempting to use the
204223
wrong type will cause an error:

0 commit comments

Comments
 (0)