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_061: Fix heating depth for gravity wave scheme #1232

Conversation

PeterHjortLauritzen
Copy link
Collaborator

The gravity wave scheme fails to catch the right maximum latent heating rate and convective top from the ZM scheme. Code provided by @liyptardis

closes #1229

@cacraigucar cacraigucar requested a review from nusbaume January 23, 2025 19:14
@cacraigucar cacraigucar assigned nusbaume and cacraigucar and unassigned nusbaume Jan 23, 2025
@cacraigucar cacraigucar changed the title Fix heating depth for gravity wave scheme cam6_4_061: Fix heating depth for gravity wave scheme Jan 23, 2025
Preserve constant dry mixing ratios in gw_drap and vertical diffusion code
@cacraigucar
Copy link
Collaborator

cacraigucar commented Feb 5, 2025

For WACCM runs - get the following traceback:

dec0402.hsn.de.hpc.ucar.edu 649: forrtl: error (73): floating divide by zero
dec0402.hsn.de.hpc.ucar.edu 649: Image              PC                Routine            Line        Source
dec0402.hsn.de.hpc.ucar.edu 649: libpthread-2.31.s  000014653BE858C0  Unknown               Unknown  Unknown
dec0402.hsn.de.hpc.ucar.edu 649: cesm.exe           0000000005B151ED  gw_common_mp_mome         856  gw_common.F90

The code with the divide by zero is:

! Total mass from ground to source level: rho*dz = dp/gravit
  do i = 1, size(tend_level)
     rdm(i) = gravit/(p%ifc(i,pver+1)-p%ifc(i,tend_level(i)+1))
  end do

It appears that tend_level(i) is equal to pver with these new code modifications

I spoke with @JulioTBacmeister and while we could modify the gw_common.F90 code, he believes that the proposed code modifications should not be returning tend_level(i) equal to pver.

@cacraigucar
Copy link
Collaborator

If the revisions for #1117 get completed before the above issue is resolved, I will swap the CAM tags for these two PRs

@liyptardis
Copy link

Hi everyone, I checked the subroutine gw_beres_src and found that the situation that tend_level(i) = pver could happen when topi =pver,which means in the heating profile, the only netdt(pver) at lowest level is positive, other level are negative or zero. This situation should be very rare so that in most running cases, I guess we won't meet this bug. To fix this bug, I think we can replace 'if ((netdt(i,k) > 0.0_r8) .AND. (zm(i,k) <= 20000._r8)) topi(i) = k' with 'if ((netdt(i,k) > 0.0_r8) .AND. (zm(i,k) <= 20000._r8)) topi(i) = k-1' This change will make the code exactly output the same result as the old scheme.

@cacraigucar
Copy link
Collaborator

Rerunning the tests now. I have asked for reapproval by reviewers.

Copy link
Collaborator Author

@PeterHjortLauritzen PeterHjortLauritzen left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@cacraigucar cacraigucar merged commit 5a1fbc8 into ESCOMP:cam_development Feb 6, 2025
2 checks passed
gold2718 pushed a commit to gold2718/CAM that referenced this pull request Feb 13, 2025
Merge pull request ESCOMP#1232 from PeterHjortLauritzen/issue1229_heating_depth_bugfix

cam6_4_061: Fix heating depth for gravity wave scheme

ESCOMP commit: 5a1fbc8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Tag
Development

Successfully merging this pull request may close these issues.

None yet

4 participants