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:

  1. Delete the words at the top of the fortin file
  2. Add a single read(*,*) (no need for anything following it) before the loop
Share:
28,794
manokaran krishnamurthy
Author by

manokaran krishnamurthy

Updated on May 06, 2020

Comments

  • manokaran krishnamurthy
    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 column

       1.0     
       5.0     
       3.0
       5.0
       7.0