12.07.2015 Views

WRF - Developmental Testbed Center

WRF - Developmental Testbed Center

WRF - Developmental Testbed Center

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

corresponding source grid point. Given this array, the data are written to a file, row-byrow,beginning at the bottom, or southern-most, row. For example, in the figure above,the elements of the n × m array would be written in the order x 11 , x 12 , ..., x 1m , x 21 , ..., x 2m ,..., x n1 , ..., x nm . When written to the file, every element is stored as a 1-, 2-, 3-, or 4-byteinteger in big-endian byte order (i.e., for the 4-byte integer ABCD, byte A is stored at thelowest address and byte D at the highest), although little-endian files may be used bysetting endian=little in the "index" file for the data set. Every element in a file mustuse the same number of bytes for its storage, and, of course, it is advantageous to use thefewest number of bytes needed to represent the complete range of values in the array.When writing the binary data to a file, no header, record marker, or additional bytesshould be written. For example, a 2-byte 1000 × 1000 array should result in a file whosesize is exactly 2,000,000 bytes. Since Fortran unformatted writes add record markers, it isnot possible to write a geogrid binary-formatted file directly from Fortran; instead, it isrecommended that the C routines in read_geogrid.c and write_geogrid.c (in thegeogrid/src directory) be called when writing data, either from C or Fortran code.Similar in format to a field of dominant categories is the case of a field of continuous, orreal, values. Like dominant-category fields, single-level continuous fields are firstorganized as a regular 2-d array, then written, row-by-row, to a binary file. However,because a continuous field may contain non-integral or negative values, the storagerepresentation of each element within the file is slightly more complex. All elements inthe array must first be converted to integral values. This is done by first scaling allelements by a constant, chosen to maintain the required precision, and then removing anyremaining fractional part through rounding. For example, if three decimal places ofprecision are required, the value -2.71828 would need to be divided by 0.001 androunded to -2718. Following conversion of all array elements to integral values, if anynegative values are found in the array, a second conversion must be applied: if elementsare stored using 1 byte each, then 2 8 is added to each negative element; for storage using2 bytes, 2 16 is added to each negative element; for storage using 3 bytes, 2 24 is added toeach negative element; and for storage using 4 bytes, a value of 2 32 is added to eachnegative element. It is important to note that no conversion is applied to positiveelements. Finally, the resulting positive, integral array is written as in the case of adominant-category field.Multi-level continuous fields are handled much the same as single-level continuousfields. For an n × m × r array, conversion to a positive, integral field is first performed asdescribed above. Then, each n × m sub-array is written contiguously to the binary file asbefore, beginning with the smallest r-index. Categorical fields that are given as fractionalfields for each possible category can be thought of as multi-level continuous fields, whereeach level k, 1 ≤ k ≤ r, is the fractional field for category k.When writing a field to a file in the geogrid binary format, the user should adhere to thenaming convention used by the geogrid program, which expects data files to have namesof the form xstart-xend.ystart-yend, where xstart, xend, ystart, and yend are five-digitpositive integers specifying, respectively, the starting x-index of the array contained in<strong>WRF</strong>-NMM V3: User’s Guide 3-29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!