@@ -497,12 +497,12 @@ subroutine HORIZ_INTERP_CONSERVE_NEW_1DX1D_ ( Interp, lon_in, lat_in, lon_out, l
497497
498498 subroutine HORIZ_INTERP_CONSERVE_NEW_2DX2D_ ( Interp, lon_in, lat_in, lon_out, lat_out, &
499499 mask_in, mask_out, verbose, save_xgrid_area, as_fregrid)
500- type (horiz_interp_type), intent (inout) :: Interp
501- real (FMS_HI_KIND_), intent (in), dimension (:,:) :: lon_in , lat_in
502- real (FMS_HI_KIND_), intent (in), dimension (:,:) :: lon_out, lat_out
503- real (FMS_HI_KIND_), intent (in), optional, dimension (:,:) :: mask_in
500+ type (horiz_interp_type), intent (inout) :: Interp
501+ real (FMS_HI_KIND_), intent (in), dimension (:,:), target :: lon_in , lat_in
502+ real (FMS_HI_KIND_), intent (in), dimension (:,:), target :: lon_out, lat_out
503+ real (FMS_HI_KIND_), intent (in), optional, dimension (:,:), target :: mask_in
504504 real (FMS_HI_KIND_), intent (inout), optional, dimension (:,:) :: mask_out
505- integer, intent (in), optional :: verbose
505+ integer, intent (in), optional :: verbose
506506 logical, intent (in), optional :: save_xgrid_area !< option to save xgrid_area
507507 logical, intent (in), optional :: as_fregrid !< save weights as xcell_area/input_cell_area
508508
@@ -518,15 +518,15 @@ subroutine HORIZ_INTERP_CONSERVE_NEW_1DX1D_ ( Interp, lon_in, lat_in, lon_out, l
518518 logical :: as_fregrid_
519519 integer, parameter :: kind_ = FMS_HI_KIND_ !< compiled kind size
520520
521- if (.not . module_is_initialized) then
521+ if (.not . module_is_initialized) then
522522 call mpp_error (FATAL, ' HORIZ_INTERP_CONSERVE_NEW_2DX2D_: horiz_interp_conserve is not intialized' )
523523 end if
524524
525- if (.not . all (shape (lon_in) == shape (lat_in))) then
525+ if (.not . all (shape (lon_in) == shape (lat_in))) then
526526 call mpp_error (FATAL, ' horiz_interp_conserve_mod: size mismatch between lon_in and lat_in' )
527527 end if
528528
529- if (.not . all (shape (lon_out) == shape (lat_out))) then
529+ if (.not . all (shape (lon_out) == shape (lat_out))) then
530530 call mpp_error (FATAL, ' horiz_interp_conserve_mod: size mismatch between lon_out and lat_out' )
531531 end if
532532
@@ -535,65 +535,65 @@ subroutine HORIZ_INTERP_CONSERVE_NEW_1DX1D_ ( Interp, lon_in, lat_in, lon_out, l
535535 nlon_out = size (lon_out, 1 ) - 1
536536 nlat_out = size (lon_out, 2 ) - 1
537537
538- if (present (mask_in)) then
539- if (.not . all (shape (mask_in) == [nlon_in, nlat_in])) then
538+ if (present (mask_in)) then
539+ if (.not . all (shape (mask_in) == [nlon_in, nlat_in])) then
540540 call mpp_error (FATAL, ' horiz_interp_conserve_mod: size mismatch between mask_in and lon_in/lat_in' )
541541 end if
542542 end if
543543
544544 as_fregrid_ = .false .
545- if (present (as_fregrid)) as_fregrid_ = as_fregrid
545+ if (present (as_fregrid)) as_fregrid_ = as_fregrid
546546
547547 maxxgrid = get_maxxgrid ()
548- allocate (i_src (maxxgrid), j_src (maxxgrid), i_dst (maxxgrid), j_dst (maxxgrid), xgrid_area (maxxgrid))
549- if (as_fregrid_) then
550- allocate (parent_area (nlon_in, nlat_in))
548+ allocate (i_src (maxxgrid), j_src (maxxgrid), i_dst (maxxgrid), j_dst (maxxgrid), xgrid_area (maxxgrid))
549+ if (as_fregrid_) then
550+ allocate (parent_area (nlon_in, nlat_in))
551551 else
552- allocate (parent_area (nlon_out, nlat_out))
552+ allocate (parent_area (nlon_out, nlat_out))
553553 end if
554554
555555#ifdef HI_R8_CODE_
556556 lon_in_r8 => lon_in
557557 lat_in_r8 => lat_in
558558 lon_out_r8 => lon_out
559559 lat_out_r8 => lat_out
560- if (present (mask_in)) then
560+ if (present (mask_in)) then
561561 mask_src => mask_in
562562 else
563- allocate (mask_src (nlon_in, nlat_in), source=1 .0_r8_kind)
563+ allocate (mask_src (nlon_in, nlat_in), source=1 .0_r8_kind)
564564 end if
565565#else
566- allocate (lon_in_r8, source=real (lon_in, r8_kind))
567- allocate (lat_in_r8, source=real (lat_in, r8_kind))
568- allocate (lon_out_r8, source=real (lon_out, r8_kind))
569- allocate (lat_out_r8, source=real (lat_out, r8_kind))
570- if (present (mask_in)) then
571- allocate (mask_src, source=real (mask_in, r8_kind))
566+ allocate (lon_in_r8, source=real (lon_in, r8_kind))
567+ allocate (lat_in_r8, source=real (lat_in, r8_kind))
568+ allocate (lon_out_r8, source=real (lon_out, r8_kind))
569+ allocate (lat_out_r8, source=real (lat_out, r8_kind))
570+ if (present (mask_in)) then
571+ allocate (mask_src, source=real (mask_in, r8_kind))
572572 else
573- allocate (mask_src (nlon_in, nlat_in), source=1 .0_r8_kind)
573+ allocate (mask_src (nlon_in, nlat_in), source=1 .0_r8_kind)
574574 end if
575575#endif
576576
577- if (great_circle_algorithm) then
578- allocate (clon (maxxgrid), clat (maxxgrid))
577+ if (great_circle_algorithm) then
578+ allocate (clon (maxxgrid), clat (maxxgrid))
579579 nxgrid = create_xgrid_great_circle (nlon_in, nlat_in, nlon_out, nlat_out, lon_in_r8, lat_in_r8, &
580580 lon_out_r8, lat_out_r8, mask_src, i_src, j_src, i_dst, j_dst, xgrid_area, clon, clat)
581- deallocate (clon, clat)
581+ deallocate (clon, clat)
582582 else
583583 nxgrid = create_xgrid_2DX2D_order1 (nlon_in, nlat_in, nlon_out, nlat_out, lon_in_r8, lat_in_r8, &
584584 lon_out_r8, lat_out_r8, mask_src, i_src, j_src, i_dst, j_dst, xgrid_area)
585585 end if
586586
587- if (as_fregrid_) then
587+ if (as_fregrid_) then
588588 call get_grid_area (nlon_in, nlat_in, lon_in_r8, lat_in_r8, parent_area)
589589 end if
590590
591591#ifdef HI_R8_CODE_
592- if (.not . present (mask_in)) deallocate (mask_src)
592+ if (.not . present (mask_in)) deallocate (mask_src)
593593#else
594- deallocate (lon_in_r8, lat_in_r8, lon_out_r8, lat_out_r8, mask_src)
594+ deallocate (lon_in_r8, lat_in_r8, lon_out_r8, lat_out_r8, mask_src)
595595#endif
596- nullify (lon_in_r8, lat_in_r8, lon_out_r8, lat_out_r8, mask_src)
596+ nullify (lon_in_r8, lat_in_r8, lon_out_r8, lat_out_r8, mask_src)
597597
598598 Interp%version = 2
599599 Interp%nxgrid = nxgrid
@@ -602,18 +602,18 @@ subroutine HORIZ_INTERP_CONSERVE_NEW_1DX1D_ ( Interp, lon_in, lat_in, lon_out, l
602602 Interp%nlon_dst = nlon_out
603603 Interp%nlat_dst = nlat_out
604604 ! +1 for C to Fortran conversion, starting index in C is 0
605- allocate (Interp%i_src, source=i_src (1 :nxgrid) + 1 )
606- allocate (Interp%j_src, source=j_src (1 :nxgrid) + 1 )
607- allocate (Interp%i_dst, source=i_dst (1 :nxgrid) + 1 )
608- allocate (Interp%j_dst, source=j_dst (1 :nxgrid) + 1 )
609- allocate (Interp%HI_KIND_TYPE_%area_frac_dst (nxgrid))
610- if (present (save_xgrid_area)) then
611- if (save_xgrid_area) then
612- allocate (Interp%xgrid_area, source=xgrid_area (1 :nxgrid))
605+ allocate (Interp%i_src, source=i_src (1 :nxgrid) + 1 )
606+ allocate (Interp%j_src, source=j_src (1 :nxgrid) + 1 )
607+ allocate (Interp%i_dst, source=i_dst (1 :nxgrid) + 1 )
608+ allocate (Interp%j_dst, source=j_dst (1 :nxgrid) + 1 )
609+ allocate (Interp%HI_KIND_TYPE_%area_frac_dst (nxgrid))
610+ if (present (save_xgrid_area)) then
611+ if (save_xgrid_area) then
612+ allocate (Interp%xgrid_area, source=xgrid_area (1 :nxgrid))
613613 end if
614614 end if
615615
616- if (as_fregrid_) then
616+ if (as_fregrid_) then
617617 do i = 1 , nxgrid
618618 ii = Interp%i_src (i)
619619 jj = Interp%j_src (i)
@@ -634,8 +634,8 @@ subroutine HORIZ_INTERP_CONSERVE_NEW_1DX1D_ ( Interp, lon_in, lat_in, lon_out, l
634634 end do
635635 end if
636636
637- if (present (mask_out)) then
638- if (.not . all (shape (mask_out) == [nlon_out, nlat_out])) then
637+ if (present (mask_out)) then
638+ if (.not . all (shape (mask_out) == [nlon_out, nlat_out])) then
639639 call mpp_error (FATAL, ' horiz_interp_conserve_mod: size mismatch between mask_out and lon_out/lat_out' )
640640 end if
641641 mask_out = 0 .0_kind_
@@ -646,7 +646,7 @@ subroutine HORIZ_INTERP_CONSERVE_NEW_1DX1D_ ( Interp, lon_in, lat_in, lon_out, l
646646 end do
647647 end if
648648
649- deallocate (i_src, j_src, i_dst, j_dst, xgrid_area, parent_area)
649+ deallocate (i_src, j_src, i_dst, j_dst, xgrid_area, parent_area)
650650
651651 Interp%HI_KIND_TYPE_%is_allocated = .true .
652652 Interp%interp_method = CONSERVE
0 commit comments