source: anuga_core/source/anuga_parallel/run_parallel_job.py @ 7459

Last change on this file since 7459 was 5923, checked in by ole, 16 years ago

Added helper script suitable for executing parallel jobs on the ANU SF facility using PBS

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/usr/bin/env python
2
3"""Run job in parallel using PBS batch system with
4   specified number of processors
5
6   Syntax
7     run_parallel_job.py 4 <prog>
8"""
9
10queue = 'normal'
11walltime = '00:10:00'
12vmem = '1Mb'
13
14import sys, string, time, os
15arg = sys.argv
16command = arg[0]
17ext = '.py'
18
19if len(arg)<3:
20    print __doc__
21    print 'Usage:'
22    print command + ' p <filename>' + ext
23    sys.exit()
24
25numproc = int(arg[1])   
26progname = arg[2]
27
28
29#Create batchfile
30
31s = """
32#!/bin/csh
33
34# This file is automatically generated - don't edit
35#
36
37#PBS -wd 
38#PBS -q %s
39#PBS -l ncpus=%d
40#PBS -l walltime=%s,vmem=%s
41#PBS -l software=python
42
43prun %s""" %(queue, numproc, walltime, vmem, progname)
44
45
46scriptname = progname + '.run'
47fid = open(scriptname, 'w')
48fid.write(s)
49fid.close()
50
51#Cleanup
52os.system('/bin/rm *.o* *.e*')
53
54# Run
55os.system('qsub %s' %scriptname)
56os.system('/bin/rm %s' %scriptname)
57
58#Create check scripts
59fid = open('q', 'w')
60fid.write("""#!/bin/csh
61#This file is generated automatically.
62#Any modifications will be lost.
63#Edit runjob.py instead.
64echo '--------------------------------------------'
65nqstat %s\n""" %queue)
66fid.close()
67
68#fid = open('o', 'w')
69#fid.write("""#!/bin/csh
70##This file is generated automatically.
71##Any modifications will be lost.
72##Edit runjob.py instead.
73#cat %s.e* %s.o*\n""" %((progname,)*2))
74#fid.close()
75
76
77fid = open('o', 'w')
78fid.write("""#!/bin/csh
79#This file is generated automatically.
80#Any modifications will be lost.
81#Edit runjob.py instead.
82cat *.e* *.o*\n""")
83
84fid.close()
85
86os.system('chmod +x o q')
87
88
89
90
91
92
93
94
95
Note: See TracBrowser for help on using the repository browser.