User’s Guide for Advanced Research WRF (ARW) Modeling System Version 2

 

Appendix B: Old Post-Processing Utilities

Table of Contents

·        Introduction

·        NCL

·        WRF2GrADS

·        WRF2VIS5D

Introduction

 

The WRF_NCL package (as describe in this chapter) has been intergraded into the NCL libraries (http://www.ncl.ucar.edu,, and are no longer needed to generate NCL images from ARW WRF model data. For more details on how to use the new functions and procedures in the NCL libraries, see chapter 8.

 

 

The software packages WRF2GrADS and WRF2VIS5D are being phased out. The new package, ARWpost, has replaced both of these packages.  ARWpost is describe in detail in chapter 8 of this user’s guide.

 




NCL

 

Ready-made NCL scripts are provided to create meta files for both real and ideal datasets. These scripts are relatively easy to read and change to generate different or more plots.

 

These notes describe the September 2005 release. This release requires high-level NCL scripts to run. This release can process ARW static/input and output files, as well as WRF-Var output data. This package can process both single and double precision data.

What is NCL

 

The NCAR Command Language (NCL) is a free interpreted language designed specifically for scientific data processing and visualization. NCL has robust file input and output. It can read in netCDF, HDF4, HDF4-EOS, GRIB, binary and ASCII data. The graphics are world class and highly customizable.

 

It runs on many different operating systems including Solaris, AIX, IRIX, Linux, MacOSX, Dec Alpha, and Cygwin/X running on Windows. The NCL binaries are freely available at: http://www.ncl.ucar.edu/Download/

 

To read more about NCL, please visit: http://www.ncl.ucar.edu/overview.shtml

Necessary software

·        Obtain the WRF_NCL TAR file from the WRF Download page (http://www2.mmm.ucar.edu/wrf/users/download/get_source.html)

·        NCAR Command Language libraries (http://www.ncl.ucar.edu/). This WRF_NCL beta release requires at least NCL version 4.2.0.a032 to run.

Hardware

The code has been tested on the following machines

·        DEC Alpha

·        IBM

·        Linux (pgi and intel compilers)

·        MAC

The code should run equally well on other machines, but has not been tested on all platforms.

Steps to compile and run

Untar WRF_NCL TAR file

Inside the TAR file, you will have the following files:

    

DOThluresfile

Control plotting background
MUST be copied to
     ~/.
hluresfile
before any scripts are run

README_FIRST

README_NCL

gsn_code.ncl

SkewTFunc.ncl

WRFOptions.ncl
WRFPlot.ncl

WRFUserARW.ncl 

Readme Files and

NCL function scripts

           

wrf_user_fortran_util_0.f

make_ncl_fortran

make_ncl_fortran.alpha

make_ncl_fortran.ibm

make_ncl_fortran.ibm64

make_ncl_fortran.linux

make_ncl_fortran.sun   

FORTRAN utility file and

make files to compile the utility program

wrf_bwave.ncl

wrf_grav2d.ncl

wrf_hill2d.ncl
wrf_qss.ncl

wrf_squall_2d_x.ncl

wrf_squall_2d_y.ncl

 

wrf_real_input.ncl

wrf_real.ncl

wrf_cloud.ncl

NCL scripts for ideal and real data

 

 

FIRST

Copy the file DOThluresfile to ~/.hluresfile

This file controls the color / background / fonts and basic size of your plot. This file MUST have the name .hluresfile, and MUST be located in your home directory.

For more information regarding this file, see:
http://www.ncl.ucar.edu/Document/Graphics/hlures.shtml

Build the external function, wrf_user_fortran_util_0.so

·        NCL has the ability to link in FORTRAN shareable object files. This provides an easy way to compute diagnostic quantities and to performing interpolations.

·         Presently, only one FORTRAN object needs to be built -        wrf_user_fortran_util_0.so

·        To build the FORTRAN object, run the “WRAPIT” script provided by NCL:
           e.g. WRAPIT wrf_user_fortran_util_0.f
           HINT:
you may need to find the script and use the full path to this script.

·        If successful, you will see the following file created in your WRF_NCL directory:
           wrf_user_fortran_util_0.so

·        Under rare occasions, this script may not work. In this case, try one of the make_ncl_fortran csh scripts provided in the WRF_NCL directory.

e.g. make_ncl_fortran    wrf_user_fortran_util_0
                 
HINT:  The most common error when building the external function,
                  is not finding the “wrapit77” function on your system. “wrapit77” is part
                  of the NCAR Graphics routines. If you run into this problem, make sure

 your path to this function is setup correctly. (If all else fails, locate the file

 on your system and copy it to your WRF_NCL directory.

·        If successful, you will see these files created in your WRF_NCL directory:

                        so_locations

                        wrf_user_fortran_util_0.o

                  wrf_user_fortran_util_0.so

·        For more information about WRAPIT and wrapit77, see:
http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclExtend.shtml

 

Edit the script you want to run
 

·        Change the location and name of the file:

a = addfile("../../WRFV2/run/wrfout_d01_2000-01-24_00:00:00.nc","r")

·        Do not remove the ".nc" after the file name - the script needs it to determine which type of input file (netCDF) it is dealing with (Note the .nc is NOT part of the actual file name.)

·        Specify the type of plot you want to generate:
           type =  ……
           Options are x11, pdf, ps, ncgm

·        Specify the output file name:
           wks = gsn_open_wks(type,”MyOutput”)

·        Give your output a title:
           res@MainTitle  =  “REAL-TIME ARW”





Control plotting options with WRFOptions.ncl

MainTitlePos

Options are top Left, Center, Right

InitTime

Add Initial Time to plot

ValidTime

Add Valid Time to Plot
Switch off for files which do not have a valid time

TimePos

Placement of Time Information. Options are top Left or Right. If MainTitlePos and TimePos are on same side, Time Information will be plotted under the Main Title

Footer

Add some model information as a Footer to the plots

mpOutlineBoundarySets

Default is GeophysicalandUSStates
Alternatively set to AllBoundaries

 

 

Basic flow of an NCL script

 

load "WRFOptions.ncl"   ; set basic plot options here
load "gsn_code.ncl"     ; high-level NCL scripts
load "WRFPlot.ncl"      ; WRF functions / procedures
load "WRFUserARW.ncl"   ; Diagnostics

begin

  a = addfile("wrfout_d01_2000-01-24_12:00:00.nc","r") ; open file

  type = "pdf"    ; Will create pdf output files
  wks = gsn_open_wks(type,"wrfout") ; open workstation + set output

  res@MainTitle    = "ARW Real Data"  ; Set plot title

  times  = wrf_user_list_times(a)  ; get times in the file
  ntimes = dimsizes(times)         ; number of times in the file

  do it = 0,ntimes-1          ; loop through file for all times

    res@TimeLabel  = times(it)      ; Set Valid time info

    map = wrf_map(wks,a,res)        ; Create a map background 
 
    ter = wrf_user_getvar(a,"HGT",time)   ; get terrain from file

    t2  = wrf_user_getvar(a,"T2",time)    ; get T2 from file     

   ; Set options and create terrain plot

    opts_ter = res                         
    opts_ter@cnFillOn           = True
    contour_ter  = wrf_contour(a,wks,ter,opts_ter)

 

  ; Set options and create t2 plot

    opts_t2 = res                         
    contour_t2  = wrf_contour(a,wks,t2,opts_t2) 

 

   ; Overplay terrain and t2 plots and place on map background
    wrf_map_overlay(wks,map,(/contour_ter, contour_t2/),False)

  end do

end


Run the NCL script

·        To run the script, type:

ncl < NCL_script   (or “ncl  NCL_script”  for higher versions of NCL)

e.g.     ncl < wrf_real.ncl

·        This will create an output file

e.g. MyOutput.(pdf/ps/ncgm)
                  If type of output was set to “x11”, no hardcopy will be produced.

·        The name of the graphics file that is created, is controlled by the line:

   wks = gsn_open_wk (type,"MyOutput")     inside the NCL script

View the output file

·        To view a meta file (type = ncgm), use the command "idt", e.g.

idt   MyOutputs.ncgms

·        Examples of plots created for both idealized and real cases are available from:

http://www2.mmm.ucar.edu/wrf/users/graphics/WRF_NCL/NCL.htm 

 

Miscellaneous

For print quality images, create pdf or ps images directly via the ncl scripts (type = pdf / ps).

 

To convert NCGM files to GIF images, a very handy tool is the ncgm2gif script (http://ngwww.ucar.edu/info/ncgm2gif)

To run the script, type:

   ncgm2gif    metafile

        e.g.     ncgm2gif -res 500x500 -nomerge test.cgm

This will convert all images in test.cgm to 500x500 pixel gif images, called testxxx.gif

A compete list of options are available inside the ncgm2gif script (http://ngwww.ucar.edu/info/ncgm2gif)


WRF2GrADS

 

The WRF2GrADS converter reads ARW netCDF files, and creates "ieee", GrADS data files, and corresponding grads_control (.ctl) files.

 

The converter can process all ARW input, output and static (real and idealized data) in netCDF format.

 

Necessary software

·        Obtain the WRF2GrADS TAR file from the WRF Download page (http://www2.mmm.ucar.edu/wrf/users/download/get_source.html)

·        GrADS software - You can download and install GrADS from   http://grads/iges.org/grads

Hardware

The code has been ported to the following machines

·        DEC Alpha

·        Linux (pgf and intel compilers)

·        MAC

·        SUN

·        SGI

·        IBM

Steps to compile and run

Untar WRF2GrADS TAR file

            Inside the TAR file you will have the following files:

Makefile
README

 

control_file
control_file_height
control_file_pressure

Sample control file

module_wrf_to_grads_netcdf.F
module_wrf_to_grads_util.F
wrf_to_grads.F

Source code

cbar.gs
rgbset.gs

Utility scripts

skew.gs
real_surf.gs
plevels.gs
rain.gs
cross_z.gs
zlevels.gs
input.gs
bwave.gs
grav2d.gs
hill2d.gs
qss.gs
sqx.gs
sqy.gs

Sample scripts to generate plots for real/idealized datasets

 Compile

·        To compile the code, EDIT the Makefile to select the compiler flags for your machine

·        Type:    make

·        This will create a   wrf_to_grads   executable

Edit the control_file file

-2
2000-01-24_12:00:00
2000-01-24_18:00:00
2000-01-25_00:00:00
end_of_time_list

Times to process

o  If the first line contains a negative number, ALL times in the WRF file are processed.

o  A positive number means process that number of times. In this case the times to process must be listed.

o  The number in the first line, do not need to match the number of times listed. For the case where a positive number is used, the first x number of times will be processed.

o  Do not remove or indent the line "end_of_time_list", the code depends on this line.

U                   ! U Compoment of wind
V                   ! V Component of wind
   UMET           ! U wind - rotated
   VMET           ! V wind - rotated 
W                  ! W Component of wind
THETA          ! Theta
TK                 ! Temperature in K
TC                 ! Temperature in C
TKE              ! TURBULENCE KINETIC ENERGY
P                    ! Pressure (HPa)
   Z                    ! Height (m)
QVAPOR      ! Vapor
QCLOUD      ! Cloud Water
TSLB             ! SOIL TEMPERATURE
   SMOIS          ! SOIL MOISTURE
end_of_3dvar_list

3D variables to process

o  List of all 3D variables you would like processed.

o  If you do not wish to process a specific field, you can skip it, but simply indenting the line in which the field it listed. In this example, UMET, VMET, Z, and SMOIS will not be processed.

o  If a variables is present in the WRF netCDF file, but not in this list, it can be processed by simply adding it to the list.

o  To add a diagnostic, requires code changes.

o  All 3D fields go here, including soil fields, which have a different number of levels.

o  The "!" and description behind each field name is required by the program. If you add variables, remember to add the description of the field as well.

o  Do not remove or indent the line "end_of_3dvar_list", the code depends on this line.

RAINC            ! TOTAL CUMULUS PRECIPITATION
RAINNC         ! TOTAL GRID SCALE PRECIPITATION
slvl                    ! sea level pressure
T2                    ! TEMP at 2 M
U10                  ! U at 10 M
   U10M              ! U at 10 M - rotated
V10                 ! V at 10 M
   V10M              ! V at 10 M - rotated
XLAT              ! LATITUDE
XLONG          ! LONGITUDE
XLAND          ! LAND MASK
end_of_2dvar_list

2D variables to process

o  List of all 2D variables you would like processed.

o  If you do not wish to process a specific field, you can skip it, but simply indenting the line in which the field it listed. In this case, U10M, and V10M will not be processed.

o  If a variables is present in the WRF netCDF file, but not in this list, it can be processed by simply adding it to the list.

o  To add a diagnostic, requires code changes.

o  The "!" and description behind each field name is required by the program. If you add variables, remember to add the description of the field as well.

o Do not remove or indent the line "end_of_2dvar_list", the code depends on this line.

   /DATA/real/wrfinput_d01
wrfout_d01_2000-01-24_12:00:00
wrfout_d01_2000-01-25_00:00:00
   /DATA/b_wave/wrfout_d01
   /DATA/hill2d_x/wrfout_d01
end_of_file_list

WRF netCDF files process

o  List of all the WRF netCDF files you would like processed.

o  Do not mix different types of WRF files.

o  If you do not wish to process a specific file, you can skip it, but simply indenting the line in which the field it listed. In this example, only the two real WRF output files will be processed.

o  Multiple input file allowed, as long as they are listed in the correct order.

o At LEAST one input file is required.

o  Do not remove or indent the line "end_of_file_list", the code it.

             ! what to do with the data
real       ! real / ideal / static
1          ! map background in grads
1          ! specify grads vertical grid
            ! 0=cartesian,
            ! -1=interp to z from lowest h
            ! 1 list levels (height/pressure)

This section describes what to do with the data

o  DO NOT ADD OR REMOVE LINES, the code needs this section exactly as is.

o  We will process real data

o  We would like a MAP background

o  We would like to interpolate the data to levels given below

1000.0
950.0
900.0
850.0
800.0
750.0
700.0
650.0
600.0
550.0
500.0
450.0
400.0
350.0
300.0
250.0
200.0
150.0
100.0

Levels to interpolate to

o  This is only used if "1" is used for vertical interpolation above.

o  Can use pressure (as in this example) or height levels.

o  Levels must be from bottom to top.

o  Pressure levels are given in mb, and height levels in km.

o  Indenting will NOT remove a level from the list, it must be removed physically.


Run the code

·        wrf_to_grads    control_file    MyOutput    [-options]
This will create MyOutput.dat and MyOutput.ctl for use with GrADS

 

·        There are 3 debug levels (options) available:

 

Only basic information will be written to the screen

-v

Debug option low

-V

Debug option high (lots of output)

 

·        Now you are ready to use GrADS


Miscellaneous

To help users get started a number of GrADS scripts have been provided.

The scripts provided are only examples of the type of plots one can generate with GrADS data.

 

The user will need to modify these scripts to suit their data (Example, if you did not specify 0.25 km and 2 km as levels to interpolate to when you run the "bwave" data through the converter, the "bwave.gs" script will not display any plots, since it will specifically look for these to levels).

  

 GENERAL SCRIPTS

cbar.gs

Plot color bar on shaded plots (from GrADS home page)

rgbset.gs

Some extra colors (Users can add/change colors from color number 20 to 99)

skew.gs

Program to plot a skewT
TO RUN TYPE: run skew.gs (needs pressure level TC,TD,U,V as input)
User will be prompted if a hardcopy of the plot must be create - 1 for yes and 0 for no.
If 1 is entered, a GIF image will be created.
Need to enter lon/lat of point you are interested in
Need to enter time you are interested in
Can overlay 2 different times

 

 

SCRIPTS FOR REAL DATA

real_surf.gs

Plot some surface data
Need input data on model levels

plevels.gs

Plot some pressure level fields
Need model output on pressure levels

rain.gs

Plot total rainfall
Need a model output data set (any vertical coordinate), that contain fields "RAINC" and "RAINNC"

cross_z.gs

Need z level data as input
Will plot a NS and EW cross section of RH and T (C)
Plots will run through middle of the domain

zlevels.gs

Plot some height level fields
Need input data on height levels
Will plot data on 2, 5, 10 and 16km levels

input.gs

Need WRF INPUT data on height levels

 

 

SCRIPTS FOR IDEALIZED DATA

bwave.gs

Need height level data as input
Will look for 0.25 and 2 km data to plot

grav2d.gs

Need normal model level data

hill2d.gs

Need normal model level data

qss.gs

Need height level data as input.
Will look for heights 0.75, 1.5, 4 and 8 km to plot

sqx.gs

Need normal model level data a input

sqy.gs

Need normal model level data a input

 

 

Examples of plots created for both idealized and real cases are available from:
http://www2.mmm.ucar.edu/wrf/users/graphics/WRF2GrADS/GrADS.htm 



Trouble Shooting

The code executes correctly, but you get "NaN" or "Undefined Grid" for all fields
when displaying the data.

Look in the .ctl file.

a) If the second line is:

options byteswapped

Remove this line from your .ctl file and try to display the data again.
If this SOLVES the problem, you need to remove the -Dbytesw option from the Makefile.

b) If the line below does NOT appear in your .ctl file:

options byteswapped

ADD this line as the second line in the .ctl file.
Try to display the data again.
If this SOLVES the problem, you need to ADD the -Dbytesw option for the Makefile.

The line "options byteswapped" is often needed on some computers (DEC alpha as an example). It is also often needed if you run the converter on one computer and use another to display the data.  


WRF2VIS5D

Generate VIS5D files from WRF netCDF files.

ONLY ARW output files in netCDF format can be converted.

Necessary software

 

·        Obtain the WRF2VIS5D TAR file from the WRF Download page (http://www2.mmm.ucar.edu/wrf/users/download/get_source.html)

·        VIS5D software (http://www.ssec.wisc.edu/~billh/vis5d.html)

Hardware

 

The code has been ported to the following machines

 

·        DEC Alpha

·        Linux

·        SUN

·        SGI

·        IBM 

Steps to compile and run

Untar WRF2VIS5D TAR file

Inside the TAR file, you will have the following files:

Makefile
README

 

wrf_v5d_input

Sample control file

module_map_utils.F
module_wrf_to_vis5d_netcdf.F
module_wrf_to_vis5d_util.F
wrf_to_vis5d.F

Source code

 

Compile

·        To compile the code, EDIT the Makefile to select the compiler flags for your machine

·        Type:    make

·        This will create a   wrf_to_vis5d   executable


 Edit the control_file file

-2
2000-01-24_12:00:00
2000-01-24_18:00:00

Times to process

o  If the first line contains a negative number, ALL times in the WRF file are processed.

o  A positive number means process that number of times. In this case the times to process must be listed.

o  The number in the first line MUST match the number of times listed, for BOTH negative and positive numbers.

U
V
W
THETA
   TK
TC
QVAPOR
QCLOUD
QRAIN
RAINC
TSK
end_of_variable_list

Variables to process

o   List of variables you would like process.

o   If you do not wish to process a specific field, you can skip it, but simply indenting the line in which the field it listed. In this example, TK will not be processed.

o   If a variables is present in the WRF netCDF file, but not in this list, it can be processed by simply adding it to the list.

o   To add a diagnostic, requires code changes.

o   Do not remove or indent the line "end_of_variable_list", the code depends on this line.

/real/wrfout_d01_2000-01-24_12:00:00
/real/wrfout_d01_2000-01-25_00:00:00
end_of_file_list

WRF netCDF files process

o   List of all the WRF netCDF files you would like processed.

o  List ONLY files you want to process. Indenting a file name will result in a run time error.

o  Multiple input file allowed, as long as they are listed in the correct order.

o   Do not remove or indent the line "end_of_file_list", the code depends on this line.

20      ! specify v5d vertical grid 0=cartesian, -
            1=interp to z from lowest h,
            >1 list levels (z) desired in vis5d file

This section describe what to do with the data

o  0 : cartesian vertical grid will be used

o  -1 : interpolation from lowest h level

o   >1 : for list of levels (height only, in km) to interpolate to (in this case 20 levels will be used)

1 1.
2 2.
3 3.
4 4.
5 5.
6 6.
7 7.
8 8.
9 9.
10 10.
11 11.
12 12.
13 13.
14 14.
15 15.
16 16.
17 17.
18 18.
19 19.
20 20.

Levels to interpolate to

o   Only height (must be in km).

o   In this case, 20 levels must be given to correspond to number set above.

o   Levels must be from bottom to top.

o   Levels must be presided by the level number.

o   Indenting will NOT remove a level from the list, it must be removed physically.

 

 Run the code

·        wrf_to_vis5d    wrf_v5d_input    MyOutput
This will create MyOutput for use with VIS5D

·        Now you are ready to use VIS5D