- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
oh Thank you so much, Steve Lionel.
problem resolved.
:-) cheers
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page