LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2005-01-05 10:32:52


This is clearly a snipit from your program, and don't include enough
information as to what the problem is.

We also have a "we don't do student's homework" policy on this list:
a)it looks like this is a typical student assignment kind of MPI
program, b) you're mailing from a hotmail account, and c) you "badly"
need help, which implies that your homework is due soon. ;-)

Don't get me wrong -- I'm not trying to be a jerk, but those are three
things that we commonly see (both on- and off-list) when students are
trying to get help for their homework assignments. As an academic
myself, I'm a firm believer in the "the point of homework is to
struggle and learn" philosophy. :-)

Ok, off my soap box. Here's a few pointers that should get you going:

- It's not clear whether you are running gets() on just one MPI process
or all of them. You probably want to run it only one one process --
the one that gets stdin from mpirun (usually MPI_COMM_WORLD rank 0, but
whatever happens to be the lowest ranking process in MPI_COMM_WORLD on
the same node as mpirun).

- When you printf, does it include \n? Is the message automatically
flushed?

- Is the same process doing the receive as the send? If so, you *may*
run into blocking issues.

- Is msg an array of at least 10 characters long?

- Is recvmsg an array of at least 10 characters long?

- What buffer are you comparing before you call create()? (I'm
assuming that the receiver is supposed to create, not the sender)

Good luck.

On Jan 4, 2005, at 5:50 PM, Imran Ahmed khan wrote:

> Hi,
> I want to send Selected data.I wrote this program but it is not
> working.
>
> while(1)
> {
> gets(msg);
> if(strncmp(msg,"end",3)==0)
> MPI_Send(msg,10,MPI_CHAR,0,tag,MPI_COMM_WORLD);
> else
> printf("%s",msg);
>
> MPI_Recv(recvmsg,10,MPI_CHAR,0,tag,MPI_COMM_WORLD,&status);
> if(strcmp(msg,"") != 0)
> create(recvmsg,022);
>
> }
>
> This program should work like...if user input "end" then its send data
> otherwise it should print the input string. But it is neither writing
> input string nor sending the string.
> it is Stuck some where...

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/