Fortran 90 Reading Format

I have a huge read file 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 am interested in reading the value after the ":", which format should be used in the read statement if I use Fortran90?

I 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 forrtl: severe (64): input conversion error

+4
source share
1 answer

Since the elements seem to not align in the columns, this is difficult to do with the formats. I would go like this:

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

read each line in the line, find the colon, then use list-driven IO to process the numeric values ​​in the line after the colon.

+10
source

Source: https://habr.com/ru/post/1433392/


All Articles