-
Notifications
You must be signed in to change notification settings - Fork 0
/
gjobadd.bash
47 lines (41 loc) · 1.23 KB
/
gjobadd.bash
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
#/bin/bash
# Include parameters files
# --------------------------
source gjobdata.bash
# Usage
# -------
if [[ $# -eq 0 ]]; then
echo "Usage: gjobadd.bash input [ queue [ jobname [ comment [ path ]]]]"
exit
fi
# Argument parsing and default values
# -------------------------------------
mygjf=${1:?"Error: Missing Gaussian input file"}
queue=${2:-q02curie}
job=${3:-${mygjf%.*}}
comment=${4:-false}
mypath=${5:-${PWD}}
# Check input file existence
if [[ ! -e "$mypath/$mygjf" ]]; then
echo "ERROR: Cannot find input file in path"
exit
fi
# Get last used index
# ---------------------
# Check if "data file" exists and gets the last index (1 if new file)
if [[ ! -e ${GJOB_FILE} ]]; then
echo ${GJOB_HEADER} > ${GJOB_FILE}
myid=1
else
# 10# means that base 10 must be used (numbers starting with 0 are considered in octal base)
myid=$((10#$(grep -v -E '^#' ${GJOB_FILE} | tail -n 1 | awk '{print $1}' ) + 1))
fi
# Insert comments before the actual job definition
if [[ "${comment}" != "false" ]]; then
printf '# %s\n' "$comment" >> ${GJOB_FILE}
fi
# Job definition
# ----------------
printf "${GJOB_DATAFMT}" $myid "WAIT" 0 0 0 $queue "NONE" $job $mygjf $mypath\
>> ${GJOB_FILE}
echo "Job number: ${myid}"