Mpif90 gfortran strange warning for mpi subroutines: 'Rank mismatch between actual argument...'

I think what is happening is that the compiler is generating interfaces to the called subrouitine internally, and using that interface to compare multiple calls to the subroutine. So whichever call it sees first effectively defines the interface, and then any subsequent calls are compared to that. In your case, one call has a scalar argument and the other call has an array argument. If only one call exists, then no problem, it is only when multiple calls are there that the inconsistency is detected. One solution is to change the scalar argument to an array with one element, c(1). Then the interface that is generated internally will be consistent. If the dummy argument is an array, which it almost certainly is, then that will also bring your code into conformance with the language. Your call with the scalar argument would also have been detected as an error if you had an explicit interface to that subroutine, either from an interface block or from a module procedure.

1 Like