forked from nmfs-ost/ss3-source-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMake_SS_330_new.sh
executable file
·147 lines (131 loc) · 4.3 KB
/
Make_SS_330_new.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
144
145
146
147
#!/bin/bash
# script modified by N. Schindler 05-17-2022
# output settings
function display_settings()
{
echo "-- $Type Settings --"
echo "ADMB_HOME = $ADMB_HOME"
echo "Source Dir = $SRC_DIR"
echo "Build Dir = $BUILD_DIR"
echo "Build exe = $BUILD_TYPE"
echo "Warnings = $WARNINGS"
}
# want help?
function usage()
{
echo ""
echo "Call this script as follows:"
echo " ./Make_SS_330_new.sh [(-s | --source) source_dir] [(-b | --build) build_dir]"
echo " [(-a | --admb) admb_dir] [[-o | --opt] | [-f | --safe] [-p] "
echo " [-w | --warn] [-d | --debug] [-h | --help]"
echo "Notes:"
echo " -p is an ADMB flag to build statically and will be passed. "
echo " -w re-compiles with common warnings enabled. "
echo " -d will display the settings used to build SS. "
echo ""
echo "The default is the 'safe' build to directory SS330."
echo ""
display_settings
}
# create safe source tpl
function cat_safe_files()
{
# concatenate all tpl files to a single file
cat SS_biofxn.tpl SS_miscfxn.tpl SS_selex.tpl SS_popdyn.tpl SS_recruit.tpl SS_benchfore.tpl SS_expval.tpl SS_objfunc.tpl SS_write.tpl SS_write_ssnew.tpl SS_write_report.tpl SS_ALK.tpl SS_timevaryparm.tpl SS_tagrecap.tpl > SS_functions.temp
cat SS_versioninfo_330safe.tpl SS_readstarter.tpl SS_readdata_330.tpl SS_readcontrol_330.tpl SS_param.tpl SS_prelim.tpl SS_global.tpl SS_proced.tpl SS_functions.temp > $BUILD_DIR/ss.tpl
}
# create opt source tpl
function cat_opt_files()
{
# concatenate all tpl files to a single file
cat SS_biofxn.tpl SS_miscfxn.tpl SS_selex.tpl SS_popdyn.tpl SS_recruit.tpl SS_benchfore.tpl SS_expval.tpl SS_objfunc.tpl SS_write.tpl SS_write_ssnew.tpl SS_write_report.tpl SS_ALK.tpl SS_timevaryparm.tpl SS_tagrecap.tpl > SS_functions.temp
cat SS_versioninfo_330opt.tpl SS_readstarter.tpl SS_readdata_330.tpl SS_readcontrol_330.tpl SS_param.tpl SS_prelim.tpl SS_global.tpl SS_proced.tpl SS_functions.temp > $BUILD_DIR/ss_opt.tpl
}
# default directories
SRC_DIR=.
BUILD_DIR=SS330
# other defaults (safe build is the default)
BUILD_TYPE=ss
WARNINGS=off
DEBUG=off
GREP=
Type=Current
STATICFLAG=
OPTFLAG=
if [ "$1" == "" ] ; then
Type=Default
display_settings
usage
exit 1
fi
while [ "$1" != "" ]; do
case $1 in
# debug
-d | --debug ) DEBUG=on
;;
# show standard warnings
-w | --warn ) WARNINGS=on
;;
# check for new source directory
-s | --source ) shift
SRC_DIR=$1
;;
# check for new build directory
-b | --build ) shift
BUILD_DIR=$1
;;
# check for ADMB directory and set
-a | --admb ) shift
ADMB_HOME=$1
export ADMB_HOME
PATH=$ADMB_HOME:$PATH
;;
# output help - usage
-h | --help ) Type=Default
usage
exit
;;
# build statically? (admb flag passed through - not documented)
-p ) STATICFLAG=-p
;;
# build safe version
-f | --safe ) BUILD_TYPE=ss
;;
# build fast version
-o | --opt ) BUILD_TYPE=ss_opt
OPTFLAG=-f
;;
esac
shift
done
# change to the source dir
cd $SRC_DIR
# delete the temp file if it exists
if [ -f SS_functions.temp ]; then
rm SS_functions.temp
fi
# create source files in build dir
mkdir -p $BUILD_DIR
case $BUILD_TYPE in
ss_opt ) grep "opt" SS_versioninfo_330opt.tpl
cat_opt_files
;;
ss ) grep "safe" SS_versioninfo_330safe.tpl
cat_safe_files
esac
# debug info
if [[ "$DEBUG" == "on" ]] ; then
display_settings
else
echo "-- Building $BUILD_TYPE in '$BUILD_DIR' --"
fi
# change to build dir and build
cd $BUILD_DIR
admb $OPTFLAG $STATICFLAG $BUILD_TYPE
chmod a+x $BUILD_TYPE
# output warnings
if [[ "$WARNINGS" == "on" ]] ; then
echo "... compiling a second time to get warnings ..."
g++ -c -std=c++0x -O3 -I. -I"$ADMB_HOME/include" -I"/$ADMB_HOME/include/contrib" -o$BUILD_TYPE.obj $BUILD_TYPE.cpp -Wall -Wextra
fi
exit