62 associate(kgds => g1_desc%gds)
65 self%RLAT1=kgds(4)*1.e-3
66 self%RLON1=kgds(5)*1.e-3
67 self%RLAT2=kgds(7)*1.e-3
68 self%RLON2=kgds(8)*1.e-3
69 iscan=mod(kgds(11)/128,2)
71 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
72 self%DLAT=(self%RLAT2-self%RLAT1)/(self%JM-1)
78 self%nscan = mod(kgds(11) / 32, 2)
79 self%nscan_field_pos = self%nscan
82 self%iwrap = nint(360/abs(self%dlon))
84 if(self%im < self%iwrap) self%iwrap=0
87 if(self%iwrap > 0 .and. mod(self%iwrap,2) == 0)
then
88 if(abs(self%rlat1) > 90-0.25*self%dlat)
then
90 elseif(abs(self%rlat1) > 90-0.75*self%dlat)
then
93 if(abs(self%rlat2) > 90-0.25*self%dlat)
then
94 self%jwrap2 = 2 * self%jm
95 elseif(abs(self%rlat2) > 90-0.75*self%dlat)
then
96 self%jwrap2 = 2 * self%jm+1
100 self%rerth = 6.3712e6
101 self%eccen_squared = 0.0
114 type(grib2_descriptor),
intent(in) :: g2_desc
116 integer :: iscale, iscan
118 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
121 iscale=igdtmpl(10)*igdtmpl(11)
122 IF(iscale==0) iscale=10**6
123 self%RLAT1=float(igdtmpl(12))/float(iscale)
124 self%RLON1=float(igdtmpl(13))/float(iscale)
125 self%RLAT2=float(igdtmpl(15))/float(iscale)
126 self%RLON2=float(igdtmpl(16))/float(iscale)
127 iscan=mod(igdtmpl(19)/128,2)
129 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
130 self%DLAT=(self%RLAT2-self%RLAT1)/(self%JM-1)
132 self%nscan = mod(igdtmpl(19)/32,2)
133 self%nscan_field_pos = self%nscan
135 self%iwrap = nint(360/abs(self%DLON))
137 if(self%im.lt.self%iwrap) self%iwrap=0
141 if(self%im < self%iwrap) self%iwrap=0
144 if(self%iwrap > 0 .and. mod(self%iwrap,2) == 0)
then
145 if(abs(self%rlat1) > 90-0.25*self%dlat)
then
147 elseif(abs(self%rlat1) > 90-0.75*self%dlat)
then
150 if(abs(self%rlat2) > 90-0.25*self%dlat)
then
151 self%jwrap2 = 2 * self%jm
152 elseif(abs(self%rlat2) > 90-0.75*self%dlat)
then
153 self%jwrap2 = 2 * self%jm+1
157 call earth_radius(igdtmpl, igdtlen, self%rerth, self%eccen_squared)
207 XPTS,YPTS,RLON,RLAT,NRET, &
208 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA)
212 INTEGER,
INTENT(IN ) :: IOPT, NPTS
213 INTEGER,
INTENT( OUT) :: NRET
215 REAL,
INTENT(IN ) :: FILL
216 REAL,
INTENT(INOUT) :: RLON(NPTS),RLAT(NPTS)
217 REAL,
INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS)
218 REAL,
OPTIONAL,
INTENT( OUT) :: CROT(NPTS),SROT(NPTS)
219 REAL,
OPTIONAL,
INTENT( OUT) :: XLON(NPTS),XLAT(NPTS)
220 REAL,
OPTIONAL,
INTENT( OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
224 LOGICAL :: LROT, LMAP, LAREA
226 REAL :: HI, RLAT1, RLON1, RLAT2, RLON2
227 REAL :: XMAX, XMIN, YMAX, YMIN
229 IF(
PRESENT(crot)) crot=fill
230 IF(
PRESENT(srot)) srot=fill
231 IF(
PRESENT(xlon)) xlon=fill
232 IF(
PRESENT(xlat)) xlat=fill
233 IF(
PRESENT(ylon)) ylon=fill
234 IF(
PRESENT(ylat)) ylat=fill
235 IF(
PRESENT(area)) area=fill
253 IF(im.EQ.nint(360/abs(
dlon))) xmax=im+2
257 IF(
PRESENT(crot).AND.
PRESENT(srot))
THEN
262 IF(
PRESENT(xlon).AND.
PRESENT(xlat).AND.
PRESENT(ylon).AND.
PRESENT(ylat))
THEN
267 IF(
PRESENT(area))
THEN
274 IF(iopt.EQ.0.OR.iopt.EQ.1)
THEN
277 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
278 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
279 rlon(n)=mod(rlon1+
dlon*(xpts(n)-1)+3600,360.)
280 rlat(n)=min(max(rlat1+
dlat*(ypts(n)-1),-90.),90.)
293 ELSEIF(iopt.EQ.-1)
THEN
296 IF(abs(rlon(n)).LE.360.AND.abs(rlat(n)).LE.90)
THEN
297 xpts(n)=1+hi*mod(hi*(rlon(n)-rlon1)+3600,360.)/
dlon
298 ypts(n)=1+(rlat(n)-rlat1)/
dlat
299 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
300 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
333 REAL,
INTENT( OUT) :: CROT, SROT
350 REAL,
INTENT( OUT) :: XLON,XLAT,YLON,YLAT
369 REAL,
INTENT(IN ) :: RLAT
370 REAL,
INTENT( OUT) :: AREA
372 REAL,
PARAMETER :: PI=3.14159265358979
373 REAL,
PARAMETER :: DPR=180./pi
375 REAL :: DSLAT, RLATU, RLATD
377 rlatu=min(max(rlat+
dlat/2,-90.),90.)
378 rlatd=min(max(rlat-
dlat/2,-90.),90.)
379 dslat=sin(rlatu/dpr)-sin(rlatd/dpr)
void gdswzd(int igdtnum, int *igdtmpl, int igdtlen, int iopt, int npts, float fill, float *xpts, float *ypts, float *rlon, float *rlat, int *nret, float *crot, float *srot, float *xlon, float *xlat, float *ylon, float *ylat, float *area)
gdswzd() interface for C for _4 build of library.
Determine earth radius and shape.
Equidistant cylindrical grib decoder and grid coordinate transformations.
real dlat
Grid resolution in degrees n/s direction.
subroutine init_grib2(self, g2_desc)
Initializes an equidistant cylindrical grid given a grib2_descriptor object.
subroutine init_grib1(self, g1_desc)
Initializes an equidistant cylindrical grid given a grib1_descriptor object.
real dlon
Grid resolution in degrees e/w direction.
subroutine equid_cylind_map_jacob(xlon, xlat, ylon, ylat)
Computes the map jacobians for a equidistant cylindrical grid.
subroutine equid_cylind_grid_area(rlat, area)
Computes the grid box area for a equidistant cylindrical grid.
subroutine gdswzd_equid_cylind(self, iopt, npts, fill, xpts, ypts, rlon, rlat, nret, crot, srot, xlon, xlat, ylon, ylat, area)
Calculates Earth coordinates (iopt = 1) or grid coorindates (iopt = -1) for equidistant cylindrical g...
real rerth
Radius of the Earth.
subroutine equid_cylind_vect_rot(crot, srot)
Computes the vector rotation sines and cosines for a equidistant cylindrical grid.
Users derived type grid descriptor objects to abstract away the raw GRIB1 and GRIB2 grid definitions.
Descriptor representing a grib1 grib descriptor section (GDS) with an integer array.
Abstract grid that holds fields and methods common to all grids.