|
Packit Service |
c5cf8c |
! This file created from test/mpi/f77/coll/red_scat_blockf.f with f77tof90
|
|
Packit Service |
c5cf8c |
! -*- Mode: Fortran; -*-
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! (C) 2012 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
! See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
! A simple test for Fortran support of Reduce_scatter_block
|
|
Packit Service |
c5cf8c |
! with or withoutMPI_IN_PLACE.
|
|
Packit Service |
c5cf8c |
!
|
|
Packit Service |
c5cf8c |
program main
|
|
Packit Service |
c5cf8c |
use mpi_f08
|
|
Packit Service |
c5cf8c |
integer MAX_SIZE
|
|
Packit Service |
c5cf8c |
parameter (MAX_SIZE=1024)
|
|
Packit Service |
c5cf8c |
integer sbuf(MAX_SIZE), rbuf(MAX_SIZE)
|
|
Packit Service |
c5cf8c |
integer rank, size
|
|
Packit Service |
c5cf8c |
TYPE(MPI_Comm) comm
|
|
Packit Service |
c5cf8c |
integer sumval, ierr, errs, i
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
errs = 0
|
|
Packit Service |
c5cf8c |
call mtest_init( ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
comm = MPI_COMM_WORLD
|
|
Packit Service |
c5cf8c |
call mpi_comm_rank( comm, rank, ierr )
|
|
Packit Service |
c5cf8c |
call mpi_comm_size( comm, size, ierr )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
do i = 1, size
|
|
Packit Service |
c5cf8c |
sbuf(i) = rank + (i-1)
|
|
Packit Service |
c5cf8c |
enddo
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call MPI_Reduce_scatter_block(sbuf, rbuf, 1, MPI_INTEGER, &
|
|
Packit Service |
c5cf8c |
& MPI_SUM, comm, ierr)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
sumval = size * rank + ((size-1) * size)/2
|
|
Packit Service |
c5cf8c |
if ( rbuf(1) .ne. sumval ) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, 'Reduce_scatter_block does not get expected value.'
|
|
Packit Service |
c5cf8c |
print *, '[', rank, ']', 'Got ', rbuf(1), ' but expected ', &
|
|
Packit Service |
c5cf8c |
& sumval, '.'
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
! Try MPI_IN_PLACE
|
|
Packit Service |
c5cf8c |
do i = 1, size
|
|
Packit Service |
c5cf8c |
rbuf(i) = rank + (i-1)
|
|
Packit Service |
c5cf8c |
enddo
|
|
Packit Service |
c5cf8c |
call MPI_Reduce_scatter_block(MPI_IN_PLACE, rbuf, 1, MPI_INTEGER, &
|
|
Packit Service |
c5cf8c |
& MPI_SUM, comm, ierr)
|
|
Packit Service |
c5cf8c |
if ( rbuf(1) .ne. sumval ) then
|
|
Packit Service |
c5cf8c |
errs = errs + 1
|
|
Packit Service |
c5cf8c |
print *, 'Reduce_scatter_block does not get expected value.'
|
|
Packit Service |
c5cf8c |
print *, '[', rank, ']', 'Got ', rbuf(1), ' but expected ', &
|
|
Packit Service |
c5cf8c |
& sumval, '.'
|
|
Packit Service |
c5cf8c |
endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
call mtest_finalize( errs )
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
end
|