-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_parareal_conv.py
61 lines (56 loc) · 2.22 KB
/
run_parareal_conv.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
import os, sys
sys.path.append('./scripts')
from build_namelist import build_namelist
from generate_q0 import generate_q0
from build_runscript import build_runscript
from generate_timemesh import generate_timemesh
from get_parameter import get_parameter
nu, Nx, Ny, Nz, dt_fine, dt_coarse, Niter, Tend, do_io, be_verbose = get_parameter()
#
do_io = True
#
generate_q0(Nx, Ny, Nz)
Nproc = 24
Niter_max = 5
# read the run command to use plus possible options
with open("system.defs", "r") as rfile:
system = rfile.readline()
system = system.rstrip()
runcmd = rfile.readline()
runcmd = runcmd.rstrip()
rfile.close()
# Run serial reference
timemesh = generate_timemesh(0.0, Tend, dt_fine, dt_coarse, 1)
Nfine = timemesh.get('Nfine')
Ncoarse = timemesh.get('Ncoarse')
param_file = "fine_serial.in"
build_namelist(nu, Nx, Ny, Nz, Nfine, Ncoarse, Niter, Tend, do_io, be_verbose, param_file)
if system=="mac":
os.system("time bin/run_timestepper.out "+param_file+" F")
else:
jobname="fine_serial"
build_runscript(1, jobname, "serial_f", system, param_file)
os.system("sbatch submit_serial_f_Np1.sh")
#
for Niter in range(1,Niter_max):
#types = [ 'mpi', 'openmp', 'openmp_pipe' ]
types = ['mpi']
timemesh = generate_timemesh(0.0, Tend, dt_fine, dt_coarse, Nproc)
Nfine = timemesh.get('Nfine')
Ncoarse = timemesh.get('Ncoarse')
for ii in range(0,len(types)):
type=types.pop(0)
param_file = "param_para_"+type+"_Niter"+str(Niter)+".in"
build_namelist(nu, Nx, Ny, Nz, Nfine, Ncoarse, Niter, Tend, do_io, be_verbose, param_file)
if system=="mac":
if type=="mpi":
os.system("time "+runcmd+" -n "+str(Nproc)+" bin/run_parareal_"+type+".out "+param_file)
elif type=="openmp":
os.system("time OMP_NUM_THREADS="+str(Nproc)+" "+runcmd+" -n 1 bin/run_parareal_"+type+".out "+param_file)
elif type=="openmp_pipe":
os.system("time OMP_NUM_THREADS="+str(Nproc)+" "+runcmd+" -n 1 bin/run_parareal_"+type+".out "+param_file)
else:
jobname="parareal_"+type+"_Np"+str(Nproc)
build_runscript(Nproc, jobname, type, system)
os.system("sbatch submit_"+type+"_Np"+str(Nproc)+".sh")
# os.system('mv timings*.dat data/')