forked from idaholab/raven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raven_framework
executable file
·136 lines (125 loc) · 3.88 KB
/
raven_framework
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
#!/bin/bash
SCRIPT_NAME=`readlink $0`
if test -x "$SCRIPT_NAME";
then
RAVEN_DIRNAME=`dirname $SCRIPT_NAME`
else
RAVEN_DIRNAME=`dirname $0`
fi
RAVEN_DIR=`(cd $RAVEN_DIRNAME; pwd)`
# DEFAULTS
SKIP_CONDA=1 # 0 for skipping conda, 1 for not skipping
# set up run keywords
# "ARGS" stores command line arguments not treated in this file (passed through)
declare -a ARGS
# by default run in "opt" mode
MODE='opt'
# source read ravenrc script
RAVEN_RC_SCRIPT=$RAVEN_DIR/scripts/read_ravenrc.sh
RAVEN_RC_SCRIPT="${RAVEN_RC_SCRIPT//\\//}"
source $RAVEN_RC_SCRIPT
INSTALLATION_MANAGER=$(read_ravenrc "INSTALLATION_MANAGER")
if [[ "$INSTALLATION_MANAGER" == "PIP" ]];
then
SKIP_CONDA=0
else
# conda
SKIP_CONDA=1
fi
# loop through arguments and look for those that are handled before Python is called
while test $# -gt 0
do
case "$1" in
-D)
# run in development mode (assertions not stripped)
MODE='dev'
;;
--help)
# display "help" print
MODE='help'
;;
--skip-conda)
SKIP_CONDA=0
;;
--profile)
# run profiling using kernprof
# note that methods to profile should be decorated with @profile
# see https://github.com/pyutils/line_profiler
# see also https://stackoverflow.com/questions/23885147/how-do-i-use-line-profiler-from-robert-kern
MODE='profile'
;;
*)
# otherwise, pass through arguments to Driver.py
ARGS[${#ARGS[@]}]="$1"
esac
shift
done
if [[ ! $SKIP_CONDA == 0 ]]; then
source $RAVEN_DIR/scripts/establish_conda_env.sh --quiet
else
source $RAVEN_DIR/scripts/establish_conda_env.sh --quiet --installation-manager PIP
fi
PYTHON_COMMAND=${PYTHON_COMMAND:=python}
# if there's no file to run after parsing arguments, run "help" after warning of the problem.
if [ ${#ARGS[@]} -eq 0 ]; then
echo ''
echo 'ERROR: No input file specified! See options below.'
MODE='help'
fi
# run Driver.py based on the mode chosen
case $MODE in
'opt' )
echo 'Running RAVEN in "opt" mode.'
$PYTHON_COMMAND -O $RAVEN_DIR/raven_framework.py "${ARGS[@]}"
;;
'dev' )
echo 'Running RAVEN in "dev" mode.'
$PYTHON_COMMAND $RAVEN_DIR/raven_framework.py "${ARGS[@]}"
;;
'profile' )
echo 'Running RAVEN in "profiling" mode.'
kernprof -l -v $RAVEN_DIR/raven_framework.py "${ARGS[@]}"
;;
'help' )
echo ''
echo ' ------------------------------------------'
echo ' Default usage:'
echo ' raven_framework filename.xml'
echo ''
echo ' Description:'
echo ' This will run RAVEN in "opt" mode using "filename.xml" as the input. This should be'
echo ' sufficient for the majority of RAVEN calculations. For more options, see below.'
echo ' ------------------------------------------'
echo ''
echo ' Advanced usage:'
echo ' raven_framework filename [-D] [--skip-conda] [interfaceCheck] [interactive] [interactiveCheck]'
echo ''
echo ' Description:'
echo ' Runs RAVEN using the input file given by "filename".'
echo ''
echo ' Options:'
echo ' -D'
echo ' Run in development mode. Turns Python "assert" statements on.'
echo ''
echo ' --profile'
echo ' Development tool. Turns on use of @profile decorator for method profiling.'
echo ''
echo ' --skip-conda'
echo ' Skip CONDA activation. This assumes the correct python libraries are already in place.'
echo ''
echo ' --help'
echo ' Shows this description and exits.'
echo ''
echo ' interfaceCheck'
echo ' Do not attempt to run the model executable, but read from existing output files.'
echo ''
echo ' interactive'
echo ' Run RAVEN in GUI mode if possible.'
echo ''
echo ' interactiveCheck'
echo ' Run tests on interactive GUI.'
echo ''
;;
*)
echo 'Unrecognized MODE "'${MODE}'" in raven_framework! Exiting ...'
esac