在Fortran 90的阅读格式(Reading format in Fortran 90)

2019-09-22 07:07发布

我有一个巨大的文件读取其结构是:

 [...]
 (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,
 [...]

我感兴趣的阅读后的值“:”,它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

但我有一个forrtl: severe (64): input conversion error

Answer 1:

由于它出现的项目不列排队,这是棘手的与格式做。 我想接近它是这样的:

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

读每一行转换成字符串,找到结肠,然后使用表式IO处理冒号后的字符串中的数字值。



文章来源: Reading format in Fortran 90