Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem with Fortran g77 code

  1. Jan 18, 2010 #1
    Hi,
    I received a code written in Fortran 77, and I am trying to compile it and run it using g77. It compiles easily with no errors, but I keep getting the following error when I execute

    errorfmt: read unexpected character
    apparent state: unit 5 named jeffin
    last format: (10X,D13.7)
    lately reading sequential formatted external IO
    Aborted

    Any idea what this error means?
     
  2. jcsd
  3. Jan 19, 2010 #2

    Mark44

    Staff: Mentor

    It looks to me like your error is coming from an input READ statement where the format string is in disagreement with what your program is trying to read.

    I can't say any more than that because I don't see your code and I don't know what the input was.
     
  4. Jan 19, 2010 #3
    Sorry, here are the codes I used in the zipped folder. The code JEFF.FOR compiles fine, but I cannot find an error in how the read command takes in the input file called jeffin. If you can help me out, I would really appreciate it!
    Donna
     

    Attached Files:

  5. Jan 19, 2010 #4

    jtbell

    User Avatar

    Staff: Mentor

    In principle, it's possible to figure out which of your READ statements is failing, by tracing through the code carefully by hand, one statement at a time, and matching each READ statement with a line in your input file to see if the format matches properly.

    However, it's easy to make mistakes doing this. Instead, get the computer to do the work for you! :smile:

    Immediately after each READ(5... statement, insert a statement which displays the value that it just read in. For example, after

    READ(5,99)NEIGEN

    add

    PRINT *, "NEIGEN = ", NEIGEN

    If the appropriate line in your input is actually being read properly, you should see the message

    NEIGEN = 2

    The last such output line before the error message will tell you which READ statement failed... it's the next one!
     
  6. Jan 19, 2010 #5
    Thanks!
    This really helped. I found the error. I had the format 102 written as (10X,D13.7) and when I put instead (20X, D13.7) it runs.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook