59 associate(kgds => g1_desc%gds)
62 self%RLAT1=kgds(4)*1.e-3
63 self%RLON1=kgds(5)*1.e-3
64 self%RLAT2=kgds(7)*1.e-3
65 self%RLON2=kgds(8)*1.e-3
66 iscan=mod(kgds(11)/128,2)
68 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
69 self%DLAT=(self%RLAT2-self%RLAT1)/(self%JM-1)
75 self%nscan = mod(kgds(11) / 32, 2)
76 self%nscan_field_pos = self%nscan
79 self%iwrap = nint(360/abs(self%dlon))
81 if(self%im < self%iwrap) self%iwrap=0
84 if(self%iwrap > 0 .and. mod(self%iwrap,2) == 0)
then
85 if(abs(self%rlat1) > 90-0.25*self%dlat)
then
87 elseif(abs(self%rlat1) > 90-0.75*self%dlat)
then
90 if(abs(self%rlat2) > 90-0.25*self%dlat)
then
91 self%jwrap2 = 2 * self%jm
92 elseif(abs(self%rlat2) > 90-0.75*self%dlat)
then
93 self%jwrap2 = 2 * self%jm+1
98 self%eccen_squared = 0.0
111 type(grib2_descriptor),
intent(in) :: g2_desc
113 integer :: iscale, iscan
115 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
118 iscale=igdtmpl(10)*igdtmpl(11)
119 IF(iscale==0) iscale=10**6
120 self%RLAT1=float(igdtmpl(12))/float(iscale)
121 self%RLON1=float(igdtmpl(13))/float(iscale)
122 self%RLAT2=float(igdtmpl(15))/float(iscale)
123 self%RLON2=float(igdtmpl(16))/float(iscale)
124 iscan=mod(igdtmpl(19)/128,2)
126 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
127 self%DLAT=(self%RLAT2-self%RLAT1)/(self%JM-1)
129 self%nscan = mod(igdtmpl(19)/32,2)
130 self%nscan_field_pos = self%nscan
132 self%iwrap = nint(360/abs(self%DLON))
134 if(self%im.lt.self%iwrap) self%iwrap=0
138 if(self%im < self%iwrap) self%iwrap=0
141 if(self%iwrap > 0 .and. mod(self%iwrap,2) == 0)
then
142 if(abs(self%rlat1) > 90-0.25*self%dlat)
then
144 elseif(abs(self%rlat1) > 90-0.75*self%dlat)
then
147 if(abs(self%rlat2) > 90-0.25*self%dlat)
then
148 self%jwrap2 = 2 * self%jm
149 elseif(abs(self%rlat2) > 90-0.75*self%dlat)
then
150 self%jwrap2 = 2 * self%jm+1
154 call earth_radius(igdtmpl, igdtlen, self%rerth, self%eccen_squared)
204 XPTS,YPTS,RLON,RLAT,NRET, &
205 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA)
209 INTEGER,
INTENT(IN ) :: IOPT, NPTS
210 INTEGER,
INTENT( OUT) :: NRET
212 REAL,
INTENT(IN ) :: FILL
213 REAL,
INTENT(INOUT) :: RLON(NPTS),RLAT(NPTS)
214 REAL,
INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS)
215 REAL,
OPTIONAL,
INTENT( OUT) :: CROT(NPTS),SROT(NPTS)
216 REAL,
OPTIONAL,
INTENT( OUT) :: XLON(NPTS),XLAT(NPTS)
217 REAL,
OPTIONAL,
INTENT( OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
221 LOGICAL :: LROT, LMAP, LAREA
223 REAL :: HI, RLAT1, RLON1, RLAT2, RLON2
224 REAL :: XMAX, XMIN, YMAX, YMIN
226 IF(
PRESENT(crot)) crot=fill
227 IF(
PRESENT(srot)) srot=fill
228 IF(
PRESENT(xlon)) xlon=fill
229 IF(
PRESENT(xlat)) xlat=fill
230 IF(
PRESENT(ylon)) ylon=fill
231 IF(
PRESENT(ylat)) ylat=fill
232 IF(
PRESENT(area)) area=fill
250 IF(im.EQ.nint(360/abs(
dlon))) xmax=im+2
254 IF(
PRESENT(crot).AND.
PRESENT(srot))
THEN
259 IF(
PRESENT(xlon).AND.
PRESENT(xlat).AND.
PRESENT(ylon).AND.
PRESENT(ylat))
THEN
264 IF(
PRESENT(area))
THEN
271 IF(iopt.EQ.0.OR.iopt.EQ.1)
THEN
274 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
275 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
276 rlon(n)=mod(rlon1+
dlon*(xpts(n)-1)+3600,360.)
277 rlat(n)=min(max(rlat1+
dlat*(ypts(n)-1),-90.),90.)
290 ELSEIF(iopt.EQ.-1)
THEN
293 IF(abs(rlon(n)).LE.360.AND.abs(rlat(n)).LE.90)
THEN
294 xpts(n)=1+hi*mod(hi*(rlon(n)-rlon1)+3600,360.)/
dlon
295 ypts(n)=1+(rlat(n)-rlat1)/
dlat
296 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
297 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
330 REAL,
INTENT( OUT) :: CROT, SROT
347 REAL,
INTENT( OUT) :: XLON,XLAT,YLON,YLAT
366 REAL,
INTENT(IN ) :: RLAT
367 REAL,
INTENT( OUT) :: AREA
369 REAL,
PARAMETER :: PI=3.14159265358979
370 REAL,
PARAMETER :: DPR=180./pi
372 REAL :: DSLAT, RLATU, RLATD
374 rlatu=min(max(rlat+
dlat/2,-90.),90.)
375 rlatd=min(max(rlat-
dlat/2,-90.),90.)
376 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.
subroutine equid_cylind_map_jacob(XLON, XLAT, YLON, YLAT)
Computes the map jacobians for a equidistant cylindrical grid.
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_grid_area(RLAT, AREA)
Computes the grid box area for a equidistant cylindrical grid.
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.
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...
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.