pregrid: Overview
Introduction
REGRID is a preprocessor of the Penn State/NCAR Mesoscale
Modeling system (MM5). The primary purpose of REGRID is to read
archived meteorological analyses on pressure levels and interpolate
these analyses in the horizontal to the model grid as defined by
program TERRAIN. The output from REGRID is generally used as a first-guess
for objective analysis by program RAWINS, or to make model initial
and boundary conditions through program INTERP. For most applications,
the objective analysis step (program RAWINS) is the normal route
taken.
Thus, the basic program flow for the MM5 modeling
system looks like:
TERRAIN (Define model grids; put terrestrial fields on
grids)
REGRID (Put first-guess analyses on model grids)
RAWINS (Get observations and perform objective analysis)
INTERP (Interpolate vertically to model sigma levels,
make initial conditions for each domain, and boundary conditions
for the outermost domain)
MM5 (Integrate the model)
REGRID is intended to replace the DATAGRID program
of the MM5 modeling system.
REGRID Structure
REGRID has been partitioned into two main parts: PREGRID, which
reads analyses from a variety of data sources, and REGRIDDER, which
interpolates those analyses to the model grid. Files written in
a simple, intermediate format are the means of passing data from
PREGRID to REGRIDDER.
This approach of partitioning the functional pieces
of REGRID into two sections was selected for several reasons:
-
Separation of input tasks from the interpolation tasks removes
the complicated code handling many types of input from the relatively
straightforward task of interpolation.
-
Access programs could be (and have been) written for individual
data sets, keeping the code for the input tasks relatively focused.
-
Data from different sources are easy to combine. This is most
applicable to surface and soil data sets which are not archived
in all atmospheric analysis data sets.
-
All fields output from the pregrid programs are interpolated
by REGRIDDER and passed along to the rest of the modeling system.
-
Separate programs and the simple intermediate format allow
users to readily introduce into the MM5 modeling system data
sets which are not included in the set of supported data
sources.
-
Users introducing data from unsupported sources need only be
concerned with the parts of the package required to decode their
own particular data sets.
-
When user intervention is necessary, the modifications are
located solely in an area where the user is a presumed expert
- with the new data source.
The Unix tarfile "regrid.tar" has been set up to reflect
the bipartite structure of the REGRID package, with a top-level
directory named "regrid", and subdirectories named "pregrid" and
"regridder".
A) PREGRID:
PREGRID is not a single program, but rather a suite of programs
to read from various sources of gridded data in various formats,
and write the data out again in a simple, specified format (described
in section C). The primary purpose of this suite of programs is
to prepare gridded
analyses for horizontal interpolation to an MM5 model grid by program
REGRIDDER.
-
General description
A separate PREGRID program has been written for a number of
data sources. In addition, many data sets in the GRIB format
may be processed by the program in the "grib.misc" directory.
Some data sets in GRIB format may be handled more easily be
a separate program, rather than by trying to make the grib.misc
code handle everything. If users want to import code from some
other data source or in some other data format, they will need
to create their own pregrid program, which simply reformats
the data to be read by REGRIDDER. There currently exists a stand-alone
shell for running PREGRID alone (without REGRIDDER). A single
shell for running both PREGRID and REGRIDDER will be available
sometime in the future.
-
The "pregrid" directory
The pregrid directory has the following files and subdirectories:
Doc:
|
Some documentation files, which you've obviously already
found
|
ecmtoga:
|
Tables needed to run the ecmwf toga archives through
pregrid
|
era :
|
Tables needed to run the Ecmwf Reanalysis dataset
|
grib.misc:
|
Fortran code to run many GRIB datasets
|
navysst:
|
Program and table needed for Navy SSTs
|
ncep.grib:
|
Program and tables needed for NCEP GDAS archives in GRIB
|
nnrp:
|
Tables needed to access NCAR/NCEP Reanalysis project
archives.
|
on84:
|
Program and Tables needed to access old NCEP GDAS archives
in
ON84 format.
|
pregrid.deck:
|
Deck used to submit a pregrid job to NCAR's crays
|
pregrid.csh:
|
C-shell script used to run pregrid locally or interactively
|
util:
|
Fortran code for many functions common to many of the
data access programs
|
-
How to use PREGRID
The pregrid programs take several different kinds of input:
1) The namelist, defining times you want to process.
2) The archived analysis files.
3) the Vtable file, which describes which fields to extract
from the archive files, and what variable names are assigned.
Vtables are explained in more detail below.
The pregrid program scans through each of the input analysis
files, checking on the dates. For any dates which fall between
your start time and end time (inclusive), pregrid scans through
the archived fields and pulls out those which have been specified
in the Vtable. From these fields, pregrid builds (or adds to)
preliminary output files, and the moves on to the next input
file. When all input files have been processed, and all pertinent
data between the start time and end time have been written to
the preliminary output files, pregrid rereads the output files,
and builds in certain fields which may be missing. The pregrid
program then scans through all the files, searching for dates
which are missing. If it finds a missing date, it fills it in
by temporal interpolation. Then the final output files are written.
-
pregrid shell
The pregrid shell "pregrid.csh", is provided to run pregrid
interactively on a workstation.
To run the "pregrid.csh" script:
1) Get the analysis archives and put them in some directory.
2) Set the script variables.
3) Fill out the namelist.
4) Make sure you've got the right Vtables, especially if
you're getting analyses other than the standard ones.
5) Make sure "pregrid.csh" is executable ("chmod u+x pregrid.csh").
6) Run pregrid.csh, by entering "pregrid.csh"
-
Script variables
DATADIR:
|
The local directory where you've placed the original
analysis archive files.
|
SCR3D:
|
The source of 3D analyses. Select from one of
the
following:
ON84 :
|
NCEP GDAS analyses, in ON84 format
(before 1997 Mar).
|
NCEP :
|
NCEP GDAS analyses, in GRIB format
(beginning 1997 Mar).
|
GRIB :
|
A catch-all for many other datasets in
the
GRIB format.
|
|
InFiles:
|
Full pathname to the files with 3D Analyses.
|
SRCSST:
|
Source of the SST Analyses. Select from among
the following:
ON84 :
|
NCEP GDAS analyses, in ON84 format
(before 1997 Mar).
|
NCEP :
|
NCEP GDAS analyses, in GRIB format
(beginning 1997 Mar).
|
NAVY :
|
Low-resolution Navy archives
(roughly 2.5x2.5 degrees)
|
GRIB :
|
A catch-all for many other datasets in
the
GRIB format.
|
$SCR3D:
|
Same source as the 3D analyses
|
|
InSST:
|
Full pathname to the files with SST analyses,
if different
from the files with 3D analyses.
|
SRCSNOW:
|
Source of snow-cover analyses.
|
InSnow:
|
Full pathname to the files with Snow-cover analyses,
if
different from the files with 3D analyses.
|
SRCSOIL:
|
Source of soil (i.e. ground) analyses (e.g.,
soil moisture,
ground temperature, etc.)
|
InSoil:
|
Full pathname to the files with Soil analyses,
if
different from the files with 3D analyses.
|
|
|
Next, there are a few script variables you need
to set if you
have set any of the above to GRIB. These script
variables
denote the tables the GRIB pregridder is going
to need to know
which variables to extract from the GRIB files.
|
VT3D:
|
The Vtable for the 3D analyses
|
VTSST:
|
The Vtable for the SST analyses
|
VTSNOW:
|
The Vtable for the Snow-cover analyses
|
VTSOIL:
|
The Vtable for the soil analyses.
|
-
namelist
There is a small namelist built by the "pregrid.csh"
script. This namelist file is named "pregrid.namelist",
and defines the dates you want to process:
The starting date of the time period you want to process
is set by
START_YEAR, START_MONTH, START_DAY, and START_HOUR:
eg:
START_YEAR = 1987 # Year (YYYY)
START_MONTH = 08 # Month ( 01 - 12 )
START_DAY = 2 # Day ( 01 - 31 )
START_HOUR = 12 # Hour ( 00 - 23 )
DELTA_TIME = 6 # Time interval (hours) to process.
# This is most sanely the same as the time interval
for
# which the analyses were archived, but you can really
# set this to just about anything, and pregrid will
# interpolate in time and/or skip over time periods
for
# your regridding pleasure.
NTIMES = 2 # Number of analysis times.
# Don't forget to count both the first and last times.
# E.g.: A 24-hour period with with 6-hour time interval
# needs 5 analysis times (00Z, 06Z, 12Z, 18Z, 00Z).
-
Vtables
The Vtables are the means by which the pregrid programs
are told which fields to extract from the analysis files.
Tables like these are expedient, because the archives tend
to label fields by code numbers, and different archives
frequently use different code numbers. The Vtables also
allow users to request that additional fields be extracted
from the archives, without having to modify the pregrid
programs themselves.
The Vtable files have a fairly strictly defined format:
++ Any lines before the first line beginning with '-' are
ignored.
++ All lines after the first line beginning with '-', and
up to the next line beginning with '-', are interpreted.
++ Any subsequent lines after the next line beginning with
'-' are ignored, until the next line beginning with '-'
is hit, and then the following lines are interpreted. This
pattern continues until the end of the file.
++ For each line to be interpreted, there are the following
fields, separated by "|":
- A code number associated with the variable to extract
- A level code number associated with the type of level
to extract. This generally refers to pressure levels, surface,
or ground.
- A "Level 1" value, denoting which level to extract (*
indicates all levels of the type of level described by the
level code).
- A "Level 2" value, needed for those fields which represent
averages or sums over more than one level.
- A REGRID Name, up to eight characters, which is what the
field will be called in the regridder output, and in subsequent
programs of the MM5 system.
- REGRID Units, a string of up to 16 characters which describes
the units of the field.
- REGRID Description, up to 54 characters describing the
field.
If the Units and Description strings are missing, pregrid
will read the named field from the archives, but will not
write it to the final output (for input to regridder). This
is necessary for those situations where one field which
we desire to output is derived from fields which we may
not want to output. For example, some archives are missing
surface RH, but have both surface T and surface dewpoint.
So we have to read in the dewpoint, but we don't want to
write it out, we want to compute RH and write RH.
If you need to make your own Vtable, there are plenty of
examples in the grib.misc directory.
B) REGRIDDER:
REGRIDDER is a program which reads the horizontal fields output
from PREGRID and interpolates them horizontally to the MM5 model
grid
C) INTERMEDIATE DATA FORMAT
-
General format description
Data are passed from the PRIGRID programs to REGRIDDER via files
written in the format described herein. Any number of horizontal
slabs may be written in to single file. The slabs in a given
file are not necessarily all from the same data source, or all
on the same map projection, but they all represent the same
time.
-
File Naming conventions
Each file contains data for a single time. The file names consist
of a prefix (ideally, but not necessarily, denoting the source
of data), followed by a colon, followed by a time-stamp in the
form YYYY-MM-DD_HH.
REGRIDDER uses the file names as discussed in section 4.
For example, analyses from the ON84-format data from NCEP for
3 January 1998 at 12 UTC would be written to a file called "ON84:1998-01-03_00"
-
File format:
The files are written as unformatted FORTRAN 32-bit IEEE records.
Four
records are used for every horizontal slab.
|
Record 1:
|
IFV
|
|
Record 2:
|
HDATE, XFCST, FIELD, UNITS, DESC, XLVL, NX, NY, IPROJ
|
if (IPROJ == 0) (Cylindrical equidistant grid)
|
|
Record 3:
|
STARTLAT, STARTLON, DELTALAT, DELTALON
|
if (IPROJ == 3) (Lambert conformal grid)
|
|
Record 3:
|
STARTLAT, STARTLON, DX, DY, XLONC, TRUELAT1, TRUELAT2
|
if (IPROJ == 5) (Polar-stereographic grid)
|
|
Record 3:
|
STARTLAT, STARTLON, DX, DY, XLONC, TRUELAT1
|
|
Record 4:
|
SLAB
|
Where:
|
|
|
|
|
integer
|
::
|
IFV
|
!
|
The PREGRID format version number, currently 2
|
character*24
|
::
|
HDATE
|
!
|
The time, in format "YYYY-MM-DD_HH:mm:ss "
(only the first 19 characters are used)
|
real
|
::
|
XFCST
|
!
|
Forecast time (in hours) of the data in the slab
|
character*8
|
::
|
FIELD
|
!
|
A field name. Names with special meaning are described
in section 4.
|
character*16
|
::
|
UNITS
|
!
|
Units describing the field in the slab
|
character*56
|
::
|
DESC
|
!
|
Text description of the field.
|
real
|
::
|
XLVL
|
!
|
Pressure-level (Pa) of the data.
200100 Pa indicates surface data;
201300 Pa indicates sea-level pressure
|
integer
|
::
|
NX
|
!
|
Slab dimension in the X direction
|
integer
|
::
|
NY
|
!
|
Slab dimension in the Y direction
|
integer
|
::
|
IPROJ
|
!
|
Flag denoting the projection. Recognized values are:
0: Cylindrical Equidistant (Lat/lon) grid.
3: Lambert-conformal projection
5: Polar-stereographic projection
|
real
|
::
|
STARTLAT
|
!
|
Starting latitude (degrees)
|
real
|
::
|
STARTLON
|
!
|
Starting longitude (degrees)
|
real
|
::
|
DELTALAT
|
!
|
Latitude increment (degrees) for lat/lon grid
|
real
|
::
|
DELTALON
|
!
|
Longitude increment (degrees) for lat/lon grid
|
real
|
::
|
DX
|
!
|
Grid-spacing in x (km at TRUELAT1 (and TRUELAT2))
|
real
|
::
|
DY
|
!
|
Grid-spacing in y (km at TRUELAT1 (and TRUELAT2))
|
real
|
::
|
XLONC
|
!
|
Center longitude of the projection.
|
real
|
::
|
TRUELAT1
|
!
|
Extra latitude used for defining Polar Stereographic
and Lambert conformal projections
|
real
|
::
|
TRUELAT2
|
!
|
A second extra latitude used for defining Lambert conformal
projection
|
real
|
::
|
SLAB(NX,NY)
|
!
|
Two-dimensional array of data.
|
-
Special field names
The program variable FIELD indicates the physical variable in
the slab.
Certain values of FIELD are recognized by REGRIDDER for specific
treatment.
Slabs identified by an unrecognized values of FIELD are simply
interpolated
horizontally and written out by REGRIDDER. Recognized field
names are:
'T '
'U '
'V '
'RH '
'HGT '
'PMSL '
'SOILT010'
'SOILT200'
'SOILT400'
'SOILM010'
'SOILM200'
'SST '
'SEAICE '
'LANDSEA '
'SOILHGT '
'WEASD '
'SNOWCOVR'
- Sample read program:
program ddread
C This is a simple program to read data in the PREGRID output
format.
C It is included mainly as an aid to understanding said format.
implicit none
C Declarations:
integer IFV
character*24 HDATE
real XFCST
character*8 FIELD
character*16 UNITS
character*56 DESC
real XLVL
integer NX
integer NY
integer IPROJ
real STARTLAT
real STARTLON
real DELTALAT
real DELTALON
real DX
real DY
real XLONC
real TRUELAT1
real TRUELAT2
C
C So as not to need dynamic memory allocation, we dimension
SLAB as
C large as we're likely to need. In order to read the appropriate
C size of SLAB, we use the read routine READSLAB. If you want
to do
C anything with the array SLAB, subroutine READSLAB is the place
to
C do it.
C
integer MAXNX, MAXNY
parameter (MAXNX=500, MAXNY=500)
real SLAB(MAXNX,MAXNY)
integer IUNIT
IUNIT = 10
100 CONTINUE
read (IUNIT, END=101) IFV
if (IFV.EQ.2) THEN
read (IUNIT) HDATE, XFCST, FIELD, UNITS, DESC, XLVL, NX, NY,
& IPROJ
print*, HDATE, XLVL, FIELD
if (IPROJ .EQ. 0) then
read (IUNIT) STARTLAT, STARTLON, DELTALAT, DELTALON
elseif (IPROJ .EQ. 3) then
read (IUNIT) STARTLAT, STARTLON, DX, DY, XLONC, TRUELAT1,
& TRUELAT2
elseif (IPROJ. EQ. 5) then
read (IUNIT) STARTLAT, STARTLON, DX, DY, XLONC, TRUELAT1
endif
call readslab(IUNIT, SLAB, NX, NY)
else
print*, 'Unrecognized format version IFV: ', IFV
stop 00001
endif
GO TO 100
101 CONTINUE
stop 99999
end
subroutine readslab(IUNIT, SLAB, NX, NY)
implicit none
integer iunit
integer nx, ny
real slab(nx,ny)
read (iunit) SLAB
C If you want to do anything with SLAB, this is as good place
as any
C for it.
return
end
|