Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 194 additions & 0 deletions jobs/JREGIONAL_GET_GEFS_LBCS_FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
#!/bin/bash

#
#-----------------------------------------------------------------------
#
# This script gets from the system directory the files generated by
# the external model (GEFS, specified by the variable EXTRN_MDL_NAME)
# for the lateral boundary conditions (LBCs).
# And then perform time interpolation to get the missing hourly GEFS
# files from the 3-hourly data, using wgrib2.
#
#-----------------------------------------------------------------------
#
# Source the variable definitions file and the bash utility functions.
#
#-----------------------------------------------------------------------
#
. ${GLOBAL_VAR_DEFNS_FP}
. $USHDIR/source_util_funcs.sh
#
#-----------------------------------------------------------------------
#
# Source the file defining the function that will be used to set various
# external-model-associated variables.
#
#-----------------------------------------------------------------------
#
. $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
#
#-----------------------------------------------------------------------
#
# Get the full path to the file in which this script/function is located
# (scrfunc_fp), the name of that file (scrfunc_fn), and the directory in
# which the file is located (scrfunc_dir).
#
#-----------------------------------------------------------------------
#
scrfunc_fp=$( readlink -f "${BASH_SOURCE[0]}" )
scrfunc_fn=$( basename "${scrfunc_fp}" )
scrfunc_dir=$( dirname "${scrfunc_fp}" )
#
#-----------------------------------------------------------------------
#
# Print message indicating entry into script.
#
#-----------------------------------------------------------------------
#
print_info_msg "
========================================================================
Entering script: \"${scrfunc_fn}\"
In directory: \"${scrfunc_dir}\"

This is the J-job script for the task that copies/fetches to a local
directory (from disk) the external model files from which
boundary condition files for the FV3 will be generated.
========================================================================"
#
#-----------------------------------------------------------------------
#
# Check whether the environment variable ICS_OR_LBCS is set to a valid
# value. This variable specifies whether we are getting the external
# model files for the purpose of generating initial conditions (ICs) or
# lateral boundary condtions (LBCs) for the forecast model.
#
#-----------------------------------------------------------------------
#
valid_vals_ICS_OR_LBCS=( "ICS" "LBCS" )
check_var_valid_value "ICS_OR_LBCS" "valid_vals_ICS_OR_LBCS"
#
#-----------------------------------------------------------------------
#
# Set the parameter anl_or_fcst that determines whether we want to get
# analysis or forecast files. This depends on whether we want these files
# to generate initial condition and surface field files or lateral boundary
# condition files. Also, set time_offset_hrs, which is the offset in
# hours between the current cycle's starting time and the starting time
# of the external model providing the LBCs.
#
#-----------------------------------------------------------------------
#
anl_or_fcst="FCST"
time_offset_hrs="${EXTRN_MDL_LBCS_OFFSET_HRS}"
lbs_spec_intvl_hrs="${LBC_SPEC_INTVL_HRS}"
boundary_len_hrs="${BOUNDARY_LEN}"
#
#-----------------------------------------------------------------------
#
# Set the name of and then create the directory in which to stage the
# external model files for the current cycle (if it doesn't already exist).
# Then change location to that directory.
#
#-----------------------------------------------------------------------
#
extrn_mdl_staging_dir="${CYCLE_DIR}${SLASH_ENSMEM_SUBDIR}/${EXTRN_MDL_NAME}/for_LBCS"
if [ -d "${extrn_mdl_staging_dir}" ]; then
rm -rf ${extrn_mdl_staging_dir}
fi
mkdir_vrfy -p "${extrn_mdl_staging_dir}"
cd_vrfy "${extrn_mdl_staging_dir}"
#
#-----------------------------------------------------------------------
#
# Call the function that sets various external-model-associated variables.
# See the function defintion file for the definitions of these variables.
#
#-----------------------------------------------------------------------
#
get_extrn_mdl_file_dir_info \
extrn_mdl_name="${EXTRN_MDL_NAME}" \
anl_or_fcst="${anl_or_fcst}" \
cdate_FV3LAM="${CDATE}" \
lbs_spec_intvl_hrs="${lbs_spec_intvl_hrs}" \
boundary_len_hrs="${boundary_len_hrs}"\
time_offset_hrs="${time_offset_hrs}" \
varname_extrn_mdl_memhead="${GEFS_INPUT_SUBDIR}" \
varname_extrn_mdl_cdate="extrn_mdl_cdate" \
varname_extrn_mdl_lbc_spec_fhrs="extrn_mdl_lbc_spec_fhrs" \
varname_extrn_mdl_fns_on_disk="extrn_mdl_fns_on_disk" \
varname_extrn_mdl_fns_on_disk2="extrn_mdl_fns_on_disk2" \
varname_extrn_mdl_fns_in_arcv="extrn_mdl_fns_in_arcv" \
varname_extrn_mdl_sysdir="extrn_mdl_sysdir" \
varname_extrn_mdl_sysdir2="extrn_mdl_sysdir2" \
varname_extrn_mdl_arcv_fmt="extrn_mdl_arcv_fmt" \
varname_extrn_mdl_arcv_fns="extrn_mdl_arcv_fns" \
varname_extrn_mdl_arcv_fps="extrn_mdl_arcv_fps" \
varname_extrn_mdl_arcvrel_dir="extrn_mdl_arcvrel_dir" || \
print_err_msg_exit "\
Call to function get_extrn_mdl_file_dir_info failed."
#
#-----------------------------------------------------------------------
#
# Set the directory in which to check for the external model files (which
# we refer to here as the "source" directory) to the default one set above
# for the current machine and external model.
#
#-----------------------------------------------------------------------
#
extrn_mdl_source_dir="${extrn_mdl_sysdir}"
extrn_mdl_source_dir2="${extrn_mdl_sysdir2}"
#
#-----------------------------------------------------------------------
#
# Call the ex-script for this J-job and pass to it the necessary variables.
#
#-----------------------------------------------------------------------
#
extrn_mdl_lbc_spec_fhrs_str="( "$( printf "\"%s\" " "${extrn_mdl_lbc_spec_fhrs[@]}" )")"
extrn_mdl_fns_on_disk_str="( "$( printf "\"%s\" " "${extrn_mdl_fns_on_disk[@]}" )")"
extrn_mdl_fns_on_disk_str2="( "$( printf "\"%s\" " "${extrn_mdl_fns_on_disk2[@]}" )")"
extrn_mdl_fns_in_arcv_str="( "$( printf "\"%s\" " "${extrn_mdl_fns_in_arcv[@]}" )")"

$SCRIPTSDIR/exregional_get_gefs_lbcs_files.sh \
ics_or_lbcs="${ICS_OR_LBCS}" \
use_user_staged_extrn_files="${USE_USER_STAGED_EXTRN_FILES}" \
extrn_mdl_cdate="${extrn_mdl_cdate}" \
extrn_mdl_lbc_spec_fhrs="${extrn_mdl_lbc_spec_fhrs_str}" \
extrn_mdl_fns_on_disk="${extrn_mdl_fns_on_disk_str}" \
extrn_mdl_fns_on_disk2="${extrn_mdl_fns_on_disk_str2}" \
extrn_mdl_fns_in_arcv="${extrn_mdl_fns_in_arcv_str}" \
extrn_mdl_source_dir="${extrn_mdl_source_dir}" \
extrn_mdl_source_dir2="${extrn_mdl_source_dir2}" \
extrn_mdl_staging_dir="${extrn_mdl_staging_dir}" || \
print_err_msg_exit "\
Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed."
#
#-----------------------------------------------------------------------
#
# Print exit message.
#
#-----------------------------------------------------------------------
#
print_info_msg "
========================================================================
Exiting script: \"${scrfunc_fn}\"
In directory: \"${scrfunc_dir}\"
========================================================================"
#
#-----------------------------------------------------------------------
#
# Restore the shell options saved at the beginning of this script/function.
#
#-----------------------------------------------------------------------
#
{ restore_shell_opts; } > /dev/null 2>&1

Loading