From 1842c22f4f4afe945e32382dec6f48a2b2830123 Mon Sep 17 00:00:00 2001 From: Anil Kumar <108816337+AnilKumar-NOAA@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:21:11 -0400 Subject: [PATCH] Convert IC staging job into a proper j-job (#1806) --- jobs/JGLOBAL_STAGE_IC | 16 ++++++++++++ jobs/rocoto/stage_ic.sh | 18 +++++++++++++ parm/config/gfs/config.resources | 12 ++++----- .../{config.coupled_ic => config.stage_ic} | 8 +++--- .../exglobal_stage_ic.sh | 25 ++++++------------- workflow/applications/gfs_forecast_only.py | 4 +-- workflow/rocoto/gfs_tasks.py | 10 ++++---- workflow/rocoto/tasks.py | 2 +- 8 files changed, 59 insertions(+), 36 deletions(-) create mode 100755 jobs/JGLOBAL_STAGE_IC create mode 100755 jobs/rocoto/stage_ic.sh rename parm/config/gfs/{config.coupled_ic => config.stage_ic} (79%) rename jobs/rocoto/coupled_ic.sh => scripts/exglobal_stage_ic.sh (83%) diff --git a/jobs/JGLOBAL_STAGE_IC b/jobs/JGLOBAL_STAGE_IC new file mode 100755 index 0000000000..437c8f40a0 --- /dev/null +++ b/jobs/JGLOBAL_STAGE_IC @@ -0,0 +1,16 @@ +#! /usr/bin/env bash + +source "${HOMEgfs}/ush/preamble.sh" +source "${HOMEgfs}/ush/jjob_header.sh" -e "stage_ic" -c "base stage_ic" + + +# Execute the Script +"${HOMEgfs}/scripts/exglobal_stage_ic.sh" + +########################################## +# Remove the Temporary working directory +########################################## +cd "${DATAROOT}" || (echo "${DATAROOT} does not exist. ABORT!"; exit 1) +[[ ${KEEPDATA} = "NO" ]] && rm -rf "${DATA}" + +exit 0 diff --git a/jobs/rocoto/stage_ic.sh b/jobs/rocoto/stage_ic.sh new file mode 100755 index 0000000000..5e7b3395d2 --- /dev/null +++ b/jobs/rocoto/stage_ic.sh @@ -0,0 +1,18 @@ +#! /usr/bin/env bash + +source "${HOMEgfs}/ush/preamble.sh" + +# Source FV3GFS workflow modules +. "${HOMEgfs}/ush/load_fv3gfs_modules.sh" +status=$? +[[ "${status}" -ne 0 ]] && exit "${status}" + +export job="stage_ic" +export jobid="${job}.$$" + +# Execute the JJOB +"${HOMEgfs}/jobs/JGLOBAL_STAGE_IC" +status=$? + + +exit "${status}" diff --git a/parm/config/gfs/config.resources b/parm/config/gfs/config.resources index 17a1423589..a73d702eac 100644 --- a/parm/config/gfs/config.resources +++ b/parm/config/gfs/config.resources @@ -8,7 +8,7 @@ if [[ $# -ne 1 ]]; then echo "Must specify an input task argument to set resource variables!" echo "argument can be any one of the following:" - echo "coupled_ic aerosol_init" + echo "stage_ic aerosol_init" echo "prep preplandobs prepatmiodaobs" echo "atmanlinit atmanlrun atmanlfinal" echo "atmensanlinit atmensanlrun atmensanlfinal" @@ -772,12 +772,12 @@ elif [[ ${step} = "arch" || ${step} = "earc" || ${step} = "getic" ]]; then eval "export memory_${step}=50GB" fi -elif [[ ${step} = "coupled_ic" ]]; then +elif [[ ${step} = "stage_ic" ]]; then - export wtime_coupled_ic="00:15:00" - export npe_coupled_ic=1 - export npe_node_coupled_ic=1 - export nth_coupled_ic=1 + export wtime_stage_ic="00:15:00" + export npe_stage_ic=1 + export npe_node_stage_ic=1 + export nth_stage_ic=1 export is_exclusive=True elif [[ "${step}" = "atmensanlinit" ]]; then diff --git a/parm/config/gfs/config.coupled_ic b/parm/config/gfs/config.stage_ic similarity index 79% rename from parm/config/gfs/config.coupled_ic rename to parm/config/gfs/config.stage_ic index bafd4e111d..4e29c3306e 100644 --- a/parm/config/gfs/config.coupled_ic +++ b/parm/config/gfs/config.stage_ic @@ -1,11 +1,11 @@ #! /usr/bin/env bash -########## config.coupled_ic ########## +########## config.stage_ic ########## -echo "BEGIN: config.coupled_ic" +echo "BEGIN: config.stage_ic" # Get task specific resources -source "${EXPDIR}/config.resources" coupled_ic +source "${EXPDIR}/config.resources" stage_ic case "${CASE}" in "C48" | "C96") @@ -32,4 +32,4 @@ case "${CASE}" in ;; esac -echo "END: config.coupled_ic" +echo "END: config.stage_ic" diff --git a/jobs/rocoto/coupled_ic.sh b/scripts/exglobal_stage_ic.sh similarity index 83% rename from jobs/rocoto/coupled_ic.sh rename to scripts/exglobal_stage_ic.sh index 8b0088834d..7ea48fe599 100755 --- a/jobs/rocoto/coupled_ic.sh +++ b/scripts/exglobal_stage_ic.sh @@ -2,19 +2,8 @@ source "${HOMEgfs}/ush/preamble.sh" -# Source FV3GFS workflow modules -. ${HOMEgfs}/ush/load_fv3gfs_modules.sh -status=$? -[[ ${status} -ne 0 ]] && exit ${status} - -export job="coupled_ic" -export jobid="${job}.$$" - -# Execute the JJOB - -source "${HOMEgfs}/ush/jjob_header.sh" -e "coupled_ic" -c "base coupled_ic" - # Locally scoped variables and functions +# shellcheck disable=SC2153 GDATE=$(date -d "${PDY} ${cyc} - ${assim_freq} hours" +%Y%m%d%H) gPDY="${GDATE:0:8}" gcyc="${GDATE:8:2}" @@ -36,7 +25,7 @@ source="${BASE_CPLIC}/${CPL_ATMIC}/${PDY}${cyc}/${CDUMP}/${CASE}/INPUT/gfs_ctrl. target="${COM_ATMOS_INPUT}/gfs_ctrl.nc" ${NCP} "${source}" "${target}" rc=$? -[[ ${rc} -ne 0 ]] && error_message "${source}" "${target}" "${rc}" +(( rc != 0 )) && error_message "${source}" "${target}" "${rc}" err=$((err + rc)) for ftype in gfs_data sfc_data; do for tt in $(seq 1 6); do @@ -44,7 +33,7 @@ for ftype in gfs_data sfc_data; do target="${COM_ATMOS_INPUT}/${ftype}.tile${tt}.nc" ${NCP} "${source}" "${target}" rc=$? - [[ ${rc} -ne 0 ]] && error_message "${source}" "${target}" "${rc}" + (( rc != 0 )) && error_message "${source}" "${target}" "${rc}" err=$((err + rc)) done done @@ -57,7 +46,7 @@ if [[ "${DO_OCN:-}" = "YES" ]]; then target="${COM_OCEAN_RESTART}/${PDY}.${cyc}0000.MOM.res.nc" ${NCP} "${source}" "${target}" rc=$? - [[ ${rc} -ne 0 ]] && error_message "${source}" "${target}" "${rc}" + (( rc != 0 )) && error_message "${source}" "${target}" "${rc}" err=$((err + rc)) case "${OCNRES}" in "500" | "100") # Only 5 degree or 1 degree ocean does not have MOM.res_[1-4].nc files @@ -69,7 +58,7 @@ if [[ "${DO_OCN:-}" = "YES" ]]; then target="${COM_OCEAN_RESTART}/${PDY}.${cyc}0000.MOM.res_${nn}.nc" ${NCP} "${source}" "${target}" rc=$? - [[ ${rc} -ne 0 ]] && error_message "${source}" "${target}" "${rc}" + (( rc != 0 )) && error_message "${source}" "${target}" "${rc}" err=$((err + rc)) fi done @@ -91,7 +80,7 @@ if [[ "${DO_ICE:-}" = "YES" ]]; then target="${COM_ICE_RESTART}/${PDY}.${cyc}0000.cice_model.res.nc" ${NCP} "${source}" "${target}" rc=$? - [[ ${rc} -ne 0 ]] && error_message "${source}" "${target}" "${rc}" + (( rc != 0 )) && error_message "${source}" "${target}" "${rc}" err=$((err + rc)) fi @@ -104,7 +93,7 @@ if [[ "${DO_WAVE:-}" = "YES" ]]; then target="${COM_WAVE_RESTART}/${PDY}.${cyc}0000.restart.${grdID}" ${NCP} "${source}" "${target}" rc=$? - [[ ${rc} -ne 0 ]] && error_message "${source}" "${target}" "${rc}" + (( rc != 0 )) && error_message "${source}" "${target}" "${rc}" err=$((err + rc)) done fi diff --git a/workflow/applications/gfs_forecast_only.py b/workflow/applications/gfs_forecast_only.py index de01caa6e2..e6d1ab35a2 100644 --- a/workflow/applications/gfs_forecast_only.py +++ b/workflow/applications/gfs_forecast_only.py @@ -15,7 +15,7 @@ def _get_app_configs(self): Returns the config_files that are involved in the forecast-only app """ - configs = ['coupled_ic', 'fcst', 'arch'] + configs = ['stage_ic', 'fcst', 'arch'] if self.do_atm: configs += ['post', 'vrfy'] @@ -65,7 +65,7 @@ def get_task_names(self): This is the place where that order is set. """ - tasks = ['coupled_ic'] + tasks = ['stage_ic'] if self.do_aero: tasks += ['aerosol_init'] diff --git a/workflow/rocoto/gfs_tasks.py b/workflow/rocoto/gfs_tasks.py index 8f91abae75..b9ba4a29ed 100644 --- a/workflow/rocoto/gfs_tasks.py +++ b/workflow/rocoto/gfs_tasks.py @@ -15,9 +15,9 @@ def _is_this_a_gdas_task(cdump, task_name): raise TypeError(f'{task_name} must be part of the "enkfgdas" cycle and not {cdump}') # Specific Tasks begin here - def coupled_ic(self): + def stage_ic(self): - cpl_ic = self._configs['coupled_ic'] + cpl_ic = self._configs['stage_ic'] deps = [] @@ -72,8 +72,8 @@ def coupled_ic(self): dependencies = rocoto.create_dependency(dep_condition='and', dep=deps) - resources = self.get_resource('coupled_ic') - task = create_wf_task('coupled_ic', resources, cdump=self.cdump, envar=self.envars, dependency=dependencies) + resources = self.get_resource('stage_ic') + task = create_wf_task('stage_ic', resources, cdump=self.cdump, envar=self.envars, dependency=dependencies) return task @@ -484,7 +484,7 @@ def fcst(self): def _fcst_forecast_only(self): dependencies = [] - dep_dict = {'type': 'task', 'name': f'{self.cdump}coupled_ic'} + dep_dict = {'type': 'task', 'name': f'{self.cdump}stage_ic'} dependencies.append(rocoto.add_dependency(dep_dict)) if self.app_config.do_wave and self.cdump in self.app_config.wave_cdumps: diff --git a/workflow/rocoto/tasks.py b/workflow/rocoto/tasks.py index 1eba5a2652..b9716c938e 100644 --- a/workflow/rocoto/tasks.py +++ b/workflow/rocoto/tasks.py @@ -10,7 +10,7 @@ class Tasks: SERVICE_TASKS = ['arch', 'earc'] - VALID_TASKS = ['aerosol_init', 'coupled_ic', + VALID_TASKS = ['aerosol_init', 'stage_ic', 'prep', 'anal', 'sfcanl', 'analcalc', 'analdiag', 'arch', 'prepatmiodaobs', 'atmanlinit', 'atmanlrun', 'atmanlfinal', 'ocnanalprep', 'ocnanalbmat', 'ocnanalrun', 'ocnanalchkpt', 'ocnanalpost', 'ocnanalvrfy',