Skip to content
Snippets Groups Projects
Commit 3a288a61 authored by Oriol Tintó's avatar Oriol Tintó
Browse files

Fix issue with paths in compress.py.

parent bdd046f0
No related branches found
No related tags found
No related merge requests found
......@@ -14,20 +14,22 @@ def main():
# Move the outputs to the proper destination
# Get some variables provided by autosubmit.
WORKDIR = Path("%HPCROOTDIR%")
STARTDATE = "%SDATE%"
MEMBER = "%MEMBER%"
output_file_names = "%simulation.OUTPUT_FILES%"
WORKDIR = Path("/project/meteo-scratch/Oriol.Tinto/tmp/autosubmit/ls-craig/oriol.tinto/a007")
STARTDATE = "2022040100"
MEMBER = "mem0"
output_file_names = "init-test_DOM01_ML_*.nc init-test-ext_DOM01_ML_*.nc icon_grid_*restart_atm_*.nc"
# Define rundir
RUNDIR = WORKDIR / STARTDATE / MEMBER
# Get a list of file names:
output_file_names = [f for f in output_file_names.split(" ") if f.strip()]
output_file_names = [RUNDIR / f for f in output_file_names.split(" ") if f.strip()]
output_files = []
for file_pattern in output_file_names:
output_files.extend(glob.glob(file_pattern))
output_files.extend(glob.glob(file_pattern.as_posix()))
# Define rundir
RUNDIR = WORKDIR / STARTDATE / MEMBER
output_files = [Path(f) for f in output_files]
# Define output dir and create it in case it doesn't exist
OUTPUT_DIR = WORKDIR / "output" / STARTDATE / MEMBER
......@@ -36,17 +38,16 @@ def main():
os.makedirs(OUTPUT_DIR.as_posix())
# Copy the output files
for file_name in output_files:
source_file_path = RUNDIR / file_name
destination_file_path = OUTPUT_DIR / file_name
for source_file_path in output_files:
destination_file_path = OUTPUT_DIR / source_file_path.name
logging.info(f"Copying {file_name}")
logging.info(f"Copying {source_file_path.name!r}")
enstools.compression.api.compress(source_file_path, output=destination_file_path, compression="lossless")
# Remove source files
if destination_file_path.exists():
logging.info(
f"{file_name} copied to {destination_file_path.as_posix()!r}. Removing {source_file_path.as_posix()!r}")
f"{source_file_path.name!r} copied to {destination_file_path.as_posix()!r}. Removing {source_file_path.as_posix()!r}")
source_file_path.unlink()
......
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