forked from jmccreight/wrfHydroScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbCleanRun.sh
More file actions
executable file
·100 lines (73 loc) · 2.04 KB
/
bCleanRun.sh
File metadata and controls
executable file
·100 lines (73 loc) · 2.04 KB
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
#!/bin/bash
## fix: check for .wrfHydroScripts?
whsPath=`grep "wrfHydroScripts" ~/.wrfHydroScripts | cut -d '=' -f2 | tr -d ' '`
cleanRunHelp=`$whsPath/cleanRun.sh | tail -n+2`
source $whsPath/helpers.sh
help="
bCleanRun :: help
Purpose: submit cleanRun calls to bsub automatically
Arguments: those for cleanRun - see below.
Options:
-j jobName - used in forming the bsubHeader. (must come before args)
-e path/exitScript - a script to be invoked prior to successful exit.
Details:
Assumes the jobs run dir is the current dir, where the binary is found.
Header items to qsub may need adjusted on an individual basis in ~/.wrfHydroScripts
number of cores and job name are set via arguments to this script.
******
Arguments as for cleanRun...
$cleanRunHelp
"
if [ -z $1 ]
then
echo -e "\e[31mPlease pass arguments to cleanRun.\e[0m $help"
exit 1
fi
while getopts "::fpuncdorj:e:" opt; do
case $opt in
j) jobName="${OPTARG}" ;;
e) exitScript="${OPTARG}" ;;
esac
done
shift "$((OPTIND-1))" # Shift off the option
allArgs=$@
IFS=$'\n'
nCores=`echo "${@:1:1}" | bc`
nNodes=`ceiling $nCores/16`
#echo "$allArgs"
if [ -z $jobName ]; then jobName=myRun; fi
echo $nCores
echo $jobName
if [ ! -z $exitScript ]
then
exitScript="./${exitScript}"
echo Exit script: "$exitScript"
fi
## check valid options
while getopts "::fpuncdor" opt; do
case $opt in
\?) echo "Invalid option: -$OPTARG"
exit 1 ;;
esac
done
shift "$((OPTIND-1))" # Shift off the option
workingDir=`pwd`
theDate=`date '+%Y-%m-%d_%H-%M-%S'`
jobFile=$theDate.bCleanRun.job
bsubHeader=`egrep '^#BSUB' ~/.wrfHydroScripts`
bsubHeader=`echo "$(eval "echo \"$bsubHeader\"")"`
echo "#!/bin/bash
$bsubHeader
#source ~/.bashrc
source $whsPath/helpers.sh
## To communicate where the stderr/out and job scripts are and their ID
export cleanRunDateId=${theDate}
cd $workingDir
$whsPath/cleanRun.sh ${allArgs}
modelReturn=\$?
unset cleanRunDateId
echo \"model return: \$modelReturn\"
$exitScript
exit \$modelReturn" > $jobFile
bsub < $jobFile
exit 0