Fortran Coder

查看: 10719|回复: 9
打印 上一主题 下一主题

[文件读写] 多个文件合并的问题,有意思的探讨,图+代码+思路。

[复制链接]

46

帖子

8

主题

0

精华

熟手

F 币
211 元
贡献
131 点
楼主
发表于 2015-4-22 21:06:28 | 显示全部楼层
没有读懂你的问题。如果你文件的数据格式一样,只是长度不同,避免读取时end of file问题可以用fcode同学写的一个函数来设置do的长度:

前面加上
      Integer :: p,q,GetFileN

长度=GetFileN(打开的文件号)

      Integer function GetFileN(iFileUnit)
      implicit none
      logical , parameter :: b = .True.
      integer , intent( IN ) :: iFileUnit
      character(len=1) :: c
      GetFileN = 0
      Rewind( iFileUnit )
      Do while (b)
      Read( iFileUnit , * ,end =999 ,Err = 999 )c
      GetFileN = GetFileN + 1
      End Do
999   Rewind( iFileUnit )
      End function GetFileN

你的结果,应当参考最长的来设定。
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-19 06:24

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表