comms_allreduce_cmplx Subroutine

private subroutine comms_allreduce_cmplx(array, size, op)

Reduce complex data to all nodes

Arguments

Type IntentOptional AttributesName
complex(kind=dp), intent(inout) :: array
integer, intent(in) :: size
character(len=*), intent(in) :: op

Called by

proc~~comms_allreduce_cmplx~~CalledByGraph proc~comms_allreduce_cmplx comms_allreduce_cmplx interface~comms_allreduce comms_allreduce interface~comms_allreduce->proc~comms_allreduce_cmplx proc~dis_extract dis_extract proc~dis_extract->interface~comms_allreduce proc~wann_omega wann_omega proc~wann_omega->interface~comms_allreduce proc~wann_main wann_main proc~wann_main->proc~wann_omega proc~dis_main dis_main proc~dis_main->proc~dis_extract program~wannier wannier program~wannier->proc~wann_main program~wannier->proc~dis_main proc~wannier_run wannier_run proc~wannier_run->proc~wann_main proc~wannier_run->proc~dis_main

Contents

Source Code


Source Code

  subroutine comms_allreduce_cmplx(array, size, op)
    !! Reduce complex data to all nodes
    implicit none

    complex(kind=dp), intent(inout) :: array
    integer, intent(in)    :: size
    character(len=*), intent(in) :: op

#ifdef MPI
    integer :: error, ierr

    complex(kind=dp), allocatable :: array_red(:)

    allocate (array_red(size), stat=ierr)
    if (ierr /= 0) then
      call io_error('failure to allocate array_red in comms_allreduce_cmplx')
    end if

    select case (op)

    case ('SUM')
      call MPI_allreduce(array, array_red, size, MPI_double_complex, MPI_sum, mpi_comm_world, error)
    case ('PRD')
      call MPI_allreduce(array, array_red, size, MPI_double_complex, MPI_prod, mpi_comm_world, error)
    case default
      call io_error('Unknown operation in comms_allreduce_cmplx')

    end select

    call zcopy(size, array_red, 1, array, 1)

    if (error .ne. MPI_success) then
      call io_error('Error in comms_allreduce_cmplx')
    end if

    if (allocated(array_red)) deallocate (array_red)
#endif

    return

  end subroutine comms_allreduce_cmplx