-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_all_python.sh
executable file
·104 lines (87 loc) · 3.1 KB
/
do_all_python.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
#!/bin/bash
set -e
# load global variables
source ${PWD}/common/global_vars_py.sh
# parse cline arguments
source ${PWD}/common/cmd_line_options.sh
# check that all basic variables are set, otherwise leave
check_minimum_vars_set_python
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
PYWORKINGDIR=${WORKINGDIR}/python
[[ ! -d ${PYWORKINGDIR} ]] && mkdir ${PYWORKINGDIR}
## wipe everything if set to 1
#[[ $WIPEEXISTING = 1 ]] && rm -rf ${PYWORKINGDIR}/*
#---------------------------
# only build
#---------------------------
if [ $WHICHTASK = "build" ]; then
source ${TOPDIR}/python/build_scripts/build.sh
fi
#---------------------------
# rom: lspg or galerkin
#---------------------------
if [ $WHICHTASK = "lspg" ] || [ $WHICHTASK = "galerkin" ];
then
# check if the build was already done
if [ ! -d ${PYWORKINGDIR}/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
# look for the basis inside the sibiling cpp folder
if [ ! -d ${WORKINGDIR}/cpp/data_${BASISDIRNAME} ]; then
echo "there is not basis dir in the target folder, do that first"
exit 0
fi
# create folder inside workindir
destDir=${PYWORKINGDIR}/"data_"${WHICHTASK}
[[ ! -d ${destDir} ]] && mkdir ${destDir}
# alias the name of target executable
EXENAME=
[[ $WHICHTASK = "lspg" ]] && EXENAME=main_rom_lspg
[[ $WHICHTASK = "galerkin" ]] && EXENAME=main_rom_galerkin
# link the bindings library
if [ $WHICHTASK = "lspg" ]; then
[[ -f ${destDir}/pressio4pyLspg.so ]] && rm ${destDir}/pressio4pyLspg.so
ln -s ${PYWORKINGDIR}/build/pressio4pyLspg.so ${destDir}
fi
if [ $WHICHTASK = "galerkin" ]; then
[[ -f ${destDir}/pressio4pyGalerkin.so ]] && rm ${destDir}/pressio4pyGalerkin.so
ln -s ${PYWORKINGDIR}/build/pressio4pyGalerkin.so ${destDir}
fi
# copy all pything scripts there
cp ${TOPDIR}/python/run_scripts/run_rom_timing.py ${destDir}/
cp ${TOPDIR}/python/src/burgers1d.py ${destDir}/
if [ $WHICHTASK = "lspg" ]; then
cp ${TOPDIR}/python/src/main_rom_lspg.py ${destDir}/
cp ${TOPDIR}/common/constants_lspg.py ${destDir}/constants.py
fi
if [ $WHICHTASK = "galerkin" ]; then
cp ${TOPDIR}/python/src/main_rom_galerkin.py ${destDir}/
cp ${TOPDIR}/common/constants_galerkin.py ${destDir}/constants.py
fi
USEDENSE=0
[[ ${JACOBIANTYPE} == dense ]] && USEDENSE=1
# enter there and run
cd ${destDir}
python run_rom_timing.py --exe=${EXENAME} --basis-dir-name=${BASISDIRNAME} -dense-jac=${USEDENSE}
cd ${TOPDIR}
fi