Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion amip_interp/amip_interp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module amip_interp_mod
! end add by JHC

use horiz_interp_mod, only: horiz_interp_init, horiz_interp, &
horiz_interp_new, horiz_interp_del, &
horiz_interp_get_weights, horiz_interp_del, &
horiz_interp_type, assignment(=)

use fms_mod, only: error_mesg, write_version_number, &
Expand Down
12 changes: 6 additions & 6 deletions amip_interp/include/amip_interp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ else
mobs_sst = 1440; nobs_sst = 720

call SET_SST_GRID_EDGES_DAILY_ (mobs_sst, nobs_sst)
call horiz_interp_new ( Interp%Hintrp2, LON_BND_, LAT_BND_, &
lon_model, lat_model, interp_method="bilinear" )
call horiz_interp_get_weights ( Interp%Hintrp2, LON_BND_, LAT_BND_, &
lon_model, lat_model, interp_method="bilinear" )

the_file_exists = fms2_io_file_exists(ncfilename)

Expand Down Expand Up @@ -428,8 +428,8 @@ endif
!-----------------------------------------------------------------------
! ---- initialization of horizontal interpolation ----

call horiz_interp_new ( Interp%Hintrp, LON_BND_, LAT_BND_, &
lon, lat, interp_method= interp_method )
call horiz_interp_get_weights ( Interp%Hintrp, LON_BND_, LAT_BND_, &
lon, lat, interp_method= interp_method )

allocate(Interp%DATA1_ (size(lon(:))-1,size(lat(:))-1))
allocate(Interp%DATA2_ (size(lon(:))-1,size(lat(:))-1))
Expand Down Expand Up @@ -466,8 +466,8 @@ endif
!-----------------------------------------------------------------------
! ---- initialization of horizontal interpolation ----

call horiz_interp_new ( Interp%Hintrp, LON_BND_, LAT_BND_, &
lon, lat, interp_method = interp_method)
call horiz_interp_get_weights ( Interp%Hintrp, LON_BND_, LAT_BND_, &
lon, lat, interp_method = interp_method)

allocate(Interp%DATA1_ (size(lon,1),size(lat,2)))
allocate(Interp%DATA2_ (size(lon,1),size(lat,2)))
Expand Down
8 changes: 4 additions & 4 deletions data_override/include/data_override.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use yaml_parser_mod
use constants_mod, only: DEG_TO_RAD
use mpp_mod, only : mpp_error, FATAL, WARNING, NOTE, stdout, stdlog, mpp_max
use mpp_mod, only : input_nml_file
use horiz_interp_mod, only : horiz_interp_init, horiz_interp_new, horiz_interp_type, &
use horiz_interp_mod, only : horiz_interp_init, horiz_interp_get_weights, horiz_interp_type, &
horiz_interp_read_weights
use time_interp_external2_mod, only: time_interp_external_init, &
time_interp_external, &
Expand Down Expand Up @@ -1462,7 +1462,7 @@ subroutine DATA_OVERRIDE_3D_(gridname,fieldname_code,return_data,time,override,d
need_compute=override_array(curr_position)%need_compute(window_id)
endif

!--- call horiz_interp_new is not initialized
!--- call horiz_interp_get_weights is not initialized

if( need_compute ) then
select case(gridname)
Expand Down Expand Up @@ -1506,12 +1506,12 @@ subroutine DATA_OVERRIDE_3D_(gridname,fieldname_code,return_data,time,override,d
else
select case (data_table(index1)%interpol_method)
case ('bilinear')
call horiz_interp_new (override_array(curr_position)%horz_interp(window_id), &
call horiz_interp_get_weights (override_array(curr_position)%horz_interp(window_id), &
override_array(curr_position)%lon_in(is_src:ie_src+1), &
override_array(curr_position)%lat_in(js_src:je_src+1), &
lon_local(isw:iew,jsw:jew), lat_local(isw:iew,jsw:jew), interp_method="bilinear")
case ('bicubic')
call horiz_interp_new (override_array(curr_position)%horz_interp(window_id), &
call horiz_interp_get_weights (override_array(curr_position)%horz_interp(window_id), &
override_array(curr_position)%lon_in(is_src:ie_src+1), &
override_array(curr_position)%lat_in(js_src:je_src+1), &
lon_local(isw:iew,jsw:jew), lat_local(isw:iew,jsw:jew), interp_method="bicubic")
Expand Down
112 changes: 73 additions & 39 deletions horiz_interp/horiz_interp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
!! horiz_interp_conserver_mod, horiz_interp_blinear_mod, horiz_interp_bicubic_mod
!! and horiz_interp_spherical_mod. bicubic interpolation requires the source grid
!! is regular lon/lat grid. User can choose the interpolation method in the
!! public interface horiz_interp_new through optional argument interp_method,
!! public interface horiz_interp_get_weights through optional argument interp_method,
!! with acceptable value "conservative", "bilinear", "bicubic" and "spherical".
!! The default value is "conservative". There is an optional mask field for
!! missing input data. An optional output mask field may be used in conjunction with
Expand All @@ -51,23 +51,26 @@ module horiz_interp_mod
use horiz_interp_type_mod, only: horiz_interp_type, assignment(=)
use horiz_interp_type_mod, only: CONSERVE, BILINEAR, SPHERICAL, BICUBIC
use horiz_interp_conserve_mod, only: horiz_interp_conserve_init, horiz_interp_conserve
use horiz_interp_conserve_mod, only: horiz_interp_conserve_new, horiz_interp_conserve_del
use horiz_interp_conserve_mod, only: horiz_interp_conserve_get_weights, horiz_interp_conserve_del
use horiz_interp_bilinear_mod, only: horiz_interp_bilinear_init, horiz_interp_bilinear
use horiz_interp_bilinear_mod, only: horiz_interp_bilinear_new, horiz_interp_bilinear_del
use horiz_interp_bilinear_mod, only: horiz_interp_bilinear_get_weights, horiz_interp_bilinear_del
use horiz_interp_bilinear_mod, only: horiz_interp_read_weights_bilinear
use horiz_interp_bicubic_mod, only: horiz_interp_bicubic_init, horiz_interp_bicubic
use horiz_interp_bicubic_mod, only: horiz_interp_bicubic_new, horiz_interp_bicubic_del
use horiz_interp_bicubic_mod, only: horiz_interp_bicubic_get_weights, horiz_interp_bicubic_del
use horiz_interp_spherical_mod, only: horiz_interp_spherical_init, horiz_interp_spherical
use horiz_interp_spherical_mod, only: horiz_interp_spherical_new, horiz_interp_spherical_del
use horiz_interp_spherical_mod, only: horiz_interp_spherical_get_pre_weights, horiz_interp_spherical_del
use platform_mod, only: r4_kind, r8_kind

implicit none
private

!---- interfaces ----

public horiz_interp_type, horiz_interp, horiz_interp_new, horiz_interp_del, &
horiz_interp_init, horiz_interp_end, assignment(=), horiz_interp_read_weights
public :: horiz_interp_type, horiz_interp, horiz_interp_get_weights, horiz_interp_del, &
horiz_interp_init, horiz_interp_end, assignment(=), horiz_interp_read_weights

! legacy name
public :: horiz_interp_new

!> Allocates space and initializes a derived-type variable
!! that contains pre-computed interpolation indices and weights.
Expand Down Expand Up @@ -123,38 +126,71 @@ module horiz_interp_mod
!! A derived-type variable containing indices and weights used for subsequent
!! interpolations. To reinitialize this variable for a different grid-to-grid
!! interpolation you must first use the "horiz_interp_del" interface.
interface horiz_interp_new

!! Horiz_interp_get_weights and horiz_interp_new are identical.
!! Horiz_interp_get_weights is the more descriptively named generic interface that
!! replaces horiz_interp_new. However, horiz_interp_new cannot
!! be removed due to resistance from FMS users (the name change will require changes to
!! codes that use horiz_interp_mod
interface horiz_interp_get_weights
! Source grid is 1d, destination grid is 1d
module procedure horiz_interp_new_1d_r4
module procedure horiz_interp_new_1d_r8
module procedure horiz_interp_get_weights_1d_r4
module procedure horiz_interp_get_weights_1d_r8
! Source grid is 1d, destination grid is 2d
module procedure horiz_interp_new_1d_src_r4
module procedure horiz_interp_new_1d_src_r8
module procedure horiz_interp_get_weights_1d_src_r4
module procedure horiz_interp_get_weights_1d_src_r8
! Source grid is 2d, destination grid is 2d
module procedure horiz_interp_new_2d_r4
module procedure horiz_interp_new_2d_r8
module procedure horiz_interp_get_weights_2d_r4
module procedure horiz_interp_get_weights_2d_r8
! Source grid is 2d, destination grid is 1d
module procedure horiz_interp_new_1d_dst_r4
module procedure horiz_interp_new_1d_dst_r8
module procedure horiz_interp_get_weights_1d_dst_r4
module procedure horiz_interp_get_weights_1d_dst_r8
end interface

interface horiz_interp_new
! Source grid is 1d, destination grid is 1d
module procedure horiz_interp_get_weights_1d_r4
module procedure horiz_interp_get_weights_1d_r8
! Source grid is 1d, destination grid is 2d
module procedure horiz_interp_get_weights_1d_src_r4
module procedure horiz_interp_get_weights_1d_src_r8
! Source grid is 2d, destination grid is 2d
module procedure horiz_interp_get_weights_2d_r4
module procedure horiz_interp_get_weights_2d_r8
! Source grid is 2d, destination grid is 1d
module procedure horiz_interp_get_weights_1d_dst_r4
module procedure horiz_interp_get_weights_1d_dst_r8
end interface horiz_interp_new

!> Subroutines for reading in weight files and using that to fill in the horiz_interp type instead
!! calculating it
!! Horiz_interp_read_weights and horiz_interp_solo_1d are identical.
!! Horiz_interp_read_weights is the more descriptively named generic interface that
!! replaces horiz_interp_solo_1d. However, horiz_interp_solo_1d cannot
!! be removed due to resistance from FMS users (the name change will require changes to
!! codes that use horiz_interp_mod
interface horiz_interp_read_weights
module procedure horiz_interp_read_weights_r4
module procedure horiz_interp_read_weights_r8
end interface horiz_interp_read_weights

interface horiz_interp_solo_1d
module procedure horiz_interp_read_weights_r4
module procedure horiz_interp_read_weights_r8
end interface horiz_interp_solo_1d



!> Subroutine for performing the horizontal interpolation between two grids.
!!
!> Subroutine for performing the horizontal interpolation between
!! two grids. There are two forms of this interface.
!! Form A requires first calling horiz_interp_new, while Form B
!! Form A requires first calling horiz_interp_get_weights, while Form B
!! requires no initialization.
!!
!! @param Interp
!! Derived-type variable containing interpolation indices and weights.
!! Returned by a previous call to horiz_interp_new.
!! Returned by a previous call to horiz_interp_get_weights.
!!
!! @param data_in
!! Input data on source grid.
Expand All @@ -178,11 +214,11 @@ module horiz_interp_mod
!!
!! @param lon_in, lat_in
!! longitude and latitude (in radians) of source grid. More explanation can
!! be found in the documentation of horiz_interp_new.
!! be found in the documentation of horiz_interp_get_weights.
!!
!! @param lon_out, lat_out
!! longitude and latitude (in radians) of destination grid. More explanation can
!! be found in the documentation of horiz_interp_new.
!! be found in the documentation of horiz_interp_get_weights.
!!
!! @param data_out
!! Output data on destination grid.
Expand All @@ -202,20 +238,18 @@ module horiz_interp_mod
!! sure you have the correct grid size.
!> @ingroup horiz_interp_mod
interface horiz_interp
module procedure horiz_interp_base_2d_r4
module procedure horiz_interp_base_2d_r8
module procedure horiz_interp_base_3d_r4
module procedure horiz_interp_base_3d_r8
module procedure horiz_interp_solo_1d_r4
module procedure horiz_interp_solo_1d_r8
module procedure horiz_interp_solo_1d_src_r4
module procedure horiz_interp_solo_1d_src_r8
module procedure horiz_interp_solo_2d_r4
module procedure horiz_interp_solo_2d_r8
module procedure horiz_interp_solo_1d_dst_r4
module procedure horiz_interp_solo_1d_dst_r8
module procedure horiz_interp_solo_old_r4
module procedure horiz_interp_solo_old_r8
module procedure horiz_interp_from_weights_2d_r4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rem1776, fixed what you pointed out

module procedure horiz_interp_from_weights_2d_r8
module procedure horiz_interp_from_weights_3d_r4
module procedure horiz_interp_from_weights_3d_r8
module procedure horiz_interp_1d_r4
module procedure horiz_interp_1d_r8
module procedure horiz_interp_1d_src_r4
module procedure horiz_interp_1d_src_r8
module procedure horiz_interp_2d_r4
module procedure horiz_interp_2d_r8
module procedure horiz_interp_1d_dst_r4
module procedure horiz_interp_1d_dst_r8
end interface

!> Private helper routines
Expand All @@ -224,9 +258,9 @@ module horiz_interp_mod
module procedure is_lat_lon_r8
end interface

interface horiz_interp_solo_1d
module procedure horiz_interp_solo_1d_r4
module procedure horiz_interp_solo_1d_r8
interface horiz_interp_1d
module procedure horiz_interp_1d_r4
module procedure horiz_interp_1d_r8
end interface


Expand Down Expand Up @@ -282,11 +316,11 @@ subroutine horiz_interp_init
end subroutine horiz_interp_init

!> Deallocates memory used by "horiz_interp_type" variables.
!! Must be called before reinitializing with horiz_interp_new.
!! Must be called before reinitializing with horiz_interp_get_weights.
subroutine horiz_interp_del ( Interp )

type (horiz_interp_type), intent(inout) :: Interp !< A derived-type variable returned by previous
!! call to horiz_interp_new. The input variable must have
!! call to horiz_interp_get_weights. The input variable must have
!! allocated arrays. The returned variable will contain
!! deallocated arrays

Expand Down
35 changes: 26 additions & 9 deletions horiz_interp/horiz_interp_bicubic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,37 @@ module horiz_interp_bicubic_mod

private

public :: horiz_interp_bicubic, horiz_interp_bicubic_new, horiz_interp_bicubic_del, fill_xy
public :: horiz_interp_bicubic_init
public :: horiz_interp_bicubic, horiz_interp_bicubic_get_weights, horiz_interp_bicubic_del, fill_xy
public :: horiz_interp_bicubic_init

!> Creates a new @ref horiz_interp_type for bicubic interpolation.
! legacy name
public :: horiz_interp_bicubic_new

!> Creates a get_weights @ref horiz_interp_type for bicubic interpolation.
!! Allocates space and initializes a derived-type variable
!! that contains pre-computed interpolation indices and weights.
!! Horiz_interp_bicubic_get_weights and horiz_interp_bicubic_new are identical.
!! Horiz_interp_bicubic_get_weights is the more descriptively named generic interface that
!! replaces horiz_interp_bicubic_new. However, horiz_interp_bicubic_new cannot
!! be removed due to resistance from FMS users (the name change will require changes to
!! codes that use horiz_interp_bicubic_mod

!> @ingroup horiz_interp_bicubic_mod
interface horiz_interp_bicubic_new
module procedure horiz_interp_bicubic_new_1d_r8
module procedure horiz_interp_bicubic_new_1d_s_r8
module procedure horiz_interp_bicubic_new_1d_r4
module procedure horiz_interp_bicubic_new_1d_s_r4
interface horiz_interp_bicubic_get_weights
module procedure horiz_interp_bicubic_get_weights_1d_r8
module procedure horiz_interp_bicubic_get_weights_1d_s_r8
module procedure horiz_interp_bicubic_get_weights_1d_r4
module procedure horiz_interp_bicubic_get_weights_1d_s_r4
end interface

interface horiz_interp_bicubic_new
module procedure horiz_interp_bicubic_get_weights_1d_r8
module procedure horiz_interp_bicubic_get_weights_1d_s_r8
module procedure horiz_interp_bicubic_get_weights_1d_r4
module procedure horiz_interp_bicubic_get_weights_1d_s_r4
end interface horiz_interp_bicubic_new


!> @brief Perform bicubic horizontal interpolation
interface horiz_interp_bicubic
module procedure horiz_interp_bicubic_r4
Expand Down Expand Up @@ -141,7 +158,7 @@ subroutine horiz_interp_bicubic_init
end subroutine horiz_interp_bicubic_init

!> Free memory from a horiz_interp_type used for bicubic interpolation
!! (allocated via @ref horiz_bicubic_new)
!! (allocated via @ref horiz_bicubic_get_weights)
subroutine horiz_interp_bicubic_del( Interp )
type(horiz_interp_type), intent(inout) :: Interp

Expand Down
32 changes: 24 additions & 8 deletions horiz_interp/horiz_interp_bilinear.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,33 @@ module horiz_interp_bilinear_mod
private


public :: horiz_interp_bilinear_new, horiz_interp_bilinear, horiz_interp_bilinear_del
public :: horiz_interp_bilinear_get_weights, horiz_interp_bilinear, horiz_interp_bilinear_del
public :: horiz_interp_bilinear_init, horiz_interp_read_weights_bilinear

! legacy name
public :: horiz_interp_bilinear_new

!> Creates a @ref horiz_interp_type for bilinear interpolation.
!! Horiz_interp_bilinear_get_weights and horiz_interp_bilinear_new are identical.
!! Horiz_interp_bilinear_get_weights is the more descriptively named generic interface that
!! replaces horiz_interp_bilinear_new. However, horiz_interp_bilinear_new cannot
!! be removed due to resistance from FMS users (the name change will require changes to
!! codes that use horiz_interp_bilinear_mod
!> @ingroup horiz_interp_bilinear_mod
interface horiz_interp_bilinear_get_weights
module procedure horiz_interp_bilinear_get_weights_1d_r4
module procedure horiz_interp_bilinear_get_weights_1d_r8
module procedure horiz_interp_bilinear_get_weights_2d_r4
module procedure horiz_interp_bilinear_get_weights_2d_r8
end interface horiz_interp_bilinear_get_weights

interface horiz_interp_bilinear_new
module procedure horiz_interp_bilinear_new_1d_r4
module procedure horiz_interp_bilinear_new_1d_r8
module procedure horiz_interp_bilinear_new_2d_r4
module procedure horiz_interp_bilinear_new_2d_r8
end interface
module procedure horiz_interp_bilinear_get_weights_1d_r4
module procedure horiz_interp_bilinear_get_weights_1d_r8
module procedure horiz_interp_bilinear_get_weights_2d_r4
module procedure horiz_interp_bilinear_get_weights_2d_r8
end interface horiz_interp_bilinear_new


!> Subroutines for reading in weight files and using that to fill in the horiz_interp type instead
!! calculating it
Expand Down Expand Up @@ -98,11 +114,11 @@ end subroutine horiz_interp_bilinear_init

!> @brief Deallocates memory used by "horiz_interp_type" variables.
!!
!> Must be called before reinitializing with horiz_interp_bilinear_new.
!> Must be called before reinitializing with horiz_interp_bilinear_get_weights.
subroutine horiz_interp_bilinear_del( Interp )

type (horiz_interp_type), intent(inout) :: Interp!< A derived-type variable returned by previous
!! call to horiz_interp_bilinear_new. The input variable must
!! call to horiz_interp_bilinear_get_weights. The input variable must
!! have allocated arrays. The returned variable will contain
!! deallocated arrays

Expand Down
Loading
Loading