Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

reading file and input conversion error

Sirat_S_
Beginner
361 Views

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
Steven_L_Intel1
Employee
361 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
Sirat_S_
Beginner
361 Views

oh Thank you so much, Steve Lionel.

problem resolved.

 :-) cheers

0 Kudos
Reply