Skip to content

Commit

Permalink
Updates in the aerosol tasks (NOAA-EMC#1420)
Browse files Browse the repository at this point in the history
-removes the definition of environment variables in the shell script j-jobs
-eliminates the use of !ENV in the yaml files for aerosol jobs.
-eliminates use of CDATE in the python tasks. Use current_cycle and previous_cycle
-uses jinja templates where appropriate.
-uses the Executable class to run the variational analysis executable
-adds verbose logging to the actions in the aerosol analysis task
-uses string templates instead of string replace where looping over tiles is required.
-links aerosol ICs when cycling with the ATMA app. ICs courtesy of @CoryMartin-NOAA

Co-authored-by: Walter Kolczynski - NOAA <Walter.Kolczynski@noaa.gov>
  • Loading branch information
aerorahul and WalterKolczynski-NOAA authored Mar 27, 2023
1 parent 3e73038 commit c549acb
Show file tree
Hide file tree
Showing 16 changed files with 208 additions and 170 deletions.
2 changes: 1 addition & 1 deletion Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protocol = git
required = False

[GDASApp]
hash = a00b5da
hash = 6aa55fa
local_path = sorc/gdas.cd
repo_url = https://github.com/NOAA-EMC/GDASApp.git
protocol = git
Expand Down
21 changes: 5 additions & 16 deletions jobs/JGLOBAL_AERO_ANALYSIS_FINALIZE
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,20 @@ source "${HOMEgfs}/ush/jjob_header.sh" -e "aeroanlfinal" -c "base aeroanl aeroan
##############################################
# Set variables used in the script
##############################################
export CDATE=${CDATE:-${PDY}${cyc}}
export CDUMP=${CDUMP:-${RUN:-"gfs"}}
GDATE=$(date +%Y%m%d%H -d "${PDY} ${cyc} - ${assim_freq} hours")
GDUMP="gdas"


##############################################
# Begin JOB SPECIFIC work
##############################################

GDATE=$(date +%Y%m%d%H -d "${CDATE:0:8} ${CDATE:8:2} - ${assim_freq} hours")
export GDATE
gPDY=${GDATE:0:8}
export gcyc=${GDATE:8:2}
export GDUMP=${GDUMP:-"gdas"}

export OPREFIX="${CDUMP}.t${cyc}z."
export GPREFIX="${GDUMP}.t${gcyc}z."
export APREFIX="${CDUMP}.t${cyc}z."

export COMOUT=${COMOUT:-${ROTDIR}/${CDUMP}.${PDY}/${cyc}/chem}

export COMOUT=${COMOUT:-${ROTDIR}/${RUN}.${PDY}/${cyc}/chem}
mkdir -p "${COMOUT}"

# COMIN_GES and COMIN_GES_ENS are used in script
export COMIN_GES="${ROTDIR}/${GDUMP}.${gPDY}/${gcyc}/chem"
export COMIN_GES_ENS="${ROTDIR}/enkf${GDUMP}.${gPDY}/${gcyc}/chem"
export COMIN_GES="${ROTDIR}/${GDUMP}.${GDATE:0:8}/${GDATE:8:2}/chem"
export COMIN_GES_ENS="${ROTDIR}/enkf${GDUMP}.${GDATE:0:8}/${GDATE:8:2}/chem"

###############################################################
# Run relevant script
Expand Down
21 changes: 5 additions & 16 deletions jobs/JGLOBAL_AERO_ANALYSIS_INITIALIZE
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,20 @@ source "${HOMEgfs}/ush/jjob_header.sh" -e "aeroanlinit" -c "base aeroanl aeroanl
##############################################
# Set variables used in the script
##############################################
export CDATE=${CDATE:-${PDY}${cyc}}
export CDUMP=${CDUMP:-${RUN:-"gfs"}}
GDATE=$(date +%Y%m%d%H -d "${PDY} ${cyc} - ${assim_freq} hours")
GDUMP="gdas"


##############################################
# Begin JOB SPECIFIC work
##############################################

GDATE=$(date +%Y%m%d%H -d "${CDATE:0:8} ${CDATE:8:2} - ${assim_freq} hours")
export GDATE
gPDY=${GDATE:0:8}
export gcyc=${GDATE:8:2}
export GDUMP=${GDUMP:-"gdas"}

export OPREFIX="${CDUMP}.t${cyc}z."
export GPREFIX="${GDUMP}.t${gcyc}z."
export APREFIX="${CDUMP}.t${cyc}z."

export COMOUT=${COMOUT:-${ROTDIR}/${CDUMP}.${PDY}/${cyc}/chem}

export COMOUT=${COMOUT:-${ROTDIR}/${RUN}.${PDY}/${cyc}/chem}
mkdir -p "${COMOUT}"

# COMIN_GES and COMIN_GES_ENS are used in script
export COMIN_GES="${ROTDIR}/${GDUMP}.${gPDY}/${gcyc}/chem"
export COMIN_GES_ENS="${ROTDIR}/enkf${GDUMP}.${gPDY}/${gcyc}/chem"
export COMIN_GES="${ROTDIR}/${GDUMP}.${GDATE:0:8}/${GDATE:8:2}/chem"
export COMIN_GES_ENS="${ROTDIR}/enkf${GDUMP}.${GDATE:0:8}/${GDATE:8:2}/chem"

###############################################################
# Run relevant script
Expand Down
24 changes: 6 additions & 18 deletions jobs/JGLOBAL_AERO_ANALYSIS_RUN
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,24 @@ source "${HOMEgfs}/ush/jjob_header.sh" -e "aeroanlrun" -c "base aeroanl aeroanlr
##############################################
# Set variables used in the script
##############################################
export CDATE=${CDATE:-${PDY}${cyc}}
export CDUMP=${CDUMP:-${RUN:-"gfs"}}

GDATE=$(date +%Y%m%d%H -d "${PDY} ${cyc} - ${assim_freq} hours")
GDUMP="gdas"

##############################################
# Begin JOB SPECIFIC work
##############################################

GDATE=$(date +%Y%m%d%H -d "${CDATE:0:8} ${CDATE:8:2} - ${assim_freq} hours")
export GDATE
gPDY=${GDATE:0:8}
export gcyc=${GDATE:8:2}
export GDUMP=${GDUMP:-"gdas"}

export OPREFIX="${CDUMP}.t${cyc}z."
export GPREFIX="${GDUMP}.t${gcyc}z."
export APREFIX="${CDUMP}.t${cyc}z."

export COMOUT=${COMOUT:-${ROTDIR}/${CDUMP}.${PDY}/${cyc}/chem}

export COMOUT=${COMOUT:-${ROTDIR}/${RUN}.${PDY}/${cyc}/chem}
mkdir -p "${COMOUT}"

# COMIN_GES and COMIN_GES_ENS are used in script
export COMIN_GES="${ROTDIR}/${GDUMP}.${gPDY}/${gcyc}/chem"
export COMIN_GES_ENS="${ROTDIR}/enkf${GDUMP}.${gPDY}/${gcyc}/chem"
export COMIN_GES="${ROTDIR}/${GDUMP}.${GDATE:0:8}/${GDATE:8:2}/chem"
export COMIN_GES_ENS="${ROTDIR}/enkf${GDUMP}.${GDATE:0:8}/${GDATE:8:2}/chem"

###############################################################
# Run relevant script

EXSCRIPT=${GDASAERORUNSH:-${HOMEgfs}/scripts/exglobal_aero_analysis_run.sh}
EXSCRIPT=${GDASAERORUNSH:-${HOMEgfs}/scripts/exglobal_aero_analysis_run.py}
${EXSCRIPT}
status=$?
[[ ${status} -ne 0 ]] && exit "${status}"
Expand Down
6 changes: 6 additions & 0 deletions jobs/rocoto/aeroanlrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ status=$?
export job="aeroanlrun"
export jobid="${job}.$$"

###############################################################
# setup python path for workflow utilities and tasks
pygwPATH="${HOMEgfs}/ush/python:${HOMEgfs}/ush/python/pygw/src"
PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${pygwPATH}"
export PYTHONPATH

###############################################################
# Execute the JJOB
"${HOMEgfs}/jobs/JGLOBAL_AERO_ANALYSIS_RUN"
Expand Down
2 changes: 1 addition & 1 deletion scripts/exglobal_aero_analysis_finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# for a global aerosol variational analysis
import os

from pygw.logger import Logger, logit
from pygw.logger import Logger
from pygw.configuration import cast_strdict_as_dtypedict
from pygfs.task.aero_analysis import AerosolAnalysis

Expand Down
23 changes: 23 additions & 0 deletions scripts/exglobal_aero_analysis_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# exgdas_global_aero_analysis_run.py
# This script creates an AerosolAnalysis object
# and runs the execute method
# which executes the global aerosol variational analysis
import os

from pygw.logger import Logger
from pygw.configuration import cast_strdict_as_dtypedict
from pygfs.task.aero_analysis import AerosolAnalysis

# Initialize root logger
logger = Logger(level='DEBUG', colored_log=True)


if __name__ == '__main__':

# Take configuration from environment and cast it as python dictionary
config = cast_strdict_as_dtypedict(os.environ)

# Instantiate the aerosol analysis task
AeroAnl = AerosolAnalysis(config)
AeroAnl.execute()
15 changes: 0 additions & 15 deletions scripts/exglobal_aero_analysis_run.sh

This file was deleted.

52 changes: 26 additions & 26 deletions sorc/build_gdas.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#! /usr/bin/env bash
set -eux

script_dir=$(dirname "${BASH_SOURCE[0]}")
cd "${script_dir}" || exit 1

source gfs_utils.fd/ush/detect_machine.sh
source gfs_utils.fd/ush/module-setup.sh

# detect_machine now includes the compiler on some machines
# but the GDAS build script does not want it
MACHINE_ID=$(echo "${MACHINE_ID}" | cut -d "." -f 1)

case "${MACHINE_ID}" in
hera|orion) build_jobs=10 ;;
*) build_jobs=4 ;;
esac

# Check final exec folder exists
if [[ ! -d "../exec" ]]; then
mkdir ../exec
fi

cd gdas.cd

WORKFLOW_BUILD="ON" BUILD_JOBS="${build_jobs}" ./build.sh -t "${MACHINE_ID}"

exit $?

OPTIND=1
while getopts ":dov" option; do
case "${option}" in
d) export BUILD_TYPE="DEBUG";;
v) export BUILD_VERBOSE="YES";;
:)
echo "[${BASH_SOURCE[0]}]: ${option} requires an argument"
usage
;;
*)
echo "[${BASH_SOURCE[0]}]: Unrecognized option: ${option}"
usage
;;
esac
done
shift $((OPTIND-1))

# TODO: GDASApp does not presently handle BUILD_TYPE

BUILD_TYPE=${BUILD_TYPE:-"Release"} \
BUILD_VERBOSE=${BUILD_VERBOSE:-"NO"} \
BUILD_JOBS="${BUILD_JOBS:-8}" \
WORKFLOW_BUILD="ON" \
./gdas.cd/build.sh

exit
2 changes: 1 addition & 1 deletion sorc/checkout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ if [[ ${checkout_gsi} == "YES" ]]; then
fi

if [[ ${checkout_gdas} == "YES" ]]; then
checkout "gdas.cd" "https://github.com/NOAA-EMC/GDASApp.git" "a00b5da"; errs=$((errs + $?))
checkout "gdas.cd" "https://github.com/NOAA-EMC/GDASApp.git" "6aa55fa"; errs=$((errs + $?))
fi

if [[ ${checkout_gsi} == "YES" || ${checkout_gdas} == "YES" ]]; then
Expand Down
Loading

0 comments on commit c549acb

Please sign in to comment.