简体   繁体   English

Fortran:从字符串中读取数字数据

[英]Fortran: read numeric data from string

I've already checked a similarly existing topic ( How to read numeric data from a string in FORTRAN ), but I'm not being able to do what I want. 我已经检查了一个类似的现有主题( 如何从FORTRAN中的字符串中读取数字数据 ),但是我无法做我想做的事情。

I need to open a file and read a numeric value from a string. 我需要打开一个文件并从字符串中读取一个数值。 Bellow there's a section of the file in question. 在下面的文件中有一部分。 I want to read the integer next to 'ELEMENTS:', but so far I'm not being able to do so. 我想读取“ ELEMENTS:”旁边的整数,但到目前为止,我还无法读取。

      ELEMENT GROUP 2.4.6
GROUP:          1 ELEMENTS:     187169 MATERIAL:          2 NFLAGS:          1
                           fluid
       0
       1       2       3       4       5       6       7       8       9      10
      11      12      13      14      15      16      17      18      19      20
      21      22      23      24      25      26      27      28      29      30
      31      32      33      34      35      36      37      38      39      40

Can someone please help me here? 有人可以在这里帮我吗?

Ok guys, thanks to your answers the program is working! 好的,感谢您的回答,程序正在运行!

For further reference, here's the reading part of the code: 作为进一步的参考,这是代码的阅读部分:

READ(77,'(A)') str
ipos = INDEX(str,"ELEMENTS:",back=.true.) + 9
READ (str(1+ipos:),*) k
PRINT*, k

Thank for the answers. 感谢您的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM