-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpi.py
executable file
·70 lines (51 loc) · 1.99 KB
/
mpi.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
#!/usr/bin/python
import os
import sys
import socket
narg=len(sys.argv)
if narg != 3:
print "Number of arguments different from 2. \n Usage:\n $>mpi.py NP NNODE\nThis will execute the command 'mpirun -np NP excitingmpi' in machine solNNODE.physik.hu-berlin.de\nExit without executing"
sys.exit()
scwd = str(os.getcwd()).split("/")
# the current working directory has to be a valid run directory, whose name is
# a timestamp in miliseconds (13 digits number) and, to be more sure, this
# folder has to be inside the "runs" directory of the project.
if len(scwd[-1])!=13 and scwd[-2]!="runs":
print "You must be inside the run directory where the input.xml is located to run this script. Exiting without executing."
sys.exit()
np=sys.argv[1]
node_name="sol"+sys.argv[2]
hostname = socket.gethostname()
exciting_root="/home1/srigamonti/exciting"
pbs_str="""#!/bin/bash
#PBS -l nodes=NNODE:ppn=NP
#PBS -N NAME
scdir=/home1/srigamonti/excitingruns/$PBS_JOBID
mkdir -p $scdir
scp [email protected]:$PBS_O_WORKDIR/* $scdir
COPYLINE
cp -r /home1/srigamonti/exciting/species $scdir
cd $scdir
RUNLINE
scp -r * [email protected]:$PBS_O_WORKDIR
ssh [email protected] rm -f $PBS_O_WORKDIR/excitingser
ssh [email protected] rm -f $PBS_O_WORKDIR/excitingmpi
ssh [email protected] rm -rf $PBS_O_WORKDIR/species
cd ..
rm -r $scdir
"""
pbs_str=pbs_str.replace("NNODE",node_name)
pbs_str=pbs_str.replace("NP",np)
pbs_str=pbs_str.replace("NAME",scwd[-1])
if np>1:
pbs_str=pbs_str.replace("RUNLINE","mpirun -np %s excitingmpi > RUN.OUT"%(np))
pbs_str=pbs_str.replace("COPYLINE","cp /home1/srigamonti/exciting/bin/excitingmpi $scdir")
if np==1:
pbs_str=pbs_str.replace("RUNLINE","excitingser > RUN.OUT")
pbs_str=pbs_str.replace("COPYLINE","cp /home1/srigamonti/exciting/bin/excitingser $scdir")
# print pbs_str
f=open("RUN.sh","w")
f.write(pbs_str)
f.close()
os.system("chmod +x+u RUN.sh")
os.system("qsub RUN.sh")