Weather Research and Forecasting (WRF) Model

Utility : read_wrf_nc


Purpose

This utility was created to allow a used to look at a WRF netCDF file at a glance

What is the difference between this utility and the netCDF utility ncdump?

  • This utility has a large number of options, to allow a user to look at the specific part of the netCDF file in question
  • The utility is written in Fortran 90, which will allow users to add options

Compile

The code has been ported to Dec Alpha, Linux, Sun, SGI and IBM

The code should run on any machine with a netCDF library (If you port the code to a different machine, please forward the compile flags to wrfhelp@ucar.edu)

To compile the code, use the compile flags at the top of the utility.
Example, for a DEC Alpha machine you need to type:

pgf90 read_wrf_nc.f -L/usr/local/netcdf/lib -lnetcdf -lm -I/usr/local/netcdf/include -Mfree -o read_wrf_nc

This will create the executable: read_wrf_nc

Run

read_wrf_nc wrf_data_file_name [-options]

options : [-help] [-head] [-m] [-M z] [-s] [-S x y z] ! [-t] [-v VAL] [-V VAL] [-w VAL]
             [-EditData]

None of the options can be used with any other option

Options:

-help

 

Print help information.

-head

 

Print header information only.

-m

 

Print list of fields available for each time, plus the min and max values for each field.
Also print the header information.

-M z

 

Print list of fields available for each time, plus the min and max values for each field.
The min max values for 3d fields will be for the z level of the field.
Also print the header information.

-s

 

Print list of fields available for each time, plus a sample value for each field.
Sample value is in middle of domain.
Also print the header information.
Default if no options are given.

-S x y z

 

Print list of fields available for each time, plus a sample value for each field.
Sample value is at point x y z in domain.
Also print the header information .

-t

 

Print only the times in the file.

-v VAR

 

Print basic information about field VAR.

-V VAR

 

Print basic information about field VAR, and dump the full field out to the screen.

-w VAR

 

Write the full field out to a file VAR.out

 

SPECIAL option : -EditData VAR

  • This options will allow a user to READ a WRF netCDF file, CHANGE a specific field and WRITE it BACK into the WRF netCDF file.

  • This option will CHANGE your CURRENT WRF netCDF file so PLEASE TAKE CARE when using this option.

  • ONLY one field at a time can be changed. So if you need 3 fields changed, you will need to run this program 3 times, each with a different "VAR"

  • IF you have multiple times in your WRF netCDF file - ALL times for variable "VAR" WILL be changed.

  • HOW TO USE THIS OPTION:

    1. Make a COPY of your WRF netCDF file BEFORE using this option
    2. EDIT the SUBROUTINE USER_CODE
    3. ADD an IF-statement block for the variable you want to change

      For REAL data work with array "data_real" and for INTEGER data work with the array "data_int". This is to prevent a variable getting overwritten by mistake

      Example 1:
      If you want to change all (all time periods too) values of U to a constant 10.0 m/s, you would add the following IF_statement
         elseif ( var == 'U') then
           data_real = 10.0

      Example 2:
      If you want to change some of the LANDMASK data from LAND to SEA points
         elseif ( var == 'LANDMASK') then
           data_real(10:15,20:25,1) = 0

      Example 3:
      Change ALL ISLTYP category 3 into category 7 (NOTE this is an INTEGER field)
         elseif ( var == 'ISLTYP') then
           where (data_int == 3 )
             data_int = 7
           endwhere

    4. Compile and run program
      You will be prompted if this is really what you want to do.
      ONLY the answer "yes" will allow the change to take effect