Skip to content
Snippets Groups Projects
Commit e58c54a2 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Create files in the slice directory

Create `cropped.nc` and `unpacked.nc` in the slice directory, so that
several processes running `inst_eddies.py` for different slices can
run in parallel.
parent f05b3d43
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,9 @@ def loop_inst_eddies(files, bbox, d, my_slice):
# Short names (without blanks):
writer.writerow(["date", "elapsed_NCO", "elapsed_Fortran"])
cropped_fname = f"SHPC/Slice_{my_slice}/cropped.nc"
unpacked_fname = f"SHPC/Slice_{my_slice}/unpacked.nc"
for nc_file in files:
print("inst_eddies.loop_inst_eddies: Date:", d)
print("inst_eddies.loop_inst_eddies: Input file:", nc_file,
......@@ -63,7 +66,7 @@ def loop_inst_eddies(files, bbox, d, my_slice):
xmin, xmax, ymin, ymax = bbox
try:
nco_instance.ncks(nc_file, output = "cropped.nc",
nco_instance.ncks(nc_file, output = cropped_fname,
options
= [f"--dimension=longitude,{xmin},{xmax}",
f"--dimension=latitude,{ymin},{ymax}"])
......@@ -71,13 +74,13 @@ def loop_inst_eddies(files, bbox, d, my_slice):
print(err.stdout)
raise
nc_file = "cropped.nc"
nc_file = cropped_fname
nco_instance.ncpdq(nc_file, output = "unpacked.nc",
nco_instance.ncpdq(nc_file, output = unpacked_fname,
options = ["--unpack"])
elapsed_NCO = time.perf_counter() - my_pc
my_pc = time.perf_counter()
subprocess.run([inst_eddies_exe, "unpacked.nc", "unpacked.nc"],
subprocess.run([inst_eddies_exe, unpacked_fname, unpacked_fname],
check = True, input = f"&dates_nml date = {d}, "
f"slice = {my_slice}/\n", text = True)
elapsed_Fortran = time.perf_counter() - my_pc
......@@ -96,8 +99,8 @@ def loop_inst_eddies(files, bbox, d, my_slice):
d += 1
perf_report.close()
os.remove("unpacked.nc")
if bbox: os.remove("cropped.nc")
os.remove(unpacked_fname)
if bbox: os.remove(cropped_fname)
if my_slice == 0 and not os.access("SHPC/n_slices.txt", os.F_OK):
with open("SHPC/n_slices.txt", "w") as f: f.write("1\n")
......
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