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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

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