Skip to content

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

Merged
climbfuji merged 29 commits into
NCAR:mainfrom
XiaSun-Atmos:constant
Aug 11, 2021
Merged

Cleanup grandfathered stuff (use of constants from host model)-1st round#525
climbfuji merged 29 commits into
NCAR:mainfrom
XiaSun-Atmos:constant

Conversation

@XiaSun-Atmos
Copy link
Copy Markdown
Contributor

@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/ufsatm#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
Copy Markdown
Contributor 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.

Comment thread physics/m_micro.F90 Outdated

! rhr8 = 1.0

onebcp=one/cp
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

SMoorthi-emc commented Jul 30, 2021 via email

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

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

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?

Comment thread physics/gscond.f Outdated
!
elwv=hvap
eliv=hvap+hfus
r=rd
Copy link
Copy Markdown
Contributor

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

Comment thread physics/m_micro.F90 Outdated
onebcp=one/cp
onebg=one/grav
kapa=rgas*onebcp
cpbg=cp/grav
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

SMoorthi-emc commented Aug 3, 2021 via email

Copy link
Copy Markdown
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
Copy Markdown
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/ufsatm 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