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