1 ! This file created from test/mpi/f77/coll/reducelocalf.f with f77tof90
2 ! -*- Mode: Fortran; -*-
4 ! (C) 2009 by Argonne National Laboratory.
5 ! See COPYRIGHT in top-level directory.
8 ! Test Fortran MPI_Reduce_local with MPI_OP_SUM and with user-defined operation.
13 parameter (max_buf_size=65000)
14 integer vin(max_buf_size), vout(max_buf_size)
25 do while (count .le. max_buf_size )
30 call mpi_reduce_local( vin, vout, count, &
31 & MPI_INTEGER, MPI_SUM, ierr )
32 ! Check if the result is correct
34 if ( vin(ii) .ne. ii ) then
37 if ( vout(ii) .ne. 2*ii ) then
41 if ( count .gt. 0 ) then
48 call mpi_op_create( user_op, .false., myop, ierr )
51 do while (count .le. max_buf_size)
56 call mpi_reduce_local( vin, vout, count, &
57 & MPI_INTEGER, myop, ierr )
58 ! Check if the result is correct
60 if ( vin(ii) .ne. ii ) then
63 if ( vout(ii) .ne. 3*ii ) then
67 if ( count .gt. 0 ) then
74 call mpi_op_free( myop, ierr )
76 call mtest_finalize(errs)
77 call mpi_finalize(ierr)
81 subroutine user_op( invec, outvec, count, datatype )
83 integer invec(*), outvec(*)
84 integer count, datatype
87 if (datatype .ne. MPI_INTEGER) then
88 write(6,*) 'Invalid datatype passed to user_op()'
93 outvec(ii) = invec(ii) * 2 + outvec(ii)