Skip to content

Commit

Permalink
Build SHiELD with the full FMSCoupler and SHiEMOM (SHIELD+MOM6) (#40)
Browse files Browse the repository at this point in the history
* Build shield with the full coupler and shiemom

* checkout team code by default

* update mk_path and config names

* remove nvhpc for mom6 and sis2 and add a error message

* use local mkmf_template and clean up commented code

* cleanup

* celanup readme

* celanup readme

* Checkout code renovated

* checkout null components from official repo and improve mkmf readability

* link files moved from atmos_driver to SHiELD_physics/atmos_shared
  • Loading branch information
JosephMouallem authored Aug 1, 2024
1 parent 41662e1 commit 257c3bb
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 20 deletions.
114 changes: 114 additions & 0 deletions Build/BUILDmom6
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/bash
#***********************************************************************
#* GNU Lesser General Public License
#*
#* This file is part of the SHiELD Build System.
#*
#* The SHiELD Build System free software: you can redistribute it
#* and/or modify it under the terms of the
#* GNU Lesser General Public License as published by the
#* Free Software Foundation, either version 3 of the License, or
#* (at your option) any later version.
#*
#* The SHiELD Build System distributed in the hope that it will be
#* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
#* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#* See the GNU General Public License for more details.
#*
#* You should have received a copy of the GNU Lesser General Public
#* License along with theSHiELD Build System
#* If not, see <http://www.gnu.org/licenses/>.
#***********************************************************************
#
# DISCLAIMER: This script is provided as-is and as such is unsupported.
#
set -x
#
# set default values
# configure your build parameters
COMPILER="intel"
BIT="64bit"
#
# parse arguments
for arg in "$@"
do
case $arg in
intel|gnu)
COMPILER="${arg#*=}"
shift # Remove "compiler" from processing
;;
32bit|64bit)
BIT="${arg#*=}"
shift # Remove *bit from processing
;;
*)
if [ ${arg#} != '--help' ] && [ ${arg#} != '-h' ] ; then
echo "option "${arg#}" not found"
fi
echo -e ' '
echo -e "valid options are:"
echo -e "\t[intel(D) | gnu ] \t\t\t compiler"
echo -e "\t[32bit(D) | 64bit] \t\t\t FV3 precision option"
echo -e "\n"
exit
;;
esac
done

#
# set up some default variables if not called from COMPILE
# BUILD_ROOT is set if this script is called from the COMPILE script
if [ -z ${BUILD_ROOT} ] ; then
export BUILD_ROOT=${PWD%/*}
export SHiELD_SRC=${PWD%/*/*}/SHiELD_SRC/
export PATH="${BUILD_ROOT}/mkmf/bin:${BUILD_ROOT}/Build/mk_scripts:${PATH}"
export NCEP_DIR=${BUILD_ROOT}/Build
if [ ! -z ${EXTERNAL_LIBS} ] ; then
export NCEP_DIR=${EXTERNAL_LIBS}
fi
# load the proper environment for your machine
. ${BUILD_ROOT}/site/environment.${COMPILER}.sh
fi



mkdir -p ${BUILD_ROOT}/Build/mom6
list_paths -l -o ${BUILD_ROOT}/Build/mom6/pathnames_mom6 \
${SHiELD_SRC}/mom6/src/MOM6/config_src/memory/dynamic_nonsymmetric \
${SHiELD_SRC}/mom6/src/MOM6/config_src/drivers/FMS_cap \
${SHiELD_SRC}/mom6/src/MOM6/src/*/ \
${SHiELD_SRC}/mom6/src/MOM6/src/*/*/ \
${SHiELD_SRC}/mom6/src/MOM6/config_src/external/ODA_hooks \
${SHiELD_SRC}/mom6/src/MOM6/config_src/external/database_comms \
${SHiELD_SRC}/mom6/src/MOM6/config_src/external/drifters \
${SHiELD_SRC}/mom6/src/MOM6/config_src/external/stochastic_physics \
${SHiELD_SRC}/mom6/src/MOM6/config_src/infra/FMS2 \
${SHiELD_SRC}/ocean_BGC/generic_tracers \
${SHiELD_SRC}/ocean_BGC/mocsy/src \
${SHiELD_SRC}/mom6/src/MOM6/pkg/GSW-Fortran/*/ \
${SHiELD_SRC}/mom6/src/MOM6/config_src/infra/FMS2
cd ${BUILD_ROOT}/Build

pushd mom6

mkmf -m Makefile -a ${SHiELD_SRC} -p libmom6.a -t "${BUILD_ROOT}/${TEMPLATE}" \
-c "-DINTERNAL_FILE_NML -g -DMAX_FIELDS_=100 -DNOT_SET_AFFINITY -D_USE_MOM6_DIAG -D_USE_GENERIC_TRACER -DUSE_PRECISION=2 -I${NCEP_DIR}/libFMS/${COMPILER}/${BIT}" \
-I${SHiELD_SRC}/FMS/axis_utils/include -I${SHiELD_SRC}/FMS/diag_manager/include -I${SHiELD_SRC}/FMS/fms/include -I${SHiELD_SRC}/FMS/fms2_io/include \
-I${SHiELD_SRC}/FMS/horiz_interp/include -I${SHiELD_SRC}/FMS/include -I${SHiELD_SRC}/FMS/mpp/include -I${SHiELD_SRC}/FMS/sat_vapor_pres/include \
-I${SHiELD_SRC}/FMS/string_utils/include -I${SHiELD_SRC}/FMS/test_fms/fms/include -I${SHiELD_SRC}/mom6/src/MOM6/pkg/CVMix-src/include \
-I${SHiELD_SRC}/mom6/src/MOM6/src/framework ${BUILD_ROOT}/Build/mom6/pathnames_mom6

make -j8 REPRO=Y OPENMP=Y AVX=Y NETCDF=3 Makefile libmom6.a >& Build_mom6.out

################
#will get noise with openmp in debugmode
################

# test and report on libFMS build success
if [ $? -ne 0 ] ; then
echo ">>> ${BUILD_ROOT}/Build/mom6 build failed"
exit 1
fi
echo " libmom6 build successful"

popd
103 changes: 103 additions & 0 deletions Build/BUILDsis2
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash
#***********************************************************************
#* GNU Lesser General Public License
#*
#* This file is part of the SHiELD Build System.
#*
#* The SHiELD Build System free software: you can redistribute it
#* and/or modify it under the terms of the
#* GNU Lesser General Public License as published by the
#* Free Software Foundation, either version 3 of the License, or
#* (at your option) any later version.
#*
#* The SHiELD Build System distributed in the hope that it will be
#* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
#* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#* See the GNU General Public License for more details.
#*
#* You should have received a copy of the GNU Lesser General Public
#* License along with theSHiELD Build System
#* If not, see <http://www.gnu.org/licenses/>.
#***********************************************************************
#
# DISCLAIMER: This script is provided as-is and as such is unsupported.
#
set -x
#
# set default values
# configure your build parameters
COMPILER="intel"
BIT="64bit"
#
# parse arguments
for arg in "$@"
do
case $arg in
intel|gnu)
COMPILER="${arg#*=}"
shift # Remove "compiler" from processing
;;
32bit|64bit)
BIT="${arg#*=}"
shift # Remove *bit from processing
;;
*)
if [ ${arg#} != '--help' ] && [ ${arg#} != '-h' ] ; then
echo "option "${arg#}" not found"
fi
echo -e ' '
echo -e "valid options are:"
echo -e "\t[intel(D) | gnu] \t\t\t compiler"
echo -e "\t[32bit(D) | 64bit] \t\t\t FV3 precision option"
echo -e "\n"
exit
;;
esac
done

# set up some default variables if not called from COMPILE
# BUILD_ROOT is set if this script is called from the COMPILE script
if [ -z ${BUILD_ROOT} ] ; then
export BUILD_ROOT=${PWD%/*}
export SHiELD_SRC=${PWD%/*/*}/SHiELD_SRC/
export PATH="${BUILD_ROOT}/mkmf/bin:${BUILD_ROOT}/Build/mk_scripts:${PATH}"
export NCEP_DIR=${BUILD_ROOT}/Build
if [ ! -z ${EXTERNAL_LIBS} ] ; then
export NCEP_DIR=${EXTERNAL_LIBS}
fi
# load the proper environment for your machine
. ${BUILD_ROOT}/site/environment.${COMPILER}.sh
fi


mkdir -p ${BUILD_ROOT}/Build/sis2
list_paths -l -o ${BUILD_ROOT}/Build/sis2/pathnames_sis2 \
${SHiELD_SRC}/mom6/src/SIS2/config_src/dynamic_symmetric \
${SHiELD_SRC}/mom6/src/SIS2/config_src/external/Icepack_interfaces \
${SHiELD_SRC}/mom6/src/SIS2/src \
${SHiELD_SRC}/mom6/src/icebergs/src \
${SHiELD_SRC}/ice_param

cd ${BUILD_ROOT}/Build

pushd sis2

mkmf -m Makefile -a ${SHiELD_SRC} -p libsis2.a -t "${BUILD_ROOT}/${TEMPLATE}" \
-c "-DINTERNAL_FILE_NML -g -DUSE_FMS2_IO -I${NCEP_DIR}/mom6 -I${NCEP_DIR}/libFMS/${COMPILER}/${BIT}" -I${SHiELD_SRC}/FMS/axis_utils/include \
-I${SHiELD_SRC}/FMS/diag_manager/include -I${SHiELD_SRC}/FMS/fms/include -I${SHiELD_SRC}/FMS/fms2_io/include -I${SHiELD_SRC}/FMS/horiz_interp/include \
-I${SHiELD_SRC}/FMS/include -I${SHiELD_SRC}/FMS/mpp/include -I${SHiELD_SRC}/FMS/sat_vapor_pres/include -I${SHiELD_SRC}/FMS/string_utils/include \
-I${SHiELD_SRC}/FMS/test_fms/fms/include -I${SHiELD_SRC}/mom6/src/MOM6/pkg/CVMix-src/include \
-I${SHiELD_SRC}/mom6/src/MOM6/src/framework ${BUILD_ROOT}/Build/sis2/pathnames_sis2


make -j8 REPRO=Y OPENMP=Y AVX=Y NETCDF=3 Makefile libsis2.a >& Build_sis2.out

#
# test and report on libsis2 build success
if [ $? -ne 0 ] ; then
echo ">>> ${BUILD_ROOT}/Build/sis2 build failed"
exit 1
fi
echo " libsis2 build successful"

popd
34 changes: 32 additions & 2 deletions Build/COMPILE
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ spin()
for arg in "$@"
do
case $arg in
shield|solo)
shield|solo|shieldfull|shiemom)
config="${arg#*=}"
if [ $config = 'solo' ] ; then
config_name="SOLO"
fi
if [ $config = 'shieldfull' ] ; then
config_name="SHiELDFULL"
fi
if [ $config = 'shiemom' ] ; then
config_name="SHiEMOM"
fi
shift # Remove "config" from processing
;;
nh|hydro|sw)
Expand Down Expand Up @@ -102,7 +108,7 @@ spin()
sleep 20
fi
;;
noclean|clean|cleanall)
noclean|clean|cleanmom|cleanall)
clean="${arg#*=}"
shift # Remove "clean" from processing
;;
Expand Down Expand Up @@ -140,6 +146,11 @@ if [ $hydro = "sw" ] && [ $config = "shield" ] ; then
exit 1
fi

if [ $compiler = "nvhpc" ] && [ $config = "shiemom" ] ; then
echo -e ">>> option '$compiler' with '$config' is not a valid configuration"
exit 1
fi

#
# set up some default variables for use within the helper scripts
export BUILD_ROOT=${PWD%/*}
Expand Down Expand Up @@ -193,10 +204,17 @@ fi
\rm -rf libFMS/${compiler}/*
\rm -rf exec/${config}_${hydro}.${comp}.${bit}.${compiler}/*
\rm -rf nceplibs/${compiler}/*
\rm -rf mom6/*
\rm -rf sis2/*
elif [ ${clean} = "clean" ] ; then
echo " cleaning build directory in 2 seconds"
sleep 2
\rm -rf exec/${config}_${hydro}.${comp}.${bit}.${compiler}/*
elif [ ${clean} = "cleanmom" ] ; then
echo " cleaning build directory in 2 seconds"
sleep 2
\rm -rf mom6/*
\rm -rf sis2/*
fi

# If EXTERNAL_LIBS is set, then the program will use the path defined by
Expand Down Expand Up @@ -232,6 +250,18 @@ fi
fi
fi

if [ $config = "shiemom" ] ; then
# from lauren
# I think mom6 needs to be built in 64bit for now?
# I can only get it to compiler with 64bit FMS
./BUILDmom6 ${compiler} ${bit}
echo "DONE WITH MOM6"

# for sis2
./BUILDsis2 ${compiler} ${bit}
echo "DONE WITH SIS2"
fi

#
# ensure the build and final executable locations are available
mkdir -p ./exec/${config}_${hydro}.${comp}.${bit}.${compiler}
Expand Down
21 changes: 14 additions & 7 deletions Build/mk_scripts/mk_make
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pic="nopic"
for arg in "$@"
do
case $arg in
shield|solo)
shield|solo|shieldfull|shiemom)
CONFIG="${arg#*=}"
shift # Remove CONFIG from processing
;;
Expand Down Expand Up @@ -90,22 +90,29 @@ module list

$FC --version

if [ ${CONFIG} = 'shield' ] ; then
if [ ${CONFIG} = 'shield' ] || [ ${CONFIG} = 'shieldfull' ] ; then
NCEPLIBS="./libfv3.a"
NCEPLIBS+=" ${NCEP_DIR}/libFMS/${COMPILER}/${bit}/libFMS.a"
NCEPLIBS+=" ./libgfs.a"
NCEPLIBS+=" -L${NCEP_DIR}/nceplibs/${COMPILER}/ -lbacio -lsp_d -lw3emc_d -lw3nco_d"
else
elif [ ${CONFIG} = 'solo' ] ; then
NCEPLIBS=${NCEP_DIR}/libFMS/${COMPILER}/${bit}/libFMS.a
elif [ ${CONFIG} = 'shiemom' ] ; then
NCEPLIBS="./libfv3.a"
NCEPLIBS+=" ${NCEP_DIR}/sis2/libsis2.a"
NCEPLIBS+=" ${NCEP_DIR}/mom6/libmom6.a"
NCEPLIBS+=" ${NCEP_DIR}/libFMS/${COMPILER}/${bit}/libFMS.a"
NCEPLIBS+=" ./libgfs.a"
NCEPLIBS+=" -L${NCEP_DIR}/nceplibs/${COMPILER}/ -lbacio -lsp_d -lw3emc_d -lw3nco_d"
fi

if [ ${CONFIG} = 'shield' ] ; then
if [ ${CONFIG} = 'shield' ] || [ ${CONFIG} = 'shieldfull' ] || [ ${CONFIG} = 'shiemom' ] ; then
(cd exec/${CONFIG}_${HYDRO}.${comp}.${bit}.${COMPILER} ; make -j 8 OPENMP=Y ${COMP} AVX=${AVX} PIC=${PIC} -f Makefile_gfs)
fi

(cd exec/${CONFIG}_${HYDRO}.${comp}.${bit}.${COMPILER} ; make -j 8 OPENMP=Y ${COMP} AVX=${AVX} ${BIT} PIC=${PIC} NCEPLIBS="${NCEPLIBS}" -f Makefile_fv3)
(cd exec/${CONFIG}_${HYDRO}.${comp}.${bit}.${COMPILER} ; make -j 8 OPENMP=Y NETCDF=3 ${COMP} AVX=${AVX} ${BIT} PIC=${PIC} NCEPLIBS="${NCEPLIBS}" -f Makefile_fv3)

if [ ${CONFIG} = 'shield' ] ; then
(cd exec/${CONFIG}_${HYDRO}.${comp}.${bit}.${COMPILER} ; make -j 8 OPENMP=Y NETCDF=3 ${COMP} AVX=${AVX} ${BIT} PIC=${PIC} NCEPLIBS="${NCEPLIBS}" -f Makefile_driver)
if [ ${CONFIG} = 'shield' ] || [ ${CONFIG} = 'shieldfull' ] || [ ${CONFIG} = 'shiemom' ] ; then
(cd exec/${CONFIG}_${HYDRO}.${comp}.${bit}.${COMPILER} ; make -j 8 OPENMP=Y NETCDF=3 ${COMP} AVX=${AVX} ${BIT} PIC=${PIC} NCEPLIBS="${NCEPLIBS}" -f Makefile_driver)
fi
exit 0
Loading

0 comments on commit 257c3bb

Please sign in to comment.