Skip to content

Commit

Permalink
+Added read_variable and read_attribute to MOM_io
Browse files Browse the repository at this point in the history
  Added the new set of routines read_variable to do a simple read of an entire
array from a netCDF file with the root PE, and then broadcast this information
to the other PEs.  Also added read_attribute to read a global or variable
attribute.  The option to read dimension names was added to get_var_sizes, and
the option for get_varid to indicate whether a variable has been found. As a
part of this, separate variants of broadcast were added for 32-bit and 64-bit
integers, as were new variants of MOM_read_data for 1-d and 0-d integer fields.
All answers are bitwise identical, but there are new options and optional
arguments for overloaded interface, and there are two new overloaded interfaces
for reading.
  • Loading branch information
Hallberg-NOAA committed Feb 1, 2021
1 parent 199a453 commit 8c01d0e
Show file tree
Hide file tree
Showing 3 changed files with 476 additions and 51 deletions.
29 changes: 25 additions & 4 deletions src/framework/MOM_coms_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module MOM_coms_infra

!> Communicate an array, string or scalar from one PE to others
interface broadcast
module procedure broadcast_char, broadcast_int0D, broadcast_int1D
module procedure broadcast_char, broadcast_int32_0D, broadcast_int64_0D, broadcast_int1D
module procedure broadcast_real0D, broadcast_real1D, broadcast_real2D
end interface broadcast

Expand Down Expand Up @@ -129,8 +129,8 @@ subroutine broadcast_char(dat, length, from_PE, PElist, blocking)
end subroutine broadcast_char

!> Communicate an integer from one PE to others
subroutine broadcast_int0D(dat, from_PE, PElist, blocking)
integer, intent(inout) :: dat !< The data to communicate and destination
subroutine broadcast_int64_0D(dat, from_PE, PElist, blocking)
integer(kind=int64), intent(inout) :: dat !< The data to communicate and destination
integer, optional, intent(in) :: from_PE !< The source PE, by default the root PE
integer, optional, intent(in) :: PElist(:) !< The list of participating PEs, by default the
!! active PE set as previously set via Set_PElist.
Expand All @@ -146,7 +146,28 @@ subroutine broadcast_int0D(dat, from_PE, PElist, blocking)
call mpp_broadcast(dat, src_PE, PElist)
if (do_block) call mpp_sync_self(PElist)

end subroutine broadcast_int0D
end subroutine broadcast_int64_0D


!> Communicate an integer from one PE to others
subroutine broadcast_int32_0D(dat, from_PE, PElist, blocking)
integer(kind=int32), intent(inout) :: dat !< The data to communicate and destination
integer, optional, intent(in) :: from_PE !< The source PE, by default the root PE
integer, optional, intent(in) :: PElist(:) !< The list of participating PEs, by default the
!! active PE set as previously set via Set_PElist.
logical, optional, intent(in) :: blocking !< If true, barriers are added around the call

integer :: src_PE ! The processor that is sending the data
logical :: do_block ! If true add synchronizing barriers

do_block = .false. ; if (present(blocking)) do_block = blocking
if (present(from_PE)) then ; src_PE = from_PE ; else ; src_PE = root_PE() ; endif

if (do_block) call mpp_sync(PElist)
call mpp_broadcast(dat, src_PE, PElist)
if (do_block) call mpp_sync_self(PElist)

end subroutine broadcast_int32_0D

!> Communicate a 1-D array of integers from one PE to others
subroutine broadcast_int1D(dat, length, from_PE, PElist, blocking)
Expand Down
Loading

0 comments on commit 8c01d0e

Please sign in to comment.