Gfortran/f90 (MinGW) namelist eof?

  • Context: Fortran 
  • Thread starter Thread starter solarblast
  • Start date Start date
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
solarblast
Messages
146
Reaction score
2
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?
 
Physics news on Phys.org
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.
 
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.