Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
17 Views

reading file and input conversion error

hello everybody

i am trying to read in a file. its a two column data. Right when i run this code, at line 5242, i get input conversion error. i am pasting the code here. the file i am trying to read is attached.

please help

 

program readout
implicit none

real::a(8243)
real::b(8243)
integer :: j=0

open (unit=10, file='nacanodes.txt', status='old')

do j=1,8243

read(10,fmt='(2f18.15)') a(j),b(j)

write(*,'(i4)') j
write(*,'(2f18.15)')a(j),b(j)

end do

close(10)

end program readout 

 

0 Kudos
2 Replies
Highlighted
17 Views

Your program assumes that the data is in fixed column positions, but it is not. If the first value in the line is negative, the sign shifts the rest of the text right one column.

You could read this data using a * format (list-directed), assuming that all of the data looked like this. The write should be fine.

I will comment that the data has far more digits than your declaration of default real can represent. Since you are writing the data back out, I'd suggest using real(8) to declare a and b.

0 Kudos
Highlighted
Beginner
17 Views

oh Thank you so much, Steve Lionel.

problem resolved.

 :-) cheers

0 Kudos