From 61875f25c9e971f82ae499b5b612d7f095deebd4 Mon Sep 17 00:00:00 2001 From: Eric Sinsky - NOAA <48259628+EricSinsky-NOAA@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:40:03 -0400 Subject: [PATCH] Remove f000 from atmos rocoto tasks for replay cases (#2778) The main purpose of this PR is to remove the f000 from atmosphere-related rocoto tasks when `REPLAY_ICS` is set to `YES`. In cases where `REPLAY_ICS` is `YES` and `OFFSET_START_HOUR `is greater than `0`, it becomes necessary to have the first lead hour set to `OFFSET_START_HOUR ` for the atmosphere-related rocoto tasks. For example, when `OFFSET_START_HOUR ` is set to `3`, then the minimum lead time for the atmos_prod and atmos_ensstat rocoto tasks needs to be 3 and the minimum lead time for the ocean_prod rocoto task needs to be 6 (assuming `FHOUT_OCN` is 6). This PR makes this rocoto workflow set up possible by removing 0 from fhrs for atmosphere-related tasks in `gefs_tasks.py` when replaying. This PR also moves where f000 is being removed for the ocean_prod and ice_prod tasks. The if-block that performs this f000 removal has been moved from `tasks.py` to `gefs_tasks.py` and `gfs_tasks.py`. --------- Co-authored-by: Rahul Mahajan --- scripts/exglobal_stage_ic.sh | 4 ++-- workflow/rocoto/gefs_tasks.py | 16 ++++++++++++++++ workflow/rocoto/gfs_tasks.py | 5 +++++ workflow/rocoto/tasks.py | 4 ---- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/scripts/exglobal_stage_ic.sh b/scripts/exglobal_stage_ic.sh index 8800292752..32356cd724 100755 --- a/scripts/exglobal_stage_ic.sh +++ b/scripts/exglobal_stage_ic.sh @@ -86,7 +86,7 @@ for MEMDIR in "${MEMDIR_ARRAY[@]}"; do # Atmosphere Perturbation Files (usually used with replay ICS) # Extra zero on MEMDIR ensure we have a number even if the string is empty - if (( 0${MEMDIR:3} > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then + if (( $((10#0${MEMDIR:3})) > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then YMD=${PDY} HH=${cyc} declare_from_tmpl COM_ATMOS_ANALYSIS:COM_ATMOS_ANALYSIS_TMPL [[ ! -d "${COM_ATMOS_ANALYSIS}" ]] && mkdir -p "${COM_ATMOS_ANALYSIS}" src="${BASE_CPLIC}/${CPL_ATMIC:-}/${PDY}${cyc}/${MEMDIR}/atmos/${DTG_PREFIX}.fv3_perturbation.nc" @@ -130,7 +130,7 @@ for MEMDIR in "${MEMDIR_ARRAY[@]}"; do # Ocean Perturbation Files # Extra zero on MEMDIR ensure we have a number even if the string is empty - if (( 0${MEMDIR:3} > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then + if (( $((10#0${MEMDIR:3})) > 0 )) && [[ "${REPLAY_ICS:-NO}" == "YES" ]]; then YMD=${PDY} HH=${cyc} declare_from_tmpl COM_OCEAN_ANALYSIS:COM_OCEAN_ANALYSIS_TMPL [[ ! -d "${COM_OCEAN_ANALYSIS}" ]] && mkdir -p "${COM_OCEAN_ANALYSIS}" src="${BASE_CPLIC}/${CPL_OCNIC:-}/${PDY}${cyc}/${MEMDIR}/ocean/${DTG_PREFIX}.mom6_perturbation.nc" diff --git a/workflow/rocoto/gefs_tasks.py b/workflow/rocoto/gefs_tasks.py index f6d1ad6cdc..24864d3b96 100644 --- a/workflow/rocoto/gefs_tasks.py +++ b/workflow/rocoto/gefs_tasks.py @@ -270,6 +270,16 @@ def _atmosoceaniceprod(self, component: str): 'maxtries': '&MAXTRIES;'} fhrs = self._get_forecast_hours('gefs', self._configs[config], component) + + # when replaying, atmos component does not have fhr 0, therefore remove 0 from fhrs + is_replay = self._configs[config]['REPLAY_ICS'] + if is_replay and component in ['atmos'] and 0 in fhrs: + fhrs.remove(0) + + # ocean/ice components do not have fhr 0 as they are averaged output + if component in ['ocean', 'ice'] and 0 in fhrs: + fhrs.remove(0) + fhr_var_dict = {'fhr': ' '.join([f"{fhr:03d}" for fhr in fhrs])} fhr_metatask_dict = {'task_name': f'{component}_prod_#member#', @@ -314,6 +324,12 @@ def atmos_ensstat(self): 'maxtries': '&MAXTRIES;'} fhrs = self._get_forecast_hours('gefs', self._configs['atmos_ensstat']) + + # when replaying, atmos component does not have fhr 0, therefore remove 0 from fhrs + is_replay = self._configs['atmos_ensstat']['REPLAY_ICS'] + if is_replay and 0 in fhrs: + fhrs.remove(0) + fhr_var_dict = {'fhr': ' '.join([f"{fhr:03d}" for fhr in fhrs])} fhr_metatask_dict = {'task_name': f'atmos_ensstat', diff --git a/workflow/rocoto/gfs_tasks.py b/workflow/rocoto/gfs_tasks.py index 1f14751642..bdc98a36fb 100644 --- a/workflow/rocoto/gfs_tasks.py +++ b/workflow/rocoto/gfs_tasks.py @@ -1128,6 +1128,11 @@ def _atmosoceaniceprod(self, component: str): } fhrs = self._get_forecast_hours(self.cdump, self._configs[config], component) + + # ocean/ice components do not have fhr 0 as they are averaged output + if component in ['ocean', 'ice'] and 0 in fhrs: + fhrs.remove(0) + fhr_var_dict = {'fhr': ' '.join([f"{fhr:03d}" for fhr in fhrs])} metatask_dict = {'task_name': f'{self.cdump}{component}_prod', 'task_dict': task_dict, diff --git a/workflow/rocoto/tasks.py b/workflow/rocoto/tasks.py index 25a6b2bef1..ca8d7f9857 100644 --- a/workflow/rocoto/tasks.py +++ b/workflow/rocoto/tasks.py @@ -158,10 +158,6 @@ def _get_forecast_hours(cdump, config, component='atmos') -> List[str]: fhrs_hf = range(fhmin, fhmax_hf + fhout_hf, fhout_hf) fhrs = list(fhrs_hf) + list(range(fhrs_hf[-1] + fhout, fhmax + fhout, fhout)) - # ocean/ice components do not have fhr 0 as they are averaged output - if component in ['ocean', 'ice'] and 0 in fhrs: - fhrs.remove(0) - return fhrs def get_resource(self, task_name):