Find input file size in Fortran 90

有些话、适合烂在心里 提交于 2019-12-25 02:24:35

问题


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?


回答1:


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. Please help.



来源:https://stackoverflow.com/questions/23497529/find-input-file-size-in-fortran-90

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!