forked from NASA-LIS/NASA-Land-Coupler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.sh
executable file
·143 lines (131 loc) · 3.88 KB
/
configure.sh
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
#!/bin/bash
#-----------------------BEGIN NOTICE -- DO NOT EDIT-----------------------------
# NASA Goddard Space Flight Center
# NASA Land Coupler (NLC)
# Version 0.5
#
# Copyright (c) 2022 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Licensed under Apache License 2.0.
#-------------------------END NOTICE -- DO NOT EDIT-----------------------------
# usage instructions
usage () {
printf "Usage: $0 [OPTIONS]...\n"
printf "\n"
printf "OPTIONS\n"
printf " --system=SYSTEM\n"
printf " name of machine (e.g. 'discover', 'cheyenne'\n"
printf " --compiler=COMPILER\n"
printf " compiler to use; valid options are 'intel.X.Y.Z', \n"
printf " 'gnu.X.Y.Z'; default is system dependent.\n"
printf " --auto\n"
printf " run non-interactive configuration\n"
printf " --verbose, -v\n"
printf " build with verbose output\n"
printf "\n"
}
# print settings
settings () {
printf "Settings:\n"
printf "\n"
printf " NLC_DIR=${NLC_DIR}\n"
printf " SYSTEM=${SYSTEM}\n"
printf " COMPILER=${MYCOMPILER}\n"
printf " INTERACTIVE=${INTERACTIVE}\n"
printf " VERBOSE=${VERBOSE}\n"
printf "\n"
}
# find system name
find_system () {
local sysname=`hostname`
sysname="${sysname//[[:digit:]]/}"
echo "$sysname"
}
# default settings
NLC_DIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P)
SYSTEM=""
MYCOMPILER=""
INTERACTIVE=true
VERBOSE=false
RC=0
# process arguments
while :; do
case $1 in
--help|-h) usage; exit 0 ;;
--system=?*) SYSTEM=${1#*=} ;;
--system) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--system=) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--compiler=?*) MYCOMPILER=${1#*=} ;;
--compiler) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--compiler=) printf "ERROR: $1 requires an argument.\n"; usage; exit 1 ;;
--auto) INTERACTIVE=false ;;
--auto=?*) printf "ERROR: $1 argument ignored.\n"; usage; exit 1 ;;
--auto=) printf "ERROR: $1 argument ignored.\n"; usage; exit 1 ;;
--verbose|-v) VERBOSE=true ;;
--verbose=?*) printf "ERROR: $1 argument ignored.\n"; usage; exit 1 ;;
--verbose=) printf "ERROR: $1 argument ignored.\n"; usage; exit 1 ;;
-?*) printf "ERROR: Unknown option $1\n"; usage; exit 1 ;;
*) break
esac
shift
done
set -u
# automatically determine system
if [ -z "${SYSTEM}" ] ; then
SYSTEM=$(find_system)
fi
# automatically determine compiler
if [ -z "${MYCOMPILER}" ] ; then
if [ "${SYSTEM}" = "discover" ]; then
MYCOMPILER="intel.19.1.3"
elif [ "${SYSTEM}" = "cheyenne" ]; then
MYCOMPILER="intel.19.1.1"
else
printf "ERROR: no default compiler for ${SYSTEM}\n"
printf "\n"
exit 1
fi
fi
# print settings
if [ "${VERBOSE}" = true ] ; then
settings
fi
# load environment for this system/compiler combination
ENVFILE="${NLC_DIR}/env/${SYSTEM}.${MYCOMPILER}"
if [ ! -f "${ENVFILE}" ]; then
printf "ERROR: environment file does not exist for ${SYSTEM}.${MYCOMPILER}\n"
printf "Please select one of the following configurations\n"
for f in "${NLC_DIR}/env"/*
do
printf " $(basename $f)\n"
done
printf "\n"
exit 1
fi
source ${ENVFILE}
printf "*************************************************\n"
printf "*** LIS BUILD CONFIGURATION ***\n"
printf "*************************************************\n"
if [ ! -f "$NLC_DIR/src/LISF/lis/configure" ]; then
printf "ERROR: LIS configure file is missing\n"
printf " \tgit submodule init\n"
printf " \tgit submodule update\n"
exit 1
else
cd $NLC_DIR/src/LISF/lis
fi
if [ "${INTERACTIVE}" = true ]; then
./configure; RC=$?
else
echo "" | ./configure; RC=$?
fi
if [ ! -f "make/configure.lis" ]; then
RC=1
fi
printf "\n"
if [ $RC -ne 0 ]; then
printf "ERROR: configuration failed.\n"
exit 1
fi
exit 0