Skip to content

Merge stochastic physics (SPPT only) into GSL's develop branch#239

Draft
gsketefian wants to merge 44 commits intoufs-community:gsl/developfrom
dtcenter:gsl/MPAS_stoch_physics_try_merge_stoch_master
Draft

Merge stochastic physics (SPPT only) into GSL's develop branch#239
gsketefian wants to merge 44 commits intoufs-community:gsl/developfrom
dtcenter:gsl/MPAS_stoch_physics_try_merge_stoch_master

Conversation

@gsketefian
Copy link
Copy Markdown

@gsketefian gsketefian commented Mar 31, 2026

This PR enables use of the SPPT scheme of stochastic physics into MPAS-Model. This is addressed in Issue #204.

Main changes:

  1. Bring in the stochastic_physics code as a submodule.
  2. Make changes to Makefiles, registry xml files, and fortran files to allow the SPPT stochastic scheme to bue used with MPAS.
  3. Adds the stochastic_physics code as a submodule. There is a companion PR into the authoritative stochastic_physics repo here.

Note that this PR still requires make to be used to build MPAS-Model with stochastic physics. The ability to build with cmake will come in a separate PR.

Mandatory Questions

  • Does this PR include any additions or changes to external inputs (e.g., microphysics lookup tables, static data for gravity-wave drag -- things like that)?
    • No
  • Does this PR require updating one or more baselines for the CI tests? If so, what?
    • Yes. We would like to add at least one test that runs MPAS with SPPT enabled. We are also curious about how to include regression tests if those are used in this repo.

Priority Reviewers

gsketefian and others added 30 commits September 12, 2025 12:36
…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.
… 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.
…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).
@@ -65,7 +65,8 @@ core_physics_mmm: core_physics_init
(cd physics_mmm; $(MAKE) -f Makefile.mpas all)

core_microphysics: core_physics_init core_physics_mmm
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changes in first line are to copy ccn_activate.bin into the top-level MPAS-Model directory, just as other microphysics files are copied there during a make invocation (e.g. MP_THOMPSON_*).


core_microphysics: core_physics_init core_physics_mmm
(cd physics_noaa/TEMPO; $(MAKE) -f Makefile.mpas)
(cd physics_noaa/TEMPO; $(MAKE) -f Makefile.mpas; cp tables/ccn_activate.bin ../../../../../)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The following new line builds TEMPO's run_build_tables executable, which is needed to generate the tables for TEMPO. This is similar to the building of the build_tables executable for THOMPSON microphysics.

Not sure why this wasn't originally included. Also, not sure if this work with all machines and compilers, but it works on Hera.

Copy link
Copy Markdown
Author

@gsketefian gsketefian Mar 31, 2026

Choose a reason for hiding this comment

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

@clark-evans Not sure if you're the right person to ask this. If not, please let me know who to ask (Anders?).

I'm wondering why the original version of this Makefile does not build the executable for generating the TEMPO MP tables. I tried to include it via this line, but it is failing during CI testing because the sub-makefile called (Makefile.intel) is apparently only for intel, but one of the CI tests is with gnu FORTRAN.

Without this executable (named run_build_tables) a user will not be able to generate the tables needed to run MPAS with TEMPO. Note that an executable for generating tables for THOMPSON MP (named build_tables) is generated during the make, so it would be nice to have one for TEMPO as well.

I will comment out this line for now so the CI tests can proceed, but it would be nice to understand why building run_build_tables (regardless of compiler) is not part of the original Makefile.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @gsketefian -- I think this is handled in src/core_atmosphere/utils/Makefile, where directives for compiling build_tables_tempo are provided alongside those for build_tables. This is called when core_atmosphere is built.

Tagging @AndersJensen-NOAA to correct me in case I'm wrong, though...

Copy link
Copy Markdown
Author

@gsketefian gsketefian Apr 1, 2026

Choose a reason for hiding this comment

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

@clark-evans @AndersJensen-NOAA As far as I can tell, that Makefile builds the executable for Thompson MP but not the one for TEMPO, probably intentionally. In my build log, I can see the fortran files for Thompson (atmphys_build_tables_thompson.F and build_tables.F) being compiled but not the ones for TEMPO (atmphys_build_tables_tempo.F and build_tables_tempo.F).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@clark-evans @AndersJensen-NOAA I talked to Anders today about this, and he pointed out that there is also a Makefile for gfortran (Makefile.gfortran) for building the TEMPO executable to generate MP tables. So I added the variable MAKEFILE_SUFFIX to distinguish between intel and gfortran.

Btw, the code in src/core_atmosphere/utils/ related to TEMPO is outdated since the subroutine interfaces for the latest TEMPO are different than the ones used in the .F files in that directory. So another option for building the executable for TEMPO table generation is to update this directory (specifically atmphys_build_tables_tempo.F, build_tables_tempo.F, and Makefile) to match the latest TEMPO, but that is a job best suited for @AndersJensen-NOAA (and not necessary for this PR).

@@ -290,6 +291,7 @@ clean:
( cd physics_noahmp/src; $(MAKE) clean )
( cd physics_noahmp/utility; $(MAKE) clean )
( if [ -d physics_noaa/TEMPO ]; then cd physics_noaa/TEMPO; $(MAKE) -f Makefile.mpas clean; fi )
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The following is to clean the run_build_tables executable and related files generated by the new line above in this Makefile.

@@ -199,9 +199,9 @@
<!-- **************************************************************************************** -->

<streams>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This was necessary to avoid SMIOL errors apparently due to another stream named output defined in the main Registry.xml. This error causes the output .nc files to contain only the smoke variables defined here and none of the output variables for the output stream in the main Registry.xml. The output file is also renamed so two different streams are not writing to the same file.

@@ -28,6 +28,7 @@ core_reg:

core_input_gen:
if [ ! -e default_inputs ]; then mkdir default_inputs; fi
Copy link
Copy Markdown
Author

@gsketefian gsketefian Mar 31, 2026

Choose a reason for hiding this comment

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

This is to remove any stale stream files (streams.atmosphere and stream_list.atmosphere.*) in the default_inputs directory under core_atmosphere generated by a previous invocation of make.

@@ -37,12 +38,21 @@ gen_includes: core_reg

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is to remove any stale stream files (streams.atmosphere and stream_list.atmosphere.*) in the default_inputs directory under the top-level MPAS-Model directory generated by a previous invocation of make.

<stream name="output_smoke"
type="output"
filename_template="history.$Y-$M-$D_$h.$m.$s.nc"
filename_template="history_smoke.$Y-$M-$D_$h.$m.$s.nc"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@gsketefian This change will break the current rrfs-workflow.v2 (with smoke and dust) as discussed in #196 (comment)

We need to discuss this and have an agreement before making this change. Thanks!

post_build:
if [ ! -e $(ROOT_DIR)/default_inputs ]; then mkdir $(ROOT_DIR)/default_inputs; fi
rm -f $(ROOT_DIR)/default_inputs/streams.$(CORE) $(ROOT_DIR)/default_inputs/stream_list.$(CORE).*
cp default_inputs/* $(ROOT_DIR)/default_inputs/.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Previously, files (e.g. stream-related files such as streams.atmosphere and stream_list.atmosphere.*) were not copied from the default_inputs directory under the top-level directory (MPAS-Model) if files with the same name already exist under MPAS-Model. This just seems wrong since we want to update those files with each make invocation. The new code makes a backup of the existing file (e.g. <file_name>.old01, <file_name>.old02, etc) before replacing the existing file with the new one from default_inputs.

@@ -9,7 +9,7 @@ else
all: mpas

mpas: $(AUTOCLEAN_DEPS) externals frame ops dycore drver
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Note that the new line here now uses esmf_time_f91 instead of esmf_time_f90.

Copy link
Copy Markdown
Author

@gsketefian gsketefian Mar 31, 2026

Choose a reason for hiding this comment

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

@NingWang325 @clark-evans These intel mkl libraries are generating the following errors in the CI build tests:

With gnu compiler:

/usr/bin/ld: cannot find -lmkl_intel_lp64: No such file or directory
/usr/bin/ld: cannot find -lmkl_core: No such file or directory
/usr/bin/ld: cannot find -lmkl_sequential: No such file or directory

With intel compiler:

ld: cannot find -lmkl_intel_lp64: No such file or directory
ld: cannot find -lmkl_core: No such file or directory
ld: cannot find -lmkl_sequential: No such file or directory

First, I thought this was due to gnu not recognizing these intel libraries, but it is also happening with the intel compiler. Do we need to change the modules when running the CI tests?

Thanks.

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.

4 participants