Skip to content

Commit

Permalink
Abstract common j-job tasks
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
- 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 a list of config
files to source:
```
${HOMEgfs}/ush/jjob_header.sh [config1 [config2 [...]]]
```

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.
  • Loading branch information
WalterKolczynski-NOAA committed Jan 6, 2023
1 parent cf1b328 commit 95a4d9c
Show file tree
Hide file tree
Showing 67 changed files with 221 additions and 2,318 deletions.
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" 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" 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" 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" 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
46 changes: 1 addition & 45 deletions jobs/JGDAS_ATMOS_GLDAS
Original file line number Diff line number Diff line change
@@ -1,42 +1,7 @@
#! /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" base gldas

if [[ "${cyc:?}" -ne "${gldas_cyc:?}" ]]; then
echo "GLDAS only runs for ${gldas_cyc} cycle; Skip GLDAS step for cycle ${cyc}"
Expand All @@ -51,15 +16,6 @@ if [[ "${CDATE}" -le "$(${NDATE:?} +"${xtime}" "${SDATE:?}")" ]]; then
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" 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" 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
30 changes: 1 addition & 29 deletions jobs/JGDAS_ATMOS_VMINMON
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,8 @@
# GDAS Minimization Monitor (MinMon) job
###########################################################
source "${HOMEgfs}/ush/preamble.sh"
source "${HOMEgfs}/ush/jjob_header.sh" 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"

###########################################################
Expand Down
Loading

0 comments on commit 95a4d9c

Please sign in to comment.