ALL 0.9.3
A Loadbalacing Library
Loading...
Searching...
No Matches
read_output.cpp
Go to the documentation of this file.
1#include <stdlib.h>
2#include <iostream>
3#include <fstream>
4#include <sstream>
5#include <string>
6#include <vector>
7#include <numeric>
8#include <mpi.h>
9
10int main (int argc, char** argv)
11{
12 MPI_Init(&argc, &argv);
13
14 if (argc < 3)
15 {
16 std::cout << "usage: " << argv[0] << " <in_file (ASCII)> <n_p>" << std::endl;
17 MPI_Finalize();
18 exit(-1);
19 }
20
21 int n = atoi(argv[2]);
22
23 MPI_File infile;
24 int err;
25
26 err = MPI_File_open(
27 MPI_COMM_WORLD,
28 argv[1],
29 MPI_MODE_CREATE | MPI_MODE_RDWR,
30 MPI_INFO_NULL,
31 &infile
32 );
33
34 double positions[3];
35 long blockID;
36 long offset;
37 int n_part;
38
39 int blocksize = sizeof(long); // + 3 * sizeof(double);
40
41 for (int d = 0; d < n; ++d)
42 {
43 MPI_File_read_at(
44 infile,
45 (MPI_Offset)(d * sizeof(int)),
46 &n_part,
47 1,
48 MPI_INT,
49 MPI_STATUS_IGNORE
50 );
51 MPI_File_read_at(
52 infile,
53 (MPI_Offset)(n * sizeof(int) + d * sizeof(long)),
54 &offset,
55 1,
56 MPI_LONG,
57 MPI_STATUS_IGNORE
58 );
59 for (int p = 0; p < n_part; ++p)
60 {
61 MPI_File_read_at(
62 infile,
63 (MPI_Offset)(
64 offset +
65 p * blocksize
66 ),
67 &blockID,
68 1,
69 MPI_LONG,
70 MPI_STATUS_IGNORE
71 );
72 /*
73 MPI_File_read_at(
74 infile,
75 (MPI_Offset)(
76 offset +
77 p * blocksize +
78 sizeof(long)
79 ),
80 positions,
81 3,
82 MPI_DOUBLE,
83 MPI_STATUS_IGNORE
84 );
85 */
86 std::cout << "Rank: " << d
87 << " Offset: " << offset
88 << " N: " << n_part
89 << " Particle: " << p
90 << " ID: " << blockID
91 /*
92 << " Position: " << positions[0] << " "
93 << positions[1] << " "
94 << positions[2] << " "
95 */
96 << std::endl;
97 }
98 }
99
100 MPI_Finalize();
101}
int main(int argc, char **argv)