Merge stochastic physics (SPPT only) into GSL's develop branch#239
Merge stochastic physics (SPPT only) into GSL's develop branch#239gsketefian wants to merge 205 commits into
Conversation
…he stochastic_physics submodule itself will be added in a separate commit.
…'t updated during latest merge of gsl/develop.
…he gsl/MPAS_stoch_physics in the stochastic_physics repo.
…teger seed workaround.
… smoke) from "output" to "output_smoke" (and file from "history..." to "history_smoke...". This is necessary because the stream name "output" is already taken by the main output stream, and having the same name for two different output streams apparently causes SMIOL I/O errors during the forecast (and incorrect/corrupted history*.nc files).
…) no stale stream_list.atmosphere files exist in the two default_inputs directories (one under core_atmosphere and the other immediately under the MPAS-Model top-level directory), and (2) for the atmosphere core, all files (stream-related as well as namelist) in the top-level directory are backed up before new such files are copied from the default_inputs directory back up a level into the top-level directory. Previously, existing (and thus possibly outdated) stream_list.atmosphere.* files in the top-level directory were not being replaced by newer ones in default_inputs, and that was causing unexpected (and wrong) behavior. Probably a similar fix is needed for the init_atmsophere core and maybe even other ones.
…ll as its output file) so it doesn't conflict with the default output stream.
…tochastic_physics's master branh will gradually happen.
…/MPAS_stoch_physics_try_merge_stoch_master
…tochastic_physics code know that the dycore being used is MPAS.
…ill instead be defined in the Makefile for stochastic_physics only (in a separate commit into the stochastic_physics repo) since it is only needed by the stochastic_physics submodule.
…e that is now added in the Makefile in stochastic_physics).
…s the TEMPO tables.
…ysics_try_merge_stoch_master' into gsl/MPAS_stoch_physics_try_merge_stoch_master
…chastic_physics submodule (from mpas_stochastic_physics.F to mpas_stochastic_physics.F90) to reflect change in directory tree.
Change the fetch URL from dustinswales/stochastic_physics to dtcenter/stochastic_physics, which is the authoritative upstream that contains the required commit (063b1897).
| COMMAND mpas_streams_gen ${CMAKE_CURRENT_BINARY_DIR}/Registry_processed.xml streams.${ARG_CORE} stream_list.${ARG_CORE}. listed | ||
| COMMENT "CORE ${ARG_CORE}: Generate Streams" | ||
| DEPENDS mpas_streams_gen Registry_processed.xml) | ||
| DEPENDS mpas_streams_gen ${CMAKE_CURRENT_BINARY_DIR}/Registry_processed.xml) |
There was a problem hiding this comment.
why we need to add ${CMAKE_CURRENT_BINARY_DIR}?
There was a problem hiding this comment.
@gsketefian or @NingWang325, is this one you can answer?
There was a problem hiding this comment.
I'm working on remembering the details of why I needed this.
There was a problem hiding this comment.
Pull request overview
This PR integrates the NOAA-PSL stochastic_physics package (SPPT scheme only) into MPAS-Model as a git submodule, plumbing the perturbation pattern generation and application into the atmosphere core's init/timestep/RK3 paths and the registry. It also adds a dedicated CI workflow that runs convection_permitting and hrrrv5 winter GFS cases with SPPT enabled, plus build-system support (MKL/LAPACK, NetCDF-Fortran) on several HPC modulefiles and CI images.
Changes:
- Add
stochastic_physicsas a submodule with corresponding Make/CMake/Registry wiring and SPPT call sites inatm_core_init,atm_do_timestep, andatm_srk3. - New CI workflow
run_mpas_stoch.ymland new test case directoriesufscommunity.{convection_permitting,hrrrv5}.gfs.winter.stoch(namelists, streams, stream_lists). - Build environment updates: LAPACK/BLAS/MKL on modulefiles and CI, NetCDF-Fortran setup,
MPAS_USE_MPI_F08always defined, registry-processed-file paths made absolute in CMake.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| testing_and_setup/ufs-community/cases/ufscommunity.hrrrv5.gfs.winter.stoch/* | New SPPT test case files (namelist, streams, stream lists) for the hrrrv5 suite. |
| testing_and_setup/ufs-community/cases/ufscommunity.convection_permitting.gfs.winter.stoch/* | New SPPT test case files for the convection_permitting suite. |
| src/Makefile | Adds $(LAPACK_LIBS) to the link line; introduces an esmf_time_f91 typo in the -I path. |
| src/core_atmosphere/Registry.xml | Adds Gaussian-grid dims (hard-coded 504/248) and new stoch_pattern_* variables; includes stochastic_physics registry. |
| src/core_atmosphere/mpas_atm_core.F | Wires stochastic_physics_pattern_init and _adv into init and timestep paths. |
| src/core_atmosphere/Makefile | Builds and links the stochastic_physics library; reworks post_build to back up existing default_inputs. |
| src/core_atmosphere/dynamics/mpas_atm_time_integration.F | Calls stochastic_physics_pattern_apply for 'phys' and 'prog' tendencies in atm_srk3. |
| src/core_atmosphere/dynamics/Makefile | Adds -I../stochastic_physics include path. |
| src/core_atmosphere/CMakeLists.txt | Defines a stochastic_physics CMake target with BLAS/NetCDF deps and links it into core_atmosphere. |
| modulefiles/mpas/{derecho,gaeac6,hera,orion,ursa}.intel.lua | Loads Intel MKL and exports NetCDF C/Fortran root env vars. |
| Makefile | Adds LAPACK_LIBS to relevant build targets; adds new intel-mpi-gaeac6 build target. |
| CMakeLists.txt | Always defines MPAS_USE_MPI_F08; adds explicit dependency to serialize init_atmosphere on core_atmosphere builds. |
| cmake/Functions/MPAS_Functions.cmake | Uses absolute ${CMAKE_CURRENT_BINARY_DIR} paths for Registry_processed.xml dependencies. |
| .gitmodules | Adds src/core_atmosphere/stochastic_physics submodule pointing at dtcenter fork. |
| .github/workflows/run_mpas.yml, run_mpas_hrrr.yml, build_mpas.yml, build_mpas_intel.yml | Add LAPACK/BLAS, NetCDF setup, and MKL support; minor commented-out trigger lines. |
| .github/workflows/run_mpas_stoch.yml | New CI workflow that runs baseline vs feature SPPT-enabled MPAS and compares outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| mpas: $(AUTOCLEAN_DEPS) externals frame ops dycore drver | ||
| $(LINKER) $(LDFLAGS) -o $(EXE_NAME) driver/*.o -L. -ldycore -lops -lframework $(LIBS) -I./external/esmf_time_f90 -L./external/esmf_time_f90 -lesmf_time | ||
| $(LINKER) $(LDFLAGS) -o $(EXE_NAME) driver/*.o -L. -ldycore -lops -lframework $(LIBS) -I./external/esmf_time_f91 -L./external/esmf_time_f90 -lesmf_time $(LAPACK_LIBS) |
There was a problem hiding this comment.
I noticed this as well but thought it might be intentional by @NingWang325. Kind of surprising that it works! @NingWang325 can you say if it's intentional or a typo?
| <dim name="lon_for" definition="504" | ||
| description="The number of longitude points for the Gaussian grid"/> | ||
| <dim name="lat_leg" definition="248" | ||
| description="The number of latitude points for the Gaussian grid"/> |
There was a problem hiding this comment.
Without full comprehension of what these variables are used for, I think Copilot has some valid points here.
There was a problem hiding this comment.
My browser quit on me so I don't know if this will be a duplicate comments or not... Without fully understanding what these variables are for, it seems Copilot has some good points here.
There was a problem hiding this comment.
From @NingWang325, these arrays are only used for debugging. These fields aren't being used otherwise. They can be removed.
| ! | ||
| ! init stochastic pattern generation | ||
| if (dosppt(domain)) then | ||
| call stochastic_physics_pattern_init (domain, ierr) | ||
| endif |
There was a problem hiding this comment.
From @NingWang325: this code follows procedure from NOAA-PSL/stochastic_physics to ensure initialization is successful. For now, a message is passed to the log saying that stochastic physics could not be initialized.
We need to stop the run in NOAA-PSL/stochastic_physics if initialization of any expect stochastic physics method fails. Check the "ierr" value and issue a stop command.
|
@gsketefian @NingWang325 @JeffBeck-NOAA I turned Copilot loose on a review of this PR. It generated five comments, the first few of which (at minimum) look like things that need to be addressed before merge. |
| &soundings | ||
| config_sounding_interval = 'none' | ||
| / | ||
| &nam_stochy |
There was a problem hiding this comment.
just curious, why "nam_stochy"?
There was a problem hiding this comment.
@joeolson42 I think this is what the stochastic physics namelist in the FV3 is called, so we just kept it. My guess as to its meaning: "nam" = namelist, "stochy" = "stochastic". Not sure about the "y" in "stochy". I can't find any explanation in the inline comments in the stochastic_physics code. It might have French origins, since I think there were some French developers working on the code at some point. I'm curious too, so I'll ask @pjpegion in the companion PR #97 into the NOAA-PSL/stochastic_physics repo.
Here's the link to my question.
There was a problem hiding this comment.
@joeolson42 Sorry, turns out @pjpegion doesn't know the answer regarding the "y" in "stochy".
I’d personally prefer a more straightforward name like stoch_phys or stoch_physics for the namelist, though it isn't a strong preference.
There was a problem hiding this comment.
I'd prefer something like "stoch_physics" too, but since it's just a preference, it can't be considered a mandatory change. Maybe let others weigh in.
There was a problem hiding this comment.
@joeolson42 I'm still curious about the "y" in "stochy", especially since it's used not just in "nam_stochy" but also all throughout the stochastic_physics code. I had claude look at that code to see if it can come up with an explanation for the "y". It said:
"stochy" reads as an adjectival nickname — like "patchy" or "scratchy" — a natural informal shorthand for "stochastic" that is also more distinctive as an identifier prefix than the bare stem "stoch".
I'm content with that.
… launching of CI tests on push.
| ! | ||
| ! init stochastic pattern generation | ||
| if (dosppt(domain)) then | ||
| call stochastic_physics_pattern_init (domain, ierr) |
There was a problem hiding this comment.
@gsketefian Should this die and report error if initialization fails?
There was a problem hiding this comment.
@dustinswales I would think it should at least write out a warning in the log file(s) if not die altogether, but I think @NingWang325 is best suited to answer this one.
| if("atmosphere" IN_LIST MPAS_CORES AND "init_atmosphere" IN_LIST MPAS_CORES) | ||
| add_dependencies(mpas_init_atmosphere core_atmosphere) | ||
| endif() | ||
|
|
There was a problem hiding this comment.
Lines 128-134: Is this a new requirement due to the stochastic physics?
I don't think we need this dependency before.
joeolson42
left a comment
There was a problem hiding this comment.
Conditionally approved, pending any changes needed to address comments.
…multiplication subroutine.
…n building with the stand-alone MPAS-Model, stochastic_physics uses "dgemm" instead of "esmf_dgemm" to perform matrix multiplication.
…mpi-gaeac6" for building the stand-alone MPAS-Model with stochastic_physics on Gaea C6 because it turns out that the existing "ifort_icx" target can be used for this purpose -- as long as a small modification (addition of LAPACK_LIBS) is made to it, which we also do here.
|
@gsketefian Can you sync this branch with the noaa/develop branch? |
| COMMAND mpas_streams_gen ${CMAKE_CURRENT_BINARY_DIR}/Registry_processed.xml streams.${ARG_CORE} stream_list.${ARG_CORE}. listed | ||
| COMMENT "CORE ${ARG_CORE}: Generate Streams" | ||
| DEPENDS mpas_streams_gen Registry_processed.xml) | ||
| DEPENDS mpas_streams_gen ${CMAKE_CURRENT_BINARY_DIR}/Registry_processed.xml) |
There was a problem hiding this comment.
Lines 217-234:
Did we get any troubles without these newly added ${CMAKE_CURRENT_BINARY_DIR} etc?
If not, I would suggest removing all the newly added ${CMAKE_CURRENT_BINARY_DIR} etc to keep sync'ed with the upstream NCAR's MPAS-Dev/MPAS-Model as much as possible.
This PR enables use of the SPPT scheme of stochastic physics into MPAS-Model. This is addressed in Issue #204.
Main changes:
stochastic_physicscode as a submodule.Makefiles, registryxmlfiles, and fortran files, and GitHub workflow files to allow the SPPT stochastic scheme to be used with MPAS.stochastic_physicscode as a submodule. There is a companion PR into the authoritativestochastic_physicsrepo here.This PR adds a new GitHub Actions CI workflow (
run_mpas_stoch.yml) that runs two tests of MPAS-Model on a winter case using GFS ICs/LBCs and with SPPT enabled. The first test is the "convection_permitting" physics suite, and the second is with the "hrrrv5" suite. These two tests use the same grid, static file, ICs, LBCs, etc as the existing CI test(s) for the winter case with GFS ICs/LBCs, etc. These tests require the setup (namelist, streams, etc) files located in the directoriesMandatory Questions
MPAS-Model/testing_and_setup/ufs-community/cases/ufscommunity.[convection_permitting|hrrrv5].gfs.winter.stoch, which are under version control.Priority Reviewers