-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·166 lines (145 loc) · 5.11 KB
/
build.sh
File metadata and controls
executable file
·166 lines (145 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
# build.sh
# 1 - determine host, load modules on supported hosts; proceed w/o otherwise
# 2 - configure; build; install
# 4 - optional, run unit tests
set -eu
echo "Start ... `date`"
dir_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $dir_root/ush/detect_machine.sh
# ==============================================================================
usage() {
set +x
echo
echo "Usage: $0 -p <prefix> | -t <target> -h"
echo
echo " -p installation prefix <prefix> DEFAULT: <none>"
echo " -t target to build for <target> DEFAULT: $MACHINE_ID"
echo " -c additional CMake options DEFAULT: <none>"
echo " -v build with verbose output DEFAULT: NO"
echo " -f force a clean build DEFAULT: NO"
echo " -d include JCSDA ctest data DEFAULT: NO"
echo " -a build everything in bundle DEFAULT: NO"
echo " -i clone and build ioda-converters DEFAULT: NO"
echo " -h display this message and quit"
echo
exit 1
}
# ==============================================================================
# Defaults:
INSTALL_PREFIX="${dir_root}/install"
CMAKE_INSTALL_LIBDIR="lib"
CMAKE_OPTS=""
BUILD_TARGET="${MACHINE_ID:-'localhost'}"
BUILD_VERBOSE="NO"
BUILD_TESTING="OFF"
CLONE_JCSDADATA="NO"
CLEAN_BUILD="NO"
COMPILER="${COMPILER:-intel}"
WORKFLOW_BUILD=${WORKFLOW_BUILD:-"OFF"}
BUILD_GSIBEC=${BUILD_GSIBEC:-"ON"}
BUILD_IODA_CONVERTERS=${BUILD_IODA_CONVERTERS:-"NO"}
BUILD_SOCA=${BUILD_SOCA:-"ON"}
while getopts "w:t:c:hvdfai" opt; do
case $opt in
w)
HOMEglobal=$OPTARG
;;
t)
BUILD_TARGET=$OPTARG
;;
c)
CMAKE_OPTS=$OPTARG
;;
v)
BUILD_VERBOSE=YES
;;
d)
CLONE_JCSDADATA=YES
;;
f)
CLEAN_BUILD=YES
;;
i)
BUILD_IODA_CONVERTERS=YES
;;
h|\?|:)
usage
;;
esac
done
case ${BUILD_TARGET} in
hera | orion | hercules | wcoss2 | noaacloud | gaeac6 | ursa | derecho | container )
echo "Building GDASApp on $BUILD_TARGET"
source $dir_root/ush/module-setup.sh
module use $dir_root/modulefiles
module load GDAS/$BUILD_TARGET.$COMPILER
CMAKE_OPTS+=" -DMPIEXEC_EXECUTABLE=$MPIEXEC_EXEC -DMPIEXEC_NUMPROC_FLAG=$MPIEXEC_NPROC -DBUILD_GSIBEC=$BUILD_GSIBEC -DBUILD_IODA_CONVERTERS=$BUILD_IODA_CONVERTERS -DBUILD_SOCA=$BUILD_SOCA"
module list
;;
$(hostname))
echo "Building GDASApp on $BUILD_TARGET"
;;
*)
echo "Building GDASApp on unknown target: $BUILD_TARGET"
;;
esac
CMAKE_OPTS+=" -DCLONE_JCSDADATA=$CLONE_JCSDADATA -DMACHINE=$BUILD_TARGET -DBUILD_TESTING=$BUILD_TESTING"
# TODO: Remove LD_LIBRARY_PATH line as soon as permanent solution is available
if [[ $BUILD_TARGET == 'wcoss2' ]]; then
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/cray/pe/mpich/8.1.29/ofi/intel/2022.1/lib"
export LMOD_MPI_NAME=cray-mpich
export LMOD_MPI_VERSION=8.1.29-xhbciau
fi
BUILD_DIR=${BUILD_DIR:-$dir_root/build}
if [[ $CLEAN_BUILD == 'YES' ]]; then
[[ -d ${BUILD_DIR} ]] && rm -rf ${BUILD_DIR}
fi
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
# Set WORKFLOW_TESTS as CMake option
CMAKE_OPTS+=" -DWORKFLOW_TESTS=${WORKFLOW_TESTS:-${WORKFLOW_BUILD}}"
if [[ $BUILD_SOCA == 'ON' ]]; then
if [[ $WORKFLOW_BUILD == 'ON' ]]; then
# Link MOM6 and Icepack in SOCA to submodules in the UFS repo
rm -rf $dir_root/sorc/soca/external/mom6/MOM6
rm -rf $dir_root/sorc/soca/external/icepack/Icepack
ln -sf $HOMEglobal/sorc/ufs_model.fd/MOM6-interface/MOM6/ $dir_root/sorc/soca/external/mom6/MOM6
ln -sf $HOMEglobal/sorc/ufs_model.fd/CICE-interface/CICE/icepack/ $dir_root/sorc/soca/external/icepack/Icepack
else
# Delete forked SOCA NOAA-EMC dev/emc repo and clone the original JCSDA develop repo
rm -rf "$dir_root/sorc/soca/"
git clone https://github.com/jcsda/soca "$dir_root/sorc/soca" --recurse-submodules
fi
fi
if [[ $BUILD_IODA_CONVERTERS == 'YES' ]]; then
# Clone and build ioda-converters
git clone https://github.com/jcsda-internal/ioda-converters "$dir_root/sorc/iodaconv"
fi
# Set INSTALL_PREFIX as CMake option
CMAKE_OPTS+=" -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}"
# Set CMAKE_INSTALL_LIBDIR as CMake option
CMAKE_OPTS+=" -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}"
# TODO: allow CRTM paths to come from the modules on machines other than derecho, and container
if [[ "${BUILD_TARGET}" != "derecho" && "${BUILD_TARGET}" != "container" ]]; then
# JCSDA changed test data things, need to make a dummy CRTM directory
if [ -d "$dir_root/bundle/fix/test-data-release/" ]; then rm -rf $dir_root/bundle/fix/test-data-release/; fi
if [ -d "$dir_root/bundle/test-data-release/" ]; then rm -rf $dir_root/bundle/test-data-release/; fi
mkdir -p $dir_root/bundle/fix/test-data-release/
mkdir -p $dir_root/bundle/test-data-release/
ln -sf $GDASAPP_TESTDATA/crtm $dir_root/bundle/fix/test-data-release/crtm
ln -sf $GDASAPP_TESTDATA/crtm $dir_root/bundle/test-data-release/crtm
fi
# Configure
echo "Configuring ... `date`"
set -x
cmake \
${CMAKE_OPTS:-} \
$dir_root/bundle
set +x
# Install
echo "Installing ... `date`"
set -x
make install -j ${BUILD_JOBS:-8} VERBOSE=${BUILD_VERBOSE:-}
set +x
echo "Finish ... `date`"
exit 0