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