72 REAL,
PARAMETER :: SLAT=60.0
74 real :: dx, dy, hi, hj
75 integer :: iproj, iscan, jscan
77 associate(kgds => g1_desc%gds)
78 self%ELLIPTICAL=mod(kgds(6)/64,2).EQ.1
80 if (.not. self%elliptical)
then
82 self%eccen_squared = 0d0
91 self%RLAT1=kgds(4)*1.e-3
92 self%RLON1=kgds(5)*1.e-3
94 self%IROT=mod(kgds(6)/8,2)
98 self%ORIENT=kgds(7)*1.e-3
103 iproj=mod(kgds(10)/128,2)
104 iscan=mod(kgds(11)/128,2)
105 jscan=mod(kgds(11)/64,2)
111 IF(abs(self%H+1.).LT.tinyreal) self%ORIENT=self%ORIENT+180.
119 self%nscan = mod(kgds(11) / 32, 2)
120 self%nscan_field_pos = self%nscan
135 type(grib2_descriptor),
intent(in) :: g2_desc
137 real :: slat, dx, dy, hi, hj
138 integer :: iproj, iscan, jscan
140 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
141 call earth_radius(igdtmpl, igdtlen, self%rerth, self%eccen_squared)
143 self%ELLIPTICAL = self%eccen_squared > 0.0
148 self%RLAT1=float(igdtmpl(10))*1.e-6
149 self%RLON1=float(igdtmpl(11))*1.e-6
151 self%IROT=mod(igdtmpl(12)/8,2)
153 slat=float(abs(igdtmpl(13)))*1.e-6
156 self%ORIENT=float(igdtmpl(14))*1.e-6
158 dx=float(igdtmpl(15))*1.e-3
159 dy=float(igdtmpl(16))*1.e-3
161 iproj=mod(igdtmpl(17)/128,2)
162 iscan=mod(igdtmpl(18)/128,2)
163 jscan=mod(igdtmpl(18)/64,2)
172 self%nscan = mod(igdtmpl(18) / 32, 2)
173 self%nscan_field_pos = self%nscan
245 FILL,XPTS,YPTS,RLON,RLAT,NRET, &
246 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA)
251 INTEGER,
INTENT(IN ) :: IOPT, NPTS
252 INTEGER,
INTENT( OUT) :: NRET
254 REAL,
INTENT(IN ) :: FILL
255 REAL,
INTENT(INOUT) :: RLON(NPTS),RLAT(NPTS)
256 REAL,
INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS)
257 REAL,
OPTIONAL,
INTENT( OUT) :: CROT(NPTS),SROT(NPTS)
258 REAL,
OPTIONAL,
INTENT( OUT) :: XLON(NPTS),XLAT(NPTS)
259 REAL,
OPTIONAL,
INTENT( OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
264 LOGICAL :: ELLIPTICAL, LROT, LMAP, LAREA
266 REAL :: ALAT, ALAT1, ALONG, DIFF
268 REAL :: DR, E, E_OVER_2
270 REAL :: RLAT1, RLON1, RHO, T, TC
271 REAL :: XMAX, XMIN, YMAX, YMIN
274 IF(
PRESENT(crot)) crot=fill
275 IF(
PRESENT(srot)) srot=fill
276 IF(
PRESENT(xlon)) xlon=fill
277 IF(
PRESENT(xlat)) xlat=fill
278 IF(
PRESENT(ylon)) ylon=fill
279 IF(
PRESENT(ylat)) ylat=fill
280 IF(
PRESENT(area)) area=fill
282 elliptical = self%elliptical
298 e2 = self%eccen_squared
301 IF (.NOT.elliptical)
THEN
302 de=(1.+sin(slatr))*
rerth
303 dr=de*cos(rlat1/dpr)/(1+
h*sin(rlat1/dpr))
311 along = (rlon1-
orient)/dpr
312 t=tan(pi4-alat/2.)/((1.-e*sin(alat))/ &
313 (1.+e*sin(alat)))**(e_over_2)
314 tc=tan(pi4-slatr/2.)/((1.-e*sin(slatr))/ &
315 (1.+e*sin(slatr)))**(e_over_2)
316 mc=cos(slatr)/sqrt(1.0-
e2*(sin(slatr)**2))
318 yp = 1.0 + rho*cos(
h*along)/
dys
319 xp = 1.0 - rho*sin(
h*along)/
dxs
326 IF(
PRESENT(crot).AND.
PRESENT(srot))
THEN
331 IF(
PRESENT(xlon).AND.
PRESENT(xlat).AND.
PRESENT(ylon).AND.
PRESENT(ylat))
THEN
336 IF(
PRESENT(area))
THEN
343 IF(iopt.EQ.0.OR.iopt.EQ.1)
THEN
344 IF(.NOT.elliptical)
THEN
347 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
348 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
352 IF(dr2.LT.
de2*1.e-6)
THEN
356 rlon(n)=mod(
orient+
h*dpr*atan2(di,-dj)+3600,360.)
357 rlat(n)=
h*dpr*asin((
de2-dr2)/(
de2+dr2))
362 xlon(n),xlat(n),ylon(n),ylat(n))
374 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
375 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
378 rho=sqrt(di*di+dj*dj)
379 t=(rho*tc)/(
rerth*mc)
380 IF(abs(ypts(n)-yp)<0.01)
THEN
382 IF(di<=0.0) along=
orient-
h*90.0
384 along=
orient+
h*atan(di/(-dj))*dpr
385 IF(dj>0) along=along+180.
387 alat1=pi2-2.0*atan(t)
389 alat = pi2 - 2.0*atan(t*(((1.0-e*sin(alat1))/ &
390 (1.0+e*sin(alat1)))**(e_over_2)))
391 diff = abs(alat-alat1)*dpr
392 IF (diff < 0.000001)
EXIT
397 IF(rlon(n)<0.0) rlon(n)=rlon(n)+360.
398 IF(rlon(n)>360.0) rlon(n)=rlon(n)-360.0
410 ELSEIF(iopt.EQ.-1)
THEN
411 IF(.NOT.elliptical)
THEN
414 IF(abs(rlon(n)).LT.(360.+tinyreal).AND.abs(rlat(n)).LT.(90.+tinyreal).AND. &
415 abs(
h*rlat(n)+90).GT.tinyreal)
THEN
416 dr=de*tan((90-
h*rlat(n))/2/dpr)
419 ypts(n)=yp-cos((rlon(n)-
orient)/dpr)*dr/
dys
420 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
421 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
425 xlon(n),xlat(n),ylon(n),ylat(n))
440 IF(abs(rlon(n)).LT.(360+tinyreal).AND.abs(rlat(n)).LT.(90+tinyreal).AND. &
441 abs(
h*rlat(n)+90).GT.tinyreal)
THEN
443 along = (rlon(n)-
orient)/dpr
444 t=tan(pi4-alat*0.5)/((1.-e*sin(alat))/ &
445 (1.+e*sin(alat)))**(e_over_2)
447 xpts(n)= xp + rho*sin(
h*along) /
dxs
448 ypts(n)= yp - rho*cos(
h*along) /
dys
449 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
450 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
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.
subroutine gdswzd_polar_stereo(self, iopt, npts, fill, xpts, ypts, rlon, rlat, nret, crot, srot, xlon, xlat, ylon, ylat, area)
GDS wizard for polar stereographic azimuthal.