Skip to content

Commit

Permalink
First attempt: Combined Build Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
manishvenu committed Aug 30, 2024
1 parent 5ec78f6 commit 2812b56
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 110 deletions.
42 changes: 0 additions & 42 deletions standalone/build/build_examples-darwin.sh

This file was deleted.

67 changes: 0 additions & 67 deletions standalone/build/build_examples-ncar.sh

This file was deleted.

92 changes: 92 additions & 0 deletions standalone/build/build_examples.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash -e
### For NCAR machines, this script should be run as
### $ qcmd -- ./build_examples.sh

echo "Starting build at `date`"

# Save various paths to use as shortcuts
cd ../..
INTERFACE_ROOT=`pwd -P`
MKMF_ROOT=${INTERFACE_ROOT}/standalone/mkmf
TEMPLATE_DIR=${INTERFACE_ROOT}/standalone/templates
MOM_ROOT=${INTERFACE_ROOT}/MOM6
cd ../..
CESM_ROOT=`pwd -P`
SHR_ROOT=${CESM_ROOT}/share
FMS_ROOT=${CESM_ROOT}/libraries/FMS

# Default compiler
COMPILER="intel"
MACHINE="ncar"

# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--compiler)
COMPILER="$2"
shift ;;
--machine)
MACHINE="$2"
shift ;;
*)
echo "Unknown parameter passed: $1"
echo "Usage: $0 [--compiler <compiler>] [--machine <machine>]"
exit 1 ;;
esac
shift
done
echo "Using compiler: $COMPILER"
echo "Using machine: $MACHINE"

TEMPLATE=${TEMPLATE_DIR}/${MACHINE}-${COMPILER}.mk

# Throw error if template does not exist:
if [ ! -f $TEMPLATE ]; then
echo "ERROR: Template file $TEMPLATE does not exist."
echo "Templates are based on the machine and compiler arguments: machine-compiler.mk. Available templates are:"
ls ${TEMPLATE_DIR}/*.mk
echo "Exiting."
exit 1
fi

# Set -j option based on the MACHINE argument
case $MACHINE in
"darwin" | "ubuntu")
jNUM=2
;;
"ncar")
jNUM=36
;;
*)
echo "Invalid machine type for make -j option: $MACHINE"
exit 1
;;
esac

if [ -e $1 ]; then
BLD_ROOT=${COMPILER}
else
BLD_ROOT=$1
fi

# 1) Build FMS
cd ${INTERFACE_ROOT}/standalone/build
mkdir -p ${BLD_ROOT}/FMS
cd ${BLD_ROOT}/FMS
${MKMF_ROOT}/list_paths ${FMS_ROOT}/src
# We need shr_const_mod.F90 and shr_kind_mod.F90 from ${SHR_ROOT}/src
# to build FMS
echo "${SHR_ROOT}/src/shr_kind_mod.F90" >> path_names
echo "${SHR_ROOT}/src/shr_const_mod.F90" >> path_names
${MKMF_ROOT}/mkmf -t ${TEMPLATE} -p libfms.a -c "-Duse_libMPI -Duse_netCDF -DSPMD" path_names
make -j36 NETCDF=3 REPRO=1 libfms.a

# 2) Build MOM6
cd ${INTERFACE_ROOT}/standalone/build
mkdir -p ${BLD_ROOT}/MOM6
cd ${BLD_ROOT}/MOM6
${MKMF_ROOT}/list_paths -l ${MOM_ROOT}/{config_src/infra/FMS2,config_src/memory/dynamic_symmetric,config_src/drivers/solo_driver,../externals/MARBL/src,config_src/external,src/{*,*/*}}/
${MKMF_ROOT}/mkmf -t ${TEMPLATE} -o '-I../FMS' -p MOM6 -l '-L../FMS -lfms' -c '-Duse_libMPI -Duse_netCDF -DSPMD' path_names
make -j${jNUM}" NETCDF=3 REPRO=1 MOM6
echo "Finished build at `date`"
2 changes: 1 addition & 1 deletion standalone/build/submit_casper_build
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
#PBS -m abe

### Run the executable
./build_examples-ncar.sh intel-casper
./build_examples-ncar.sh --compiler intel --machine ncar

0 comments on commit 2812b56

Please sign in to comment.