For example, to create an operation that has the same effect as
MPI_SUM on Fortran double precision values, use
subroutine myfunc( invec, inoutvec, len, datatype ) integer len, datatype double precision invec(len), inoutvec(len) integer i do 10 i=1,len 10 inoutvec(i) = invec(i) + inoutvec(i) return endTo use, just
integer myop call MPI_Op_create( myfunc, .true., myop, ierr ) call MPI_Reduce( a, b, 1, MPI_DOUBLE_PRECISON, myop, ... )The routine MPI_Op_free destroys user-functions when they are no longer needed.