Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ old
exec
bin
libFMS
nceplibs
*.out
.lib*
78 changes: 78 additions & 0 deletions Build/BUILDlibfms
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/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 if not called from COMPILE
# NCEP_DIR is set if this script is called from the COMPILE script
# EXTERNAL_LIBS is set if using external location for storage of libFMS
if [ -z ${NCEP_DIR} ] ; 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

#
# build FMS library
echo " building ${NCEP_DIR}/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 ">>> ${NCEPDIR}/libFMS/${compiler} build failed"
exit 1
fi
echo " libFMS build successful"
101 changes: 101 additions & 0 deletions Build/BUILDnceplibs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/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 if not called from COMPILE
# NCEP_DIR is set if this script is called from the COMPILE script
# EXTERNAL_LIBS is set if using external location for storage of nceplibs
if [ -z ${NCEP_DIR} ] ; then
BUILD_ROOT=${PWD%/*}
NCEP_DIR=${BUILD_ROOT}/Build
if [ ! -z ${EXTERNAL_LIBS} ] ; then
NCEP_DIR=${EXTERNAL_LIBS}
fi
# load the proper environment for your machine
. ${BUILD_ROOT}/site/environment.${compiler}.sh
fi

nceplibs_dir=${NCEP_DIR}/nceplibs/${compiler}
\rm -rf $nceplibs_dir


git clone https://github.com/NOAA-EMC/NCEPLIBS-bacio
pushd NCEPLIBS-bacio
cmake -DCMAKE_C_STANDARD=99 -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_C_STANDARD=99 -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_C_STANDARD=99 -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_C_STANDARD=99 -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
61 changes: 40 additions & 21 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 @@ -129,6 +129,7 @@ fi
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

#
# load the proper environment for your machine
Expand All @@ -151,65 +152,83 @@ sleep 5
#
# conditionally clean the build directory
if [ ${clean} = "cleanall" ] ; then
echo " cleaning FMS library and build directory in 2 seconds"
echo " cleaning FMS library, nceplibs 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}/*
\rm -rf nceplibs/${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

# 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
echo " External Libraries are being used: ${EXTERNAL_LIBS}"
export NCEP_DIR=${EXTERNAL_LIBS}
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 [ -d ${NCEP_DIR}/libFMS/${compiler} ] && [ -e ${NCEP_DIR}/libFMS/${compiler}/32bit/libFMS.a ] && \
[ -e ${NCEP_DIR}/libFMS/${compiler}/64bit/libFMS.a ] ; then
echo " pre-built ${NCEP_DIR}/libFMS/${compiler} exists"
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
echo " ${NCEP_DIR}/libFMS/${compiler} does not exist"
./BUILDlibfms ${compiler}
Comment thread
laurenchilutti marked this conversation as resolved.
if [ $? -ne 0 ] ; then
echo ">>> libFMS $compiler build failed"
exit 2
echo ">>> ${NCEP_DIR}/Libfms/${compiler} build failed"
exit 2
fi
fi
# check to make sure nceplibs exists
if [ -d ${NCEP_DIR}/nceplibs/${compiler} ] && [ -e ${NCEP_DIR}/nceplibs/${compiler}/libbacio.a ] && \
[ -e ${NCEP_DIR}/nceplibs/${compiler}/libsp_d.a ] && [ -e ${NCEP_DIR}/nceplibs/${compiler}/libw3emc_d.a ] && \
[ -e ${NCEP_DIR}/nceplibs/${compiler}/libw3nco_d.a ] ; then
echo " pre-built ${NCEP_DIR}/nceplibs/${compiler} exists"
else
echo " ${NCEP_DIR}/nceplibs/${compiler} does not exist"
./BUILDnceplibs ${compiler}
if [ $? -ne 0 ] ; then
echo ">>> ${NCEP_DIR}/ncepdir/${compiler} build failed"
exit 3
fi
echo " libFMS build successful"
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
22 changes: 11 additions & 11 deletions Build/mk_scripts/MAKE_libFMS
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ cppDefs="-Duse_libMPI -Duse_netCDF -Duse_LARGEFILE -DHAVE_SCHED_GETAFFINITY -DIN

#
# clean up and create the FMS library directory
\rm -rf libFMS/${COMPILER}
\rm -rf ${NCEPDIR}/libFMS/${COMPILER}

#########################
#---CREATE 32-BIT libFMS
#########################
bit="32bit"
mkdir -p libFMS/${COMPILER}/${bit}
pushd libFMS/${COMPILER}/${bit}
(cd ${SHiELD_SRC} ; list_paths -o ${BUILD_ROOT}/Build/libFMS/${COMPILER}/${bit}/pathnames_fms FMS)
mkdir -p ${NCEP_DIR}/libFMS/${COMPILER}/${bit}
pushd ${NCEP_DIR}/libFMS/${COMPILER}/${bit}
(cd ${SHiELD_SRC} ; list_paths -o ${NCEP_DIR}/libFMS/${COMPILER}/${bit}/pathnames_fms FMS)
mkmf -m Makefile -a ${SHiELD_SRC} -t "${BUILD_ROOT}/${TEMPLATE}" -c "$cppDefs" \
-p libFMS.a ${BUILD_ROOT}/Build/libFMS/${COMPILER}/${bit}/pathnames_fms
echo "building libFMS/${COMPILER}/32bit/libFMS.a..."
-p libFMS.a ${NCEP_DIR}/libFMS/${COMPILER}/${bit}/pathnames_fms
echo "building ${NCEP_DIR}/libFMS/${COMPILER}/32bit/libFMS.a..."
make -j8 OPENMP=Y AVX=Y 32BIT=Y Makefile libFMS.a >& Build_libFMS.out

#
Expand All @@ -81,12 +81,12 @@ popd
#---CREATE 64-BIT libFMS
#########################
bit="64bit"
mkdir -p libFMS/${COMPILER}/${bit}
pushd libFMS/${COMPILER}/${bit}
(cd ${SHiELD_SRC} ; list_paths -o ${BUILD_ROOT}/Build/libFMS/${COMPILER}/${bit}/pathnames_fms FMS)
mkdir -p ${NCEP_DIR}/libFMS/${COMPILER}/${bit}
pushd ${NCEP_DIR}/libFMS/${COMPILER}/${bit}
(cd ${SHiELD_SRC} ; list_paths -o ${NCEP_DIR}/libFMS/${COMPILER}/${bit}/pathnames_fms FMS)
mkmf -m Makefile -a ${SHiELD_SRC} -t "${BUILD_ROOT}/${TEMPLATE}" -c "$cppDefs" \
-p libFMS.a ${BUILD_ROOT}/Build/libFMS/${COMPILER}/${bit}/pathnames_fms
echo "building libFMS/${COMPILER}/64bit/libFMS.a..."
-p libFMS.a ${NCEP_DIR}/libFMS/${COMPILER}/${bit}/pathnames_fms
echo "building ${NCEP_DIR}/libFMS/${COMPILER}/64bit/libFMS.a..."
make -j8 OPENMP=Y AVX=Y Makefile libFMS.a >& Build_libFMS.out

#
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
Loading