-
Notifications
You must be signed in to change notification settings - Fork 1
/
RunMPI_couplings.py
executable file
·51 lines (40 loc) · 1.54 KB
/
RunMPI_couplings.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
#!/usr/bin/env python
from mpi4py import MPI
from subprocess import call
import sys
"""
This script will create 'nprocs' parallel instances of
CalcDisc-vs-Couplings.py and calculate the significance
for a different coupling index on each instance.
For a given mass and ensemble, there are 1024 indices, so
this code is meant to be run in batches. The number of the
batch is specified in arr_index (starting from arr_index=1).
The code will then automatically calculate the appropriate
coupling indices based on the batch number and the number of
processes in the current batch.
See CalcDisc-vs-Couplings.py for information on what the other
command line parameters should be.
To execute with 16 MPI processes, you would have something
like the following in your submission script:
mpirun -np 16 python RunMPI_couplings.py
"""
#Get inputs from command line
ensemble = sys.argv[1]
mass = sys.argv[2]
arr_index = int(sys.argv[3]) #Array index of the current batch
output_dir = sys.argv[4] #output directory for the results
comm = MPI.COMM_WORLD
#Get total number of MPI processes
nprocs = comm.Get_size()
#Get rank of current process
rank = comm.Get_rank()
#Coupling index
index = nprocs*(arr_index-1) + rank + 1
#Output file labelled by coupling index
outfile = output_dir + "Results_p" + str(index) + ".txt"
#Directory where the calc files are located
myDir = "/home/kavanagh/AntiparticleDM/calc/"
cmd = "cd "+myDir+" ; python CalcDisc-vs-Couplings.py "
cmd += ensemble + " " + mass + " " + str(index) + " " + outfile
sts = call(cmd,shell=True)
comm.Barrier()