Skip to content

Namelist Refactor#83

Closed
jjuyeonkim wants to merge 12 commits into
NOAA-GFDL:developfrom
jjuyeonkim:20250908_namelist_2
Closed

Namelist Refactor#83
jjuyeonkim wants to merge 12 commits into
NOAA-GFDL:developfrom
jjuyeonkim:20250908_namelist_2

Conversation

@jjuyeonkim

Copy link
Copy Markdown
Collaborator

Description
This is one of multiple PRs to refactor the NDSL's Namelistand NamelistDefaults so that submodules have more ownership over configuration parameters and corresponding default values. NDSL Issue#64

Changes include the following:

  • Removes usage of NamelistDefaults in the dycore config. instead, the config class will store the default values directly.
  • Uses simplified ndsl.Namelist
  • Replaces namelist with config in TranslateDycoreFortranData2Py
  • Updates translate tests with these changes
  • Modifes github workflow tests to run jjuyeonkim's fork's tests until namelist refactor is completed

Fixes: NOAA-GFDL/NDSL#64 (refactor that affects Pace, NDSL, PyFV3, and PySHiELD).

How Has This Been Tested?
PyFV3 and PySHiELD translate tests run as expected compared to the develop branch. Pace unit tests also pass as expected.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules -- There are changes in Pace, NDSL, PyFV3, and PySHiELD to address this issue. They need to be checked in together.
  • New check tests, if applicable, are included
  • Targeted model if this changed was triggered by a model need/shortcoming

- Removing NamelistDefaults in the dycore config
- Using simplified ndsl.Namelist
- Replacing namelist with config in TranslateDycoreFortranData2Py
- Updating translate tests with these changes
- Modifying workflow tests until namelist refactor is completed
@jjuyeonkim jjuyeonkim changed the title 20250908 namelist 2 Namelist Refactor Sep 9, 2025
Comment thread pyfv3/_config.py
check_negative: bool = NamelistDefaults.check_negative
layout: Tuple[int, int] = (1, 1)
grid_type: int = 0
u_max: float = 350.0 # max windspeed for dp config

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this (and the other floats) be type hinted as an NDSL defined Float, or is it sufficient for it to be a Python native float?

@jjuyeonkim jjuyeonkim Sep 12, 2025

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.

This is a good point. I think eventually they should be changed to Float.

However, I wanted to focus on the Namelist split/refactor for these PRs. If more people think that it should be part of this PR, I'll be overruled and will change it.

Comment thread pyfv3/_config.py

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.

@FlorianDeconinck @romanc I'm proposing a change to the wrapper with the Namelists refactoring. Please let me know if you have feedback on this.

Comment on lines 2303 to +2311
def compute_parallel(self, inputs, communicator):
namelist = self.namelist
grid_generator = MetricTerms.from_tile_sizing(
npx=namelist.npx,
npy=namelist.npy,
npx=self.config.npx,
npy=self.config.npy,
npz=int(inputs["npz"]),
communicator=communicator,
backend=self.stencil_factory.backend,
grid_type=namelist.grid_type,
dx_const=namelist.dx_const,
dy_const=namelist.dy_const,
deglat=namelist.deglat,
)
grid_type=self.config.grid_type,
) # Note: default dx_const, dy_const, deglat

@jjuyeonkim jjuyeonkim Sep 15, 2025

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.

@oelbert I found another spot where I wanted some feedback. Does this look okay?

When calling MetricTerms.from_tile_sizing, I removed the explicit setting of dx_const, dy_const, and deglat. These values existed in the old Namelist, but not in the DynamicalCoreConfig.

instead, I'm relying on the defaults in MetricTerms, which were the same values as the old NamelistDefaults.

@jjuyeonkim jjuyeonkim marked this pull request as ready for review September 16, 2025 23:48
@jjuyeonkim jjuyeonkim closed this Sep 17, 2025
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.

NDSL should provide a framweork for physics namelists instead of specifying the namlist members and default values for specific physics models

2 participants