forked from plesager/ece3-raw-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub_ece3_bckp.sh
executable file
·69 lines (54 loc) · 1.35 KB
/
sub_ece3_bckp.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
#!/usr/bin/env bash
usage()
{
echo "Usage:"
echo " ${0##*/} [-a account] [-c] EXP LEG"
echo
echo "Submit a job to backup output/restart from ONE leg of a run"
echo
echo "Options are:"
echo " -a account : specify a different special project for accounting (default ${ECE3_POSTPROC_ACCOUNT:-DEFAULT})"
echo " -c : check for success of previously submitted script with a '${PAGER:-less} <log>' command"
echo
}
set -e
# -- options
account=$ECE3_POSTPROC_ACCOUNT
while getopts "h?ca:" opt; do
case "$opt" in
h|\?)
usage
exit 0
;;
a) account=$OPTARG
;;
c) chck=1
esac
done
shift $((OPTIND-1))
# -- Arg
if [ "$#" -ne 2 ]; then
echo; echo " NEED TWO ARGUMENTS, NO MORE, NO LESS!"; echo
usage
exit 0
fi
# location of script to be submitted and its log
OUT=$SCRATCH/tmp_ece3_bckp
mkdir -p $OUT/log
# -- basic check
if (( $chck ))
then
echo "Checking $OUT/log/bckp_$1_$2.out"
${PAGER:-less} $OUT/log/bckp_$1_$2.out
exit
fi
# -- submit script
tgt_script=$OUT/bckp_$1_$2
sed "s/<EXPID>/$1/" < backup_ecearth3.sh.tmpl > $tgt_script
[[ -n $account ]] && \
sed -i "s/<ACCOUNT>/$account/" $tgt_script || \
sed -i "/<ACCOUNT>/ d" $tgt_script
sed -i "s|<LEG>|$2|" $tgt_script
cd $OUT
qsub $tgt_script
qstat -wu $USER