在Fortran 90中查找输入文件的大小 [英] Find input file size in Fortran 90

查看:145
本文介绍了在Fortran 90中查找输入文件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据文件总大小与到目前为止读取的文件大小创建一个进度指示器.我正在处理二进制文件.

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

要编译,我使用:

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

因此,循环的每次迭代都将调用子例程progress,并发送文件总大小和到目前为止读取的大小.您如何找出总大小和到目前为止读取的大小?还是有更好的方法来处理进度指示器的想法?

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)

但是,我仍然不知道如何在read()指令后找出指针位于哪个字节.

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

这篇关于在Fortran 90中查找输入文件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆