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

Gfortran/f90 (MinGW) namelist eof?

  1. Apr 28, 2012 #1
    I've written a small f90 program to read and write a file using namelists in Windows, MinGW. I've never tried this before.

    I entered the name list using notepad. The name input namelist file looks like:

    &WW_ANML aname="John Doe", age=44

    Whenever I try to read it I get an eof indication. Do I need some special eof marker at the end of line?
  2. jcsd
  3. Apr 28, 2012 #2

    I like Serena

    User Avatar
    Homework Helper

    eof means end-of-file.

    When you read the number 44, your program tries to read another digit, but finds the end of the file, which it indicates.

    Try to put a new line at the end of the line.
    That will explain to your program that there is no other digit coming, without triggering the end-of-file indicator.
  4. Apr 28, 2012 #3
    Thanks for your response.

    I tried a CR. I'm using Win7. It didn't work.

    I just happened to realize that I had used a 8 character string in the program, but in reality used a much longer name than John Doe. I boosted the 8 to 25. That fixed it.

    Well, my next namelist challenge will be to read 2-dim arrays. I think the numerical data comes in a column at a time from a namelist to get into a (n,2) array.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook