Question

I'm reading a binary file, direct access, in Fortran 90, and i'm trying to find out the pointer position. For that i use:

inquire(unitvector, pos=cur_pos)

But when i print the cur_pos it's always 0, even after i've read a substantial amount of the file. Why is it 0?

To compile i use:

$ ifort -warn all -traceback -free util.F fold2Bloch.f90 -o fold2Bloch
Was it helpful?

Solution

The variable used for the POS= specifier is defined only for a file connected with stream access, rather than the chosen direct access. 0 is a possible result in this case.

With direct access the position perhaps doesn't really have much general value: the point of such a connection is random access.

From the draft standard, section 9.10.2.22 (my emphasis):

The scalar-int-variable in the POS= specifier is assigned the number of the file storage unit immediately following the current position of a file connected for stream access. [..] If [..] the file is not connected for stream access [..] the variable becomes undefined

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top