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

Cleanup grandfathered stuff (use of constants from host model)-1st round #525

Merged
merged 29 commits into from
Aug 11, 2021

Conversation

XiaSun-Atmos
Copy link
Collaborator

@XiaSun-Atmos XiaSun-Atmos commented Dec 4, 2020

Description

This PR cleans up the constants that are defined in schemes

  • move constants defined in schemes to the argument list
    -rainmin (passed)
    -karman constant (passed)
    ...
  • remove use physcons from schemes

Related issues

NCAR/ccpp-physics #104 #245

Testing

See ufs-community/ufs-weather-model#726

Dependencies

#525
NOAA-EMC/fv3atm#360
ufs-community/ufs-weather-model#726

@XiaSun-Atmos XiaSun-Atmos changed the title Cleanup grandfathered stuff (use of constants from host model) Cleanup grandfathered stuff (use of constants from host model)-1st round Jan 12, 2021
@XiaSun-Atmos
Copy link
Collaborator Author

@climbfuji The 1st round clean-up is finished and passed RT tests on Hera using intel. The 2nd round will focus on those internal dependencies.

climbfuji and others added 3 commits July 29, 2021 09:25
@@ -397,6 +394,14 @@ subroutine m_micro_run( im, lm, flipv, dt_i &
ipr = 1

! rhr8 = 1.0

onebcp=one/cp
Copy link
Collaborator

Choose a reason for hiding this comment

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

When these constants are in a parameter statement, they are computed once.
When they are a fortran statement like here they are computed every time step - somewhat inefficient.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed. One way to improve this is to make these variables module variables and use the _init routine of a scheme to compute them once at the beginning of the run. We have done that for some schemes, but not for all. Do you want me to make the change for m_micro?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be great if it can be done. Otherwise, we can do it another time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@SMoorthi-emc I made the change. Before the change, both PROD and DEBUG tests gave b4b identical results to the old code. After making the change, the DEBUG tests (control_csawmg_debug, control_csawmgt_debug)are still bit-for-bit, but the PROD tests are different (control_csawmg, control_csawmgt). I will check if there is a way to rewrite the code to retain b4b identical results in PROD mode, but not sure if it is possible.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks Dom.
If the order of computation changed, bit for bit may reproducibility may not happen. As long as the coding is correct, I have no problem with that.

Copy link
Collaborator

@climbfuji climbfuji Jul 30, 2021

Choose a reason for hiding this comment

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

Got it. Since this PR is supposed to be a quick one w/o changing the baseline, I suggest to defer this change to later?

EDIT: Scrap that. Let's do it right away and create new baselines.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@SMoorthi-emc I made the changes as requested, including the formatting changes in gscond.f. Now the tests csawmg and csawmgt give b4b identical results compared to the existing baseline in DEBUG mode, but not in PROD mode. This means the code is correct, the Intel compiler is just optimizing the code differently. Please take a look. The commit that contains all these changes, based on the existing PR, is 4fa6a3b. Thanks!

@SMoorthi-emc
Copy link
Collaborator

SMoorthi-emc commented Jul 30, 2021 via email

physics/gscond.f Outdated
&, cpr=cp*r, rcp=h1/cp)

parameter (h1=1.e0, d00=0.e0 &
&, epsq=2.e-12)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about removing unnecessary blanks?

physics/gscond.f Outdated
@@ -158,6 +157,12 @@ subroutine zhaocarr_gscond_run (im,km,dt,dtf,prsl,ps,q,clw1 &
enddo
!-----------------prepare constants for later uses-----------------
!
elwv=hvap
eliv=hvap+hfus
r=rd
Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommend adding blanks on either side of = sign and aligh = sign

onebcp=one/cp
onebg=one/grav
kapa=rgas*onebcp
cpbg=cp/grav
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, the same recommendation about adding blanks before and after the = sign

@SMoorthi-emc
Copy link
Collaborator

SMoorthi-emc commented Aug 3, 2021 via email

Copy link
Contributor

@llpcarson llpcarson 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, approved

Copy link
Collaborator

@grantfirl grantfirl left a comment

Choose a reason for hiding this comment

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

Looks OK to me.

@climbfuji climbfuji merged commit aaa4792 into NCAR:main Aug 11, 2021
DusanJovic-NOAA pushed a commit to NOAA-EMC/fv3atm that referenced this pull request Aug 12, 2021
Add metadata for three constants that are required for the changes in PR NCAR/ccpp-physics#525.
The motivation behind these changes is that physical parameterizations should receive constants (e.g. gravitational acceleration) from the host model via the argument list instead of importing them from some Fortran module or defining them locally. This ensures consistency and enhances interoperability.
DusanJovic-NOAA pushed a commit to ufs-community/ufs-weather-model that referenced this pull request Aug 12, 2021
Add metadata for three constants that are required for the changes in PR NCAR/ccpp-physics#525.
The motivation behind these changes is that physical parameterizations should receive constants (e.g. gravitational acceleration) from the host model via the argument list instead of importing them from some Fortran module or defining them locally. This ensures consistency and enhances interoperability.
HelinWei-NOAA pushed a commit to HelinWei-NOAA/ccpp-physics that referenced this pull request Feb 26, 2023
NCAR#525)

* Added coupling of GOCART aerosols with radiation related to issue#899 in NCAR/ccpp-physics

* Updated ccpp/physics to include Barry Baker's updates for wet deposition in the Thompson scheme

* Updated physics/rte-rrtmgp with the latest commit in ccpp/physics

* Update ccpp/physics to include the updates of precipitation fluxes outputs in the Thompson microphysics scheme

* Updated ccpp/physics for fixing a bug in mp_thompson.F90
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.

5 participants