1*5be7d1a3SCameron Smith program readheaderFtn 2*5be7d1a3SCameron Smith use iso_c_binding 3*5be7d1a3SCameron Smith use phio 4*5be7d1a3SCameron Smith include "mpif.h" 5*5be7d1a3SCameron Smith 6*5be7d1a3SCameron Smith integer :: rank, ierror, one, ppf, peers, fish 7*5be7d1a3SCameron Smith type(c_ptr) :: handle 8*5be7d1a3SCameron Smith character(len=30) :: dataDbl, iotype 9*5be7d1a3SCameron Smith character(len=256) :: phrase 10*5be7d1a3SCameron Smith character(len=256), dimension(2) :: fname 11*5be7d1a3SCameron Smith integer, dimension(2) :: nfiles, fishweight, numFish 12*5be7d1a3SCameron Smith 13*5be7d1a3SCameron Smith call MPI_Init(ierror) 14*5be7d1a3SCameron Smith call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierror) 15*5be7d1a3SCameron Smith call MPI_Comm_size(MPI_COMM_WORLD, peers, ierror) 16*5be7d1a3SCameron Smith 17*5be7d1a3SCameron Smith phrase = c_char_"number of fishes"//c_null_char 18*5be7d1a3SCameron Smith dataDbl = c_char_"double"//c_null_char 19*5be7d1a3SCameron Smith iotype = c_char_"binary"//c_null_char 20*5be7d1a3SCameron Smith one = 1 21*5be7d1a3SCameron Smith fish = 2 22*5be7d1a3SCameron Smith 23*5be7d1a3SCameron Smith fishweight(1) = 1.23 24*5be7d1a3SCameron Smith fishweight(2) = 1.23 25*5be7d1a3SCameron Smith 26*5be7d1a3SCameron Smith fname(1) = c_char_"fortranWater-dat."//c_null_char 27*5be7d1a3SCameron Smith fname(2) = c_char_"fortranWater.dat."//c_null_char 28*5be7d1a3SCameron Smith nfiles(1) = 2 29*5be7d1a3SCameron Smith nfiles(2) = 1 30*5be7d1a3SCameron Smith ppf = peers/nfiles(1) 31*5be7d1a3SCameron Smith do i=1,2 32*5be7d1a3SCameron Smith call phio_openfile_write(fname(i), nfiles(i), one, ppf, handle) 33*5be7d1a3SCameron Smith call phio_writeheader(handle, phrase, c_loc(fish), one, one, 34*5be7d1a3SCameron Smith & dataDbl, iotype) 35*5be7d1a3SCameron Smith call phio_writedatablock(handle, phrase, c_loc(fishweight(i)), 36*5be7d1a3SCameron Smith & one, dataDbl, iotype) 37*5be7d1a3SCameron Smith call phio_closefile_write(handle) 38*5be7d1a3SCameron Smith end do 39*5be7d1a3SCameron Smith do i=1,2 40*5be7d1a3SCameron Smith call phio_openfile_read(fname(i), nfiles(i), handle) 41*5be7d1a3SCameron Smith call phio_readheader(handle, phrase, c_loc(numFish(i)), 42*5be7d1a3SCameron Smith & one, dataDbl, iotype) 43*5be7d1a3SCameron Smith call phio_readdatablock(handle, phrase, c_loc(fishweight(i)), 44*5be7d1a3SCameron Smith & one, dataDbl, iotype) 45*5be7d1a3SCameron Smith call phio_closefile_read(handle) 46*5be7d1a3SCameron Smith end do 47*5be7d1a3SCameron Smith if( numFish(1) .ne. numFish(2) .or. 48*5be7d1a3SCameron Smith & fishweight(1) .ne. fishweight(2) ) then 49*5be7d1a3SCameron Smith write (*,*) "fish don\'t match" 50*5be7d1a3SCameron Smith stop 1 51*5be7d1a3SCameron Smith end if 52*5be7d1a3SCameron Smith call MPI_Finalize(ierror) 53*5be7d1a3SCameron Smith end 54