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

Make RRTMGP thread-safe #2990

Merged
merged 5 commits into from
Jun 21, 2019
Merged

Make RRTMGP thread-safe #2990

merged 5 commits into from
Jun 21, 2019

Conversation

brhillman
Copy link
Contributor

Make RRTMGP radiation code thread-safe. This fixes a long-standing bug in RRTMGP that prevented us from running the code in threaded configurations. The fix involves a very small change in the RRTMGP interface (in radiation.F90), and similarly small changes in the external RRTMGP repo. In order to pull in the external changes, .gitmodules is updated to point to the "develop" branch of the external RRTMGP repo, and the submodule is updated to point to the latest commit. Changes are BFB for RRTMGP configurations (and should be for non-RRTMGP configurations as well since no code is touched outside of the RRTMGP except .gitmodules).

@brhillman
Copy link
Contributor Author

Thanks @worleyph for finding these fixes!

@worleyph
Copy link
Contributor

@brhillman and @mt5555 , was the decision then NOT to eliminate the initialization declaration for

 ! Clear-sky heating rates are not on the physics buffer, and we have no
  ! reason to put them there, so declare these are regular arrays here
  real(r8) :: qrsc(pcols,pver) = 0._r8
  real(r8) :: qrlc(pcols,pver) = 0._r8

Even though it works fine this way, there was some concern that it shouldn't :-), or was dangerous if only because it might lead to duplicating the style in a situation that would not be innocuous?

@brhillman
Copy link
Contributor Author

Oh sorry, I can change that. These don't affect the model simulation, which is why they won't appear to change anything.

@worleyph
Copy link
Contributor

sorry to be a pest, but do you now need to add

  qrsc(:,:) = 0._r8
  qrlc(:,:) = 0._r8

at the beginning of the routine? Or was the initialization not actually needed?

@brhillman
Copy link
Contributor Author

It shouldn't be needed, but I can add it for safety. Only reason I can see to add it is that these get populated to make outfld calls, but only up to nday/ncol, so there could be garbage in the columns > ncol but < pcols. I'll add an initialization.

@brhillman
Copy link
Contributor Author

Look better? Running tests now as a sanity check, but it shouldn't change anything...(said that before)

@worleyph
Copy link
Contributor

What does the call to pbuf_get_field do? By the name, would have guessed that it reads data from the physics buffer into the local array. You put the initialization to zero after the call to pbuf_get_field?

@brhillman
Copy link
Contributor Author

brhillman commented Jun 11, 2019

Careful...we are initializing qrsc and qrlc (note the postfix "c" to indicate clear-sky), which are not on the physics buffer. The above call to pbuf_get_field is associating the pointers to qrs and qrl on the physics buffer (note the absence of the "c" for clear-sky). So these are unrelated.

But, to answer your question, pbuf_get_field associates pointer variables to data in the physics buffer. So in general, yes we would want to call pbuf_get_field before initializing the data, because until we associate the pointers, we have no idea where in memory they point to.

@worleyph
Copy link
Contributor

Thanks!

Copy link
Contributor

@worleyph worleyph left a comment

Choose a reason for hiding this comment

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

The code changes that I can see (the ones not in the external repository) look good. Based on earlier discussions, I trust that the appropriate changes were made in mo_gas_optics_rrtmgp.F90 .

@worleyph
Copy link
Contributor

Thanks @worleyph for finding these fixes!

Glad that I could help. Wish that I had remembered the issue with fortran initializations in declarations - this has come up before and I had just spaced it - I would have been more confident about proposing the solution.

@brhillman
Copy link
Contributor Author

Pinging @singhbalwinder

Copy link
Contributor

@singhbalwinder singhbalwinder left a comment

Choose a reason for hiding this comment

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

Thanks for the reminder. The changes look good to me.

@brhillman
Copy link
Contributor Author

Thanks @singhbalwinder !

@rljacob rljacob assigned wlin7 and unassigned singhbalwinder Jun 20, 2019
@rljacob
Copy link
Member

rljacob commented Jun 20, 2019

re-assigning to @wlin7 to balance the integrator work load.

wlin7 added a commit that referenced this pull request Jun 20, 2019
Make RRTMGP radiation code thread-safe.

This fixes a long-standing bug in RRTMGP that prevented us from running the code in threaded configurations. The fix involves a very small change in the RRTMGP interface (in radiation.F90), and similarly small changes in the external RRTMGP repo. In order to pull in the external changes, .gitmodules is updated to point to the "develop" branch of the external RRTMGP repo, and the submodule is updated to point to the latest commit. Changes are BFB for RRTMGP configurations (and should be for non-RRTMGP configurations as well since no code is touched outside of the RRTMGP except .gitmodules).

[BFB]
@wlin7
Copy link
Contributor

wlin7 commented Jun 20, 2019

Merged to next.

@wlin7 wlin7 merged commit c4ce81a into master Jun 21, 2019
wlin7 added a commit that referenced this pull request Jun 21, 2019
Make RRTMGP radiation code thread-safe

This fixes a long-standing bug in RRTMGP that prevented us from running the code in threaded configurations. The fix involves a very small change in the RRTMGP interface (in radiation.F90), and similarly small changes in the external RRTMGP repo. In order to pull in the external changes, .gitmodules is updated to point to the "develop" branch of the external RRTMGP repo, and the submodule is updated to point to the latest commit. Changes are BFB for RRTMGP configurations (and should be for non-RRTMGP configurations as well since no code is touched outside of the RRTMGP except .gitmodules).

[BFB]
@wlin7
Copy link
Contributor

wlin7 commented Jun 21, 2019

Merged to master.

@brhillman
Copy link
Contributor Author

Thanks @wlin7!

@brhillman brhillman deleted the brhillman/atm/make-rrtmgp-threadsafe branch June 21, 2019 15:46
jgfouca added a commit that referenced this pull request Jun 25, 2019
Modifications to allow for E3SM developer tests for the SE SCM

This PR includes modifications to allow for E3SM developer tests for the Spectral Element (SE) version of the Single Column Model (SCM), which will be the default version of the SCM for E3SMv2. This PR 1) adds the SE SCM test in config/e3sm/tests.py , 2) removes the restriction that the SCM be compiled with mpi-serial mode (will not compile with the SE SCM and no longer a requirement for the Eulerian SCM), and 3) add a single_column logical check in src/drivers/mct/main/seq_io_mod.F90. In the E3SM SE SCM since the full dynamics grid is initialized but only one physics column is initialized, a shr_sys_abort is called when coupler diagnostics would otherwise be successfully written to history file. Added a logical check to avoid this abort call when SCM is used.

Note that required modifications to run the SE SCM test have also be made in a companion E3SM PR.

Test suite: scripts/test/scripts_regression_tests.py
Along with modifications in the E3SM PR, my e3sm_developer tests for both SE SCM and Eulerian SCM pass (in addition to the full testing suite). SCM runs using the official E3SM SCM scripts also pass for both dynamical cores.
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes [CIME Github issue #]

User interface changes?:

Update gh-pages html (Y/N)?:

Code review:
rljacob pushed a commit that referenced this pull request Apr 21, 2021
Modifications to allow for E3SM developer tests for the SE SCM

This PR includes modifications to allow for E3SM developer tests for the Spectral Element (SE) version of the Single Column Model (SCM), which will be the default version of the SCM for E3SMv2. This PR 1) adds the SE SCM test in config/e3sm/tests.py , 2) removes the restriction that the SCM be compiled with mpi-serial mode (will not compile with the SE SCM and no longer a requirement for the Eulerian SCM), and 3) add a single_column logical check in src/drivers/mct/main/seq_io_mod.F90. In the E3SM SE SCM since the full dynamics grid is initialized but only one physics column is initialized, a shr_sys_abort is called when coupler diagnostics would otherwise be successfully written to history file. Added a logical check to avoid this abort call when SCM is used.

Note that required modifications to run the SE SCM test have also be made in a companion E3SM PR.

Test suite: scripts/test/scripts_regression_tests.py
Along with modifications in the E3SM PR, my e3sm_developer tests for both SE SCM and Eulerian SCM pass (in addition to the full testing suite). SCM runs using the official E3SM SCM scripts also pass for both dynamical cores.
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes [CIME Github issue #]

User interface changes?:

Update gh-pages html (Y/N)?:

Code review:
jgfouca pushed a commit that referenced this pull request Nov 7, 2024
Addresses issue #2990 which notes that the list of options for output
frequency in CIME covers more cases than are currently allowed in
EAMxx.  This commit expands the list of acceptable strings to include
those with full words spelled out, with and without plural.
rfiorella pushed a commit to rfiorella/E3SM that referenced this pull request Jan 28, 2025
Addresses issue E3SM-Project#2990 which notes that the list of options for output
frequency in CIME covers more cases than are currently allowed in
EAMxx.  This commit expands the list of acceptable strings to include
those with full words spelled out, with and without plural.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Atmosphere BFB PR leaves answers BFB bug fix PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants