wrfout_to_cf.ncl - Usage

An NCL based script to create new CF based NetCDF files from native wrfout NetCDF files.

Running the script:

Command syntax:

	ncl 'file_in="wrfout.nc"' 'file_out="wrfpost.nc"' wrfout_to_cf.ncl
      • The file input and output values can be set by replacing wrfout.nc and wrfpost.nc to the desired file names.
      • Alternatively, the variables file_out and file_in can be set in the script (see values shortly after the start of the main program in the script) and then there is no need to specify the file names when calling the NCL script.
      • A csh script can also be created that calls the NCL program with the wrfout_to_cf.ncl script and file names specified.

Output variables:

The selected output variables are determined by setting two attribute variables in the script to True (include). One flag designates that any or all of a block of variables are to be output. For example, the attribute out2dMet indicates that the selected 2dMet variables will be included in the output. A second flag is set for the individual variables within a block. For example if out2dMet@T_sfc and out2dMet@T_2m are set to True then T_sfc and T_2m will be included in the output. See the variables page for a listing of the available output fields.

A single variable or a block of variables can be excluded from the output by setting the individual or the block attribute to False (exclude). For example, setting the attribute out2dMet to False means that all 2dMet variables will not be included, no matter how the individual attributes are set.

There are two slp calculations included in this script. The first (slp) ; is based on the slp calculation which is a part of the wrf_ncl programs. ; The second (slp_b) is based on a calculation using only the lowest model ; level. If only one of the two are selected, the netcdf output variable ; is slp. If both are selected then the output variables are slp and slp_b.

Additional Settings:

TimeUnits [ex: TimeUnits = "hours since 2001-01-01 00:00:00"] 
  • Sets the units for the starting value for the CF time variable.
pressure [ex: pressure = (/1000.,850.,700.,500.,300./)]
  • Sets the values of the pressure levels for all variables outputted on pressure levels.
limTime    [ex: limTime = (/3,7/)]
  • Allows for sub-setting the CF output file for a range of times from the original wrfout file. Setting the initial value to 0 and the second value to something greater than the number of times in the wrfout file outputs all times.  Setting the variable to (/0,9999/) will output all times.
limS_N    [ex: limS_N = (/45,256/)]
  • Allows for sub-setting the output file to a range in the S_N grid.  Setting the variable to (/0,9999/) will output the entire S_N dimension of the domain.
limW_E    [ex: limW_E = (/41,151/)]
  • Allows for sub-setting the output file to a range in the W_E grid. Setting the variable to (/0,9999/) will output the entire W_E dimension of the domain.
limPres    [ex: limPres = (/0,4/)]
  • Allows for sub-setting the output file to a range of pressure levels for all pressure level output.  The pressure levels are set by the variable pressure.  Setting the variable to (/0,9999/) will output all pressure levels specified by the variable pressure.
limEta    [ex: limEta = (/0,19/)]
  • Allows for sub-setting the output file to a range of eta levels for all eta level output.  Setting the variable to (/0,9999/) will output all eta levels.
limSoil    [ex: limSoil = (/0,3/)]
  • Allows for sub-setting the output file to a range of soil levels for all soil level output.  Setting the variable to (/0,9999/) will output all soil levels.
outPtop    [True/False]
  • The WRFOUT file contains the variable P_TOP.  This variable is not necessarily a variable commonly used for research other than model evaluation or analysis of what the model is doing.  Setting to True will include the variable in the output file.
outDateTime    [True/False]
  • Include a yyyymmddhh field in the output file.  Note:  this variable does not show minutes therefore it is not very useful when sub-hourly output time intervals.
outUTCDate    [True/False]
  • Include yr, mo, dy, hr, mn fields in the output file.
C-shell Scripts:
  • The wrfout_to_cf script is deliberately written to process one file at a time.  This was done to keep the script simple and focused.  If multiple native wrfout files are to be processed they can be done through another NCL script or by using a c-shell script.  The following are two examples of c-shell scripts that can be used to process multiple wrfout files.
  • Option 1:  Process all wrfout_d* files located in the current directory:
#!/bin/csh -f

# list the files in the directory, loop through each file
foreach file_pre (`ls wrfout_d* | sed 's/\:00\:00//g'`)
  # set the file_in and file_out values
  set file_in = {$file_pre}:00:00
  set file_out = {$file_pre}-cf.nc
  # run the wrfout_to_cf NCL script
  ncl 'file_in="'{$file_in}'"' 'file_out="'{$file_out}'"' wrfout_to_cf.ncl
end
  • Option 2:  Loop through a series of years, months, days, and forecast initial times processing whole files for the WRF simulation.
#!/bin/csh -f

# set the constants for the year, month, hour of forecast, and domain
set yyyy = ('2001' '2002' '2003' '2004' '2005' '2006' '2007' '2008' \
            '2009' '2010' '2011' '2012' '2013' '2014' '2015' '2016')
set mm = ('01' '02' '03' '04' '05' '06' '07' '08' '09' '10' '11' '12')
set hr = ('00' '12')
set dom = ('1' '2' '3')

#set the domain
n = 1
#initiate the loop through the years
set y = 12
while ($y <= 12)
  #initiate the loop through the months
  set m = 1
  while ($m <= 2)
    #set the variable for year and month
    set yyyymm = ${yyyy[$y]}${mm[$m]}
      # iniate the loop through the days of the month
      set d = 17
      while ($d <= 17)
        # set the string for the day of the month
        if ($d < 10) then
          set dd = 0{$d}
        else
          set dd = {$d}
        endif
        # set the variable for year, month, and day
        set yyyymmdd = $yyyymm$dd
        # initiate the loop through the forecast simulations
        set h = 1
        while ($h <= 1)
          # set the variable for year, month, day, and hour
          set yyyymmddhh = $yyyymmdd${hr[$h]}
          echo $yyyymmddhh
          # set the file_in and file_out names
          set file_in = wrfout_d0${dom[$n]}_${yyyy[$y]}-${mm[$m]}-${dd}_${hr[$h]}:00:00
          set file_out = {$yyyymmddhh}-cf.nc
          # run the wrfout_to_cf NCL script
          ncl 'file_in="'{$file_in}'"' 'file_out="'{$file_out}'"' wrfout_to_cf.ncl
      @ h ++
      end
    @ d ++
    end
  @ m ++
  end
@ y ++
end



Overview Usage Variables Add a Variable Release Notes TO DO Download