-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakegmi.sh
More file actions
executable file
·95 lines (84 loc) · 3.27 KB
/
Copy pathmakegmi.sh
File metadata and controls
executable file
·95 lines (84 loc) · 3.27 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
#!/usr/bin/env bash
# makegmi.sh — Build GMI.mexa64 via MACOS_resources/GMI/Makefile
#
# Usage:
# source ./makegmi.sh [debug|release] [ifx|gfortran]
#
# Options (order-independent, defaults: release, gfortran):
# debug — use debug build module files
# release — use release build module files (default)
# gfortran — compile GMI mex with gfortran (default). Produces a
# mex that exits MATLAB cleanly.
# ifx — compile GMI mex with ifx. Mex SIGSEGVs at MATLAB
# process-exit teardown (cosmetic; results correct).
#
# Either compiler choice picks up libsmacos.a from the matching
# build_release[_gfortran] tree, so build macos+smacos with the
# same compiler first (makems.sh for ifx, makegfortran.sh for
# gfortran). MATLAB is auto-detected under /usr/local/MATLAB/.
#
# Output location:
# GMI.mexa64 : ~/dev/MACOS_resources/GMI/GMI.mexa64
#
# Note: PGPLOT support was removed on release-candidate; Giza is now
# the only PGPLOT-API provider.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# --- Parse arguments ---
BUILD_TYPE="Release"
FC="gfortran"
USE_NPSOL="OFF"
for arg in "$@"; do
case "$arg" in
debug) BUILD_TYPE="Debug" ;;
release) BUILD_TYPE="Release" ;;
ifx) FC="ifx" ;;
gfortran) FC="gfortran" ;;
npsol) USE_NPSOL="ON" ;;
*)
echo "makegmi.sh: unknown option '$arg'"
echo "Usage: source ./makegmi.sh [debug|release] [ifx|gfortran] [npsol]"
return 1 2>/dev/null || exit 1
;;
esac
done
BUILD_TAG="$(echo "${BUILD_TYPE}" | tr '[:upper:]' '[:lower:]')"
[ "${FC}" = "gfortran" ] && BUILD_TAG="${BUILD_TAG}_gfortran"
[ "${USE_NPSOL}" = "ON" ] && BUILD_TAG="${BUILD_TAG}_npsol"
BUILD_DIR="${SCRIPT_DIR}/build_${BUILD_TAG}"
echo "makegmi: BUILD_TYPE=${BUILD_TYPE} FC=${FC} USE_NPSOL=${USE_NPSOL}"
echo "makegmi: MACOS_BUILD_DIR=${BUILD_DIR}"
# --- Intel oneAPI environment (only needed when FC=ifx) ---
if [ "${FC}" = "ifx" ]; then
ONEAPI_SETVARS="/opt/intel/oneapi/setvars.sh"
if [ -f "${ONEAPI_SETVARS}" ]; then
source "${ONEAPI_SETVARS}" --force > /dev/null 2>&1
fi
fi
# --- Locate MACOS_resources/GMI ---
GMI_DIR="$(realpath "${SCRIPT_DIR}/../MACOS_resources/GMI" 2>/dev/null || \
(cd "${SCRIPT_DIR}/../MACOS_resources/GMI" && pwd))"
if [ ! -f "${GMI_DIR}/Makefile" ]; then
echo "makegmi: ERROR — GMI Makefile not found at ${GMI_DIR}"
echo " Clone MACOS_resources alongside macos/: git clone git@github.com:nasa-jpl/MACOS_resources.git"
return 1 2>/dev/null || exit 1
fi
# --- Check that the cmake build dir exists ---
if [ ! -d "${BUILD_DIR}/mod_smacos" ]; then
echo "makegmi: ERROR — module directory not found: ${BUILD_DIR}/mod_smacos"
if [ "${FC}" = "gfortran" ]; then
echo " Build macos+smacos first: source ./makegfortran.sh ${BUILD_TYPE,,}"
else
echo " Build macos+smacos first: source ./makems.sh ${BUILD_TYPE,,}"
fi
return 1 2>/dev/null || exit 1
fi
# --- Build ---
echo "makegmi: building GMI via ${GMI_DIR}/Makefile ..."
make -C "${GMI_DIR}" \
FC="${FC}" \
macossrc_dir="${SCRIPT_DIR}/macos_f90" \
MACOS_BUILD_DIR="${BUILD_DIR}" \
|| { echo "makegmi: GMI build FAILED"; return 1 2>/dev/null || exit 1; }
echo ""
echo "makegmi: BUILD SUCCEEDED"
echo " GMI : ${GMI_DIR}/GMI.mexa64"