Skip to content

Fix stale 'ocnice' grid directory references in case creation - #45

Open
manishvenu wants to merge 9 commits into
mainfrom
fix/stale-ocnice-grid-paths
Open

manishvenu wants to merge 9 commits into
mainfrom
fix/stale-ocnice-grid-paths

Conversation

@manishvenu

Copy link
Copy Markdown
Collaborator

Summary

  • CrocoDash's Case creation writes MOM6/CICE/WW3 grid files into separate ocean/sea_ice/wave subdirectories, but several call sites here still looked for a single combined ocnice directory that no longer exists on disk.
  • This made _update_component_grids_xml's ocn_dir existence assertion fail unconditionally for every custom-grid case created through CaseCreator (add_grids_to_ccs_config=False path). The AssertionError was silently swallowed by the caller's broad except Exception, so case.setup never actually ran and the MOM6 grid namelist section (NIGLOBAL, GRID_CONFIG, GRID_FILE, ...) never got written to user_nl_mom -- the case looked like it was created successfully, but only surfaced as a KeyError: 'NIGLOBAL' much later, at case.build time.
  • get_custom_ocn_grid_path() now points at "ocean" (matching where MOM6's supergrid/topo/vgrid/scrip/ESMF-mesh files actually live). Added two new sibling methods, get_custom_ice_grid_path() (-> "sea_ice") and get_custom_wave_grid_path() (-> "wave"), since CICE's grid file and WW3's .inp files live in their own subdirectories, not alongside the ocean grid files.

Test plan

  • Fresh ocean-only `Case()` + `configure_forcings()` + `process_forcings()` now writes the full MOM6 grid section to `user_nl_mom`, and `case.setup`/`case.build` complete successfully (previously failed with `KeyError: 'NIGLOBAL'` at build time).
  • Submitted the resulting case to the real PBS queue on Derecho to confirm the run itself starts.
  • Rebuilt a WW3-active case (custom ocean grid reused as the wave grid) with the fix and confirmed `case.build` succeeds.

CrocoDash's Case creation writes MOM6/CICE/WW3 grid files into separate
ocean/sea_ice/wave subdirectories, but several call sites here still
looked for a single combined "ocnice" directory that no longer exists.
This made _update_component_grids_xml's ocn_dir existence assertion
fail unconditionally for every custom-grid case, which was silently
swallowed by CrocoDash's Case.__init__ -- case.setup never ran, and
MOM6's grid namelist section (NIGLOBAL, GRID_CONFIG, ...) never got
written to user_nl_mom, only surfacing as a KeyError at build time.

get_custom_ocn_grid_path() now points at "ocean"; new
get_custom_ice_grid_path()/get_custom_wave_grid_path() cover CICE's
grid file and WW3's *.inp files, which live in their own subdirectories.
Needed by CrocoDash's process_cice_forcing (extract_forcings/cice.py),
which calls supergrid.expand(n_halo_cells) to grow the CICE grid by a
halo before regridding -- the previously-pinned commit predates that
method entirely. Points at NCAR/mom6_forge#122 (still open upstream;
rebase onto its merge commit once that lands).
manishvenu added a commit to CROCODILE-CESM/CrocoDash that referenced this pull request Aug 7, 2026
visualCaseGen previously looked for a single combined "ocnice" grid
directory that no longer exists (CrocoDash's Case creation writes
ocean/sea_ice/wave separately), which silently broke case.setup for
every custom-grid case -- see ESMCI/visualCaseGen#45. Its embedded
external/mom6_forge was also several months stale and missing
SupergridBase.expand(), needed by process_cice_forcing.
Picks up NCAR/mom6_forge#112 (calendar-arg-chl), merged with the
existing expand() bump. interpolate_and_fill_seawifs() now accepts a
calendar kwarg, matching what CrocoDash's process_chl() has been
passing since CrocoDash#220.
Comment thread visualCaseGen/custom_widget_types/mom6_forge_launcher.py Outdated
def get_custom_ice_grid_path():
"""Return the path to the directory where the custom CICE grid file is to be stored."""
custom_grid_path = cvars["CUSTOM_GRID_PATH"].value
return Path(custom_grid_path) / "sea_ice"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set the path to "ice" instead of sea_ice?.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any concern about land ice?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Land ice is "glc".

Comment thread visualCaseGen/custom_widget_types/mom6_forge_launcher.py Outdated
Comment thread visualCaseGen/custom_widget_types/mom6_forge_launcher.py Outdated
Rename the custom grid subdirectories to match CIME component naming:
ocean -> ocn, sea_ice -> ice, wave -> wav. Applied at every site, not
just the accessors -- including the WW3 *.inp glob in case_creator,
where a stale name silently copied zero files rather than erroring.

Also create the CICE grid directory in _create_notebook_object. The
generated notebook calls Topo.write_cice_grid, which (unlike
write_ww3_input) does not create parent directories, so a CICE-active
case previously failed with FileNotFoundError.

@alperaltuntas alperaltuntas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below are a couple more line comments. Also, the mom6_forge commit hash doesn't appear to be pointing to a commit that's in the main branch. Could you elaborate on that?

"""Return the path to the directory where the custom ocean grid files are to be stored."""
custom_grid_path = cvars["CUSTOM_GRID_PATH"].value
return Path(custom_grid_path) / "ocnice"
return Path(custom_grid_path) / "ocn"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now need to update the documentation and the examples where we had ocnice.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return Path(custom_grid_path) / "ice"

@staticmethod
def get_custom_wave_grid_path():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rename this function as get_custom_wav_grid_path to be consistent with the other two.

@manishvenu

Copy link
Copy Markdown
Collaborator Author

Reverted the m6f change, not sure what that was there for.

@manishvenu

Copy link
Copy Markdown
Collaborator Author

Do you mind if we bring in mom6_forge main on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants