Skip to content

Add NSSL 2/3-moment cloud microphysics - #1113

Open
MicroTed wants to merge 61 commits into
MPAS-Dev:developfrom
MicroTed:dev-nssl3m
Open

MicroTed wants to merge 61 commits into
MPAS-Dev:developfrom
MicroTed:dev-nssl3m

Conversation

@MicroTed

@MicroTed MicroTed commented Aug 23, 2023 •

Copy link
Copy Markdown

Add NSSL 2/3-moment cloud microphysics

Adds option to use the NSSL 2-moment cloud microphysics scheme with 6 hydrometeor species (droplets, rain, cloud ice, snow, graupel, and hail). It includes the option for 3-moment rain/graupel/hail (adds reflectivity moment) and an option to turn off hail (for non-severe convection). Details on using the scheme are in docs/README.NSSLmp. Also adds a 3D reflectivity field for optional output (refl10cm). The parameterization code is (or will be) at parity with the current WRF PR for the 3-moment scheme wrf-model/WRF#1876 (and eventual CCPP update).

Tested on daily 3-km regional CONUS forecasts (with v7.3), so similar performance is expected with v8.0

Outstanding issue: At least in the physics_mmm directory, the .mod files are not updated by recompiling newer .F files. They have to be deleted in order to be replaced. I don't know if this is general or a gfortran quirk.

…icrophysics (adds refl. moment variables for rain, graupel, hail: zrw, zgw, zhw).

 Also added code to compute the composite and 1-km reflectivity for NSSL2M (not actually tested yet)
  mpas_io_streams.F : pass ioformat to def_var
  mpas_io.F : add conditional to set deflate on variables if ioformat is netcdf4 (needs netcdf-4.7.4 or later)
…ophysics

ccpp_kinds.F : Add 'machine' module for CCPP compatibility
mpas_atmphys_driver_microphysics.F : Add support for NSSL microphysics (arrays, init/driver etc.)
mpas_atmphys_interface.F : Get/put data for NSSL microphysics
mpas_atmphys_packages.F : Set up packages for NSSL microphysics
physics_mmm/Makefile : add dependencies for NSSL-mp
physics_wrf/Makefile : remove NSSL-mp (moved to physics_mmm)
docs/README.NSSLmp : brief overview of options in the NSSL microphysics scheme
physics_mmm: module_mp_nssl_2mom.F, mp_nssl.F : new code file for NSSL-MP
@MicroTed

Copy link
Copy Markdown
Author

Hi, @ldfowler58 would you have time to look at this at some point? Let me know if this is the approach you want for physics_mmm or if there is more to shift from the model code to the interface. The physics module is an updated version from CCPP, so it has all the extra comments for documentation. The interface 'run' subroutine is from CCPP (for SCM/FV3), but isn't actually used since MPAS can call the microphysics directly with the "_p" arrays.
Thanks!

@mgduda

mgduda commented Aug 31, 2023

Copy link
Copy Markdown
Contributor

I think it would be good to separate the changes for NetCDF compression from the changes to add the NSSL microphysics scheme, as these (if I understand correctly) are unrelated changes.

@MicroTed

Copy link
Copy Markdown
Author

I agree that it would be cleaner to split it off the netcdf part, and it is only 2 files and I think no overlapping changes. It's a bare-bones implementation that assumes one would only choose the netcdf4 option because of compression being available. Otherwise the speed of pnetcdf for uncompressed writes really can't be beat.

@MicroTed MicroTed changed the title Add NSSL 2/3-moment cloud microphysics AND enable compression for netcdf-4.7.4 or greater Add NSSL 2/3-moment cloud microphysics Aug 31, 2023
@MicroTed

Copy link
Copy Markdown
Author

I moved the netcdf changes to a separate branch: https://github.com/MicroTed/MPAS-Model/tree/dev-nc4deflate
I could make a draft PR or just leave it on ice for now -- whatever you want to do given your priorities and limited time. Ideally I would add a netcdf version check and an extra flag for deflate level etc.

@ldfowler58

Copy link
Copy Markdown
Contributor

I started to look at the changes and add-ons made by Ted in order to include the NSSL cloud microphysics scheme. Here my first suggestions for the top files that I have been modified:

  1. In ./src/core_atmosphere/Registry.xml, I suggest to keep the "mp_" reference in front of the packages named nssl_hail_in, nssl_ccn_in, nssl3m_in, and nssl3m_hail_in. Users may appreciate that those packages point to cloud microphysics options. nssl3m_in can be changed to mp_nssl3m_in since you defined the NSSL 2-moment package as mp_nssl2m_in. Thanks.

  2. In ./src/core_atmosphere/physics/mpas_atmphys_packages.F, can you please keep everything "lower case" and remove extra blank spaces to ensure "continuity" in how the sourcecode has been originally written (if not much to ask). For instance, change "
    if(config_nssl_hail_on) then
    nssl_hail_in = .true.
    endif

  3. In ./src/core_atmosphere/physics/mpas_atmphys_control.F, change lines
    config_microp_scheme .eq. 'mp_thompson' .or. &
    config_microp_scheme .eq. 'mp_nssl2m' .or. &
    to
    config_microp_scheme .eq. 'mp_nssl2m' .or. &
    config_microp_scheme .eq. 'mp_thompson' .or. &

  4. In ./src/core_atmosphere/physics/mpas_atmphys_vars.F (lines 197-203), do you mind putting one variable per line as for lines 188-195 so that I can add the definition of the different variables later. Thanks.

  5. In ./src/core_atmosphere/physics/mpas_atmphys_manager.F, same comments as in 2) regarding lower case and space. Wouldn't it be simpler to use 75._RKIND instead of 1.25001*60._RKIND? Thanks.

Will look at the actual microphysics next. Thanks.

@MicroTed

MicroTed commented Jan 3, 2024

Copy link
Copy Markdown
Author

Thanks for the comments! My thinking for leaving off "mp_" from nssl3m_in and nssl_hail_in etc. is that they are package options rather than full packages. They are not seen by the user, but rather activated by config_ options. So maybe it doesn't really matter? The package is still the mp_nssl2m_in, and the others are options (subpackages?) to turn variables on or off.

Perhaps I could just rename mp_nssl2m_in to just mp_nssl_in? Or something like that? I also have a version with an option to run single-moment, but I'm not sure that's needed for a release code.

I can change the other formatting things to match the rest of the code. (Although I'm firmly in the camp of having a space after 'if' :) considering there is an unbalanced space in front of 'then', haha.)

@MicroTed

Copy link
Copy Markdown
Author

Updated to use the manage externals functionality to clone the microphysics code to physics_noaa

@MicroTed

MicroTed commented Nov 19, 2025 •

Copy link
Copy Markdown
Author

Question for anybody: How much work would be involved to get the namelist filename from within mpas_atmphys_driver_microphysics.F? (In the case where somebody is using the '-n' command line option to change it from the default.) The init subroutine takes the file name as an input, and it is currently hardwired to the default in the call. The reason is so that it can check for its internal namelist with rarely-used options. Most users would never use it, but it would be nice to correct this at some point.

EDIT: code has been updated to pass the namelist filename to the nssl init routine

@jihyeonjang

Copy link
Copy Markdown
Collaborator

Hi Ted,

Here are my suggestions based on my tests (before dev-nssl3m was merged into the current develop at 840ef2d).

  1. Radar reflectivity for Thompson scheme
    There was an issue with the radar reflectivity output for the Thompson scheme after merging the NSSL-MP changes. To address this, please consider the following changes:

src/core_atmosphere/physics/mpas_atmphys_interface.F

  • Remove L1022 (no longer needed; related to the PR #1329)
L1022:        call mpas_pool_get_array(diag_physics,'refl10cm',refl10cm)
  • Remove L1044 and L1053 for the Thompson scheme:
L1044:              call mpas_pool_get_array(diag_physics,'refl10cm',refl10cm)
L1053:                 refl10cm(k,i) = refl10cm_p(i,k,j)

src/core_atmosphere/physics/mpas_atmphys_driver_microphysics.F

  • Remove L163 and L274 for the Thompson scheme:
L163:           if(.not.allocated(refl10cm_p)) allocate(refl10cm_p(ims:ime,kms:kme,jms:jme))
L274:          if(allocated(refl10cm_p)) deallocate(refl10cm_p)

Note: The physics-intermediate refl10cm_p array was removed in the PR #1329, but it is still needed for NSSL-MP, since 10-cm radar reflectivity is computed in nssl_2mom_driver.

 

  1. In src/framework/mpas_dmpar.F, the following lines are no longer needed after the commit a5fc16f.
L87:   integer, public :: numprocs = 1
L313:       numprocs = mpi_size

 

  1. In src/core_atmosphere/physics/mpas_atmphys_packages.F, remove the following duplicated line.
L127:    call mpas_log_write('    config_nssl_hail_on            = $l', logicArgs=(/config_nssl_hail_on/))

@jihyeonjang

jihyeonjang commented Nov 21, 2025 •

Copy link
Copy Markdown
Collaborator

I would also like to confirm the preferred namelist name for NSSL-MP: "mp_nssl2m" vs "mp_nssl". When config_nssl_3moment = .true., the 3-moment option becomes available, but still the microphysics name remains mp_nssl2m. Also, your branch name for this PR is dev-nssl3m. However, the subroutine names (nssl_2mom_init_const, nssl_2mom_driver, nssl_2mom_gs) are consistent with "mp_nssl2m", so mp_nssl2m could be more consistent.

Could you decide which namelist name you prefer for NSSL-MP?

@MicroTed

Copy link
Copy Markdown
Author

I would also like to confirm the preferred namelist name for NSSL-MP: "mp_nssl2m" vs "mp_nssl". When

I agree it is awkward and was I just keeping the '2m' for legacy. It would make sense to simplify it to 'mp_nssl'. It can even be run in single-moment still, but I didn't see the need to add the flags to enable that option. I can change those.

I'll look at the changes for the reflectivity issue, too. Thanks for finding and pointing that out!

     Changed tokens from from mp_nssl2m to mp_nssl
     Reconciled parallel changes in mpas_dmpar.F and mpas_atmphys_interface.F
     mpas_atmphys_init.F: Added flag f_qh for hail, but may be obsolete (f_qg is not used anymore)
@MicroTed

Copy link
Copy Markdown
Author

@jihyeonjang OK, I have fixed the Thompson issue and updated tokens from mp_nssl2m to mp_nssl (with a backward compatibility to allow 'mp_nssl2m' for config input).
mpas_atmphys_init.F has a flag f_qg for graupel, and although it doesn't seem to do anything, I also added one for hail in case it is ever needed.

@MicroTed

Copy link
Copy Markdown
Author

One more commit fixes an oversight with the MYNN scheme where the cloud droplet concentration tendencies were not being applied but the mass tendency was. It would have some effect, but it's unclear how large.

MicroTed added 3 commits April 2, 2026 13:52
  module_mp_thompson.F : fix print statement with correct file name
… call where gfortran debug compile causes an error.

! check for missing moments that are needed
do k=1,nVertLevels
IF ( index_qs > 0 .and. index_ns > 0 ) THEN

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.

Since qs, ns, etc. aren't defined as scalar constituents in the Registry.xml file, I think this code will lead to the use of unassociated pointers (index_qs, etc.).

Should there be additional changes in the Registry.xml file for the init_atmosphere core for scalar constituents beyond qv, qc, qr, nifa, and nwfa?

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.

Yes, there is work to be done here! We recently ran into an issue where gfortran thought a pointer was associated because it wasn't explicitly initialized as null. (in the GSL version) One question here is whether to add the microphysics scheme to the init namelist as in core_atmosphere and set the microphysics variables accordingly (i.e., have to know what scheme will be used). That would limit file sizes by not including unneeded variables. Or do we just provide all possible variables to have a generic IC/BC?

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.

Given the number of new scalars, my inclination would be to only include these in LBC files if they will be needed in the model (i.e., if the NSSL scheme will be used). If we were to attach packages to each of the scalars, we could activate packages based on a specification in the namelist.init_atmosphere file of the microphysics scheme(s) that will be used in the model.

In future, though, it might be possible to scan through input files and activate packages for each scalar individually based on whether that scalar contains initial data in the input files. My thinking here is that, if we have no initial data for, say, qs, there would be no value in including it in the LBC files (as it would simply be zero everywhere, which is what the model will assume for a missing scalar anyway).

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.

Also, perhaps the diagnosed scalars (e.g., number concentration from a single-moment species) could be done in 'atmosphere' if the LBC is not found? For example, if there is snow mixing ratio, but the scheme needs the number concentration, it might be better to create that when mpas is reading lbcs and finds qs but not ns. It would be basically the same code that I have now on the init side, and would save having to write 'bogus' LBCs. That combined with your idea of checking what is even available would help limit the number of vars in the LBC file.

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.

Apologies for the long delay in following up. I've finally spent a bit of time looking into the possibility of setting up packages for individual species based on either (1) the contents of the initial intermediate file or (2) a namelist-provided list of species. I've pushed a new branch, demo/hydrometeor_packages, to my fork of the MPAS-Model repository with what I think might be a workable solution. In particular, the last commit on that branch adds the new package setup logic. Furthermore, I like your suggestion of diagnosing number concentrations and other scalars in the atmosphere core, as this would save on LBC file size.

If the approach take in the demo/hydrometeor_packages branch looks like it would work from your perspective, I think we could get that capability into the develop branch fairly quickly, and we could then rebase this PR branch and add packages for the new species in this PR (qs, etc.). Does that sound like a reasonable approach?

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.

Looks like a pretty clever approach to peek at the intermediate file. Sounds good to me.

As far as diagnosing LBC values, I guess that would need to be done in mpas_atm_update_bdy_tend?

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.

I agree that mpas_atm_update_bdy_tend is probably the best place to diagnose number concentrations, etc. Around line 169 (in the v8.4.0 code) might be ideal, since we will have just read in the new boundary state into lbc_* time level 2 but not yet computed the time tendencies for the LBC fields: https://github.com/MPAS-Dev/MPAS-Model/blob/v8.4.0/src/core_atmosphere/dynamics/mpas_atm_boundaries.F#L169-L171 .

@MicroTed MicroTed Jun 1, 2026 •

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.

Yunheng Wang wrote a subroutine to calculate reflectivity in the init phase for the initial output time, and that routine could be used as a template (or expanded) for diagnosing missing number concentrations, etc.
https://github.com/NOAA-National-Severe-Storms-Laboratory/frdd-MPAS-Model/blob/da78534402b341adc4a921d062f1c2785ae35907/src/core_atmosphere/physics/mpas_atmphys_driver_microphysics.F#L1465 (corrected link)
It would be cleaner to call a similar routine than trying to handle various microphysics here. For NSSL-MP, it is ultimately calling the nssl_column_dbz and calcnfromq routines from the module.

@mgduda
mgduda removed the request for review from ldfowler58 April 24, 2026 17:45
${ATMOSPHERE_CORE_PHYSICS_MMM_SOURCES}
${ATMOSPHERE_CORE_PHYSICS_WRF_SOURCES}
${ATMOSPHERE_CORE_PHYSICS_NOAA_SOURCES}
${ATMOSPHERE_CORE_PHYSICS_NSSL-MP_SOURCES}

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.

I don't know cmake very well, but I see that other packages have explicit source file lists. I can add that for NSSLmp if that's needed.


! check for missing moments that are needed
do k=1,nVertLevels
IF ( index_qs > 0 .and. index_ns > 0 ) THEN

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.

Yes, there is work to be done here! We recently ran into an issue where gfortran thought a pointer was associated because it wasn't explicitly initialized as null. (in the GSL version) One question here is whether to add the microphysics scheme to the init namelist as in core_atmosphere and set the microphysics variables accordingly (i.e., have to know what scheme will be used). That would limit file sizes by not including unneeded variables. Or do we just provide all possible variables to have a generic IC/BC?

@mgduda

mgduda commented May 6, 2026

Copy link
Copy Markdown
Contributor

@MicroTed Regarding this part of the PR description,

Outstanding issue: At least in the physics_mmm directory, the .mod files are not updated by recompiling newer .F files. They have to be deleted in order to be replaced. I don't know if this is general or a gfortran quirk.

I think this should be fixed with the merge of NCAR/MMM-physics#6 .

@MicroTed

MicroTed commented May 7, 2026

Copy link
Copy Markdown
Author

@MicroTed Regarding this part of the PR description,

Outstanding issue: At least in the physics_mmm directory, the .mod files are not updated by recompiling newer .F files. They have to be deleted in order to be replaced. I don't know if this is general or a gfortran quirk.

I think this should be fixed with the merge of NCAR/MMM-physics#6 .

Oh, it has been so long... I recall somebody saying that this behavior was a 'feature' and that gfortran only generated a new module if the interface or variables had changed -- or I'm misremembering. I haven't had any problems with gnu-12.x (or 15.x)

MicroTed added 3 commits June 1, 2026 12:39
…o pass the actual namelist

  filename to the init routine (to read the local nssl_mp_params namelist)
 Files modified: mpas_atm_core.F mpas_atmphys_driver_microphysics.F mpas_atmphys_init.F
 Change commands in core_atmosphere/physics/Makefile for NSSL-MP to create symbolic links instead of copying, which avoids a needless recompile
@mgduda

mgduda commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@MicroTed We've just merged PR #1467 into the develop branch, so if you're able to merge develop to this PR branch, or to rebase this PR branch onto the HEAD of the develop branch, that should provide the groundwork needed for adding packages to the new scalars in ICs and LBCs that are introduced by this PR. I'm glad to help with any of this -- just let me know if you'd like me to do so (though I may need to be added as a GitHub 'collaborator' on your fork?).

@MicroTed

Copy link
Copy Markdown
Author

@mgduda I was out of the office last week, so I just got to this. It should be merged up to the current develop branch. I also found double-counting issue in the NSSL-MP that was causing excessive hail reflectivity in the 2-moment option. Hopefully good to go at this point.
I'm happy to add you as a collaborator, too.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants