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

Possible issue with FindESMF.cmake #39

Closed
mathomp4 opened this issue Jan 28, 2020 · 14 comments
Closed

Possible issue with FindESMF.cmake #39

mathomp4 opened this issue Jan 28, 2020 · 14 comments

Comments

@mathomp4
Copy link

All,

I was trying to build following the instructions and was getting frustrated by the fact that ESMF could not be found. Eventually, I tracked down my issue to this line:

string(REPLACE "-I" "" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})

Why? Well, if we look in my esmf.mk file:

ESMF_F90COMPILEPATHS=-I/discover/swdev/mathomp4/NCEPLIBS/install-Intel18/mod -I/discover/swdev/mathomp4/NCEPLIBS/install-Intel18/include -I/discover/swdev/mathomp4/NCEPLIBS/install-Intel18/include

The issue is that I installed NCEPLIBS with -DCMAKE_INSTALL_PREFIX=../install-Intel18. And what's in the center of that? -I. Thus, CMake was seeing:

-- MATMAT fv3cpl ESMF_MOD: /discover/swdev/mathomp4/NCEPLIBS/installntel18/mod;/discover/swdev/mathomp4/NCEPLIBS/installntel18/include;/discover/swdev/mathomp4/NCEPLIBS/installntel18/include

I solved it by installing to a different directory, but I'm lucky only in that nowhere else in my full path was a -I.

It's not a fatal flaw, but it might be useful to make a bit more robust.

@climbfuji
Copy link
Collaborator

Thanks for reporting this issue. Please note that the entire ufs model, including the NCEPLIBS umbrella build, are currently under development and testing (basically what you did, thank you). We are currently refactoring the NCEPLIBS build, by the end of the week we hope to have it finalized. We will make sure that the issue you reported (that is, a -I in the filepath) is addressed in the refactored build system. Meanwhile, I need to ask you for your patience. Thanks!

@DusanJovic-NOAA
Copy link
Collaborator

How about changing:

string(REPLACE "-I" "" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS}) 

to:

string(REPLACE " -I" " " ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})

@mathomp4 Can you install ESMF in install-Intel18 directory again and try this change?

@climbfuji
Copy link
Collaborator

This will not catch the leading -I in ESMF_F90COMPILEPATHS. The script will also have to look for a -I at the beginning of the string.

  message(INFO "ESMF_F90COMPILEPATHS 1: ${ESMF_F90COMPILEPATHS}")
  string(REPLACE "-I" "" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})
  message(INFO "ESMF_F90COMPILEPATHS 2: ${ESMF_F90COMPILEPATHS}")
  string(REPLACE " " ";" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})
  message(INFO "ESMF_F90COMPILEPATHS 3: ${ESMF_F90COMPILEPATHS}")
INFO ESMF_F90COMPILEPATHS 1: -I/usr/local/gnu/esmf-8.0.0/mod -I/usr/local/gnu/esmf-8.0.0/include -I/usr/local/gnu/include
INFO ESMF_F90COMPILEPATHS 2: /usr/local/gnu/esmf-8.0.0/mod /usr/local/gnu/esmf-8.0.0/include /usr/local/gnu/include
INFO ESMF_F90COMPILEPATHS 3: /usr/local/gnu/esmf-8.0.0/mod;/usr/local/gnu/esmf-8.0.0/include;/usr/local/gnu/include

@climbfuji
Copy link
Collaborator

We should use the following imo:

  string(REGEX REPLACE "^-I" "" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})
  string(REPLACE " -I" " " ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})
  string(REPLACE " " ";" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})

This also takes care of filenames containing spaces unless it's something really weird, but who would do that?

-I/some/stupid/filepath/containing\ -I/and/something/else

Well, probably someone will. @kgerheiser @mark-a-potts I will create a PR for Kyle's refactored version.

@mathomp4
Copy link
Author

This could also work:

separate_arguments(ESMF_F90COMPILEPATHS)
foreach (ITEM ${ESMF_F90COMPILEPATHS})
   string(REGEX REPLACE "^-I" "" ITEM "${ITEM}")
   list(APPEND tmp ${ITEM})
endforeach()
set(ESMF_F90COMPILEPATHS ${tmp})

@climbfuji
Copy link
Collaborator

@DusanJovic-NOAA
Copy link
Collaborator

This file is in ufs-weather-model (this repository). We should thoroughly test this change and commit it in one of our next PRs.

@mathomp4
Copy link
Author

mathomp4 commented Jan 28, 2020

This could also work:

Actually, this still might cause issue with paths with spaces in. Okay. New challenge...

@climbfuji
Copy link
Collaborator

Thanks @mathomp4. I tested your version to see if it fixes the shortcoming I noted for my suggestion, and unfortunately it doesn't solve this problem either:

INFOESMF_F90COMPILEPATHS: -I/usr/local/gnu/esmf-8.0.0/mod -I/usr/local/gnu/esmf-8.0.0/include -I/usr/local/gnu/include -I/something/stupid -Ibla/stuff
INFOESMF_F90COMPILEPATHS: /usr/local/gnu/esmf-8.0.0/mod;/usr/local/gnu/esmf-8.0.0/include;/usr/local/gnu/include;/something/stupid;bla/stuff
INFOESMF_F90COMPILEPATHS: -I/usr/local/gnu/esmf-8.0.0/mod -I/usr/local/gnu/esmf-8.0.0/include -I/usr/local/gnu/include -I'/something/stupid -Ibla/stuff'
INFOESMF_F90COMPILEPATHS: /usr/local/gnu/esmf-8.0.0/mod;/usr/local/gnu/esmf-8.0.0/include;/usr/local/gnu/include;'/something/stupid;bla/stuff'

So, for now I will keep what is in https://github.com/kgerheiser/CMakeModules/pull/2. Thanks for helping!

@climbfuji
Copy link
Collaborator

@mathomp4 if course we could replace \ -I with something else temporarily, then do the decomposition using your or my method, and then replace the temporary string with \ -I again. But I don't know if it is worth the effort.

@mathomp4
Copy link
Author

mathomp4 commented Jan 28, 2020

This seems to handle spaces in paths:

separate_arguments(ESMF_F90COMPILEPATHS NATIVE_COMMAND ${ESMF_F90COMPILEPATHS})
foreach (ITEM ${ESMF_F90COMPILEPATHS})
   string(REGEX REPLACE "^-I" "" ITEM "${ITEM}")
   list(APPEND tmp ${ITEM})
endforeach()
set(ESMF_F90COMPILEPATHS ${tmp})

ETA: Should perhaps work on Windows as well.

@climbfuji
Copy link
Collaborator

This works as long as the ESMF_F90COMPILEPATHS variable puts the filepath with spaces in quotes, otherwise not. I hope it does.

INFO ESMF_F90COMPILEPATHS: -I/usr/local/gnu/esmf-8.0.0/mod -I/usr/local/gnu/esmf-8.0.0/include -I/usr/local/gnu/include -I'/something/stupid -Ibla/stuff'
...
INFO ESMF_F90COMPILEPATHS: /usr/local/gnu/esmf-8.0.0/mod;/usr/local/gnu/esmf-8.0.0/include;/usr/local/gnu/include;/something/stupid -Ibla/stuff

INFO ESMF_F90COMPILEPATHS: -I/usr/local/gnu/esmf-8.0.0/mod -I/usr/local/gnu/esmf-8.0.0/include -I/usr/local/gnu/include -I/something/stupid -Ibla/stuff
...
INFO ESMF_F90COMPILEPATHS: /usr/local/gnu/esmf-8.0.0/mod;/usr/local/gnu/esmf-8.0.0/include;/usr/local/gnu/include;/something/stupid;bla/stuff

Anyway, your solution is better. I'll update the PR. Thanks.

@climbfuji
Copy link
Collaborator

This has been fixed in the new branch release/public-v1, which will replace all other branches associated with the UFS public release. Have a look here, and if satisfied, please close the issue:

https://github.com/NOAA-EMC/CMakeModules/blob/7f5b1b3f51ddaf2d33b0e658587b978887c524f7/Modules/FindESMF.cmake#L75

Thanks!

@junwang-noaa
Copy link
Collaborator

The problem was fixed. Close issue.

climbfuji added a commit to climbfuji/ufs-weather-model that referenced this issue Apr 14, 2020
…nto_dtc_hwrf-physics

dtc/hwrf-physics: merge HWRF saSAS with GFS version, update to a more recent version of ufs-weather-model from EMC develop
climbfuji pushed a commit to climbfuji/ufs-weather-model that referenced this issue Sep 3, 2020
Update submodule pointer for fv3atm / ccpp-physics (changes for flexible number of soil levels)
LarissaReames-NOAA pushed a commit to LarissaReames-NOAA/ufs-weather-model that referenced this issue Oct 22, 2021
Fix mesh generation in init_grid()
DeniseWorthen pushed a commit to DeniseWorthen/ufs-weather-model that referenced this issue Aug 1, 2024
modified ADCIRC-interface/CMakeLists.txt to support Python & Bash for the generation of the version file
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

No branches or pull requests

4 participants