#!/bin/ksh # set -x # August 2005: Hui-Ya Chuang, NCEP: This script uses # NCEP's Unipost to post processes WRF native model # output, and uses copygb to horizontally interpolate posted # output from native A-E to a regular projection grid. # # July 2006: Meral Demirtas, NCAR/DTC: Added new "copygb" # options and revised some parts for clarity. # #-11-20-14 #-11-20-14 Mods by Lee Byerle on handling global WRF files and #-11-20-14 results in single grib1 file in output #-11-20-14 dir ./postprd/grbout for entire forecast, #-11-20-14 instead of default grib1 file every output time. #-11-20-14 Must make /postprd/grbout dir before running #-11-20-14 grib2ctl.pl not making xdef/ydef for global grid #-11-20-14 so must add xdef/ydef to ctl file and re-run gribmap #-11-20-14 see #-11-20-14 comments #-11-20-14 Updates to GrADS visualization scripts, #-11-20-14 add'l fields plotted and adds date/time stamps #-11-20-14 # January 2019: Modified to remove NMM, put user edits all at top of script, TH (DTC) #-------------------------------------------------------- # This script performs 3 jobs: # # 1. Run Unipost # 2. Run copygb to horizontally interpolate output from # native A-E to a regular projection grid (optional) # 3. Run GrADS to plot results. #-------------------------------------------------------- #---------------------------------------------------------------------------------- #--- USER EDIT DESCIPTIONS -------------------------------------------------------- # See UPP User's Guide for more information # http://www.dtcenter.org/upp/users/docs/user_guide/V4/upp_users_guide.pdf #---------------------------------------------------------------------------------- # TOP_DIR : Top level directory for source codes (UPPV4.0) # DOMAINPATH : Working directory for this run. # UNIPOST_HOME : Where the UPP build directory located # POSTEXEC : Where the UPP executables are located # SCRIPTS : Where the UPP scripts directory is (i.e. UPPV4.0/scripts/) # modelDataPath : Where are the model data files to be processed located # : e.g. "wrfprd/" for WRF-based runs # paramFile : Name and location of cntrl.parm file (wrf_cntrl.parm) # Text file lists desired fields for grib1 output. Template in UPPV4.0/parm/ # txtCntrlFile : Name and location of post flat file (postxconfig-NT.txt) for grib2 # Text file listing desired fields to be generated by the user before running UPP. # Step 1: Edit postcntrl.xml to include desired fields (template in UPPV4.0/parm) # Step 2: Validate postcntrl.xml and post_avblflds.xml # Step 3: Type 'make' in parm directory to generate the post flat file # dyncore : What model is used ARW (WRF) # inFormat : Format of the model data # arw - "netcdf" # outFormat : Format of output from UPP # grib # grib2 # startdate : Forecast start date (YYYYMMDDHH) # fhr : First forecast hour to be post-processed # lastfhr : Last forecast hour to be post-processed # incrementhr : Increment (in hours) between forecast files # * Do not set to 0 or the script will loop continuously * # domain_list : List of domains for run # RUN_COMMAND : System run command for serial or parallel runs, examples below. # copygb_opt : Copygb grid specfication option to regrid (optional) # "awips" = Use a predefined awips grid, e.g. 212 # ** Uncomment "export awips_id= " and add desired grid number. # "custom" = Specify your own grid # ** Uncomment "export custom_gds= " and add grid description. # #---------------------------------------------------------------------------------- #--- BEGIN USER EDIT HERE --------------------------------------------------------- #---------------------------------------------------------------------------------- export TOP_DIR=/home/username export DOMAINPATH=${TOP_DIR}/DOMAINS/test_case export UNIPOST_HOME=${TOP_DIR}/UPPV4.0 export POSTEXEC=${UNIPOST_HOME}/bin export SCRIPTS=${UNIPOST_HOME}/scripts export modelDataPath=${DOMAINPATH}/wrfprd export paramFile=${DOMAINPATH}/parm/wrf_cntrl.parm # grib1 (WRF only) export txtCntrlFile=${DOMAINPATH}/parm/postxconfig-NT-WRF.txt # grib2 # Specify Dyn Core (ARW in upper case) export dyncore="ARW" # Set input format from model and ouput format from unipost export inFormat="netcdf" export outFormat="grib2" # Set date/time information export startdate=2014070300 export fhr=00 export lastfhr=24 export incrementhr=06 # Set domain lists export domain_list="d01" # Set run command: # Serial command example export RUN_COMMAND="${POSTEXEC}/unipost.exe " # Parallel command examples: #export RUN_COMMAND="mpirun -np 1 ${POSTEXEC}/unipost.exe " #export RUN_COMMAND="mpirun.lsf ${POSTEXEC}/unipost.exe " #export RUN_COMMAND="mpiexec_mpt ${POSTEXEC}/unipost.exe " # DEBUG command example found further below, search "DEBUG" # Optional: Specify COPYGB grid spec for regridding # (options are awips or custom) #export copygb_opt="custom" # If using awips grid, uncomment awips_id and modify to desired grid # If familiar with copygb and selecting custom, uncomment custom_gds # and modify to fit your needs. Use at own risk! #export awips_id="212" #export custom_gds="255 3 109 91 37748 -77613 8 -71000 10379 9900 0 64 42000 42000" # Shouldn't need to edit these. # tmmark is an variable used as the file extention of the output # filename .GrbF is used if this variable is not set # COMSP is a variable used as the initial string of the output filename export tmmark=tm00 export MP_SHARED_MEMORY=yes export MP_LABELIO=yes #---------------------------------------------------------------------- #--- END USER EDIT ---------------------------------------------------- #---------------------------------------------------------------------- #---------------------------------------------------------------------- # Shouldn't need to edit below unless something goes wrong or debugging #---------------------------------------------------------------------- #---------------------------------------------------------------------- # Do some checks for directory/executable existence, user input, etc. #---------------------------------------------------------------------- if [ ! -d ${POSTEXEC} ]; then echo "ERROR: POSTEXEC, '${POSTEXEC}', does not exist" exit 1 fi if [ ! -x ${POSTEXEC}/unipost.exe ]; then echo "ERROR: unipost.exe, '${POSTEXEC}/unipost.exe', does not exist or is not executable." exit 1 fi if [ ! -x ${POSTEXEC}/copygb.exe ]; then echo "ERROR: copygb.exe, '${POSTEXEC}/copygb.exe', does not exist or is not executable." exit 1 fi if [ ! -x ${POSTEXEC}/ndate.exe ]; then echo "ERROR: ndate.exe, '${POSTEXEC}/ndate.exe', does not exist or is not executable." exit 1 fi # Set tag based on user defined $dyncore (ARW or FV3 in upper case) if [ $dyncore = "ARW" ]; then export tag=NCAR else echo "${dyncore} is not supported. Edit script to choose ARW dyncore." exit fi if [[ ${dyncore} == "ARW" ]]; then if [[ ${inFormat} != "netcdf" ]]; then echo "ERROR: 'inFormat' must be 'netcdf' for ARW model output. Exiting... " exit 1 fi fi if [[ ${outFormat} == "grib" ]]; then if [ ! -e ${paramFile} ]; then echo "ERROR: 'paramFile' not found in '${paramFile}'. Exiting... " exit 1 fi elif [[ ${outFormat} == "grib2" ]]; then if [ ! -e ${txtCntrlFile} ]; then echo "ERROR: 'txtCntrlFile' not found in '${txtCntrlFile}'. Exiting... " exit 1 fi fi if [ ! -d ${DOMAINPATH}/postprd ]; then echo "ERROR: DOMAINPATH/postprd, '${DOMAINPATH}/postprd', does not exist. Exiting..." exit 1 fi if [ ${incrementhr} -eq 0 ]; then echo "ERROR: increment hour (incrementhr) cannot be zero. Inifinite loop will result. Please modify. Exiting..." exit 1 fi if [ ${copygb_opt} == 'awips' ]; then if [ -z ${awips_id} ]; then echo "ERROR: copygb_opt = '${copygb_opt}', must uncomment and set 'awips_id'. Exiting..." exit 1 fi fi if [ ${copygb_opt} == 'custom' ]; then if [ -z ${custom_gds} ]; then echo "ERROR: copygb_opt = '${copygb_opt}', must uncomment and set 'custom_gds'. Exiting..." exit 1 fi fi #---------------------------------------------------------------------- # End checks of user input #---------------------------------------------------------------------- #---------------------------------------------------------------------- # Begin work #---------------------------------------------------------------------- # cd to working directory cd ${DOMAINPATH}/postprd err1=$? if test "$err1" -ne 0; then echo "ERROR: Could not 'cd' to working directory. Did you create directory: '${DOMAINPATH}/postprd'? \ Does '${DOMAINPATH}' exist? Exiting... " exit 1 fi # Get local copy of parm file # For GRIB1 the code uses wrf_cntrl.parm to select variables for output # the available fields are set at compilation if [[ ${outFormat} == "grib" ]]; then ln -fs ${paramFile} wrf_cntrl.parm elif [[ ${outFormat} == "grib2" ]]; then # For GRIB2 the code reads postxconfig-NT.txt to select variables for output # the available fields are defined in post_avlbflds.xml -- while we # set a link to this file for reading during runtime it is not typical # for one to update this file, therefore the link goes back to the # program directory - this is true for params_grib2_tbl_new also - a # file which defines the GRIB2 table values ln -fs ${txtCntrlFile} postxconfig-NT.txt ln -fs ${UNIPOST_HOME}/parm/post_avblflds.xml post_avblflds.xml ln -fs ${UNIPOST_HOME}/src/lib/g2tmpl/params_grib2_tbl_new params_grib2_tbl_new fi # Link microphysics tables - code will use based on mp_physics option # found in data ln -fs ${UNIPOST_HOME}/parm/nam_micro_lookup.dat . ln -fs ${UNIPOST_HOME}/parm/hires_micro_lookup.dat . # link coefficients for crtm2 (simulated synthetic satellites) CRTMDIR=${UNIPOST_HOME}/src/lib/crtm2/src/fix ln -fs $CRTMDIR/EmisCoeff/IR_Water/Big_Endian/Nalli.IRwater.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/MW_Water/Big_Endian/FASTEM4.MWwater.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/MW_Water/Big_Endian/FASTEM5.MWwater.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/MW_Water/Big_Endian/FASTEM6.MWwater.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/IR_Land/SEcategory/Big_Endian/NPOESS.IRland.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/IR_Snow/SEcategory/Big_Endian/NPOESS.IRsnow.EmisCoeff.bin ./ ln -fs $CRTMDIR/EmisCoeff/IR_Ice/SEcategory/Big_Endian/NPOESS.IRice.EmisCoeff.bin ./ ln -fs $CRTMDIR/AerosolCoeff/Big_Endian/AerosolCoeff.bin ./ ln -fs $CRTMDIR/CloudCoeff/Big_Endian/CloudCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/imgr_g11.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/imgr_g11.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/imgr_g12.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/imgr_g12.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/imgr_g13.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/imgr_g13.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/imgr_g15.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/imgr_g15.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/imgr_mt1r.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/imgr_mt1r.TauCoeff.bin ln -fs $CRTMDIR/SpcCoeff/Big_Endian/imgr_mt2.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/imgr_mt2.TauCoeff.bin ln -fs $CRTMDIR/SpcCoeff/Big_Endian/imgr_insat3d.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/imgr_insat3d.TauCoeff.bin ln -fs $CRTMDIR/SpcCoeff/Big_Endian/amsre_aqua.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/amsre_aqua.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/tmi_trmm.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/tmi_trmm.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmi_f13.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmi_f13.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmi_f14.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmi_f14.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmi_f15.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmi_f15.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmis_f16.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmis_f16.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmis_f17.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmis_f17.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmis_f18.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmis_f18.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmis_f19.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmis_f19.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/ssmis_f20.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/ssmis_f20.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/seviri_m10.SpcCoeff.bin ./ ln -fs $CRTMDIR/TauCoeff/ODPS/Big_Endian/seviri_m10.TauCoeff.bin ./ ln -fs $CRTMDIR/SpcCoeff/Big_Endian/v.seviri_m10.SpcCoeff.bin ./ ####################################################### # 1. Run Unipost # # The Unipost is used to read native WRF model # output and put out isobaric state fields and derived fields. ####################################################### export NEWDATE=$startdate while [ $((10#${fhr})) -le $((10#${lastfhr})) ]; do # Formatted fhr for filenames fhr=`printf "%02i" ${fhr}` NEWDATE=`${POSTEXEC}/ndate.exe +$((10#${fhr})) $startdate` YY=`echo $NEWDATE | cut -c1-4` MM=`echo $NEWDATE | cut -c5-6` DD=`echo $NEWDATE | cut -c7-8` HH=`echo $NEWDATE | cut -c9-10` echo 'NEWDATE' $NEWDATE echo 'YY' $YY # Begin looping through domains list for domain in ${domain_list}; do # Create model file name (inFileName) dom_id=`echo "${domain}" | cut -d 'd' -f 2` inFileName=${modelDataPath}/wrfout_d${dom_id}_${YY}-${MM}-${DD}_${HH}:00:00 # Check if the files exist if [[ ! -e ${inFileName} ]]; then echo "ERROR: Can't find 'inFileName': ${inFileName}. Directory or file does not exist. Exiting..." echo "ERROR: Check if 'modelDataPath': ${modelDataPath} exists." echo "ERROR: Check if file: 'wrfout_d${dom_id}_${YY}-${MM}-${DD}_${HH}:00:00' exists in modelDataPath." exit 1 fi # Create itag based on user provided info. # Output format now set by user so if-block below uses this # to generate the correct itag. if [[ ${outFormat} == "grib" ]]; then cat > itag <<EOF ${inFileName} ${inFormat} ${YY}-${MM}-${DD}_${HH}:00:00 ${tag} EOF elif [[ ${outFormat} == "grib2" ]]; then cat > itag <<EOF ${inFileName} ${inFormat} ${outFormat} ${YY}-${MM}-${DD}_${HH}:00:00 ${tag} EOF else echo "ERROR: output format 'outFormat=${outFormat}' not supported, must choose 'grib' or 'grib2'. Exiting..." exit 1 fi #----------------------------------------------------------------------- # Run unipost. #----------------------------------------------------------------------- rm fort.* ln -sf ${paramFile} fort.14 #---------------------------------------------------------------------- # There are two environment variables tmmark and COMSP # RUN the unipost.exe executable. #---------------------------------------------------------------------- ${RUN_COMMAND} > unipost_${domain}.${fhr}.out 2>&1 # This prefix was given in the wrf_cntl.parm file (GRIB1) # or postcntrl.xml(GRIB2) mv WRFPRS${fhr}.${tmmark} WRFPRS_${domain}.${fhr} # #---------------------------------------------------------------------- # End of unipost job #---------------------------------------------------------------------- # check to make sure UPP was successful and script linked the file ls -l WRFPRS_${domain}.${fhr} err1=$? if test "$err1" -ne 0; then echo 'UNIPOST FAILED, EXITTING' exit fi ####################################################################### # EXAMPLES of running copygb ####################################################################### # # Copygb interpolates unipost output from its native # grid to a regular projection grid. The package copygb # is used to horizontally interpolate from one domain # to another, but this is not necessary for WRF-ARW. # # Copygb can be run in 2 ways as explained below. # # NOTE: This section is providied as examples of the various ways to # run copygb. The script runs copygb based on user input above # (copygb_opt).The user will need to uncomment running copygb below # in order to do so. # #---------------------------------------------------------------------- # # Option 1: # Copygb is run with a pre-defined AWIPS grid # (variable $awips_id, see above in user edit section). Specify # the grid to interpolate the forecast onto. To use standard AWIPS # grids (list in http://www.nco.ncep.noaa.gov/pmb/products/nam/ # or http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html), # set the number of the grid in variable awips_id which is then # passed to $nav variable for processing. # # ${POSTEXEC}/copygb.exe -xg"212" WRFPRS_${domain}.${fhr} wrfprs_${domain}.${fhr} # #---------------------------------------------------------------------- # # Option 2: # Copygb ingests a custom kgds definition. Grid definition is set above in the # User Edit section (custom_gds) and then passed to the $nav variable # for processing. # # ${POSTEXEC}/copygb.exe -xg"255 3 109 91 37748 -77613 8 -71000 10379 9900 0 64 42000 42000" WRFPRS_${domain}.${fhr} wrfprs_${domain}.${fhr} # #---------------------------------------------------------------------- # # (For more info on "copygb" see UPP User's Guide - link at top of script) # ####################################################################### # End EXAMPLES Section ####################################################################### # ####################################################################### # To run copygb, uncomment sections below ####################################################################### #if [[ ${outFormat} == "grib" ]]; then ##------------------------------------------------------------------------------------- ## 2. Run copygb. ##------------------------------------------------------------------------------------- ## Set grid specs file to read based on user specifications (copygb_opt) ## in User Edit Section at top of script. #if [[ ${copygb_opt} == "awips" ]]; then # export nav=${awips_id} # echo "copygb_opt = ${copygb_opt}, using awips_id=${awips_id} to run copygb." # echo $nav #elif [[ ${copygb_opt} == "custom" ]]; then # echo ${custom_gds} > 'copygb_custom.txt' # read nav < 'copygb_custom.txt' # export nav # echo "copygb_opt = ${copygb_opt}, using custom_gds=${custom_gds} to run copygb." # echo $nav #fi ## Execute copygb with grid specs read into ${nav} and check if successful #if [[ ${dyncore} == "ARW" ]]; then # ${POSTEXEC}/copygb.exe -xg"${nav}" WRFPRS_${domain}.${fhr} wrfprs_${domain}.${fhr} # ls -l wrfprs_${domain}.${fhr} # err1=$? #fi #if test "$err1" -ne 0; then # echo 'copygb FAILED, EXITTING' # exit #fi # End test block for file #elif [[ ${outFormat} == "grib2" ]]; then # echo "Warning: nothing done for grib2 output using copygb, see wgrib2 for regridding grib2 output" #fi # End if-block for if grib or grib2 #---------------------------------------------------------------------- # End of copygb job #---------------------------------------------------------------------- ####################################################### # 3. Run GrADS to plot results. # Use GrADS to first create GrADS control and index # (or bitmap) files and then plot various fields. ####################################################### # creating GrADS index or bitmap file rm -f WRFPRS_${domain}_${fhr}.ctl #Choose script to create grads .ctl file: #(Not currently used) #For grib1 use grib2ctl #For grib2 use g2ctl #set ictlpl = "grib2ctl" #set ictlpl = "g2ctl" #-11-20-14 grib2ctl.pl -verf WRFPRS_${domain}.${fhr} > WRFPRS_${domain}_${fhr}.ctl #-7-1-14 ${ictlpl}.pl -verf wrfprs_${domain}.${fhr} > wrfprs_${domain}_${fhr}.ctl #-5-31-14 clab below for grib2 files #/gpfs/home/lbyerle/grads/g2ctl.pl -verf wrfprs_${domain}.${fhr} > wrfprs_${domain}_${fhr}.ctl # GrADS has problem plotting vorticity because it's not posted on all 39 pressure levels # modify control file to define a 500 mb vorticity field #-11-20-14 #-6-30-14 sed -i '10ixdef 256 linear 0.70 1.4062' WRFPRS_${domain}_${fhr}.ctl sed -i '11iydef 128 linear -89.30 1.4062' WRFPRS_${domain}_${fhr}.ctl #-6-30-14 #-11-20-14 cp WRFPRS_${domain}_${fhr}.ctl WRFPRS_${domain}_${fhr}.ctl_org # creating GrADS index or bitmap file gribmap -i WRFPRS_${domain}_${fhr}.ctl #-11-20-14 #grads << EOF cat > plotgrads << EOF *-11-20-14 *clab-7-3-14 Retreive 00-hour date time stamp: *open 00-hour file: 'open WRFPRS_d01_00.ctl' 'q dims' res=sublin(result,5) ttim=subwrd(res,6) *Initial time: say ttim 'close 1' * 'open WRFPRS_${domain}_${fhr}.ctl' *clab-7-3-14 Date and forecast hour info: 'query time' lndate=sublin(result,1) lnhdate=subwrd(lndate,3) say lnhdate *get forecast hour from file name: 'query file' ifr=sublin(result,1) iifr=subwrd(ifr,4) say iifr iiifr=substr(iifr,12,3) say iiifr * 'set lat 23 52' 'set lon 260 300' 'set display color white' 'set mpdset hires' 'set gxout shaded' *'set clevs 0.01 1 3 6 9 12 15 18 21' *'set rbcols 0 10 13 5 11 4 8 2 6 9' 'run jaecol.gs' *regular: *'set clevs 0.01 0.10 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.50 3.00 4.00 5.00 6.00 7.00 8.00 9.00' *Hurricane: *'set clevs 0.25 0.50 1.00 1.50 2.00 2.50 3.00 4.00 5.00 7.00 9.00 11.00 13.00 15.00 17.00 19.00 20.00 21.00' 'set clevs 0.01 0.10 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.50 3.00 4.00 5.00 7.00 9.00 11.00 12.00' 'set ccols 0 34 37 39 49 46 44 42 53 55 57 28 27 26 25 24 23 22 21 0' 'set rbcols 0 34 37 39 49 46 44 42 53 55 57 28 27 26 25 24 23 22 21' 'd APCPsfc' 'cbarn.gs' *'cbar' 'set gxout contour' 'set ccolor 9' 'set cint 2' *'set clab off' 'd MSLETmsl/100' 'draw title 6-Hour precip. accum. (shaded-in) & MSLP (hPa)\ 'ttim' F+'iiifr' HR, Valid at 'lnhdate *'draw title Accumulated Total precipitation (shaded-in) & MSLP (hPa)\ 'ttim' F+'iiifr' HR, Valid at 'lnhdate **'draw title Accumulated Total precipitation (shaded-mm) & MSLP (hPa)' 'printim Sfcmap${fhr}_${domain}_GrADS.gif gif' *'gxyat Sfcmap${fhr}_${domain}_GrADS.png' 'clear' 'set gxout shaded' 'set clevs 70 75 80 85 90 92 94 96 98 99' 'set rbcols 0 10 13 5 11 4 8 6 2 9 15' 'set lev 850' 'd RHprs' 'cbar' 'draw title RH at 850 hPa (shaded-%)\ 'ttim' F+'iiifr' HR, Valid at 'lnhdate *'draw title RH at 850 hPa (shaded-%)' 'printim 850mbRH${fhr}_${domain}_GrADS.gif gif' *'gxyat 850mbRH${fhr}_${domain}_GrADS.png' 'clear' 'set gxout shaded' 'set clevs -20 -15 -10 -5 0 5 10 15 20' 'set rbcols 0 4 11 15 13 8 6 2 9 15' 'set lev 850' 'd TMPprs-273' 'cbar' 'set gxout contour' 'set cthick 3' 'set clevs -20 -15 -10 -5 0 5 10 15 20' 'set ccolor 1' 'd TMPprs-273' 'set gxout barb' 'set cthick 3' 'set ccolor 1' 'd skip(ugrdprs*1.94,2);vgrdprs*1.94' *'d ugrdprs;skip(vgrdprs,5)' 'draw title Temperature (shaded-C) & winds (Kt) at 850 hPa\ 'ttim' F+'iiifr' HR, Valid at 'lnhdate *'draw title Temperature (shaded-C) & winds (m/s) at 850 hPa' 'printim 850mbTempandWind${fhr}_${domain}_GrADS.gif gif' *'gxyat 850mbTempandWind${fhr}_${domain}_GrADS.png' 'clear' 'set gxout shaded' 'set clevs 1.6 2.0 2.4 2.8 3.2 3.6 4' *clab'set clevs -2.4 -2.0 -1.6 1.6 2.0 2.4 3.0' 'set rbcols 0 10 13 5 11 4 8 2' 'set lev 500' 'd ABSVprs*10000' *'define h1= hcurl(ugrdprs,vgrdprs)' *'d h1*1000' 'cbar' 'set gxout contour' 'set ccolor 7' 'd HGTprs' *'draw title Abs Vort (shaded-10^5 s-1) & geo hgt (contour-m) at 500 hPa' 'draw title Abs Vort (shaded-10^5 s-1) & geo hgt (contour-m) at 500 hPa\ 'ttim' F+'iiifr' HR, Valid at 'lnhdate 'printim 500mbHandVort${fhr}_${domain}_GrADS.gif gif' *'gxyat 500mbHandVort${fhr}_${domain}_GrADS.png' 'clear' 'set lat -80 80' 'set x 1 256' 'set gxout shaded' 'set clevs 20 30 35 40 45 50 65' *'set clevs 20 25 30 35 40 45 50' 'set rbcols 0 10 13 5 11 4 8 6' 'set lev 250' *'d sqrt(ugrdprs*ugrdprs+vgrdprs*vgrdprs)' *clab-7-2-14 plots the max wind in the column: 'd sqrt(UGRDmwl*UGRDmwl+VGRDmwl*VGRDmwl)' 'cbar' 'set gxout contour' 'set ccolor 7' 'd HGTprs' 'draw title Max Speed (shaded-m/s) & 250 hPa height (contour-m)\ 'ttim' F+'iiifr' HR, Valid at 'lnhdate *'draw title Speed (shaded-m/s) & geo height (contour-m) at 250 hPa' 'printim 250mbWindandH${fhr}_${domain}_GrADS.gif gif' *'gxyat 250mbWindandH${fhr}_${domain}_GrADS.png' 'quit' EOF grads -blc "run plotgrads" #gradsc -blc "run plotgrads" #---------------------------------------------------------------------- # End of GrADS job #---------------------------------------------------------------------- done fhr=$((10#${fhr}+$((${incrementhr})))) NEWDATE=`${POSTEXEC}/ndate.exe +$((10#${fhr})) $startdate` done date echo "End of Output Job" #-11-20-14 #clab-6-29-14 #cat all grib files to 1 and then run grib2ctl on them #at end of loop, and then invoke sed to add xdef, ydef and update to #tdef to give 6hr and correct number of times and THEN gribmap. #make ctl file to check gfs file that will init model #clab #above generated gifs go here for html: #-11-20-14 optional location to place gifs cp *.gif /p/CWFS3/lbyerle/wrf/global/html/gif #-11-20-14 Before running this script #-11-20-14 make dir under postprd called grbout #-11-20-14 grib2ctl.pl goes in this dir and it is location where #-11-20-14 a single grib1 file will be created, along w/GrADS ctl file #-11-20-14 upon completion rm ./grbout/WRFPRS* cp WRFPRS* ./grbout #This section is to get a single ctl file and grib file cd ./grbout ls -l ../unipost_d01*.out | wc -l > temp itdef=`head -1 temp` echo "Number of times is ${itdef}" ls -1 ../unipost_d01*.out > temp2 head -2 temp2 > temp3 tail -1 temp3 > temp4 awk 'length > 1 {print substr($1,16,2)}' temp4 > temp5 incrhr=`head -1 temp5` echo "Hour Increment is ${incrhr}" rm temp temp2 temp3 temp4 temp5 #clab For bash need extra char up front, since starts at 0, not 1 ispellmon=( dummy Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) #Next get yymmddhh for the control file: wgrib -s -4yr -d 1 WRFPRS_${domain}.00 > temptim awk 'length > 1 {print substr($1,7,4)}' temptim > tempyr awk 'length > 1 {print substr($1,11,2)}' temptim > tempmo awk 'length > 1 {print substr($1,13,2)}' temptim > tempdy awk 'length > 1 {print substr($1,15,2)}' temptim > temphr iyr=`head -1 tempyr` echo "Initial Year is ${iyr}" imn=`head -1 tempmo` echo "Initial Month is ${imo}" idy=`head -1 tempdy` echo "Initial Day is ${idy}" ihr=`head -1 temphr` echo "Initial Hour is ${ihr}" rm temptim tempyr tempmo tempdy temphr #mv/remove old files mv wrf_${domain}_all.grib ./archive/wrf_${domain}_all_${iyr}${imn}${idy}${ihr}.grib rm *.idx mv wrf_${domain}_all.ctl ./archive/wrf_${domain}_all_${iyr}${imn}${idy}${ihr}.ctl #rm temp_wrf_${domain}_all.ctl cat WRFPRS* > wrf_${domain}_all.grib grib2ctl.pl wrf_${domain}_all.grib > temp_wrf_${domain}_all.ctl #-6-5-14 #-11-20-14 grib2ctl.pl not adding xdef ydef for the global WRF ctl file #-11-20-14 Below adds appropriate xdef and ydef to ctl file, hardwired for 1.4-deg run #-11-20-14 edit as required from namelist.wps, based upon global model resolution sed -i '10ixdef 256 linear 0.70 1.4062' temp_wrf_${domain}_all.ctl sed -i '11iydef 128 linear -89.30 1.4062' temp_wrf_${domain}_all.ctl sed "8,8s/^.*/TDEF ${itdef} LINEAR ${ihr}Z${idy}${ispellmon[$imn]}${iyr} ${incrhr}hr/g" temp_wrf_${domain}_all.ctl > wrf_${domain}_all.ctl gribmap -i wrf_${domain}_all.ctl rm temp_wrf_${domain}_all.ctl echo ALL DONE #-11-20-14 exit