Skip to content
Snippets Groups Projects
Commit 3cc17153 authored by Pierre Augier's avatar Pierre Augier
Browse files

load_params_simul with MPI

parent 4b18bb52
No related branches found
No related tags found
No related merge requests found
......@@ -189,6 +189,10 @@
def load_params_simul(path=None):
"""Load the parameters and return a Parameters instance."""
if path is None:
path = os.getcwd()
if mpi.rank > 0:
params = None
params = mpi.comm.bcast(params, root=0)
else:
if path is None:
path = os.getcwd()
......@@ -194,12 +198,9 @@
path_xml = None
if os.path.isdir(path):
path_xml = os.path.join(path, "params_simul.xml")
elif path.endswith(".xml"):
if not os.path.exists(path):
raise ValueError("The file " + path + "does not exists.")
path_xml = path
if path_xml is not None and os.path.exists(path_xml):
return Parameters(path_file=path_xml)
path_xml = None
if os.path.isdir(path):
path_xml = os.path.join(path, "params_simul.xml")
elif path.endswith(".xml"):
if not os.path.exists(path):
raise ValueError("The file " + path + "does not exists.")
path_xml = path
......@@ -205,8 +206,11 @@
if os.path.isfile(path):
paths = [path]
else:
paths = glob(os.path.join(path, "state_*"))
if paths:
path = sorted(paths)[0]
if path_xml is not None and os.path.exists(path_xml):
params = Parameters(path_file=path_xml)
else:
if os.path.isfile(path):
paths = [path]
else:
paths = glob(os.path.join(path, "state_*"))
if paths:
path = sorted(paths)[0]
......@@ -212,6 +216,6 @@
if len(path) > 100:
str_path = "[...]" + path[-100:]
else:
str_path = path
if len(path) > 100:
str_path = "[...]" + path[-100:]
else:
str_path = path
......@@ -217,9 +221,14 @@
print("load params from file\n" + str_path)
with h5py.File(path) as h5file:
return Parameters(hdf5_object=h5file["/info_simul/params"])
else:
return ValueError
print("load params from file\n" + str_path)
with h5py.File(path) as h5file:
params = Parameters(hdf5_object=h5file["/info_simul/params"])
else:
raise ValueError
if mpi.nb_proc > 1:
params = mpi.comm.bcast(params, root=0)
return params
def load_info_solver(path_dir=None):
......
......@@ -64,6 +64,7 @@
"""Should be able to run a base experiment."""
with stdout_redirected():
self.sim.time_stepping.start()
load_params_simul(self.sim.output.path_run + "/params_simul.xml")
fld.show()
......@@ -72,5 +73,5 @@
with stdout_redirected():
modif_resolution_from_dir(
self.sim.output.path_run, coef_modif_resol=3/2, PLOT=False
self.sim.output.path_run, coef_modif_resol=3./2, PLOT=False
)
......@@ -76,5 +77,4 @@
)
load_params_simul(self.sim.output.path_run + "/params_simul.xml")
path_new = os.path.join(self.sim.output.path_run, "State_phys_12x12")
os.chdir(path_new)
load_params_simul()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment