Skip to content

Commit 40e69b2

Browse files
committed
util: name_file_from_time_approx only called by rank 0
1 parent c1f48b9 commit 40e69b2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

fluidsim/util/util.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,16 @@ def _path_file_from_time_approx(thing, t_approx):
279279
if thing is not None and Path(thing).is_file():
280280
path_file = Path(thing)
281281
else:
282-
path_dir = pathdir_from_namedir(thing)
282+
path_dir = Path(pathdir_from_namedir(thing))
283283
# choose the file with the time closer to t_approx
284-
name_file = name_file_from_time_approx(path_dir, t_approx)
285-
path_file = Path(path_dir) / name_file
284+
if mpi.rank == 0:
285+
name_file = name_file_from_time_approx(path_dir, t_approx)
286+
else:
287+
name_file = None
288+
if mpi.nb_proc > 1:
289+
name_file = mpi.comm.bcast(name_file, root=0)
290+
291+
path_file = path_dir / name_file
286292
return path_file
287293

288294

0 commit comments

Comments
 (0)