I usually deal with data file with multiple data block, repeating n number of lines for m number of times.
This is one of the example:
9276
4900000
AA 4 4 6260 519 8350 1571 0 0 0 0 0 0 0 0.934 0.933 0.93 0.935 0 0 0 0 0 0 3.867 0.0 1.541
BB 3 3 3388 8391 6637 0 0 0 0 0 0 0 0 0.939 0.565 0.361 0 0 0 0 0 0 0 1.913 2.0 -0.732
CC 3 2 241 694 0 0 0 0 0 0 0 0 0 0.933 0.941 0 0 0 0 0 0 0 0 1.888 2.0 -0.834
...
Top line is total number of line for data block, second line is other value, those two lines are header. Then following 9276 lines are data. One datablock has 9278 lines, and then the same format of datablock repeats from 9279 line, for m number of data block. Usually m become really huge.
So far, I use something like this using f77 format:
program test
parameter (nn = 20000)
integer,dimension(nn,nn) :: conn
integer,dimension(nn) :: aaa,bbb,ccc,ddd,eee
real,dimension(nn) :: fff,ggg,hhh,iii,zzz
real,dimension(nn,nn) :: bos
character*2,dimension(nn) :: elem
open (2, file = 'input.txt', status = 'old')
iframe=0
100 continue
iframe=iframe+1
read (2,15, err = 50,end= 50) nat2
read (2,15) framenum2
do i=1,nat2
read (2,42) elem(i),aaa(i),ccc(i),(conn(i,j),j=1,10),ddd(i),(bos(i,j),j=1,10),fff(i),ggg(i),zzz(i)
enddo
do something using do and if loops
write (120,15) nat2
write (120,15) framenum2
do i=1,nat
write (120,75) elem(i),test(i),result(i)
write (121,76) iframe, zzz2, iii2
enddo
goto 100
I don't need to write formats, they are all properly formatted. As you could see, my script reads data per each datablock, do something, print them, then go to next datablock.
I learned fortran so long time ago, and I didn't cared that much about my style, and didn't think I should learn new style. But these days I feels like I should be more familiar with newer style of fortran. I feel I'm bit too late to learn new language at this point (mostly due to time constraint) so I think I better stick to the fortran...
Anyway, I want to change this to f90 style. But I'm not sure where should I need to begin. How can I improve this style of declaration, open, read, and write to be more efficient and faster? Any suggestion about those? I prefer f90 style but if there are any newer fortran way, I will be interested (if it is freeware and compilable with f90 or intel fortran)