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

cam6_4_006: fix CLUBB interface bug #1054

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
===============================================================

Tag name: cam6_3_
Originator(s): pel
Date: June 4, 2024
One-line Summary: fix clubb interface bug (dry/moist mixing ratio conversion)
Github PR URL:

Purpose of changes (include the issue number and title text for each relevant GitHub issue):
- fix issue described in https://github.com/ESCOMP/CAM/issues/1053

Describe any changes made to build system: N/A

Describe any changes made to the namelist: N/A

List any changes to the defaults for the boundary datasets: N/A

Describe any substantial timing or memory changes: N/A

Code reviewed by:

List all files eliminated: N/A

List all files added and what they do: N/A

List all existing files that have been modified, and describe the changes:
M src/physics/cam/clubb_intr.F90

All tests using CLUBB will have baseline failures

===============================================================

Expand Down
18 changes: 11 additions & 7 deletions src/physics/cam/clubb_intr.F90
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious why make this fix in place here instead of fixing set_wet_to_dry in physics_types.F90?
The "broken" set_wet_to_dry is still called in vertical_diffusion_tend which is called in tphysac.

Copy link
Collaborator Author

@PeterHjortLauritzen PeterHjortLauritzen Jun 6, 2024

Choose a reason for hiding this comment

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

What the subroutine set_wet_to_dry does would be clearer if it was named undo_set_dry_to_wet or revert_set_dry_to_wet

Explanation:

subroutine set_dry_to_wet does as the subroutine name suggests: it converts mixing ratios that are dry ((cnst_type(m).eq.'dry')) to wet.

subroutine set_wet_to_dry reverts this operation by converting the tracers that are supposed to be dry back to dry (from wet).

set_wet_to_dry does NOT convert wet tracers to dry as the name seems to imply: here is the code from set_wet_to_dry

  do m = 1,pcnst
     if (cnst_type(m).eq.'dry') then
        state%q(:ncol,:,m) = state%q(:ncol,:,m)*state%pdel(:ncol,:)/state%pdeldry(:ncol,:)
     endif
  end do

Hence the operation in vertical_diffusion_tend is correct as it converts dry tracers to wet and reverts the operation at the end.

Converting all of CAM physics to a dry basis would highly likely make sure these kinds of bugs are avoided ... and vertical diffusion would not create spurious gradients for constant dry mixing ratios ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, thanks. I keep forgetting about that subtlety (probably because of the broken name and also getting rusty in that part of the code). Also, there is no tag on a constituent's current state which has caused plenty of other problems in the past. I'm still hoping this can get fixed in CAM-SIMA but I don't know if that has been fully fleshed out yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@PeterHjortLauritzen @gold2718 I have wondered this question for a while: why do we need to use dry basis and wet basis in different CAM parts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Traditionally, moist physics developers have always used moist mixing ratios for water species. For example, specific humidity (which equals the moist mixing ratio of water vapor) is a directly measurable and observable quantity, making it a logical choice for moist physics. However, chemists usually use dry mixing ratios; for them, a moist basis is problematic because it includes a water vapor signal embedded in the mixing ratio. Numerical schemes are generally designed to conserve a constant mixing ratio. Specifically, some chemical species remain constant (on a dry basis) in most of the atmosphere. If one uses a moist basis, the numerical schemes will likely introduce a water vapor signal into the mixing ratio that was supposed to remain constant.

We wrote a detailed argument for using a dry basis, which you can find here:

https://agupubs.onlinelibrary.wiley.com/doi/epdf/10.1029/2017MS001257

(see Introduction)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks @PeterHjortLauritzen so much for your detailed explanation and sharing of your paper. That is very helpful.

Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,7 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &

use physics_types, only: physics_state, physics_ptend, &
physics_state_copy, physics_ptend_init, &
physics_ptend_sum, physics_update, set_wet_to_dry
physics_ptend_sum, physics_update

use physics_buffer, only: pbuf_old_tim_idx, pbuf_get_field, physics_buffer_desc
use physics_buffer, only: pbuf_set_field
Expand Down Expand Up @@ -2483,7 +2483,7 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
real(r8) :: temp2d(pcols,pver), temp2dp(pcols,pverp) ! temporary array for holding scaled outputs

integer :: nlev

integer :: m
intrinsic :: max

character(len=*), parameter :: subr='clubb_tend_cam'
Expand Down Expand Up @@ -2549,17 +2549,21 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
! Copy the state to state1 array to use in this routine
call physics_state_copy(state, state1)

! Determine number of columns and which chunk computation is to be performed on
ncol = state%ncol
lchnk = state%lchnk

! constituents are all treated as dry mmr by clubb
call set_wet_to_dry(state1)
do m = 1,pcnst
if (cnst_type(m).eq.'wet') then
state1%q(:ncol,:,m) = state1%q(:ncol,:,m)*state1%pdel(:ncol,:)/state1%pdeldry(:ncol,:)
endif
end do

if (clubb_do_liqsupersat) then
call pbuf_get_field(pbuf, npccn_idx, npccn)
endif

! Determine number of columns and which chunk computation is to be performed on
ncol = state%ncol
lchnk = state%lchnk

! Determine time step of physics buffer
itim_old = pbuf_old_tim_idx()

Expand Down