-
Notifications
You must be signed in to change notification settings - Fork 119
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
[develop] Added environment variable LDFLAGS on macOS as requested by the corresponding module file #729
[develop] Added environment variable LDFLAGS on macOS as requested by the corresponding module file #729
Conversation
…sponding module file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting changes to the modulefile build_macos_gnu.lua instead of adding conditionals to devbuild.sh
Lines 59-65 of build_macos_gnu.lua to be changed to a single line adding a flag to the existing ones (note "+=" instead of "=", and spaces before "L" and after "lib")
export LDFLAGS+=" -L$MPI_ROOT/lib "
Another change that is needed for build_macos_gnu.lua in lines 49-50:
setenv("CMAKE_Platform", "macosx.gnu")
--setenv("CMAKE_Platform", "macosx.intel")
instead of "macos.<compiler>".
The ufs-weather-model expects "macosx.<compiler>" as a platform name, and it has ufs-weather-model/cmake/configure_macosx.gnu.cmake
and configure_macosx.intel.cmake
platform-dependent configuration files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export LDFLAGS+=" -L$MPI_ROOT/lib "
does not work in a Lua module file. Note that it is a shell command.- If we change the platform name inside the module file,
build_macos_gnu.lua
, the file name should also be changed tobuild_macosx_gnu.lua
to be consistent. And all other scripts that mentionedbuild_macos_gnu
should also be changed.
It will be involved too many modifications and is error prone. I prefer to leaving it to the next major version update? My current modification is not perfect, but it requests the minimal changes that make the script devbuild.sh
work on the macOS platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ywangwof -
Thank you for your responses!
- Yes, indeed this will not work as in the bash shell. Even if we use Lua syntax, such as
append_path (”LDFLAGS”, “ -L$MPI_ROOT/lib ", “ ”)
it will not work either, because the $MPI_ROOT could only be expanded after the modulefile is loaded; it is not yet available inside the modulefile.
Your solution to modify devbuild.sh is then a good option. My only suggestion is to use a conditional based on a $PLATFORM variable, because we may have other compilers Intel, Clang. The line 452 in devbuild.sh then would be:
if [[ "${PLATFORM}" == "macos" ]]; then
-
Agree. If a platform+compiler naming for the SRW differs from that for the UFS-WM, but still works for the SRW system, it's OK to leave it unchanged.
-
Modulefiles build_macos_gnu.lua may still need a correction to the syntax for the export LDFLAGS string, suggesting:
if mode() == "load" then
LmodMsgRaw([===[
Please export env. variable LDFLAGS after the module is successfully loaded:
export LDFLAGS+=" -L$MPI_ROOT/lib "
]===])
end
devbuild.sh
Outdated
@@ -450,7 +450,7 @@ else | |||
module use ${SRW_DIR}/modulefiles | |||
module load ${MODULE_FILE} | |||
if [[ "${MODULE_FILE}" == "build_macos_gnu" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting the following for the line 452:
if [[ "${PLATFORM}" == "macos" ]]; then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your comments. The modifications are committed as you suggested. Please review them again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your solution to modify devbuild.sh is then a good option. My only suggestion is to use a conditional based on a $PLATFORM variable, because we may have other compilers Intel, Clang. The line 452 in devbuild.sh then would be:
if [[ "${PLATFORM}" == "macos" ]]; then
Modulefile build_macos_gnu.lua
may still need a correction to the syntax for the export LDFLAGS string, suggesting:
if mode() == "load" then
LmodMsgRaw([===[
Please export env. variable LDFLAGS after the module is successfully loaded:
export LDFLAGS+=" -L$MPI_ROOT/lib "
]===])
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ywangwof -
Thank you for your responses!
- Yes, indeed this will not work as in the bash shell. Even if we use Lua syntax, such as
append_path (”LDFLAGS”, “ -L$MPI_ROOT/lib ", “ ”)
it will not work either, because the $MPI_ROOT could only be expanded after the modulefile is loaded; it is not yet available inside the modulefile.
Your solution to modify devbuild.sh is then a good option. My only suggestion is to use a conditional based on a $PLATFORM variable, because we may have other compilers Intel, Clang. The line 452 in devbuild.sh then would be:
if [[ "${PLATFORM}" == "macos" ]]; then
-
Agree. If a platform+compiler naming for the SRW differs from that for the UFS-WM, but still works for the SRW system, it's OK to leave it unchanged.
-
Modulefiles build_macos_gnu.lua may still need a correction to the syntax for the export LDFLAGS string, suggesting:
if mode() == "load" then
LmodMsgRaw([===[
Please export env. variable LDFLAGS after the module is successfully loaded:
export LDFLAGS+=" -L$MPI_ROOT/lib "
]===])
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line 63 needs in modulefiles/build_macos_gnu.lua to be changed to:
export LDFLAGS+=" -L$MPI_ROOT/lib "
there are extra characters that need to be removed. They were related to a message when written in a bash script, and the conversion to *.lua format has not been done properly.
modulefiles/build_macos_gnu.lua
Outdated
@@ -60,7 +60,7 @@ setenv("FFLAGS", " -DNO_QUAD_PRECISION -fallow-argument-mismatch ") | |||
if mode() == "load" then | |||
LmodMsgRaw([===[ | |||
Please export env. variable LDFLAGS after the module is successfully loaded: | |||
> export LDFLAGS=\"-L\$MPI_ROOT/lib \" " | |||
> export LDFLAGS+=\"-L\$MPI_ROOT/lib \" " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line 63 needs to be changed to:
export LDFLAGS+=" -L$MPI_ROOT/lib "
there are extra characters that need to be removed. They were related to a message when written in a bash script, and the conversion to *.lua format not done properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ywangwof - please see my comment above regarding the change!..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Changed with a new commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ywangwof Thank you so much for working with @natalie-perlin on this PR. Approving now.
@ywangwof The automated Jenkins testing showed a failure in There was also the failure of the Now moving forward with merging this work into develop. |
DESCRIPTION OF CHANGES:
On macOS with GNU compiler, once the module file build_macos_gnu.lua is loaded, it outputs a message to request for setting environment variable LDFLAGS:
When using script devbuild.sh however, it does not give users a chance to read/set this environment variable. I added three lines in the script devbuild.sh, which will set this environment variable automatically when the module build_macos_gnu is detected.
This will make script devbuild.sh working on macOS as it is on other platforms and will also avoid a library not found error on macOS.
Type of change
TESTS CONDUCTED:
It is tested on Mac OS Monterey using GNU compiler and the latest HPC-stack installation (from develop branch). It should not affect the performance of this script on other platforms and it is also confirmed on Jet using Intel compiler.
DEPENDENCIES:
None
DOCUMENTATION:
N/A
CHECKLIST
LABELS (optional):
A Code Manager needs to add the following labels to this PR: