Skip to content

Commit

Permalink
Merge pull request NOAA-EMC#115 from gsketefian/community_develop
Browse files Browse the repository at this point in the history
Community develop
  • Loading branch information
JeffBeck-NOAA authored Oct 3, 2019
2 parents b8ca7ce + 777200e commit 9e2e710
Show file tree
Hide file tree
Showing 51 changed files with 4,071 additions and 6,137 deletions.
54 changes: 20 additions & 34 deletions jobs/JREGIONAL_GET_EXTRN_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
# (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
# depends on the value of the variable ICS_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
# by the variable EXTRN_MDL_FILES_BASEDIR_ICS, and if considering
# LBCs, it places the files in a subdirectory under the one specified by
# the variable EXTRN_MDL_FILES_BASEDIR_LBCS.
#
Expand Down Expand Up @@ -55,7 +55,7 @@
#
#-----------------------------------------------------------------------
#
script_name=$( basename "$0" )
script_name=$( basename "${BASH_SOURCE[0]}" )
print_info_msg "\n\
========================================================================
Entering script: \"${script_name}\"
Expand Down Expand Up @@ -92,9 +92,11 @@ later than the last forecast date and time (CDATE_max) with this model:

"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"
# this was the first official forecast with the FV3GFS. However, paral-
# lel runs with the FV3GFS go back to 2018121500. So we set the first
# CDATE for the FV3GFS to this date and time.
# CDATE_min="2019061212"
CDATE_min="2018121500"
if [ "$CDATE" -lt "$CDATE_min" ]; then
print_err_msg_exit "${script_name}" "\
Output from the specified external model (EXTRN_MDL_NAME) is not availa-
Expand Down Expand Up @@ -153,49 +155,33 @@ esac
#
#-----------------------------------------------------------------------
#
valid_vals_ICSSURF_OR_LBCS=( "ICSSURF" "LBCS" )
if [ "$ICSSURF_OR_LBCS" = "ICSSURF" ]; then
valid_vals_ICS_OR_LBCS=( "ICS" "LBCS" )
if [ "$ICS_OR_LBCS" = "ICS" ]; then
ANL_OR_FCST="ANL"
TIME_OFFSET_HRS="0"
elif [ "$ICSSURF_OR_LBCS" = "LBCS" ]; then
elif [ "$ICS_OR_LBCS" = "LBCS" ]; then
ANL_OR_FCST="FCST"
TIME_OFFSET_HRS="$EXTRN_MDL_LBCS_OFFSET_HRS"
else
valid_vals_ICSSURF_OR_LBCS_str=$( printf "\"%s\" " "${valid_vals_ICSSURF_OR_LBCS[@]}" )
valid_vals_ICS_OR_LBCS_str=$( printf "\"%s\" " "${valid_vals_ICS_OR_LBCS[@]}" )
print_err_msg_exit "${script_name}" "\
Invalid value specified for ICSSURF_OR_LBCS:
ICSSURF_OR_LBCS = \"$ICSSURF_OR_LBCS\"
Invalid value specified for ICS_OR_LBCS:
ICS_OR_LBCS = \"$ICS_OR_LBCS\"
Valid values are:
${valid_vals_ICSSURF_OR_LBCS_str}
${valid_vals_ICS_OR_LBCS_str}
"
fi
#
#-----------------------------------------------------------------------
#
# Create the directory EXTRN_MDL_FILES_BASEDIR_ICSSURF if it doesn't al-
# Create the directory EXTRN_MDL_FILES_BASEDIR_ICS 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 .
# files from the external model.
#
#-----------------------------------------------------------------------
#
if [ "${RUN_ENVIR}" = "nco" ]; then

COMINGFS=COMINgfs=/scratch3/NCEPDEV/hwrf/noscrub/hafs-input/COMGFS
COMINgfs=/scratch3/NCEPDEV/hwrf/noscrub/hafs-input/COMGFS
EXTRN_MDL_FILES_DIR="$EXTRN_MDL_FILES_BASEDIR_ICSSURF/$CDATE"

else

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

fi
EXTRN_MDL_FILES_DIR="${CYCLE_DIR}/${EXTRN_MDL_NAME}/${ICS_OR_LBCS}"
#
#-----------------------------------------------------------------------
#
Expand Down Expand Up @@ -250,8 +236,8 @@ $SCRIPTSDIR/exregional_get_extrn_files.sh \
EXTRN_MDL_ARCV_FNS="${EXTRN_MDL_ARCV_FNS_str}" \
EXTRN_MDL_ARCV_FPS="${EXTRN_MDL_ARCV_FPS_str}" \
EXTRN_MDL_ARCV_FMT="${EXTRN_MDL_ARCV_FMT}" \
EXTRN_MDL_ARCVREL_DIR="${EXTRN_MDL_ARCVREL_DIR}" \
|| print_err_msg_exit "${script_name}" "\
EXTRN_MDL_ARCVREL_DIR="${EXTRN_MDL_ARCVREL_DIR}" || \
print_err_msg_exit "${script_name}" "\
Call to ex-script corresponding to J-job \"${script_name}\" failed."
#
#-----------------------------------------------------------------------
Expand Down
199 changes: 199 additions & 0 deletions jobs/JREGIONAL_MAKE_GRID
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#!/bin/bash

#
#-----------------------------------------------------------------------
#
# This script generates grid and orography files in NetCDF format that
# are required as inputs for running the FV3SAR model (i.e. the FV3 mo-
# del on a regional domain). It in turn calls three other scripts whose
# file names are specified in the variables grid_gen_scr, orog_gen_scr,
# and orog_fltr_scr and then calls the executable defined in the varia-
# ble shave_exec. These scripts/executable perform the following tasks:
#
# 1) grid_gen_scr:
#
# This script generates grid files that will be used by subsequent
# preprocessing steps. It places its output in the temporary direc-
# tory defined in GRID_DIR. Note that:
#
# a) This script creates grid files for each of the 7 tiles of the
# cubed sphere grid (where tiles 1 through 6 cover the globe, and
# tile 7 is the regional grid located somewhere within tile 6)
# even though the forecast will be performed only on tile 7.
#
# b) The tile 7 grid file that this script creates includes a halo,
# i.e. a layer of cells beyond the boundary of tile 7). The width
# of this halo (i.e. the number of cells in the halo in the direc-
# tion perpendicular to the boundary of the tile) must be made
# large enough such that the "shave" steps later below (which take
# this file as input and generate grid files with thinner halos)
# have a wide enough starting halo to work with. More specifical-
# ly, the FV3SAR model needs as inputs two grid files: one with a
# halo that is 3 cells and another with a halo that is 4 cells
# wide. Thus, the halo in the grid file that the grid_gen_scr
# script generates must be greater than 4 since otherwise, the
# shave steps would shave off cells from within the interior of
# tile 7. We will let nhw_T7 denote the width of the halo in the
# grid file generated by grid_gen_scr. The "n" in this variable
# name denotes number of cells, the "h" is used to indicate that
# it refers to a halo region, the "w" is used to indicate that it
# refers to a wide halo (i.e. wider than the 3-cell and 4-cell ha-
# los that the FV3SAR model requires as inputs, and the "T7" is
# used to indicate that the cell count is on tile 7.
#
# 2) orog_gen_scr:
#
# This script generates the orography file. It places its output in
# the temporary directory defined in OROG_DIR. Note that:
#
# a) This script generates an orography file only on tile 7.
#
# b) This orography file contains a halo of the same width (nhw_T7)
# as the grid file for tile 7 generated by the grid_gen_scr script
# in the previous step.
#
# 3) orog_fltr_scr:
#
# This script generates a filtered version of the orography file ge-
# nerated by the script orog_gen_scr. This script places its output
# in the temporary directory defined in WORKDIR_FLTR. Note that:
#
# a) The filtered orography file generated by this script contains a
# halo of the same width (nhw_T7) as the (unfiltered) orography
# file generated by script orog_gen_scr (and the grid file genera-
# ted by grid_gen_scr).
#
# b) In analogy with the input grid files, the FV3SAR model needs as
# input two (filtered) orography files -- one with no halo cells
# and another with 3. These are obtained later below by "shaving"
# off layers of halo cells from the (filtered) orography file ge-
# nerated in this step.
#
# 4) shave_exec:
#
# This "shave" executable is called 4 times to generate 4 files from
# the tile 7 grid file generated by grid_gen_scr and the tile 7 fil-
# tered orography file generated by orog_fltr_scr (both of which have
# a halo of width nhw_T7 cells). The 4 output files are placed in
# the temporary directory defined in WORKDIR_SHVE. More specifically:
#
# a) shave_exec is called to shave the halo in the tile 7 grid file
# generated by grid_gen_scr down to a width of 3 cells and store
# the result in a new grid file in WORKDIR_SHVE.
#
# b) shave_exec is called to shave the halo in the tile 7 grid file
# generated by grid_gen_scr down to a width of 4 cells and store
# the result in a new grid file in WORKDIR_SHVE.
#
# c) shave_exec is called to shave the halo in the tile 7 filtered
# orography file generated by orog_fltr_scr down to a width of 0
# cells (i.e. no halo) and store the result in a new filtered oro-
# graphy file in WORKDIR_SHVE.
#
# d) shave_exec is called to shave the halo in the tile 7 filtered
# orography file generated by orog_fltr_scr down to a width of 4
# cells and store the result in a new filtered orography file in
# WORKDIR_SHVE.
#
#-----------------------------------------------------------------------
#

#
#-----------------------------------------------------------------------
#
# Source the variable definitions script and the function definitions
# file.
#
#-----------------------------------------------------------------------
#
. $SCRIPT_VAR_DEFNS_FP
. $USHDIR/source_funcs.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
#
#-----------------------------------------------------------------------
#
# Set the script name and print out an informational message informing
# the user that we've entered this script.
#
#-----------------------------------------------------------------------
#
script_name=$( basename "${BASH_SOURCE[0]}" )
print_info_msg "\n\
========================================================================
Entering script: \"${script_name}\"
This is the J-job script for the task that generates grid files.
========================================================================"
#
#-----------------------------------------------------------------------
#
# Export select variables.
#
#-----------------------------------------------------------------------
#
export gtype
export stretch_fac
#
#-----------------------------------------------------------------------
#
# Call the ex-script for this J-job and pass to it the necessary varia-
# bles.
#
#-----------------------------------------------------------------------
#
${SCRIPTSDIR}/exregional_make_grid.sh \
WORKDIR_LOCAL="ABCD" || \
print_err_msg_exit "${script_name}" "\
Call to ex-script corresponding to J-job \"${script_name}\" failed."
#
#-----------------------------------------------------------------------
#
# Create a flag file to make rocoto aware that the make_grid task has
# successfully completed (so that other tasks that depend on it can be
# launched).
#
# Although we can use the <taskdep> tag to make other tasks depend on
# the successful completion of make_grid, it turns out that the <task-
# dep> tag assumes that the task it specifies (in this case make_grid)
# runs for the same set of cycles as the one in which it appears as a
# dependency. Thus, if we use <taskdep> in a cycle-dependent task in
# the workflow to make it depend on the make_grid, then the workflow
# will wait for make_grid to run for each cycle for which that cycle-de-
# pendent task is defined before running the task. But since make_grid
# will not run for each cycle (except possibly for the very first one),
# the cycle-dependent task will not be able to run for any of the cycles
# except the first one. For this reason, we cannot use the <taskdep>
# tag to make other cycle-dependent tasks depend on make_grid and must
# instead use a flag file.
#
#-----------------------------------------------------------------------
#
touch "$LOGDIR/make_grid_task_complete.txt"
#
#-----------------------------------------------------------------------
#
# Print exit message.
#
#-----------------------------------------------------------------------
#
print_info_msg "\n\
========================================================================
Exiting script: \"${script_name}\"
========================================================================"
#
#-----------------------------------------------------------------------
#
# Restore the shell options saved at the beginning of this script/func-
# tion.
#
#-----------------------------------------------------------------------
#
{ restore_shell_opts; } > /dev/null 2>&1

Loading

0 comments on commit 9e2e710

Please sign in to comment.