NCEPLIBS-g2  3.5.0
gridtemplates.F90
Go to the documentation of this file.
1 
6 
41 
42  integer, parameter :: maxlen = 200
43  integer, parameter :: maxtemp = 31
44 
46  integer :: template_num
47  integer :: mapgridlen
48  integer, dimension(MAXLEN) :: mapgrid
49  logical :: needext
50  end type gridtemplate
51 
52  type(gridtemplate), dimension(MAXTEMP) :: templates
53 
54  data templates(1)%template_num /0/ ! Lat/Lon
55  data templates(1)%mapgridlen /19/
56  data templates(1)%needext /.false./
57  data (templates(1)%mapgrid(j), j = 1, 19) &
58  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1/
59 
60  data templates(2)%template_num /1/ ! Rotated Lat/Lon
61  data templates(2)%mapgridlen /22/
62  data templates(2)%needext /.false./
63  data (templates(2)%mapgrid(j), j = 1, 22) &
64  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, 4/
65 
66  data templates(3)%template_num /2/ ! Stretched Lat/Lon
67  data templates(3)%mapgridlen /22/
68  data templates(3)%needext /.false./
69  data (templates(3)%mapgrid(j), j = 1, 22) &
70  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, -4/
71 
72  data templates(4)%template_num /3/ ! Stretch and Rotated Lat/Lon
73  data templates(4)%mapgridlen /25/
74  data templates(4)%needext /.false./
75  data (templates(4)%mapgrid(j), j = 1, 25) &
76  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, 4, -4, 4, -4/
77 
78  data templates(5)%template_num /10/ ! Mercator
79  data templates(5)%mapgridlen /19/
80  data templates(5)%needext /.false./
81  data (templates(5)%mapgrid(j), j = 1, 19) &
82  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, -4, 4, 1, 4, 4, 4/
83 
84  data templates(6)%template_num /20/ ! Polar Stereographic
85  data templates(6)%mapgridlen /18/
86  data templates(6)%needext /.false./
87  data (templates(6)%mapgrid(j), j = 1, 18) &
88  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 1/
89 
90  data templates(7)%template_num /30/ ! Lambert Conformal
91  data templates(7)%mapgridlen /22/
92  data templates(7)%needext /.false./
93  data (templates(7)%mapgrid(j), j = 1, 22) &
94  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 1, -4, -4, -4, 4/
95 
96  data templates(8)%template_num /40/ ! Gaussian Lat/Lon
97  data templates(8)%mapgridlen /19/
98  data templates(8)%needext /.false./
99  data (templates(8)%mapgrid(j), j = 1, 19) &
100  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1/
101 
102  data templates(9)%template_num /41/ ! Rotated Gaussian Lat/Lon
103  data templates(9)%mapgridlen /22/
104  data templates(9)%needext /.false./
105  data (templates(9)%mapgrid(j), j = 1, 22) &
106  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, 4/
107 
108  data templates(10)%template_num /42/ ! Stretched Gaussian Lat/Lon
109  data templates(10)%mapgridlen /22/
110  data templates(10)%needext /.false./
111  data (templates(10)%mapgrid(j), j = 1, 22) &
112  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, -4/
113 
114  data templates(11)%template_num /43/ ! Strtchd and Rot'd Gaus Lat/Lon
115  data templates(11)%mapgridlen /25/
116  data templates(11)%needext /.false./
117  data (templates(11)%mapgrid(j), j = 1, 25) &
118  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, 4, -4, 4, -4/
119 
120  data templates(12)%template_num /50/ ! Spherical Harmonic Coefficients
121  data templates(12)%mapgridlen /5/
122  data templates(12)%needext /.false./
123  data (templates(12)%mapgrid(j), j = 1, 5) /4, 4, 4, 1, 1/
124 
125  data templates(13)%template_num /51/ ! Rotated Spherical Harmonic Coeff
126  data templates(13)%mapgridlen /8/
127  data templates(13)%needext /.false./
128  data (templates(13)%mapgrid(j), j = 1, 8) /4, 4, 4, 1, 1, -4, 4, 4/
129 
130  data templates(14)%template_num /52/ ! Stretch Spherical Harmonic Coeff
131  data templates(14)%mapgridlen /8/
132  data templates(14)%needext /.false./
133  data (templates(14)%mapgrid(j), j = 1, 8) /4, 4, 4, 1, 1, -4, 4, -4/
134 
135  data templates(15)%template_num /53/ ! Strch and Rot Spher Harm Coeffs
136  data templates(15)%mapgridlen /11/
137  data templates(15)%needext /.false./
138  data (templates(15)%mapgrid(j), j = 1, 11) /4, 4, 4, 1, 1, -4, 4, 4, -4, 4, -4/
139 
140  data templates(16)%template_num /90/ ! Space view Perspective
141  data templates(16)%mapgridlen /21/
142  data templates(16)%needext /.false./
143  data (templates(16)%mapgrid(j), j = 1, 21) &
144  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, 4, 4, 4, 4, 1, 4, 4, 4, 4/
145 
146  data templates(17)%template_num /100/ ! Triangular grid (icosahedron)
147  data templates(17)%mapgridlen /11/
148  data templates(17)%needext /.false./
149  data (templates(17)%mapgrid(j), j = 1, 11) /1, 1, 2, 1, -4, 4, 4, 1, 1, 1, 4/
150 
151  data templates(18)%template_num /110/ ! Equatorial Azimuthal equidistant
152  data templates(18)%mapgridlen /16/
153  data templates(18)%needext /.false./
154  data (templates(18)%mapgrid(j), j = 1, 16) &
155  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, 4, 4, 1, 1/
156 
157  data templates(19)%template_num /120/ ! Azimuth-range
158  data templates(19)%mapgridlen /7/
159  data templates(19)%needext /.true./
160  data (templates(19)%mapgrid(j), j = 1, 7) /4, 4, -4, 4, 4, 4, 1/
161 
162  data templates(20)%template_num /1000/ ! Cross Section Grid
163  data templates(20)%mapgridlen /20/
164  data templates(20)%needext /.true./
165  data (templates(20)%mapgrid(j), j = 1, 20) &
166  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, 4, 4, 1, 2, 1, 1, 2/
167 
168  data templates(21)%template_num /1100/ ! Hovmoller Diagram Grid
169  data templates(21)%mapgridlen /28/
170  data templates(21)%needext /.false./
171  data (templates(21)%mapgrid(j), j = 1, 28) &
172  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, -4, 4, 1, 4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1/
173 
174  data templates(22)%template_num /1200/ ! Time Section Grid
175  data templates(22)%mapgridlen /16/
176  data templates(22)%needext /.true./
177  data (templates(22)%mapgrid(j), j = 1, 16) &
178  /4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2/
179 
180  data templates(23)%template_num /31/ ! Albers Equal Area
181  data templates(23)%mapgridlen /22/
182  data templates(23)%needext /.false./
183  data (templates(23)%mapgrid(j), j = 1, 22) &
184  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 1, -4, -4, -4, 4/
185 
186  data templates(24)%template_num /204/ ! Curilinear Orthogonal Grids
187  data templates(24)%mapgridlen /19/
188  data templates(24)%needext /.false./
189  data (templates(24)%mapgrid(j), j = 1, 19) &
190  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1/
191 
192  data templates(25)%template_num /32768/ ! Rotate Lat/Lon E-grid
193  data templates(25)%mapgridlen /19/
194  data templates(25)%needext /.false./
195  data (templates(25)%mapgrid(j), j = 1, 19) &
196  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1/
197 
198  data templates(26)%template_num /32769/ ! Rotate Lat/Lon Non-E Stagger grid
199  data templates(26)%mapgridlen /21/
200  data templates(26)%needext /.false./
201  data (templates(26)%mapgrid(j), j = 1, 21) &
202  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 4, 4/
203  !
204  ! GDT 3.4 Added (08/05/2013)
205  !
206  data templates(27)%template_num /4/ ! Variable resolution Latitude/Longitude
207  data templates(27)%mapgridlen /13/
208  data templates(27)%needext /.true./
209  data (templates(27)%mapgrid(j), j = 1, 13) &
210  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, 1, 1/
211  !
212  ! GDT 3.5 Added (08/05/2013)
213  !
214  data templates(28)%template_num /5/ ! Variable resolution rotate Latitude/Longitude
215  data templates(28)%mapgridlen /16/
216  data templates(28)%needext /.true./
217  data (templates(28)%mapgrid(j), j = 1, 16) &
218  /1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, 1, 1, -4, 4, 4/
219  !
220  ! GDT 3.12 Added (08/05/2013)
221  !
222  data templates(29)%template_num /12/ ! Transverse Mercator
223  data templates(29)%mapgridlen /22/
224  data templates(29)%needext /.false./
225  data (templates(29)%mapgrid(j), j = 1, 22) &
226  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, 4, 4, 1, 4, 4, -4, -4, -4, -4/
227  !
228  ! GDT 3.101 Added (08/05/2013)
229  !
230  data templates(30)%template_num /101/ ! General unstructured grid
231  data templates(30)%mapgridlen /4/
232  data templates(30)%needext /.false./
233  data (templates(30)%mapgrid(j), j = 1, 4) &
234  /1, 4, 1, -4/
235  !
236  ! GDT 3.140 Added (08/05/2013)
237  !
238  data templates(31)%template_num /140/ ! Lambert Azimuthal Equal Area Projection
239  data templates(31)%mapgridlen /17/
240  data templates(31)%needext /.false./
241  data (templates(31)%mapgrid(j), j = 1, 17) &
242  /1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 4, 4, 1, 4, 4, 1/
243 
244 contains
245 
255  integer function getgridindex(number)
256  implicit none
257  integer, intent(in) :: number
258  integer :: j
259 
260  getgridindex = -1
261 
262  do j = 1, maxtemp
263  if (number.eq.templates(j)%template_num) then
264  getgridindex = j
265  return
266  endif
267  enddo
268 
269  end function getgridindex
270 
291  subroutine getgridtemplate(number, nummap, map, needext, iret)
292  implicit none
293 
294  integer, intent(in) :: number
295  integer, intent(out) :: nummap, map(*), iret
296  logical, intent(out) :: needext
297  integer :: index
298 
299  iret = 0
300 
301  index = getgridindex(number)
302 
303  if (index.ne.-1) then
304  nummap = templates(index)%mapgridlen
305  needext = templates(index)%needext
306  map(1:nummap) = templates(index)%mapgrid(1:nummap)
307  else
308  nummap = 0
309  needext = .false.
310  print *, 'getgridtemplate: Grid Template ', number, ' not defined.'
311  iret = 1
312  endif
313  end subroutine getgridtemplate
314 
332  subroutine extgridtemplate(number, list, nummap, map)
333  implicit none
334 
335  integer, intent(in) :: number, list(*)
336  integer, intent(out) :: nummap, map(*)
337  integer i, index, n, ni, nj
338 
339  index = getgridindex(number)
340  if (index.eq.-1) return
341 
342  if (.not. templates(index)%needext) return
343  nummap = templates(index)%mapgridlen
344  map(1:nummap) = templates(index)%mapgrid(1:nummap)
345 
346  if (number.eq.120) then
347  n = list(2)
348  do i = 1, n
349  map(nummap + 1) = 2
350  map(nummap + 2) = -2
351  nummap = nummap + 2
352  enddo
353  elseif (number.eq.4) then
354  ni = list(8)
355  do i = 1, ni
356  map(nummap + 1) = 4
357  nummap = nummap + 1
358  enddo
359  nj = list(9)
360  do i = 1, nj
361  map(nummap + 1) = -4
362  nummap = nummap + 1
363  enddo
364  elseif (number.eq.5) then
365  ni = list(8)
366  do i = 1, ni
367  map(nummap + 1) = 4
368  nummap = nummap + 1
369  enddo
370  nj = list(9)
371  do i = 1, nj
372  map(nummap + 1) = -4
373  nummap = nummap + 1
374  enddo
375  elseif (number.eq.1000) then
376  n = list(20)
377  do i = 1, n
378  map(nummap + 1) = 4
379  nummap = nummap + 1
380  enddo
381  elseif (number.eq.1200 ) then
382  n = list(16)
383  do i = 1, n
384  map(nummap + 1) = 4
385  nummap = nummap + 1
386  enddo
387  endif
388  end subroutine extgridtemplate
389 
400  integer function getgdtlen(number)
401  implicit none
402 
403  integer, intent(in) :: number
404  integer :: index
405 
406  getgdtlen = 0
407 
408  index = getgridindex(number)
409 
410  if (index .ne. -1) then
411  getgdtlen = templates(index)%mapgridlen
412  endif
413  end function getgdtlen
414 end module gridtemplates
This Fortran module contains info on all the available GRIB2 Grid Definition Templates used in [Secti...
subroutine getgridtemplate(number, nummap, map, needext, iret)
Get the grid template information for a specified Grid Definition Template.
integer, parameter maxtemp
maximum number of entries in the template
integer, parameter maxlen
maximum number of octets in mapgrid
integer function getgdtlen(number)
This function returns the initial length (number of entries) in the static part of specified Grid Def...
subroutine extgridtemplate(number, list, nummap, map)
Generate the remaining octet map for a given Grid Definition Template, if required.
integer function getgridindex(number)
Return the index of specified Grid Definition Template.
type(gridtemplate), dimension(maxtemp) templates
a gridtemplate type