xref: /phasta/phSolver/common/test/phIOposixMultiTopo.cc (revision 103be4246587c2bbc935c942957c29d1ff752010)
1 #include <mpi.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include "phIO.h"
6 #include "syncio.h"
7 #include "posixio.h"
8 #include <assert.h>
9 
10 int main(int argc, char* argv[]) {
11   MPI_Init(&argc,&argv);
12   int rank;
13   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
14   const char* iotype = "binary";
15   int seven = 7;
16   int headerData[7] = {0,0,0,0,0,0,0};
17   int blocksRead = 0;
18   phio_fp file;
19   posixio_setup(&file, 'r');
20   phio_openfile("geombc.dat.", file);
21   for(int i=0;i<2;i++) {
22     phio_readheader(file, "connectivity interior",
23         headerData, &seven, "integer", iotype);
24     assert(headerData[0] > 0 && headerData[3] > 0);
25     int size = headerData[0]*headerData[3]; /* neltp*nshl */
26     fprintf(stderr, "rank %d data[0] %d\n", rank, headerData[0]);
27     int* vals = (int*) calloc(size,sizeof(int));
28     phio_readdatablock(file,"connectivity interior",vals,&size,"integer",iotype);
29     free(vals);
30     blocksRead += (headerData[0] > 0);
31   }
32   phio_closefile(file);
33   MPI_Barrier(MPI_COMM_WORLD);
34   fprintf(stderr, "rank %d number of blocks read %d\n", rank, blocksRead);
35   MPI_Finalize();
36   return (blocksRead==2);
37 }
38