-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqsub
executable file
·93 lines (83 loc) · 2.15 KB
/
qsub
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
#!/usr/bin/bash
# Script for submitting jobs to the supercomputers I use.
# Use with:
# qsub [remote] [job_file] [--queue queue_name]
# Example: qsub jupiter job.inp --queue big # submit to jupiter with queue big
# qsub pipeline job.inp # submit to pipeline
usage() {
echo "Usage: $0 [remote] [job_file] [--queue queue_name]"
echo
echo "Arguments:"
echo " remote The remote server to submit the job: jupiter or pipeline."
echo " job_file The job input file (e.g., job.inp)."
echo
echo "Options:"
echo " --queue Specify the queue name for the jupiter server."
echo " -h, --help Show this help message."
exit 1
}
# Initialize variables
queue_name=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
;;
--queue)
queue_name="$2"
shift 2
;;
jupiter|pipeline)
remote="$1"
shift
;;
*)
job_file="$1"
shift
;;
esac
done
# Ensure required arguments are provided
if [[ -z "$remote" || -z "$job_file" ]]; then
echo "ERROR: Missing required arguments."
usage
fi
# Change your local working directory here
local="/home/vport/projects/"
filename="${job_file%%.*}"
current_dir=$(pwd)'/'
# Set remote directories and job commands
case "$remote" in
jupiter)
cluster="jupiter"
remote_dir="/scratch/vport/projects/"
if [[ -n "$queue_name" ]]; then
job_command="qorca -q $queue_name $job_file"
else
job_command="qorca $job_file"
fi
;;
pipeline)
cluster="pipeline"
remote_dir="/home/vport/projects/"
job_command="pueue add -- job $job_file"
;;
*)
echo "ERROR: Invalid remote '$remote'. Must be 'jupiter' or 'pipeline'."
usage
;;
esac
# Set up target directories
len_local=${#local}
len_current=${#current_dir}
remote_target="${remote_dir}${current_dir:$len_local:$len_current}"
current_remote="$remote_target"
# Push all files of the current folder to the remote and submit the job
csync "$cluster" push
# Submit the job on the remote server
ssh "$cluster" "
cd \"$current_remote\"
echo \"Submitting file $job_file at $cluster:$current_remote\"
$job_command
"