This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
q_spr
52 lines (52 loc) · 1.69 KB
/
q_spr
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
#!/bin/bash
#==========================================
# Copyright © 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#==========================================
# Script to submit job in Intel(R) DevCloud
# Version: 0.7
#==========================================
if [ -z "$1" ]; then
echo "Missing script argument, Usage: ./q run.sh"
elif [ ! -f "$1" ]; then
echo "File $1 does not exist"
else
echo "Job has been submitted to Intel(R) DevCloud and will execute soon."
echo ""
echo " If you do not see result in 60 seconds, please restart the Jupyter kernel:"
echo " Kernel -> 'Restart Kernel and Clear All Outputs...' and then try again"
echo ""
script=$1
# Remove old output files
rm *.sh.* > /dev/null 2>&1
# Submit job using qsub
qsub_id=`qsub -l nodes=1:spr:ppn=2 -d . $script`
job_id="$(cut -d'.' -f1 <<<"$qsub_id")"
# Print qstat output
qstat
# Wait for output file to be generated and display
echo ""
echo -ne "Waiting for Output "
until [ -f $script.o$job_id ]; do
sleep 1
echo -ne "█"
((timeout++))
# Timeout if no output file generated within 60 seconds
if [ $timeout == 300 ]; then
echo ""
echo ""
echo "TimeOut 300 seconds: Job is still queued for execution, check for output file later ($script.o$job_id)"
echo ""
break
fi
done
# Print output and error file content if exist
if [ -n "$(find -name '*.sh.o'$job_id)" ]; then
echo " Done⬇"
cat $script.o$job_id
cat $script.e$job_id
echo "Job Completed in $timeout seconds."
rm *.sh.*$job_id > /dev/null 2>&1
fi
fi