NCEPLIBS-ip 5.2.0
Loading...
Searching...
No Matches
ipolates.F90
Go to the documentation of this file.
1
4
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
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
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
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
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
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.