Skip to content

Commit

Permalink
Abstract common j-job tasks (#1230)
Browse files Browse the repository at this point in the history
Takes all of the tasks that are common to all j-jobs and abstracts them out into a shared script that is sourced by each job:
- Set and create $DATA directory
- Call setpy and set $cycle
- Set pid, pgmout, and pgmerr
- Source config files
- Source machine environment file

The common j-job header script is called by passing the job name for the `${machine}.env` files using the `-e` option, and a list of config files to source with the `-c` option.
```
${HOMEgfs}/ush/jjob_header.sh -e [env_job] -c "[config1 [config2 [...]]]"
```
The job name argument (`-e`) is mandatory, and the config list is optional but recommend to always use as well.

Some pre j-job rocoto entry scripts (`jobs/rocoto/*`) are currently doing much more than they should be. These sometimes required extra finagling, usually pre-calling the jjob header in the rocoto script before it does something.

Refs: #1069
  • Loading branch information
WalterKolczynski-NOAA committed Jan 14, 2023
1 parent e8d4778 commit ca5baeb
Show file tree
Hide file tree
Showing 69 changed files with 277 additions and 2,320 deletions.
2 changes: 2 additions & 0 deletions env/HERA.env
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ elif [[ "${step}" = "awips" ]]; then

elif [[ "${step}" = "gempak" ]]; then

export CFP_MP="YES"

nth_max=$((npe_node_max / npe_node_gempak))

export NTHREADS_GEMPAK=${nth_gempak:-1}
Expand Down
2 changes: 2 additions & 0 deletions env/ORION.env
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ elif [[ "${step}" = "awips" ]]; then

elif [[ "${step}" = "gempak" ]]; then

export CFP_MP="YES"

nth_max=$((npe_node_max / npe_node_gempak))

export NTHREADS_GEMPAK=${nth_gempak:-1}
Expand Down
44 changes: 1 addition & 43 deletions jobs/JGDAS_ATMOS_ANALYSIS_DIAG
Original file line number Diff line number Diff line change
@@ -1,49 +1,7 @@
#! /usr/bin/env bash

source "${HOMEgfs}/ush/preamble.sh"

##############################################
# make temp directory
##############################################
export DATA=${DATA:-${DATAROOT}/${jobid}}
mkdir -p ${DATA}
cd ${DATA}


##############################################
# Run setpdy and initialize PDY variables
##############################################
export cycle="t${cyc}z"
setpdy.sh
. ./PDY


##############################################
# Determine Job Output Name on System
##############################################
export pid=${pid:-$$}
export pgmout="OUTPUT.${pid}"
export pgmerr=errfile


#############################
# Source relevant config files
#############################
export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config}
configs="base anal analdiag"
for config in ${configs}; do
. ${EXPDIR}/config.${config}
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
done


##########################################
# Source machine runtime environment
##########################################
. ${HOMEgfs}/env/${machine}.env anal
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
source "${HOMEgfs}/ush/jjob_header.sh" -e "anal" -c "base anal analdiag"


##############################################
Expand Down
44 changes: 1 addition & 43 deletions jobs/JGDAS_ATMOS_CHGRES_FORENKF
Original file line number Diff line number Diff line change
@@ -1,49 +1,7 @@
#! /usr/bin/env bash

source "${HOMEgfs}/ush/preamble.sh"

##############################################
# make temp directory
##############################################
export DATA=${DATA:-${DATAROOT}/${jobid}}
mkdir -p ${DATA}
cd ${DATA}


##############################################
# Run setpdy and initialize PDY variables
##############################################
export cycle="t${cyc}z"
setpdy.sh
. ./PDY


##############################################
# Determine Job Output Name on System
##############################################
export pid=${pid:-$$}
export pgmout="OUTPUT.${pid}"
export pgmerr=errfile


#############################
# Source relevant config files
#############################
export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config}
configs="base anal echgres"
for config in ${configs}; do
. ${EXPDIR}/config.${config}
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
done


##########################################
# Source machine runtime environment
##########################################
. ${HOMEgfs}/env/${machine}.env anal
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
source "${HOMEgfs}/ush/jjob_header.sh" -e "anal" -c "base anal echgres"


##############################################
Expand Down
41 changes: 3 additions & 38 deletions jobs/JGDAS_ATMOS_GEMPAK
Original file line number Diff line number Diff line change
@@ -1,45 +1,12 @@
#! /usr/bin/env bash

source "${HOMEgfs}/ush/preamble.sh"
source "${HOMEgfs}/ush/jjob_header.sh" -e "gempak" -c "base gempak"

##########################################################
# make temp directory
##########################################################
export DATA=${DATA:-${DATAROOT}/${jobid}}
mkdir -p ${DATA}
cd ${DATA}

###########################################
# Run setpdy and initialize PDY variables
###########################################
export cycle="t${cyc}z"
setpdy.sh
. ./PDY

export pid=${pid:-$$}
export pgmout="OUTPUT.${pid}"
export pgmerr=errfile

#############################
# Source relevant config files
#############################
export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config}
configs="base gempak"
for config in ${configs}; do
. ${EXPDIR}/config.${config}
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
done

###############################################################
. ${BASE_ENV}/${machine}.env gempak
status=$?
[[ ${status} -ne 0 ]] && exit ${status}
# TODO (#1219) This j-job is not part of the rocoto suite

################################
# Set up the HOME directory
################################
export HOMEgfs=${HOMEgfs:-${PACKAGEROOT}/gfs.${gfs_ver}} # TODO: remove these as they are already defined in config.base
export EXECgfs=${EXECgfs:-${HOMEgfs}/exec}
export PARMgfs=${PARMgfs:-${HOMEgfs}/parm}
export PARMwmo=${PARMwmo:-${HOMEgfs}/parm/wmo}
Expand Down Expand Up @@ -67,8 +34,6 @@ export DBNROOT=${DBNROOT:-${UTILROOT}/fakedbn}
###################################
# Specify NET and RUN Name and model
####################################
export NET=${NET:-gfs}
export RUN=${RUN:-gdas}
export model=${model:-gdas}
export COMPONENT="atmos"

Expand All @@ -83,7 +48,7 @@ if [ ${SENDCOM} = YES ] ; then
fi


# TODO: These actions belong in an ex-script not a j-job
# TODO: These actions belong in an ex-script not a j-job (#1219)
if [ -f ${DATA}/poescript ]; then
rm ${DATA}/poescript
fi
Expand Down
23 changes: 3 additions & 20 deletions jobs/JGDAS_ATMOS_GEMPAK_META_NCDC
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
#! /usr/bin/env bash

source "${HOMEgfs}/ush/preamble.sh"

############################################
# GDAS GEMPAK META NCDC PRODUCT GENERATION
############################################

##########################################################
# make temp directory
##########################################################
export DATA=${DATA:-${DATAROOT}/${jobid}}
mkdir -p ${DATA}
cd ${DATA}
# TODO (#1222) This j-job is not part of the rocoto

###########################################
# Run setpdy and initialize PDY variables
###########################################
export cycle="t${cyc}z"
setpdy.sh
. ./PDY

export pid=${pid:-$$}
export pgmout="OUTPUT.${pid}"
export pgmerr=errfile
source "${HOMEgfs}/ush/preamble.sh"
source "${HOMEgfs}/ush/jjob_header.sh" -e "gempak_meta" -c "base gempak"

################################
# Set up the HOME directory
Expand All @@ -46,8 +31,6 @@ cp ${FIXgempak}/datatype.tbl datatype.tbl
###################################
# Specify NET and RUN Name and model
####################################
export NET=${NET:-gfs}
export RUN=${RUN:-gdas}
export COMPONENT="atmos"
export MODEL=GDAS
export GRID_NAME=gdas
Expand Down
48 changes: 3 additions & 45 deletions jobs/JGDAS_ATMOS_GLDAS
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
#! /usr/bin/env bash

source "${HOMEgfs:?}/ush/preamble.sh"

##############################################
# Obtain unique process id (pid) and make temp directory
##############################################
export DATA=${DATA:-${DATAROOT}/${jobid}}
mkdir -p "${DATA}"
cd "${DATA}" || exit 1


##############################################
# Run setpdy and initialize PDY variables
##############################################
export cycle="t${cyc}z"
setpdy.sh
. ./PDY


##############################################
# Determine Job Output Name on System
##############################################
export pid=${pid:-$$}
export pgmout="OUTPUT.${pid}"
export pgmerr=errfile


#############################
# Source relevant config files
#############################
export EXPDIR=${EXPDIR:-${HOMEgfs}/parm/config}
configs="base gldas"
for config in ${configs}; do
. ${EXPDIR}/config.${config}
status=$?
[[ ${status} -ne 0 ]] && exit "${status}"
done

source "${HOMEgfs}/ush/jjob_header.sh" -e "gldas" -c "base gldas"

if [[ "${cyc:?}" -ne "${gldas_cyc:?}" ]]; then
echo "GLDAS only runs for ${gldas_cyc} cycle; Skip GLDAS step for cycle ${cyc}"
rm -Rf "${DATA}"
exit 0
fi

Expand All @@ -48,18 +14,10 @@ xtime=$((gldas_spinup_hours+12))
if [[ "${CDATE}" -le "$(${NDATE:?} +"${xtime}" "${SDATE:?}")" ]]; then
echo "GLDAS needs fluxes as forcing from cycles in previous ${xtime} hours"
echo "starting from ${SDATE}. This gldas cycle is skipped"
rm -Rf "${DATA}"
exit 0
fi

##########################################
# Source machine runtime environment
##########################################
# shellcheck disable=SC1090-SC1091
. "${HOMEgfs}/env/${machine:?}.env" gldas
# shellcheck disable=
status=$?
[[ ${status} -ne 0 ]] && exit "${status}"


##############################################
# Set variables used in the exglobal script
Expand Down
26 changes: 1 addition & 25 deletions jobs/JGDAS_ATMOS_VERFOZN
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,12 @@
# Set up environment for GDAS Ozone Monitor job
#############################################################
source "${HOMEgfs}/ush/preamble.sh"

###########################################################
# make temp directories
###########################################################
export DATA=${DATA:-${DATAROOT}/${jobid}}
mkdir -p ${DATA}
cd ${DATA}


##############################################
# Run setpdy and initialize PDY variables
##############################################
export cycle="t${cyc}z"
setpdy.sh
. ./PDY


####################################
# Determine Job Output Name on System
####################################
export pid=$$
export pgmout="OUTPUT.${pid}"
export pgmerr=errfile
source "${HOMEgfs}/ush/jjob_header.sh" -e "vrfy" -c "base vrfy"


###############################
# Specify NET, RUN, and COMPONENT name
##############################
export NET=${NET:-gfs}
export RUN=${RUN:-gdas}
export COMPONENT="atmos"

export OZNMON_SUFFIX=${OZNMON_SUFFIX:-${NET}}
Expand Down
30 changes: 1 addition & 29 deletions jobs/JGDAS_ATMOS_VERFRAD
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,8 @@
# Set up environment for GDAS Radiance Monitor job
#############################################################
source "${HOMEgfs}/ush/preamble.sh"
source "${HOMEgfs}/ush/jjob_header.sh" -e "vrfy" -c "base vrfy"

###########################################################
# make temp directories
###########################################################
export DATA=${DATA:-${DATAROOT}/${jobid}}
mkdir -p ${DATA}
cd ${DATA}


##############################################
# Run setpdy and initialize PDY variables
##############################################
export cycle="t${cyc}z"
setpdy.sh
. ./PDY


####################################
# Determine Job Output Name on System
####################################
export pid=$$
export pgmout="OUTPUT.${pid}"
export pgmerr=errfile


###############################
# Specify NET, RUN, and COMPONENT name
##############################
export NET=${NET:-gfs}
export RUN=${RUN:-gdas}
export COMPONENT="atmos"

export RAD_DATA_IN=${DATA}
Expand Down
Loading

0 comments on commit ca5baeb

Please sign in to comment.