forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mean/spread for atmos grib2 (NOAA-EMC#2482)
Adds the basic mean and spread grib2 products for the atmosphere. The new mean/spread files are named according to the new convention, though `pres_${grid_type}` may be changed to `pgrb_${grid_type}`. Either way, the input filenames will need to be updated when that change is made. For now, the mismatch means the unlettered grib files result in `pres_`. Resolves NOAA-EMC#2296 Refs NOAA-EMC#1522
- Loading branch information
1 parent
b7e5b6e
commit 9052ec4
Showing
9 changed files
with
269 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#! /usr/bin/env bash | ||
|
||
# | ||
# Caculate the mean, spread, and other probabilistic fields. | ||
# | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
source "${HOMEgfs}/ush/jjob_header.sh" -e "atmos_ensstat" -c "base atmos_ensstat" | ||
|
||
|
||
############################################## | ||
# Begin JOB SPECIFIC work | ||
############################################## | ||
|
||
# Construct COM variables from templates | ||
# Input directories loop over members, so this is done downstream | ||
|
||
for grid in '0p25' '0p50' '1p00'; do | ||
prod_dir="COMOUT_ATMOS_GRIB_${grid}" | ||
MEMDIR="ensstat" GRID=${grid} YMD=${PDY} HH=${cyc} declare_from_tmpl -rx "${prod_dir}:COM_ATMOS_GRIB_GRID_TMPL" | ||
if [[ ! -d "${!prod_dir}" ]]; then mkdir -m 775 -p "${!prod_dir}"; fi | ||
done | ||
|
||
############################################################### | ||
# Run exglobal script | ||
"${SCRgfs}/exglobal_atmos_ensstat.sh" | ||
status=$? | ||
(( status != 0 )) && exit "${status}" | ||
|
||
############################################## | ||
# End JOB SPECIFIC work | ||
############################################## | ||
|
||
############################################## | ||
# Final processing | ||
############################################## | ||
if [[ -e "${pgmout}" ]]; then | ||
cat "${pgmout}" | ||
fi | ||
|
||
########################################## | ||
# Remove the Temporary working directory | ||
########################################## | ||
cd "${DATAROOT}" || exit 1 | ||
[[ "${KEEPDATA:-NO}" = "NO" ]] && rm -rf "${DATA}" | ||
|
||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#! /usr/bin/env bash | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
|
||
############################################################### | ||
## atmosphere products driver script | ||
## FHRLST : forecast hour list to post-process (e.g. -f001, f000, f000_f001_f002, ...) | ||
############################################################### | ||
|
||
# Source FV3GFS workflow modules | ||
. "${HOMEgfs}/ush/load_fv3gfs_modules.sh" | ||
status=$? | ||
if (( status != 0 )); then exit "${status}"; fi | ||
|
||
export job="atmos_ensstat" | ||
export jobid="${job}.$$" | ||
|
||
############################################################### | ||
# shellcheck disable=SC2153,SC2001 | ||
IFS='_' read -ra fhrs <<< "${FHRLST//f}" # strip off the 'f's and convert to array | ||
|
||
#--------------------------------------------------------------- | ||
# Execute the JJOB | ||
for fhr in "${fhrs[@]}"; do | ||
# The analysis fhr is -001. Performing math on negative, leading 0 integers is tricky. | ||
# The negative needs to be in front of "10#", so do some regex magic to make it happen. | ||
fhr="10#${fhr}" | ||
fhr=${fhr//10\#-/-10\#} | ||
export FORECAST_HOUR=$(( fhr )) | ||
"${HOMEgfs}/jobs/JGLOBAL_ATMOS_ENSSTAT" | ||
status=$? | ||
if (( status != 0 )); then exit "${status}"; fi | ||
done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
########## config.atmos_ensstat ########## | ||
# atmosphere grib2 enstat specific | ||
|
||
echo "BEGIN: config.atmos_ensstat" | ||
|
||
# Get task specific resources | ||
. "${EXPDIR}/config.resources" atmos_ensstat | ||
|
||
echo "END: config.atmos_ensstat" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /usr/bin/env bash | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
|
||
fhr3=$(printf "%03d" "${FORECAST_HOUR}") | ||
|
||
if [[ -a mpmd_script ]]; then rm -Rf mpmd_script; fi | ||
|
||
{ | ||
for grid in '0p25' '0p50' '1p00'; do | ||
echo "${USHgfs}/atmos_ensstat.sh ${grid} ${fhr3}" | ||
# echo "${USHgfs}/atmos_ensstat.sh ${grid} ${fhr3} b" | ||
done | ||
} > mpmd_script | ||
|
||
"${USHgfs}/run_mpmd.sh" mpmd_script | ||
err=$? | ||
|
||
exit "${err}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#! /usr/bin/env bash | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
|
||
grid=${1} | ||
fhr3=${2} | ||
grid_type=${3:-''} | ||
|
||
mkdir "${grid}${grid_type}" | ||
cd "${grid}${grid_type}" || exit 2 | ||
|
||
# Collect input grib files | ||
input_files=() | ||
for ((mem_num = 0; mem_num <= "${NMEM_ENS:-0}"; mem_num++)); do | ||
mem=$(printf "%03d" "${mem_num}") | ||
MEMDIR="mem${mem}" GRID="${grid}" YMD="${PDY}" HH="${cyc}" declare_from_tmpl COMIN_ATMOS_GRIB:COM_ATMOS_GRIB_GRID_TMPL | ||
memfile_in="${COMIN_ATMOS_GRIB}/${RUN}.t${cyc}z.pgrb2${grid_type}.${grid}.f${fhr3}" | ||
|
||
if [[ -r "${memfile_in}.idx" ]]; then | ||
${NLN} "${memfile_in}" "mem${mem}" | ||
input_files+=("mem${mem}") | ||
else | ||
echo "FATAL ERROR: ${memfile_in} does not exist" | ||
exit 10 | ||
fi | ||
done | ||
|
||
num_found=${#input_files[@]} | ||
if (( num_found != NMEM_ENS + 1 )); then | ||
echo "FATAL ERROR: Only ${num_found} grib files found out of $(( NMEM_ENS + 1 )) expected members." | ||
exit 10 | ||
fi | ||
|
||
# Create namelist for ensstat | ||
mean_out="${RUN}.t${cyc}z.mean.pres_${grid_type}.${grid}.f${fhr3}.grib2" | ||
spr_out="${RUN}.t${cyc}z.spread.pres_${grid_type}.${grid}.f${fhr3}.grib2" | ||
|
||
cat << EOF > input.nml | ||
&namdim | ||
lfdim=${lfm:-''} | ||
/ | ||
&namens | ||
nfiles=${num_found} | ||
nenspost=0 | ||
navg_min=${NMEM_ENS} | ||
cfopg1="${mean_out}" | ||
cfopg2="${spr_out}" | ||
$( | ||
for (( filenum = 1; filenum <= num_found; filenum++ )); do | ||
echo " cfipg(${filenum})=\"${input_files[$((filenum-1))]}\"," | ||
echo " iskip(${filenum})=0," | ||
done | ||
) | ||
/ | ||
EOF | ||
|
||
cat input.nml | ||
|
||
# Run ensstat | ||
"${EXECgfs}/ensstat.x" < input.nml | ||
|
||
export err=$? | ||
if (( err != 0 )) ; then | ||
echo "FATAL ERROR: ensstat returned error code ${err}" | ||
exit "${err}" | ||
fi | ||
|
||
# Send data to com and send DBN alerts | ||
comout_var_name="COMOUT_ATMOS_GRIB_${grid}" | ||
comout_path="${!comout_var_name}" | ||
|
||
for outfile in ${mean_out} ${spr_out}; do | ||
if [[ ! -s ${outfile} ]]; then | ||
echo "FATAL ERROR: Failed to create ${outfile}" | ||
exit 20 | ||
fi | ||
|
||
${WGRIB2} -s "${outfile}" > "${outfile}.idx" | ||
err=$? | ||
if (( err != 0 )); then | ||
echo "FATAL ERROR: Failed to create inventory file, wgrib2 returned ${err}" | ||
exit "${err}" | ||
fi | ||
|
||
cpfs "${outfile}" "${comout_path}/${outfile}" | ||
cpfs "${outfile}.idx" "${comout_path}/${outfile}.idx" | ||
|
||
if [[ ${SENDDBN} == "YES" ]]; then | ||
"${DBNROOT}/bin/dbn_alert" MODEL "${RUN^^}_PGB2${grid_type}_${grid}" "${job}" \ | ||
"${comout_path}/${outfile}" | ||
"${DBNROOT}/bin/dbn_alert" MODEL "${RUN^^}_PGB2${grid_type}_${grid}" "${job}" \ | ||
"${comout_path}/${outfile}.idx" | ||
fi | ||
|
||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters