From a5eba2653e404279a04b9eea2592872aa6a73b7e Mon Sep 17 00:00:00 2001 From: Christina Holt <56881914+christinaholtNOAA@users.noreply.github.com> Date: Wed, 12 Jan 2022 18:56:02 -0600 Subject: [PATCH] Refactor supported input path handling. (#653) ## DESCRIPTION OF CHANGES: This PR is one of two in a series that addresses refactoring platform-dependence. The topic of this PR is to refactor the logic for supporting platforms with specific real-time data feeds. Here is a list of features and modifications that were made: - Apply appropriate style for functions, mainly related to white space for nested code and comments. - Make external model file offset hours configurable for analysis- and forecast-type files because sometimes we like to start a forecast from a forecast of another model. - Refactor to reduce duplication of information. - Set up filenames and paths to be specified with templates in a consistent way for every model instead of with bash logic that is different for every model's naming convention. - Remove paths that do not exist on platforms I have access to: Jet and Hera. No changes were made to the logic for input managed by USE_USER_STAGED_EXTRN_FILES or COMINGgfs for NCO mode, although it could make sense to re-assess the NCO mode handling at a later date. I plan to go through and "review" the code to lead reviewers through this one since it bit of change. It may be helpful to view it using GitHub's ignore whitespace feature. ## TESTS CONDUCTED: Test cases using the WE2E test on Hera; see PR for full list. A test case for the same forecast configuration using known paths on Hera to exercise the new code. I checked that arrays were consistent, that the script exits in a sane manner when files are not available on disk or HPSS, and that I haven't broken anything with the way files are handled through the "user specified" mechanism necessary for the test framework. ## ISSUE (optional): This work is an incremental change in support of Issue #618 ## CONTRIBUTORS (optional): @christopherwharrop-noaa @venitahagerty @robgonzalezpita --- jobs/JREGIONAL_GET_EXTRN_MDL_FILES | 25 +- ush/config_defaults.sh | 20 + ush/get_extrn_mdl_file_dir_info.sh | 1023 ++++++++++------------------ ush/set_extrn_mdl_params.sh | 384 +++-------- 4 files changed, 477 insertions(+), 975 deletions(-) diff --git a/jobs/JREGIONAL_GET_EXTRN_MDL_FILES b/jobs/JREGIONAL_GET_EXTRN_MDL_FILES index bfe2d7bcea..a452062c5f 100755 --- a/jobs/JREGIONAL_GET_EXTRN_MDL_FILES +++ b/jobs/JREGIONAL_GET_EXTRN_MDL_FILES @@ -167,28 +167,29 @@ 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. +# Set parameters for grabbing either the initial conditions from analysis or +# forecast files of external models, or the lateral boundary conditions +# from external models. The script has been called to do the work for +# one or the other. # #----------------------------------------------------------------------- # if [ "${ICS_OR_LBCS}" = "ICS" ]; then - anl_or_fcst="ANL" - time_offset_hrs="0" + if [ ${EXTRN_MDL_ICS_OFFSET_HRS} -eq 0 ] ; then + anl_or_fcst="ANL" + time_offset_hrs=0 + else + anl_or_fcst="FCST" + time_offset_hrs=${EXTRN_MDL_ICS_OFFSET_HRS:-0} + fi elif [ "${ICS_OR_LBCS}" = "LBCS" ]; then anl_or_fcst="FCST" - time_offset_hrs="${EXTRN_MDL_LBCS_OFFSET_HRS}" + time_offset_hrs=${EXTRN_MDL_LBCS_OFFSET_HRS:-0} fi # #----------------------------------------------------------------------- # -# 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. +# Create the directory where the exetrnal model files should be stored # #----------------------------------------------------------------------- # diff --git a/ush/config_defaults.sh b/ush/config_defaults.sh index c3090cc8bc..21d6096a16 100644 --- a/ush/config_defaults.sh +++ b/ush/config_defaults.sh @@ -604,6 +604,24 @@ NDAS_OBS_DIR="/path/to/observation-directory/ndas/proc" # data availble at least every 6 hours. It is up to the user to ensure # that this is the case. # +# EXTRN_MDL_ICS_OFFSET_HRS: +# Users may wish to start a forecast from a forecast of a previous cycle +# of an external model. This variable sets the number of hours earlier +# the external model started than when the FV3 forecast configured here +# should start. For example, the forecast should start from a 6 hour +# forecast of the GFS, then EXTRN_MDL_ICS_OFFSET_HRS=6. + +# EXTRN_MDL_LBCS_OFFSET_HRS: +# Users may wish to use lateral boundary conditions from a forecast that +# was started earlier than the initial time for the FV3 forecast +# configured here. This variable sets the number of hours earlier +# the external model started than when the FV3 forecast configured here +# should start. For example, the forecast should use lateral boundary +# conditions from the GFS started 6 hours earlier, then +# EXTRN_MDL_LBCS_OFFSET_HRS=6. +# Note: the default value is model-dependent and set in +# set_extrn_mdl_params.sh +# # FV3GFS_FILE_FMT_ICS: # If using the FV3GFS model as the source of the ICs (i.e. if EXTRN_MDL_NAME_ICS # is set to "FV3GFS"), this variable specifies the format of the model @@ -619,6 +637,8 @@ NDAS_OBS_DIR="/path/to/observation-directory/ndas/proc" EXTRN_MDL_NAME_ICS="FV3GFS" EXTRN_MDL_NAME_LBCS="FV3GFS" LBC_SPEC_INTVL_HRS="6" +EXTRN_MDL_ICS_OFFSET_HRS="0" +EXTRN_MDL_LBCS_OFFSET_HRS="" FV3GFS_FILE_FMT_ICS="nemsio" FV3GFS_FILE_FMT_LBCS="nemsio" # diff --git a/ush/get_extrn_mdl_file_dir_info.sh b/ush/get_extrn_mdl_file_dir_info.sh index ff7d1bfda1..fdab7dad41 100755 --- a/ush/get_extrn_mdl_file_dir_info.sh +++ b/ush/get_extrn_mdl_file_dir_info.sh @@ -18,83 +18,10 @@ # #----------------------------------------------------------------------- # -function get_extrn_mdl_file_dir_info() { -# -#----------------------------------------------------------------------- -# -# 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). -# -#----------------------------------------------------------------------- -# - local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) - local scrfunc_fn=$( basename "${scrfunc_fp}" ) - local scrfunc_dir=$( dirname "${scrfunc_fp}" ) -# -#----------------------------------------------------------------------- -# -# Get the name of this function. -# -#----------------------------------------------------------------------- -# - local func_name="${FUNCNAME[0]}" -# -#----------------------------------------------------------------------- -# -# Specify the set of valid argument names for this script/function. Then -# process the arguments provided to this script/function (which should -# consist of a set of name-value pairs of the form arg1="value1", etc). -# -#----------------------------------------------------------------------- -# - local valid_args=( \ - "extrn_mdl_name" \ - "anl_or_fcst" \ - "cdate_FV3LAM" \ - "time_offset_hrs" \ - "varname_extrn_mdl_cdate" \ - "varname_extrn_mdl_lbc_spec_fhrs" \ - "varname_extrn_mdl_fns_on_disk" \ - "varname_extrn_mdl_fns_in_arcv" \ - "varname_extrn_mdl_sysdir" \ - "varname_extrn_mdl_arcv_fmt" \ - "varname_extrn_mdl_arcv_fns" \ - "varname_extrn_mdl_arcv_fps" \ - "varname_extrn_mdl_arcvrel_dir" \ - ) - process_args valid_args "$@" -# -#----------------------------------------------------------------------- -# -# For debugging purposes, print out values of arguments passed to this -# script/function. Note that these will be printed out only if VERBOSE -# is set to TRUE. -# -#----------------------------------------------------------------------- -# - print_input_args valid_args -# -#----------------------------------------------------------------------- -# -# Check arguments. -# -#----------------------------------------------------------------------- -# -if [ 0 = 1 ]; then - if [ "$#" -ne "13" ]; then +usage () { - print_err_msg_exit " +echo " Incorrect number of arguments specified: Function name: \"${func_name}\" @@ -117,7 +44,7 @@ Usage: varname_extrn_mdl_arcvrel_dir where the arguments are defined as follows: - + extrn_mdl_name: Name of the external model, i.e. the name of the model providing the fields from which files containing initial conditions, surface fields, @@ -160,9 +87,13 @@ where the arguments are defined as follows: boundary condition (LBC) output files are obtained from the external model (and will be used to update the LBCs of the FV3-LAM). - varname_extrn_mdl_fns: - Name of the global variable that will contain the names of the exter- - nal model output files. + varname_extrn_mdl_fns_on_disk: + Name of the global variable that will contain the expected names of + the external model output files on disk. + + varname_extrn_mdl_fns_in_arcv: + Name of the global variable that will contain the expected names of + the external model output files on NOAA HPSS. varname_extrn_mdl_sysdir: Name of the global variable that will contain the system directory in @@ -187,32 +118,8 @@ where the arguments are defined as follows: rectory, i.e. the directory \"inside\" the archive file in which the ex- ternal model output files may be stored. " +} - fi - -fi - - -# -#----------------------------------------------------------------------- -# -# Declare additional local variables. -# -#----------------------------------------------------------------------- -# - local yyyy mm dd hh mn yyyymmdd \ - lbc_spec_fhrs i num_fhrs \ - yy ddd fcst_hhh fcst_hh fcst_mn \ - prefix suffix fns fns_on_disk fns_in_arcv \ - sysbasedir sysdir \ - arcv_dir arcv_fmt arcv_fns arcv_fps arcvrel_dir -# -#----------------------------------------------------------------------- -# -# Declare local function to avoid repetition -# -#----------------------------------------------------------------------- -# function quit_unless_user_spec_data() { if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then print_err_msg_exit "\ @@ -222,236 +129,195 @@ has not been specified for this external model and machine combination: MACHINE = \"$MACHINE\"" fi } -# -#----------------------------------------------------------------------- -# -# Check input variables for valid values. -# -#----------------------------------------------------------------------- -# + +function get_extrn_mdl_file_dir_info() { + + { save_shell_opts; set -u +x; } > /dev/null 2>&1 + + local func_name="${FUNCNAME[0]}" + # + #----------------------------------------------------------------------- + # + # Specify the set of valid argument names for this script/function. Then + # process the arguments provided to this script/function (which should + # consist of a set of name-value pairs of the form arg1="value1", etc). + # + #----------------------------------------------------------------------- + # + local valid_args=( \ + "extrn_mdl_name" \ + "anl_or_fcst" \ + "cdate_FV3LAM" \ + "time_offset_hrs" \ + "varname_extrn_mdl_cdate" \ + "varname_extrn_mdl_lbc_spec_fhrs" \ + "varname_extrn_mdl_fns_on_disk" \ + "varname_extrn_mdl_fns_in_arcv" \ + "varname_extrn_mdl_sysdir" \ + "varname_extrn_mdl_arcv_fmt" \ + "varname_extrn_mdl_arcv_fns" \ + "varname_extrn_mdl_arcv_fps" \ + "varname_extrn_mdl_arcvrel_dir" \ + ) + process_args valid_args "$@" + + if [ "$#" -ne "13" ]; then + print_err_msg_exit $(usage) + fi + + # + #----------------------------------------------------------------------- + # + # For debugging purposes, print out values of arguments passed to this + # script/function. Note that these will be printed out only if VERBOSE + # is set to TRUE. + # + #----------------------------------------------------------------------- + # + print_input_args valid_args + + # + #----------------------------------------------------------------------- + # + # Declare additional local variables. + # + #----------------------------------------------------------------------- + # + local yyyy yy mm dd hh mn yyyymmdd ddd \ + lbc_spec_fhrs i num_fhrs \ + fcst_hhh fcst_hh fcst_mn \ + prefix suffix fns fns_on_disk fns_in_arcv \ + sysbasedir sysdir \ + arcv_dir arcv_fmt arcv_fns arcv_fps arcvrel_dir + anl_or_fcst=$(echo_uppercase $anl_or_fcst) valid_vals_anl_or_fcst=( "ANL" "FCST" ) check_var_valid_value "anl_or_fcst" "valid_vals_anl_or_fcst" -# -#----------------------------------------------------------------------- -# -# Extract from cdate_FV3LAM the starting year, month, day, and hour of -# the FV3-LAM cycle. Then subtract the temporal offset specified in -# time_offset_hrs (assumed to be given in units of hours) from cdate_FV3LAM -# to obtain the starting date and time of the external model, express the -# result in YYYYMMDDHH format, and save it in cdate. This is the starting -# time of the external model forecast. -# -#----------------------------------------------------------------------- -# - yyyy=${cdate_FV3LAM:0:4} - mm=${cdate_FV3LAM:4:2} - dd=${cdate_FV3LAM:6:2} + # + #----------------------------------------------------------------------- + # + # Set cdate to the start time for the external model being used. + # + #----------------------------------------------------------------------- + # hh=${cdate_FV3LAM:8:2} yyyymmdd=${cdate_FV3LAM:0:8} + # Adjust time for offset cdate=$( $DATE_UTIL --utc --date "${yyyymmdd} ${hh} UTC - ${time_offset_hrs} hours" "+%Y%m%d%H" ) -# -#----------------------------------------------------------------------- -# -# Extract from cdate the starting year, month, day, and hour of the external -# model forecast. Also, set the starting minute to "00" and get the date -# without the time-of-day. These are needed below in setting various -# directory and file names. -# -#----------------------------------------------------------------------- -# + yyyy=${cdate:0:4} + yy=${yyyy:2:4} mm=${cdate:4:2} dd=${cdate:6:2} hh=${cdate:8:2} mn="00" yyyymmdd=${cdate:0:8} -# -#----------------------------------------------------------------------- -# -# Initialize lbc_spec_fhrs to an empty array. Then, if considering a -# forecast, reset lbc_spec_fhrs to the array of forecast hours at which -# the lateral boundary conditions (LBCs) are to be updated, starting with -# the 2nd such time (i.e. the one having array index 1). We do not include -# the first hour (hour 0) because at this initial time, the LBCs are -# obtained from the analysis fields provided by the external model (as -# opposed to a forecast field). -# -#----------------------------------------------------------------------- -# + # Julian day -- not 3 digit day of month + ddd=$( $DATE_UTIL --utc --date "${yyyy}-${mm}-${dd} ${hh}:${mn} UTC" "+%j" ) + # + #----------------------------------------------------------------------- + # + # Initialize lbc_spec_fhrs array. Skip the initial time, since it is + # handled separately. + # + #----------------------------------------------------------------------- + # lbc_spec_fhrs=( "" ) if [ "${anl_or_fcst}" = "FCST" ]; then lbc_spec_fhrs=( "${LBC_SPEC_FCST_HRS[@]}" ) -# -# Add the temporal offset specified in time_offset_hrs (assumed to be in -# units of hours) to the the array of LBC update forecast hours to make -# up for shifting the starting hour back in time. After this addition, -# lbc_spec_fhrs will contain the LBC update forecast hours relative to -# the start time of the external model run. -# + num_fhrs=${#lbc_spec_fhrs[@]} for (( i=0; i<=$((num_fhrs-1)); i++ )); do + # Add in offset to account for shift in initial time lbc_spec_fhrs[$i]=$(( ${lbc_spec_fhrs[$i]} + time_offset_hrs )) done fi -# -#----------------------------------------------------------------------- -# -# Set additional parameters needed in forming the names of the external -# model files only under certain circumstances. -# -#----------------------------------------------------------------------- -# - if [ "${extrn_mdl_name}" = "RAP" ] || \ - [ "${extrn_mdl_name}" = "HRRR" ] || \ - [ "${extrn_mdl_name}" = "NAM" ] || \ - [ "${extrn_mdl_name}" = "FV3GFS" -a "${MACHINE}" = "JET" ]; then -# -# Get the Julian day-of-year of the starting date and time of the exter- -# nal model forecast. -# - ddd=$( $DATE_UTIL --utc --date "${yyyy}-${mm}-${dd} ${hh}:${mn} UTC" "+%j" ) -# -# Get the last two digits of the year of the starting date and time of -# the external model forecast. -# - yy=${yyyy:2:4} + # + #----------------------------------------------------------------------- + # + # The model may be started with a variety of file types from FV3GFS. + # Set that file type now + # + #----------------------------------------------------------------------- + # - fi -# -#----------------------------------------------------------------------- -# -# Set the external model output file names that must be obtained (from -# disk if available, otherwise from HPSS). -# -#----------------------------------------------------------------------- -# if [ "${anl_or_fcst}" = "ANL" ]; then fv3gfs_file_fmt="${FV3GFS_FILE_FMT_ICS}" elif [ "${anl_or_fcst}" = "FCST" ]; then fv3gfs_file_fmt="${FV3GFS_FILE_FMT_LBCS}" fi + # + #----------------------------------------------------------------------- + # + # Generate an array of file names expected from the external model + # Assume that filenames in archive and on disk are the same, unless + # otherwise specified (primarily on Jet). + # + #----------------------------------------------------------------------- + # + declare -a fns_on_disk + declare -a fns_in_arcv case "${anl_or_fcst}" in -# -#----------------------------------------------------------------------- -# -# Consider analysis files (possibly including surface files). -# -#----------------------------------------------------------------------- -# - "ANL") - - fcst_hh="00" - fcst_mn="00" - - case "${extrn_mdl_name}" in - - "GSMGFS") -# fns=( "atm" "sfc" "nst" ) - fns=( "atm" "sfc" ) - prefix="gfs.t${hh}z." - fns=( "${fns[@]/#/$prefix}" ) - suffix="anl.nemsio" - fns_on_disk=( "${fns[@]/%/$suffix}" ) - fns_in_arcv=( "${fns[@]/%/$suffix}" ) - ;; - "FV3GFS") - - if [ "${fv3gfs_file_fmt}" = "nemsio" ]; then - - fns=( "atm" "sfc" ) - suffix="anl.nemsio" - fns=( "${fns[@]/%/$suffix}" ) - -# Set names of external files if searching on disk. - if [ "${MACHINE}" = "JET" ]; then - prefix="${yy}${ddd}${hh}00.gfs.t${hh}z." - else - prefix="gfs.t${hh}z." + "ANL") + + fcst_hh="00" + fcst_mn="00" + + case "${extrn_mdl_name}" in + + "GSMGFS") + fns_in_arcv=("gfs.t${hh}z.atmanl.nemsio" "gfs.t${hh}z.sfcanl.nemsio") + ;; + + "FV3GFS") + case "${fv3gfs_file_fmt}" in + "nemsio") + fns_in_arcv=("gfs.t${hh}z.atmanl.nemsio" "gfs.t${hh}z.sfcanl.nemsio") + + # File names are prefixed with a date time on Jet + if [ "${MACHINE}" = "JET" ]; then + prefix="${yy}${ddd}${hh}00" + fns_on_disk=( ${fns_in_arcv[@]/#/$prefix}) + fi + ;; + "grib2") + fns_in_arcv=( "gfs.t${hh}z.pgrb2.0p25.f000" ) + ;; + "netcdf") + fns_in_arcv=("gfs.t${hh}z.atmanl.nc" "gfs.t${hh}z.sfcanl.nc") + # File names are prefixed with a date time on Jet + if [ "${MACHINE}" = "JET" ]; then + prefix="${yy}${ddd}${hh}00" + fns_on_disk=( ${fns_in_arcv[@]/#/$prefix}) + fi + ;; + esac + ;; + + "RAP") + ;& # Fall through. RAP and HRRR follow same naming rules + + "HRRR") + fns_in_arcv=( "${yy}${ddd}${hh}${mn}${fcst_hh}${fcst_mn}" ) + if [ "${MACHINE}" = "JET" ]; then + fns_on_disk=( "${yy}${ddd}${hh}${mn}${fcst_mn}${fcst_hh}${fcst_mn}" ) fi - fns_on_disk=( "${fns[@]/#/$prefix}" ) - -# Set names of external files if searching in an archive file, e.g. from -# HPSS. - prefix="gfs.t${hh}z." - fns_in_arcv=( "${fns[@]/#/$prefix}" ) - - elif [ "${fv3gfs_file_fmt}" = "grib2" ]; then - -# GSK 12/16/2019: -# Turns out that the .f000 file contains certain necessary fields that -# are not in the .anl file, so switch to the former. -# fns=( "gfs.t${hh}z.pgrb2.0p25.anl" ) # Get only 0.25 degree files for now. -# fns=( "gfs.t${hh}z.pgrb2.0p25.f000" ) # Get only 0.25 degree files for now. - fns_on_disk=( "gfs.t${hh}z.pgrb2.0p25.f000" ) # Get only 0.25 degree files for now. - fns_in_arcv=( "gfs.t${hh}z.pgrb2.0p25.f000" ) # Get only 0.25 degree files for now. - - elif [ "${fv3gfs_file_fmt}" = "netcdf" ]; then + ;; - fns=( "atm" "sfc" ) - suffix="anl.nc" - fns=( "${fns[@]/%/$suffix}" ) + "NAM") + fns=( "" ) + fns_in_arcv=( "nam.t${hh}z.bgrdsf${fcst_hh}.tm00" ) + ;; -# Set names of external files if searching on disk. - if [ "${MACHINE}" = "JET" ]; then - prefix="${yy}${ddd}${hh}00.gfs.t${hh}z." - else - prefix="gfs.t${hh}z." - fi - fns_on_disk=( "${fns[@]/#/$prefix}" ) - -# Set names of external files if searching in an archive file, e.g. from -# HPSS. - prefix="gfs.t${hh}z." - fns_in_arcv=( "${fns[@]/#/$prefix}" ) - - fi - ;; - - "RAP") -# -# Note that this is GSL RAPX data, not operational NCEP RAP data. An option for the latter -# may be added in the future. -# - if [ "${MACHINE}" = "JET" ]; then - fns_on_disk=( "wrfnat_130_${fcst_hh}.grib2" ) - else - fns_on_disk=( "${yy}${ddd}${hh}${mn}${fcst_hh}${fcst_mn}" ) - fi - fns_in_arcv=( "${yy}${ddd}${hh}${mn}${fcst_hh}${fcst_mn}" ) - ;; - - "HRRR") -# -# Note that this is GSL HRRRX data, not operational NCEP HRRR data. An option for the latter -# may be added in the future. -# - if [ "${MACHINE}" = "JET" ]; then - fns_on_disk=( "wrfnat_hrconus_${fcst_hh}.grib2" ) - else - fns_on_disk=( "${yy}${ddd}${hh}${mn}${fcst_hh}${fcst_mn}" ) - fi - fns_in_arcv=( "${yy}${ddd}${hh}${mn}${fcst_hh}${fcst_mn}" ) - ;; - - "NAM") - fns=( "" ) - prefix="nam.t${hh}z.bgrdsfi${hh}" - fns=( "${fns[@]/#/$prefix}" ) - suffix=".tm${hh}" - fns_on_disk=( "${fns[@]/%/$suffix}" ) - fns_in_arcv=( "${fns[@]/%/$suffix}" ) - ;; - - *) - if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then - print_err_msg_exit "\ + *) + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The external model file names (either on disk or in archive files) have not yet been specified for this combination of external model (extrn_mdl_name) and analysis or forecast (anl_or_fcst): @@ -460,343 +326,182 @@ and analysis or forecast (anl_or_fcst): fi ;; - esac + esac # End external model case for ANL files ;; -# -#----------------------------------------------------------------------- -# -# Consider forecast files. -# -#----------------------------------------------------------------------- -# - "FCST") - - fcst_mn="00" - - case "${extrn_mdl_name}" in - "GSMGFS") + "FCST") + fcst_mn="00" fcst_hhh=( $( printf "%03d " "${lbc_spec_fhrs[@]}" ) ) - prefix="gfs.t${hh}z.atmf" - fns=( "${fcst_hhh[@]/#/$prefix}" ) - suffix=".nemsio" - fns_on_disk=( "${fns[@]/%/$suffix}" ) - fns_in_arcv=( "${fns[@]/%/$suffix}" ) - ;; - - "FV3GFS") - - if [ "${fv3gfs_file_fmt}" = "nemsio" ]; then - - fcst_hhh=( $( printf "%03d " "${lbc_spec_fhrs[@]}" ) ) - suffix=".nemsio" - fns=( "${fcst_hhh[@]/%/$suffix}" ) + fcst_hh=( $( printf "%02d " "${lbc_spec_fhrs[@]}" ) ) - if [ "${MACHINE}" = "JET" ]; then - prefix="${yy}${ddd}${hh}00.gfs.t${hh}z.atmf" - else - prefix="gfs.t${hh}z.atmf" + case "${extrn_mdl_name}" in + + "GSMGFS") + fn_tmpl="gfs.t${hh}z.atmfFHR3.nemsio" + ;; + + "FV3GFS") + + if [ "${fv3gfs_file_fmt}" = "nemsio" ]; then + fn_tmpl="gfs.t${hh}z.atmfFHR3.nemsio" + if [ "${MACHINE}" = "JET" ]; then + disk_tmpl="${yy}${ddd}${hh}00.gfs.t${hh}z.atmfFHR3.nemsio" + for fhr in ${fcst_hhh[@]} ; do + fns_on_disk+=(${disk_tmpl/FHR3/$fhr}) + done + fi + elif [ "${fv3gfs_file_fmt}" = "grib2" ]; then + fn_tmpl="gfs.t${hh}z.pgrb2.0p25.fFHR3" + elif [ "${fv3gfs_file_fmt}" = "netcdf" ]; then + fn_tmpl="gfs.t${hh}z.atmfFHR3.nc" + if [ "${MACHINE}" = "JET" ]; then + disk_tmpl="${yy}${ddd}${hh}00.gfs.t${hh}z.atmfFHR3.nc" + for fhr in ${fcst_hhh[@]} ; do + fns_on_disk+=(${disk_tmpl/FHR3/$fhr}) + done + fi fi - fns_on_disk=( "${fns[@]/#/$prefix}" ) - - prefix="gfs.t${hh}z.atmf" - fns_in_arcv=( "${fns[@]/#/$prefix}" ) - - elif [ "${fv3gfs_file_fmt}" = "grib2" ]; then - - fcst_hhh=( $( printf "%03d " "${lbc_spec_fhrs[@]}" ) ) - prefix="gfs.t${hh}z.pgrb2.0p25.f" - fns_on_disk=( "${fcst_hhh[@]/#/$prefix}" ) - fns_in_arcv=( "${fcst_hhh[@]/#/$prefix}" ) - - elif [ "${fv3gfs_file_fmt}" = "netcdf" ]; then - - fcst_hhh=( $( printf "%03d " "${lbc_spec_fhrs[@]}" ) ) - suffix=".nc" - fns=( "${fcst_hhh[@]/%/$suffix}" ) - - if [ "${MACHINE}" = "JET" ]; then - prefix="${yy}${ddd}${hh}00.gfs.t${hh}z.atmf" - else - prefix="gfs.t${hh}z.atmf" + ;; + + "RAP") + ;& # Fall through since RAP and HRRR are named the same + + "HRRR") + fn_tmpl="${yy}${ddd}${hh}00FHR200" + if [ "${MACHINE}" = "JET" ]; then + disk_tmpl="${yy}${ddd}${hh}0000FHR2" + for fhr in ${fcst_hhh[@]} ; do + fns_on_disk+=(${disk_tmpl/FHR3/$fhr}) + done fi - fns_on_disk=( "${fns[@]/#/$prefix}" ) - - prefix="gfs.t${hh}z.atmf" - fns_in_arcv=( "${fns[@]/#/$prefix}" ) - - fi - ;; - - "RAP") -# -# Note that this is GSL RAPX data, not operational NCEP RAP data. An option for the latter -# may be added in the future. -# - fcst_hh=( $( printf "%02d " "${lbc_spec_fhrs[@]}" ) ) - - if [ "${MACHINE}" = "JET" ]; then - prefix="wrfnat_130_" - suffix=".grib2" - else - prefix="${yy}${ddd}${hh}${mn}" - suffix="${fcst_mn}" - fi - fns_on_disk=( "${fcst_hh[@]/#/$prefix}" ) - fns_on_disk=( "${fns_on_disk[@]/%/$suffix}" ) - - prefix="${yy}${ddd}${hh}${mn}" - fns_in_arcv=( "${fcst_hh[@]/#/$prefix}" ) - suffix="${fcst_mn}" - fns_in_arcv=( "${fns_in_arcv[@]/%/$suffix}" ) - ;; - - "HRRR") -# -# Note that this is GSL HRRRX data, not operational NCEP HRRR data. An option for the latter -# may be added in the future. -# - fcst_hh=( $( printf "%02d " "${lbc_spec_fhrs[@]}" ) ) - - if [ "${MACHINE}" = "JET" ]; then - prefix="wrfnat_hrconus_" - suffix=".grib2" - else - prefix="${yy}${ddd}${hh}${mn}" - suffix="${fcst_mn}" - fi - fns_on_disk=( "${fcst_hh[@]/#/$prefix}" ) - fns_on_disk=( "${fns_on_disk[@]/%/$suffix}" ) + ;; - prefix="${yy}${ddd}${hh}${mn}" - fns_in_arcv=( "${fcst_hh[@]/#/$prefix}" ) - suffix="${fcst_mn}" - fns_in_arcv=( "${fns_in_arcv[@]/%/$suffix}" ) - ;; + "NAM") + fn_tmpl="nam.t${hh}z.bgrdsfFHR3" + ;; - "NAM") - fcst_hhh=( $( printf "%03d " "${lbc_spec_fhrs[@]}" ) ) - prefix="nam.t${hh}z.bgrdsf" - fns=( "${fcst_hhh[@]/#/$prefix}" ) - suffix="" - fns_on_disk=( "${fns[@]/%/$suffix}" ) - fns_in_arcv=( "${fns[@]/%/$suffix}" ) - ;; - - *) - if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then - print_err_msg_exit "\ + *) + if [ "${USE_USER_STAGED_EXTRN_FILES}" != "TRUE" ]; then + print_err_msg_exit "\ The external model file names have not yet been specified for this com- bination of external model (extrn_mdl_name) and analysis or forecast (anl_or_fcst): extrn_mdl_name = \"${extrn_mdl_name}\" anl_or_fcst = \"${anl_or_fcst}\"" - fi - ;; + fi + ;; - esac + esac # End external model case for FCST files ;; + esac # End ANL FCST case + + # + # Expand the archive file names for all forecast hours + # + if [ ${anl_or_fcst} = FCST ] ; then + if [[ $fn_tmpl =~ FHR3 ]] ; then + fhrs=( $( printf "%03d " "${lbc_spec_fhrs[@]}" ) ) + tmpl=FHR3 + elif [[ ${fn_tmpl} =~ FHR2 ]] ; then + fhrs=( $( printf "%02d " "${lbc_spec_fhrs[@]}" ) ) + tmpl=FHR2 + else + print_err_msg_exit "\ + Forecast file name templates are expected to contain a template + string, either FHR2 or FHR3" + fi + for fhr in ${fhrs[@]}; do + fns_in_arcv+=(${fn_tmpl/$tmpl/$fhr}) + done + fi - esac -# -#----------------------------------------------------------------------- -# -# Set the system directory (i.e. a directory on disk) in which the external -# model output files for the specified cycle date (cdate) may be located. -# Note that this will be used by the calling script only if the output -# files for the specified cdate actually exist at this location. Otherwise, -# the files will be searched for on the mass store (HPSS). -# -#----------------------------------------------------------------------- -# + # Make sure all filenames variables are set. + if [ -z $fns_in_arcv ] ; then + print_err_msg_exit "\ + The script has not set \$fns_in_arcv properly" + fi + + if [ -z ${fns_on_disk:-} ] ; then + fns_on_disk=(${fns_in_arcv[@]}) + fi + # + #----------------------------------------------------------------------- + # + # Set the system directory (i.e. a directory on disk) in which the external + # model output files for the specified cycle date (cdate) may be located. + # Note that this will be used by the calling script only if the output + # files for the specified cdate actually exist at this location. Otherwise, + # the files will be searched for on the mass store (HPSS). + # + #----------------------------------------------------------------------- + # if [ "${anl_or_fcst}" = "ANL" ]; then - sysbasedir="${EXTRN_MDL_SYSBASEDIR_ICS}" + sysbasedir=${EXTRN_MDL_SYSBASEDIR_ICS} elif [ "${anl_or_fcst}" = "FCST" ]; then - sysbasedir="${EXTRN_MDL_SYSBASEDIR_LBCS}" + sysbasedir=${EXTRN_MDL_SYSBASEDIR_LBCS} fi - sysdir="" - case "${extrn_mdl_name}" in - -# -# It is not clear which, if any, systems the (old) spectral GFS model is -# available on, so set sysdir for this external model to a null string. -# - "GSMGFS") - case "$MACHINE" in - "WCOSS_CRAY") - sysdir="" - ;; - "WCOSS_DELL_P3") - sysdir="" - ;; - "HERA") - sysdir="" - ;; - "ORION") - sysdir="$sysbasedir" - ;; - "JET") - sysdir="" - ;; - "ODIN") - sysdir="$sysbasedir" - ;; - "CHEYENNE") - sysdir="" - ;; - "STAMPEDE") - sysdir="$sysbasedir" - ;; - *) - quit_unless_user_spec_data - ;; - esac - ;; - - - "FV3GFS") - case "$MACHINE" in - "WCOSS_CRAY") - sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}/atmos" - ;; - "WCOSS_DELL_P3") - sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}/atmos" - ;; - "HERA") - sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}/atmos" - ;; - "ORION") - sysdir="$sysbasedir" - ;; - "JET") - sysdir="$sysbasedir" - ;; - "ODIN") - sysdir="$sysbasedir/${yyyymmdd}" - ;; - "CHEYENNE") - sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}" - ;; - "STAMPEDE") - sysdir="$sysbasedir" - ;; - *) - quit_unless_user_spec_data - ;; - esac - ;; - - - "RAP") - case "$MACHINE" in - "WCOSS_CRAY") - sysdir="$sysbasedir" - ;; - "WCOSS_DELL_P3") - sysdir="$sysbasedir" - ;; - "HERA") - sysdir="$sysbasedir" - ;; - "ORION") - sysdir="$sysbasedir" - ;; - "JET") - sysdir="$sysbasedir/${yyyymmdd}${hh}/postprd" - ;; - "ODIN") - sysdir="$sysbasedir" - ;; - "CHEYENNE") - sysdir="$sysbasedir" - ;; - *) - quit_unless_user_spec_data - ;; - esac - ;; + sysdir=$sysbasedir + # Use the basedir unless otherwise specified for special platform + # cases below. + if [ -n "${sysbasedir}" ] ; then + case "${extrn_mdl_name}" in + "FV3GFS") + case "$MACHINE" in + "WCOSS_CRAY") + sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}/atmos" + ;; + "WCOSS_DELL_P3") + sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}/atmos" + ;; + "HERA") + sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}/atmos" + ;; + "ODIN") + sysdir="$sysbasedir/${yyyymmdd}" + ;; + "CHEYENNE") + sysdir="$sysbasedir/gfs.${yyyymmdd}/${hh}" + ;; + esac + ;; + + "RAP") + case "$MACHINE" in + "JET") + sysdir="$sysbasedir/${yyyymmdd}${hh}/postprd" + ;; + esac + ;; + + "HRRR") + case "$MACHINE" in + "JET") + sysdir="$sysbasedir/${yyyymmdd}${hh}/postprd" + ;; + esac + ;; - "HRRR") - case "$MACHINE" in - "WCOSS_CRAY") - sysdir="$sysbasedir" - ;; - "WCOSS_DELL_P3") - sysdir="$sysbasedir" - ;; - "HERA") - sysdir="$sysbasedir" - ;; - "ORION") - sysdir="$sysbasedir" - ;; - "JET") - sysdir="$sysbasedir/${yyyymmdd}${hh}/postprd" - ;; - "ODIN") - sysdir="$sysbasedir" - ;; - "CHEYENNE") - sysdir="$sysbasedir" - ;; - *) - quit_unless_user_spec_data - ;; esac - ;; - - "NAM") - case "$MACHINE" in - "WCOSS_CRAY") - sysdir="$sysbasedir" - ;; - "WCOSS_DELL_P3") - sysdir="$sysbasedir" - ;; - "HERA") - sysdir="$sysbasedir" - ;; - "ORION") - sysdir="$sysbasedir" - ;; - "JET") - sysdir="$sysbasedir" - ;; - "ODIN") - sysdir="$sysbasedir" - ;; - "CHEYENNE") - sysdir="$sysbasedir" - ;; - *) - quit_unless_user_spec_data - ;; - esac - ;; - - - *) - quit_unless_user_spec_data - esac -# -#----------------------------------------------------------------------- -# -# Set parameters associated with the mass store (HPSS) for the specified -# cycle date (cdate). These consist of: -# -# 1) The type of the archive file (e.g. tar, zip, etc). -# 2) The name of the archive file. -# 3) The full path in HPSS to the archive file. -# 4) The relative directory in the archive file in which the model output -# files are located. -# -# Note that these will be used by the calling script only if the archive -# file for the specified cdate actually exists on HPSS. -# -#----------------------------------------------------------------------- -# + fi + # + #----------------------------------------------------------------------- + # + # Set parameters associated with the mass store (HPSS) for the specified + # cycle date (cdate). These consist of: + # + # 1) The type of the archive file (e.g. tar, zip, etc). + # 2) The name of the archive file. + # 3) The full path in HPSS to the archive file. + # 4) The relative directory in the archive file in which the model output + # files are located. + # + # Note that these will be used by the calling script only if the archive + # file for the specified cdate actually exists on HPSS. + # + #----------------------------------------------------------------------- + # case "${extrn_mdl_name}" in "GSMGFS") @@ -890,30 +595,29 @@ bination of external model (extrn_mdl_name) and analysis or forecast "RAP") -# -# Note that this is GSL RAPX data, not operational NCEP RAP data. An option for the latter -# may be added in the future. -# -# The zip archive files for RAPX are named such that the forecast files -# for odd-numbered starting hours (e.g. 01, 03, ..., 23) are stored -# together with the forecast files for the corresponding preceding even- -# numbered starting hours (e.g. 00, 02, ..., 22, respectively), in an -# archive file whose name contains only the even-numbered hour. Thus, -# in forming the name of the archive file, if the starting hour (hh) is -# odd, we reduce it by one to get the corresponding even-numbered hour -# and use that to form the archive file name. -# + # + # Note that this is GSL RAPX data, not operational NCEP RAP data. + # An option for the latter may be added in the future. + # + # The zip archive files for RAPX are named such that the forecast + # files for odd-numbered starting hours (e.g. 01, 03, ..., 23) are + # stored together with the forecast files for the corresponding + # preceding even numbered starting hours (e.g. 00, 02, ..., 22, + # respectively), in an archive file whose name contains only the + # even-numbered hour. Thus, in forming the name of the archive + # file, if the starting hour (hh) is odd, we reduce it by one to get + # the corresponding even-numbered hour and use that to form the + # archive file name. + # + # Convert hh to a decimal (i.e. base-10) number to ovoid octal + # interpretation in bash. + hh_orig=$hh -# Convert hh to a decimal (i.e. base-10) number. We need this because -# if it starts with a 0 (e.g. 00, 01, ..., 09), bash will treat it as an -# octal number, and 08 and 09 are illegal ocatal numbers for which the -# arithmetic operations below will fail. hh=$((10#$hh)) if [ $(($hh%2)) = 1 ]; then hh=$((hh-1)) fi -# Now that the arithmetic is done, recast hh as a two-digit string because -# that is needed in constructing the names below. + # Archive files use 2-digit forecast hour hh=$( printf "%02d\n" $hh ) arcv_dir="/BMC/fdr/Permanent/${yyyy}/${mm}/${dd}/data/fsl/rap/full/wrfnat" @@ -921,17 +625,16 @@ bination of external model (extrn_mdl_name) and analysis or forecast arcv_fns="${yyyy}${mm}${dd}${hh}00.${arcv_fmt}" arcv_fps="${arcv_dir}/${arcv_fns}" arcvrel_dir="" -# -# Reset hh to its original value in case it is used again later below. -# + + # Reset hh to its original value hh=${hh_orig} ;; "HRRR") -# -# Note that this is GSL HRRRX data, not operational NCEP HRRR data. An option for the latter -# may be added in the future. -# + # + # Note that this is GSL HRRRX data, not operational NCEP HRRR data. + # An option for the latter may be added in the future. + # arcv_dir="/BMC/fdr/Permanent/${yyyy}/${mm}/${dd}/data/fsl/hrrr/conus/wrfnat" arcv_fmt="zip" arcv_fns="${yyyy}${mm}${dd}${hh}00.${arcv_fmt}" @@ -954,23 +657,23 @@ Archive file information has not been specified for this external model: ;; esac -# -# Depending on the experiment configuration, the above code may set -# arcv_fns and arcv_fps to either scalars or arrays. If they are not -# arrays, recast them as arrays because that is what is expected in the -# code below. -# + # + # Depending on the experiment configuration, the above code may set + # arcv_fns and arcv_fps to either scalars or arrays. If they are not + # arrays, recast them as arrays because that is what is expected in + # the code below. + # is_array arcv_fns || arcv_fns=( "${arcv_fns}" ) is_array arcv_fps || arcv_fps=( "${arcv_fps}" ) -# -#----------------------------------------------------------------------- -# -# Use the eval function to set the output variables. Note that each of -# these is set only if the corresponding input variable specifying the -# name to use for the output variable is not empty. -# -#----------------------------------------------------------------------- -# + # + #----------------------------------------------------------------------- + # + # Use the eval function to set the output variables. Note that each + # of these is set only if the corresponding input variable specifying + # the name to use for the output variable is not empty. + # + #----------------------------------------------------------------------- + # if [ ! -z "${varname_extrn_mdl_cdate}" ]; then eval ${varname_extrn_mdl_cdate}="${cdate}" fi @@ -1011,12 +714,12 @@ Archive file information has not been specified for this external model: if [ ! -z "${varname_extrn_mdl_arcvrel_dir}" ]; then eval ${varname_extrn_mdl_arcvrel_dir}="${arcvrel_dir}" fi -# -#----------------------------------------------------------------------- -# -# Restore the shell options saved at the beginning of this script/function. -# -#----------------------------------------------------------------------- -# + # + #----------------------------------------------------------------------- + # + # Restore the shell options saved at the beginning of this script/function. + # + #----------------------------------------------------------------------- + # { restore_shell_opts; } > /dev/null 2>&1 } diff --git a/ush/set_extrn_mdl_params.sh b/ush/set_extrn_mdl_params.sh index c40e3a1280..e315c240ba 100644 --- a/ush/set_extrn_mdl_params.sh +++ b/ush/set_extrn_mdl_params.sh @@ -1,81 +1,52 @@ # #----------------------------------------------------------------------- # -# This file defines and then calls a function that sets parameters -# associated with the external model used for initial conditions (ICs) -# and the one used for lateral boundary conditions (LBCs). +# This file defines and then calls a function that sets known locations +# of files on supported platforms. # #----------------------------------------------------------------------- # -function set_extrn_mdl_params() { -# -#----------------------------------------------------------------------- -# -# 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). -# -#----------------------------------------------------------------------- -# -local scrfunc_fp=$( $READLINK -f "${BASH_SOURCE[0]}" ) -local scrfunc_fn=$( basename "${scrfunc_fp}" ) -local scrfunc_dir=$( dirname "${scrfunc_fp}" ) -# -#----------------------------------------------------------------------- -# -# Get the name of this function. -# -#----------------------------------------------------------------------- -# -local func_name="${FUNCNAME[0]}" -# -#----------------------------------------------------------------------- -# -# Set the system directory (i.e. location on disk, not on HPSS) in which -# the files generated by the external model specified by EXTRN_MDL_NAME_ICS -# that are necessary for generating initial condition (IC) and surface -# files for the FV3SAR are stored (usually for a limited time, e.g. for -# the GFS external model, 2 weeks on WCOSS and 2 days on hera). If for -# a given cycle these files are available in this system directory, they -# will be copied over to a subdirectory under the cycle directory. If -# these files are not available in the system directory, then we search -# for them elsewhere, e.g. in the mass store (HPSS). -# -#----------------------------------------------------------------------- -# -if [ "${RUN_ENVIR}" = "nco" ]; then - - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-$COMINgfs}" - -else - - case "${EXTRN_MDL_NAME_ICS}" in +function set_known_sys_dir() { + + # Usage: + # set_known_sys_dir model + # + # model is the name of the external model + # + local known_sys_dir model_name + + model=$1 + # + #----------------------------------------------------------------------- + # + # Set the system directory (i.e. location on disk, not on HPSS) in + # which the files generated by the external model specified by + # EXTRN_MDL_NAME_ICS that are necessary for generating initial + # condition (IC) and surface files for the FV3SAR are stored (usually + # for a limited time, e.g. for the GFS external model, 2 weeks on + # WCOSS and 2 days on hera). If for a given cycle these files are + # available in this system directory, they will be copied over to a + # subdirectory under the cycle directory. If these files are not + # available in the system directory, then we search for them + # elsewhere, e.g. in the mass store (HPSS). + # + #----------------------------------------------------------------------- + # + + # Set some default known locations on supported platforms. Not all + # platforms have known input locations + case "${model}" in "GSMGFS") case "$MACHINE" in - "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" - ;; - "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" - ;; "ODIN") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/scratch/ywang/EPIC/GDAS/2019053000_mem001}" + known_sys_dir=/scratch/ywang/EPIC/GDAS/2019053000_mem001 ;; "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/glade/p/ral/jntp/UFS_CAM/COMGFS}" + known_sys_dir=/glade/p/ral/jntp/UFS_CAM/COMGFS ;; "STAMPEDE") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/scratch/00315/tg455890/GDAS/20190530/2019053000_mem001}" + known_sys_dir=/scratch/00315/tg455890/GDAS/20190530/2019053000_mem001 ;; esac ;; @@ -83,28 +54,24 @@ else "FV3GFS") case "$MACHINE" in "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/dell1/nco/ops/com/gfs/prod}" - ;; + ;& # Fall through "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/dell1/nco/ops/com/gfs/prod}" + known_sys_dir=/gpfs/dell1/nco/ops/com/gfs/prod ;; "HERA") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/scratch1/NCEPDEV/rstprod/com/gfs/prod}" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" + known_sys_dir=/scratch1/NCEPDEV/rstprod/com/gfs/prod ;; "JET") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/public/data/grids/gfs/nemsio}" + known_sys_dir=/public/data/grids/gfs/nemsio ;; "ODIN") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/scratch/ywang/test_runs/FV3_regional/gfs}" + known_sys_dir=/scratch/ywang/test_runs/FV3_regional/gfs ;; "STAMPEDE") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/scratch/00315/tg455890/GDAS/20190530/2019053000_mem001}" + known_sys_dir=/scratch/00315/tg455890/GDAS/20190530/2019053000_mem001 ;; "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/glade/p/ral/jntp/UFS_CAM/COMGFS}" + known_sys_dir=/glade/p/ral/jntp/UFS_CAM/COMGFS} ;; esac ;; @@ -112,22 +79,9 @@ else "RAP") case "$MACHINE" in "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/hps/nco/ops/com/rap/prod}" - ;; + ;& # Fall through "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/hps/nco/ops/com/rap/prod}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/scratch2/BMC/public/data/gsd/rap/full/wrfnat}" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/misc/whome/rtrr/rap}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-dummy_value}" + known_sys_dir=/gpfs/hps/nco/ops/com/rap/prod ;; esac ;; @@ -135,22 +89,9 @@ else "HRRR") case "$MACHINE" in "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/hps/nco/ops/com/hrrr/prod}" - ;; + ;& # Fall through "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/hps/nco/ops/com/hrrr/prod}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/scratch2/BMC/public/data/gsd/hrrr/conus/wrfnat}" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-}" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/misc/whome/rtrr/hrrr}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-dummy_value}" + known_sys_dir=/gpfs/hps/nco/ops/com/hrrr/prod ;; esac ;; @@ -158,216 +99,53 @@ else "NAM") case "$MACHINE" in "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/dell1/nco/ops/com/nam/prod}" - ;; + ;& # Fall through "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-/gpfs/dell1/nco/ops/com/nam/prod}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-dummy_value}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-dummy_value}" + known_sys_dir=/gpfs/dell1/nco/ops/com/nam/prod ;; esac ;; esac -fi -# -# If EXTRN_MDL_SYSBASEDIR_ICS has not been set (not even to a null string), -# print out an error message and exit. -# -if [ -z "${EXTRN_MDL_SYSBASEDIR_ICS+x}" ]; then - print_err_msg_exit "\ -The variable EXTRN_MDL_SYSBASEDIR_ICS specifying the system directory -in which to look for the files generated by the external model for ICs -has not been set for the current combination of machine (MACHINE) and -external model (EXTRN_MDL_NAME_ICS): - MACHINE = \"$MACHINE\" - EXTRN_MDL_NAME_ICS = \"${EXTRN_MDL_NAME_ICS}\"" -fi -# -#----------------------------------------------------------------------- -# -# Set EXTRN_MDL_LBCS_OFFSET_HRS, which is the number of hours to shift -# the starting time of the external model that provides lateral boundary -# conditions. -# -#----------------------------------------------------------------------- -# -case "${EXTRN_MDL_NAME_LBCS}" in - "GSMGFS") - EXTRN_MDL_LBCS_OFFSET_HRS="0" - ;; - "FV3GFS") - EXTRN_MDL_LBCS_OFFSET_HRS="0" - ;; - "RAP") - EXTRN_MDL_LBCS_OFFSET_HRS="3" - ;; - "HRRR") - EXTRN_MDL_LBCS_OFFSET_HRS="0" - ;; - "NAM") - EXTRN_MDL_LBCS_OFFSET_HRS="0" - ;; -esac -# -#----------------------------------------------------------------------- -# -# Set the system directory (i.e. location on disk, not on HPSS) in which -# the files generated by the external model specified by EXTRN_MDL_NAME_LBCS -# that are necessary for generating lateral boundary condition (LBC) files -# for the FV3SAR are stored (usually for a limited time, e.g. for the GFS -# external model, 2 weeks on WCOSS and 2 days on hera). If for a given -# cycle these files are available in this system directory, they will be -# copied over to a subdirectory under the cycle directory. If these files -# are not available in the system directory, then we search for them -# elsewhere, e.g. in the mass store (HPSS). -# -#----------------------------------------------------------------------- -# -if [ "${RUN_ENVIR}" = "nco" ]; then - - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-$COMINgfs}" - -else + echo $known_sys_dir +} +function set_extrn_mdl_params() { + # + #----------------------------------------------------------------------- + # + # Use known locations or COMINgfs as default, depending on RUN_ENVIR + # + #----------------------------------------------------------------------- + # + if [ "${RUN_ENVIR}" = "nco" ]; then + EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-$COMINgfs}" + EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-$COMINgfs}" + else + EXTRN_MDL_SYSBASEDIR_ICS="${EXTRN_MDL_SYSBASEDIR_ICS:-$(set_known_sys_dir \ + ${EXTRN_MDL_NAME_ICS})}" + EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-$(set_known_sys_dir \ + ${EXTRN_MDL_NAME_LBCS})}" + fi + + # + #----------------------------------------------------------------------- + # + # Set EXTRN_MDL_LBCS_OFFSET_HRS, which is the number of hours to shift + # the starting time of the external model that provides lateral boundary + # conditions. + # + #----------------------------------------------------------------------- + # case "${EXTRN_MDL_NAME_LBCS}" in - - "GSMGFS") - case "$MACHINE" in - "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "ODIN") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/scratch/ywang/EPIC/GDAS/2019053000_mem001}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/glade/p/ral/jntp/UFS_CAM/COMGFS}" - ;; - "STAMPEDE") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/scratch/00315/tg455890/GDAS/20190530/2019053000_mem001}" - ;; - esac - ;; - - "FV3GFS") - case "$MACHINE" in - "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/gpfs/dell1/nco/ops/com/gfs/prod}" - ;; - "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/gpfs/dell1/nco/ops/com/gfs/prod}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/scratch1/NCEPDEV/rstprod/com/gfs/prod}" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/public/data/grids/gfs/nemsio}" - ;; - "ODIN") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/scratch/ywang/test_runs/FV3_regional/gfs}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/glade/p/ral/jntp/UFS_CAM/COMGFS}" - ;; - "STAMPEDE") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/scratch/00315/tg455890/GDAS/20190530/2019053000_mem001}" - ;; - esac - ;; - - "RAP") - case "$MACHINE" in - "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/gpfs/hps/nco/ops/com/rap/prod}" - ;; - "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/gpfs/hps/nco/ops/com/rap/prod}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/scratch2/BMC/public/data/gsd/rap/full/wrfnat}" - ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/misc/whome/rtrr/rap}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-dummy_value}" + "RAP") + EXTRN_MDL_LBCS_OFFSET_HRS=${EXTRN_MDL_LBCS_OFFSET_HRS:-"3"} ;; - esac - ;; - - "HRRR") - case "$MACHINE" in - "WCOSS_CRAY") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/gpfs/hps/nco/ops/com/hrrr/prod}" - ;; - "WCOSS_DELL_P3") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/gpfs/hps/nco/ops/com/hrrr/prod}" - ;; - "HERA") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/scratch2/BMC/public/data/gsd/hrrr/conus/wrfnat}" + "*") + EXTRN_MDL_LBCS_OFFSET_HRS=${EXTRN_MDL_LBCS_OFFSET_HRS:-"0"} ;; - "ORION") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-}" - ;; - "JET") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-/misc/whome/rtrr/hrrr}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-dummy_value}" - ;; - esac - ;; - - "NAM") - case "$MACHINE" in - "HERA") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-dummy_value}" - ;; - "CHEYENNE") - EXTRN_MDL_SYSBASEDIR_LBCS="${EXTRN_MDL_SYSBASEDIR_LBCS:-dummy_value}" - ;; - esac - ;; - esac - -fi -# -# If EXTRN_MDL_SYSBASEDIR_LBCS has not been set (not even to a null string), -# print out an error message and exit. -# -if [ -z "${EXTRN_MDL_SYSBASEDIR_LBCS+x}" ]; then - print_err_msg_exit "\ -The variable EXTRN_MDL_SYSBASEDIR_LBCS specifying the system directory -in which to look for the files generated by the external model for LBCs -has not been set for the current combination of machine (MACHINE) and -external model (EXTRN_MDL_NAME_LBCS): - MACHINE = \"$MACHINE\" - EXTRN_MDL_NAME_LBCS = \"${EXTRN_MDL_NAME_LBCS}\"" -fi } # #-----------------------------------------------------------------------