Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mpas_dmpar_bcast_real4s routine for broadcasting real(kind=R4KIND) arrays #1207

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all 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
41 changes: 41 additions & 0 deletions src/framework/mpas_dmpar.F
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module mpas_dmpar
public :: mpas_dmpar_bcast_ints
public :: mpas_dmpar_bcast_real
public :: mpas_dmpar_bcast_reals
public :: mpas_dmpar_bcast_real4s
public :: mpas_dmpar_bcast_double
public :: mpas_dmpar_bcast_doubles
public :: mpas_dmpar_bcast_logical
Expand Down Expand Up @@ -551,6 +552,46 @@ subroutine mpas_dmpar_bcast_reals(dminfo, n, rarray, proc)!{{{

end subroutine mpas_dmpar_bcast_reals!}}}

!-----------------------------------------------------------------------
! routine mpas_dmpar_bcast_real4s
!
!> \brief MPAS dmpar broadcast R4KIND routine.
!> \author Michael Duda, William Lipscomb
!> \date 8 July 2024
!> \details
!> This routine broadcasts an array of R4KIND reals to all processors in
!> the communicator. An optional argument specifies the source node; else
!> broadcast from IO_NODE.
!
!-----------------------------------------------------------------------
subroutine mpas_dmpar_bcast_real4s(dminfo, n, rarray, proc)!{{{

implicit none

type (dm_info), intent(in) :: dminfo !< Input: Domain information
integer, intent(in) :: n !< Input: Length of array
real (kind=R4KIND), dimension(n), intent(inout) :: rarray !< Input/Output: Array of reals to be broadcast
integer, intent(in), optional :: proc !< optional argument indicating which processor to broadcast from

#ifdef _MPI
integer :: mpi_ierr, source
integer :: threadNum

threadNum = mpas_threading_get_thread_num()

if ( threadNum == 0 ) then
if (present(proc)) then
source = proc
else
source = IO_NODE
endif

call MPI_Bcast(rarray, n, MPI_REAL, source, dminfo % comm, mpi_ierr)
end if
#endif

end subroutine mpas_dmpar_bcast_real4s!}}}

!-----------------------------------------------------------------------
! routine mpas_dmpar_bcast_double
!
Expand Down