From 9ca1af881b40859416020657442a25925ef37944 Mon Sep 17 00:00:00 2001 From: Jan Streffing Date: Mon, 29 Jun 2026 10:59:56 +0200 Subject: [PATCH] Stage source INIUA into output dir before CO2 interpolation Step 7 (3D CO2 interpolation) read and wrote the INIUA file at the output path, but nothing ever copied the source INIUA from the input directory into the output dir -- unlike the INIT file, which is staged in process_land_sea_mask() (lsm.py). As a result the CO2 read failed with FileNotFoundError, the error was caught and merely printed, and the run still exited 0 with no CO2 written into the INIUA. Add config.get_icmgg_iniua_input_file() and copy the source INIUA into the output path immediately before Step 7 in both entry points (run_ocp_tool.py and ocp_tool/__main__.py). CO2 is then added in place. --- ocp_tool/__main__.py | 5 +++++ ocp_tool/config.py | 4 ++++ run_ocp_tool.py | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/ocp_tool/__main__.py b/ocp_tool/__main__.py index 8305131..7190612 100644 --- a/ocp_tool/__main__.py +++ b/ocp_tool/__main__.py @@ -3,6 +3,7 @@ import sys import time from pathlib import Path +from shutil import copy2 from ocp_tool.config import load_config from ocp_tool.gaussian_grids import generate_gaussian_grid, read_fesom_grid_polygon @@ -58,6 +59,10 @@ def run_ocp_tool(config): print("\nStep 7: Interpolating 3D CO2 concentrations...") icmgg_iniua_file = config.get_icmgg_iniua_file() + # Stage the source INIUA into the output dir (mirrors how the INIT + # file is copied in process_land_sea_mask); CO2 is then added in place. + icmgg_iniua_input = config.get_icmgg_iniua_input_file() + copy2(icmgg_iniua_input, icmgg_iniua_file) interpolate_co2_to_icmgg( str(config.co2_grib_file), str(icmgg_iniua_file), diff --git a/ocp_tool/config.py b/ocp_tool/config.py index 622cdb6..c768344 100644 --- a/ocp_tool/config.py +++ b/ocp_tool/config.py @@ -94,6 +94,10 @@ def get_icmgg_output_file(self) -> Path: """Get path to output ICMGG INIT file.""" return self.output_paths.openifs_modified / f'ICMGG{self.atmosphere.experiment_name}INIT_{self.ocean.grid_name}' + def get_icmgg_iniua_input_file(self) -> Path: + """Get path to input ICMGG INIUA file.""" + return self.input_paths.openifs_default / f'ICMGG{self.atmosphere.experiment_name}INIUA' + def get_icmgg_iniua_file(self) -> Path: """Get path to output ICMGG INIUA file.""" return self.output_paths.openifs_modified / f'ICMGG{self.atmosphere.experiment_name}INIUA' diff --git a/run_ocp_tool.py b/run_ocp_tool.py index cb2920f..56abd19 100644 --- a/run_ocp_tool.py +++ b/run_ocp_tool.py @@ -14,6 +14,7 @@ import time from os import makedirs from pathlib import Path +from shutil import copy2 from ocp_tool.config import load_config, OCPConfig from ocp_tool.gaussian_grids import generate_gaussian_grid, read_fesom_grid_polygon @@ -108,6 +109,10 @@ def run_ocp_tool(config: OCPConfig) -> None: # Step 7: Interpolate 3D CO2 to INIUA file print("\nStep 7: Interpolating 3D CO2 concentrations...") icmgg_iniua_file = config.get_icmgg_iniua_file() + # Stage the source INIUA into the output dir (mirrors how the INIT + # file is copied in process_land_sea_mask); CO2 is then added in place. + icmgg_iniua_input = config.get_icmgg_iniua_input_file() + copy2(icmgg_iniua_input, icmgg_iniua_file) interpolate_co2_to_icmgg( str(config.co2_grib_file), str(icmgg_iniua_file),