xref: /phasta/phSolver/common/test/phIOreadIlwork.cc (revision 560e081f137c5df861ce8be72b5bbca3320849a0)
1 #include <mpi.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include "phIO.h"
6 #include "posixio.h"
7 #include "phio_posix.h"
8 
9 int main(int argc, char* argv[]) {
10   MPI_Init(&argc,&argv);
11   if( argc != 2 ) {
12     fprintf(stderr, "Usage: %s <geombc posix file>\n",argv[0]);
13     MPI_Finalize();
14     return 1;
15   }
16   const char* filename = argv[1];
17   const char* phrase = "ilwork";
18   const char* type = "integer";
19   const char* iotype = "binary";
20   int* ilwork = NULL;
21   int len = 0;
22   int one = 2;
23 
24   phio_fp file;
25   posixio_setup(&(file), 'r');
26   posix_openfile_single(filename, file);
27   phio_readheader(file, phrase, &len, &one, type, iotype);
28   fprintf(stderr, "len %d\n", len);
29   ilwork = (int*) malloc(len*sizeof(int));
30   phio_readdatablock(file, phrase, ilwork, &len, type, iotype);
31   phio_closefile(file);
32   free(ilwork);
33 
34   MPI_Finalize();
35   return 0;
36 }
37