49 REAL,
ALLOCATABLE ::
blat(:)
69 associate(kgds => g1_desc%gds)
71 self%eccen_squared = 0.0
75 self%RLAT1=kgds(4)*1.e-3
76 self%RLON1=kgds(5)*1.e-3
77 self%RLON2=kgds(8)*1.e-3
79 iscan=mod(kgds(11)/128,2)
80 self%JSCAN=mod(kgds(11)/64,2)
82 self%JH=(-1)**self%JSCAN
83 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
88 self%nscan = mod(kgds(11) / 32, 2)
89 self%nscan_field_pos = self%nscan
92 self%iwrap=nint(360 / abs(self%dlon))
93 if(self%im < self%iwrap) self%iwrap = 0
95 if(self%iwrap > 0 .and. mod(self%iwrap, 2) == 0)
then
97 if(self%jm == self%jg)
then
99 self%jwrap2 = 2 * self%jm + 1
114 type(grib2_descriptor),
intent(in) :: g2_desc
116 integer :: iscale, iscan, jg
118 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
119 call earth_radius(igdtmpl, igdtlen, self%rerth, self%eccen_squared)
123 iscale=igdtmpl(10)*igdtmpl(11)
124 IF(iscale==0) iscale=10**6
125 self%RLAT1=float(igdtmpl(12))/float(iscale)
126 self%RLON1=float(igdtmpl(13))/float(iscale)
127 self%RLON2=float(igdtmpl(16))/float(iscale)
128 self%JG=igdtmpl(18)*2
129 iscan=mod(igdtmpl(19)/128,2)
130 self%JSCAN=mod(igdtmpl(19)/64,2)
132 self%JH=(-1)**self%JSCAN
133 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
136 self%iwrap = nint(360 / abs(self%dlon))
137 if(self%im < self%iwrap) self%iwrap = 0
140 if(self%iwrap > 0 .and. mod(self%iwrap, 2) == 0)
then
142 if(self%jm == jg)
then
144 self%jwrap2 = 2 * self%jm + 1
147 self%nscan = mod(igdtmpl(19) / 32, 2)
148 self%nscan_field_pos = self%nscan
199 XPTS,YPTS,RLON,RLAT,NRET, &
200 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA)
204 INTEGER,
INTENT(IN ) :: IOPT, NPTS
205 INTEGER,
INTENT( OUT) :: NRET
207 REAL,
INTENT(IN ) :: FILL
208 REAL,
INTENT(INOUT) :: RLON(NPTS),RLAT(NPTS)
209 REAL,
INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS)
210 REAL,
OPTIONAL,
INTENT( OUT) :: CROT(NPTS),SROT(NPTS)
211 REAL,
OPTIONAL,
INTENT( OUT) :: XLON(NPTS),XLAT(NPTS)
212 REAL,
OPTIONAL,
INTENT( OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
214 INTEGER :: JSCAN, IM, JM
218 LOGICAL :: LROT, LMAP, LAREA
220 REAL,
ALLOCATABLE :: ALAT(:), ALAT_JSCAN(:)
221 REAL,
ALLOCATABLE :: ALAT_TEMP(:),BLAT_TEMP(:)
222 REAL :: HI, RLATA, RLATB, RLAT1, RLON1, RLON2
223 REAL :: XMAX, XMIN, YMAX, YMIN, YPTSA, YPTSB
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
234 IF(
PRESENT(crot).AND.
PRESENT(srot))
THEN
239 IF(
PRESENT(xlon).AND.
PRESENT(xlat).AND.
PRESENT(ylon).AND.
PRESENT(ylat))
THEN
244 IF(
PRESENT(area))
THEN
265 ALLOCATE(alat_temp(jg))
266 ALLOCATE(blat_temp(jg))
267 CALL splat(4,jg,alat_temp,blat_temp)
268 ALLOCATE(alat(0:jg+1))
269 ALLOCATE(
blat(0:jg+1))
272 alat(ja)=real(dpr*asin(alat_temp(ja)))
273 blat(ja)=blat_temp(ja)
276 DEALLOCATE(alat_temp,blat_temp)
282 DO WHILE(
j1.LT.jg.AND.rlat1.LT.(alat(
j1)+alat(
j1+1))/2)
286 ALLOCATE(alat_jscan(jg))
288 alat_jscan(
j1+
jh*(ja-1))=alat(ja)
292 ylat_row(ja)=2.0/(alat_jscan(ja+1)-alat_jscan(ja-1))
294 ylat_row(1)=1.0/(alat_jscan(2)-alat_jscan(1))
296 ylat_row(jg)=1.0/(alat_jscan(jg)-alat_jscan(jg-1))
298 DEALLOCATE(alat_jscan)
302 IF(im.EQ.nint(360/abs(
dlon))) xmax=im+2
308 IF(iopt.EQ.0.OR.iopt.EQ.1)
THEN
311 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
312 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
313 rlon(n)=mod(rlon1+
dlon*(xpts(n)-1)+3600,360.)
316 rlata=alat(
j1+
jh*(j-1))
318 rlat(n)=rlata+wb*(rlatb-rlata)
322 xlon(n),xlat(n),ylon(n),ylat(n))
332 ELSEIF(iopt.EQ.-1)
THEN
337 IF(abs(rlon(n)).LE.360.AND.abs(rlat(n)).LE.90)
THEN
338 xpts(n)=1+hi*mod(hi*(rlon(n)-rlon1)+3600,360.)/
dlon
339 ja=min(int((jg+1)/180.*(90-rlat(n))),jg)
340 IF(rlat(n).GT.alat(ja)) ja=max(ja-2,0)
341 IF(rlat(n).LT.alat(ja+1)) ja=min(ja+2,jg)
342 IF(rlat(n).GT.alat(ja)) ja=ja-1
343 IF(rlat(n).LT.alat(ja+1)) ja=ja+1
346 wb=(alat(ja)-rlat(n))/(alat(ja)-alat(ja+1))
347 ypts(n)=yptsa+wb*(yptsb-yptsa)
348 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
349 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
353 xlon(n),xlat(n),ylon(n),ylat(n))
363 DEALLOCATE(alat,
blat)
383 REAL,
INTENT( OUT) :: CROT, SROT
403 REAL,
INTENT(IN ) :: YPTS
404 REAL,
INTENT( OUT) :: XLON, XLAT, YLON, YLAT
423 REAL,
INTENT(IN ) :: YPTS
424 REAL,
INTENT( OUT) :: AREA
428 REAL :: WB, WLAT, WLATA, WLATB
434 wlat=wlata+wb*(wlatb-wlata)
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.
Module containing common constants.
Gaussian grid coordinate transformations.
subroutine gdswzd_gaussian(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 Gaussian grids.
real, dimension(:), allocatable ylat_row
dy/dlat for each row in 1/degrees.
subroutine gaussian_grid_area(ypts, area)
Computes the grid box area for a gaussian cylindrical grid.
integer jh
Scan mode flag in 'j' direction.
subroutine gaussian_map_jacob(ypts, xlon, xlat, ylon, ylat)
Computes the map jacobians for a gaussian cylindrical grid.
real rerth
Radius of the earth.
real dlon
"i"-direction increment.
subroutine init_grib1(self, g1_desc)
Initializes a gaussian grid given a grib1_descriptor object.
subroutine gaussian_vect_rot(crot, srot)
Computes the vector rotation sines and cosines for a gaussian cylindrical grid.
subroutine init_grib2(self, g2_desc)
Initializes a gaussian grid given a grib2_descriptor object.
real, dimension(:), allocatable blat
Gaussian latitude for each parallel.
integer j1
'j' index of first grid point within the global array of latitudes.
Users derived type grid descriptor objects to abstract away the raw GRIB1 and GRIB2 grid definitions.
subroutine splat(idrt, jmax, slat, wlat)
Computes cosines of colatitude and Gaussian weights for one of the following specific global sets of ...
Descriptor representing a grib1 grib descriptor section (GDS) with an integer array.
Abstract grid that holds fields and methods common to all grids.