Skip to content

[DSL] Moist physics: UW, GFDL_1M and GF2020#1231

Merged
mathomp4 merged 168 commits intoGEOS-ESM:developfrom
FlorianDeconinck:dsl/feature/moist/UW_and_GFDL1M
May 6, 2026
Merged

[DSL] Moist physics: UW, GFDL_1M and GF2020#1231
mathomp4 merged 168 commits intoGEOS-ESM:developfrom
FlorianDeconinck:dsl/feature/moist/UW_and_GFDL1M

Conversation

@FlorianDeconinck
Copy link
Copy Markdown
Collaborator

@FlorianDeconinck FlorianDeconinck commented Mar 25, 2026

This PR brings the work of @katrinafandrich and @CharlesKrop to mainline GEOS.

It cover the first DSL-powered version of the UW and GFDL_1M parametrization. All the files exists in a pyMoist directoy within the GEOSmoist_GridComp directory. The pyMoist is a self-sustaining package but is not use like one for runs on Discover (see GEOS-ESM/GEOSgcm_App#826 PR and GEOS-ESM/ESMA_env#178).

The status of the parametrizations are:

  • GFDL_1M: first SCM experiments are showing some small instability. Expect follow up fixing PR.
  • UW: code is not up to DSL standards yet but is functional with good results on SCM experiments. Follow up PR to clean up and raise the code to DSL standards.
  • GF2020: code is slowly drifting but within reason. Expect following fixing PR.

Continuous integration:

  • A new github workflow ndsl-checks to run specific checks for pyMoist code on a paths hooks

Build:

  • Changed GEOSmoist_GridComp to a shared library so the python dynamically open it and fetch fortran hooks
  • Requires dependencies fms_r4 to be spelled out for the previous change to work
  • Install pyMoist python code in lib/Python

Change to the Fortran:

  • MoistGridComp
    • A new Finalize function to allow for profiler data collection in the DSL
  • GFDL_1M_Interface
    • Introducing a USE_PYMOIST_GFD1M flag to turn on/off the DSL code
    • Introducing custom code for convection tracers that move them to Structure of Arrays - fitting the DSL needs
    • A new Finalize function to allow for profiler data collection in the DSL
  • UW_Interface
    • Introducing a USE_PYMOIST_UW flag to turn on/off the DSL code
    • A new Finalize function to allow for profiler data collection in the DSL

Closes #1232

@FlorianDeconinck FlorianDeconinck marked this pull request as draft March 26, 2026 20:23
@FlorianDeconinck
Copy link
Copy Markdown
Collaborator Author

Pulling back to draft for now as we have discovered a failing interaction between the Python and the model.

To reviewers: the Fortran is still correct and can be reviewed as-is.

@FlorianDeconinck FlorianDeconinck marked this pull request as ready for review March 31, 2026 18:33
@mathomp4
Copy link
Copy Markdown
Member

I just tested this with current GEOSgcm v11 along with GEOS-ESM/GEOSgcm_App#826

I believe all the other DSL PRs are in various tags on other repos.


Well, technically, I tested FlorianDeconinck#13 which is a merge of this PR ( #1231 ) and #1232

* v11: Remove FMS dependence in Moist

* Fix call to gfdl

* One last fms
@FlorianDeconinck FlorianDeconinck changed the title [DSL] Moist physics: UW & GFDL_1M [DSL] Moist physics: UW, GFDL_1M and GF2020 Apr 24, 2026
@FlorianDeconinck FlorianDeconinck marked this pull request as draft April 24, 2026 15:19
@FlorianDeconinck
Copy link
Copy Markdown
Collaborator Author

Pulling back the PR to draft as we have additional ports (GF and UW unlocked for all levels) that have come to completion in the meantime. We will merge those and re-push the PR for merge.

In the interval, this PR still depends on

To be merged for the system to be usable on the HPC.

katrinafandrich and others added 2 commits April 24, 2026 16:43
…14)

* Updated UW to include code for LM=181. This code has not been tested.

* Fixed UW interface and config for 181 level code. And set NUMBER_OF_TRACERS to NCNST.

* Clean up of bad code calling down to Python

* Minor fix to 181 level code

* Added NOOP to get Fortran-In and -Out files

* Added UW init to UW run to get a clean class each timestep

* Reset state output vars to zero. Just a test.

* Remove debug code.

* Added flag to turn on/off state recorder.

* Formatting fixes from `pre-commit run` and other PR fixes.

---------

Co-authored-by: Katrina Fandrich <[email protected]>
Co-authored-by: Florian Deconinck <[email protected]>
* GF2020: changed PLUME_ORDER to SHALLOW_MID_DEEP, bringing it back in line with fortran behavior

* GF2020: removing dynamic intervals

* GF2020: updating a couple translate tests that were missed in the DTIME --> DT_MOIST change

* GF2020: Updated CumulusParameterization comments with new test results (using dace instead of debug backend) and updated a few comments to reflected changes to translate test names

* GF2020: cleaning up large_scale_forcing

* better .gitignore (#8)

We've been tracking (in git) an empty vscode config and a temp graph
from dace. This commit removes both files and

- moves the `.vscode/` ignore "up" to the grid comp
- adds `_dacegraphs/` to the ignore paths because it will only ever
  contain invalid/failed dace graphs for debugging.

* GF2020: fix typos (#9)

* GF2020: fix typos

* fix typo in README

* GF2020: fix ensemble_forcing_mid_plume (#10)

Fix access of `updraft_lfc_level` inside `ensemble_forcing_mid_plume`.

* GF2020: updating comments for LargeScaleForcing test

* GF2020: removing a quantity --> np array --> stencil, passing a slice of the field to the stencil instead

* GF2020: changing .field to .data in a few places

* GF2020: .data to .field in translate test

* Updated UW to include code for LM=181. This code has not been tested.

* constants file was broken when GF2020 was manually merged, fixing

* Fixed UW interface and config for 181 level code. And set NUMBER_OF_TRACERS to NCNST.

* Clean up of bad code calling down to Python

* Protect GetPointer call when association has been read to be False - to avoid `icpx` failure

* fix: manually inline `cap_max_internal` in the right computation (#11)

* unrelated: fall back to default number of tracers

* unrelated: namelist is unused in `TestCore`

* unrelated: fixing typos in GF_2020

* unrelated: fixing typos (2) in GF2020

* unrelated: start_level and lcl_level are both 2d

* unrelated: unused variables

* unrelated: cleanup dzh temporary

The temprory `dzh` is only used in that scope and can be (manually)
scalarized. No need to have an IJ-Field.

* fix: manually inline `cap_max_internal` in the right computation

`cap_max_internal` might be read before written (in case `MOIST_TRIGGER`
is not `1`). DaCe wronly scalarizes the variable into both (previous)
computation blocks. That leads to a potential read of undefined memory
in the later computation block. Manually scoping `cap_max_internal` to
the later block ensures that an initial value is written before the
variable is read the first time.

This is only a temp fix. I'll go debug the DaCe scalarization ...

* GF2020: fix for DowndraftWindShear

* GF2020: fix for DowndraftWindShear

* cleanup: don't pass unused arguments

---------

Co-authored-by: Charles Kropiewnicki <[email protected]>

* [dsl]: Fix and cleanup GF2020 and GFDL_1M translate tests (#12)

* fix/cleanup GF translate tests

This PR fixes and cleans up translate tests of GF2020. The things you
will find in this PR are:

1. Fix cumulus parametrization (args of `StaticControl`)
2. Clean up tests by not passing `namelist` down to `TestCore` if
   it isn't used there.
3. Fix some translate tests (e.g. GF2020) that were initializing
   `TranslateFortranData2Py` with `namelist`. `namelist` has never been
   an argument of that base class.
4. Cleaning up tests by not overloading `self.stencil_factory` in the
   subclass (the baseclass already assigns, given the right arguments
   are passed to the base class (see 3)).

* fix / cleanup GFDL_1M translate tests

This commit changes the translate tests of the GFDL_1M microphysics
code. In particular, this PR

1. fixes tests that were initiliazing `TranslateFortranData2Py` with a
   namelist argument (there is no such argument).
2. cleans up translate tests that were shadowing `self.stencil_factory`
   in the subclasse (already done in the base class).

* Updating tracer constants

* GF2020: more guards and removing duplicate constant

* GF2020 fortran side of the interface

* GF2020 python side of the interface

* GF2020 integration - python is numerically stable, but does not quite agree with the fortran (consistently about 0.5 degrees C too cold after the first day or so)

* GF2020: Safer data dimension management

* GF2020: fixed a few small bugs in the numerics

* GF2020: put namelist back into a translate test

* GF2020: disable two variables in GF2020_CumulusParameterization that fail b/c of a bug on the fortran side

* GF2020: minor translate test updates

* GF2020: bunch of changes/bugfixes in Setup & Finalize

* Minor fix to 181 level code

* GF2020: test reorganization

renamed one test, moved another to a different folder

* GF2020: fixes bringing the code in line with 11.8.1

* GF2020: flipped shallow and deep entrainment in the interface

* GF2020: remove seed convection from inputs in GF2020 translate test

* GFDL1M: few bugs in the interface

* GF2020: stencil in setup needed K_INTERFACE_DIM instead of K_DIM

* GF2020: fixing bad fortran conditional

* GF2020: added dynamic call support to GF2020 test

* GF2020: reworked lat/lon integration to python

* GF2020: removing initial precipitable water fields from inputs of GF2020 and GF2020_Setup tests (after they were removed form the savepoint). changed the data source for the GF2020_Finalize savepoint for those two fields

* GF2020: getting domain side properly for one of the setup stencils

* fixing a dace bug

* GF2020: fixed some bad defaults in the interface

* GF2020: bugfix in finalize, putting optional outputs in their own stencils, with the execution hidden behind an existance check

* GF2020: minor bugfixes in the interface - bad defaults and incorrect alloc=True

* Added NOOP to get Fortran-In and -Out files

* Added UW init to UW run to get a clean class each timestep

* Reset state output vars to zero. Just a test.

* Remove debug code.

* GF2020: added a pbl level shift to the interface

unlike microphysics, gf convection takes a level (pbl_level) from the model state. this level must be adjusted by one to python indexing before the python runs, then back to fortran indexing before it is passed back to the rest of the state

* Added flag to turn on/off state recorder.

* Formatting fixes from `pre-commit run` and other PR fixes.

* GF2020: pre-commit - automatic changes, reformatting and such

* GF2020: removing most instances of == True. some cannot be removed, as doing if (X and Y): breaks when x or why is a boolean. Error: "ValueError: Arithmetic expression is not allowed in boolean operation."

* GF2020: changing == False to "not"

* GF2020: bugfix, changing == True to == 1 for ENABLE_SHALLOW/MID/DEEP, as these fields are integers (albiet always 0 or 1) and not booleans

* GF2020: unused imports

* GF2020: two minor changes to make pre-commit happy

* GF2020: type: ignores and noqas to make pre-commit happy

* reverting changes that were made at various times that should not have been pushed

* Changed pre-commit line length to 170

* Cast is enforced via dtype callable - which fails lint but is portable between numpy , cupy and python. Type ignored.

---------

Co-authored-by: Roman Cattaneo <[email protected]>
Co-authored-by: Katrina Fandrich <[email protected]>
Co-authored-by: Florian Deconinck <[email protected]>
@FlorianDeconinck FlorianDeconinck marked this pull request as ready for review April 27, 2026 15:35
@FlorianDeconinck
Copy link
Copy Markdown
Collaborator Author

Branch back ready for merge. Grell-Freitas 2020 part of the fray news. Changes are restricted to the integration of the DSL into the GEOS_GF_InterfaceMod.

GEOS-ESM/GEOSgcm_App#826 still to be merged first

@mathomp4
Copy link
Copy Markdown
Member

Retested and still 0-diff.

@sdrabenh sdrabenh removed the Contingent - DNA These changes are contingent on other PRs (DNA=do not approve) label May 6, 2026
@mathomp4 mathomp4 added 0 diff structural Structural changes to repository that are zero-diff and removed 0 diff structural Structural changes to repository that are zero-diff labels May 6, 2026
@mathomp4 mathomp4 merged commit 1b755ec into GEOS-ESM:develop May 6, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 diff The changes in this pull request have verified to be zero-diff with the target branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants