gengrid
Generates a regular grid from bounding box coordinates and resolution.
Signature
call gengrid(idata, Xmin, Ymin, Xmax, Ymax, res)
| Parameter | Intent | Type | Description |
|---|---|---|---|
idata | inout | FPL type | Structure to populate |
Xmin | in | real/double | Western boundary (longitude) |
Ymin | in | real/double | Southern boundary (latitude) |
Xmax | in | real/double | Eastern boundary (longitude) |
Ymax | in | real/double | Northern boundary (latitude) |
res | in | real/double | Grid cell resolution (degrees) |
Behavior
- Computes
nlonsandnlatsfrom the bounding box and resolution - Allocates and fills
longitudesandlatitudesarrays - Allocates
ncdatainitialized to zero - For 3D/4D types, uses
ntimes/nlevelsalready set in the structure
note
Set ntimes (3D/4D) and nlevels (4D) before calling gengrid.
Supported Types
Works with all 100 FPL data types via the gengrid generic interface.
Example
type(nc2d_float_llf) :: dem
dem%varname = "elevation"
dem%lonname = "lon"
dem%latname = "lat"
dem%long_name = "Digital Elevation Model"
dem%varunits = "meters"
dem%lonunits = "degrees_east"
dem%latunits = "degrees_north"
dem%FillValue = -9999.0
! Generate a 0.5-degree grid over South America
call gengrid(dem, -82.0, -56.0, -34.0, 13.0, 0.5)
write(*,*) "Grid size:", dem%nlons, "x", dem%nlats
! Output: Grid size: 96 x 138
call dealloc(dem)