Hi,
I executed this programas and this is not working. My output error was:
[campogrande27:05794] *** Process received signal ***
[campogrande27:05794] Signal: Segmentation fault (11)
[campogrande27:05794] Signal code: Address not mapped (1)
[campogrande27:05794] Failing at address: 0x46
[campogrande27:05794] [ 0] [0xffffe440]
[campogrande27:05794] [ 1]
/lib/tls/i686/cmov/libc.so.6(_IO_fprintf+0x22) [0xb7d45902]
[campogrande27:05794] [ 2] helloMPI2(main+0x16d) [0x8048a41]
[campogrande27:05794] [ 3]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0) [0xb7d15050]
[campogrande27:05794] [ 4] helloMPI2 [0x8048871]
[campogrande27:05794] *** End of error message ***
mpiexec noticed that job rank 0 with PID 5794 on node campogrande27
exited on signal 11 (Segmentation fault).
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <string.h>
>> #include "mpi.h"
>>
>> int main(int argc, char** argv) {
>> int my_rank; /* Rank of process */
>> int p; /* Number of processes */
>> int source; /* Rank of sender */
>> int dest; /* Rank of receiver */
>> int tag = 50; /* Tag for messages */
>> char message[100]; /* Storage for the message */
>> char new_string[100];
>> MPI_Status status; /* Return status for receive */
>> MPI_Init(&argc, &argv);
>> MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
>> MPI_Comm_size(MPI_COMM_WORLD, &p);
>>
>> FILE *pfile;
>>
>> if (my_rank != 0) {
>> sprintf(message, "Greetings from process %d!", my_rank);
>> dest = 0;
>> //pfile = fopen("/mnt/pvfs2/teste.txt","w");
>> /* Use strlen(message)+1 to include '\0' */
>> MPI_Send(message, strlen(message)+1, MPI_CHAR, dest,
>> tag,MPI_COMM_WORLD);
>>
>> } else { /* my_rank == 0 */
>> pfile = fopen("/mnt/pvfs2/teste.txt","a+");
>> for (source = 1 ; source < p ; source++)
>> {
>> MPI_Recv(message, 100, MPI_CHAR, source, tag,MPI_COMM_WORLD,
>> &status);
>> fprintf(pfile,"%s\n", message);
>> }
>> fclose(pfile);
>> }
>>
>> MPI_Finalize();
>>
>> return 0;
>> } /* main */
>>
>> Try it. Good luck...
--
Davi Vercillo Carneiro Garcia
Universidade Federal do Rio de Janeiro
Departamento de Ciência da Computação
DCC-IM/UFRJ - http://www.dcc.ufrj.br
"Good things come to those who... wait." - Debian Project
"A computer is like air conditioning: it becomes useless when you open
windows." - Linus Torvalds
"Há duas coisas infinitas, o universo e a burrice humana. E eu estou
em dúvida quanto o primeiro." - Albert Einstein
_______________________________________________
Pvfs2-users mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-users