$subject_val = "[OMPI users] MPI-IO: reading an unformatted binary fortran file"; include("../../include/msg-header.inc"); ?>
Subject: [OMPI users] MPI-IO: reading an unformatted binary fortran file
From: Greg Fischer (greg.a.fischer_at_[hidden])
Date: 2009-06-11 17:33:58
Hello,
I'm attempting to wrap my brain around the MPI I/O mechanisms, and I was
hoping to find some guidance. I'm trying to read a file that contains a
117-character string, followed by a series records that contain integers and
reals. The following code would read it in serial:
--- character(len=117) :: cfx1 read (nin) cfx1 do i=1,end_of_file read(nin) integer1,integer2,real1,real2,real3,real4,real5,real6,real7 enddo --- To simplify the problem, I removed the "cfx1" string from the file I'm reading, and created an MPI_TYPE_STRUCT as follows: --- length( 1 ) = 1 length( 2 ) = 2 length( 3 ) = 7 length( 3 ) = 1 disp( 1 ) = 0 disp( 2 ) = sizeof( MPI_LB ) disp( 3 ) = disp( 2 ) + 2*sizeof(MPI_INTEGER) disp( 4 ) = disp( 3 ) + 7*sizeof(MPI_REAL) type( 1 ) = MPI_LB type( 2 ) = MPI_INTEGER type( 3 ) = MPI_REAL type( 4 ) = MPI_UB call MPI_TYPE_STRUCT( 4, length, disp, type, sptype, ierr ) call MPI_TYPE_COMMIT( sptype, ierr ) --- I then open the file, set the view as follows and try to do a read: --- mode = MPI_MODE_RDONLY call MPI_FILE_OPEN( MPI_COMM_WORLD, filename, mode, + MPI_INFO_NULL, fh, ierr ) offset = 0 call MPI_FILE_SET_VIEW( fh, offset, sptype, + sptype, 'native', MPI_INFO_NULL, ierr ) call MPI_FILE_READ( fh, sourcepart, 1, sptype, + status, ierr ) --- where "sourcepart" is: --- type source_particle_datatype integer :: ipt,idm real :: xxx,yyy,zzz,uuu,vvv,www,erg end type --- This almost works. With some fiddling (I can't seem to make it work right now), I'm able to get most of the reals and integers into "sourcepart", but something doesn't line up quite correctly. I've spent a lot of time looking at the documentation and tutorials on the web, but haven't found a resource that helps me work through this problem. Ultimately, the objective will be to allow an arbitrary number of processes read this file, with each record being uniquely read by a single process. (e.g. process 1 read record 1, process 2 reads record 2, process 1 reads record 3, process 2 reads record 4, etc.) What's the best way to skin this cat? Any assistance would be greatly appreciated. Thanks, Greg