Skip to content

Unify rair constant in CAM calculations #1292

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

Closed
jimmielin opened this issue Apr 11, 2025 · 1 comment
Closed

Unify rair constant in CAM calculations #1292

jimmielin opened this issue Apr 11, 2025 · 1 comment
Assignees
Labels
CoupledEval3 enhancement New feature or request

Comments

@jimmielin
Copy link
Member

jimmielin commented Apr 11, 2025

What is the feature/what would you like to discuss?

This was discovered in code review for #1271

There are a few instances of a magic number (287.15) being used in CAM code that is not referencing physconst.

@nusbaume wrote:

I am like 95% sure that this 287 number is the gas constant for dry air. I might vote to either just use the actual physical constant, or if that changes answers too much to just create a new parameter here labeling it as the gas constant but keeping the actual value the same.

@jimmielin wrote:
This should be rair but the numbers in shr_const_rdair work out to something closer to ~287.04:

Breakpoint 1, physconst::physconst_readnl (nlfile=..., _nlfile=_nlfile@entry=80) at ...CAMdev64_075/src/utils/physconst.F90:273
273	   end subroutine physconst_readnl
(gdb) p rair
$1 = 287.03999999999996

It is used RK_stratiform to calculate the ice/liquid water content

 1316:          iwc(i,k)   = state1%q(i,k,ixcldice)*state1%pmid(i,k)/(287.15_r8*state1%t(i,k))
 1317:          lwc(i,k)   = state1%q(i,k,ixcldliq)*state1%pmid(i,k)/(287.15_r8*state1%t(i,k))

and a couple of other places for diagnostics:

src/physics/cam/cloud_diagnostics.F90:
  405               icimr(i,k)     = min( allcld_ice(i,k) / max(0.0001_r8,cld(i,k)),0.005_r8 )
  406               icwmr(i,k)     = min( allcld_liq(i,k) / max(0.0001_r8,cld(i,k)),0.005_r8 )
  407:              iwc(i,k)       = allcld_ice(i,k) * state%pmid(i,k) / (287.15_r8*state%t(i,k))
  408:              lwc(i,k)       = allcld_liq(i,k) * state%pmid(i,k) / (287.15_r8*state%t(i,k))
  409               ! Calculate total cloud water paths in each layer
  410               iciwp(i,k)     = icimr(i,k) * state%pdel(i,k) / gravit

src/physics/cam/micro_pumas_cam.F90:
 2642           icwmrst(i,k)   = min( state_loc%q(i,k,ixcldliq) / max(mincld,liqcldf(i,k)),0.005_r8 )
 2643           icinc(i,k)     = state_loc%q(i,k,ixnumice) / max(mincld,icecldf(i,k)) * &
 2644:               state_loc%pmid(i,k) / (287.15_r8*state_loc%t(i,k))
 2645           icwnc(i,k)     = state_loc%q(i,k,ixnumliq) / max(mincld,liqcldf(i,k)) * &
 2646:               state_loc%pmid(i,k) / (287.15_r8*state_loc%t(i,k))
 2647           ! Calculate micro_pumas_cam cloud water paths in each layer
 2648           ! Note: uses stratiform cloud fraction!

So maybe they should all be updated in one go as there will be answer changes.

Is there anyone in particular you want to be part of this conversation?

@nusbaume

Will this change (regression test) answers?

Yes

Will you be implementing this enhancement yourself?

Any CAM SE can do this

@PeterHjortLauritzen
Copy link
Collaborator

Agreed ... lets change to cpair in CAM4 and CAM6/7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CoupledEval3 enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

4 participants