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

ESMF CMake config/capitalization #1498

Closed
AlexanderRichert-NOAA opened this issue Nov 18, 2022 · 14 comments
Closed

ESMF CMake config/capitalization #1498

AlexanderRichert-NOAA opened this issue Nov 18, 2022 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@AlexanderRichert-NOAA
Copy link
Collaborator

Description

When compiling UFS against a spack-stack installation of NCEPLIBS etc., UFS executable fails to complie because "-lESMF" cannot be found.

To Reproduce:

What compilers/machines are you seeing this with?
Give explicit steps to reproduce the behavior.

  1. Compile a model that includes GOCART with a copy of MAPL whose cmake config has capitalized "ESMF" as a target library.
  2. The build will fail when "-lESMF" is added to the UFS executable link step.

Additional context

This problem is due to inconsistencies in capitalization of the ESMF target in several places. In the last several versions of ESMF, the ESMF library target name is capitalized. This problem presented itself when switching to spack-stack from hpc-stack because unlike hpc-stack, the spack-stack installation of ESMF provides its own copy of FindESMF.cmake. When MAPL is built on top of this, the now-capitalized ESMF target name gets propagated into MAPL's cmake configuration. For reasons I do not yet entirely understand, when GOCART is compiled and pulls in MAPL, it transforms that capitalized "ESMF" target name into a "-lESMF" flag that gets included in the linking step of the UFS executable. This causes the build to fail, because there is no libESMF.{a,so} to be found. I am able to resolve this problem by modifying CMakesModules/Modules/FindESMF.cmake and WW3/model/src/CMakeLists.txt, specifically, by capitalizing the target name "esmf" to "ESMF" in several places. I have corresponded with the ESMF developers, who confirmed that the target name will continue to be capitalized, and moreover that UFS's copy of FindESMF.cmake should be kept up to date. The fact that the GOCART installation transforms the target name into a linker flag suggests that there is some other problem there, i.e., an incorrectly used variable somewhere in GOCART's cmake system, but from my testing, modifying "esmf"->"ESMF" in UFS's cmake configurations to make it consistent with ESMF and MAPL is sufficient to resolve this issue.

@arunchawla-NOAA
Copy link

@AlexanderRichert-NOAA is this an issue that still needs to be addressed?

@climbfuji
Copy link
Collaborator

Not speaking for Alex, but yes, this still needs to be addressed, and it's somewhat urgent because we need to put workarounds in place to build the ufs-weather-model with spack-stack.

@arunchawla-NOAA
Copy link

Is it as simple as modifying esmf to ESMF? As proposed or am I missing something? Do we need to get ESMF group involved?

@climbfuji
Copy link
Collaborator

This is an interesting one, because it involves NASA GMAO and ESMF people (it's got to do with MAPL using esma_cmake and somewhere deep inside there esmf gets capitalized to ESMF, which it shouldn't). It's discussed between the spack-stack developers and GMAO.

@AlexanderRichert-NOAA
Copy link
Collaborator Author

My understanding is that ESMF sets its target name as capitalized "ESMF", and they have no plans to change that. So either we can change ESMF by removing or modifying cmake/FindESMF.cmake, which is certainly not ideal, or, preferably, we can modify the target name to capitalized "ESMF" throughout UFS.

@climbfuji
Copy link
Collaborator

Is there a cmake convention that packages should follow? @DusanJovic-NOAA do you know?

@DusanJovic-NOAA
Copy link
Collaborator

Is there a cmake convention that packages should follow? @DusanJovic-NOAA do you know?

I am not sure, but I do not think there's any rule regarding the capitalization of target names.

@BrianCurtis-NOAA
Copy link
Collaborator

@AlexanderRichert-NOAA @climbfuji What version of MAPL has "MAPL whose cmake config has capitalized "ESMF" as a target library"

@BrianCurtis-NOAA
Copy link
Collaborator

@AlexanderRichert-NOAA @climbfuji Is there a version of spack-stack I should be using on Hera to get these fixes into a PR that will, i assume, be a dependency for the spack-stack PR?

@AlexanderRichert-NOAA
Copy link
Collaborator Author

@AlexanderRichert-NOAA @climbfuji What version of MAPL has "MAPL whose cmake config has capitalized "ESMF" as a target library"

It's a little more complicated than that-- it comes into the UFS/GOCART build system through the MAPL config, but when MAPL is built, it's get the target name from ESMF cmake. This was not an issue with hpc-stack because no "cmake/" directory was being installed under ESMF. I'd have to look and see if there's a version going back where this isn't the case.

@AlexanderRichert-NOAA
Copy link
Collaborator Author

@AlexanderRichert-NOAA @climbfuji Is there a version of spack-stack I should be using on Hera to get these fixes into a PR that will, i assume, be a dependency for the spack-stack PR?

I can set up a test version of ESMF/MAPL on hera without the capitalized ESMF library names.

@AlexanderRichert-NOAA
Copy link
Collaborator Author

@BrianCurtis-NOAA here is a copy of the 1.4.1 environment but without the capitalized library (libESMF): /scratch1/NCEPDEV/nems/Alexander.Richert/esmf-test/envs/test/install/modulefiles/Core

@junwang-noaa
Copy link
Collaborator

@BrianCurtis-NOAA is this issue resolved?

@BrianCurtis-NOAA
Copy link
Collaborator

Yes, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: In review
Development

No branches or pull requests

6 participants