forked from HYCOM/HYCOM-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·121 lines (110 loc) · 3.19 KB
/
build.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
#!/bin/ksh -l
set -eu
# Formatting Variables
HR="----------------------------------------"
HR+="----------------------------------------"
# Script Help
help="NAME\n"
help+="\t$0 --- HYCOM build script\n\n"
help+="USAGE\n"
help+="\t$0 [ options ]\n\n"
help+="DESCRIPTION\n"
help+="\tThis script builds or cleans the HYCOM object files and "
help+="executable.\n\n"
help+="OPTIONS\n"
help+="\t-b,\tBuild object files and executable (default).\n"
help+="\t-a,\tBuild architecture.\n"
help+="\t-t,\tBuild type.\n"
help+="\t-e,\tBuild extras.\n"
help+="\t-n,\tBuild with NUOPC cap.\n"
help+="\t-i,\tNUOPC installation directory.\n"
help+="\t-c,\tClean object files and executable.\n"
help+="\t-v,\tIncrease output.\n"
help+="\t-h,\tHelp information.\n"
# Script Usage
usage="ba:t:e:ni:cvh"
# Default Options
verbosity=0
build=true clean=false
build_arch="intelsse-impi-sm-relo"
build_type="mpi"
build_extras=""
nuopc=false
nuopc_dir="NUOPC"
nuopc_install=false
nuopc_install_dir="."
# Process Command Line Options
while getopts "$usage" optchar ; do
case $optchar in
b ) ;;
a ) build_arch=$OPTARG ;;
t ) build_type=$OPTARG ;;
e ) build_extras=$OPTARG ;;
n ) nuopc=true ;;
i ) nuopc_install=true nuopc_install_dir=$OPTARG ;;
c ) clean=true build=false ;;
v ) verbosity=$((verbosity+1)) ;;
h ) print $help; exit 0;;
* ) print >&2 "See Help: $0 -h"; exit 1;;
esac
done
if $nuopc; then
if $nuopc_install; then
mkdir -p $nuopc_install_dir
fi
build_extras=${build_extras}" -DEOS_SIG2 -DEOS_17T -DESPC_COUPLE"
else
build_extras=${build_extras}" -DEOS_SIG2 -DEOS_17T"
fi
nuopc_dir=$(readlink -f $nuopc_dir)
nuopc_install_dir=$(readlink -f $nuopc_install_dir)
# Print Command Line Options
if [ $verbosity -ge 1 ]; then
print "$HR"
print "Compile Script Settings"
print "$HR"
print "\tVerbosity: $verbosity"
print "\tBuild: $build"
print "\tBuild Arch: $build_arch"
print "\tBuild Type: $build_type"
print "\tBuild Extras: $build_extras"
print "\tClean: $clean"
print "\tNUOPC: $nuopc"
print "\tNUOPC Dir: $nuopc_dir"
print "\tNUOPC Install: $nuopc_install"
print "\tNUOPC Install Dir: $nuopc_install_dir"
print "$HR"
fi
if $nuopc; then
if $build; then
(cd ${nuopc_dir} && make nuopc \
ARCH="${build_arch}" TYPE="${build_type}" \
CPP_EXTRAS="${build_extras}")
fi
if $clean; then
(cd ${nuopc_dir} && make nuopcdistclean \
ARCH="${build_arch}" TYPE="${build_type}" \
CPP_EXTRAS="${build_extras}")
fi
else
if $build; then
make -f Makefile hycom \
ARCH="${build_arch}" TYPE="${build_type}" \
CPP_EXTRAS="${build_extras}"
fi
if $clean; then
make -f Makefile clean \
ARCH="${build_arch}" TYPE="${build_type}" \
CUSE_FLAG="${build_extras}"
fi
fi
# Edit Executable for specified architectures
if [[ $build_arch == "Asp5" || $build_arch == "sp5" ]]; then
ldedit -bdatapsize=64K -bstackpsize=64K hycom
fi
if [[ $build_arch == "Asp6" || $build_arch == "sp6" ]]; then
ldedit -bdatapsize=64K -bstackpsize=64K hycom
fi
if [[ $build_arch == "Asp6-nofl" || $build_arch == "sp6-nofl" ]]; then
ldedit -bdatapsize=64K -bstackpsize=64K hycom
fi