forked from jmccreight/wrfHydroScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqCleanRun.sh
executable file
·79 lines (58 loc) · 1.72 KB
/
qCleanRun.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
#!/bin/bash
whsPath=`grep "wrfHydroScripts" ~/.wrfHydroScripts | cut -d '=' -f2 | tr -d ' '`
cleanRunHelp=`$whsPath/cleanRun.sh | tail -n+2`
help="
qCleanRun :: help
Purpose: submit cleanRun calls to qsub automatically calculating the number of nodes
requested in the header from the number of cores/mpitasks askedfor and divided
by 16. (Assumes the job is to be run from the current dir, where the binary is found.)
Other header items to qsub may need adjusted on an individual basis.
Arguments as for cleanRun...
$cleanRunHelp
"
if [ -z $1 ]
then
echo -e "\e[31mPlease pass arguments to cleanRun.\e[0m $help"
exit 1
fi
allArgs=$@
while getopts ":fpuncdor" opt; do
case $opt in
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift "$((OPTIND-1))"
source $whsPath/helpers.sh
IFS=$'\n'
nCores=`echo $1 | bc`
nNodes=`ceiling $nCores/16`
#echo $nNodes
#echo "$allArgs"
workingDir=`pwd`
theDate=`date '+%Y-%m-%d_%H-%M-%S'`
jobFile=job.qCleanRun.$theDate
## fix: can I make the job name more informative?
echo "#!/bin/bash
#PBS -l nodes=$nNodes:ppn=16,walltime=20:00:00
###PBS -k oe
#PBS -o stdout.$theDate.txt
#PBS -e stderr.$theDate.txt
#PBS -N wrfhydro
source ~/.bashrc
## 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\"
exit $modelReturn" > $jobFile
qJobId=`qsub $jobFile`
echo $qJobId
## fix: want to put this into a file in the run directory...
## but theres some complex parsing of the arguments to get that... it's in cleanRun.
#qJobId=`echo $qJobId | cut -d '.' -f 1`
#echo "$sJobId" > $runDir/qsubJobId.log
exit 0