44 subroutine gdt2gds(igds, igdstmpl, idefnum, ideflist, kgds, igrid, iret)
47 integer,
intent(in) :: idefnum
48 integer,
intent(in) :: igds(*), igdstmpl(*), ideflist(*)
49 integer,
intent(out) :: kgds(*), igrid, iret
51 integer :: kgds72(200), kgds71(200), idum(200), jdum(200)
56 if (igds(5) .eq. 0)
then
60 kgds(4) = igdstmpl(12) / 1000
61 kgds(5) = igdstmpl(13) / 1000
63 if (igdstmpl(1) == 2) kgds(6) = 64
64 if (btest(igdstmpl(14), 4).OR.btest(igdstmpl(14), 5)) kgds(6) = kgds(6) + 128
65 if (btest(igdstmpl(14), 3)) kgds(6) = kgds(6) + 8
66 kgds(7) = igdstmpl(15) / 1000
67 kgds(8) = igdstmpl(16) / 1000
68 kgds(9) = igdstmpl(17) / 1000
69 kgds(10) = igdstmpl(18) / 1000
70 kgds(11) = igdstmpl(19)
85 if (idefnum.ne.0)
then
86 if (igdstmpl(8) .eq. -1)
then
90 if (igdstmpl(9) .eq. -1)
then
96 if (kgds(1) .eq. 1.OR.kgds(1) .eq. 3) kgds(20) = 43
99 kgds(21 + j) = ideflist(j)
102 elseif (igds(5) .eq. 10)
then
104 kgds(2) = igdstmpl(8)
105 kgds(3) = igdstmpl(9)
106 kgds(4) = igdstmpl(10) / 1000
107 kgds(5) = igdstmpl(11) / 1000
109 if (igdstmpl(1)==2) kgds(6) = 64
110 if (btest(igdstmpl(12), 4).OR.btest(igdstmpl(12), 5)) kgds(6) = kgds(6) + 128
111 if (btest(igdstmpl(12), 3)) kgds(6) = kgds(6) + 8
112 kgds(7) = igdstmpl(14) / 1000
113 kgds(8) = igdstmpl(15) / 1000
114 kgds(9) = igdstmpl(13) / 1000
116 kgds(11) = igdstmpl(16)
117 kgds(12) = igdstmpl(18) / 1000
118 kgds(13) = igdstmpl(19) / 1000
128 elseif (igds(5) .eq. 30)
then
130 kgds(2) = igdstmpl(8)
131 kgds(3) = igdstmpl(9)
132 kgds(4) = igdstmpl(10) / 1000
133 kgds(5) = igdstmpl(11) / 1000
135 if (igdstmpl(1)==2) kgds(6) = 64
136 if (btest(igdstmpl(12), 4).OR.btest(igdstmpl(12), 5)) kgds(6) = kgds(6) + 128
137 if (btest(igdstmpl(12), 3)) kgds(6) = kgds(6) + 8
138 kgds(7) = igdstmpl(14) / 1000
139 kgds(8) = igdstmpl(15) / 1000
140 kgds(9) = igdstmpl(16) / 1000
141 kgds(10) = igdstmpl(17)
142 kgds(11) = igdstmpl(18)
143 kgds(12) = igdstmpl(19) / 1000
144 kgds(13) = igdstmpl(20) / 1000
145 kgds(14) = igdstmpl(21) / 1000
146 kgds(15) = igdstmpl(22) / 1000
154 elseif (igds(5) .eq. 40)
then
156 kgds(2) = igdstmpl(8)
157 kgds(3) = igdstmpl(9)
158 kgds(4) = igdstmpl(12) / 1000
159 kgds(5) = igdstmpl(13) / 1000
161 if (igdstmpl(1)==2) kgds(6) = 64
162 if (btest(igdstmpl(14), 4).OR.btest(igdstmpl(14), 5)) kgds(6) = kgds(6) + 128
163 if (btest(igdstmpl(14), 3)) kgds(6) = kgds(6) + 8
164 kgds(7) = igdstmpl(15) / 1000
165 kgds(8) = igdstmpl(16) / 1000
166 kgds(9) = igdstmpl(17) / 1000
167 kgds(10) = igdstmpl(18)
168 kgds(11) = igdstmpl(19)
180 elseif (igds(5) .eq. 20)
then
182 kgds(2) = igdstmpl(8)
183 kgds(3) = igdstmpl(9)
184 kgds(4) = igdstmpl(10) / 1000
185 kgds(5) = igdstmpl(11) / 1000
187 if (igdstmpl(1)==2) kgds(6) = 64
188 if (btest(igdstmpl(12), 4).OR.btest(igdstmpl(12), 5)) kgds(6) = kgds(6) + 128
189 if (btest(igdstmpl(12), 3)) kgds(6) = kgds(6) + 8
190 kgds(7) = igdstmpl(14) / 1000
191 kgds(8) = igdstmpl(15) / 1000
192 kgds(9) = igdstmpl(16) / 1000
193 kgds(10) = igdstmpl(17)
194 kgds(11) = igdstmpl(18)
206 elseif (igds(5) .eq. 204)
then
208 kgds(2) = igdstmpl(8)
209 kgds(3) = igdstmpl(9)
213 if (igdstmpl(1)==2) kgds(6) = 64
214 if (btest(igdstmpl(14), 4).OR.btest(igdstmpl(14), 5)) kgds(6) = kgds(6) + 128
215 if (btest(igdstmpl(14), 3)) kgds(6) = kgds(6) + 8
220 kgds(11) = igdstmpl(19)
235 if (idefnum.ne.0)
then
236 if (igdstmpl(8) .eq. -1)
then
240 if (igdstmpl(9) .eq. -1)
then
246 if (kgds(1) .eq. 1.OR.kgds(1) .eq. 3) kgds(20) = 43
249 kgds(21 + j) = ideflist(j)
252 elseif (igds(5) .eq. 32768)
then
254 kgds(2) = igdstmpl(8)
255 kgds(3) = igdstmpl(9)
256 kgds(4) = igdstmpl(12) / 1000
257 kgds(5) = igdstmpl(13) / 1000
259 if (igdstmpl(1)==2) kgds(6) = 64
260 if (btest(igdstmpl(14), 4).OR.btest(igdstmpl(14), 5)) kgds(6) = kgds(6) + 128
261 if (btest(igdstmpl(14), 3)) kgds(6) = kgds(6) + 8
262 kgds(7) = igdstmpl(15) / 1000
263 kgds(8) = igdstmpl(16) / 1000
264 kgds(9) = igdstmpl(17) / 1000
265 kgds(10) = igdstmpl(18) / 1000
266 kgds(11) = igdstmpl(19)
281 if (idefnum.ne.0)
then
282 if (igdstmpl(8) .eq. -1)
then
286 if (igdstmpl(9) .eq. -1)
then
292 if (kgds(1) .eq. 1.OR.kgds(1) .eq. 3) kgds(20) = 43
295 kgds(21 + j) = ideflist(j)
298 elseif (igds(5) .eq. 32769)
then
300 kgds(2) = igdstmpl(8)
301 kgds(3) = igdstmpl(9)
302 kgds(4) = igdstmpl(12) / 1000
303 kgds(5) = igdstmpl(13) / 1000
305 if (igdstmpl(1)==2) kgds(6) = 64
306 if (btest(igdstmpl(14), 4).OR.btest(igdstmpl(14), 5)) kgds(6) = kgds(6) + 128
307 if (btest(igdstmpl(14), 3)) kgds(6) = kgds(6) + 8
308 kgds(7) = igdstmpl(15) / 1000
309 kgds(8) = igdstmpl(16) / 1000
310 kgds(9) = igdstmpl(17) / 1000
311 kgds(10) = igdstmpl(18) / 1000
312 kgds(11) = igdstmpl(19)
313 kgds(12) = igdstmpl(20) / 1000
314 kgds(13) = igdstmpl(21) / 1000
325 print *,
'gdt2gds: Unrecognized GRIB2 GDT = 3.', igds(5)
338 call w3fi71(j, kgds71, ierr)
341 if (kgds71(3) .eq. 0)
then
342 if (kgds71(7) .lt. 0) kgds71(7) = 360000 + kgds71(7)
343 if (kgds71(10) .lt. 0) kgds71(10) = 360000 + kgds71(10)
344 elseif (kgds71(3) .eq. 1)
then
345 if (kgds71(7) .lt. 0) kgds71(7) = 360000 + kgds71(7)
346 if (kgds71(10) .lt. 0) kgds71(10) = 360000 + kgds71(10)
347 elseif (kgds71(3) .eq. 3)
then
348 if (kgds71(7) .lt. 0) kgds71(7) = 360000 + kgds71(7)
349 if (kgds71(9) .lt. 0) kgds71(9) = 360000 + kgds71(9)
350 if (kgds71(18) .lt. 0) kgds71(18) = 360000 + kgds71(18)
351 elseif (kgds71(3) .eq. 4)
then
352 if (kgds71(7) .lt. 0) kgds71(7) = 360000 + kgds71(7)
353 if (kgds71(10) .lt. 0) kgds71(10) = 360000 + kgds71(10)
354 elseif (kgds71(3) .eq. 5)
then
355 if (kgds71(7) .lt. 0) kgds71(7) = 360000 + kgds71(7)
356 if (kgds71(9) .lt. 0) kgds71(9) = 360000 + kgds71(9)
358 call r63w72(idum, kgds, jdum, kgds72)
359 if (kgds72(3) .eq. 3) kgds72(14) = 0
360 if (kgds72(3) .eq. 1) kgds72(15:18) = 0
361 if (kgds72(3) .eq. 5) kgds72(14:18) = 0
364 if (all(kgds71 .eq. kgds72) )
then
subroutine gdt2gds(igds, igdstmpl, idefnum, ideflist, kgds, igrid, iret)
Convert grid information from a GRIB2 Grid Description Section as well as its Grid Definition Templat...