User’s Guide for Advanced Research WRF (ARW) Modeling System Version 2
Appendix B: Old Post-Processing Utilities
· NCL
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.
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 |
README_FIRST README_NCL gsn_code.ncl SkewTFunc.ncl WRFOptions.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_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 |
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 |
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)
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 |
|
control_file |
Sample control file
|
module_wrf_to_grads_netcdf.F |
Source code |
cbar.gs |
Utility scripts |
skew.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 |
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 |
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 |
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 |
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 |
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 |
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 |
SCRIPTS FOR REAL DATA
real_surf.gs |
Plot some surface data |
plevels.gs |
Plot some pressure level fields |
rain.gs |
Plot total rainfall |
cross_z.gs |
Need z level data as input |
zlevels.gs |
Plot some height level fields |
input.gs |
Need WRF INPUT data on height levels |
SCRIPTS FOR IDEALIZED DATA
bwave.gs |
Need height level data as input |
grav2d.gs |
Need normal model level data |
hill2d.gs |
Need normal model level data |
qss.gs |
Need height level data as input. |
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.
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 |
|
wrf_v5d_input |
Sample control file |
module_map_utils.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 |
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 |
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 |
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, - |
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. |
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