Skip to content

Commit

Permalink
Update ufs_macosx.gnu.lua modulefile and building scripts for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Natalie Perlin committed Jan 13, 2025
1 parent 5be9169 commit 816a4cb
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 12 deletions.
29 changes: 18 additions & 11 deletions modulefiles/ufs_macosx.gnu.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
help([[
loads UFS Model prerequisites for MacOS clang/gcc ("gnu")
loads UFS Model modules for MacOSX
]])

prepend_path("MODULEPATH", "/Users/username/spack-stack/spack-stack-1.8.0/envs/ufs-srw-env/install/modulefiles/Core")
-- Replace the stackpath below by the path of the local spack-stack environment build:
local stackpath = "/Users/username/spack-stack/spack-stack-1.8.0/envs/ufs-srw-env"
local modulepath = stackpath .. "/install/modulefiles/Core"
prepend_path("MODULEPATH", modulepath)

stack_gnu_ver=os.getenv("stack_apple_clang_ver") or "15.0.0"
load(pathJoin("stack-apple-clang", stack_gnu_ver))

stack_openmpi_ver=os.getenv("stack_openmpi_ver") or "5.0.3"
stack_openmpi_ver=os.getenv("stack_openmpi_ver") or "4.1.6"
load(pathJoin("stack-openmpi", stack_openmpi_ver))

cmake_ver=os.getenv("cmake_ver") or "3.27.9"
Expand Down Expand Up @@ -54,12 +56,17 @@ setenv("CMAKE_Fortran_COMPILER_ID", "GNU")
osx_sysroot=os.getenv("OSX_SYSROOT")
setenv("CMAKE_OSX_SYSROOT","OSX_SYSROOT")

setenv("CFLAGS"," -Wno-implicit-function-declaration ")

if mode() == "load" then
LmodMsgRaw([===[
Please export these env. variables after the module is successfully loaded:
> export LDFLAGS+=" -L${libjpeg_turbo_ROOT}/lib -ljpeg -Wl,-rpath,$libjpeg_turbo_ROOT}/lib -L${jasper_ROOT}/lib -ljasper -Wl,-rpath,${jasper_ROOT}/lib -L${libpng_ROOT}/lib -lpng -Wl,-rpath,${libpng_ROOT}/lib "
]===])
local libjpeg_ROOT = os.getenv("libjpeg_turbo_ROOT")
local jasper_ROOT = os.getenv("jasper_ROOT")
local libpng_ROOT = os.getenv("libpng_ROOT")
local ldflags0 = os.getenv("LDFLAGS") or ""
local ldflags_add = " -Wl,-no_compact_unwind"

if jasper_ROOT and libpng_ROOT and libjpeg_ROOT then
local ldflags1 = " -L" .. libjpeg_ROOT .. "/lib -ljpeg -Wl,-rpath," .. libjpeg_ROOT .. "/lib"
local ldflags2 = " -L" .. jasper_ROOT .. "/lib -ljasper -Wl,-rpath," .. jasper_ROOT .. "/lib"
local ldflags3 = " -L" .. libpng_ROOT .. "/lib -lpng -Wl,-rpath," .. libpng_ROOT .. "/lib"
local ldflags = ldflags0 .. ldflags_add .. ldflags1 .. ldflags2 .. ldflags3
setenv("LDFLAGS", ldflags)
end
whatis("Description: UFS build environment")
2 changes: 1 addition & 1 deletion tests/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ BUILD_JOBS=${BUILD_JOBS:-8}

set +x
case ${MACHINE_ID} in
macosx|linux)
linux)
source "${PATHTR}/modulefiles/ufs_${MACHINE_ID}.${RT_COMPILER}"
;;
*)
Expand Down
25 changes: 25 additions & 0 deletions tests/default_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,31 @@ elif [[ ${MACHINE_ID} = linux ]]; then
export ICE_tasks_cpl_thrd=10
export WAV_tasks_cpl_thrd=12

elif [[ ${MACHINE_ID} = macosx ]]; then

export TPN=8

export INPES_dflt=3
export JNPES_dflt=8
export INPES_thrd=3
export JNPES_thrd=4

export THRD_cpl_dflt=1
export INPES_cpl_dflt=3
export JNPES_cpl_dflt=8
export WPG_cpl_dflt=6
export OCN_tasks_cpl_dflt=20
export ICE_tasks_cpl_dflt=10
export WAV_tasks_cpl_dflt=20

export THRD_cpl_thrd=2
export INPES_cpl_thrd=3
export JNPES_cpl_thrd=4
export WPG_cpl_thrd=6
export OCN_tasks_cpl_thrd=20
export ICE_tasks_cpl_thrd=10
export WAV_tasks_cpl_thrd=12

elif [[ ${MACHINE_ID} = jet ]]; then

export TPN=24
Expand Down
5 changes: 5 additions & 0 deletions tests/detect_machine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ case $(hostname -f) in
*) MACHINE_ID=UNKNOWN ;; # Unknown platform
esac

# Determine if the system is MacOS/Darwin:
case $(uname -s) in
Darwin) MACHINE_ID=macosx ;; ### MacOS
esac

if [[ ${MACHINE_ID} == "UNKNOWN" ]]; then
case ${PW_CSP:-} in
"aws" | "google" | "azure") MACHINE_ID=noaacloud ;;
Expand Down
11 changes: 11 additions & 0 deletions tests/opnReqTest
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,17 @@ elif [[ $MACHINE_ID = linux ]]; then
PTMP=${dprefix}/stmp2
SCHEDULER=none

elif [[ $MACHINE_ID = macosx ]]; then

PARTITION=
QUEUE=
COMPILE_QUEUE=
dprefix=/Users/username
DISKNM=${dprefix}/data
STMP=${dprefix}/stmp4
PTMP=${dprefix}/stmp2
SCHEDULER=none

else
error "unknown machine ID. edit detect_machine.sh file"
fi
Expand Down

0 comments on commit 816a4cb

Please sign in to comment.