Skip to content

Commit

Permalink
[develop] Added environment variable LDFLAGS on macOS as requested by…
Browse files Browse the repository at this point in the history
… the corresponding module file (ufs-community#729)

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:

Please export env. variable LDFLAGS after the module is successfully loaded:
> export LDFLAGS="-L$MPI_ROOT/lib " "
%

When using script devbuild.sh however, it does not give users a chance to read/set this environment variable. Three lines in the script devbuild.sh were added, which will set this environment variable automatically when the module build_macos_gnu is detected.

if [[ "${MODULE_FILE}" == "build_macos_gnu" ]]; then
    export LDFLAGS+=" -L$MPI_ROOT/lib "
fi

This will make script devbuild.sh work on macOS as it does on other platforms and will also avoid a library not found error on macOS.
  • Loading branch information
ywangwof committed May 1, 2023
1 parent 55337a7 commit 99944d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions devbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ CONTINUE=false
VERBOSE=false

# Turn off all apps to build and choose default later
DEFAULT_BUILD=true
DEFAULT_BUILD=true
BUILD_UFS="off"
BUILD_UFS_UTILS="off"
BUILD_UPP="off"
Expand Down Expand Up @@ -263,7 +263,7 @@ fi
RUN_VERSION_FILE="${SRW_DIR}/versions/run.ver.${PLATFORM}"
if [ -f ${RUN_VERSION_FILE} ]; then
. ${RUN_VERSION_FILE}
fi
fi

# set MODULE_FILE for this platform/compiler combination
MODULE_FILE="build_${PLATFORM}_${COMPILER}"
Expand Down Expand Up @@ -352,7 +352,7 @@ if [ "${APPLICATION}" = "ATMAQ" ]; then
cp "${SRW_DIR}/sorc/UFS_UTILS/modulefiles/build.${PLATFORM}.${COMPILER}.lua" "${EXTRN_BUILD_MOD_DIR}/mod_ufs-utils.lua"
fi
if [ "${BUILD_UPP}" = "on" ]; then
cp "${SRW_DIR}/sorc/UPP/modulefiles/${PLATFORM}.lua" "${EXTRN_BUILD_MOD_DIR}/mod_upp.lua"
cp "${SRW_DIR}/sorc/UPP/modulefiles/${PLATFORM}.lua" "${EXTRN_BUILD_MOD_DIR}/mod_upp.lua"
fi
if [ "${BUILD_NEXUS}" = "on" ]; then
cp "${SRW_DIR}/sorc/AQM-utils/parm/nexus_modulefiles/${PLATFORM}.${COMPILER}.lua" "${EXTRN_BUILD_MOD_DIR}/mod_nexus.lua"
Expand Down Expand Up @@ -449,6 +449,9 @@ if [ $USE_SUB_MODULES = true ]; then
else
module use ${SRW_DIR}/modulefiles
module load ${MODULE_FILE}
if [[ "${PLATFORM}" == "macos" ]]; then
export LDFLAGS+=" -L$MPI_ROOT/lib "
fi
fi
module list

Expand Down
2 changes: 1 addition & 1 deletion modulefiles/build_macos_gnu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
]===])
end

Expand Down

0 comments on commit 99944d2

Please sign in to comment.