Fortran Gfortran/f90 (MinGW) namelist eof?

  • Thread starter Thread starter solarblast
  • Start date Start date
AI Thread Summary
A user created a Fortran 90 program to read and write files using namelists on Windows with MinGW but encountered an EOF (end-of-file) error when attempting to read a namelist input file. The input format included a name and age, but the program failed to read the age correctly due to the lack of a newline character at the end of the line. After suggestions to add a newline, the user discovered that the issue stemmed from using an 8-character string in the program while the actual name exceeded that length. Increasing the string length to 25 characters resolved the EOF issue. The user plans to tackle reading 2-dimensional arrays from namelists in future programming efforts.
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?
 
Technology 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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
5
Views
2K
Replies
13
Views
5K
Replies
3
Views
7K
Replies
5
Views
10K
Replies
34
Views
4K
Replies
3
Views
3K
Replies
1
Views
4K
Back
Top