Skip to content

Main candidate from NCAR (04/21/2021)#1381

Merged
marshallward merged 45 commits into
mom-ocean:dev/gfdlfrom
gustavo-marques:main-candidate-ncar-2021-04-21
May 3, 2021
Merged

Main candidate from NCAR (04/21/2021)#1381
marshallward merged 45 commits into
mom-ocean:dev/gfdlfrom
gustavo-marques:main-candidate-ncar-2021-04-21

Conversation

@gustavo-marques
Copy link
Copy Markdown
Collaborator

Summary

  • Many improvements in the lateral boundary diffusion module

  • Adds a new counter-based random number generator

  • Fixes a minor bug in the neutral diffusion module (only applies when NDIFF_INTERIOR_ONLY = True)

  • Fixes sign bug in the latent heat contribution from frozen precipitation and frozen runoff (MCT and NUOPC caps)

  • Adds option to apply an are flux correction in the NUOPC cap

  • Adds support for threading in the NUOPC cap

This PR does not change the MOM6-examples answers (w.r.t. branch main at 1a420f2) when using the intel/19.0.5 compiler. It also does not add new MOM input flags or diagnostics.

gustavo-marques and others added 30 commits December 15, 2020 18:13
* Also reducing line lenghts > 120
Fixes inconsistency in the calculation of tendency due to lateral diffusion
See https://arxiv.org/abs/2004.06278. Not an exact reproduction of "squares" because Fortran doesn't have a uint64 type, and not all compilers provide integers with > 64 bits...
…_diff

Adds mask2dT checker to avoid calling boundary_k_range at land points
Added a counter-based PRNG to MOM_random
Remove an omp parallel do directive due to thread-unsafe cpu_clock
This patch fixes a sign bug, in both MCT and NUOPC, when
accounting for the latent heat from fprec and frunnoff.
Following MOM6's definition, both fprec
and frunoff are > 0 into the ocean. Therefore, the latent heat
associated with these terms should be negative.
* Fixes latent heat contribution from fprec and frunoff (MCT and NUOPC)
…ndidate_2021-02-19

Fix LBD module after merging main candidate 2021 02 19
Add med2mod_areacor and move where area correction is applied
Sync with main to bring in new file layout
@gustavo-marques gustavo-marques changed the title Main candidate from NCAR (2021/04/21) Main candidate from NCAR (04/21/2021) Apr 21, 2021
@gustavo-marques
Copy link
Copy Markdown
Collaborator Author

@kshedstrom, @jiandewang, @abozec (or @awallcraft): please review/test this PR.

@jiandewang
Copy link
Copy Markdown
Collaborator

@gustavo-marques https://github.com/NOAA-GFDL/MOM6/pull/1381/files#diff-68076a5015442fbab97fced84c6d2c139c715798d26b7e0fe0c542bab0b3c1d6R467-R478
use function ChkErr(rc,LINE,u_FILE_u) to replace
if (ESMF_LogFoundError

@gustavo-marques
Copy link
Copy Markdown
Collaborator Author

@jiandewang, thanks for catching that.

@kshedstrom
Copy link
Copy Markdown
Collaborator

I approve this PR.

Copy link
Copy Markdown
Collaborator

@abozec abozec left a comment

Choose a reason for hiding this comment

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

COAPS approves this PR.

call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if(localPeCount == 1) then
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.

The two instances of retrieving the attribute 'nthreads' are failing for EMC. They will need "isPresent,isSet" conditionals added. Thanks.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done. Thanks, @DeniseWorthen.

@DeniseWorthen
Copy link
Copy Markdown
Contributor

@gustavo-marques This still isn't working for EMC. We need to use the isPresent,isSet conditionals to optionally retrieve the config variable. I've tested the following change for our configuration on Gaea:

Please check the logic and make sure it is what you intend. Thanks.

diff --git a/config_src/drivers/nuopc_cap/mom_cap.F90 b/config_src/drivers/nuopc_cap/mom_cap.F90
index f5f7985e1..742b7575d 100644
--- a/config_src/drivers/nuopc_cap/mom_cap.F90
+++ b/config_src/drivers/nuopc_cap/mom_cap.F90
@@ -418,6 +418,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
   character(len=512)                     :: diro
   character(len=512)                     :: logfile
   character(ESMF_MAXSTR)                 :: cvalue
+  character(len=64)                      :: logmsg
   logical                                :: isPresent, isPresentDiro, isPresentLogfile, isSet
   logical                                :: existflag
   integer                                :: userRc
@@ -467,13 +468,19 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
   if (ChkErr(rc,__LINE__,u_FILE_u)) return

   if(localPeCount == 1) then
-     call NUOPC_CompAttributeGet(gcomp, "nthreads", value=cvalue, &
+     call NUOPC_CompAttributeGet(gcomp, name="nthreads", value=cvalue, &
           isPresent=isPresent, isSet=isSet, rc=rc)
      if (ChkErr(rc,__LINE__,u_FILE_u)) return
-     read(cvalue,*) nthrds
+     if (isPresent .and. isSet) then
+        read(cvalue,*) nthrds
+     else
+        nthrds = localPeCount
+     end if
   else
      nthrds = localPeCount
   endif
+  write(logmsg,*) nthrds
+  call ESMF_LogWrite(trim(subname)//': nthreads = '//trim(logmsg), ESMF_LOGMSG_INFO)

 !$  call omp_set_num_threads(nthrds)

@@ -898,10 +905,14 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
   if (ChkErr(rc,__LINE__,u_FILE_u)) return

   if(localPeCount == 1) then
-     call NUOPC_CompAttributeGet(gcomp, "nthreads", value=cvalue, &
+     call NUOPC_CompAttributeGet(gcomp, name="nthreads", value=cvalue, &
           isPresent=isPresent, isSet=isSet, rc=rc)
      if (ChkErr(rc,__LINE__,u_FILE_u)) return
-     read(cvalue,*) nthrds
+     if (isPresent .and. isSet) then
+        read(cvalue,*) nthrds
+     else
+        nthrds = localPeCount
+     end if
   else
      nthrds = localPeCount
   endif

@gustavo-marques
Copy link
Copy Markdown
Collaborator Author

@DeniseWorthen, sorry for breaking your tests, and thank you for suggesting a solution. I will add your changes and run them by Jim Edwards since he implemented the threading option in NUOPC.

@jiandewang
Copy link
Copy Markdown
Collaborator

@gustavo-marques I will run UFS RT with your updated code, but may take some time as we ran out of CPU quota at this moment, job turnover rate is extremely low.

@jiandewang
Copy link
Copy Markdown
Collaborator

@gustavo-marques: by adding !$ call omp_set_num_threads(nthrds) in the cap code, does it mean part of cap will be running with OMP or something else ? we don't have a clear idea here, can you explain ?

The updated code passed UFS RT, thanks for @DeniseWorthen and @gustavo-marques

@alperaltuntas
Copy link
Copy Markdown
Collaborator

@jiandewang, these (or any) OpenMP directives are effective only if you explicitly enable OpenMP at compile time. Unless you compile with OpenMP, these directives (!$) are merely regarded as comments, and so will not affect your model. If you are compiling with OpenMP, on the other hand, the directive you refer to does the following: "Instead of using the default number of threads, the directive sets the number of threads to the value received from NUOPC_CompAttributeGet call.

Also mentioned @jedwards4b, if he likes to add more.

@jiandewang
Copy link
Copy Markdown
Collaborator

@jiandewang, these (or any) OpenMP directives are effective only if you explicitly enable OpenMP at compile time. Unless you compile with OpenMP, these directives (!$) are merely regarded as comments, and so will not affect your model. If you are compiling with OpenMP, on the other hand, the directive you refer to does the following: "Instead of using the default number of threads, the directive sets the number of threads to the value received from NUOPC_CompAttributeGet call.

Also mentioned @jedwards4b, if he likes to add more.

@alperaltuntas thanks for the explanation, did you get identical results from different threading # ?

@marshallward
Copy link
Copy Markdown
Collaborator

marshallward commented Apr 28, 2021

GFDL Gaea regression (internal): https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/pipelines/12566 ✔️

@alperaltuntas
Copy link
Copy Markdown
Collaborator

@jiandewang Yes, the number of threads doesn't change the results.

@marshallward
Copy link
Copy Markdown
Collaborator

@sanAkel Did you want to review this PR? The number of non-NUOPC changes is very small so I would not expect any issues.

Otherwise, I will go ahead and merge this if there's no objection. (I will redirect it to main rather than dev/gfdl).

@sanAkel
Copy link
Copy Markdown
Collaborator

sanAkel commented May 3, 2021

@sanAkel Did you want to review this PR? The number of non-NUOPC changes is very small so I would not expect any issues.

Otherwise, I will go ahead and merge this if there's no objection. (I will redirect it to main rather than dev/gfdl).

@marshallward Thanks for checking. I think I will take a pass on this one. Though I am a bit confused by "(I will redirect it to main rather than dev/gfdl)" You won't merge it to dev/gfdl ?

@marshallward
Copy link
Copy Markdown
Collaborator

I am a bit confused by "(I will redirect it to main rather than dev/gfdl)" You won't merge it to dev/gfdl ?

The PR was misdirected to the dev/gfdl branch, but we want it to go to main, i.e. our release branch. I will manually merge this to main but will later merge the contents into dev/gfdl.

@sanAkel
Copy link
Copy Markdown
Collaborator

sanAkel commented May 3, 2021

I am a bit confused by "(I will redirect it to main rather than dev/gfdl)" You won't merge it to dev/gfdl ?

The PR was misdirected to the dev/gfdl branch, but we want it to go to main, i.e. our release branch. I will manually merge this to main but will later merge the contents into dev/gfdl.

Got it, Thanks @marshallward. Once you have

later merge the contents into dev/gfdl.

We will update GEOS-ESM.

@marshallward
Copy link
Copy Markdown
Collaborator

This PR has now been added to main. It should auto-close once we merge into dev/gfdl.

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.