Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variables we can use to modify the radiative fluxes to the Statein #158

Merged
merged 13 commits into from
Mar 12, 2021

Conversation

spencerkclark
Copy link
Member

@spencerkclark spencerkclark commented Feb 22, 2021

This PR adds three variables to the Statein derived type that we can use to override the downward longwave, downward shortwave, and net shortwave radiative fluxes at the surface. By default these variables are not allocated or used. To use them one must set the gfs_physics_nml.override_surface_radiative_fluxes namelist parameter to .true.. Setters for these variables in the Python wrapper can be found in a complementary PR.

A significant amount of work in this PR also goes into refactoring the diagnostics related to these variables. When running in a mode where we override these fluxes, we want the usual fortran diagnostics -- namely DLWRF, DSWRF, USWRF, DLWRFI, DSWRFI, and USWRFI -- to correspond to the overriding fluxes. We modify things such that this is the case. In addition, to enable diagnosis of what the traditional radiation code would predict for these fluxes, we add diagnostics with the suffix _from_rrtmg. This notebook checks to make sure all of these diagnostics work as expected in a case where we override the fluxes with ML (the regression tests ensure that things continue to work when we are not overriding the fluxes).

Care has been made to ensure that if gfs_physics_nml.override_surface_radiative_fluxes is set to .false., the model will run identically to before, both in producing bit-for-bit identical results and in terms of memory allocated during runtime. When it is set to .true. the model will use more memory to accommodate the arrays used for storing the RRTMG diagnostics as well as the overriding fluxes in the Statein.

@spencerkclark spencerkclark marked this pull request as ready for review March 8, 2021 19:35
Copy link
Contributor

@oliverwm1 oliverwm1 left a comment

Choose a reason for hiding this comment

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

Great work getting this together. I did my best to follow the logic of the GFS physics driver changes, but it is not trivial. For future reference, do you have a doc that describes the implementation you ended up going with?

I was wondering why the averaged SW diagnostics are treated somewhat uniquely (i.e. store them in uswsfc versus fluxr depending on whether overriding)?

Thanks for the notebook checking the outputs. I was a bit unclear on the configuration of the run—you were outputting the diagnostics on every timestep or was it every 3 hours? I guess I was just wondering if we are confident that the time-averaging across multiple timesteps is working as expected in the case of overriding.

@spencerkclark
Copy link
Member Author

I was a bit unclear on the configuration of the run—you were outputting the diagnostics on every timestep or was it every 3 hours?

Yes, I think I put this detail at the top of the notebook. I output instantaneous and time-mean diagnostics every 3 hours from both the Python wrapper and the fortran model.

For future reference, do you have a doc that describes the implementation you ended up going with?

I think the natural place for that would be this document. I vaguely allude to the current approach here, but I should update it to be more specific about what we actually went with (in terms of technical details of the changes to the physics driver).

Copy link
Contributor

@oliverwm1 oliverwm1 left a comment

Choose a reason for hiding this comment

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

Okay, I think this looks good! I do think it would be useful to make a section in your doc that is explicitly about what was actually implemented.

Copy link
Contributor

@rheacangeo rheacangeo left a comment

Choose a reason for hiding this comment

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

Thank you for being so careful about preserving the implementation when this new flag is false. Looks good to me!

@spencerkclark spencerkclark merged commit 7560512 into master Mar 12, 2021
@spencerkclark spencerkclark deleted the flux-override-or-correct branch March 12, 2021 00:19
@spencerkclark
Copy link
Member Author

@oliverwm1 @brianhenn I wrote a document describing the implementation here (and its motivation). I linked to it in the original writeup as well.

spencerkclark added a commit to ai2cm/fv3gfs-wrapper that referenced this pull request Mar 22, 2021
…ive fluxes (#244)

This PR is tied to ai2cm/fv3gfs-fortran#158.  It adds getters and setters for four fields in the fortran model:
- `Statein%adjsfcdlw_override` (the downward longwave radiative flux at the surface seen by the land surface model)
- `Statein%adjsfcdsw_override` (the downward shortwave radiative flux at the surface seen by the land surface model)
- `Statein%adjsfcnsw_override` (the net shortwave radiative flux at the surface seen by the land surface model).
- `Radtend%sfalb` (the average surface albedo)

The first three are only valid if `gfs_physics_nml.override_surface_radiative_fluxes` is set to `.true.` in the fortran namelist (if it is not set to `.true.`, memory will not be allocated for them).  We add a flag to the wrapper to be able to dynamically check this; if it is not set and a user asks to get or set one of these variables, then an informative error will be raised (rather than a model segmentation fault).  The test infrastructure for the setters is modified to check this.

In adding the new boolean flag, it was discovered that there was a bug in the implementation of earlier boolean flags (#244 (comment)).  We fixed this, and added more comprehensive tests of the flags, which did not exist previously.  In addition we added a flag for the physics timestep, `dt_atmos`, using the preexisting `get_physics_timestep_subroutine` subroutine.

Finally, to check that the fortran diagnostics for the radiative fluxes were updated as expected, we added an additional set of tests (which basically are an automated way of doing what we did in [this notebook](https://github.com/VulcanClimateModeling/explore/blob/master/spencerc/2021-03-04-predicting-radiative-fluxes-online/2021-03-11-verify-diagnostics.ipynb)).  We also add a test that ensures that modifying the surface radiative fluxes modifies the temperature after a timestep (indicating that the modifications are being felt by the land surface model).
spencerkclark added a commit to ai2cm/SHiELD-wrapper that referenced this pull request Nov 2, 2023
This PR ports the ability to override the surface radiative fluxes seen by the land surface model from the wrapper.  This was split across two PRs originally in the case of FV3GFS:

- ai2cm/fv3gfs-fortran#158
- ai2cm/fv3gfs-wrapper#244

This depends on the fortran changes made in:

- NOAA-GFDL/SHiELD_physics#31
- NOAA-GFDL/atmos_drivers#31

which have now been merged, and incorporated into this repo via #11.
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