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 hooks for overriding surface radiative fluxes seen by land and ocean models #31

Merged

Conversation

spencerkclark
Copy link
Member

@spencerkclark spencerkclark commented Oct 20, 2023

Description

This PR adds hooks to enable overriding the surface radiative fluxes seen by the land and ocean models following ai2cm/fv3gfs-fortran#158 in AI2's fork of FV3GFS. This document contains a description of the thought process behind this code in FV3GFS, which has been used in several studies. In short it:

  • Adds fields to a new data structure (IPD_Data%OverridesFromPythonWrapper) that are meant to hold data for overriding the surface radiative fluxes (namely the downward longwave, downward shortwave, and net shortwave radiative components).
  • Creates pointers in the physics driver for these fluxes, which are set to either point to the adjusted values from the radiative transfer code (i.e. how the model normally runs) or the overriding fluxes, depending on the value of the gfs_physics_nml.override_surface_radiative_fluxes namelist parameter.
  • Configures the radiative flux diagnostics to reflect what the surface felt, and adds additional diagnostics for the radiative fluxes output by the radiative transfer code when they are being overridden (i.e. the _from_rrtmg fields).

Note that this PR also must be coupled with a PR to NOAA-GFDL/atmos_drivers to follow through with passing the override_surface_radiative_fluxes namelist parameter to the diagnostics initialization routine (see NOAA-GFDL/atmos_drivers#31).

@lharris4 this should be the last set of PRs needed to obtain feature parity with our wrapper of FV3GFS. Since this does something science-related, I'm guessing it may require a more careful review.

How Has This Been Tested?

These changes have been tested in ai2cm/SHiELD-wrapper#5. There we test that overriding the fluxes changes the solution of the model, and that the diagnostics are updated as expected based on the overridden values. As expected, the answers for the model also do not change in configurations where gfs_physics_nml.override_surface_radiative_fluxes is .false. (the default).

Checklist:
Please check all whether they apply or not

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@lharris4 lharris4 left a comment

Choose a reason for hiding this comment

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

I agree with @bensonr. I think that using the existing Coupler type or a new override data type would be cleaner and avoids needing to change the FV3 state.

@spencerkclark
Copy link
Member Author

Sounds good @lharris4. I'll pick this back up next week.

@spencerkclark spencerkclark changed the title Add hooks for overriding surface radiative fluxes seen by the land surface model Add hooks for overriding surface radiative fluxes seen by land and ocean models Oct 23, 2023
@spencerkclark
Copy link
Member Author

@lharris4 @bensonr I went ahead and created a new type to hold this unusual fortran state called GFS_overrides_from_python_wrapper, and added some additional context in a comment.

For good measure I also made sure to use these potentially overridden values when assigning state to the Coupling type and state passed to the mixed layer ocean model (42dda21). These were areas that we did not worry about or did not exist in FV3GFS, but it seems like behavior one would want in such configurations.

The model compiles and the tests pass in ai2cm/SHiELD-wrapper#5 with these code updates. Things should be ready for re-review.

Copy link
Contributor

@lharris4 lharris4 left a comment

Choose a reason for hiding this comment

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

Thanks so much for putting this together so quickly and doing such thorough testing. I don't see any problems with your code. I just have a couple of minor cosmetic suggestions and a few things I would be interested in making sure I understand correctly (hence 'minor revisions').

GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
FV3GFS/FV3GFS_io.F90 Show resolved Hide resolved
GFS_layer/GFS_physics_driver.F90 Show resolved Hide resolved
GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
FV3GFS/FV3GFS_io.F90 Outdated Show resolved Hide resolved
Copy link
Member Author

@spencerkclark spencerkclark left a comment

Choose a reason for hiding this comment

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

Thanks @lharris4 and @bensonr for the review. I'll push some updates shortly.

GFS_layer/GFS_physics_driver.F90 Show resolved Hide resolved
GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
GFS_layer/GFS_typedefs.F90 Outdated Show resolved Hide resolved
FV3GFS/FV3GFS_io.F90 Outdated Show resolved Hide resolved
FV3GFS/FV3GFS_io.F90 Show resolved Hide resolved
@spencerkclark spencerkclark force-pushed the override-radiative-fluxes branch 2 times, most recently from 437d1a7 to 71bdf66 Compare October 25, 2023 16:03
FV3GFS/FV3GFS_io.F90 Outdated Show resolved Hide resolved
@spencerkclark
Copy link
Member Author

I think this should be ready for re-review. Spurred on by #31 (comment) and #31 (comment) I have refactored the diagnostics related code to always use the existing diagnostics buckets (fluxr, dlwsfci and the like) for RRTMG-related data, and always use newly added _override buckets for data from the overrides. This should hopefully make things a little more readable than before, where I was sometimes using existing buckets for overrides and sometimes not. I have addressed the other comments following my inline responses above.

Copy link
Contributor

@bensonr bensonr left a comment

Choose a reason for hiding this comment

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

Thanks for making the suggested changes and adding appropriate comments. The logic behind the overrides is now easy to follow.

Copy link
Contributor

@lharris4 lharris4 left a comment

Choose a reason for hiding this comment

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

Thanks for putting in the extra effort to answer my many questions. I think this is good to go.

FV3GFS/FV3GFS_io.F90 Show resolved Hide resolved
@spencerkclark
Copy link
Member Author

Excellent, thanks @lharris4! Should we be good to merge this and the related NOAA-GFDL/atmos_drivers#31 now?

@lharris4
Copy link
Contributor

lharris4 commented Nov 1, 2023 via email

@laurenchilutti laurenchilutti merged commit a5a3a40 into NOAA-GFDL:main Nov 1, 2023
@spencerkclark spencerkclark deleted the override-radiative-fluxes branch November 1, 2023 15:19
spencerkclark added a commit to ai2cm/SHiELD-wrapper that referenced this pull request Nov 1, 2023
This PR updates the dycore, physics, and driver NOAA-GFDL submodules in this repo to their latest `main` branches.  Now that

- NOAA-GFDL/SHiELD_physics#31
- NOAA-GFDL/atmos_drivers#31
- NOAA-GFDL/atmos_drivers#30
- NOAA-GFDL/GFDL_atmos_cubed_sphere#302

have been merged, all the required features in SHiELD are in place to bring SHiELD-wrapper up-to-par with fv3gfs-wrapper.

Note that NOAA-GFDL/SHiELD_physics#31 made changes to the long names of some of the diagnostics output in our regression test, which required a checksum update.  

I have also taken the liberty to remove the disclaimer from the README that states that changes to SHiELD are required to bring SHiELD-wrapper up-to-par with FV3GFS.  That is no longer a limiting factor, and those remaining features are implemented in open PRs in this repo.
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.

6 participants