知識の箱

主に気象を研究する上で得た知識と、WEBページ作成のために得た知識を記録しています。

metgridに入れるファイルのフォーマット

metgridをかけるときのインプットデータを作るためのサンプルプログラム

本家ページより引用
Chapter 3: WRF Preprocessing System (WPS)
http://www.mmm.ucar.edu/wrf/users/docs/user_guide_V3.1/users_guide_chap3.htm#_Writing_Meteorological_Data

————————————–
Writing Meteorological Data to the Intermediate Format

The role of the ungrib program is to decode GRIB data sets into a simple intermediate format that is understood by metgrid. If meteorological data are not available in GRIB Edition 1 or GRIB Edition 2 formats, the user is responsible for writing such data into the intermediate file format. Fortunately, the intermediate format is relatively simple, consisting of a sequence of unformatted Fortran writes. It is important to note that these unformatted writes use big-endian byte order, which can typically be specified with compiler flags. Below, we describe the WPS intermediate format; users interested in the SI or MM5 intermediate formats can first gain familiarity with the WPS format, which is very similar, and later examine the Fortran subroutines that read and write all three intermediate formats (metgrid/src/read_met_module.F90 and metgrid/src/write_met_module.F90, respectively).

When writing data to the WPS intermediate format, 2-dimensional fields are written as a rectangular array of real values. 3-dimensional arrays must be split across the vertical dimension into 2-dimensional arrays, which are written independently. It should also be noted that, for global data sets, either a Gaussian or cylindrical equidistant projection must be used, and for regional data sets, either a Mercator, Lambert conformal, polar stereographic, or cylindrical equidistant may be used. The sequence of writes used to write a single 2-dimensional array in the WPS intermediate format is as follows (note that not all of the variables declared below are used for a given projection of the data).

——————————————

integer :: version ! Format version (must =5 for WPS format)
integer :: nx, ny ! x- and y-dimensions of 2-d array
integer :: iproj ! Code for projection of data in array:
                       ! 0 = cylindrical equidistant
                       ! 1 = Mercator
                       ! 3 = Lambert conformal conic
                       ! 4 = Gaussian (global only!)
                       ! 5 = Polar stereographic
real :: nlats ! Number of latitudes north of equator
                       ! (for Gaussian grids)
real :: xfcst ! Forecast hour of data
real :: xlvl ! Vertical level of data in 2-d array
real :: startlat, startlon ! Lat/lon of point in array indicated by
                       ! startloc string
real :: deltalat, deltalon ! Grid spacing, degrees
real :: dx, dy ! Grid spacing, km
real :: xlonc ! Standard longitude of projection
real :: truelat1, truelat2 ! True latitudes of projection
real :: earth_radius ! Earth radius, km
real, dimension(nx,ny) :: slab ! The 2-d array holding the data
logical :: is_wind_grid_rel ! Flag indicating whether winds are
                       ! relative to source grid (TRUE) or
                       ! relative to earth (FALSE)
character (len=8) :: startloc ! Which point in array is given by
                       ! startlat/startlon; set either
                       ! to ‘SWCORNER’ or ‘CENTER ‘
character (len=9) :: field ! Name of the field
character (len=24) :: hdate ! Valid date for data YYYY:MM:DD_HH:00:00
character (len=25) :: units ! Units of data
character (len=32) :: map_source ! Source model / originating center
character (len=46) :: desc ! Short description of data

! 1) WRITE FORMAT VERSION
write(unit=ounit) version

! 2) WRITE METADATA
! Cylindrical equidistant
if (iproj == 0) then
write(unit=ounit) hdate, xfcst, map_source, field, &
units, desc, xlvl, nx, ny, iproj
write(unit=ounit) startloc, startlat, startlon, &
deltalat, deltalon, earth_radius

! Mercator
else if (iproj == 1) then
write(unit=ounit) hdate, xfcst, map_source, field, &
units, desc, xlvl, nx, ny, iproj
write(unit=ounit) startloc, startlat, startlon, dx, dy, &
truelat1, earth_radius

! Lambert conformal
else if (iproj == 3) then
write(unit=ounit) hdate, xfcst, map_source, field, &
units, desc, xlvl, nx, ny, iproj
write(unit=ounit) startloc, startlat, startlon, dx, dy, &
xlonc, truelat1, truelat2, earth_radius

! Gaussian
else if (iproj == 4) then
write(unit=ounit) hdate, xfcst, map_source, field, &
units, desc, xlvl, nx, ny, iproj
write(unit=ounit) startloc, startlat, startlon, &
nlats, deltalon, earth_radius

! Polar stereographic
else if (iproj == 5) then
write(unit=ounit) hdate, xfcst, map_source, field, &
units, desc, xlvl, nx, ny, iproj
write(unit=ounit) startloc, startlat, startlon, dx, dy, &
xlonc, truelat1, earth_radius

end if

! 3) WRITE WIND ROTATION FLAG
write(unit=ounit) is_wind_grid_rel

! 4) WRITE 2-D ARRAY OF DATA
write(unit=ounit) slab