Advertisement
Lubino41

Untitled

Nov 25th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1.  
  2.  
  3. #include <stdio.h>
  4. #include <mpi.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. int main(int argc, char * argv[])
  8. {
  9.  
  10. int noProcesses, processId;
  11.  
  12. int ch = 0 ,c = 0, number_of_lines = 0; //number_of_lines = -1;
  13. static const char filename[] = "buu.txt";
  14.  
  15.  
  16.  
  17.  
  18.  
  19. MPI_Init(&argc, &argv);
  20. MPI_Comm_size(MPI_COMM_WORLD, &noProcesses);
  21. MPI_Comm_rank(MPI_COMM_WORLD, &processId);
  22. FILE *file = fopen ( filename, "r" );
  23. int pocetriadkov = 0;
  24.  
  25. if ( file != NULL )
  26. {
  27. char line [512]; /* or other suitable maximum line size */
  28. while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
  29. {
  30. pocetriadkov++;
  31.  
  32. }
  33. fclose ( file );
  34. printf("pocet riadkov suboru je: %d ", pocetriadkov);
  35. }
  36.  
  37.  
  38. else
  39. {
  40. perror ( filename ); /* why didn't the file open? */
  41. }
  42.  
  43. MPI_Finalize();
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement