<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><font size="3">I Write the following&nbsp; MPI source file binding with c++, it is error ,why ? can anyone help me to fix it?</font><br><br>-----<br><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">void sumfunc(const void* x,void * y,int length,const MPI::Datatype &amp; dtype)</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">{</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; int n=dtype.Get_size();</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp;
 for(int i=0;i&lt;length;i++)</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *(y+n*i)=*(x+n*i)+*(y+n*i);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; return;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">}</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">void op_test(){</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida
 console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; MPI::Op mysum;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; mysum.Init(sumfunc,true);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; int unit=pow(MPI::COMM_WORLD.Get_size(),3);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; int result1,result2;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; MPI::COMM_WORLD.Reduce(&amp;unit,&amp;result1,1,MPI::INT,MPI::SUM,0);</span><br
 style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; MPI::COMM_WORLD.Reduce(&amp;unit,&amp;result2,1,MPI::INT,mysum,0);</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; if(unit==0)</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout&lt;&lt;"The results via sum&amp;mysum are "&lt;&lt;result1&lt;&lt;" , "&lt;&lt;result2&lt;&lt;endl;</span><br style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);"><span style="font-family: lucida console,sans-serif; color: rgb(0, 0, 255);">}</span><br><br><font size="3">Thank you very much!<br>&nbsp;</font></div><div><font
 size="2"><span style="font-family:tahoma, new york, times, serif;"><span style="font-family:tahoma, new york, times, serif;"></span>---<br>Kong Tao</span></font><font size="2"><br style="font-family:tahoma, new york, times, serif;"><span style="font-family:tahoma, new york, times, serif;">School of Maths,Shandong Univ. P.R.C.</span><br></font></div></div></body></html>