Skip to content

Commit

Permalink
New interfaces for array redistribution across domains.
Browse files Browse the repository at this point in the history
  • Loading branch information
MJHarrison-GFDL committed Jan 15, 2021
1 parent b6ce7c7 commit bfdbe21
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion src/framework/MOM_domains.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ module MOM_domains
use mpp_domains_mod, only : To_East => WUPDATE, To_West => EUPDATE, Omit_Corners => EDGEUPDATE
use mpp_domains_mod, only : To_North => SUPDATE, To_South => NUPDATE
use mpp_domains_mod, only : CENTER, CORNER, NORTH_FACE => NORTH, EAST_FACE => EAST
use mpp_domains_mod, only : global_field => mpp_global_field
use mpp_domains_mod, only : mpp_redistribute
use fms_io_mod, only : file_exist, parse_mask_table
use fms_affinity_mod, only : fms_affinity_init, fms_affinity_set, fms_affinity_get

Expand All @@ -48,7 +50,7 @@ module MOM_domains
public :: start_group_pass, complete_group_pass
public :: compute_block_extent, get_global_shape
public :: get_simple_array_i_ind, get_simple_array_j_ind
public :: domain2D
public :: domain2D, global_field, redistribute_array

!> Do a halo update on an array
interface pass_var
Expand Down Expand Up @@ -100,6 +102,11 @@ module MOM_domains
module procedure clone_MD_to_MD, clone_MD_to_d2D
end interface clone_MOM_domain

!> Pass an array from one MOM domain to another
interface redistribute_array
module procedure redistribute_array_3d, redistribute_array_2d
end interface redistribute_array

!> The MOM_domain_type contains information about the domain decompositoin.
type, public :: MOM_domain_type
type(domain2D), pointer :: mpp_domain => NULL() !< The FMS domain with halos
Expand Down Expand Up @@ -1979,4 +1986,42 @@ subroutine get_global_shape(domain, niglobal, njglobal)

end subroutine get_global_shape

!> Returns various data that has been stored in a MOM_domain_type
subroutine redistribute_array_2d(Domain1, array1, Domain2, array2, complete)
type(domain2d), &
intent(in) :: Domain1 !< The MOM domain from which to extract information.
real, dimension(:,:), intent(in) :: array1 !< The array from which to extract information.
type(domain2d), &
intent(in) :: Domain2 !< The MOM domain receiving information.
real, dimension(:,:), intent(out) :: array2 !< The array receiving information.
logical, optional, intent(in) :: complete !< If true, finish communication before proceeding.

! Local variables
logical :: do_complete

do_complete=.true.;if (PRESENT(complete)) do_complete = complete

call mpp_redistribute(Domain1, array1, Domain2, array2, do_complete)

end subroutine redistribute_array_2d

!> Returns various data that has been stored in a MOM_domain_type
subroutine redistribute_array_3d(Domain1, array1, Domain2, array2, complete)
type(domain2d), &
intent(in) :: Domain1 !< The MOM domain from which to extract information.
real, dimension(:,:,:), intent(in) :: array1 !< The array from which to extract information.
type(domain2d), &
intent(in) :: Domain2 !< The MOM domain receiving information.
real, dimension(:,:,:), intent(out) :: array2 !< The array receiving information.
logical, optional, intent(in) :: complete !< If true, finish communication before proceeding.

! Local variables
logical :: do_complete

do_complete=.true.;if (PRESENT(complete)) do_complete = complete

call mpp_redistribute(Domain1, array1, Domain2, array2, do_complete)

end subroutine redistribute_array_3d

end module MOM_domains

0 comments on commit bfdbe21

Please sign in to comment.