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

[develop]: Updates for building and running SRW on MacOS platform #1171

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
20 changes: 16 additions & 4 deletions devbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ if [ "${BUILD_CONDA}" = "on" ] ; then
conda activate
if ! conda env list | grep -q "^srw_app\s" ; then
mamba env create -n srw_app --file environment.yml
if [ "${os}" == "MacOSX" ] ; then
conda activate srw_app
conda install -y -c conda-forge netcdf4
conda deactivate
fi
fi
if ! conda env list | grep -q "^srw_graphics\s" ; then
mamba env create -n srw_graphics --file graphics_environment.yml
Expand Down Expand Up @@ -353,10 +358,11 @@ else
printf "[C]ontinue building in the existing directory\n"
printf "[Q]uit this build script\n"
read -p "Choose an option (R/C/Q):" choice
echo "Your choice is : ${choice}"
case ${choice} in
[Rr]* ) rm -rf ${BUILD_DIR}; break ;;
[Cc]* ) break ;;
[Qq]* ) exit ;;
[Rr]* ) echo "Remove the build dir"; rm -rf ${BUILD_DIR}; break ;;
[Cc]* ) echo "Continue ..."; break ;;
[Qq]* ) echo "Exit the build"; exit ;;
* ) printf "Invalid option selected.\n" ;;
esac
done
Expand Down Expand Up @@ -470,11 +476,17 @@ else
module use ${SRW_DIR}/modulefiles
module load ${MODULE_FILE}
if [[ "${PLATFORM}" == "macos" ]]; then
export LDFLAGS+=" -L$MPI_ROOT/lib "
[[ -z "${HISTFILE+x}" ]] && export HISTFILE=${USER:-}/.bash_ethernal_history
[[ -z "${HISTTIMEFORMAT+x}" ]] && export HISTTIMEFORMAT="[%F %T] "
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 "
fi
fi
module list

if [[ "${PLATFORM}" == "macos" ]]; then
gsed -i'.backup' "s:LINKER_LANGUAGE Fortran:LINKER_LANGUAGE CXX:" ./sorc/ufs-weather-model/CMakeLists.txt
fi

mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR}

Expand Down
62 changes: 22 additions & 40 deletions modulefiles/build_macos_gnu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,40 @@ if mode() == "load" then
execute{cmd="ulimit -S -s unlimited", modeA={"load"}}
end

-- This path should point to your HPCstack installation directory
local HPCstack="/Users/username/hpc-stack/install"

-- Load HPC stack
prepend_path("MODULEPATH", pathJoin(HPCstack, "modulefiles/stack"))
load("hpc")
prepend_path("MODULEPATH", "/Users/username/spack-stack/spack-stack-1.8.0/envs/ufs-srw-env/install/modulefiles/Core")

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

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

-- MacOS with arm64 architecture: `uname -m` expands to arm64
-- MacOS with Intel architecture: `uname -m` expands to x86_64
local arch = 'eval $(uname -m)'
if (arch == "arm64") then
setenv("CC", "/opt/homebrew/bin/gcc")
setenv("FC", "/opt/homebrew/bin/gfortran")
setenv("CXX", "/opt/homebrew/bin/g++")
else
setenv("CC", "/usr/local/bin/gcc")
setenv("FC", "/usr/local/bin/gfortran")
setenv("CXX", "/usr/local/bin/g++")
end
cmake_ver=os.getenv("cmake_ver") or "3.27.9"
load(pathJoin("cmake", cmake_ver))

-- Set MPI compilers depending on the MPI libraries built:
local MPI_CC="mpicc"
local MPI_CXX="mpicxx"
local MPI_FC="mpif90"
load("srw_common")

setenv("CC", "mpicc")
setenv("CXX", "mpicxx")
setenv("F90", "mpif90")
setenv("FC", "mpifort")
setenv("CPP", "${F90} -E -x f95-cpp-input")
setenv("CMAKE_Platform", "macosx.gnu")
setenv("VERBOSE","1")
setenv("BUILD_VERBOSE","1")

-- Set compilers and platform names for CMake:
setenv("CMAKE_C_COMPILER", MPI_CC)
setenv("CMAKE_CXX_COMPILER", MPI_CXX)
setenv("CMAKE_Fortran_COMPILER", MPI_FC)

setenv("CMAKE_Platform", "macos.gnu")
--setenv("CMAKE_Platform", "macos.intel")

setenv("CMAKE_C_COMPILER", "mpicc")
setenv("CMAKE_CXX_COMPILER", "mpicxx")
setenv("CMAKE_Fortran_COMPILER", "mpifort")
setenv("CMAKE_Fortran_COMPILER_ID", "GNU")
--setenv("CMAKE_Fortran_COMPILER_ID", "Intel")

-- Set compiler and linker flags if needed:
setenv("FFLAGS", " -DNO_QUAD_PRECISION -fallow-argument-mismatch ")
setenv("CFLAGS","-Wno-implicit-function-declaration ")

-- export the env. variable LDFLAGS after loading the current module
-- export LDFLAGS="-L$MPI_ROOT/lib"
if mode() == "load" then
LmodMsgRaw([===[
Please export env. variable LDFLAGS after the module is successfully loaded:
> export LDFLAGS+=" -L$MPI_ROOT/lib "
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 "
]===])
end


10 changes: 5 additions & 5 deletions modulefiles/srw_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ load("libpng/1.6.37")

load("netcdf-c/4.9.2")
load("netcdf-fortran/4.6.1")
load("parallelio/2.5.10")
load("parallelio/2.6.2")
load("esmf/8.6.0")
load("fms/2024.01")
load("fms/2024.02")

load("bacio/2.4.1")
load("crtm/2.4.0.1")
load("g2/3.5.1")
load("g2tmpl/1.13.0")
load("ip/4.3.0")
load("ip/5.0.0")
load("sp/2.5.0")
load("w3emc/2.10.0")

load("gftl-shared/1.6.1")
load("gftl-shared/1.9.0")
load("mapl/2.40.3-esmf-8.6.0")

load("nemsio/2.5.4")
Expand All @@ -25,4 +25,4 @@ load("sigio/2.3.2")
load("w3nco/2.4.1")
load("wrf-io/1.2.0")

load_any("wgrib2/2.0.8","wgrib2/3.1.1")
load("wgrib2/3.1.1")
6 changes: 5 additions & 1 deletion scripts/exregional_make_sfc_climo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ export OMP_STACKSIZE=${OMP_STACKSIZE_MAKE_SFC_CLIMO}
#
#-----------------------------------------------------------------------
#
ulimit -s unlimited
if [[ "$MACHINE" == "MACOS" ]] ; then
ulimit -s -S unlimited
else
ulimit -s unlimited
fi
#
#-----------------------------------------------------------------------
#
Expand Down
49 changes: 49 additions & 0 deletions ush/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
metadata:
description:
Sample community config
user:
RUN_ENVIR: community
MACHINE: macos
ACCOUNT: an_account
workflow:
USE_CRON_TO_RELAUNCH: false
EXPT_SUBDIR: test_macos
CCPP_PHYS_SUITE: FV3_GFS_v16
PREDEF_GRID_NAME: RRFS_CONUS_25km
DATE_FIRST_CYCL: '2019061518'
DATE_LAST_CYCL: '2019061518'
FCST_LEN_HRS: 12
PREEXISTING_DIR_METHOD: rename
VERBOSE: true
COMPILER: intel
task_get_extrn_ics:
EXTRN_MDL_NAME_ICS: FV3GFS
FV3GFS_FILE_FMT_ICS: grib2
USE_USER_STAGED_EXTRN_FILES: true
EXTRN_MDL_SOURCE_BASEDIR_ICS: "/Users/username/UFS_SRW_data/input_model_data/FV3GFS/grib2/2019061518"
task_get_extrn_lbcs:
EXTRN_MDL_NAME_LBCS: FV3GFS
LBC_SPEC_INTVL_HRS: 6
FV3GFS_FILE_FMT_LBCS: grib2
USE_USER_STAGED_EXTRN_FILES: true
EXTRN_MDL_SOURCE_BASEDIR_LBCS: "/Users/username/UFS_SRW_data/input_model_data/FV3GFS/grib2/2019061518"
task_run_fcst:
QUILTING: true
LAYOUT_X: 3
LAYOUT_Y: 2
WRTCMP_write_tasks_per_group: 2
task_plot_allvars:
COMOUT_REF: ""
global:
DO_ENSEMBLE: false
NUM_ENS_MEMBERS: 2
rocoto:
tasks:
taskgroups: '{{ ["parm/wflow/prep.yaml", "parm/wflow/coldstart.yaml", "parm/wflow/post.yaml", "parm/wflow/plot.yaml"]|include }}'
metatask_run_ensemble:
task_run_fcst_mem#mem#:
walltime: 02:00:00
task_plot_allvars:
PLOT_FCST_START: 0
PLOT_FCST_INC: 6
PLOT_FCST_END: 6
10 changes: 6 additions & 4 deletions ush/machine/macos.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
platform:
WORKFLOW_MANAGER: rocoto
WORKFLOW_MANAGER: none
NCORES_PER_NODE: 8
TASKTHROTTLE: 1
SCHED: slurm
SCHED: none
TEST_CCPA_OBS_DIR: /Users/username/DATA/UFS/obs_data/ccpa/proc
TEST_MRMS_OBS_DIR: /Users/username/DATA/UFS/obs_data/mrms/proc
TEST_NDAS_OBS_DIR: /Users/username/DATA/UFS/obs_data/ndas/proc
Expand All @@ -13,7 +13,7 @@ platform:
RUN_CMD_PRDGEN: mpirun
RUN_CMD_SERIAL: time
RUN_CMD_UTILS: mpirun
PRE_TASK_CMDS: '{ ulimit -a; ulimit -s unlimited; }'
PRE_TASK_CMDS: '{ ulimit -a; ulimit -s -S unlimited; }'
TEST_EXTRN_MDL_SOURCE_BASEDIR: /Users/username/DATA/UFS/input_model_data
TEST_PREGEN_BASEDIR: /Users/username/DATA/UFS/FV3LAM_pregen
TEST_ALT_EXTRN_MDL_SYSBASEDIR_ICS: /Users/username/DATA/UFS/dummy_FV3GFS_sys_dir
Expand All @@ -27,4 +27,6 @@ platform:
EXTRN_MDL_DATA_STORES: aws nomads
data:
ics_lbcs:
FV3GFS: /Users/username/DATA/UFS/FV3GFS
FV3GFS:
nemsio: /Users/username/DATA/UFS/input_model_data/FV3GFS/nemsio
grib2: /Users/username/DATA/UFS/input_model_data/FV3GFS/grib2
Loading