45 REAL,
ALLOCATABLE ::
blat(:)
65 associate(kgds => g1_desc%gds)
67 self%eccen_squared = 0.0
71 self%RLAT1=kgds(4)*1.e-3
72 self%RLON1=kgds(5)*1.e-3
73 self%RLON2=kgds(8)*1.e-3
75 iscan=mod(kgds(11)/128,2)
76 self%JSCAN=mod(kgds(11)/64,2)
78 self%JH=(-1)**self%JSCAN
79 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
84 self%nscan = mod(kgds(11) / 32, 2)
85 self%nscan_field_pos = self%nscan
88 self%iwrap=nint(360 / abs(self%dlon))
89 if(self%im < self%iwrap) self%iwrap = 0
91 if(self%iwrap > 0 .and. mod(self%iwrap, 2) == 0)
then
93 if(self%jm == self%jg)
then
95 self%jwrap2 = 2 * self%jm + 1
110 type(grib2_descriptor),
intent(in) :: g2_desc
112 integer :: iscale, iscan, jg
114 associate(igdtmpl => g2_desc%gdt_tmpl, igdtlen => g2_desc%gdt_len)
115 call earth_radius(igdtmpl, igdtlen, self%rerth, self%eccen_squared)
119 iscale=igdtmpl(10)*igdtmpl(11)
120 IF(iscale==0) iscale=10**6
121 self%RLAT1=float(igdtmpl(12))/float(iscale)
122 self%RLON1=float(igdtmpl(13))/float(iscale)
123 self%RLON2=float(igdtmpl(16))/float(iscale)
124 self%JG=igdtmpl(18)*2
125 iscan=mod(igdtmpl(19)/128,2)
126 self%JSCAN=mod(igdtmpl(19)/64,2)
128 self%JH=(-1)**self%JSCAN
129 self%DLON=self%HI*(mod(self%HI*(self%RLON2-self%RLON1)-1+3600,360.)+1)/(self%IM-1)
132 self%iwrap = nint(360 / abs(self%dlon))
133 if(self%im < self%iwrap) self%iwrap = 0
136 if(self%iwrap > 0 .and. mod(self%iwrap, 2) == 0)
then
138 if(self%jm == jg)
then
140 self%jwrap2 = 2 * self%jm + 1
143 self%nscan = mod(igdtmpl(19) / 32, 2)
144 self%nscan_field_pos = self%nscan
195 XPTS,YPTS,RLON,RLAT,NRET, &
196 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA)
200 INTEGER,
INTENT(IN ) :: IOPT, NPTS
201 INTEGER,
INTENT( OUT) :: NRET
203 REAL,
INTENT(IN ) :: FILL
204 REAL,
INTENT(INOUT) :: RLON(NPTS),RLAT(NPTS)
205 REAL,
INTENT(INOUT) :: XPTS(NPTS),YPTS(NPTS)
206 REAL,
OPTIONAL,
INTENT( OUT) :: CROT(NPTS),SROT(NPTS)
207 REAL,
OPTIONAL,
INTENT( OUT) :: XLON(NPTS),XLAT(NPTS)
208 REAL,
OPTIONAL,
INTENT( OUT) :: YLON(NPTS),YLAT(NPTS),AREA(NPTS)
210 INTEGER :: JSCAN, IM, JM
214 LOGICAL :: LROT, LMAP, LAREA
216 REAL,
ALLOCATABLE :: ALAT(:), ALAT_JSCAN(:)
217 REAL,
ALLOCATABLE :: ALAT_TEMP(:),BLAT_TEMP(:)
218 REAL :: HI, RLATA, RLATB, RLAT1, RLON1, RLON2
219 REAL :: XMAX, XMIN, YMAX, YMIN, YPTSA, YPTSB
222 IF(
PRESENT(crot)) crot=fill
223 IF(
PRESENT(srot)) srot=fill
224 IF(
PRESENT(xlon)) xlon=fill
225 IF(
PRESENT(xlat)) xlat=fill
226 IF(
PRESENT(ylon)) ylon=fill
227 IF(
PRESENT(ylat)) ylat=fill
228 IF(
PRESENT(area)) area=fill
230 IF(
PRESENT(crot).AND.
PRESENT(srot))
THEN
235 IF(
PRESENT(xlon).AND.
PRESENT(xlat).AND.
PRESENT(ylon).AND.
PRESENT(ylat))
THEN
240 IF(
PRESENT(area))
THEN
261 ALLOCATE(alat_temp(jg))
262 ALLOCATE(blat_temp(jg))
263 CALL splat(4,jg,alat_temp,blat_temp)
264 ALLOCATE(alat(0:jg+1))
265 ALLOCATE(
blat(0:jg+1))
268 alat(ja)=real(dpr*asin(alat_temp(ja)))
269 blat(ja)=blat_temp(ja)
272 DEALLOCATE(alat_temp,blat_temp)
278 DO WHILE(
j1.LT.jg.AND.rlat1.LT.(alat(
j1)+alat(
j1+1))/2)
282 ALLOCATE(alat_jscan(jg))
284 alat_jscan(
j1+
jh*(ja-1))=alat(ja)
288 ylat_row(ja)=2.0/(alat_jscan(ja+1)-alat_jscan(ja-1))
290 ylat_row(1)=1.0/(alat_jscan(2)-alat_jscan(1))
292 ylat_row(jg)=1.0/(alat_jscan(jg)-alat_jscan(jg-1))
294 DEALLOCATE(alat_jscan)
298 IF(im.EQ.nint(360/abs(
dlon))) xmax=im+2
304 IF(iopt.EQ.0.OR.iopt.EQ.1)
THEN
307 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
308 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
309 rlon(n)=mod(rlon1+
dlon*(xpts(n)-1)+3600,360.)
312 rlata=alat(
j1+
jh*(j-1))
314 rlat(n)=rlata+wb*(rlatb-rlata)
318 xlon(n),xlat(n),ylon(n),ylat(n))
328 ELSEIF(iopt.EQ.-1)
THEN
333 IF(abs(rlon(n)).LE.360.AND.abs(rlat(n)).LE.90)
THEN
334 xpts(n)=1+hi*mod(hi*(rlon(n)-rlon1)+3600,360.)/
dlon
335 ja=min(int((jg+1)/180.*(90-rlat(n))),jg)
336 IF(rlat(n).GT.alat(ja)) ja=max(ja-2,0)
337 IF(rlat(n).LT.alat(ja+1)) ja=min(ja+2,jg)
338 IF(rlat(n).GT.alat(ja)) ja=ja-1
339 IF(rlat(n).LT.alat(ja+1)) ja=ja+1
342 wb=(alat(ja)-rlat(n))/(alat(ja)-alat(ja+1))
343 ypts(n)=yptsa+wb*(yptsb-yptsa)
344 IF(xpts(n).GE.xmin.AND.xpts(n).LE.xmax.AND. &
345 ypts(n).GE.ymin.AND.ypts(n).LE.ymax)
THEN
349 xlon(n),xlat(n),ylon(n),ylat(n))
359 DEALLOCATE(alat,
blat)
379 REAL,
INTENT( OUT) :: CROT, SROT
399 REAL,
INTENT(IN ) :: YPTS
400 REAL,
INTENT( OUT) :: XLON, XLAT, YLON, YLAT
419 REAL,
INTENT(IN ) :: YPTS
420 REAL,
INTENT( OUT) :: AREA
424 REAL :: WB, WLAT, WLATA, WLATB
430 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.
Module containing common constants.
Determine earth radius and shape.
Gaussian grid coordinate transformations.
real, dimension(:), allocatable ylat_row
dy/dlat for each row in 1/degrees.
integer jh
Scan mode flag in 'j' direction.
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 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_grid_area(YPTS, AREA)
Computes the grid box area for a gaussian cylindrical grid.
subroutine gaussian_vect_rot(CROT, SROT)
Computes the vector rotation sines and cosines for a gaussian cylindrical grid.
subroutine gaussian_map_jacob(YPTS, XLON, XLAT, YLON, YLAT)
Computes the map jacobians 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.
Descriptor representing a grib1 grib descriptor section (GDS) with an integer array.
Abstract grid that holds fields and methods common to all grids.