Gfortran/f90 (MinGW) namelist eof?

  • Context: Fortran 
  • Thread starter Thread starter solarblast
  • Start date Start date
Click For Summary
SUMMARY

The forum discussion centers on using Gfortran with MinGW to read and write namelists in Fortran 90 on Windows. A user encountered an end-of-file (eof) error when reading a namelist file, which was resolved by adding a newline at the end of the input line and increasing the character length for string variables from 8 to 25. This adjustment allowed the program to correctly interpret the input data without triggering an eof indication. Future challenges mentioned include reading two-dimensional arrays from namelists.

PREREQUISITES
  • Familiarity with Fortran 90 programming
  • Understanding of MinGW toolchain for Windows
  • Knowledge of namelist syntax in Fortran
  • Basic file I/O operations in Fortran
NEXT STEPS
  • Research how to properly format namelist files in Fortran
  • Learn about handling end-of-file conditions in Fortran I/O
  • Explore reading and writing two-dimensional arrays in Fortran
  • Investigate debugging techniques for Fortran programs in MinGW
USEFUL FOR

This discussion is beneficial for Fortran developers, particularly those using Gfortran with MinGW on Windows, and anyone looking to troubleshoot namelist input/output issues in their programs.

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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
8K
  • · Replies 13 ·
Replies
13
Views
5K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 5 ·
Replies
5
Views
11K
  • · Replies 34 ·
2
Replies
34
Views
5K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K