简体   繁体   中英

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.

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.

      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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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