在Fortran 90中查找输入文件大小

问题描述 投票:0回答:1

我正在尝试根据目前为止读取的文件总大小与文件大小创建进度指示器。我正在使用二进制文件。

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

编译我使用:

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

所以循环的每次迭代我都会调用子例程progress并发送到目前为止读取的总文件大小和大小。你怎么能找到到目前为止读取的总大小和大小?或者有更好的方法来实现这一进度指标的想法吗?

fortran progress-bar fortran90 filesize
1个回答
0
投票

要查找文件的大小(以字节为单位),请使用以下命令:

inquire(unitvector, size=tot_len)

但是,我仍然不知道如何在read()指令之后找出指针所在的字节。请帮忙。

© www.soinside.com 2019 - 2024. All rights reserved.