<div dir="ltr"><font face="monospace">Recently, I have been writing mpi4py and Fortran 2008 MPI code (<a href="https://github.com/ParRes/Kernels/pull/592">https://github.com/ParRes/Kernels/pull/592</a>), which ends up looking quite similar except for 0-1 base indexing and MPI argument deduction.</font><div><font face="monospace"><br></font></div><div><font face="monospace">Numpy arrays behave a lot like Fortran arrays, including how they store size information in them.<br></font><div><font face="monospace"><br></font></div><div><font face="monospace">I wonder if it is reasonable to add this same argument inference to MPI Fortran.  If I pass an array argument with no type or size information, it should be inferred.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">The first inference is type.  There is no reason to ask users to specify MPI_DOUBLE_PRECISION when the argument is of type double precision.  Obviously, this only works for built-in types, but as that is the common case, why not do it?</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">The second inference is size.  If I pass A(100) to MPI_Bcast, why do I need to say MPI_Bcast(buf=A,count=100,...)?  The dope vector for A contains the 100 already.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">The hard part here seems to be needing 15 dimensions worth of interfaces, but those are trivial to generate.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Are there any hard problems here that I don't realize?</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Thanks,</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Jeff</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">PS code excerpts from the link above.  Named arguments would make Fortran even more similar.</font></div><div><font face="monospace"><br>for phase in range(0,np):<br>  recv_from = (me + phase ) % np<br>  send_to = (me - phase + np) % np<br>  lo = block_order * send_to<br>  hi = block_order * (send_to+1)<br>  comm.Sendrecv(sendbuf=A[lo:hi,:],dest=send_to,sendtag=phase,recvbuf=T,source=recv_from,recvtag=phase)<br>  lo = block_order * recv_from<br>  hi = block_order * (recv_from+1)<br>  B[lo:hi,:] += T.T</font><div><font face="monospace"><br></font></div><div><p class="MsoNormal" style="margin:0cm"><font face="monospace">do q=0,np-1</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  recv_from =
mod( (me + q     ), np)</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  send_to   = mod( (me - q + np), np)</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  lo =
block_order * send_to + 1</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  hi =
block_order * (send_to+1)</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  call
MPI_Sendrecv(A(:,lo:hi), block_order*block_order, MPI_DOUBLE_PRECISION,    &</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">                    send_to,q,                                                    &</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">                    T,block_order*block_order, MPI_DOUBLE_PRECISION,              &</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">                    recv_from, q, MPI_COMM_WORLD, MPI_STATUS_IGNORE)</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  lo =
block_order * recv_from + 1</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  hi =
block_order * (recv_from+1)</font></p>

<p class="MsoNormal" style="margin:0cm"><font face="monospace">  B(:,lo:hi) =
B(:,lo:hi) + transpose(T)</font></p><div><font face="monospace"><br></font></div><font face="monospace">-- <br></font><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><font face="monospace">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></font></div></div></div></div></div>