문제

I'm trying to create a progress indicator based on the total file size vs. file size read so far. I am working with a binary file.

open(unit=unitvector, file=vectorname, status='old',form='unformatted')
do while (ios.eq.0)
    read(unitvector,end=888,err=888, iostat=ios) KX, KY, KZ, KNAME, NV, NE, WEIGHT
    nkcount=nkcount+1
    call progress(FILE SIZE, PROGRESS SIZE)
    allocate( Vector(3,NV) )
    read(unitvector) (Vector(1,I),Vector(2,I),Vector(3,I),I=1,NV)
.
.
.
 end do

To compile i use:

ifort -warn all -traceback -free util.F fold2Bloch.f90 -o fold2Bloch

So every iteration of the loop I would call the subroutine progress and send the total file size and the size read so far. How can you find out the total size and size read so far? Or is there a better way to approach this progress indicator idea?

도움이 되었습니까?

해결책

To find the size (in bytes) of a file use the following:

inquire(unitvector, size=tot_len)

However, I still have no idea how to figure out what byte the pointer is at after a read() instruction.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top