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

Test MAPL v2.53.0 in UFS weather model #2346

Open
Tracked by #2984
junwang-noaa opened this issue Jun 28, 2024 · 77 comments
Open
Tracked by #2984

Test MAPL v2.53.0 in UFS weather model #2346

junwang-noaa opened this issue Jun 28, 2024 · 77 comments
Assignees
Labels
enhancement New feature or request

Comments

@junwang-noaa
Copy link
Collaborator

junwang-noaa commented Jun 28, 2024

Description

MAPL 2.46.2 has fixes for issue #2162. UFS weather model needs to be tested and updated with this version.

20240830:
MAPL 2.46.2 has a bug. MAPL 2.46.3 should be installed and tested in UFS weather model. The issue title is updated.

Solution

Alternatives

Related to

@junwang-noaa
Copy link
Collaborator Author

@lipan-NOAA Can you confirm this version of MAPL works in GOCART for GEFSv13? Thanks

@BrianCurtis-NOAA
Copy link
Collaborator

@Hang-Lei-NOAA is MAPL 2.46.2 installed on Acorn/WCOSS2?

@Hang-Lei-NOAA
Copy link

Hang-Lei-NOAA commented Jul 1, 2024 via email

@lipan-NOAA
Copy link
Collaborator

@Hang-Lei-NOAA Can you tell me where you installed it?

@Hang-Lei-NOAA
Copy link

Hang-Lei-NOAA commented Jul 2, 2024 via email

@ulmononian
Copy link
Collaborator

do you want this installed in spack-stack/1.6.0? and on which machine?

@jkbk2004
Copy link
Collaborator

@DusanJovic-NOAA @junwang-noaa new maple and esmf version are available on hercules and orion for the test and debug activities. @RatkoVasic-NOAA thanks for the installation!

Hercules: /work/noaa/epic/role-epic/spack-stack/hercules/spack-stack-1.6.0/envs/ue-esmf-8.6.1-mapl-2.46.3/install/modulefiles/Core
Orion: /work/noaa/epic/role-epic/spack-stack/orion/spack-stack-1.6.0/envs/ue-esmf-8.6.1-mapl-2.46.3/install/modulefiles/Core

@mathomp4
Copy link

As an FYI, the MAPL 2.46.3 fix was when using externally initialized MPI. (Which is something you all do but we don't do internally).

We also had this notice to users:

Notice to users: External code should initialize MPI with MPI_THREAD_MULTIPLE as that is what MAPL expects. Also, code might need to call:

call ESMF_InitializePreMPI()

for all features of MAPL to be supported, namely if ESMF Single System Image (SSI) code is enabled. If users do not use this (or know what it is), it most likely is not needed.

My guess is you do not need to call ESMF_InitializePreMPI() as I don't think even we internally quite use all the SSI code yet.

@junwang-noaa
Copy link
Collaborator Author

@weiyuan-jiang may I ask what compiler/mpi versions you want to test? Thanks

@mathomp4
Copy link

mathomp4 commented Dec 2, 2024

@weiyuan-jiang may I ask what compiler/mpi versions you want to test? Thanks

@junwang-noaa Well for that version of MAPL, we would have been testing with:

  • Intel ifort 2021.6
  • Intel ifort 2021.12 (or .13)
  • GCC 13.2.0

We never had Intel ifort 2021.9 on any machines we have. Are any of these possible?

@junwang-noaa
Copy link
Collaborator Author

@AlexanderRichert-NOAA do we have these intel and GCC version on Hera or Hercules orGaea?

@AlexanderRichert-NOAA
Copy link
Collaborator

I can't get onto Hera at the moment but for the others:

  • Gaea (C5 & C6):
    • ifort 2021.6 (module load intel-classic/2022.1.0)
    • GCC 13.2 (module load gcc-native/13.2)
  • Hercules & Orion:
    • ifort 2021.12.0 (module load intel-oneapi-compilers/2024.1.0)

@mathomp4
Copy link

mathomp4 commented Dec 3, 2024

As we have access to Hercules/Orion, I guess ifort 2021.12 is our best bet at the moment (though I'd have to imagine there must be a recent-ish gcc on there).

I'm fairly certain we can run with 2021.12. There were some bugfixes needed in places of GEOS (I don't think MAPL, but I can find out), so by the time we got them all in, 2021.13 was out, but I think 2021.12 works.

Plus, we have 2021.12 on discover, so we can do some matching if need be.

@junwang-noaa
Copy link
Collaborator Author

@weiyuan-jiang @mathomp4 Which MAPL version would you like us to test in UFS? I assume the ESMF version is 8.6.1

@weiyuan-jiang
Copy link
Collaborator

@junwang-noaa It doesn't matter. I can always replace the MAPL as long as it can be built and run under new compiler on Hercules

@DusanJovic-NOAA
Copy link
Collaborator

@DusanJovic-NOAA I do not think we want to change the current (0,1) mask values for ATM because that will have downstream impacts in CMEPS.

I can't even find the MAPL code you reference, but if you don't want to mask the destination anywhere, then why not provide a special value? CMEPS uses ispval_mask = -987987 ! spval for RH mask values

MAPL code I reference is here:
https://github.com/GEOS-ESM/MAPL/blob/1c55973c244834ed0d78c39964d2738c3d8f8a8b/base/MAPL_EsmfRegridder.F90#L1519

I do not understand where that special value should be provided and how is MAPL going to use that value?

@DeniseWorthen
Copy link
Collaborator

I didn't mean that MAPL should somehow reach into CMEPS for the value. I was just pointing out that by setting a special value (one that is never encountered), you can map to all destination points.

@DusanJovic-NOAA
Copy link
Collaborator

DusanJovic-NOAA commented Jan 2, 2025

I didn't mean that MAPL should somehow reach into CMEPS for the value. I was just pointing out that by setting a special value (one that is never encountered), you can map to all destination points.

Sorry, I still do not understand what should be set to a special value, a grid mask? The problem is that some of the fv3atm grid points have grid mask set to 0 and MAPL considers them as destination grid points that should be masked out.

The fv3atm grid mask is defined in this routine https://github.com/NOAA-EMC/fv3atm/blob/a7d46eee01a78f0915373ebc58c9b20ba14a6c36/atmos_model.F90#L3654

@DeniseWorthen
Copy link
Collaborator

The dstMaskValue can be set to a special value.

I'm probably misunderstanding, since I've never looked at MAPL. But the issue is that when the destination is ATM, you want all destination points mapped, right? Or is the destination in this case the aerosol "grid/mesh" ?

@DusanJovic-NOAA
Copy link
Collaborator

The dstMaskValue can be set to a special value.

Yes, it can be. But it is currently set to 0 (MAPL_MASK_OUT is 0). Here. That means any fv3atm destination point with grid mask 0 (all ocean points) will be masked out.

I'm probably misunderstanding, since I've never looked at MAPL. But the issue is that when the destination is ATM, you want all destination points mapped, right? Or is the destination in this case the aerosol "grid/mesh" ?

Yes. All fv3atm destination points should be mapped, ie. it should not have grid mask set to 0.

If we can not redefine fv3atm grid mask to not use 0 for any grid point, which it seems we can not do, then either we pass the information to MAPL to not use 0 to mask out destination points. Or maybe somewhere in fv3atm or maybe in gocart we redefine grid mask that is going to be passed to MAPL.

@DeniseWorthen
Copy link
Collaborator

But why does the dstMaskValue have to be set using the values that ATM uses to define it's mask? I realize that may be how the code is working, but I don't think it should be constrained like that.

@junwang-noaa
Copy link
Collaborator Author

@weiyuan-jiang @tclune UFS is using a land sea mask on FV3 cubed sphere grid (0 for ocean and 1 for land) for coupling purposes. May I ask if the following line (MAPL_MASK_OUT) can be updated so that mask value 0 in UFS won't be considered undefined?

          if (has_mask) dstMaskValues = [MAPL_MASK_OUT] ! otherwise unallocated

@weiyuan-jiang
Copy link
Collaborator

I think the constant value of MAPL_MASK_OUT should be updated

@DusanJovic-NOAA
Copy link
Collaborator

With this change in GOCART I was able to make a successful (no floating point exception) run.

diff --git a/ESMF/UFS/Aerosol_Cap.F90 b/ESMF/UFS/Aerosol_Cap.F90
index b753afa..e21ed11 100644
--- a/ESMF/UFS/Aerosol_Cap.F90
+++ b/ESMF/UFS/Aerosol_Cap.F90
@@ -243,6 +243,7 @@ contains
     type(MAPL_CapOptions)     :: maplCapOptions
     type(Aerosol_InternalState_T) :: is
     type(Aerosol_Tracer_T), pointer :: trp
+    integer(kind=ESMF_KIND_I4), pointer  :: maskPtr(:,:)
 
     ! begin
     rc = ESMF_SUCCESS
@@ -338,6 +339,10 @@ contains
       file=__FILE__)) &
       return  ! bail out
 
+    call ESMF_GridGetItem(grid, itemflag=ESMF_GRIDITEM_MASK,   &
+                          staggerloc=ESMF_STAGGERLOC_CENTER, farrayPtr=maskPtr, _RC)
+    maskPtr = 1
+
     ! provide model grid to MAPL
     call cap % cap_gc % set_grid(grid, lm=nlev, _RC)

This change explicitly sets all grid mask points to 1, before passing the grid to MAPL.

@weiyuan-jiang
Copy link
Collaborator

weiyuan-jiang commented Jan 6, 2025

Ben has a new PR (GEOS-ESM/MAPL#3281) to solve the problem on MAPL. So no need to change on ufs

@DusanJovic-NOAA
Copy link
Collaborator

Ben has a new PR (GEOS-ESM/MAPL#3281) to solve the problem on MAPL. So no need to change on ufs

@weiyuan-jiang Thanks for the update. It's good to know that no changes in fv3atm nor gocart are necessary to solve the issues with masking in MAPL regridding.

Any progress with cubed sphere subgrids issue when threading is used.

@weiyuan-jiang
Copy link
Collaborator

@DusanJovic-NOAA I have opened an issue on MAPL. (GEOS-ESM/MAPL#3274) . It seems multi-threading is not working at this point

@DusanJovic-NOAA
Copy link
Collaborator

DusanJovic-NOAA commented Jan 23, 2025

@weiyuan-jiang I see the MAPL team has released version 2.52.0, which includes the fix for grid masks. I tested it together with recently releases ESMF 8.8.0 on Hercules and all ufs-weather-model regression test passed (using intel compiler, I did not test gnu). I had to turn off OpenMP threading in GOCART due to the first issue with cubed-sphere grids and threading.

@climbfuji
Copy link
Collaborator

@DusanJovic-NOAA Do you want mapl to be updated to 2.52.0 for spack-stack-1.9.0 (we already have esmf 8.8.0)? We are hoping to cut the release branch tomorrow, thus this would be just in time. Thanks!

@mathomp4
Copy link

@DusanJovic-NOAA Do you want mapl to be updated to 2.52.0 for spack-stack-1.9.0 (we already have esmf 8.8.0)? We are hoping to cut the release branch tomorrow, thus this would be just in time. Thanks!

Note: We do think we have the fix for the GOCART OpenMP issue here:

GEOS-ESM/MAPL#3350

I believe it worked for @weiyuan-jiang on Hercules, but if it works for you, I could get a MAPL version out tomorrow.

Also, MAPL 2.52 doesn't (yet) require ESMF 8.8 as we don't need any features from that yet in MAPL2. MAPL3 does currently require it.

@DusanJovic-NOAA
Copy link
Collaborator

@DusanJovic-NOAA Do you want mapl to be updated to 2.52.0 for spack-stack-1.9.0 (we already have esmf 8.8.0)? We are hoping to cut the release branch tomorrow, thus this would be just in time. Thanks!

Note: We do think we have the fix for the GOCART OpenMP issue here:

GEOS-ESM/MAPL#3350

I believe it worked for @weiyuan-jiang on Hercules, but if it works for you, I could get a MAPL version out tomorrow.

Also, MAPL 2.52 doesn't (yet) require ESMF 8.8 as we don't need any features from that yet in MAPL2. MAPL3 does currently require it.

Thanks for the update @mathomp4. I am using a shell script provided by @AlexanderRichert-NOAA to build chained spack environment with updated ESMF and MAPL to run test on Hercules. If you can make a temporary tag or branch or something that spack can point to (I'm not sure if it has to be release), I should be able to try that version that includes OpenMP fix from 3350 PR you mentioned above. And if we can get that tested before @climbfuji needs to cut release for 1.9.0 spack-stack that would be perfect.

@climbfuji
Copy link
Collaborator

Other components/models need esmf 8.8.0, might as well use that across the board if it works for Dusan. Thanks Matt!

@mathomp4
Copy link

@DusanJovic-NOAA I've tagged with temp-tag-for-dusan if that's easy to use. It's also at commit GEOS-ESM/MAPL@260d563

@DusanJovic-NOAA
Copy link
Collaborator

@DusanJovic-NOAA I've tagged with temp-tag-for-dusan if that's easy to use. It's also at commit GEOS-ESM/MAPL@260d563

Thanks. @AlexanderRichert-NOAA is there a way to use this tag (specific commit hash) in your env chainer script to build MAPL.

@AlexanderRichert-NOAA
Copy link
Collaborator

Thanks. @AlexanderRichert-NOAA is there a way to use this tag (specific commit hash) in your env chainer script to build MAPL.

@DusanJovic-NOAA in theory yes-- I just made a small tweak in the env chainer script to allow it to use Spack's built-in support for using git references. For the mapl spec, it would be something like mapl@git.260d563d08ff0d3e8436ec33ed98a362110e731b=develop where 'develop' is the version that Spack is going to treat it as (you can set this to a numbered version for the purpose of determining dependencies etc.). The only trick is that in that commit, MAPL's CMakeLists.txt requires CMake 3.24 or higher, which is not what spack-stack-1.6.0 uses, so you have to work around that. mapl@git.260d563d08ff0d3e8436ec33ed98a362110e731b=develop cmake@3.24.4 for the specs worked for me on hercules just now (with another 'git pull' of the env chainer script, and not forgetting about the depends_on("udunits")).

@DusanJovic-NOAA
Copy link
Collaborator

Thanks. @AlexanderRichert-NOAA is there a way to use this tag (specific commit hash) in your env chainer script to build MAPL.

@DusanJovic-NOAA in theory yes-- I just made a small tweak in the env chainer script to allow it to use Spack's built-in support for using git references. For the mapl spec, it would be something like mapl@git.260d563d08ff0d3e8436ec33ed98a362110e731b=develop where 'develop' is the version that Spack is going to treat it as (you can set this to a numbered version for the purpose of determining dependencies etc.). The only trick is that in that commit, MAPL's CMakeLists.txt requires CMake 3.24 or higher, which is not what spack-stack-1.6.0 uses, so you have to work around that. mapl@git.260d563d08ff0d3e8436ec33ed98a362110e731b=develop cmake@3.24.4 for the specs worked for me on hercules just now (with another 'git pull' of the env chainer script, and not forgetting about the depends_on("udunits")).

Thanks. Let me try that.

@mathomp4
Copy link

I just confirmed with @weiyuan-jiang that he didn't do anything else after using that new MAPL code. He kept OpenMP on in his test.

He did mention you'll need to make sure you have udunits loaded, but @AlexanderRichert-NOAA indicated that as well.

@DusanJovic-NOAA
Copy link
Collaborator

I successfully compiled MAPL tag (commit 260d563d08ff0d3e8436ec33ed98a362110e731b) using @AlexanderRichert-NOAA instructions, and I am running all intel ufs-wm regression tests. So far all tests passed (most importantly, cpld_control_p8_intel passed, which is the test that was failing previously). This is the configuration with:

$ grep use_threads parm/gocart/GOCART2G_GridComp.rc
use_threads: .TRUE.

So looks like we finally have a version of MAPL that fixes both issues, cubed_sphere grid with threading and masking of ESMF_grid due to mask value conflict between fv3atm and mapl.

In the meantime I will try to build spack-stack using GNU, and run gnu ufs-wm regression tests, just to be sure.

@DusanJovic-NOAA
Copy link
Collaborator

DusanJovic-NOAA commented Jan 24, 2025

I should also mention that in order to use ufs-wm with ESMF v8.8.0 an update in GOCART was needed. In my tests, I used a branch @theurich created that has some updates for esmf 8.8.0. This one. So before we can actually switch to 8.8.0 this change will need to be merged in gocart. The only issue is that we (ufs-wm) are still using a gocart commit from Sep 2023. And Gerhard's changes are on top of that commit. Somebody will need to port Gerhard's changes to newer gocart and then update ufs-wm to use that version.

@climbfuji
Copy link
Collaborator

@mathomp4 or @DusanJovic-NOAA Would you mind creating an issue in github.com/jcsda/spack-stack to update MAPL to version x.y.z for spack-stack-1.9.0, and list changes to the build options (if applicable)? Thanks!

@mathomp4
Copy link

mathomp4 commented Jan 24, 2025

I'm going to work on getting MAPL 2.53 out now. Shouldn't take me too long. Then you'll have a semver tag rather than a crazy git-hash.

ETA: Well, might take about 30-40 minutes. My final test is a full run on discover to make sure it is zero-diff, etc. and good ol' CMake has decided to rebuild the full model. I really hope ifx doesn't have this same CMake+ifort issue with recompiling!

@mathomp4
Copy link

MAPL 2.53.0 has been released:

https://github.com/GEOS-ESM/MAPL/releases/tag/v2.53.0

And I have a PR to spack:

spack/spack#48712

and an issue for JCSDA/spack-stack:

JCSDA/spack-stack#1469

Though that last one might not be "complete" as I'm not sure if any updates are needed for how MAPL is built, etc.

@DusanJovic-NOAA DusanJovic-NOAA changed the title Test MAPL v2.46.3 in UFS weather model Test MAPL v2.53.0 in UFS weather model Jan 24, 2025
@climbfuji
Copy link
Collaborator

Thanks @mathomp4 !

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

No branches or pull requests