3 ##########################################################################
5 # Script Name: met_point_verf_ua.ksh
7 # Author: J.Wolff & M.Harrold
13 # This script runs the MET/Point-Stat tool to verify gridded output
14 # from the WRF PostProcessor using point observations. The MET/PB2NC
15 # tool is run on the PREPBUFR observation files within this script.
17 # START_TIME = The cycle time to use for the initial time.
18 # FCST_TIME = The three-digit forecast that is to be verified.
19 # DOMAIN_LIST = A list of domains to be verified.
20 # MET_EXE_ROOT = The full path of the MET executables.
21 # MET_CONFIG = The full path of the MET configuration files.
22 # UTIL_EXEC = The full path of the ndate executable.
23 # MOAD_DATAROOT = Top-level data directory of WRF output.
24 # RAW_OBS = Directory containing observations to be used.
25 # MODEL = The model being evaluated.
27 ##########################################################################
30 SCRIPT=met_point_verf_ua.ksh
32 # Set path for manual testing of script
33 #export CONSTANT=/scratch4/BMC/gmtb/harrold/gmtb-tierIII/bin/constants.ksh
35 # Make sure ${CONSTANT} exists
36 if [ ! -x "${CONSTANT}" ]; then
37 ${ECHO} "ERROR: ${CONSTANT} does not exist or is not executable"
41 # Read constants into the current shell
44 # Vars used for manual testing of the script
45 #export START_TIME=2016012200
46 #export FCST_TIME="048"
47 #export RES_LIST="0p25"
48 #export GRID_VX_LIST="G3 G218"
49 #export MET_EXE_ROOT=/scratch4/BMC/dtc/MET/met-5.1/bin
50 #export MET_CONFIG=/scratch4/BMC/gmtb/harrold/gmtb-tierIII/parm/met_config
51 #export UTIL_EXEC=/scratch4/BMC/gmtb/gmtb-tierIII/util
52 #export MOAD_DATAROOT=/scratch4/BMC/gmtb/mid_tier/OUTPUT/prtutornems_0p25/DOMAINS/2016012200
53 #export PNT_OBS_DIR=/scratch4/NCEPDEV/global/noscrub/stat/prepbufr
56 # Print run parameters/masks
58 ${ECHO} "${SCRIPT} started at `${DATE}`"
60 ${ECHO} " START_TIME = ${START_TIME}"
61 ${ECHO} " FCST_TIME = ${FCST_TIME}"
62 ${ECHO} " RES_LIST = ${RES_LIST}"
63 ${ECHO} " GRID_VX_LIST = ${GRID_VX_LIST}"
64 ${ECHO} " MET_EXE_ROOT = ${MET_EXE_ROOT}"
65 ${ECHO} " MET_CONFIG = ${MET_CONFIG}"
66 ${ECHO} " UTIL_EXEC = ${UTIL_EXEC}"
67 ${ECHO} " MOAD_DATAROOT = ${MOAD_DATAROOT}"
68 ${ECHO} " ROTDIR = ${ROTDIR}"
69 ${ECHO} " PNT_OBS_DIR = ${PNT_OBS_DIR}"
70 ${ECHO} " MODEL = ${MODEL}"
72 # Make sure $MOAD_DATAROOT exists
73 if [ ! -d "${MOAD_DATAROOT}" ]; then
74 ${ECHO} "MOAD_DATAROOT, ${MOAD_DATAROOT} does not exist; will create it now!"
75 ${MKDIR} -p ${MOAD_DATAROOT}
78 # Make sure ROTDIR exists
79 if [ ! -d "${ROTDIR}" ]; then
80 ${ECHO} "ERROR: ROTDIR, ${ROTDIR} does not exist"
84 # Make sure PNT_OBS_DIR directory exists
85 if [ ! -d ${PNT_OBS_DIR} ]; then
86 ${ECHO} "ERROR: PNT_OBS_DIR, ${PNT_OBS_DIR}, does not exist!"
90 # Go to working directory
91 workdir=${MOAD_DATAROOT}/metprd
92 ${MKDIR} -p ${workdir}
97 ${ECHO} "MODEL=${MODEL}"
98 ${ECHO} "FCST_TIME=${FCST_TIME}"
100 ########################################################################
101 # Compute VX date - only need to run once
102 ########################################################################
104 # Compute the verification date
105 VDATE=`${UTIL_EXEC}/ndate +${FCST_TIME} ${START_TIME}`
106 VYYYYMMDD=`${ECHO} ${VDATE} | ${CUT} -c1-8`
107 VHH=`${ECHO} ${VDATE} | ${CUT} -c9-10`
108 ${ECHO} 'valid time for ' ${FCST_TIME} 'h forecast = ' ${VDATE}
110 ########################################################################
111 # Run pb2nc on prepbufr obs file - only need to run once
112 ########################################################################
114 # Specify the MET PB2NC configuration file to be used
115 export CONFIG_PB2NC="${MET_CONFIG}/PB2NCConfig_GMTB"
117 # Make sure the MET configuration files exists
118 if [ ! -e ${CONFIG_PB2NC} ]; then
119 echo "ERROR: ${CONFIG_PB2NC} does not exist!"
123 # Handle time -- set beg and end times for pb2nc processing
124 VYYYY=`echo ${VYYYYMMDD} | cut -c1-4`
125 VMM=`echo ${VYYYYMMDD} | cut -c5-6`
126 VDD=`echo ${VYYYYMMDD} | cut -c7-8`
127 REF_UT=`date -ud ''${VYYYY}-${VMM}-${VDD}' UTC '${VHH}:00:00'' +%s`
128 BEG_UT=`expr ${REF_UT} - 2700`
129 END_UT=`expr ${REF_UT} + 2700`
130 BEG_STR=`date -ud '1970-01-01 UTC '${BEG_UT}' seconds' +%Y%m%d_%H%M%S`
131 END_STR=`date -ud '1970-01-01 UTC '${END_UT}' seconds' +%Y%m%d_%H%M%S`
133 # List observation file to be run through pb2nc
134 PB_FILE="${PNT_OBS_DIR}/gdas/prepbufr.gdas.${VYYYYMMDD}${VHH}"
135 if [ ! -e ${PB_FILE} ]; then
136 PB_FILE="${OBS_DIR}/gdas/${VYYYYMMDD}/prepbufr.gdas.${VYYYYMMDD}${VHH}"
138 if [ ! -e ${PB_FILE} ]; then
139 echo "ERROR: Could not find observation file."
144 pb2nc=${workdir}/pb2nc
147 # Create a PB2NC output file name
148 OBS_FILE="${pb2nc}/prepbufr.gdas.${VYYYYMMDD}.t${VHH}z.nc"
151 echo "CALLING: ${MET_EXE_ROOT}/pb2nc ${PB_FILE} ${OBS_FILE} ${CONFIG_PB2NC} -v 2"
153 ${MET_EXE_ROOT}/pb2nc ${PB_FILE} ${OBS_FILE} ${CONFIG_PB2NC} -valid_beg ${BEG_STR} -valid_end ${END_STR} -v 2
155 ########################################################################
156 # Run point stat for each grid resolution and verification grid
157 ########################################################################
159 # Loop through the domain list
160 for RES in ${RES_LIST}; do
165 for GRID_VX in ${GRID_VX_LIST}; do
166 GRID_VX_NUM=`${ECHO} ${GRID_VX} | cut -c2-`
167 typeset -Z3 GRID_VX_NUM
168 GRID_VX_FORMAT="G${GRID_VX_NUM}"
171 export GRID_VX_FORMAT
173 # Specify new mask directory structure
174 MASKS=${MET_CONFIG}/masks
177 # Specify the MET Point-Stat configuration files to be used
178 CONFIG_ADPUPA="${MET_CONFIG}/PointStatConfig_ADPUPA_REGRID_${GRID_VX}"
180 # Make sure the Point-Stat configuration files exists
181 if [ ! -e ${CONFIG_ADPUPA} ]; then
182 ${ECHO} "ERROR: ${CONFIG_ADPUPA} does not exist!"
186 # Check the GDAS observation file (created from previous command to run pb2nc)
187 ${ECHO} "OBS_FILE: ${OBS_FILE}"
189 if [ ! -e ${OBS_FILE} ]; then
190 ${ECHO} "ERROR: Could not find observation file: ${OBS_FILE}"
194 # Get the forecast to verify
195 FCST_FILE=${ROTDIR}/pgrbq${FCST_TIME}.gfs.${START_TIME}.grib2
196 ${ECHO} "FCST_FILE: ${FCST_FILE}"
198 if [ ! -e ${FCST_FILE} ]; then
199 ${ECHO} "ERROR: Could not find UPP output file: ${FCST_FILE}"
203 #######################################################################
205 #######################################################################
207 # Verify upper air variables only at 00Z and 12Z
208 if [ "${VHH}" == "00" -o "${VHH}" == "12" ]; then
209 CONFIG_FILE=${CONFIG_ADPUPA}
211 ${ECHO} "CALLING: ${MET_EXE_ROOT}/point_stat ${FCST_FILE} ${OBS_FILE} ${CONFIG_FILE} -outdir . -v 2"
213 /usr/bin/time ${MET_EXE_ROOT}/point_stat ${FCST_FILE} ${OBS_FILE} ${CONFIG_FILE} \
217 if [ ${error} -ne 0 ]; then
218 ${ECHO} "ERROR: For ${MODEL}, ${MET_EXE_ROOT}/point_stat ${CONFIG_FILE} crashed Exit status: ${error}"
226 ##########################################################################
228 ${ECHO} "${SCRIPT} completed at `${DATE}`"