<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.5726" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>
<DIV><FONT size=2>Hi,</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> I want to send a data as pointer type in C
to the other nodes. </FONT></DIV>
<DIV><FONT size=2>Is there any method to do so? I tried several times.
</FONT><FONT size=2>But failed. </FONT></DIV>
<DIV><FONT size=2>Thanks a lot. </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>PS: Purpose -- make a variable which can be read and
written by the other nodes.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>My code is attached below:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>#include <stdlib.h><BR>#include
<string.h><BR>#include "mpi.h"</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>int main(int argc,char *argv[])<BR>{<BR> int myid,
numprocs;<BR> <BR> double *ptr;<BR> double
Q[1];<BR> Q[0]=1.3;<BR> Q[1]=7.3;<BR> <BR> MPI_Init(&argc,&argv);<BR>
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);<BR>
MPI_Comm_rank(MPI_COMM_WORLD,&myid);<BR> <BR> if (myid == 0)
{<BR> <BR> ptr =
&Q;<BR> MPI_Bcast((void*)&ptr, 1, MPI_DOUBLE, 0,
MPI_COMM_WORLD);<BR> printf("\n");<BR> printf("sizeof
pointer %d\n", sizeof(ptr));<BR> printf("ptr has the value %p and is
stored at %p\n", ptr, (void*)&ptr);<BR> printf("The value of the
integer pointed to by ptr is %f\n", *ptr);<BR> printf("Second address
of ptr has the value %p and is valued at %f\n", ptr+1,
*(ptr+1));<BR> <BR> }<BR> else{<BR> <BR> MPI_Bcast(ptr,
1, MPI_DOUBLE, 0,
MPI_COMM_WORLD);<BR> printf("\n");<BR> printf("ptr has the
value %p and is stored at %p\n", ptr,
(void*)&ptr);<BR> printf("The value of the integer pointed to by
ptr is %f\n", *ptr);<BR> printf("Second address of ptr has the value
%p and is valued at %f\n", ptr+1, *(ptr+1));<BR> }</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> MPI_Finalize();<BR> return
0;<BR>}</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>With all my best wishes.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Yours, Dongping Liu</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Group M02<BR>State Key Laboratory of Magnetism<BR>Institute of
Physics<BR>Chinese Academy of Sciences<BR>P.O.Box 603, Beijing 100190, P. R.
China</FONT></DIV></FONT></DIV></BODY></HTML>