Skip to content

Commit

Permalink
Merge pull request NOAA-GSL#53 from JulieSchramm/features/split_get_f…
Browse files Browse the repository at this point in the history
…iles_ics

Split get_extrn_mdl_files.sh into j-job and ex-script
  • Loading branch information
gsketefian authored Aug 8, 2019
2 parents 18bd96a + 0260b94 commit 17e5bcc
Show file tree
Hide file tree
Showing 6 changed files with 1,006 additions and 2 deletions.
242 changes: 242 additions & 0 deletions jobs/JREGIONAL_GET_FILES_ICS
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
#!/bin/sh -l

#
#-----------------------------------------------------------------------
#
# This script gets either from the system directory or from mass store
# (HPSS) the files generated by the external model (specified by the va-
# riable EXTRN_MDL_NAME) for either the initial conditions (ICs) or the
# lateral boundary conditions (LBCs). Which of these we are considering
# depends on the value of the variable ICSSURF_OR_LBCS. Also, when we
# refer to ICs, we are also referring to the surface fields and the 0-th
# hour LBC, and when we refer to LBCs, we are referring to the LBCs ex-
# cluding the one at 0-th hour. If considering ICs, this script places
# these external model files in a subdirectory under the one specified
# by the variable EXTRN_MDL_FILES_BASEDIR_ICSSURF, and if considering
# LBCs, it places the files in a subdirectory under the one specified by
# the variable EXTRN_MDL_FILES_BASEDIR_LBCS.
#
#-----------------------------------------------------------------------
#
#-----------------------------------------------------------------------
#
# Source the variable definitions script.
#
#-----------------------------------------------------------------------
#
. $SCRIPT_VAR_DEFNS_FP
#
#-----------------------------------------------------------------------
#
# Source function definition files.
#
#-----------------------------------------------------------------------
#
. $USHDIR/source_funcs.sh
#
#-----------------------------------------------------------------------
#
# Source function that sets the output file names needed from the exter-
# nal model and, if relevant, the full path to the archive file on HPSS.
#
#-----------------------------------------------------------------------
#
. $USHDIR/get_extrn_mdl_file_dir_info.sh
#
#-----------------------------------------------------------------------
#
# Save current shell options (in a global array). Then set new options
# for this script/function.
#
#-----------------------------------------------------------------------
#
{ save_shell_opts; set -u -x; } > /dev/null 2>&1
#
#-----------------------------------------------------------------------
#
# Check whether output files from the specified external model (EXTRN_-
# MDL_NAME) are available on the specified cycle date and time (CDATE).
#
#-----------------------------------------------------------------------
#
case $EXTRN_MDL_NAME in

"GSMGFS")
# The transition date from the GSMGFS to the FV3GFS was 2019061212, i.e.
# this was the first official forecast with the FV3GFS. So we set the
# last CDATE for the GSMGFS to the one 6 hours before this.
CDATE_max="2019061206"
if [ "$CDATE" -gt "$CDATE_max" ]; then
print_err_msg_exit "\
Output from the specified external model (EXTRN_MDL_NAME) is not availa-
ble for the specified cycle date and time (CDATE) because the latter is
later than the last forecast date and time (CDATE_max) with this model:
EXTRN_MDL_NAME = \"${EXTRN_MDL_NAME}\"
CDATE_max = \"${CDATE_max}\"
CDATE = \"${CDATE}\"
"
fi
;;

"FV3GFS")
# The transition date from the GSMGFS to the FV3GFS was 2019061212, i.e.
# this was the first official forecast with the FV3GFS. So we set the
# first CDATE for the FV3GFS to this date and time.
CDATE_min="2019061212"
if [ "$CDATE" -lt "$CDATE_min" ]; then
print_err_msg_exit "\
Output from the specified external model (EXTRN_MDL_NAME) is not availa-
ble for the specified cycle date and time (CDATE) because the latter is
earlier than the implementation date of this model:
EXTRN_MDL_NAME = \"${EXTRN_MDL_NAME}\"
CDATE_min = \"${CDATE_min}\"
CDATE = \"${CDATE}\"
"
fi
;;

"RAPX")
# Examination of the HPSS archives shows that the RAP data goes back to
# July 01, 2015.
CDATE_min="2015070100"
if [ "$CDATE" -lt "$CDATE_min" ]; then
print_err_msg_exit "\
Output from the specified external model (EXTRN_MDL_NAME) is not availa-
ble for the specified cycle date and time (CDATE) because the latter is
earlier than the implementation date of this model:
EXTRN_MDL_NAME = \"${EXTRN_MDL_NAME}\"
CDATE_min = \"${CDATE_min}\"
CDATE = \"${CDATE}\"
"
fi
;;

"HRRRX")
# From the HRRR home page (https://rapidrefresh.noaa.gov/hrrr), the im-
# plementation of the first version of the operational HRRR was Septem-
# ber 30, 2014.
CDATE_min="2014103000"
if [ "$CDATE" -lt "$CDATE_min" ]; then
print_err_msg_exit "\
Output from the specified external model (EXTRN_MDL_NAME) is not availa-
ble for the specified cycle date and time (CDATE) because the latter is
earlier than the implementation date of this model:
EXTRN_MDL_NAME = \"${EXTRN_MDL_NAME}\"
CDATE_min = \"${CDATE_min}\"
CDATE = \"${CDATE}\"
"
fi
;;

esac
#
#-----------------------------------------------------------------------
#
# Set the parameter that determines whether we want to get analysis or
# forecast files. This depends on whether we want these files to gene-
# rate initial condition and surface field files or lateral boundary
# condition files for the FV3SAR.
#
#-----------------------------------------------------------------------
#
if [ "$ICSSURF_OR_LBCS" = "ICSSURF" ]; then
ANL_OR_FCST="ANL"
TIME_OFFSET_HRS="0"
elif [ "$ICSSURF_OR_LBCS" = "LBCS" ]; then
ANL_OR_FCST="FCST"
TIME_OFFSET_HRS="$EXTRN_MDL_LBCS_OFFSET_HRS"
else
print_err_msg_exit "\
Bad value for ICSSURF_OR_LBCS:
ICSSURF_OR_LBCS = \"$ICSSURF_OR_LBCS\"
"
fi
#
#-----------------------------------------------------------------------
#
# Create the directory EXTRN_MDL_FILES_BASEDIR_ICSSURF if it doesn't al-
# ready exist. This is the directory in which we will create a subdi-
# rectory for each cycle (i.e. for each CDATE) in which to store the
# output files from the external model .
#
#-----------------------------------------------------------------------
#
if [ "$ANL_OR_FCST" = "ANL" ]; then
mkdir_vrfy -p "$EXTRN_MDL_FILES_BASEDIR_ICSSURF"
EXTRN_MDL_FILES_DIR="$EXTRN_MDL_FILES_BASEDIR_ICSSURF/$CDATE"
elif [ "$ANL_OR_FCST" = "FCST" ]; then
mkdir_vrfy -p "$EXTRN_MDL_FILES_BASEDIR_LBCS"
EXTRN_MDL_FILES_DIR="$EXTRN_MDL_FILES_BASEDIR_LBCS/$CDATE"
fi
#
#-----------------------------------------------------------------------
#
# Create the directory specific to the current forecast (whose starting
# date and time is specified in CDATE) in which to store the external
# model files. Then change location to that directory.
#
#-----------------------------------------------------------------------
#
mkdir_vrfy -p "$EXTRN_MDL_FILES_DIR"
cd_vrfy $EXTRN_MDL_FILES_DIR || print_err_msg_exit "\
Could not change directory to EXTRN_MDL_FILES_DIR:
EXTRN_MDL_FILES_DIR = \"$EXTRN_MDL_FILES_DIR\""
#
#-----------------------------------------------------------------------
#
#
#
#-----------------------------------------------------------------------
#
EXTRN_MDL_INFO_FP="${EXTRN_MDL_FILES_DIR}/${EXTRN_MDL_INFO_FN}"

#if [ -f "${EXTRN_MDL_INFO_FP}" ]; then
# print_err_msg_exit "\
#File defining external model parameters (EXTRN_MDL_INFO_FP) already ex-
#ists in directory EXTRN_MDL_FILES_DIR:
# EXTRN_MDL_FILES_DIR = \"${EXTRN_MDL_FILES_DIR}\"
# EXTRN_MDL_INFO_FP = \"${EXTRN_MDL_INFO_FP}\"
#"
#else
get_extrn_mdl_file_dir_info \
"$EXTRN_MDL_NAME" "$ANL_OR_FCST" "$CDATE" "$TIME_OFFSET_HRS" \
"$EXTRN_MDL_INFO_FP" ${EXTRN_MDL_INFO_VAR_NAMES[@]}
#fi


if [ ! -f "${EXTRN_MDL_INFO_FP}" ]; then
print_err_msg_exit "\
File defining external model parameters (EXTRN_MDL_INFO_FP) does not ex-
ist:
EXTRN_MDL_INFO_FP = \"${EXTRN_MDL_INFO_FP}\"
"
else
. ${EXTRN_MDL_INFO_FP}
fi
#
# As a check, print out the variables and their values set by the above
# function call.
#
printf "\n"
#for output_var_name in "${output_var_names[@]}"; do
for output_var_name in "${EXTRN_MDL_INFO_VAR_NAMES[@]}"; do
tmp="$output_var_name[@]"
elems=$( printf "\"%s\" " "${!tmp}" )
printf "$output_var_name = $elems\n"
done

#------------------------------------------------------------------
# Run relevant exregional script

# Pass variables into exregional script

EXTRN_MDL_FNS_str="( "$( printf "\"%s\" " "${EXTRN_MDL_FNS[@]}" )")"

$SCRIPTSDIR/exregional_get_files_ics.sh.ecf \
EXTRN_MDL_FNS="${EXTRN_MDL_FNS_str}" \
EXTRN_MDL_FILES_SYSDIR="${EXTRN_MDL_FILES_SYSDIR}" \
EXTRN_MDL_FILES_DIR="${EXTRN_MDL_FILES_DIR}" \
EXTRN_MDL_ARCV_FP="${EXTRN_MDL_ARCV_FP}" \
EXTRN_MDL_ARCV_FILE_FMT="${EXTRN_MDL_ARCV_FILE_FMT}" \
EXTRN_MDL_ARCVREL_DIR="${EXTRN_MDL_ARCVREL_DIR}"

Loading

0 comments on commit 17e5bcc

Please sign in to comment.