23 interp_method, num_nbrs, max_dist, src_modulo, &
24 grid_at_center, mask_in, mask_out)
27 type(horiz_interp_type),
intent(inout) :: Interp
28 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_in , lat_in
29 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_out, lat_out
30 integer,
intent(in),
optional :: verbose
31 character(len=*),
intent(in),
optional :: interp_method
32 integer,
intent(in),
optional :: num_nbrs
33 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
34 logical,
intent(in),
optional :: src_modulo
35 logical,
intent(in),
optional :: grid_at_center
36 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
37 real(FMS_HI_KIND_),
intent(inout),
dimension(:,:),
optional :: mask_out
39 real(FMS_HI_KIND_),
dimension(:,:),
allocatable :: lon_src, lat_src, lon_dst, lat_dst
40 real(FMS_HI_KIND_),
dimension(:),
allocatable :: lon_src_1d, lat_src_1d, lon_dst_1d, lat_dst_1d
41 integer :: i, j, nlon_in, nlat_in, nlon_out, nlat_out
43 character(len=40) :: method
44 integer,
parameter :: kindl = fms_hi_kind_
46 call horiz_interp_init
48 method =
'conservative'
49 if(
present(interp_method)) method = interp_method
51 select case (trim(method))
53 interp%interp_method = conserve
54 call horiz_interp_conserve_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose)
56 interp%interp_method = bilinear
58 if(
present(grid_at_center) ) center = grid_at_center
60 nlon_out =
size(lon_out(:)); nlat_out =
size(lat_out(:))
61 allocate(lon_dst(nlon_out,nlat_out), lat_dst(nlon_out,nlat_out))
63 lon_dst(i,:) = lon_out(i)
66 lat_dst(:,j) = lat_out(j)
69 call horiz_interp_bilinear_new ( interp, lon_in, lat_in, lon_dst, lat_dst, &
71 deallocate(lon_dst, lat_dst)
73 nlon_in =
size(lon_in(:))-1; nlat_in =
size(lat_in(:))-1
74 nlon_out =
size(lon_out(:))-1; nlat_out =
size(lat_out(:))-1
75 allocate(lon_src_1d(nlon_in), lat_src_1d(nlat_in))
76 allocate(lon_dst(nlon_out,nlat_out), lat_dst(nlon_out,nlat_out))
78 lon_src_1d(i) = (lon_in(i) + lon_in(i+1)) * 0.5_kindl
81 lat_src_1d(j) = (lat_in(j) + lat_in(j+1)) * 0.5_kindl
84 lon_dst(i,:) = (lon_out(i) + lon_out(i+1)) * 0.5_kindl
87 lat_dst(:,j) = (lat_out(j) + lat_out(j+1)) * 0.5_kindl
89 call horiz_interp_bilinear_new ( interp, lon_src_1d, lat_src_1d, lon_dst, lat_dst, &
91 deallocate(lon_src_1d, lat_src_1d, lon_dst, lat_dst)
94 interp%interp_method = bicubic
96 if(
present(grid_at_center) ) center = grid_at_center
99 call horiz_interp_bicubic_new ( interp, lon_in, lat_in, lon_out, lat_out, &
102 nlon_in =
size(lon_in(:))-1; nlat_in =
size(lat_in(:))-1
103 nlon_out =
size(lon_out(:))-1; nlat_out =
size(lat_out(:))-1
104 allocate(lon_src_1d(nlon_in), lat_src_1d(nlat_in))
105 allocate(lon_dst_1d(nlon_out), lat_dst_1d(nlat_out))
107 lon_src_1d(i) = (lon_in(i) + lon_in(i+1)) * 0.5_kindl
110 lat_src_1d(j) = (lat_in(j) + lat_in(j+1)) * 0.5_kindl
113 lon_dst_1d(i) = (lon_out(i) + lon_out(i+1)) * 0.5_kindl
116 lat_dst_1d(j) = (lat_out(j) + lat_out(j+1)) * 0.5_kindl
118 call horiz_interp_bicubic_new ( interp, lon_src_1d, lat_src_1d, lon_dst_1d, lat_dst_1d, &
120 deallocate(lon_src_1d, lat_src_1d, lon_dst_1d, lat_dst_1d)
123 interp%interp_method = spherical
124 nlon_in =
size(lon_in(:)); nlat_in =
size(lat_in(:))
125 nlon_out =
size(lon_out(:)); nlat_out =
size(lat_out(:))
126 allocate(lon_src(nlon_in,nlat_in), lat_src(nlon_in,nlat_in))
127 allocate(lon_dst(nlon_out,nlat_out), lat_dst(nlon_out,nlat_out))
129 lon_src(i,:) = lon_in(i)
132 lat_src(:,j) = lat_in(j)
135 lon_dst(i,:) = lon_out(i)
138 lat_dst(:,j) = lat_out(j)
140 call horiz_interp_spherical_new ( interp, lon_src, lat_src, lon_dst, lat_dst, &
141 num_nbrs, max_dist, src_modulo)
142 deallocate(lon_src, lat_src, lon_dst, lat_dst)
144 call mpp_error(fatal,
'horiz_interp_mod: interp_method should be conservative, bilinear, bicubic, spherical')
148 interp% HI_KIND_TYPE_ % is_allocated = .true.
149 interp%I_am_initialized = .true.
156 verbose, interp_method, num_nbrs, max_dist, &
157 src_modulo, grid_at_center, mask_in, mask_out, is_latlon_out )
159 type(horiz_interp_type),
intent(inout) :: Interp
160 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_in , lat_in
161 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_out, lat_out
162 integer,
intent(in),
optional :: verbose
163 character(len=*),
intent(in),
optional :: interp_method
164 integer,
intent(in),
optional :: num_nbrs
165 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
166 logical,
intent(in),
optional :: src_modulo
167 logical,
intent(in),
optional :: grid_at_center
168 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
169 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
170 logical,
intent(in),
optional :: is_latlon_out
172 real(FMS_HI_KIND_),
dimension(:,:),
allocatable :: lon_src, lat_src
173 real(FMS_HI_KIND_),
dimension(:),
allocatable :: lon_src_1d, lat_src_1d
174 integer :: i, j, nlon_in, nlat_in
175 character(len=40) :: method
177 logical :: dst_is_latlon
178 integer,
parameter :: kindl = fms_hi_kind_
180 call horiz_interp_init
182 method =
'conservative'
183 if(
present(interp_method)) method = interp_method
185 select case (trim(method))
186 case (
"conservative")
187 interp%interp_method = conserve
189 if(
PRESENT(is_latlon_out))
then
190 dst_is_latlon = is_latlon_out
192 dst_is_latlon = is_lat_lon(lon_out, lat_out)
194 if(dst_is_latlon )
then
195 if(
present(mask_in))
then
196 if ( any(mask_in < -.0001_kindl) .or. any(mask_in > 1.0001_kindl)) &
197 call mpp_error(fatal, &
198 'horiz_interp_conserve_new_1d_src(horiz_interp_conserve_mod): input mask not between 0,1')
199 allocate(interp%HI_KIND_TYPE_%mask_in(
size(mask_in,1),
size(mask_in,2)) )
200 interp%HI_KIND_TYPE_%mask_in = mask_in
202 call horiz_interp_conserve_new ( interp, lon_in, lat_in, lon_out(:,1), lat_out(1,:), &
205 call horiz_interp_conserve_new ( interp, lon_in, lat_in, lon_out, lat_out, &
206 verbose=verbose, mask_in=mask_in, mask_out=mask_out )
209 interp%interp_method = bilinear
211 if(
present(grid_at_center) ) center = grid_at_center
213 call horiz_interp_bilinear_new ( interp, lon_in, lat_in, lon_out, lat_out, &
214 verbose, src_modulo )
216 nlon_in =
size(lon_in(:))-1; nlat_in =
size(lat_in(:))-1
217 allocate(lon_src_1d(nlon_in), lat_src_1d(nlat_in))
219 lon_src_1d(i) = (lon_in(i) + lon_in(i+1)) * 0.5_kindl
222 lat_src_1d(j) = (lat_in(j) + lat_in(j+1)) * 0.5_kindl
224 call horiz_interp_bilinear_new ( interp, lon_src_1d, lat_src_1d, lon_out, lat_out, &
225 verbose, src_modulo )
226 deallocate(lon_src_1d,lat_src_1d)
229 interp%interp_method = bicubic
231 if(
present(grid_at_center) ) center = grid_at_center
233 call horiz_interp_bicubic_new ( interp, lon_in, lat_in, lon_out, lat_out, &
234 verbose, src_modulo )
236 nlon_in =
size(lon_in(:))-1; nlat_in =
size(lat_in(:))-1
237 allocate(lon_src_1d(nlon_in), lat_src_1d(nlat_in))
239 lon_src_1d(i) = (lon_in(i) + lon_in(i+1)) * 0.5_kindl
242 lat_src_1d(j) = (lat_in(j) + lat_in(j+1)) * 0.5_kindl
244 call horiz_interp_bicubic_new ( interp, lon_src_1d, lat_src_1d, lon_out, lat_out, &
245 verbose, src_modulo )
246 deallocate(lon_src_1d,lat_src_1d)
249 interp%interp_method = spherical
250 nlon_in =
size(lon_in(:)); nlat_in =
size(lat_in(:))
251 allocate(lon_src(nlon_in,nlat_in), lat_src(nlon_in,nlat_in))
253 lon_src(i,:) = lon_in(i)
256 lat_src(:,j) = lat_in(j)
258 call horiz_interp_spherical_new ( interp, lon_src, lat_src, lon_out, lat_out, &
259 num_nbrs, max_dist, src_modulo)
260 deallocate(lon_src, lat_src)
262 call mpp_error(fatal,
'interp_method should be conservative, bilinear, bicubic, spherical')
266 interp% HI_KIND_TYPE_ % is_allocated = .true.
267 interp%I_am_initialized = .true.
273 subroutine horiz_interp_new_2d_ (Interp, lon_in, lat_in, lon_out, lat_out, &
274 verbose, interp_method, num_nbrs, max_dist, &
275 src_modulo, mask_in, mask_out, is_latlon_in, is_latlon_out )
276 type(horiz_interp_type),
intent(inout) :: Interp
277 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_in , lat_in
278 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_out, lat_out
279 integer,
intent(in),
optional :: verbose
280 character(len=*),
intent(in),
optional :: interp_method
281 integer,
intent(in),
optional :: num_nbrs
282 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
283 logical,
intent(in),
optional :: src_modulo
284 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
285 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
286 logical,
intent(in),
optional :: is_latlon_in, is_latlon_out
287 logical :: src_is_latlon, dst_is_latlon
288 character(len=40) :: method
289 integer,
parameter :: kindl = fms_hi_kind_
291 call horiz_interp_init
294 if(
present(interp_method)) method = interp_method
296 select case (trim(method))
297 case (
"conservative")
298 interp%interp_method = conserve
299 if(
PRESENT(is_latlon_in))
then
300 src_is_latlon = is_latlon_in
302 src_is_latlon = is_lat_lon(lon_in, lat_in)
304 if(
PRESENT(is_latlon_out))
then
305 dst_is_latlon = is_latlon_out
307 dst_is_latlon = is_lat_lon(lon_out, lat_out)
309 if(src_is_latlon .AND. dst_is_latlon)
then
310 if(
present(mask_in))
then
311 if ( any(mask_in < -0.0001_kindl) .or. any(mask_in > 1.0001_kindl))
then
312 call mpp_error(fatal,
'horiz_interp_conserve_new_2d(horiz_interp_conserve_mod):' // &
313 ' input mask not between 0,1')
315 allocate(interp%HI_KIND_TYPE_%mask_in(
size(mask_in,1),
size(mask_in,2)) )
316 interp%HI_KIND_TYPE_%mask_in = mask_in
318 call horiz_interp_conserve_new ( interp, lon_in(:,1), lat_in(1,:), lon_out(:,1), lat_out(1,:), &
320 else if(src_is_latlon)
then
321 call horiz_interp_conserve_new ( interp, lon_in(:,1), lat_in(1,:), lon_out, lat_out, &
322 verbose=verbose, mask_in=mask_in, mask_out=mask_out )
323 else if(dst_is_latlon)
then
324 call horiz_interp_conserve_new ( interp, lon_in, lat_in, lon_out(:,1), lat_out(1,:), &
325 verbose=verbose, mask_in=mask_in, mask_out=mask_out )
327 call horiz_interp_conserve_new ( interp, lon_in, lat_in, lon_out, lat_out, &
328 verbose=verbose, mask_in=mask_in, mask_out=mask_out )
332 interp%interp_method = spherical
333 call horiz_interp_spherical_new ( interp, lon_in, lat_in, lon_out, lat_out, &
334 num_nbrs, max_dist, src_modulo )
336 interp%interp_method = bilinear
337 call horiz_interp_bilinear_new ( interp, lon_in, lat_in, lon_out, lat_out, &
338 verbose, src_modulo )
340 call mpp_error(fatal,
'when source grid are 2d, interp_method should be spherical or bilinear')
343 interp% HI_KIND_TYPE_ % is_allocated = .true.
344 interp%I_am_initialized = .true.
346 end subroutine horiz_interp_new_2d_
349 subroutine horiz_interp_new_1d_dst_ (Interp, lon_in, lat_in, lon_out, lat_out, &
350 verbose, interp_method, num_nbrs, max_dist, src_modulo, mask_in, mask_out, is_latlon_in )
351 type(horiz_interp_type),
intent(inout) :: Interp
352 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_in , lat_in
353 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_out, lat_out
354 integer,
intent(in),
optional :: verbose
355 character(len=*),
intent(in),
optional :: interp_method
356 integer,
intent(in),
optional :: num_nbrs
357 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
358 logical,
intent(in),
optional :: src_modulo
359 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
360 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
361 logical,
intent(in),
optional :: is_latlon_in
363 character(len=40) :: method
364 integer,
parameter :: kindl = fms_hi_kind_
366 integer :: i, j, nlon_out, nlat_out
367 real(FMS_HI_KIND_),
dimension(:,:),
allocatable :: lon_dst, lat_dst
368 logical :: src_is_latlon
370 call horiz_interp_init
373 if(
present(interp_method)) method = interp_method
375 nlon_out =
size(lon_out(:)); nlat_out =
size(lat_out(:))
376 allocate(lon_dst(nlon_out,nlat_out), lat_dst(nlon_out,nlat_out))
378 lon_dst(i,:) = lon_out(i)
381 lat_dst(:,j) = lat_out(j)
384 select case (trim(method))
385 case (
"conservative")
386 interp%interp_method = conserve
387 if(
PRESENT(is_latlon_in))
then
388 src_is_latlon = is_latlon_in
390 src_is_latlon = is_lat_lon(lon_in, lat_in)
393 if(src_is_latlon)
then
394 if(
present(mask_in))
then
395 if ( any(mask_in < -0.0001_kindl) .or. any(mask_in > 1.0001_kindl)) &
396 call mpp_error(fatal, &
397 'horiz_interp_conserve_new_1d_dst(horiz_interp_conserve_mod): input mask not between 0,1')
398 allocate(interp%HI_KIND_TYPE_%mask_in(
size(mask_in,1),
size(mask_in,2)) )
399 interp%HI_KIND_TYPE_%mask_in = mask_in
401 call horiz_interp_conserve_new ( interp, lon_in(:,1), lat_in(1,:), lon_out, lat_out, &
404 call horiz_interp_conserve_new ( interp, lon_in, lat_in, lon_out, lat_out, &
405 verbose=verbose, mask_in=mask_in, mask_out=mask_out )
408 interp%interp_method = bilinear
409 call horiz_interp_bilinear_new ( interp, lon_in, lat_in, lon_dst, lat_dst, &
410 verbose, src_modulo )
412 interp%interp_method = spherical
413 call horiz_interp_spherical_new ( interp, lon_in, lat_in, lon_dst, lat_dst, &
414 num_nbrs, max_dist, src_modulo)
416 call mpp_error(fatal,
'when source grid are 2d, interp_method should be spherical or bilinear')
419 deallocate(lon_dst,lat_dst)
421 interp% HI_KIND_TYPE_ % is_allocated = .true.
422 interp%I_am_initialized = .true.
424 end subroutine horiz_interp_new_1d_dst_
428 subroutine horiz_interp_base_2d_ ( Interp, data_in, data_out, verbose, &
429 mask_in, mask_out, missing_value, missing_permit, &
430 err_msg, new_missing_handle )
432 type (horiz_interp_type),
intent(in) :: Interp
433 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: data_in
434 real(FMS_HI_KIND_),
intent(out),
dimension(:,:) :: data_out
435 integer,
intent(in),
optional :: verbose
436 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
437 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
438 real(FMS_HI_KIND_),
intent(in),
optional :: missing_value
439 integer,
intent(in),
optional :: missing_permit
440 character(len=*),
intent(out),
optional :: err_msg
441 logical,
intent(in),
optional :: new_missing_handle
443 if(
present(err_msg)) err_msg =
''
444 if(.not.interp%I_am_initialized)
then
445 if(fms_error_handler(
'horiz_interp',
'The horiz_interp_type variable is not initialized',err_msg))
return
448 select case(interp%interp_method)
450 call horiz_interp_conserve(interp,data_in, data_out, verbose, mask_in, mask_out)
452 call horiz_interp_bilinear(interp,data_in, data_out, verbose, mask_in, mask_out, &
453 missing_value, missing_permit, new_missing_handle )
455 call horiz_interp_bicubic(interp,data_in, data_out, verbose, mask_in, mask_out, &
456 missing_value, missing_permit )
458 call horiz_interp_spherical(interp,data_in, data_out, verbose, mask_in, mask_out, &
461 call mpp_error(fatal,
'interp_method should be conservative, bilinear, bicubic, spherical')
466 end subroutine horiz_interp_base_2d_
474 missing_value, missing_permit, err_msg )
480 type (horiz_interp_type),
intent(in) :: Interp
481 real(FMS_HI_KIND_),
intent(in),
dimension(:,:,:) :: data_in
482 real(FMS_HI_KIND_),
intent(out),
dimension(:,:,:) :: data_out
483 integer,
intent(in),
optional :: verbose
484 real(FMS_HI_KIND_),
intent(in),
dimension(:,:,:),
optional :: mask_in
485 real(FMS_HI_KIND_),
intent(out),
dimension(:,:,:),
optional :: mask_out
486 real(FMS_HI_KIND_),
intent(in),
optional :: missing_value
487 integer,
intent(in),
optional :: missing_permit
488 character(len=*),
intent(out),
optional :: err_msg
492 if(
present(err_msg)) err_msg =
''
493 if(.not.interp%I_am_initialized)
then
494 if(fms_error_handler(
'horiz_interp',
'The horiz_interp_type variable is not initialized',err_msg))
return
497 do n = 1,
size(data_in,3)
498 if (
present(mask_in))
then
499 if(
present(mask_out))
then
500 call horiz_interp( interp, data_in(:,:,n), data_out(:,:,n), &
501 verbose, mask_in(:,:,n), mask_out(:,:,n), &
502 missing_value, missing_permit )
504 call horiz_interp( interp, data_in(:,:,n), data_out(:,:,n), &
505 verbose, mask_in(:,:,n), missing_value = missing_value, &
506 missing_permit = missing_permit )
509 if(
present(mask_out))
then
510 call horiz_interp( interp, data_in(:,:,n), data_out(:,:,n), &
511 verbose, mask_out=mask_out(:,:,n), missing_value = missing_value, &
512 missing_permit = missing_permit )
514 call horiz_interp( interp, data_in(:,:,n), data_out(:,:,n), &
515 verbose, missing_value = missing_value, &
516 missing_permit = missing_permit )
531 data_out, verbose, mask_in, mask_out, &
532 interp_method, missing_value, missing_permit, &
533 num_nbrs, max_dist,src_modulo, grid_at_center )
535 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: data_in
536 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_in , lat_in
537 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_out, lat_out
538 real(FMS_HI_KIND_),
intent(out),
dimension(:,:) :: data_out
539 integer,
intent(in),
optional :: verbose
540 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
541 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
542 character(len=*),
intent(in),
optional :: interp_method
543 real(FMS_HI_KIND_),
intent(in),
optional :: missing_value
544 integer,
intent(in),
optional :: missing_permit
545 integer,
intent(in),
optional :: num_nbrs
546 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
547 logical,
intent(in),
optional :: src_modulo
548 logical,
intent(in),
optional :: grid_at_center
550 type (horiz_interp_type) :: Interp
552 call horiz_interp_init
554 call horiz_interp_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose, &
555 interp_method, num_nbrs, max_dist, src_modulo, grid_at_center )
557 call horiz_interp ( interp, data_in, data_out, verbose, &
558 mask_in, mask_out, missing_value, missing_permit )
560 call horiz_interp_del ( interp )
571 data_out, verbose, mask_in, mask_out, &
572 interp_method, missing_value, missing_permit, &
573 num_nbrs, max_dist, src_modulo, grid_at_center )
575 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: data_in
576 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_in , lat_in
577 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_out, lat_out
578 real(FMS_HI_KIND_),
intent(out),
dimension(:,:) :: data_out
579 integer,
intent(in),
optional :: verbose
580 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
581 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
582 character(len=*),
intent(in),
optional :: interp_method
583 real(FMS_HI_KIND_),
intent(in),
optional :: missing_value
584 integer,
intent(in),
optional :: missing_permit
585 integer,
intent(in),
optional :: num_nbrs
586 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
587 logical,
intent(in),
optional :: src_modulo
588 logical,
intent(in),
optional :: grid_at_center
591 type (horiz_interp_type) :: Interp
592 logical :: dst_is_latlon
593 character(len=128) :: method
595 call horiz_interp_init
596 method =
'conservative'
597 if(
present(interp_method)) method = interp_method
598 dst_is_latlon = .true.
599 if(trim(method) ==
'conservative') dst_is_latlon = is_lat_lon(lon_out, lat_out)
601 if(dst_is_latlon)
then
602 call horiz_interp_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose, &
603 interp_method, num_nbrs, max_dist, src_modulo, &
604 grid_at_center, is_latlon_out = dst_is_latlon )
605 call horiz_interp ( interp, data_in, data_out, verbose, &
606 mask_in, mask_out, missing_value, missing_permit )
608 call horiz_interp_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose, &
609 interp_method, num_nbrs, max_dist, src_modulo, &
610 grid_at_center, mask_in, mask_out, is_latlon_out = dst_is_latlon)
612 call horiz_interp ( interp, data_in, data_out, verbose, &
613 missing_value=missing_value, missing_permit=missing_permit )
616 call horiz_interp_del ( interp )
628 verbose, mask_in, mask_out, interp_method, missing_value,&
629 missing_permit, num_nbrs, max_dist, src_modulo )
631 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: data_in
632 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_in , lat_in
633 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_out, lat_out
634 real(FMS_HI_KIND_),
intent(out),
dimension(:,:) :: data_out
635 integer,
intent(in),
optional :: verbose
636 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
637 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
638 character(len=*),
intent(in),
optional :: interp_method
639 real(FMS_HI_KIND_),
intent(in),
optional :: missing_value
640 integer,
intent(in),
optional :: missing_permit
641 integer,
intent(in),
optional :: num_nbrs
642 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
643 logical,
intent(in),
optional :: src_modulo
645 type (horiz_interp_type) :: Interp
646 logical :: dst_is_latlon, src_is_latlon
647 character(len=128) :: method
649 call horiz_interp_init
651 method =
'conservative'
652 if(
present(interp_method)) method = interp_method
653 dst_is_latlon = .true.
654 src_is_latlon = .true.
655 if(trim(method) ==
'conservative')
then
656 dst_is_latlon = is_lat_lon(lon_out, lat_out)
657 src_is_latlon = is_lat_lon(lon_in, lat_in)
660 if(dst_is_latlon .and. src_is_latlon)
then
661 call horiz_interp_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose, &
662 interp_method, num_nbrs, max_dist, src_modulo, &
663 is_latlon_in=dst_is_latlon, is_latlon_out = dst_is_latlon )
664 call horiz_interp ( interp, data_in, data_out, verbose, &
665 mask_in, mask_out, missing_value, missing_permit )
667 call horiz_interp_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose, &
668 interp_method, num_nbrs, max_dist, src_modulo, &
670 is_latlon_in=dst_is_latlon, is_latlon_out = dst_is_latlon)
671 call horiz_interp ( interp, data_in, data_out, verbose, &
672 missing_value=missing_value, missing_permit=missing_permit )
675 call horiz_interp_del ( interp )
687 verbose, mask_in, mask_out,interp_method,missing_value, &
688 missing_permit, num_nbrs, max_dist, src_modulo)
690 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: data_in
691 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: lon_in , lat_in
692 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_out, lat_out
693 real(FMS_HI_KIND_),
intent(out),
dimension(:,:) :: data_out
694 integer,
intent(in),
optional :: verbose
695 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
696 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
697 character(len=*),
intent(in),
optional :: interp_method
698 real(FMS_HI_KIND_),
intent(in),
optional :: missing_value
699 integer,
intent(in),
optional :: missing_permit
700 integer,
intent(in),
optional :: num_nbrs
701 real(FMS_HI_KIND_),
intent(in),
optional :: max_dist
702 logical,
intent(in),
optional :: src_modulo
704 type (horiz_interp_type) :: Interp
705 logical :: src_is_latlon
706 character(len=128) :: method
708 call horiz_interp_init
710 method =
'conservative'
711 if(
present(interp_method)) method = interp_method
712 src_is_latlon = .true.
713 if(trim(method) ==
'conservative') src_is_latlon = is_lat_lon(lon_in, lat_in)
715 if(src_is_latlon)
then
716 call horiz_interp_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose, &
717 interp_method, num_nbrs, max_dist, src_modulo, &
718 is_latlon_in = src_is_latlon )
719 call horiz_interp ( interp, data_in, data_out, verbose, &
720 mask_in, mask_out, missing_value, missing_permit )
722 call horiz_interp_new ( interp, lon_in, lat_in, lon_out, lat_out, verbose, &
723 interp_method, num_nbrs, max_dist, src_modulo, &
724 mask_in, mask_out, is_latlon_in = src_is_latlon)
726 call horiz_interp ( interp, data_in, data_out, verbose, &
727 missing_value=missing_value, missing_permit=missing_permit )
730 call horiz_interp_del ( interp )
740 lon_out, lat_out, data_out, &
741 verbose, mask_in, mask_out)
744 real(FMS_HI_KIND_),
intent(in),
dimension(:,:) :: data_in
746 real(FMS_HI_KIND_),
intent(in) :: wb
748 real(FMS_HI_KIND_),
intent(in) :: sb
750 real(FMS_HI_KIND_),
intent(in) :: dx
752 real(FMS_HI_KIND_),
intent(in) :: dy
754 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lon_out
758 real(FMS_HI_KIND_),
intent(in),
dimension(:) :: lat_out
762 real(FMS_HI_KIND_),
intent(out),
dimension(:,:) :: data_out
763 integer,
intent(in),
optional :: verbose
764 real(FMS_HI_KIND_),
intent(in),
dimension(:,:),
optional :: mask_in
765 real(FMS_HI_KIND_),
intent(out),
dimension(:,:),
optional :: mask_out
767 real(FMS_HI_KIND_),
dimension(size(data_in,1)+1) :: blon_in
768 real(FMS_HI_KIND_),
dimension(size(data_in,2)+1) :: blat_in
769 integer :: i, j, nlon_in, nlat_in
770 real(FMS_HI_KIND_) :: tpi
771 integer,
parameter :: kindl = fms_hi_kind_
773 call horiz_interp_init
775 tpi = 2.0_kindl * real(pi, fms_hi_kind_)
776 nlon_in =
size(data_in,1)
777 nlat_in =
size(data_in,2)
780 blon_in(i) = wb + real(i-1, fms_hi_kind_)*dx
782 if (abs(blon_in(nlon_in+1)-blon_in(1)-tpi) < epsilon(blon_in)) &
783 blon_in(nlon_in+1)=blon_in(1)+tpi
786 blat_in(j) = sb + real(j-1, fms_hi_kind_)*dy
788 blat_in(1) = -0.5_kindl * real(pi, fms_hi_kind_)
789 blat_in(nlat_in+1) = 0.5_kindl * real(pi, fms_hi_kind_)
792 call horiz_interp_solo_1d (data_in, blon_in, blat_in, &
793 lon_out, lat_out, data_out, &
794 verbose, mask_in, mask_out )
804 function is_lat_lon_(lon, lat)
805 real(FMS_HI_KIND_),
dimension(:,:),
intent(in) :: lon, lat
806 logical :: IS_LAT_LON_
807 integer :: i, j, nlon, nlat, num
812 loop_lat:
do j = 1, nlat
814 if(lat(i,j) .NE. lat(1,j))
then
815 is_lat_lon_ = .false.
822 loop_lon:
do i = 1, nlon
824 if(lon(i,j) .NE. lon(i,1))
then
825 is_lat_lon_ = .false.
833 if(is_lat_lon_) num = 1
838 is_lat_lon_ = .false.
842 end function is_lat_lon_
847 weight_file_source, interp_method, isw, iew, jsw, jew, nglon, nglat)
848 type(horiz_interp_type),
intent(inout) :: Interp
849 character(len=*),
intent(in) :: weight_filename
850 real(FMS_HI_KIND_),
intent(in) :: lat_out(:,:)
851 real(FMS_HI_KIND_),
intent(in) :: lon_out(:,:)
852 real(FMS_HI_KIND_),
intent(in) :: lat_in(:)
853 real(FMS_HI_KIND_),
intent(in) :: lon_in(:)
854 character(len=*),
intent(in) :: weight_file_source
855 character(len=*),
intent(in) :: interp_method
856 integer,
intent(in) :: isw, iew, jsw, jew
857 integer,
intent(in) :: nglon
858 integer,
intent(in) :: nglat
863 real(FMS_HI_KIND_),
allocatable :: lon_src_1d(:)
864 real(FMS_HI_KIND_),
allocatable :: lat_src_1d(:)
865 integer,
parameter :: kindl = fms_hi_kind_
867 select case (trim(interp_method))
873 nlon_in =
size(lon_in(:))-1; nlat_in =
size(lat_in(:))-1
874 allocate(lon_src_1d(nlon_in), lat_src_1d(nlat_in))
876 lon_src_1d(i) = (lon_in(i) + lon_in(i+1)) * 0.5_kindl
879 lat_src_1d(j) = (lat_in(j) + lat_in(j+1)) * 0.5_kindl
882 call horiz_interp_read_weights_bilinear(interp, weight_filename, lon_out, lat_out, &
883 lon_src_1d, lat_src_1d, weight_file_source, interp_method, &
884 isw, iew, jsw, jew, nglon, nglat)
885 deallocate(lon_src_1d,lat_src_1d)
887 call mpp_error(fatal,
"Reading weight from file is not supported for the "//&
888 trim(interp_method)//
" method. It is currently only supported for bilinear")
subroutine horiz_interp_solo_1d_dst_(data_in, lon_in, lat_in, lon_out, lat_out, data_out, verbose, mask_in, mask_out, interp_method, missing_value, missing_permit, num_nbrs, max_dist, src_modulo)
interpolates from any grid to rectangular longitude/latitude grid. interp_method should be "spherical...
subroutine horiz_interp_new_1d_src_(Interp, lon_in, lat_in, lon_out, lat_out, verbose, interp_method, num_nbrs, max_dist, src_modulo, grid_at_center, mask_in, mask_out, is_latlon_out)
subroutine horiz_interp_solo_1d_(data_in, lon_in, lat_in, lon_out, lat_out, data_out, verbose, mask_in, mask_out, interp_method, missing_value, missing_permit, num_nbrs, max_dist, src_modulo, grid_at_center)
Interpolates from a rectangular grid to rectangular grid. interp_method can be the value conservative...
subroutine horiz_interp_base_3d_(Interp, data_in, data_out, verbose, mask_in, mask_out, missing_value, missing_permit, err_msg)
Overload of interface HORIZ_INTERP_BASE_2D_ uses 3d arrays for data and mask this allows for multiple...
subroutine horiz_interp_read_weights_(Interp, weight_filename, lon_out, lat_out, lon_in, lat_in, weight_file_source, interp_method, isw, iew, jsw, jew, nglon, nglat)
Subroutine for reading a weight file and use it to fill in the horiz interp type for the bilinear int...
subroutine horiz_interp_new_1d_(Interp, lon_in, lat_in, lon_out, lat_out, verbose, interp_method, num_nbrs, max_dist, src_modulo, grid_at_center, mask_in, mask_out)
subroutine horiz_interp_solo_2d_(data_in, lon_in, lat_in, lon_out, lat_out, data_out, verbose, mask_in, mask_out, interp_method, missing_value, missing_permit, num_nbrs, max_dist, src_modulo)
Interpolates from any grid to any grid. interp_method should be "spherical" horiz_interp_new don't ne...
subroutine horiz_interp_solo_1d_src_(data_in, lon_in, lat_in, lon_out, lat_out, data_out, verbose, mask_in, mask_out, interp_method, missing_value, missing_permit, num_nbrs, max_dist, src_modulo, grid_at_center)
Interpolates from a uniformly spaced grid to any output grid. interp_method can be the value "onserva...
subroutine horiz_interp_solo_old_(data_in, wb, sb, dx, dy, lon_out, lat_out, data_out, verbose, mask_in, mask_out)
Overloaded version of interface horiz_interp_solo_2.