Fortran runtime error: Bad real number in item 1 of list input
28,794
Your code expects only numbers and it appears you have characters in the file. You can do one of two things to fix this:
- Delete the words at the top of the
fortin
file - Add a single
read(*,*)
(no need for anything following it) before the loop
Author by
manokaran krishnamurthy
Updated on May 06, 2020Comments
-
manokaran krishnamurthy almost 4 years
I am getting run time error:
Bad real number in item 1 of list input
for this sample problem. Please, suggest the correct way.implicit double precision (a-h,o-x) parameter (ni=150) dimension x(ni) open(40,file='fortin') do 80 i=1,5 read(40,*)x(i) write(*,*)i,x(i) 80 continue stop end
The data in the
fortin
file arranged in column1.0 5.0 3.0 5.0 7.0