NCEPLIBS-ip 5.3.0
All Data Structures Namespaces Files Functions Variables Pages
ipolates.F90
Go to the documentation of this file.
1!> @file
2!! @brief Top-level driver for scalar interpolation routine ipolates().
3!! @author Mark Iredell, Kyle Gerheiser
4
5!> @brief Top-level driver for scalar interpolation interpolation
6!! routine ipolates().
7!!
8!! ipolates() is overloaded with interfaces for GRIB1 and GRIB2
9!! descriptors.
10!!
11!! @author George Gayno, Mark Iredell, Kyle Gerheiser
17 use ip_grid_mod
18 implicit none
19
20 private
22
23 interface ipolates
24 module procedure ipolates_grib1
25 module procedure ipolates_grib1_single_field
26 module procedure ipolates_grib2
27 module procedure ipolates_grib2_single_field
28 end interface ipolates
29
30contains
31
32 !> Interpolates scalar fields between grids given ip_grid objects.
33 !!
34 !! Calls the specific interpolation routines on the generic ip_grids
35 !! created from a grib1/grib2 descriptor.
36 !!
37 !! @param[in] ip Interpolation method.
38 !! @param[in] ipopt Interpolation options.
39 !! @param[in] grid_in Input grid.
40 !! @param[in] grid_out Output grid object created.
41 !! @param[in] mi Skip number between input grid fields if km>1 or dimension of input grid fields if km=1.
42 !! @param[in] mo Skip number between output grid fields if km>1 or dimension of output grid fields if km=1.
43 !! @param[in] km Number of fields to interpolate.
44 !! @param[in] ibi Input bitmap flags.
45 !! @param[in] li Input bitmaps (if respective ibi(k)=1).
46 !! @param[in] gi Input fields to interpolate.
47 !! @param[out] no Number of output points (only if kgdso(1)<0).
48 !! @param[out] rlat Output latitudes in degrees (if kgdso(1)<0).
49 !! @param[out] rlon Output longitudes in degrees (if kgdso(1)<0).
50 !! @param[out] ibo Output bitmap flags.
51 !! @param[out] lo Output bitmaps (always output).
52 !! @param[out] go Output fields interpolated.
53 !! @param[out] iret Return code.
54 !! - 0 Successful interpolation.
55 !! - 1 Unrecognized interpolation method.
56 !! - 2 Unrecognized input grid or no grid overlap.
57 !! - 3 Unrecognized output grid.
58 !! - 1x Invalid bicubic method parameters.
59 !! - 3x Invalid budget method parameters.
60 !! - 4x Invalid spectral method parameters.
61 !!
62 !! @author Mark Iredell, Kyle Gerheiser
63 subroutine ipolates_grid(ip, ipopt, grid_in, grid_out, mi, mo, km,&
64 & ibi, li, gi, no, rlat, rlon, ibo, lo, go, iret)
65 class(ip_grid), intent(in) :: grid_in, grid_out
66 INTEGER, INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
67 INTEGER, INTENT(IN ) :: IBI(KM)
68 INTEGER, INTENT(INOUT) :: NO
69 INTEGER, INTENT( OUT) :: IRET, IBO(KM)
70 !
71 LOGICAL*1, INTENT(IN ) :: LI(MI,KM)
72 LOGICAL*1, INTENT( OUT) :: LO(MO,KM)
73 !
74 REAL, INTENT(IN ) :: GI(MI,KM)
75 REAL, INTENT(INOUT) :: RLAT(MO),RLON(MO)
76 REAL, INTENT( OUT) :: GO(MO,KM)
77 !
78
79 select case(ip)
81 CALL interpolate_bilinear(ipopt,grid_in,grid_out,mi,mo,km,ibi&
82 &,li,gi,no,rlat,rlon,ibo,lo,go,iret)
84 CALL interpolate_bicubic(ipopt,grid_in,grid_out,mi,mo,km,ibi&
85 &,li,gi,no,rlat,rlon,ibo,lo,go,iret)
87 CALL interpolate_neighbor(ipopt,grid_in,grid_out,mi,mo,km,ibi&
88 &,li,gi,no,rlat,rlon,ibo,lo,go,iret)
90 CALL interpolate_budget(ipopt,grid_in,grid_out,mi,mo,km,ibi,li&
91 &,gi,no,rlat,rlon,ibo,lo,go,iret)
93 CALL interpolate_spectral(ipopt,grid_in,grid_out,mi,mo,km,ibi&
94 &,gi,no,rlat,rlon,ibo,lo,go,iret)
96 CALL interpolate_neighbor_budget(ipopt,grid_in,grid_out,mi,mo&
97 &,km,ibi,li,gi,no,rlat,rlon,ibo,lo,go,iret)
98 case default
99 ! IF(KGDSO(1).GE.0) NO=0
100 ! DO K=1,KM
101 ! IBO(K)=1
102 ! DO N=1,NO
103 ! LO(N,K)=.FALSE.
104 ! GO(N,K)=0.
105 ! ENDDO
106 ! ENDDO
107 iret=1
108 print *, "Unrecognized interp option: ", ip
109 error stop
110 end select
111
112 end subroutine ipolates_grid
113
114 !> Special case of ipolates_grib1 when interpolating a single field.
115 !! Removes the km dimension of input arrays so scalars can be passed to ibi/ibo.
116 !!
117 !! @param ip Interpolation method
118 !! - ip = BILINEAR_INTERP_ID = 0 for bilinear
119 !! - ip = BICUBIC_INTERP_ID = 1 for bicubic
120 !! - ip = NEIGHBOR_INTERP_ID = 2 for neighbor;
121 !! - ip = BUDGET_INTERP_ID = 3 for budget;
122 !! - ip = SPECTRAL_INTERP_ID = 4 for spectral;
123 !! - ip = NEIGHBOR_BUDGET_INTERP_ID = 6 for neighbor-budget
124 !!
125 !! @param ipopt Interpolation options
126 !! - ip=0 (bilinear): (No options)
127 !! - ip=1 Cbicubic): constraint option
128 !! - ip=2 (neighbor): (No options)
129 !! - ip=3 (budget): Number in radius, radius weights, search radius
130 !! - ip=4 (spectral): Spectral shape, spectral truncation
131 !! - ip=6 (neighbor-budget): Number in radius, radius weights ...)
132 !!
133 !! @param[in] kgdsi Input gds parameters as decoded by w3fi63.
134 !! @param[in] kgdso Output gds parameters.
135 !! @param[in] mi Skip number between input grid fields if km>1 or dimension of input grid fields if km=1.
136 !! @param[in] mo Skip number between output grid fields if km>1 or dimension of output grid fields if km=1.
137 !! @param[in] km Number of fields to interpolate.
138 !! @param[in] ibi Input bitmap flags.
139 !! @param[in] li Input bitmaps (if respective ibi(k)=1).
140 !! @param[in] gi Input fields to interpolate.
141 !! @param[out] no Number of output points (only if kgdso(1)<0).
142 !! @param[out] rlat Output latitudes in degrees (if kgdso(1)<0).
143 !! @param[out] rlon Output longitudes in degrees (if kgdso(1)<0).
144 !! @param[out] ibo Output bitmap flags.
145 !! @param[out] lo Output bitmaps (always output).
146 !! @param[out] go Output fields interpolated.
147 !! @param[out] iret Return code.
148 !! - 0 Successful interpolation.
149 !! - 1 Unrecognized interpolation method.
150 !! - 2 Unrecognized input grid or no grid overlap.
151 !! - 3 Unrecognized output grid.
152 !! - 1x Invalid bicubic method parameters.
153 !! - 3x Invalid budget method parameters.
154 !! - 4x Invalid spectral method parameters.
155 !!
156 !! @date Jan 2022
157 !! @author Kyle Gerheiser
158 subroutine ipolates_grib1_single_field(ip,ipopt,kgdsi,kgdso,mi,mo,km,ibi,li,gi, &
159 no,rlat,rlon,ibo,lo,go,iret) bind(c)
160 !
161 USE iso_c_binding, ONLY: c_int, c_float, c_double, c_bool, c_long
162#if (LSIZE==8)
163 INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
164 INTEGER(C_LONG), INTENT(IN ) :: IBI, KGDSI(200), KGDSO(200)
165 INTEGER(C_LONG), INTENT(INOUT) :: NO
166 INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO
167#else
168 INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
169 INTEGER(C_INT), INTENT(IN ) :: IBI, KGDSI(200), KGDSO(200)
170 INTEGER(C_INT), INTENT(INOUT) :: NO
171 INTEGER(C_INT), INTENT( OUT) :: IRET, IBO
172#endif
173 !
174 LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI)
175 LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO)
176 !
177#if (LSIZE==4)
178 REAL(C_FLOAT), INTENT(IN ) :: GI(MI)
179 REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO)
180 REAL(C_FLOAT), INTENT( OUT) :: GO(MO)
181#else
182 REAL(C_DOUBLE), INTENT(IN ) :: GI(MI)
183 REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO)
184 REAL(C_DOUBLE), INTENT( OUT) :: GO(MO)
185#endif
186 !
187
188 type(grib1_descriptor) :: desc_in, desc_out
189 class(ip_grid), allocatable :: grid_in, grid_out
190 integer :: ibo_array(1)
191
192 desc_in = init_descriptor(kgdsi)
193 desc_out = init_descriptor(kgdso)
194
195 call init_grid(grid_in, desc_in)
196 call init_grid(grid_out, desc_out)
197
198 ! Can't pass expression (e.g. [ibo]) to intent(out) argument.
199 ! Initialize placeholder array of size 1 to make rank match.
200 ibo_array(1) = ibo
201
202 call ipolates_grid(ip, ipopt, grid_in, grid_out, mi, mo, km, [ibi], li, gi, no, rlat, rlon, ibo_array, lo, go, iret)
203
204 ibo = ibo_array(1)
205
206 END SUBROUTINE ipolates_grib1_single_field
207
208 !> This subprogram interpolates scalar field from any grid
209 !! to any grid given a grib1 Grid Descriptor Section.
210 !!
211 !! Only horizontal interpolation is performed.
212 !! The following interpolation methods are possible:
213 !! - (ip=0) bilinear
214 !! - (ip=1) bicubic
215 !! - (ip=2) neighbor
216 !! - (ip=3) budget
217 !! - (ip=4) spectral
218 !! - (ip=6) neighbor-budget
219 !!
220 !! Some of these methods have interpolation options and/or
221 !! restrictions on the input or output grids, both of which
222 !! are documented more fully in their respective subprograms.
223 !!
224 !! The grids are defined by their grid description sections
225 !! (passed in integer form as decoded by subprogram w3fi63).
226 !!
227 !! The current code recognizes the following projections:
228 !! - (kgds(1)=000) equidistant cylindrical
229 !! - (kgds(1)=001) mercator cylindrical
230 !! - (kgds(1)=003) lambert conformal conical
231 !! - (kgds(1)=004) gaussian cylindrical
232 !! - (kgds(1)=005) polar stereographic azimuthal
233 !! - (kgds(1)=203) rotated equidistant cylindrical - e-stagger
234 !! - (kgds(1)=205) rotated equidistant cylindrical - b-stagger
235 !!
236 !! Where kgds could be either input kgdsi or output kgdso.
237 !!
238 !! As an added bonus the number of output grid points
239 !! and their latitudes and longitudes are also returned.
240 !!
241 !! On the other hand, the output can be a set of station points
242 !! if kgdso(1)<0, in which case the number of points
243 !! and their latitudes and longitudes must be input.
244 !! for the budget approach, a subsection of the grid may
245 !! be output by subtracting kgdso(1) from 255 and passing
246 !! in the latitudes and longitudes of the points.
247 !! Input bitmaps will be interpolated to output bitmaps.
248 !!
249 !! Output bitmaps will also be created when the output grid
250 !! extends outside of the domain of the input grid.
251 !! the output field is set to 0 where the output bitmap is off.
252 !!
253 !! @param ip Interpolation method
254 !! - ip = BILINEAR_INTERP_ID = 0 for bilinear
255 !! - ip = BICUBIC_INTERP_ID = 1 for bicubic
256 !! - ip = NEIGHBOR_INTERP_ID = 2 for neighbor;
257 !! - ip = BUDGET_INTERP_ID = 3 for budget;
258 !! - ip = SPECTRAL_INTERP_ID = 4 for spectral;
259 !! - ip = NEIGHBOR_BUDGET_INTERP_ID = 6 for neighbor-budget
260 !!
261 !! @param ipopt Interpolation options
262 !! - ip=0 (bilinear): (No options)
263 !! - ip=1 Cbicubic): constraint option
264 !! - ip=2 (neighbor): (No options)
265 !! - ip=3 (budget): Number in radius, radius weights, search radius
266 !! - ip=4 (spectral): Spectral shape, spectral truncation
267 !! - ip=6 (neighbor-budget): Number in radius, radius weights ...)
268 !!
269 !! @param[in] kgdsi Input gds parameters as decoded by w3fi63.
270 !! @param[in] kgdso Output gds parameters.
271 !! @param[in] mi Skip number between input grid fields if km>1 or dimension of input grid fields if km=1.
272 !! @param[in] mo Skip number between output grid fields if km>1 or dimension of output grid fields if km=1.
273 !! @param[in] km Number of fields to interpolate.
274 !! @param[in] ibi Input bitmap flags.
275 !! @param[in] li Input bitmaps (if respective ibi(k)=1).
276 !! @param[in] gi Input fields to interpolate.
277 !! @param[out] no Number of output points (only if kgdso(1)<0).
278 !! @param[out] rlat Output latitudes in degrees (if kgdso(1)<0).
279 !! @param[out] rlon Output longitudes in degrees (if kgdso(1)<0).
280 !! @param[out] ibo Output bitmap flags.
281 !! @param[out] lo Output bitmaps (always output).
282 !! @param[out] go Output fields interpolated.
283 !! @param[out] iret Return code.
284 !! - 0 Successful interpolation.
285 !! - 1 Unrecognized interpolation method.
286 !! - 2 Unrecognized input grid or no grid overlap.
287 !! - 3 Unrecognized output grid.
288 !! - 1x Invalid bicubic method parameters.
289 !! - 3x Invalid budget method parameters.
290 !! - 4x Invalid spectral method parameters.
291 !!
292 !! @author Mark Iredell, Kyle Gerheiser
293 subroutine ipolates_grib1(ip,ipopt,kgdsi,kgdso,mi,mo,km,ibi,li,gi, &
294 no,rlat,rlon,ibo,lo,go,iret) bind(c)
295 !
296 USE iso_c_binding, ONLY: c_int, c_float, c_double, c_bool, c_long
297#if (LSIZE==8)
298 INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
299 INTEGER(C_LONG), INTENT(IN ) :: IBI(KM), KGDSI(200), KGDSO(200)
300 INTEGER(C_LONG), INTENT(INOUT) :: NO
301 INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO(KM)
302#else
303 INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
304 INTEGER(C_INT), INTENT(IN ) :: IBI(KM), KGDSI(200), KGDSO(200)
305 INTEGER(C_INT), INTENT(INOUT) :: NO
306 INTEGER(C_INT), INTENT( OUT) :: IRET, IBO(KM)
307#endif
308 !
309 LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI,KM)
310 LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO,KM)
311 !
312#if (LSIZE==4)
313 REAL(C_FLOAT), INTENT(IN ) :: GI(MI,KM)
314 REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO)
315 REAL(C_FLOAT), INTENT( OUT) :: GO(MO,KM)
316#else
317 REAL(C_DOUBLE), INTENT(IN ) :: GI(MI,KM)
318 REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO)
319 REAL(C_DOUBLE), INTENT( OUT) :: GO(MO,KM)
320#endif
321 !
322
323 type(grib1_descriptor) :: desc_in, desc_out
324 class(ip_grid), allocatable :: grid_in, grid_out
325
326 desc_in = init_descriptor(kgdsi)
327 desc_out = init_descriptor(kgdso)
328
329 call init_grid(grid_in, desc_in)
330 call init_grid(grid_out, desc_out)
331
332 call ipolates_grid(ip, ipopt, grid_in, grid_out, mi, mo, km, ibi, li, gi, no, rlat, rlon, ibo, lo, go, iret)
333
334 END SUBROUTINE ipolates_grib1
335
336 !> This subprogram interpolates scalar field from any grid to any
337 !! grid given a grib2 descriptor.
338 !!
339 !! Wrapper for ipolates_grid which converts a grib1 descriptor into
340 !! an ip_grid_descriptor, which is used to create an ip_grid. Only
341 !! horizontal interpolation is performed.
342 !!
343 !! The following interpolation methods are possible:
344 !! - (ip=0) bilinear
345 !! - (ip=1) bicubic
346 !! - (ip=2) neighbor
347 !! - (ip=3) budget
348 !! - (ip=4) spectral
349 !! - (ip=6) neighbor-budget
350 !!
351 !! Some of these methods have interpolation options and/or
352 !! restrictions on the input or output grids, both of which
353 !! are documented more fully in their respective subprograms.
354 !!
355 !! Input and output grids are defined by their grib 2 grid
356 !! definition template as decoded by the ncep g2 library. The
357 !! current code recognizes the following projections, where
358 !! "igdtnumi/o" is the grib 2 grid defintion template number
359 !! for the input and output grids, respectively:
360 !! - (igdtnumi/o=00) equidistant cylindrical
361 !! - (igdtnumi/o=01) rotated equidistant cylindrical. "e" and non-"e" staggered
362 !! - (igdtnumi/o=10) mercator cylindrical
363 !! - (igdtnumi/o=20) polar stereographic azimuthal
364 !! - (igdtnumi/o=30) lambert conformal conical
365 !! - (igdtnumi/o=40) gaussian cylindrical
366 !!
367 !! As an added bonus the number of output grid points
368 !! and their latitudes and longitudes are also returned.
369 !!
370 !! On the other hand, data may be interpolated to a set of station
371 !! points if "igdtnumo"<0 (or subtracted from 255 for the budget
372 !! option), in which case the number of points and
373 !! their latitudes and longitudes must be input.
374 !!
375 !! Input bitmaps will be interpolated to output bitmaps.
376 !! Output bitmaps will also be created when the output grid
377 !! extends outside of the domain of the input grid.
378 !!
379 !! The output field is set to 0 where the output bitmap is off.
380 !!
381 !! @param[in] ip Interpolation method
382 !! - ip=0 for bilinear
383 !! - ip=1 for bicubic
384 !! - ip=2 for neighbor;
385 !! - ip=3 for budget;
386 !! - ip=4 for spectral;
387 !! - ip=6 for neighbor-budget
388 !!
389 !! @param[in] ipopt Interpolation options
390 !! - ip=0: (No options)
391 !! - ip=1: Constraint option
392 !! - ip=2: (No options)
393 !! - ip=3: Number in radius, radius weights, search radius
394 !! - ip=4: Spectral shape, spectral truncation
395 !! - ip=6: Number in radius, radius weights ...)
396 !!
397 !! @param[in] igdtnumi Grid definition template number for the input grid.
398 !! Corresponds to the gfld%igdtnum component of the ncep g2 library gridmod data structure:
399 !! - 00 - EQUIDISTANT CYLINDRICAL
400 !! - 01 - Rotated equidistant cylindrical. "e" and non-"e" staggered
401 !! - 10 - MERCATOR CYCLINDRICAL
402 !! - 20 - POLAR STEREOGRAPHIC AZIMUTHAL
403 !! - 30 - LAMBERT CONFORMAL CONICAL
404 !! - 40 - GAUSSIAN EQUIDISTANT CYCLINDRICAL
405 !!
406 !! @param[in] igdtmpli Grid definition template array input grid.
407 !! Corresponds to the gfld%igdtmpl component of the NCEPLIBS-g2 gridmod data structure
408 !!
409 !! Section 3 Info:
410 !!
411 !! All map projections:
412 !! - (1): SHAPE OF EARTH, OCTET 15
413 !! - (2): SCALE FACTOR OF SPHERICAL EARTH RADIUS, OCTET 16
414 !! - (3): SCALED VALUE OF RADIUS OF SPHERICAL EARTH, OCTETS 17-20
415 !! - (4): SCALE FACTOR OF MAJOR AXIS OF ELLIPTICAL EARTH, OCTET 21
416 !! - (5): SCALED VALUE OF MAJOR AXIS OF ELLIPTICAL EARTH, OCTETS 22-25
417 !! - (6): SCALE FACTOR OF MINOR AXIS OF ELLIPTICAL EARTH, OCTET 26
418 !! - (7): SCALED VALUE OF MINOR AXIS OF ELLIPTICAL EARTH, OCTETS 27-30
419 !!
420 !! Equidistant Cyclindrical:
421 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
422 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
423 !! - (10): BASIC ANGLE OF INITIAL PRODUCTION DOMAIN, OCTETS 39-42.
424 !! - (11): SUBDIVISIONS OF BASIC ANGLE, OCTETS 43-46
425 !! - (12): LATITUDE OF FIRST GRID POINT, OCTETS 47-50
426 !! - (13): LONGITUDE OF FIRST GRID POINT, OCTETS 51-54
427 !! - (14): RESOLUTION AND COMPONENT FLAGS, OCTET 55
428 !! - (15): LATITUDE OF LAST GRID POINT, OCTETS 56-59
429 !! - (16): LONGITUDE OF LAST GRID POINT, OCTETS 60-63
430 !! - (17): I-DIRECTION INCREMENT, OCTETS 64-67
431 !! - (18): J-DIRECTION INCREMENT, OCTETS 68-71
432 !! - (19): SCANNING MODE, OCTET 72
433 !!
434 !! Mercator Cyclindrical:
435 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
436 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
437 !! - (10): LATITUDE OF FIRST POINT, OCTETS 39-42
438 !! - (11): LONGITUDE OF FIRST POINT, OCTETS 43-46
439 !! - (12): RESOLUTION AND COMPONENT FLAGS, OCTET 47
440 !! - (13): TANGENT LATITUDE, OCTETS 48-51
441 !! - (14): LATITUDE OF LAST POINT, OCTETS 52-55
442 !! - (15): LONGITUDE OF LAST POINT, OCTETS 56-59
443 !! - (16): SCANNING MODE FLAGS, OCTET 60
444 !! - (17): ORIENTATION OF GRID, OCTETS 61-64
445 !! - (18): LONGITUDINAL GRID LENGTH, OCTETS 65-68
446 !! - (19): LATITUDINAL GRID LENGTH, OCTETS 69-72
447 !!
448 !! Lambert Conformal Conical:
449 !! - (8): NUMBER OF POINTS ALONG X-AXIS, OCTS 31-34
450 !! - (9): NUMBER OF POINTS ALONG Y-AXIS, OCTS 35-38
451 !! - (10): LATITUDE OF FIRST POINT, OCTETS 39-42
452 !! - (11): LONGITUDE OF FIRST POINT, OCTETS 43-46
453 !! - (12): RESOLUTION OF COMPONENT FLAG, OCTET 47
454 !! - (13): LATITUDE WHERE GRID LENGTHS SPECIFIED,OCTETS 48-51
455 !! - (14): LONGITUDE OF MERIDIAN THAT IS PARALLEL TO Y-AXIS, OCTETS 52-55
456 !! - (15): X-DIRECTION GRID LENGTH, OCTETS 56-59
457 !! - (16): Y-DIRECTION GRID LENGTH, OCTETS 60-63
458 !! - (17): PROJECTION CENTER FLAG, OCTET 64
459 !! - (18): SCANNING MODE, OCTET 65
460 !! - (19): FIRST TANGENT LATITUDE FROM POLE, OCTETS 66-69
461 !! - (20): SECOND TANGENT LATITUDE FROM POLE, OCTETS 70-73
462 !! - (21): LATITUDE OF SOUTH POLE OF PROJECTION, OCTETS 74-77
463 !! - (22): LONGITUDE OF SOUTH POLE OF PROJECTION, OCTETS 78-81
464 !!
465 !! Gaussian Cylindrical:
466 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
467 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
468 !! - (10): BASIC ANGLE OF INITIAL PRODUCTION DOMAIN, OCTETS 39-42
469 !! - (11): SUBDIVISIONS OF BASIC ANGLE, OCTETS 43-46
470 !! - (12): LATITUDE OF FIRST GRID POINT, OCTETS 47-50
471 !! - (13): LONGITUDE OF FIRST GRID POINT, OCTETS 51-54
472 !! - (14): RESOLUTION AND COMPONENT FLAGS, OCTET 55
473 !! - (15): LATITUDE OF LAST GRID POINT, OCTETS 56-59
474 !! - (16): LONGITUDE OF LAST GRID POINT, OCTETS 60-63
475 !! - (17): I-DIRECTION INCREMENT, OCTETS 64-67
476 !! - (18): NUMBER OF PARALLELS BETWEEN POLE AND EQUATOR, OCTETS 68-71
477 !! - (19): SCANNING MODE, OCTET 72
478 !!
479 !! Polar Stereographic Azimuthal:
480 !! - (8): NUMBER OF POINTS ALONG X-AXIS, OCTETS 31-34
481 !! - (9): NUMBER OF POINTS ALONG Y-AXIS, OCTETS 35-38
482 !! - (10): LATITUDE OF FIRST GRID POINT, OCTETS 39-42
483 !! - (11): LONGITUDE OF FIRST GRID POINT, OCTETS 43-46
484 !! - (12): RESOLUTION AND COMPONENT FLAGS, OCTET 47
485 !! - (13): TRUE LATITUDE, OCTETS 48-51
486 !! - (14): ORIENTATION LONGITUDE, OCTETS 52-55
487 !! - (15): X-DIRECTION GRID LENGTH, OCTETS 56-59
488 !! - (16): Y-DIRECTION GRID LENGTH, OCTETS 60-63
489 !! - (17): PROJECTION CENTER FLAG, OCTET 64
490 !! - (18): SCANNING MODE FLAGS, OCTET 65
491 !!
492 !! Rotated Equidistant Cyclindrical:
493 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
494 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
495 !! - (10): BASIC ANGLE OF INITIAL PRODUCTION DOMAIN, OCTETS 39-42
496 !! - (11): SUBDIVISIONS OF BASIC ANGLE, OCTETS 43-46
497 !! - (12): LATITUDE OF FIRST GRID POINT, OCTETS 47-50
498 !! - (13): LONGITUDE OF FIRST GRID POINT, OCTETS 51-54
499 !! - (14): RESOLUTION AND COMPONENT FLAGS, OCTET 55
500 !! - (15): LATITUDE OF LAST GRID POINT, OCTETS 56-59
501 !! - (16): LONGITUDE OF LAST GRID POINT, OCTETS 60-63
502 !! - (17): I-DIRECTION INCREMENT, OCTETS 64-67
503 !! - (18): J-DIRECTION INCREMENT, OCTETS 68-71
504 !! - (19): SCANNING MODE, OCTET 72
505 !! - (20): LATITUDE OF SOUTHERN POLE OF PROJECTION, OCTETS 73-76
506 !! - (21): LONGITUDE OF SOUTHERN POLE OF PROJECTION, OCTETS 77-80
507 !! - (22): ANGLE OF ROTATION OF PROJECTION, OCTS 81-84
508 !!
509 !! @param[in] igdtleni Number of elements of the grid definition
510 !! template array for the input grid. Corresponds to the gfld%igdtlen
511 !! component of the ncep g2 library gridmod data structure.
512 !!
513 !! @param[in] igdtnumo Grid definition template number for the output grid.
514 !! Corresponds to the gfld%igdtnum component of the
515 !! ncep g2 library gridmod data structure.
516 !! See "igdtnumi" for specific template definitions.
517 !! Note: igdtnumo<0 means interpolate to random station points.
518 !!
519 !! @param[in] igdtmplo Grid definition template array for the output grid.
520 !! Corresponds to the gfld%igdtmpl component of the ncep g2 library gridmod data structure.
521 !! See "igdtmpli" for definition of array elements.
522 !!
523 !! @param[in] igdtleno Number of elements of the grid definition template array for the output grid. c
524 !! Corresponds to the gfld%igdtlen component of the ncep g2 library gridmod data structure.
525 !!
526 !! @param[in] mi Skip number between input grid fields if km>1 or dimension of input grid fields if km=1.
527 !! @param[in] mo Skip number between output grid fields if km>1 or dimension of output grid fields if km=1.
528 !! @param[in] km Number of fields to interpolate.
529 !! @param[in] ibi Input bitmap flags.
530 !! @param[in] li Input bitmaps (if respective ibi(k)=1).
531 !! @param[in] gi Input fields to interpolate.
532 !! @param[out] no Number of output points (only if kgdso(1)<0).
533 !! @param[out] rlat Output latitudes in degrees (if kgdso(1)<0).
534 !! @param[out] rlon Output longitudes in degrees (if kgdso(1)<0).
535 !! @param[out] ibo Output bitmap flags.
536 !! @param[out] lo Output bitmaps (always output).
537 !! @param[out] go Output fields interpolated.
538 !! @param[out] iret Return code.
539 !! - 0 Successful interpolation.
540 !! - 1 Unrecognized interpolation method.
541 !! - 2 Unrecognized input grid or no grid overlap.
542 !! - 3 Unrecognized output grid.
543 !! - 1x Invalid bicubic method parameters.
544 !! - 3x Invalid budget method parameters.
545 !! - 4x Invalid spectral method parameters.
546 !!
547 !! @note Examples demonstrating relative cpu costs.
548 !! This example is interpolating 12 levels of temperatures
549 !! from the 360 x 181 global grid (ncep grid 3)
550 !! to the 93 x 68 hawaiian mercator grid (ncep grid 204).
551 !!
552 !! The example times are for the c90. As a reference, the cp time
553 !! for unpacking the global 12 temperature fields is 0.04 seconds.
554 !!
555 !! METHOD | IP| IPOPT | CP SECONDS
556 !! --------| --|-------------| ----------
557 !! BILINEAR| 0 | | 0.03
558 !! BICUBIC | 1 | 0 | 0.07
559 !! BICUBIC | 1 | 1 | 0.07
560 !! NEIGHBOR| 2 | | 0.01
561 !! BUDGET | 3 | -1,-1 | 0.48
562 !! SPECTRAL| 4 | 0,40 | 0.22
563 !! SPECTRAL| 4 | 1,40 | 0.24
564 !! SPECTRAL| 4 | 0,-1 | 0.42
565 !! N-BUDGET| 6 | -1,-1 | 0.15
566 !!
567 !! The spectral interpolation is fast for the mercator grid.
568 !! However, for some grids the spectral interpolation is slow.
569 !!
570 !! The following example is interpolating 12 levels of temperatures
571 !! from the 360 x 181 global grid (ncep grid 3)
572 !! to the 93 x 65 conus lambert conformal grid (ncep grid 211).
573 !!
574 !! METHOD | IP| IPOPT |CP SECONDS
575 !! --------| --| -------------|----------
576 !! BILINEAR| 0 | | 0.03
577 !! BICUBIC | 1 | 0 | 0.07
578 !! BICUBIC | 1 | 1 | 0.07
579 !! NEIGHBOR| 2 | | 0.01
580 !! BUDGET | 3 | -1,-1 | 0.51
581 !! SPECTRAL| 4 | 0,40 | 3.94
582 !! SPECTRAL| 4 | 1,40 | 5.02
583 !! SPECTRAL| 4 | 0,-1 | 11.36
584 !! N-BUDGET| 6 | -1,-1 | 0.18
585 !!
586 !! @author Mark Iredell, Kyle Gerheiser
587 SUBROUTINE ipolates_grib2(IP,IPOPT,IGDTNUMI,IGDTMPLI,IGDTLENI, &
588 IGDTNUMO,IGDTMPLO,IGDTLENO, &
589 MI,MO,KM,IBI,LI,GI, &
590 NO,RLAT,RLON,IBO,LO,GO,IRET) bind(C)
591 USE iso_c_binding, ONLY: c_int, c_float, c_double, c_bool, c_long
592#if (LSIZE==8)
593 INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
594 INTEGER(C_LONG), INTENT(IN ) :: IBI(KM)
595 INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMI, IGDTLENI
596 INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLI(IGDTLENI)
597 INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMO, IGDTLENO
598 INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLO(IGDTLENO)
599 INTEGER(C_LONG), INTENT( OUT) :: NO
600 INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO(KM)
601#else
602 INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
603 INTEGER(C_INT), INTENT(IN ) :: IBI(KM)
604 INTEGER(C_INT), INTENT(IN ) :: IGDTNUMI, IGDTLENI
605 INTEGER(C_INT), INTENT(IN ) :: IGDTMPLI(IGDTLENI)
606 INTEGER(C_INT), INTENT(IN ) :: IGDTNUMO, IGDTLENO
607 INTEGER(C_INT), INTENT(IN ) :: IGDTMPLO(IGDTLENO)
608 INTEGER(C_INT), INTENT( OUT) :: NO
609 INTEGER(C_INT), INTENT( OUT) :: IRET, IBO(KM)
610#endif
611 !
612 LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI,KM)
613 LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO,KM)
614 !
615#if (LSIZE==4)
616 REAL(C_FLOAT), INTENT(IN ) :: GI(MI,KM)
617 REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO)
618 REAL(C_FLOAT), INTENT( OUT) :: GO(MO,KM)
619#else
620 REAL(C_DOUBLE), INTENT(IN ) :: GI(MI,KM)
621 REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO)
622 REAL(C_DOUBLE), INTENT( OUT) :: GO(MO,KM)
623#endif
624
625 type(grib2_descriptor) :: desc_in, desc_out
626 class(ip_grid), allocatable :: grid_in, grid_out
627
628 desc_in = init_descriptor(igdtnumi, igdtleni, igdtmpli)
629 desc_out = init_descriptor(igdtnumo, igdtleno, igdtmplo)
630
631 call init_grid(grid_in, desc_in)
632 call init_grid(grid_out, desc_out)
633
634 CALL ipolates_grid(ip,ipopt,grid_in,grid_out,mi,mo,km,ibi,li,gi,no,rlat,rlon,ibo,lo,go,iret)
635
636 END SUBROUTINE ipolates_grib2
637
638 !> Special case of ipolates_grib2 when interpolating a single field.
639 !! Removes the km dimension of input arrays so scalars can be passed to ibi/ibo.
640 !!
641 !! @param[in] ip Interpolation method
642 !! - ip=0 for bilinear
643 !! - ip=1 for bicubic
644 !! - ip=2 for neighbor;
645 !! - ip=3 for budget;
646 !! - ip=4 for spectral;
647 !! - ip=6 for neighbor-budget
648 !!
649 !! @param[in] ipopt Interpolation options
650 !! - ip=0: (No options)
651 !! - ip=1: Constraint option
652 !! - ip=2: (No options)
653 !! - ip=3: Number in radius, radius weights, search radius
654 !! - ip=4: Spectral shape, spectral truncation
655 !! - ip=6: Number in radius, radius weights ...)
656 !!
657 !! @param[in] igdtnumi Grid definition template number for the input grid.
658 !! Corresponds to the gfld%igdtnum component of the ncep g2 library gridmod data structure:
659 !! - 00 - EQUIDISTANT CYLINDRICAL
660 !! - 01 - Rotated equidistant cylindrical. "e" and non-"e" staggered
661 !! - 10 - MERCATOR CYCLINDRICAL
662 !! - 20 - POLAR STEREOGRAPHIC AZIMUTHAL
663 !! - 30 - LAMBERT CONFORMAL CONICAL
664 !! - 40 - GAUSSIAN EQUIDISTANT CYCLINDRICAL
665 !!
666 !! @param[in] igdtmpli Grid definition template array input grid.
667 !! Corresponds to the gfld%igdtmpl component of the NCEPLIBS-g2 gridmod data structure
668 !!
669 !! Section 3 Info:
670 !!
671 !! All map projections:
672 !! - (1): SHAPE OF EARTH, OCTET 15
673 !! - (2): SCALE FACTOR OF SPHERICAL EARTH RADIUS, OCTET 16
674 !! - (3): SCALED VALUE OF RADIUS OF SPHERICAL EARTH, OCTETS 17-20
675 !! - (4): SCALE FACTOR OF MAJOR AXIS OF ELLIPTICAL EARTH, OCTET 21
676 !! - (5): SCALED VALUE OF MAJOR AXIS OF ELLIPTICAL EARTH, OCTETS 22-25
677 !! - (6): SCALE FACTOR OF MINOR AXIS OF ELLIPTICAL EARTH, OCTET 26
678 !! - (7): SCALED VALUE OF MINOR AXIS OF ELLIPTICAL EARTH, OCTETS 27-30
679 !!
680 !! Equidistant Cyclindrical:
681 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
682 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
683 !! - (10): BASIC ANGLE OF INITIAL PRODUCTION DOMAIN, OCTETS 39-42.
684 !! - (11): SUBDIVISIONS OF BASIC ANGLE, OCTETS 43-46
685 !! - (12): LATITUDE OF FIRST GRID POINT, OCTETS 47-50
686 !! - (13): LONGITUDE OF FIRST GRID POINT, OCTETS 51-54
687 !! - (14): RESOLUTION AND COMPONENT FLAGS, OCTET 55
688 !! - (15): LATITUDE OF LAST GRID POINT, OCTETS 56-59
689 !! - (16): LONGITUDE OF LAST GRID POINT, OCTETS 60-63
690 !! - (17): I-DIRECTION INCREMENT, OCTETS 64-67
691 !! - (18): J-DIRECTION INCREMENT, OCTETS 68-71
692 !! - (19): SCANNING MODE, OCTET 72
693 !!
694 !! Mercator Cyclindrical:
695 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
696 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
697 !! - (10): LATITUDE OF FIRST POINT, OCTETS 39-42
698 !! - (11): LONGITUDE OF FIRST POINT, OCTETS 43-46
699 !! - (12): RESOLUTION AND COMPONENT FLAGS, OCTET 47
700 !! - (13): TANGENT LATITUDE, OCTETS 48-51
701 !! - (14): LATITUDE OF LAST POINT, OCTETS 52-55
702 !! - (15): LONGITUDE OF LAST POINT, OCTETS 56-59
703 !! - (16): SCANNING MODE FLAGS, OCTET 60
704 !! - (17): ORIENTATION OF GRID, OCTETS 61-64
705 !! - (18): LONGITUDINAL GRID LENGTH, OCTETS 65-68
706 !! - (19): LATITUDINAL GRID LENGTH, OCTETS 69-72
707 !!
708 !! Lambert Conformal Conical:
709 !! - (8): NUMBER OF POINTS ALONG X-AXIS, OCTS 31-34
710 !! - (9): NUMBER OF POINTS ALONG Y-AXIS, OCTS 35-38
711 !! - (10): LATITUDE OF FIRST POINT, OCTETS 39-42
712 !! - (11): LONGITUDE OF FIRST POINT, OCTETS 43-46
713 !! - (12): RESOLUTION OF COMPONENT FLAG, OCTET 47
714 !! - (13): LATITUDE WHERE GRID LENGTHS SPECIFIED,OCTETS 48-51
715 !! - (14): LONGITUDE OF MERIDIAN THAT IS PARALLEL TO Y-AXIS, OCTETS 52-55
716 !! - (15): X-DIRECTION GRID LENGTH, OCTETS 56-59
717 !! - (16): Y-DIRECTION GRID LENGTH, OCTETS 60-63
718 !! - (17): PROJECTION CENTER FLAG, OCTET 64
719 !! - (18): SCANNING MODE, OCTET 65
720 !! - (19): FIRST TANGENT LATITUDE FROM POLE, OCTETS 66-69
721 !! - (20): SECOND TANGENT LATITUDE FROM POLE, OCTETS 70-73
722 !! - (21): LATITUDE OF SOUTH POLE OF PROJECTION, OCTETS 74-77
723 !! - (22): LONGITUDE OF SOUTH POLE OF PROJECTION, OCTETS 78-81
724 !!
725 !! Gaussian Cylindrical:
726 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
727 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
728 !! - (10): BASIC ANGLE OF INITIAL PRODUCTION DOMAIN, OCTETS 39-42
729 !! - (11): SUBDIVISIONS OF BASIC ANGLE, OCTETS 43-46
730 !! - (12): LATITUDE OF FIRST GRID POINT, OCTETS 47-50
731 !! - (13): LONGITUDE OF FIRST GRID POINT, OCTETS 51-54
732 !! - (14): RESOLUTION AND COMPONENT FLAGS, OCTET 55
733 !! - (15): LATITUDE OF LAST GRID POINT, OCTETS 56-59
734 !! - (16): LONGITUDE OF LAST GRID POINT, OCTETS 60-63
735 !! - (17): I-DIRECTION INCREMENT, OCTETS 64-67
736 !! - (18): NUMBER OF PARALLELS BETWEEN POLE AND EQUATOR, OCTETS 68-71
737 !! - (19): SCANNING MODE, OCTET 72
738 !!
739 !! Polar Stereographic Azimuthal:
740 !! - (8): NUMBER OF POINTS ALONG X-AXIS, OCTETS 31-34
741 !! - (9): NUMBER OF POINTS ALONG Y-AXIS, OCTETS 35-38
742 !! - (10): LATITUDE OF FIRST GRID POINT, OCTETS 39-42
743 !! - (11): LONGITUDE OF FIRST GRID POINT, OCTETS 43-46
744 !! - (12): RESOLUTION AND COMPONENT FLAGS, OCTET 47
745 !! - (13): TRUE LATITUDE, OCTETS 48-51
746 !! - (14): ORIENTATION LONGITUDE, OCTETS 52-55
747 !! - (15): X-DIRECTION GRID LENGTH, OCTETS 56-59
748 !! - (16): Y-DIRECTION GRID LENGTH, OCTETS 60-63
749 !! - (17): PROJECTION CENTER FLAG, OCTET 64
750 !! - (18): SCANNING MODE FLAGS, OCTET 65
751 !!
752 !! Rotated Equidistant Cyclindrical:
753 !! - (8): NUMBER OF POINTS ALONG A PARALLEL, OCTS 31-34
754 !! - (9): NUMBER OF POINTS ALONG A MERIDIAN, OCTS 35-38
755 !! - (10): BASIC ANGLE OF INITIAL PRODUCTION DOMAIN, OCTETS 39-42
756 !! - (11): SUBDIVISIONS OF BASIC ANGLE, OCTETS 43-46
757 !! - (12): LATITUDE OF FIRST GRID POINT, OCTETS 47-50
758 !! - (13): LONGITUDE OF FIRST GRID POINT, OCTETS 51-54
759 !! - (14): RESOLUTION AND COMPONENT FLAGS, OCTET 55
760 !! - (15): LATITUDE OF LAST GRID POINT, OCTETS 56-59
761 !! - (16): LONGITUDE OF LAST GRID POINT, OCTETS 60-63
762 !! - (17): I-DIRECTION INCREMENT, OCTETS 64-67
763 !! - (18): J-DIRECTION INCREMENT, OCTETS 68-71
764 !! - (19): SCANNING MODE, OCTET 72
765 !! - (20): LATITUDE OF SOUTHERN POLE OF PROJECTION, OCTETS 73-76
766 !! - (21): LONGITUDE OF SOUTHERN POLE OF PROJECTION, OCTETS 77-80
767 !! - (22): ANGLE OF ROTATION OF PROJECTION, OCTS 81-84
768 !!
769 !! @param[in] igdtleni Number of elements of the grid definition
770 !! template array for the input grid. Corresponds to the gfld%igdtlen
771 !! component of the ncep g2 library gridmod data structure.
772 !!
773 !! @param[in] igdtnumo Grid definition template number for the output grid.
774 !! Corresponds to the gfld%igdtnum component of the
775 !! ncep g2 library gridmod data structure.
776 !! See "igdtnumi" for specific template definitions.
777 !! Note: igdtnumo<0 means interpolate to random station points.
778 !!
779 !! @param[in] igdtmplo Grid definition template array for the output grid.
780 !! Corresponds to the gfld%igdtmpl component of the ncep g2 library gridmod data structure.
781 !! See "igdtmpli" for definition of array elements.
782 !!
783 !! @param[in] igdtleno Number of elements of the grid definition template array for the output grid. c
784 !! Corresponds to the gfld%igdtlen component of the ncep g2 library gridmod data structure.
785 !!
786 !! @param[in] mi Skip number between input grid fields if km>1 or dimension of input grid fields if km=1.
787 !! @param[in] mo Skip number between output grid fields if km>1 or dimension of output grid fields if km=1.
788 !! @param[in] km Number of fields to interpolate.
789 !! @param[in] ibi Input bitmap flags.
790 !! @param[in] li Input bitmaps (if respective ibi(k)=1).
791 !! @param[in] gi Input fields to interpolate.
792 !! @param[out] no Number of output points (only if kgdso(1)<0).
793 !! @param[out] rlat Output latitudes in degrees (if kgdso(1)<0).
794 !! @param[out] rlon Output longitudes in degrees (if kgdso(1)<0).
795 !! @param[out] ibo Output bitmap flags.
796 !! @param[out] lo Output bitmaps (always output).
797 !! @param[out] go Output fields interpolated.
798 !! @param[out] iret Return code.
799 !! - 0 Successful interpolation.
800 !! - 1 Unrecognized interpolation method.
801 !! - 2 Unrecognized input grid or no grid overlap.
802 !! - 3 Unrecognized output grid.
803 !! - 1x Invalid bicubic method parameters.
804 !! - 3x Invalid budget method parameters.
805 !! - 4x Invalid spectral method parameters.
806 !!
807 !! @author Eric Engle @date November 2022
808 SUBROUTINE ipolates_grib2_single_field(IP,IPOPT,IGDTNUMI,IGDTMPLI,IGDTLENI, &
809 IGDTNUMO,IGDTMPLO,IGDTLENO, &
810 MI,MO,KM,IBI,LI,GI, &
811 NO,RLAT,RLON,IBO,LO,GO,IRET) bind(C)
812 USE iso_c_binding, ONLY: c_int, c_float, c_double, c_bool, c_long
813#if (LSIZE==8)
814 INTEGER(C_LONG), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
815 INTEGER(C_LONG), INTENT(IN ) :: IBI
816 INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMI, IGDTLENI
817 INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLI(IGDTLENI)
818 INTEGER(C_LONG), INTENT(IN ) :: IGDTNUMO, IGDTLENO
819 INTEGER(C_LONG), INTENT(IN ) :: IGDTMPLO(IGDTLENO)
820 INTEGER(C_LONG), INTENT( OUT) :: NO
821 INTEGER(C_LONG), INTENT( OUT) :: IRET, IBO
822#else
823 INTEGER(C_INT), INTENT(IN ) :: IP, IPOPT(20), KM, MI, MO
824 INTEGER(C_INT), INTENT(IN ) :: IBI
825 INTEGER(C_INT), INTENT(IN ) :: IGDTNUMI, IGDTLENI
826 INTEGER(C_INT), INTENT(IN ) :: IGDTMPLI(IGDTLENI)
827 INTEGER(C_INT), INTENT(IN ) :: IGDTNUMO, IGDTLENO
828 INTEGER(C_INT), INTENT(IN ) :: IGDTMPLO(IGDTLENO)
829 INTEGER(C_INT), INTENT( OUT) :: NO
830 INTEGER(C_INT), INTENT( OUT) :: IRET, IBO
831#endif
832 !
833 LOGICAL(C_BOOL), INTENT(IN ) :: LI(MI)
834 LOGICAL(C_BOOL), INTENT( OUT) :: LO(MO)
835 !
836#if (LSIZE==4)
837 REAL(C_FLOAT), INTENT(IN ) :: GI(MI)
838 REAL(C_FLOAT), INTENT(INOUT) :: RLAT(MO),RLON(MO)
839 REAL(C_FLOAT), INTENT( OUT) :: GO(MO)
840#else
841 REAL(C_DOUBLE), INTENT(IN ) :: GI(MI)
842 REAL(C_DOUBLE), INTENT(INOUT) :: RLAT(MO),RLON(MO)
843 REAL(C_DOUBLE), INTENT( OUT) :: GO(MO)
844#endif
845
846 type(grib2_descriptor) :: desc_in, desc_out
847 class(ip_grid), allocatable :: grid_in, grid_out
848 integer :: ibo_array(1)
849
850 desc_in = init_descriptor(igdtnumi, igdtleni, igdtmpli)
851 desc_out = init_descriptor(igdtnumo, igdtleno, igdtmplo)
852
853 call init_grid(grid_in, desc_in)
854 call init_grid(grid_out, desc_out)
855
856 ! Can't pass expression (e.g. [ibo]) to intent(out) argument.
857 ! Initialize placeholder array of size 1 to make rank match.
858 ibo_array(1) = ibo
859
860 call ipolates_grid(ip,ipopt,grid_in,grid_out,mi,mo,km,[ibi],li,gi,no,rlat,rlon,ibo_array,lo,go,iret)
861
862 ibo = ibo_array(1)
863
864 END SUBROUTINE ipolates_grib2_single_field
865
866end module ipolates_mod
867
Users derived type grid descriptor objects to abstract away the raw GRIB1 and GRIB2 grid definitions.
Routines for creating an ip_grid given a Grib descriptor.
Abstract ip_grid type.
Top-level module to export interpolation routines and constants.
integer, parameter, public neighbor_interp_id
integer, parameter, public bilinear_interp_id
integer, parameter, public budget_interp_id
integer, parameter, public spectral_interp_id
integer, parameter, public bicubic_interp_id
integer, parameter, public neighbor_budget_interp_id
Top-level driver for scalar interpolation interpolation routine ipolates().
Definition ipolates.F90:12
subroutine ipolates_grid(ip, ipopt, grid_in, grid_out, mi, mo, km, ibi, li, gi, no, rlat, rlon, ibo, lo, go, iret)
Interpolates scalar fields between grids given ip_grid objects.
Definition ipolates.F90:65
subroutine, public ipolates_grib2(ip, ipopt, igdtnumi, igdtmpli, igdtleni, igdtnumo, igdtmplo, igdtleno, mi, mo, km, ibi, li, gi, no, rlat, rlon, ibo, lo, go, iret)
This subprogram interpolates scalar field from any grid to any grid given a grib2 descriptor.
Definition ipolates.F90:591
subroutine, public ipolates_grib2_single_field(ip, ipopt, igdtnumi, igdtmpli, igdtleni, igdtnumo, igdtmplo, igdtleno, mi, mo, km, ibi, li, gi, no, rlat, rlon, ibo, lo, go, iret)
Special case of ipolates_grib2 when interpolating a single field.
Definition ipolates.F90:812
subroutine, public ipolates_grib1(ip, ipopt, kgdsi, kgdso, mi, mo, km, ibi, li, gi, no, rlat, rlon, ibo, lo, go, iret)
This subprogram interpolates scalar field from any grid to any grid given a grib1 Grid Descriptor Sec...
Definition ipolates.F90:295
subroutine, public ipolates_grib1_single_field(ip, ipopt, kgdsi, kgdso, mi, mo, km, ibi, li, gi, no, rlat, rlon, ibo, lo, go, iret)
Special case of ipolates_grib1 when interpolating a single field.
Definition ipolates.F90:160
Descriptor representing a grib1 grib descriptor section (GDS) with an integer array.
Grib-2 descriptor containing a grib2 GDT represented by an integer array.
Abstract grid that holds fields and methods common to all grids.