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

Changes to build UFS-WM on MacOS platform with clang@15/[email protected] #2551

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,12 @@ target_link_libraries(ufs PUBLIC "${_ufs_libs_public}")
add_executable(ufs_model driver/UFS.F90)
add_dependencies(ufs_model ufs)
target_link_libraries(ufs_model ufs esmf w3emc::w3emc_d)
set_target_properties(ufs_model PROPERTIES LINKER_LANGUAGE Fortran)

if(CMAKE_Platform MATCHES "macosx.gnu")
set_target_properties(ufs_model PROPERTIES LINKER_LANGUAGE CXX)
else()
set_target_properties(ufs_model PROPERTIES LINKER_LANGUAGE Fortran)
endif()

###############################################################################
### Install
Expand Down
24 changes: 0 additions & 24 deletions modulefiles/ufs_macosx.gnu

This file was deleted.

72 changes: 72 additions & 0 deletions modulefiles/ufs_macosx.gnu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
help([[
loads UFS Model modules for MacOSX
]])
-- 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 "4.1.6"
load(pathJoin("stack-openmpi", stack_openmpi_ver))

cmake_ver=os.getenv("cmake_ver") or "3.27.9"
load(pathJoin("cmake", cmake_ver))

local ufs_modules = {
{["jasper"] = "2.0.32"},
{["zlib"] = "1.2.13"},
{["libpng"] = "1.6.37"},
{["hdf5"] = "1.14.0"},
{["netcdf-c"] = "4.9.2"},
{["netcdf-fortran"] = "4.6.1"},
{["parallelio"] = "2.6.2"},
{["esmf"] = "8.6.0"},
{["fms"] = "2024.02"},
{["bacio"] = "2.4.1"},
{["crtm"] = "2.4.0.1"},
{["g2"] = "3.5.1"},
{["g2tmpl"] = "1.13.0"},
{["ip"] = "5.0.0"},
{["sp"] = "2.5.0"},
{["w3emc"] = "2.10.0"},
{["gftl-shared"] = "1.9.0"},
{["mapl"] = "2.40.3-esmf-8.6.0"},
{["scotch"] = "7.0.4"},
}

for i = 1, #ufs_modules do
for name, default_version in pairs(ufs_modules[i]) do
local env_version_name = string.gsub(name, "-", "_") .. "_ver"
load(pathJoin(name, os.getenv(env_version_name) or default_version))
end
end

nccmp_ver=os.getenv("nccmp_ver") or "1.9.0.1"
load(pathJoin("nccmp", nccmp_ver))

setenv("CC", "mpicc")
setenv("CXX", "mpicxx")
setenv("FC", "mpifort")
setenv("CMAKE_Platform", "macosx.gnu")
setenv("CMAKE_Fortran_COMPILER_ID", "GNU")

osx_sysroot=os.getenv("OSX_SYSROOT")
setenv("CMAKE_OSX_SYSROOT","OSX_SYSROOT")


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
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
6 changes: 5 additions & 1 deletion tests/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,11 @@ fi
################################################################################
export OMP_ENV=${OMP_ENV:-""}
if [[ ${SCHEDULER} = 'none' ]]; then
ulimit -s unlimited
if [[ ${MACHINE_ID} == macosx ]]; then
ulimit -s -S unlimited
else
ulimit -s unlimited
fi
if [[ ${CI_TEST} = 'true' ]]; then
eval "${OMP_ENV}" redirect_out_err mpiexec -n "${TASKS}" ./fv3.exe
else
Expand Down
Loading