forked from opensbli/environment_and_run_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerate.sh
executable file
·56 lines (47 loc) · 1.35 KB
/
Generate.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
#!/bin/bash
##@brief Generate OPS C/C++ code for a OpenSBLI app
##@author Jianping Meng
##@contributors
##@details
function usage {
echo "This script will translate the OpenSBLI Python cod e to C/C++!"
echo "Usage: ./$(basename $0) PythonSource"
echo "./$(basename $0) -h -> showing usage"
echo "./$(basename $0) -e -> Specifying the environment directory."
}
ScriptPath="${BASH_SOURCE:-$0}"
AbsolutScriptPath="$(realpath "${ScriptPath}")"
EnvDir="$(dirname "${AbsolutScriptPath}")"
optstring="e:h"
while getopts ${optstring} options; do
case ${options} in
h)
usage
exit 0
;;
e)
EnvDir=${OPTARG}
;;
:)
echo "$0: Must supply an argument to -$OPTARG." >&2
exit 1
;;
?)
echo "Invalid option: -${OPTARG}."
exit 2
;;
esac
done
Src=${@:$OPTIND:1}
if [ -z $Src ]
then
echo "This script will translate the OpenSBLI Python code to C/C++!"
echo "Usage: ./$(basename $0) [options] PythonSource"
echo "./$(basename $0) -h -> showing usage"
echo "./$(basename $0) -e -> Specifying the environment directory."
fi
echo "Source name is ${Src} and evn is ${EnvDir}"
# activate Python
source ${EnvDir}/Python/bin/activate "${EnvDir}/Python"
export PYTHONPATH=$PYTHONPATH:$EnvDir/OpenSBLI
python $Src