Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

mpi function signature

Terry_Gerald
Beginner
1,312 Views

The MPI library is writtten in C and you may call these functions from Fortran.

Consider the MPI function MPI_Recv:


int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) Output Parameters buf initial address of receive buffer (choice) status status object (Status)

Input Parameters count maximum number of elements in receive buffer (integer) datatype datatype of each receive buffer element (handle) source rank of source (integer) tag message tag (integer) comm communicator (handle)
Did you see that void* pointer in the argument list?   Fortran doesn't have a void* type.
Intel Fortran doesn't appear to have (need?) a function interface definition for MPI.So how does the following work:(?)      Integer idim(100), jdim(100)      Real*8 xdim(100), ydim(100)      Call MPI_RECV(idim(n+1),1,MPI_INTEGER,n,n,MPI_COMM_WORLD,status,ierr)     ! #1
      Call MPI_RECV(xdim(n+1),1,MPI_DOUBLE,n,n,MPI_COMM_WORLD, status,ierr)    ! #2      Statement #1 receives integers while #2 receives doubles.
Look at the first argument (of variable type)  and the third argument ( a type selector).
How would you write an interface for a function with an argument that can be of multiple types?Does the Fortran compiler circumvent type checking when dealing with the MPI library?



0 Kudos
2 Replies
TimP
Honored Contributor III
1,312 Views

It's  considered good form to use the MPI header data types, to be certain you don't use one which isn't implemented or take the risk that the macro of you MPI expands to include indicator codes.....

It's the responsibility of the MPI library to work with the corresponding Fortran to handle those cases where an argument appears as a reference on the C++ side, for example, and relieve the programmer from using iso_c_binding.

If you have a data type clash which MPI objects to, it will throw a run time error.  Each MPI has its own data type codes.  I don't know of a case of magical run-time dynamic selection; you would have to write out the alternatives, e.g. using Fortran generic function machinery.

0 Kudos
Reply