On Jun 28, 2005, at 5:58 AM, Davide Cesari wrote:
>> #include <stdio.h>
>> #include "mpi.h"
>> int main(int argc, char *argv[])
>> {
>> char greet[12];
>> int i, numprocs, myid;
>> MPI_Status status;
>> MPI_Init(&argc,&argv);
>> MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
>> MPI_Comm_rank(MPI_COMM_WORLD,&myid);
>> if(myid == 0)
>> {
>> sprintf(greet,"Hello world");
>> }
>> printf("%s from processor %d of %d.\n",&greet,myid,numprocs);
>> MPI_Finalize();
>> }
>
> Hi Stephan,
> Just a couple of suggestions to be sure it is not a C issue,
> before passing
> the problem to the (64 bit) Gurus:
>
> - The string greet should be initialized to something before printing
> also on
> processes other than 0 otherwise strange things may happen
Agreed. You could be getting unlucky since you're printf'ing a string
on all processes, even those where greet[] has not been initialized
everywhere. Hence, printf could be running past the end of greet[] and
into memory that does not belong to you (causing a seg fault), etc.
--
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/
|