Skip to content

Postprocessor

fernanqv edited this page Mar 17, 2022 · 1 revision

Why a postprocessor?

The raw files produced by WRF need to be postprocessed to make them CF-compliant. But this is conveniently carried out after the simulations are finished. However, for users that do not have large storage resources, the whole WRF raw files on an experiment can be too heavy. In fact, by default, WRF saves many variables, and these files are large. Thus, WRF4G provides the possibility of passing the WRF raw output files through a post-processing script as WRF is running.

postprocessors in WRF4G

Similar to preprocessor, WRF4G postprocessor is an executable script that can be written in any programming language, provided it does accept one argument, which is one WRF raw file. We usually use a modified version of p_interp (available on $WRF4G_DEPLOYMENT_DIR/repository/apps/p_inperp/) or py_interp to interpolate to filter out unnecessary variables and interpolate to pressure levels. Note that users with large storage resources may not be interested in using a postprocessor. In order to create a postprocessor, it has to be located in the wrf4g_files/bin directory of the specific experiment. Post-processors are included under the $WRF4G_DEPLOYMENT_DIR/repository/apps/postprocessor/ directory.

Sample postprocesor:

#! /bin/bash
set -e

# Sample postprocessor
#
# This can be any kind of executable accepting one argument:
#
wrfnc_file=$1        # The WRF file to postprocess
#
# and creating a postprocessed file with the same name to be uploaded by register_file
#

function pintnml(){
  idir=$1
  ifile=$2
  cat << EOF > namelist.pinterp
&io
  path_to_input            = '${idir}/',
  input_name               = '${ifile}',
  path_to_output           = '${idir}/',
  fields                   = 'RAINTOT,T2,Q2,PSFC,U10,V10,CLT,SFCEVP,QFX,GLW,SWDOWN,RAINC,HGT,SMOIS,PH,PHB,GHT,T,TT,PRES,MSLP,PLEV,ALBEDO,SST,ACSNOW,GRDFLX,CLDFRA,SMSTOT,LH,ACLHF,HFX,ACHFX,SNOWH,ACSNOM,PBLH,Times',
  process                  = 'list',
  debug                    = .FALSE.,
  grid_filt                = 3,
  ntimes_filt              = 10,
/

&interp_in
  interp_levels            = 1000.0, 925., 850.0, 700., 500.0, 300,
  extrapolate              = 1,
  interp_method            = 1,
  unstagger_grid           = .TRUE.,
/
EOF
}

pintnml . ${wrfnc_file}
p_interp
rm namelist.pinterp

xptdsize=$( echo "print int($(stat -c %s ${wrfnc_file})*0.025)" | python )
if test "$(stat -c %s ${wrfnc_file}_PLEV)" -ge ${xptdsize}; then
  mv "${wrfnc_file}_PLEV" "${wrfnc_file}" 
fi
Clone this wiki locally