Imagine summing the values of a variable var_to_be_summed via MPI_REDUCE to a buffer on root=0.
call MPI_REDUCE(var_to_be_summed, buffer, 1, MPI_REAL, MPI_SUM, root, MPI_COMM_WORLD, err)
According to MPICH the buffer is only significant on root. So in principle I could use any variable. For example in cases where the buffer is not natively present on the non-root ranks.
real :: dummy
if(rank==root) then
call MPI_REDUCE(var_to_be_summed, buffer, 1, MPI_REAL, MPI_SUM, root, MPI_COMM_WORLD, err)
else
call MPI_REDUCE(var_to_be_summed, dummy, 1, MPI_REAL, MPI_SUM, root, MPI_COMM_WORLD, err)
endif
My question is: Is there a nice/generic/standard way (in terms of portability, easy coding and reading) of giving a null-like argument to MPI routines with an "non significant" buffer on the non-root ranks.
I thought of replacing dummy in the code above with MPI_BOTTOM since it represents an address, but I am not sure about any side effects.
TL;DR:
Is there a variable supported by MPI that represents a "null" or "any" address like the generic tag MPI_ANY_TAG?