@@ -108,7 +108,7 @@ def create_case(self, do_exec):
108108 if cvars ["GRID_MODE" ].value == "Standard" :
109109 resolution = cvars ["GRID" ].value
110110 elif cvars ["GRID_MODE" ].value == "Custom" :
111- resolution = Path ( cvars ["CUSTOM_GRID_PATH " ].value ). name
111+ resolution = "a%" + cvars ["CUSTOM_ATM_GRID " ].value + "_l%" + cvars [ "CUSTOM_LND_GRID" ]. value + "_oi%VisualCaseGen_Custom_r%null_g%null_w%null_z%null_m%VisualCaseGen_Custom"
112112 else :
113113 raise RuntimeError (f"Unknown grid mode: { cvars ['GRID_MODE' ].value } " )
114114
@@ -226,15 +226,34 @@ def _update_component_grids(
226226
227227 xmlchange ("ICE_DOMAIN_MESH" , ocn_mesh .as_posix (), do_exec , self ._is_non_local (), self ._out )
228228
229- xmlchange ("ATM_GRID " , cvars [ "CUSTOM_ATM_GRID" ]. value , do_exec , self ._is_non_local (), self ._out )
229+ xmlchange ("MASK_MESH " , ocn_mesh . as_posix () , do_exec , self ._is_non_local (), self ._out )
230230
231- xmlchange ("LND_GRID " , cvars [ "CUSTOM_LND_GRID" ]. value , do_exec , self ._is_non_local (), self ._out )
231+ xmlchange ("OCN_GRID " , "VCG_Changed" , do_exec , self ._is_non_local (), self ._out )
232232
233- xmlchange ("MASK_MESH" , ocn_mesh .as_posix (), do_exec , self ._is_non_local (), self ._out )
234233
235-
236-
234+ lnd_grid_mode = cvars ["LND_GRID_MODE" ].value
235+ if lnd_grid_mode == "Modified" :
236+ if cvars ["COMP_OCN" ].value != "mom" :
237+ with self ._out :
238+ print (f"{ COMMENT } Apply custom land grid xml changes:{ RESET } \n " )
239+
240+ # TODO: NO LONGER RELEVANT - OCEAN GRIDS ARE DONE THROUGH XML CHANGES AS WELL: instead of xmlchanges, these changes should be made via adding the new lnd domain mesh to
241+ # component_grids_nuopc.xml and modelgrid_aliases_nuopc.xml (just like how we handle new ocean grids)
242+
243+ # lnd domain mesh
244+ xmlchange ("LND_DOMAIN_MESH" , cvars ["INPUT_MASK_MESH" ].value , do_exec , self ._is_non_local (), self ._out )
245+
246+ # mask mesh (if modified)
247+ base_lnd_grid = cvars ["CUSTOM_LND_GRID" ].value
248+ custom_grid_path = Path (cvars ["CUSTOM_GRID_PATH" ].value )
249+ lnd_dir = custom_grid_path / "lnd"
250+ modified_mask_mesh = lnd_dir / f"{ base_lnd_grid } _mesh_mask_modifier.nc" # TODO: the way we get this filename is fragile
251+ assert modified_mask_mesh .exists (), f"Modified mask mesh file { modified_mask_mesh } does not exist."
252+ xmlchange ("MASK_MESH" , modified_mask_mesh , do_exec , self ._is_non_local (), self ._out )
253+ else :
254+ assert lnd_grid_mode in [None , "" , "Standard" ], f"Unknown land grid mode: { lnd_grid_mode } "
237255
256+
238257 def _run_create_newcase (self , caseroot , compset , resolution , do_exec ):
239258 """Run CIME's create_newcase tool to create a new case instance.
240259
@@ -301,28 +320,7 @@ def _run_create_newcase(self, caseroot, compset, resolution, do_exec):
301320 raise RuntimeError ("Error creating case." )
302321
303322 def _apply_all_xmlchanges (self , do_exec ):
304-
305- lnd_grid_mode = cvars ["LND_GRID_MODE" ].value
306- if lnd_grid_mode == "Modified" :
307- if cvars ["COMP_OCN" ].value != "mom" :
308- with self ._out :
309- print (f"{ COMMENT } Apply custom land grid xml changes:{ RESET } \n " )
310-
311- # TODO: instead of xmlchanges, these changes should be made via adding the new lnd domain mesh to
312- # component_grids_nuopc.xml and modelgrid_aliases_nuopc.xml (just like how we handle new ocean grids)
313-
314- # lnd domain mesh
315- xmlchange ("LND_DOMAIN_MESH" , cvars ["INPUT_MASK_MESH" ].value , do_exec , self ._is_non_local (), self ._out )
316-
317- # mask mesh (if modified)
318- base_lnd_grid = cvars ["CUSTOM_LND_GRID" ].value
319- custom_grid_path = Path (cvars ["CUSTOM_GRID_PATH" ].value )
320- lnd_dir = custom_grid_path / "lnd"
321- modified_mask_mesh = lnd_dir / f"{ base_lnd_grid } _mesh_mask_modifier.nc" # TODO: the way we get this filename is fragile
322- assert modified_mask_mesh .exists (), f"Modified mask mesh file { modified_mask_mesh } does not exist."
323- xmlchange ("MASK_MESH" , modified_mask_mesh , do_exec , self ._is_non_local (), self ._out )
324- else :
325- assert lnd_grid_mode in [None , "" , "Standard" ], f"Unknown land grid mode: { lnd_grid_mode } "
323+ """Apply all the necessary xmlchanges to the case."""
326324
327325 # Set NTASKS based on grid size. e.g. NX * NY < max_pts_per_core
328326 if cvars ["COMP_OCN" ].value == "mom" :
0 commit comments