Gfortran/f90 (MinGW) namelist eof?

  • Fortran
  • Thread starter solarblast
  • Start date
In summary, the conversation discusses using a small f90 program to read and write a file using namelists in Windows, specifically MinGW. The individual encountered an eof indication when trying to read a namelist file and was advised to add a new line at the end of the line to avoid triggering the end-of-file indicator. They then discovered that the issue was due to using a longer name than the 8 character string in the program and fixed it by increasing the limit to 25 characters. The next challenge discussed is reading 2-dimensional arrays from a namelist.
  • #1
solarblast
152
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
  • #2
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.
 
  • #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.
 
1.

What is Gfortran/f90 (MinGW) namelist eof?

Gfortran/f90 (MinGW) namelist eof is a feature in the Gfortran compiler that allows for the end of a namelist to be specified using the keyword "eof" instead of a blank line.

2.

How is Gfortran/f90 (MinGW) namelist eof used?

Gfortran/f90 (MinGW) namelist eof is used by inserting the keyword "eof" at the end of the namelist, followed by a semicolon. This signals to the compiler that the end of the namelist has been reached.

3.

Can Gfortran/f90 (MinGW) namelist eof be used with other compilers?

Yes, Gfortran/f90 (MinGW) namelist eof is a standard feature in the Fortran 90 language and can be used with any compiler that supports this language version.

4.

What are the benefits of using Gfortran/f90 (MinGW) namelist eof?

Some benefits of using Gfortran/f90 (MinGW) namelist eof include improved readability of code by replacing blank lines, and the ability to easily specify the end of a namelist without having to count the number of variables.

5.

Are there any limitations to using Gfortran/f90 (MinGW) namelist eof?

One limitation of using Gfortran/f90 (MinGW) namelist eof is that it is not compatible with older versions of the Fortran language. It also cannot be used with namelists that contain only a single variable.

Similar threads

  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
0
Views
415
  • Programming and Computer Science
Replies
4
Views
6K
  • Programming and Computer Science
Replies
5
Views
10K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
9
Views
8K
  • Programming and Computer Science
Replies
5
Views
1K
Back
Top