Just read each line as a string using a
descriptor and then you can read your data using a list-directed read (*
instead of the format). Or you can use the list directed read directly, if there is no danger of reading from two lines at once.
integer :: tmp1,tmp2
character(5) :: tmp3
character(2) :: tmp4
real :: values(3)
open(12,file="data.txt")
do j = 1,4
read(12,*) tmp1, tmp2, tmp3, values(1), values(2), tmp4, values(3)
print *,values
end do
close(12)
end
prints
52.3878326 13.4026670 0.200000003
52.5371666 13.2258329 0.00000000
52.5551682 13.2019997 0.00000000
52.4843330 13.4385004 0.00000000
Using the fixed column format is useful only when the columns are really fixed.
You can also just use single character variable tmp
instead of all those different ones.