-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_all_cpp.sh
executable file
·140 lines (114 loc) · 4.39 KB
/
do_all_cpp.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
#!/bin/bash
set -e
# load global variables
source ${PWD}/common/global_vars_cpp.sh
# parse cline arguments
source ${PWD}/common/cmd_line_options.sh
# check that all basic variables are set, otherwise leave
check_minimum_vars_set_cpp
echo ""
echo "--------------------------------------------"
echo " current setting is: "
echo ""
print_global_vars
# set env if not already set
if [[ ! -z ${SETENVscript} ]]; then
echo "loading environment from ${SETENVscript}"
source ${SETENVscript}
echo "PATH = $PATH"
else
echo "--with-env-script NOT set, so we assume env is set already"
fi
# create working dir if not existing
[[ ! -d ${WORKINGDIR} ]] && mkdir ${WORKINGDIR}
# create subworking dir if not existing
CPPWORKINGDIR=${WORKINGDIR}/cpp
[[ ! -d ${CPPWORKINGDIR} ]] && mkdir ${CPPWORKINGDIR}
# wipe everything if set to 1
[[ $WIPEEXISTING == yes ]] && wipe_existing_data_in_target_dir ${CPPWORKINGDIR}
#---------------------------
# build c++ exes
#---------------------------
if [ $WHICHTASK = "build" ]; then
source ${TOPDIR}/cpp/build_scripts/build.sh
fi
#---------------------------
# fom timing or basis or velocity sample
#---------------------------
if [[ $WHICHTASK == *"fom"* ]]; then
# check if the build is already done
if [ ! -d ${CPPWORKINGDIR}/build ]; then
echo "there is no build in the target folder, do that first"
exit 0
fi
# create folder inside workindir
destDir=${CPPWORKINGDIR}/"data_"${WHICHTASK}
[[ ! -d ${destDir} ]] && mkdir ${destDir}
# link the executable from build directory
EXENAME=
[[ $WHICHTASK == *"fom_bdf1"* ]] && EXENAME=burgers1d_fom_bdf1
[[ $WHICHTASK == *"fom_rk4"* ]] && EXENAME=burgers1d_fom_rk4
[[ $WHICHTASK == *"fom_velocity"* ]] && EXENAME=burgers1d_fom_velocity
[[ -f ${destDir}/${EXENAME} ]] && rm ${destDir}/${EXENAME}
ln -s ${CPPWORKINGDIR}/build/${EXENAME} ${destDir}
# copy the template input and python scripts
[[ $WHICHTASK == *"bdf1"* ]] && cp ${TOPDIR}/common/constants_lspg.py ${destDir}/constants.py
[[ $WHICHTASK == *"rk4"* ]] && cp ${TOPDIR}/common/constants_galerkin.py ${destDir}/constants.py
cp ${TOPDIR}/cpp/src/input.template ${destDir}
cp ${TOPDIR}/cpp/run_scripts/myutils.py ${destDir}/
if [[ $WHICHTASK == *"timing"* ]]; then
cp ${TOPDIR}/cpp/run_scripts/run_fom_timing.py ${destDir}/
elif [[ $WHICHTASK == *"basis"* ]]; then
cp ${TOPDIR}/cpp/run_scripts/run_fom_basis.py ${destDir}/
else
echo "error: unrecognized task for WHICHTASK=${WHICHTASK}. Terminating."
exit 11
fi
# set python driver depending on the task
PYTHONEXE=
[[ $WHICHTASK == *"timing"* ]] && PYTHONEXE=run_fom_timing.py
[[ $WHICHTASK == *"basis"* ]] && PYTHONEXE=run_fom_basis.py
# enter and run
cd ${destDir}
python ${PYTHONEXE} --exe ${EXENAME}
cd ${TOPDIR}
fi
#---------------------------
# rom: lspg or galerkin
#---------------------------
if [ $WHICHTASK = "lspg" ] || [ $WHICHTASK = "galerkin" ];
then
# check if the build was already done
if [ ! -d ${CPPWORKINGDIR}/build ]; then
echo "there is no build in the target folder, do that first"
exit 0
fi
# check if the basis are present
BASISDIRNAME=
[[ $WHICHTASK = "lspg" ]] && BASISDIRNAME=fom_bdf1_basis
[[ $WHICHTASK = "galerkin" ]] && BASISDIRNAME=fom_rk4_basis
if [ ! -d ${CPPWORKINGDIR}/"data_"${BASISDIRNAME} ]; then
echo "there is not basis dir in the target folder, do that first"
exit 0
fi
# create folder inside workindir
destDir=${CPPWORKINGDIR}/"data_"${WHICHTASK}
[[ ! -d ${destDir} ]] && mkdir ${destDir}
# link the executable
EXENAME=
[[ $WHICHTASK = "lspg" ]] && EXENAME=burgers1d_rom_lspg
[[ $WHICHTASK = "galerkin" ]] && EXENAME=burgers1d_rom_galerkin
[[ -f ${destDir}/${EXENAME} ]] && rm ${destDir}/${EXENAME}
ln -s ${CPPWORKINGDIR}/build/${EXENAME} ${destDir}
# copy the template input
cp ${TOPDIR}/cpp/src/input.template ${destDir}
# copy all python scripts there
cp ${TOPDIR}/cpp/run_scripts/myutils.py ${destDir}/
cp ${TOPDIR}/cpp/run_scripts/run_rom_timing.py ${destDir}/
[[ $WHICHTASK = "lspg" ]] && cp ${TOPDIR}/common/constants_lspg.py ${destDir}/constants.py
[[ $WHICHTASK = "galerkin" ]] && cp ${TOPDIR}/common/constants_galerkin.py ${destDir}/constants.py
# enter there and run
cd ${destDir}
python run_rom_timing.py --exe ${EXENAME} --basis-dir-name=${BASISDIRNAME}
cd ${TOPDIR}
fi