-
Notifications
You must be signed in to change notification settings - Fork 0
/
doarray.py
executable file
·67 lines (51 loc) · 1.53 KB
/
doarray.py
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
#!/usr/bin/python
import os
import sys
import random
"""
Set up a file, in_list, that has input for a collection of array jobs
then run them using the script uselist.sh. Input to this script is the
account to use to run the jobs.
Example Run:
el2:array> ./doarray.py hpcapps
Example Output:
COMMAND:
sbatch -A hpcapps --array=1-24 uselist.sh
Submitted batch job 5400715
###################
We the use squeue to see what is in the queue.
el2:array> squeue -u tkaiser2
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
5400715_[1-24] short array_jo tkaiser2 PD 0:00 1 (Priority)
el2:array>
The script uselist.sh pulls a single line from "in_list" for each instance
and uses if for input for the application it is going to run. The
application is a matrix inversion program. n1-n5 are used to set up
the matricies.
"""
size=24
# make list of inputs
l=open("in_list","w")
for x in range(0,size):
n1=int(random.random()*99)+2
n2=int(random.random()*99)+2
n3=int(random.random()*99)+2
n4=int(random.random()*99)+2
n5=400
l.write("%d %d %d %d %d\n" % (n1,n2,n3,n4,n5))
l.close()
print("created in_list")
if len(sys.argv) < 2 :
print("\nNormal USAGE:")
print(sys.argv[0]+" account")
sys.exit()
account=sys.argv[1]
command="sbatch -J slurm_test -A ACCOUNT --array=1-COUNT uselist.sh"
command=command.replace("ACCOUNT",account)
command=command.replace("COUNT",str(size))
print("COMMAND:")
print(command)
doit=os.popen(command,"r")
output=doit.readlines()
for o in output:
print(o)