Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
72 changes: 72 additions & 0 deletions Build/BUILDlibfms
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/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 default values
# configure your build parameters
compiler="intel"
#
# parse arguments
for arg in "$@"
do
case $arg in
intel|gnu)
compiler="${arg#*=}"
shift # Remove "compiler" 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 "\n"
exit
;;
esac
done

#
# set up some default variables for use within the helper scripts
export BUILD_ROOT=${PWD%/*}
export SHiELD_SRC=${PWD%/*/*}/SHiELD_SRC/
export PATH="${BUILD_ROOT}/mkmf/bin:${BUILD_ROOT}/Build/mk_scripts:${PATH}"

#
# load the proper environment for your machine
. ${BUILD_ROOT}/site/environment.${compiler}.sh

#
# build FMS library
echo " building libFMS/${compiler}"
MAKE_libFMS ${compiler} >> build_libFMS_${compiler}.out 2>&1 # build 32bit and 64bit versions of libFMS
#
# test and report on libFMS build success
if [ $? -ne 0 ] ; then
echo ">>> libFMS $compiler build failed"
exit 1
fi
echo " libFMS build successful"
98 changes: 98 additions & 0 deletions Build/BUILDnceplibs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/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 default compiler
compiler="intel"

# parse arguments
for arg in "$@"
do
case $arg in
intel|gnu)
compiler="${arg#*=}"
shift # Remove "compiler" 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 "\n"
exit
;;
esac
done

# set up some default variables
BUILD_ROOT=${PWD%/*}
if [ -z ${EXTERNAL_LIBS} ] ; then
nceplibs_dir=${BUILD_ROOT}/Build/nceplibs/${compiler}
else
nceplibs_dir=${EXTERNAL_LIBS}/nceplibs/${compiler}
fi

\rm -rf $nceplibs_dir

# load the proper environment for your machine
. ${BUILD_ROOT}/site/environment.${compiler}.sh
module load cmake/3.20.1

git clone https://github.com/NOAA-EMC/NCEPLIBS-bacio
pushd NCEPLIBS-bacio
cmake -DCMAKE_INSTALL_PREFIX=${BUILD_ROOT}/Build/NCEPLIBS-bacio/install .
make -j8
make install
popd

git clone https://github.com/NOAA-EMC/NCEPLIBS-sp
pushd NCEPLIBS-sp
cmake -DCMAKE_INSTALL_PREFIX=${BUILD_ROOT}/Build/NCEPLIBS-sp/install .
make -j8 sp_d
make install
popd

git clone https://github.com/NOAA-EMC/NCEPLIBS-w3emc
pushd NCEPLIBS-w3emc
cmake -DCMAKE_INSTALL_PREFIX=${BUILD_ROOT}/Build/NCEPLIBS-w3emc/install -DCMAKE_PREFIX_PATH=${BUILD_ROOT}/Build/NCEPLIBS-bacio/install/lib/cmake/bacio/ .
make -j8 w3emc_d
make install
popd

git clone https://github.com/NOAA-EMC/NCEPLIBS-w3nco
pushd NCEPLIBS-w3nco
cmake -DCMAKE_INSTALL_PREFIX=${BUILD_ROOT}/Build/NCEPLIBS-w3nco/install .
make -j8 w3nco_d
make install
popd

mkdir -p $nceplibs_dir
mv ${BUILD_ROOT}/Build/NCEPLIBS-bacio/install/lib/libbacio.a $nceplibs_dir/.
mv ${BUILD_ROOT}/Build/NCEPLIBS-sp/install/lib64/libsp_d.a $nceplibs_dir/.
mv ${BUILD_ROOT}/Build/NCEPLIBS-w3emc/install/lib64/libw3emc_d.a $nceplibs_dir/.
mv ${BUILD_ROOT}/Build/NCEPLIBS-w3nco/install/lib/libw3nco_d.a $nceplibs_dir/.

\rm -rf NCEPLIBS-bacio NCEPLIBS-sp NCEPLIBS-w3emc NCEPLIBS-w3nco
65 changes: 41 additions & 24 deletions Build/COMPILE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#* (at your option) any later version.
#*
#* The SHiELD Build System distributed in the hope that it will be
#* useful, but WITHOUT ANYWARRANTY; without even the implied warranty
#* 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.
#*
Expand Down Expand Up @@ -154,62 +154,79 @@ sleep 5
echo " cleaning FMS library and build directory in 2 seconds"
sleep 2
\rm -rf libFMS/${compiler}/*
\rm -rf exec/${config}_${compiler}/*
\rm -rf exec/${config}_${hydro}.${comp}.${bit}.${compiler}/*
elif [ ${clean} = "clean" ] ; then
echo " cleaning build directory in 2 seconds"
sleep 2
\rm -rf exec/${config}_${compiler}/*
\rm -rf exec/${config}_${hydro}.${comp}.${bit}.${compiler}/*
fi

#
# check to make sure libFMS exists
if [ -d libFMS/${compiler} ] && [ -e libFMS/${compiler}/32bit/libFMS.a ] && [ -e libFMS/${compiler}/64bit/libFMS.a ] ; then
echo " pre-built libFMS/${compiler} exists"
# If EXTERNAL_LIBS is set, then the program will use the path defined by
# EXTERNAL_LIBS as the location of nceplibs and libFMS
if [ -z ${EXTERNAL_LIBS} ] ; then
# internal libraries (fms and ncep) are being used
export NCEP_DIR=${BUILD_ROOT}/Build
#
# check to make sure libFMS exists
if [ -d libFMS/${compiler} ] && [ -e libFMS/${compiler}/32bit/libFMS.a ] && [ -e libFMS/${compiler}/64bit/libFMS.a ] ; then
echo " pre-built libFMS/${compiler} exists"
else
echo " libFMS/${compiler} does not exist"
./BUILDlibfms ${compiler}
if [ $? -ne 0 ] ; then
echo ">>> Libfms ${compiler} build failed"
exit 2
fi
fi
else
echo " libFMS/${compiler} does not exist - building libFMS/${compiler}"
MAKE_libFMS ${compiler} >> build_libFMS_${compiler}.out 2>&1 # build 32bit and 64bit versions of libFMS
#
# test and report on libFMS build success
if [ $? -ne 0 ] ; then
echo ">>> libFMS $compiler build failed"
exit 2
fi
echo " libFMS build successful"
echo " External Libraries are being used: ${EXTERNAL_LIBS}"
export NCEP_DIR=${EXTERNAL_LIBS}
fi

# Check that nceplibs and fms libs are built
if [ ! -d ${NCEP_DIR}/nceplibs/${compiler} ] && [ ! -d ${NCEP_DIR}/libFMS/${compiler} ] && \
[ ! -e ${NCEP_DIR}/libFMS/${compiler}/32bit/libFMS.a ] && [ ! -e ${NCEP_DIR}/libFMS/${compiler}/64bit/libFMS.a ] && \
[ ! -e ${NCEP_DIR}/nceplibs/${compiler}/libbacio.a ] && [ ! -e ${NCEP_DIR}/nceplibs/${compiler}/libsp_d.a ] && \
[ ! -e ${NCEP_DIR}/nceplibs/${compiler}/libbacio.a ] && [ ! -e ${NCEP_DIR}/nceplibs/${compiler}/libw3nco_d.a ] ; then
echo "The necessary nceplibs or libFMS libraries are not installed at ${NCEP_DIR}"
echo "Set EXTERNAL_LIBS if you intend to use an external location for nceplibs and libFMS"
echo "Unset EXTERNAL_LIBS if you intend to use libraries stored in SHiELD_build/Build"
exit 3
fi

#
# ensure the build and final executable locations are available
mkdir -p ./exec/${config}_${compiler}
mkdir -p ./exec/${config}_${hydro}.${comp}.${bit}.${compiler}
mkdir -p ./bin/

# build the model
echo -e " building ${config} ${hydro} ${comp} ${bit} ${compiler} \t `date`"
#
# create the file list for the build
mk_paths ${config} ${compiler} > build_${config}_${hydro}.${comp}.${bit}.${compiler}.out 2>&1
mk_paths ${config} ${hydro} ${comp} ${bit} ${compiler} > build_${config}_${hydro}.${comp}.${bit}.${compiler}.out 2>&1
if [ $? -ne 0 ] ; then
echo ">>> filelist cration failed"
exit 3
exit 4
fi
#
# create the library makefiles
mk_makefile ${config} ${hydro} ${bit} ${compiler} >> build_${config}_${hydro}.${comp}.${bit}.${compiler}.out 2>&1
mk_makefile ${config} ${hydro} ${comp} ${bit} ${compiler} >> build_${config}_${hydro}.${comp}.${bit}.${compiler}.out 2>&1
if [ $? -ne 0 ] ; then
echo ">>> makefile creation failed"
exit 4
exit 5
fi
#
# build the configuration
mk_make ${config} ${comp} ${bit} ${avx} ${compiler} >> build_${config}_${hydro}.${comp}.${bit}.${compiler}.out 2>&1
mk_make ${config} ${hydro} ${comp} ${bit} ${avx} ${compiler} >> build_${config}_${hydro}.${comp}.${bit}.${compiler}.out 2>&1
#
# move the executable to an accessible area
mv exec/${config}_${compiler}/test.x bin/${config_name}_${hydro}.${comp}.${bit}.${compiler}.x
mv exec/${config}_${hydro}.${comp}.${bit}.${compiler}/test.x bin/${config_name}_${hydro}.${comp}.${bit}.${compiler}.x

#
# test and report on build success
if [ $? -ne 0 ] ; then
echo ">>> ${config_name} build ${hydro} ${comp} ${bit} ${compiler} failed"
exit 5
exit 6
else
echo " ${config_name} build ${hydro} ${comp} ${bit} ${compiler} successful"
fi
Expand Down
15 changes: 11 additions & 4 deletions Build/mk_scripts/mk_make
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
#
## set default values
CONFIG="shield"
HYDRO="nh"
COMP=""
BIT="32BIT=Y"
AVX="Y"
COMPILER="intel"

bit="32bit"
comp="prod"

#
## parse arguments
Expand All @@ -42,7 +44,12 @@ do
CONFIG="${arg#*=}"
shift # Remove CONFIG from processing
;;
nh|hydro|sw)
HYDRO="${arg#*=}"
shift # remove "hydro" from processing
;;
prod|repro|debug)
comp="${arg#*=}"
if [ ${arg#} = 'repro' ] ; then
COMP="REPRO=Y"
elif [ ${arg#} = 'debug' ] ; then
Expand Down Expand Up @@ -74,15 +81,15 @@ module list

$FC --version

NCEPLIBS="../../libFMS/${COMPILER}/${bit}/libFMS.a"
NCEPLIBS="${NCEP_DIR}/libFMS/${COMPILER}/${bit}/libFMS.a"
if [ ${CONFIG} = 'shield' ] ; then
NCEPLIBS+=" ./libgfs.a"
NCEPLIBS+=" -L../../nceplibs/${COMPILER}/ -lbacio_4 -lsp_v2.0.2_d -lw3emc_d -lw3nco_d"
NCEPLIBS+=" -L${NCEP_DIR}/nceplibs/${COMPILER}/ -lbacio -lsp_d -lw3emc_d -lw3nco_d"
fi

if [ ${CONFIG} = 'shield' ] ; then
(cd exec/${CONFIG}_${COMPILER} ; make -j 8 OPENMP=Y ${COMP} AVX=${AVX} -f Makefile_gfs)
(cd exec/${CONFIG}_${HYDRO}.${comp}.${bit}.${COMPILER} ; make -j 8 OPENMP=Y ${COMP} AVX=${AVX} -f Makefile_gfs)
fi
(cd exec/${CONFIG}_${COMPILER} ; make -j 8 OPENMP=Y NETCDF=3 ${COMP} AVX=${AVX} ${BIT} NCEPLIBS="${NCEPLIBS}" -f Makefile_fv3)
(cd exec/${CONFIG}_${HYDRO}.${comp}.${bit}.${COMPILER} ; make -j 8 OPENMP=Y NETCDF=3 ${COMP} AVX=${AVX} ${BIT} NCEPLIBS="${NCEPLIBS}" -f Makefile_fv3)

exit 0
11 changes: 8 additions & 3 deletions Build/mk_scripts/mk_makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
## set default values
CONFIG="shield"
HYDRO="nh"
COMP="prod"
BIT="32bit"
COMPILER="intel"

Expand All @@ -43,6 +44,10 @@ do
HYDRO="${arg#*=}"
shift # Remove HYDRO from processing
;;
prod|repro|debug)
COMP="${arg#*=}"
shift # remove "comp" from processing
;;
32bit|64bit)
BIT="${arg#*=}"
shift # Remove *bit from processing
Expand Down Expand Up @@ -77,19 +82,19 @@ elif [ ${HYDRO} = 'sw' ] ; then
FV3_cppDefs+=" -DSW_DYNAMICS -DDYNAMICS_ZS"
fi

pushd exec/${CONFIG}_${COMPILER}/
pushd exec/${CONFIG}_${HYDRO}.${COMP}.${BIT}.${COMPILER}/

############################
#---CREATE MAKEFILES
############################
if [ ${CONFIG} = 'shield' ] ; then
mkmf -m Makefile_gfs -a ${SHiELD_SRC} -t "${BUILD_ROOT}/${TEMPLATE}" -o "-cpp" -c "${GFS_cppDefs}" \
-p libgfs.a ${BUILD_ROOT}/Build/exec/${CONFIG}_${COMPILER}/pathnames_gfs
-p libgfs.a ${BUILD_ROOT}/Build/exec/${CONFIG}_${HYDRO}.${COMP}.${BIT}.${COMPILER}/pathnames_gfs
fi

mkmf -m Makefile_fv3 -a ${SHiELD_SRC} -t "${BUILD_ROOT}/${TEMPLATE}" -c "${FV3_cppDefs}" \
-p test.x -o "-I${SHiELD_SRC}/FMS/include -I${BUILD_ROOT}/Build/libFMS/${COMPILER}/${BIT}" \
${BUILD_ROOT}/Build/exec/${CONFIG}_${COMPILER}/pathnames_fv3
${BUILD_ROOT}/Build/exec/${CONFIG}_${HYDRO}.${COMP}.${BIT}.${COMPILER}/pathnames_fv3

############################
#---ADD LIBS TO FINAL LINK
Expand Down
Loading