80 real(kd) :: rlat1, rlon1, rlat0, rlat2, rlon2, nbd, ebd
81 real(kd) :: hs, hs2, slat1, slat2, slatr, clon1, clon2, clat1, clat2, clatr, clonr, rlonr, rlatr
83 associate(kgds => g1_desc%gds)
84 self%rerth = 6.3712e6_kd
85 self%eccen_squared = 0d0
87 rlat1=kgds(4)*1.e-3_kd
88 rlon1=kgds(5)*1.e-3_kd
89 rlat0=kgds(7)*1.e-3_kd
90 self%RLON0=kgds(8)*1.e-3_kd
91 rlat2=kgds(12)*1.e-3_kd
92 rlon2=kgds(13)*1.e-3_kd
94 self%IROT=mod(kgds(6)/8,2)
100 self%SLAT0=sin(rlat0/
dpr)
101 self%CLAT0=cos(rlat0/
dpr)
103 hs=sign(1._kd,mod(rlon1-self%RLON0+180+3600,360._kd)-180)
104 clon1=cos((rlon1-self%RLON0)/
dpr)
105 slatr=self%CLAT0*slat1-self%SLAT0*clat1*clon1
106 clatr=sqrt(1-slatr**2)
107 clonr=(self%CLAT0*clat1*clon1+self%SLAT0*slat1)/clatr
108 rlatr=
dpr*asin(slatr)
109 rlonr=hs*
dpr*acos(clonr)
115 hs2=sign(1._kd,mod(rlon2-self%RLON0+180+3600,360._kd)-180)
116 clon2=cos((rlon2-self%RLON0)/
dpr)
117 slatr=self%CLAT0*slat2-self%SLAT0*clat2*clon2
118 clatr=sqrt(1-slatr**2)
119 clonr=(self%CLAT0*clat2*clon2+self%SLAT0*slat2)/clatr
121 ebd=hs2*
dpr*acos(clonr)
122 self%DLATS=(nbd-self%SBD)/float(self%JM-1)
123 self%DLONS=(ebd-self%WBD)/float(self%IM-1)
128 self%nscan = mod(kgds(11) / 32, 2)
129 self%nscan_field_pos = self%nscan
165 type(grib2_descriptor),
intent(in) :: g2_desc
167 real(kd) :: rlat1, rlon1, rlat0, rlat2, rlon2, nbd, ebd
169 integer :: i_offset_odd, i_offset_even, j_offset
171 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
173 CALL earth_radius(igdtmpl,igdtlen,self%rerth,self%eccen_squared)
175 i_offset_odd=mod(igdtmpl(19)/8,2)
176 i_offset_even=mod(igdtmpl(19)/4,2)
177 j_offset=mod(igdtmpl(19)/2,2)
179 iscale=igdtmpl(10)*igdtmpl(11)
180 IF(iscale==0) iscale=10**6
182 rlat1=float(igdtmpl(12))/float(iscale)
183 rlon1=float(igdtmpl(13))/float(iscale)
184 rlat0=float(igdtmpl(20))/float(iscale)
187 self%RLON0=float(igdtmpl(21))/float(iscale)
189 rlat2=float(igdtmpl(15))/float(iscale)
190 rlon2=float(igdtmpl(16))/float(iscale)
192 self%IROT=mod(igdtmpl(14)/8,2)
196 self%SLAT0=sin(rlat0/dpr)
197 self%CLAT0=cos(rlat0/dpr)
200 IF (self%WBD > 180.0) self%WBD = self%WBD - 360.0
206 self%DLATS=(nbd-self%SBD)/float(self%JM-1)
207 self%DLONS=(ebd-self%WBD)/float(self%IM-1)
209 IF(i_offset_odd==1) self%WBD=self%WBD+(0.5_kd*self%DLONS)
210 IF(j_offset==1) self%SBD=self%SBD+(0.5_kd*self%DLATS)
216 self%nscan = mod(igdtmpl(19) / 32, 2)
217 self%nscan_field_pos = self%nscan
232 type(grib2_descriptor),
intent(in) :: g2_desc
234 real(kd) :: rlat1, rlon1, rlat0, rlat2, rlon2, nbd, ebd
236 integer :: i_offset_odd, i_offset_even, j_offset
237 real(kd) :: hs, hs2, slat1, slat2, slatr, clon1, clon2, clat1, clat2, clatr, clonr, rlonr, rlatr
239 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
241 CALL earth_radius(igdtmpl,igdtlen,self%rerth,self%eccen_squared)
243 i_offset_odd=mod(igdtmpl(19)/8,2)
244 i_offset_even=mod(igdtmpl(19)/4,2)
245 j_offset=mod(igdtmpl(19)/2,2)
247 iscale=igdtmpl(10)*igdtmpl(11)
248 IF(iscale==0) iscale=10**6
250 rlat1=float(igdtmpl(12))/float(iscale)
251 rlon1=float(igdtmpl(13))/float(iscale)
252 rlat0=float(igdtmpl(15))/float(iscale)
254 self%RLON0=float(igdtmpl(16))/float(iscale)
256 rlat2=float(igdtmpl(20))/float(iscale)
257 rlon2=float(igdtmpl(21))/float(iscale)
259 self%IROT=mod(igdtmpl(14)/8,2)
266 self%SLAT0=sin(rlat0/dpr)
267 self%CLAT0=cos(rlat0/dpr)
269 hs=sign(1._kd,mod(rlon1-self%RLON0+180+3600,360._kd)-180)
271 clon1=cos((rlon1-self%RLON0)/dpr)
272 slatr=self%CLAT0*slat1-self%SLAT0*clat1*clon1
273 clatr=sqrt(1-slatr**2)
274 clonr=(self%CLAT0*clat1*clon1+self%SLAT0*slat1)/clatr
275 rlatr=dpr*asin(slatr)
276 rlonr=hs*dpr*acos(clonr)
279 IF (self%WBD > 180.0) self%WBD = self%WBD - 360.0
284 hs2=sign(1._kd,mod(rlon2-self%RLON0+180+3600,360._kd)-180)
285 clon2=cos((rlon2-self%RLON0)/dpr)
286 slatr=self%CLAT0*slat2-self%SLAT0*clat2*clon2
287 clatr=sqrt(1-slatr**2)
288 clonr=(self%CLAT0*clat2*clon2+self%SLAT0*slat2)/clatr
290 ebd=hs2*dpr*acos(clonr)
291 self%DLATS=(nbd-self%SBD)/float(self%JM-1)
292 self%DLONS=(ebd-self%WBD)/float(self%IM-1)
294 IF(i_offset_odd==1) self%WBD=self%WBD+(0.5_kd*self%DLONS)
295 IF(j_offset==1) self%SBD=self%SBD+(0.5_kd*self%DLATS)
301 self%nscan = mod(igdtmpl(19) / 32, 2)
302 self%nscan_field_pos = self%nscan
366 FILL,XPTS,YPTS,RLON,RLAT,NRET, &
367 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA)
371 INTEGER,
INTENT(IN ) :: IOPT, NPTS
372 INTEGER,
INTENT( OUT) :: NRET
374 REAL,
INTENT(IN ) :: FILL
375 REAL,
INTENT(INOUT) :: RLON(NPTS),RLAT(NPTS)
376 REAL,
INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS)
377 REAL,
OPTIONAL,
INTENT( OUT) :: CROT(NPTS),SROT(NPTS)
378 REAL,
OPTIONAL,
INTENT( OUT) :: XLON(NPTS),XLAT(NPTS)
379 REAL,
OPTIONAL,
INTENT( OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
383 LOGICAL :: LROT, LMAP, LAREA
386 REAL(KIND=
kd) :: clonr,clatr,slatr
387 REAL(KIND=
kd) :: clat,slat,clon
388 REAL(KIND=
kd) :: rlatr,rlonr
389 REAL(KIND=
kd) :: wbd,sbd
390 REAL :: XMIN,XMAX,YMIN,YMAX
392 IF(
PRESENT(crot)) crot=fill
393 IF(
PRESENT(srot)) srot=fill
394 IF(
PRESENT(xlon)) xlon=fill
395 IF(
PRESENT(xlat)) xlat=fill
396 IF(
PRESENT(ylon)) ylon=fill
397 IF(
PRESENT(ylat)) ylat=fill
398 IF(
PRESENT(area)) area=fill
440 IF(
PRESENT(crot).AND.
PRESENT(srot))
THEN
445 IF(
PRESENT(xlon).AND.
PRESENT(xlat).AND.
PRESENT(ylon).AND.
PRESENT(ylat))
THEN
450 IF(
PRESENT(area))
THEN
457 IF(iopt.EQ.0.OR.iopt.EQ.1)
THEN
461 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
462 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
463 rlonr=wbd+(xpts(n)-1._kd)*
dlons
464 rlatr=sbd+(ypts(n)-1._kd)*
dlats
465 IF(rlonr <= 0._kd)
THEN
479 ELSEIF(slat.GE.1)
THEN
487 clon=min(max(clon,-1._kd),1._kd)
488 rlon(n)=real(mod(
rlon0+hs*dpr*acos(clon)+3600,360._kd))
489 rlat(n)=real(dpr*asin(slat))
493 clat, slat, clon, crot(n), srot(n))
495 clat, slat, clon, xlon(n), xlat(n), ylon(n), ylat(n))
505 ELSEIF(iopt.EQ.-1)
THEN
509 IF(abs(rlon(n)).LE.360.AND.abs(rlat(n)).LE.90)
THEN
510 hs=sign(1._kd,mod(rlon(n)-
rlon0+180+3600,360._kd)-180)
511 clon=cos((rlon(n)-
rlon0)/dpr)
512 slat=sin(rlat(n)/dpr)
513 clat=cos(rlat(n)/dpr)
519 ELSEIF(slatr.GE.1)
THEN
524 clatr=sqrt(1-slatr**2)
526 clonr=min(max(clonr,-1._kd),1._kd)
527 rlonr=hs*dpr*acos(clonr)
528 rlatr=dpr*asin(slatr)
530 xpts(n)=real((rlonr-wbd)/
dlons+1._kd)
531 ypts(n)=real((rlatr-sbd)/
dlats+1._kd)
532 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
533 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
536 clat, slat, clon, crot(n), srot(n))
538 clat, slat, clon, xlon(n), xlat(n), ylon(n), ylat(n))
668 SLAT, CLON, XLON, XLAT, YLON, YLAT)
671 REAL(KIND=
kd),
INTENT(IN ) :: clatr, clat, slat, clon
672 REAL ,
INTENT(IN ) :: FILL, RLON
673 REAL ,
INTENT( OUT) :: XLON, XLAT, YLON, YLAT
675 REAL(KIND=
kd) :: slon, term1, term2
677 IF(clatr.LE.0._kd)
THEN
683 slon=sin((rlon-
rlon0)/dpr)
685 term2=
slat0*slon/clatr
686 xlon=real(term1*clat/(
dlons*clatr))
687 xlat=real(-term2/(
dlons*clatr))
688 ylon=real(term2*clat/
dlats)
689 ylat=real(term1/
dlats)
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(self, iopt, npts, fill, xpts, ypts, rlon, rlat, nret, crot, srot, xlon, xlat, ylon, ylat, area)
GDS wizard for rotated equidistant cylindrical.
subroutine rot_equid_cylind_map_jacob(fill, rlon, clatr, clat, slat, clon, xlon, xlat, ylon, ylat)
Map jacobians for rotated equidistant cylindrical grids - non "e" stagger.