96 real(kd) :: rlat1, rlon1, rlon0, slat1, clat1, slat0, clat0, clon1
97 real(kd) :: slatr, clatr, clonr, rlatr, rlonr, dlats, dlons, hs, hi
100 integer :: is1, kscan, irot
102 associate(kgds => g1_desc%gds)
103 self%rerth = 6.3712e6_kd
104 self%eccen_squared = 0.0
109 self%nscan_field_pos = 3
110 self%nscan = mod(kgds(11)/32,2)
112 rlat1=kgds(4)*1.e-3_kd
113 rlon1=kgds(5)*1.e-3_kd
114 rlat0=kgds(7)*1.e-3_kd
115 rlon0=kgds(8)*1.e-3_kd
117 irot=mod(kgds(6)/8,2)
118 kscan=mod(kgds(11)/256,2)
119 iscan=mod(kgds(11)/128,2)
125 hs=sign(1._kd,mod(rlon1-rlon0+180+3600,360._kd)-180)
126 clon1=cos((rlon1-rlon0)/
dpr)
127 slatr=clat0*slat1-slat0*clat1*clon1
128 clatr=sqrt(1-slatr**2)
129 clonr=(clat0*clat1*clon1+slat0*slat1)/clatr
130 rlatr=
dpr*asin(slatr)
131 rlonr=hs*
dpr*acos(clonr)
132 dlats=rlatr/(-(jm-1)/2)
133 dlons=rlonr/(-((im * 2 - 1) -1)/2)
168 type(grib2_descriptor),
intent(in) :: g2_desc
170 integer :: iscale, iscan
172 integer :: i_offset_odd
174 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
175 CALL earth_radius(igdtmpl,igdtlen,self%rerth,self%eccen_squared)
192 self%NSCAN=mod(igdtmpl(16)/32,2)
193 self%nscan_field_pos = 3
195 iscale=igdtmpl(10)*igdtmpl(11)
196 IF(iscale==0) iscale=10**6
198 self%RLON0=float(igdtmpl(21))/float(iscale)
199 self%DLATS=float(igdtmpl(18))/float(iscale)
201 self%DLONS=float(igdtmpl(17))/float(iscale) * 0.5_kd
203 self%IROT=mod(igdtmpl(14)/8,2)
205 i_offset_odd=mod(igdtmpl(19)/8,2)
206 self%KSCAN=i_offset_odd
207 iscan=mod(igdtmpl(19)/128,2)
211 rlat0=float(igdtmpl(20))/float(iscale)
214 self%SLAT0=sin(rlat0/dpr)
215 self%CLAT0=cos(rlat0/dpr)
217 self%RLAT1=float(igdtmpl(12))/float(iscale)
218 self%RLON1=float(igdtmpl(13))/float(iscale)
271 FILL,XPTS,YPTS,RLON,RLAT,NRET, &
272 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA)
277 INTEGER,
INTENT(IN ) :: IOPT, NPTS
278 INTEGER,
INTENT( OUT) :: NRET
280 REAL,
INTENT(IN ) :: FILL
281 REAL,
INTENT(INOUT) :: RLON(NPTS),RLAT(NPTS)
282 REAL,
INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS)
283 REAL,
OPTIONAL,
INTENT( OUT) :: CROT(NPTS),SROT(NPTS)
284 REAL,
OPTIONAL,
INTENT( OUT) :: XLON(NPTS),XLAT(NPTS)
285 REAL,
OPTIONAL,
INTENT( OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
287 INTEGER :: IM, JM, IS1, N
291 LOGICAL :: LROT, LMAP, LAREA
293 REAL(KIND=
kd) :: rlat1, rlon1
294 REAL(KIND=
kd) :: clonr
295 REAL(KIND=
kd) :: rlatr, rlonr, sbd, wbd, hs, hi
296 REAL :: XMAX, XMIN, YMAX, YMIN, XPTF, YPTF
298 IF(
PRESENT(crot)) crot=fill
299 IF(
PRESENT(srot)) srot=fill
300 IF(
PRESENT(xlon)) xlon=fill
301 IF(
PRESENT(xlat)) xlat=fill
302 IF(
PRESENT(ylon)) ylon=fill
303 IF(
PRESENT(ylat)) ylat=fill
304 IF(
PRESENT(area)) area=fill
330 IF (wbd > 180.0) wbd = wbd - 360.0
343 IF(
PRESENT(crot).AND.
PRESENT(srot))
THEN
348 IF(
PRESENT(xlon).AND.
PRESENT(xlat).AND.
PRESENT(ylon).AND.
PRESENT(ylat))
THEN
353 IF(
PRESENT(area))
THEN
361 IF(iopt.EQ.0.OR.iopt.EQ.1)
THEN
363 xptf=ypts(n)+(xpts(n)-is1)
364 yptf=ypts(n)-(xpts(n)-is1)+kscan
365 IF(xptf.GE.xmin.AND.xptf.LE.xmax.AND. &
366 yptf.GE.ymin.AND.yptf.LE.ymax)
THEN
367 hs=hi*sign(1.,xptf-(im+1)/2)
368 select type(desc => self%descriptor)
369 type is(grib1_descriptor)
370 rlonr=(xptf-(im+1)/2)*
dlons
371 rlatr=(yptf-(jm+1)/2)*
dlats
372 type is(grib2_descriptor)
373 rlonr=(xptf-1.0_kd)*
dlons + wbd
374 rlatr=(yptf-1.0_kd)*
dlats + sbd
385 ELSEIF(
slat.GE.1)
THEN
394 rlon(n)=real(mod(
rlon0+hs*dpr*acos(
clon)+3600,360._kd))
395 rlat(n)=real(dpr*asin(
slat))
400 xlon(n),xlat(n),ylon(n),ylat(n))
409 ELSEIF(iopt.EQ.-1)
THEN
411 IF(abs(rlon(n)).LE.360.AND.abs(rlat(n)).LE.90)
THEN
412 hs=sign(1._kd,mod(rlon(n)-
rlon0+180+3600,360._kd)-180)
414 slat=sin(rlat(n)/dpr)
415 clat=cos(rlat(n)/dpr)
421 ELSEIF(
slatr.GE.1)
THEN
428 clonr=min(max(clonr,-1._kd),1._kd)
429 rlonr=hs*dpr*acos(clonr)
430 rlatr=dpr*asin(
slatr)
432 select type(desc => self%descriptor)
433 type is(grib1_descriptor)
434 xptf=real(((rlonr-wbd)/
dlons)+1.0_kd)
435 yptf=real(((rlatr-sbd)/
dlats)+1.0_kd)
436 type is(grib2_descriptor)
437 xptf=real((im+1)/2+rlonr/
dlons)
438 yptf=real((jm+1)/2+rlatr/
dlats)
441 IF(xptf.GE.xmin.AND.xptf.LE.xmax.AND. &
442 yptf.GE.ymin.AND.yptf.LE.ymax)
THEN
443 xpts(n)=is1+(xptf-(yptf-kscan))/2
444 ypts(n)=(xptf+(yptf-kscan))/2
448 xlon(n),xlat(n),ylon(n),ylat(n))
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_rot_equid_cylind_egrid(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 rotated equidistant cylin...