Make sure dumpfolder created only on rank 0

This commit is contained in:
Richard Stiskalek 2024-02-27 13:28:41 +00:00
parent 66d9f46919
commit fb93f85543

View file

@ -19,7 +19,7 @@ from argparse import ArgumentParser
from datetime import datetime from datetime import datetime
from gc import collect from gc import collect
from os import makedirs, remove, rmdir from os import makedirs, remove, rmdir
from os.path import exists, isdir, join from os.path import exists, join
import csiborgtools import csiborgtools
import numpy as np import numpy as np
@ -229,9 +229,6 @@ if __name__ == "__main__":
parser.add_argument("--grid", type=int, help="Grid resolution.") parser.add_argument("--grid", type=int, help="Grid resolution.")
args = parser.parse_args() args = parser.parse_args()
out_folder = "/mnt/extraspace/rstiskalek/csiborg_postprocessing/field_los"
dump_folder = join(out_folder,
f"temp_{str(datetime.now())}".replace(" ", "_"))
rmax = 200 rmax = 200
dr = 0.1 dr = 0.1
smooth_scales = None smooth_scales = None
@ -240,10 +237,16 @@ if __name__ == "__main__":
paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring) paths = csiborgtools.read.Paths(**csiborgtools.paths_glamdring)
nsims = get_nsims(args, paths) nsims = get_nsims(args, paths)
out_folder = "/mnt/extraspace/rstiskalek/csiborg_postprocessing/field_los"
# Create the dumping folder. # Create the dumping folder.
if comm.Get_rank() == 0 and not isdir(dump_folder): if comm.Get_rank() == 0:
dump_folder = join(out_folder,
f"temp_{str(datetime.now())}".replace(" ", "_"))
print(f"Creating folder `{dump_folder}`.") print(f"Creating folder `{dump_folder}`.")
makedirs(dump_folder) makedirs(dump_folder)
else:
dump_folder = None
dump_folder = comm.bcast(dump_folder, root=0)
# Get the line of sight RA/dec coordinates. # Get the line of sight RA/dec coordinates.
pos = get_los(args.catalogue, comm) pos = get_los(args.catalogue, comm)