Clarification needed on EOF/file pointer update

Parkson Wong (parkson@nas.nasa.gov)
Mon, 12 May 1997 09:36:13 -0700 (PDT)

Hi:

I have a question on EOF and file pointer update, for instance,

Case 1:
etype is a real, buftype is a contiguous of 2 reals, the file (or view)
has 3 reals in it, file pointer is pointing to the beginning of the
file. The program attemp a read of 2 buftype. What is the right answer?
MPI_File_read(fh, buf, 2, buftype, &status)

1) Read everything that is possible. 3 reals filled in buf
file pointer updated to 3 (3 etypes (real))
MPI_Get_count(status, buftype, &count) will set count to MPI_UNDEFINED
MPI_Get_element(status, buftype, &count) will set count to 3.

This is consistent with MPI-1 on receive as described in the section
MPI_Get_element.

2a) Only allow integral number of etype read. 3 reals filled in buf
Same as 1, since etype is a basic type.

2b) Only allow integral number of buftype read. Only 2 reals filled in buf.
file pointer updated to 2
MPI_Get_count will set count to 2.
MPI_Get_element will set count to 2.

Now onto a more unnatural case (case 2):
etype is 2 reals
buttype is 4 reals
there is 7 reals in the file
file pointer pointing the beginning of the file
MPI_File_read(fh, buf, 2, buftype, &status)

1) Read everything that is possible. 5 reals filled in buf
MPI_Get_count(status, buftype, &count) will set count to MPI_UNDEFINED
MPI_Get_element(status, buftype, &count) will set count to 7.
file pointer updated to 4 (4 etypes (8 real)) and leave a hole in the file.

2a) Only allow integral number of etype read. Only 6 reals filled in buf
MPI_Get_count(status, buftype, &count) will set count to MPI_UNDEFINED
MPI_Get_element(status, buftype, &count) will set count to 6.
file pointer updated to 3 (3 etypes (6 real))

2b) Only allow integral number of buftype read. Only 4 reals filled in buf.
MPI_Get_count will set count to 1.
MPI_Get_element will set count to 4.
file pointer updated to 2

In case 1, the clear winning choice is 1 or 2a (they are equivalent).

In case 2, the choice is less obvious. 1 leaves a hole in the file (not
a desirable feature, we tried hard to eliminate that). 2a or 2b doesn't
return all the data in the file. I think 2a is more consistent with MPI-1
then 2b. Or we could make 1 in case 2 erroneous since we defined read
as in multiple of etypes.

-- parkson

-- 
Parkson Wong			Address: Numerical Aerodynamic Simulation
MRJ, Inc.				 NASA Ames Research Center M/S 258-6
Supercomputer Applications Segment	 Moffett Field, CA  94035-1000
e-mail: parkson@nas.nasa.gov	Phone: (415)604-3988	Fax: (415)966-8669