You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1153 lines
28 KiB
Fortran
1153 lines
28 KiB
Fortran
!
|
|
! Parallel Sparse BLAS version 3.5
|
|
! (C) Copyright 2006, 2010, 2015, 2017
|
|
! Salvatore Filippone Cranfield University
|
|
! Alfredo Buttari CNRS-IRIT, Toulouse
|
|
!
|
|
! Redistribution and use in source and binary forms, with or without
|
|
! modification, are permitted provided that the following conditions
|
|
! are met:
|
|
! 1. Redistributions of source code must retain the above copyright
|
|
! notice, this list of conditions and the following disclaimer.
|
|
! 2. Redistributions in binary form must reproduce the above copyright
|
|
! notice, this list of conditions, and the following disclaimer in the
|
|
! documentation and/or other materials provided with the distribution.
|
|
! 3. The name of the PSBLAS group or the names of its contributors may
|
|
! not be used to endorse or promote products derived from this
|
|
! software without specific written permission.
|
|
!
|
|
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
|
|
! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
! POSSIBILITY OF SUCH DAMAGE.
|
|
!
|
|
!
|
|
|
|
|
|
module psi_bcast_mod
|
|
use psb_const_mod
|
|
use psi_penv_mod
|
|
interface psb_bcast
|
|
module procedure psb_ibcasts, psb_ibcastv, psb_ibcastm,&
|
|
& psb_dbcasts, psb_dbcastv, psb_dbcastm,&
|
|
& psb_zbcasts, psb_zbcastv, psb_zbcastm,&
|
|
& psb_sbcasts, psb_sbcastv, psb_sbcastm,&
|
|
& psb_cbcasts, psb_cbcastv, psb_cbcastm,&
|
|
& psb_hbcasts, psb_hbcastv,&
|
|
& psb_lbcasts, psb_lbcastv
|
|
end interface psb_bcast
|
|
|
|
#if defined(LONG_INTEGERS)
|
|
interface psb_bcast
|
|
module procedure psb_ibcasts_ic, psb_ibcastv_ic, psb_ibcastm_ic,&
|
|
& psb_dbcasts_ic, psb_dbcastv_ic, psb_dbcastm_ic,&
|
|
& psb_zbcasts_ic, psb_zbcastv_ic, psb_zbcastm_ic,&
|
|
& psb_sbcasts_ic, psb_sbcastv_ic, psb_sbcastm_ic,&
|
|
& psb_cbcasts_ic, psb_cbcastv_ic, psb_cbcastm_ic,&
|
|
& psb_hbcasts_ic, psb_hbcastv_ic, &
|
|
& psb_lbcasts_ic, psb_lbcastv_ic
|
|
end interface psb_bcast
|
|
#else
|
|
interface psb_bcast
|
|
module procedure psb_i8bcasts, psb_i8bcastv, psb_i8bcastm
|
|
end interface psb_bcast
|
|
#endif
|
|
|
|
contains
|
|
|
|
! !!!!!!!!!!!!!!!!!!!!!!
|
|
!
|
|
! Broadcasts
|
|
!
|
|
! !!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
|
subroutine psb_ibcasts(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
integer(psb_ipk_), intent(inout) :: dat
|
|
integer(psb_ipk_), save :: dat_buf[*]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
!if (this_image()==1) print*,'-----------ibcasts'
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
!if (allocated(dat_buf)) deallocate(dat_buf)
|
|
!allocate(dat_buf(1)[*])
|
|
if (this_image() == root_ + 1) then
|
|
dat_buf=dat
|
|
endif
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
!if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_ibcasts
|
|
|
|
subroutine psb_ibcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
integer(psb_ipk_), intent(inout) :: dat(:)
|
|
integer(psb_ipk_), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
#if !defined(SERIAL_MPI)
|
|
!if (this_image()==1) print*,'-----------ibcastv'
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_ibcastv
|
|
|
|
subroutine psb_ibcastm(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
integer(psb_ipk_), intent(inout) :: dat(:,:)
|
|
integer(psb_ipk_), allocatable :: dat_buf(:,:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
!if (this_image()==1) print*,'-----------ibcastm'
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat,1),size(dat,2))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_ibcastm
|
|
|
|
|
|
subroutine psb_sbcasts(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
real(psb_spk_), intent(inout) :: dat
|
|
real(psb_spk_), allocatable :: dat_buf[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
#endif
|
|
end subroutine psb_sbcasts
|
|
|
|
|
|
subroutine psb_sbcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
real(psb_spk_), intent(inout) :: dat(:)
|
|
real(psb_spk_), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_sbcastv
|
|
|
|
subroutine psb_sbcastm(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
real(psb_spk_), intent(inout) :: dat(:,:)
|
|
real(psb_spk_), allocatable :: dat_buf(:,:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat,1),size(dat,2))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_sbcastm
|
|
|
|
|
|
subroutine psb_dbcasts(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
real(psb_dpk_), intent(inout) :: dat
|
|
real(psb_dpk_), allocatable :: dat_buf[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
if (this_image()==1) print*,'-----------dbcasts'
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
#endif
|
|
end subroutine psb_dbcasts
|
|
|
|
|
|
subroutine psb_dbcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
real(psb_dpk_), intent(inout) :: dat(:)
|
|
real(psb_dpk_), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
if (this_image()==1) print*,'-----------dbcastv'
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_dbcastv
|
|
|
|
subroutine psb_dbcastm(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
real(psb_dpk_), intent(inout) :: dat(:,:)
|
|
real(psb_dpk_), allocatable :: dat_buf(:,:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
if (this_image()==1) print*,'-----------dbcastm'
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat,1),size(dat,2))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_dbcastm
|
|
|
|
subroutine psb_cbcasts(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
complex(psb_spk_), intent(inout) :: dat
|
|
complex(psb_spk_), allocatable :: dat_buf[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
#endif
|
|
end subroutine psb_cbcasts
|
|
|
|
subroutine psb_cbcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
complex(psb_spk_), intent(inout) :: dat(:)
|
|
complex(psb_spk_), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_cbcastv
|
|
|
|
subroutine psb_cbcastm(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
complex(psb_spk_), intent(inout) :: dat(:,:)
|
|
complex(psb_spk_), allocatable :: dat_buf(:,:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat,1),size(dat,2))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_cbcastm
|
|
|
|
subroutine psb_zbcasts(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
complex(psb_dpk_), intent(inout) :: dat
|
|
complex(psb_dpk_), allocatable :: dat_buf[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
#endif
|
|
end subroutine psb_zbcasts
|
|
|
|
subroutine psb_zbcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
complex(psb_dpk_), intent(inout) :: dat(:)
|
|
complex(psb_dpk_), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_zbcastv
|
|
|
|
subroutine psb_zbcastm(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
complex(psb_dpk_), intent(inout) :: dat(:,:)
|
|
complex(psb_dpk_), allocatable :: dat_buf(:,:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf(size(dat,1),size(dat,2))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_zbcastm
|
|
|
|
|
|
subroutine psb_hbcasts(ictxt,dat,root,length)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
character(len=*), intent(inout) :: dat
|
|
character(len=:), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root,length
|
|
|
|
integer(psb_mpik_) :: iam, np, root_,length_,info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
if (present(length)) then
|
|
length_ = length
|
|
else
|
|
length_ = len(dat)
|
|
endif
|
|
|
|
if (.true.) then
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(character(length_) :: dat_buf(1)[*])
|
|
dat_buf(1)=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf(1)
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
else
|
|
call psb_info(ictxt,iam,np)
|
|
call mpi_bcast(dat,length_,MPI_CHARACTER,root_,ictxt,info)
|
|
endif
|
|
#endif
|
|
|
|
end subroutine psb_hbcasts
|
|
|
|
subroutine psb_hbcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
character(len=*), intent(inout) :: dat(:)
|
|
character(len=:), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_,length_,info, size_
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
length_ = len(dat)
|
|
size_ = size(dat)
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(character(length_) :: dat_buf(size_)[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
|
|
#endif
|
|
|
|
end subroutine psb_hbcastv
|
|
|
|
subroutine psb_lbcasts(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
logical, intent(inout) :: dat
|
|
logical, allocatable :: dat_buf[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_,info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
#endif
|
|
|
|
end subroutine psb_lbcasts
|
|
|
|
|
|
subroutine psb_lbcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
logical, intent(inout) :: dat(:)
|
|
logical, allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_,info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
allocate(dat_buf(size(dat))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
|
|
end subroutine psb_lbcastv
|
|
|
|
#if !defined(LONG_INTEGERS)
|
|
|
|
subroutine psb_i8bcasts(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
integer(psb_long_int_k_), intent(inout) :: dat
|
|
integer(psb_long_int_k_), allocatable :: dat_buf[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
allocate(dat_buf[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
#endif
|
|
end subroutine psb_i8bcasts
|
|
|
|
subroutine psb_i8bcastv(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
integer(psb_long_int_k_), intent(inout) :: dat(:)
|
|
integer(psb_long_int_k_), allocatable :: dat_buf(:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
allocate(dat_buf(size(dat))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_i8bcastv
|
|
|
|
subroutine psb_i8bcastm(ictxt,dat,root)
|
|
use psb_caf_mod
|
|
#ifdef MPI_MOD
|
|
use mpi
|
|
#endif
|
|
implicit none
|
|
#ifdef MPI_H
|
|
include 'mpif.h'
|
|
#endif
|
|
integer(psb_mpik_), intent(in) :: ictxt
|
|
integer(psb_long_int_k_), intent(inout) :: dat(:,:)
|
|
integer(psb_long_int_k_), allocatable :: dat_buf(:,:)[:]
|
|
integer(psb_mpik_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iam, np, root_, info
|
|
|
|
#if !defined(SERIAL_MPI)
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
|
|
allocate(dat_buf(size(dat,1),size(dat,2))[*])
|
|
dat_buf=dat
|
|
sync all
|
|
call co_broadcast(dat_buf,root_ + 1)
|
|
dat = dat_buf
|
|
if (allocated(dat_buf)) deallocate(dat_buf)
|
|
#endif
|
|
end subroutine psb_i8bcastm
|
|
|
|
#endif
|
|
|
|
|
|
#if defined(LONG_INTEGERS)
|
|
|
|
subroutine psb_ibcasts_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
integer(psb_ipk_), intent(inout) :: dat
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_ibcasts_ic
|
|
|
|
subroutine psb_ibcastv_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
integer(psb_ipk_), intent(inout) :: dat(:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_ibcastv_ic
|
|
|
|
subroutine psb_ibcastm_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
integer(psb_ipk_), intent(inout) :: dat(:,:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_ibcastm_ic
|
|
|
|
|
|
subroutine psb_sbcasts_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
real(psb_spk_), intent(inout) :: dat
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_sbcasts_ic
|
|
|
|
|
|
subroutine psb_sbcastv_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
real(psb_spk_), intent(inout) :: dat(:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_sbcastv_ic
|
|
|
|
subroutine psb_sbcastm_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
real(psb_spk_), intent(inout) :: dat(:,:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_sbcastm_ic
|
|
|
|
|
|
subroutine psb_dbcasts_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
real(psb_dpk_), intent(inout) :: dat
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_dbcasts_ic
|
|
|
|
|
|
subroutine psb_dbcastv_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
real(psb_dpk_), intent(inout) :: dat(:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_dbcastv_ic
|
|
|
|
subroutine psb_dbcastm_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
real(psb_dpk_), intent(inout) :: dat(:,:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_dbcastm_ic
|
|
|
|
subroutine psb_cbcasts_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
complex(psb_spk_), intent(inout) :: dat
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_cbcasts_ic
|
|
|
|
subroutine psb_cbcastv_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
complex(psb_spk_), intent(inout) :: dat(:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_cbcastv_ic
|
|
|
|
subroutine psb_cbcastm_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
complex(psb_spk_), intent(inout) :: dat(:,:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_cbcastm_ic
|
|
|
|
subroutine psb_zbcasts_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
complex(psb_dpk_), intent(inout) :: dat
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_zbcasts_ic
|
|
|
|
subroutine psb_zbcastv_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
complex(psb_dpk_), intent(inout) :: dat(:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_zbcastv_ic
|
|
|
|
subroutine psb_zbcastm_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
complex(psb_dpk_), intent(inout) :: dat(:,:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_zbcastm_ic
|
|
|
|
|
|
subroutine psb_hbcasts_ic(ictxt,dat,root,length)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
character(len=*), intent(inout) :: dat
|
|
integer(psb_ipk_), intent(in), optional :: root,length
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_hbcasts_ic
|
|
|
|
subroutine psb_hbcastv_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
character(len=*), intent(inout) :: dat(:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_hbcastv_ic
|
|
|
|
subroutine psb_lbcasts_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
logical, intent(inout) :: dat
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_lbcasts_ic
|
|
|
|
|
|
subroutine psb_lbcastv_ic(ictxt,dat,root)
|
|
implicit none
|
|
integer(psb_ipk_), intent(in) :: ictxt
|
|
logical, intent(inout) :: dat(:)
|
|
integer(psb_ipk_), intent(in), optional :: root
|
|
|
|
integer(psb_mpik_) :: iictxt, root_
|
|
|
|
iictxt = ictxt
|
|
if (present(root)) then
|
|
root_ = root
|
|
else
|
|
root_ = psb_root_
|
|
endif
|
|
call psb_bcast(iictxt,dat,root_)
|
|
end subroutine psb_lbcastv_ic
|
|
#endif
|
|
|
|
|
|
end module psi_bcast_mod
|