Skip to content

Commit

Permalink
"add the task of smoke emission preprocessing" (NOAA-EMC#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
haiqinli committed Oct 28, 2022
1 parent fb8398a commit 7355c69
Show file tree
Hide file tree
Showing 10 changed files with 560 additions and 5 deletions.
170 changes: 170 additions & 0 deletions jobs/JREGIONAL_PROCESS_SMOKE
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#!/bin/bash
#
#-----------------------------------------------------------------------
#
# This J-JOB script runs the radar reflectivity preprocess
# for the FV3-LAM model
#
#-----------------------------------------------------------------------
#
#-----------------------------------------------------------------------
#
# Source the variable definitions file and the bash utility functions.
#
#-----------------------------------------------------------------------
#
. ${GLOBAL_VAR_DEFNS_FP}
. $USHDIR/source_util_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
#
#-----------------------------------------------------------------------
#
# 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 runs a radar reflectivity
preprocess with FV3 for the specified cycle.
========================================================================"
#
#-----------------------------------------------------------------------
#
# Create the working directory under the cycle directory.
#
#-----------------------------------------------------------------------
#
if [ ${CYCLE_TYPE} == "spinup" ]; then
workdir=${CYCLE_DIR}/process_smoke_spinup
else
workdir=${CYCLE_DIR}/process_smoke
fi
rm -fr ${workdir}
mkdir_vrfy -p ${workdir}
#
#
#
gridspec_dir=${NWGES_BASEDIR}/grid_spec
#
#-----------------------------------------------------------------------
#
# Set the name of and create the directory in which the output from this
# script will be saved for long time (if that directory doesn't already exist).
# Usually ics_dir under tmpnwprd should be purged fairly soon after cycle done
#
#-----------------------------------------------------------------------
#
rave_nwges_dir=${NWGES_DIR}/RAVE_INTP
mkdir_vrfy -p "${rave_nwges_dir}"
#-----------------------------------------------------------------------
#
# Call the ex-script for this J-job and pass to it the necessary varia-
# bles.
#
#-----------------------------------------------------------------------
#
cd_vrfy ${workdir}
python -u ${SCRIPTSDIR}/preprocess_smoke.py \
"${FIRE_RRFS_ROOT}/${PREDEF_GRID_NAME}/fixed" \
"${FIRE_RAVE_DIR}" \
"${rave_nwges_dir}" \
"${PREDEF_GRID_NAME}" \
print_err_msg_exit "\
Call to pyscript \"${scrfunc_fn}\" failed."

ECHO=/bin/echo
AWK="/bin/gawk --posix"
SED=/bin/sed
DATE=/bin/date

START_DATE=$(echo "${CDATE}" | sed 's/\([[:digit:]]\{2\}\)$/ \1/')
YYYYMMDDHH=$(date +%Y%m%d%H -d "${START_DATE}")
YYYYMMDD=${YYYYMMDDHH:0:8}
HH=${YYYYMMDDHH:8:2}
echo ${YYYYMMDD}
echo ${HH}

current_day=`${DATE} -d "${YYYYMMDD}"`
HH=${HH}
current_hh=`${DATE} -d ${HH} +"%H"`
prev_hh=`${DATE} -d "$current_hh -24 hour" +"%H"`
previous_day=`${DATE} '+%C%y%m%d' -d "$current_day-1 days"`
previous_day=${previous_day}${prev_hh}
output_filename=SMOKE_RRFS_data_${YYYYMMDDHH}00.nc
#output_filename=SMOKE_RRFS_data_${previous_day}00.nc
echo ${previous_day}
echo ${output_filename}

#cd_vrfy /mnt/lfs4/BMC/gsd-fv3-dev/FIRE_RRFS_ROOT/RAVE_INTP2
cd_vrfy ${rave_nwges_dir}
echo ${rave_nwges_dir}

# Convert START_TIME from 'YYYYMMDDHH' format to Unix date format, e.g. "Fri May 6 19:50:23 GMT 2005"
if [ `${ECHO} "${previous_day}" | ${AWK} '/^[[:digit:]]{10}$/'` ]; then
previous_day=`${ECHO} "${previous_day}" | ${SED} 's/\([[:digit:]]\{2\}\)$/ \1/'`
else
${ECHO} "ERROR: start time, '${previous_day}', is not in 'yyyymmddhh' or 'yyyymmdd hh' format"
exit 1
fi
previous_day=`${DATE} -d "${previous_day}"`
echo ${previous_day}

nfiles=24
files2cat=()
for i in $(seq 0 $(($nfiles - 1)) )
do
timestr=`date +%Y%m%d%H -d "$previous_day + $i hours"`
echo ${timestr}
files2cat[$i]=${PREDEF_GRID_NAME}_intp_${timestr}00_${timestr}00.nc
done
echo ${files2cat[*]}
ncrcat ${files2cat[*]} ${output_filename}

#
#-----------------------------------------------------------------------
#
# 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/func-
# tion.
#
#-----------------------------------------------------------------------
#
{ restore_shell_opts; } > /dev/null 2>&1

3 changes: 2 additions & 1 deletion jobs/JREGIONAL_RUN_FCST
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ $SCRIPTSDIR/exregional_run_fcst.sh \
cycle_dir="${run_dir}" \
gridspec_dir="${gridspec_dir}" \
ensmem_indx="${ENSMEM_INDX}" \
slash_ensmem_subdir="${SLASH_ENSMEM_SUBDIR}" || \
slash_ensmem_subdir="${SLASH_ENSMEM_SUBDIR}" \
NWGES_BASEDIR="${NWGES_BASEDIR}" || \
print_err_msg_exit "\
Call to ex-script corresponding to J-job \"${scrfunc_fn}\" failed."
#
Expand Down
4 changes: 4 additions & 0 deletions modulefiles/tasks/hera/run_proc_smoke.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#%Module
module use /contrib/miniconda3/modulefiles
module load miniconda3/4.5.12
setenv SRW_ENV /scratch1/BMC/acomp/Johana/miniconda/envs/interpol_esmpy
4 changes: 4 additions & 0 deletions modulefiles/tasks/jet/run_proc_smoke.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#%Module
module use /contrib/miniconda3/modulefiles
module load miniconda3/4.5.12
setenv SRW_ENV /home/Johana.Romero-Alvarez/miniconda3/envs/interpol_esmpy
11 changes: 9 additions & 2 deletions scripts/exregional_run_fcst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ valid_args=( \
"gridspec_dir" \
"ensmem_indx" \
"slash_ensmem_subdir" \
"NWGES_BASEDIR" \
)
process_args valid_args "$@"
#
Expand Down Expand Up @@ -410,8 +411,14 @@ fi
if [ "${DO_SMOKE_DUST}" = "TRUE" ]; then
ln_vrfy -snf ${FIX_SMOKE_DUST}/${PREDEF_GRID_NAME}/dust12m_data.nc ${run_dir}/INPUT/dust12m_data.nc
ln_vrfy -snf ${FIX_SMOKE_DUST}/${PREDEF_GRID_NAME}/emi_data.nc ${run_dir}/INPUT/emi_data.nc
#yyyymmdd=${cdate:0:8}
ln_vrfy -snf ${FIRE_RRFS_ROOT}/${PREDEF_GRID_NAME}/FIRE_RRFS_data_3km_in.nc ${run_dir}/INPUT/SMOKE_RRFS_data.nc
yyyymmddhh=${cdate:0:10}
echo ${yyyymmddhh}
echo ${NWGES_BASEDIR}/RAVE_INTP/SMOKE_RRFS_data_${yyyymmddhh}00.nc
if [ -f ${NWGES_BASEDIR}/RAVE_INTP/SMOKE_RRFS_data_${yyyymmddhh}00.nc ]; then
ln_vrfy -snf ${NWGES_BASEDIR}/RAVE_INTP/SMOKE_RRFS_data_${yyyymmddhh}00.nc ${run_dir}/INPUT/SMOKE_RRFS_data.nc
else
ln_vrfy -snf ${FIRE_RRFS_ROOT}/${PREDEF_GRID_NAME}/fixed/dummy_24hr_smoke.nc ${run_dir}/INPUT/SMOKE_RRFS_data.nc
fi
fi
#
#-----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 7355c69

Please sign in to comment.