在Fortran 90中读取格式 [英] Reading format in Fortran 90

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

问题描述

  [...] 
(0, 0,0,0,0):5.00634e-33,5.59393e-33,6.24691e-33,7.29338e-33,
(0,0,0,0,4):7.77607e-33, 8.95879e-33,9.65316e-33,1.07434e-32,
(0,0,0,0,8):1.20824e-32,1.334983e-32,1.49987e-32,1.73061e-32 ,
(0,0,0,0,12):1.919e-32,2.15391e-32,2.3996e-32,2.67899e-32,
[...]

我有兴趣阅读<:c $ c> format 我应该在读语句中使用,如果我使用Fortran90?



我已经试过

  read(1,'((,I6,,,I6,,,I6,,,I6,,,I6,): F10.4,F10.4,F10.4,F10.4)')idx1,idx2,idx3,idx4,idx5,dummy1,dummy2,dummy3,dummy4 
$ b $但是我得到了一个 forrtl:severe(64):输入转换错误


<由于看起来这些项目不在列中排列,所以对于格式来说这是非常棘手的。我会这样处理:

$ $ p $ read(55,'(A)')string
colon_pos = index (string,:)
read(string(colon_pos + 1:len_string),*)real1,real2,real3,real4

将每行读入一个字符串,找到冒号,然后使用列表控制的IO来处理冒号后面的字符串中的数字值。


I have a huge file to read whose structure is:

 [...]
 (0,0,0,0,0): 5.00634e-33, 5.59393e-33, 6.24691e-33, 7.29338e-33,
 (0,0,0,0,4): 7.77607e-33, 8.95879e-33, 9.65316e-33, 1.07434e-32,
 (0,0,0,0,8): 1.20824e-32, 1.34983e-32, 1.49877e-32, 1.73061e-32,
 (0,0,0,0,12): 1.919e-32, 2.15391e-32, 2.3996e-32, 2.67899e-32,
 [...]

I'm interested in reading the value after ":", which format should I use in the read statement if I use Fortran90?

I've tried with

 read(1,'("(",I6,",",I6,",",I6,",",I6,",",I6,"):",F10.4,F10.4,F10.4,F10.4)')idx1,idx2,idx3,idx4,idx5,dummy1,dummy2,dummy3,dummy4

But I got a forrtl: severe (64): input conversion error

解决方案

Since it appears that the items don't line up in columns this is tricky to do with formats. I'd approach it this way:

read (55, '(A)')  string
colon_pos = index (string, ":")
read (string (colon_pos+1:len_string), * ) real1, real2, real3, real4

read each line into a string, locate the colon, then use list-directed IO to process the numeric values in the string after the colon.

这篇关于在Fortran 90中读取格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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