Fortran Fortran runtime error: Sequential READ or WRITE not allowed

Click For Summary
The discussion centers around an error encountered while using the NMTO package for constructing Wannier functions in Fortran. The specific error message indicates a problem with reading or writing data after reaching the end of a file (EOF) in the code file plotnmto.f90. Users suggest checking the data file setup, ensuring it matches a known working data file, and verifying the presence of any required end markers. It is emphasized that once the EOF is reached, further sequential reads are not permitted, which could also occur if attempting to write to an existing file. The advice includes looking into the source code for loops that manage data reading and confirming that the data file is correctly formatted to avoid this runtime error.
fort_phys
Messages
3
Reaction score
0
Dear Forum users,

I am running a program called NMTO package for constructing Wannier functions for a material. It uses a code plotnmto.f90 to calculate wannier isosurfaces within the mesh defined by me. I compiled the code in gfortran. After defining the mesh when I ran the program for Wannier functions I get the error

At line 329 of file NMTO/plotnmto.f90 (unit = 999, file = 'RHOF')
Fortran runtime error: Sequential READ or WRITE not allowed after EOF marker, possibly use REWIND or BACKSPACE

I searched in the forum and I find some similar error for gfortran but I am unable to find the error in the code. As I know there are many fortran program experts in the forum I would like to request if you could help me to solve this error .

Thanking you in advance,

Santu Baidya
 
Technology news on Phys.org
Check that your data file is properly setup. Compare it to a known working datafile. Perhaps you are missing some sort of sentinel card/line at the end of the file, some fortran programs would look for a special end card/line starting with '***end' or '99999999' or something like that. If you have the source code you can look at where things are read and see if there is a loop that terminates when a specific piece of data is read.

By known working datafile I mean one that the NMTO program processes without error.
 
fort_phys said:
At line 329 of file NMTO/plotnmto.f90 (unit = 999, file = 'RHOF')
Fortran runtime error: Sequential READ or WRITE not allowed after EOF marker, possibly use REWIND or BACKSPACE
This error is pretty straightforward. Once you have read all of the data in a file, and so are at the end of the file (EOF), it is an error to attempt to read in a sequential fashion (i.e., from beginning of file toward the end) additional data from the file.

I'm not sure why this error would arise if you're writing to a file, unless possibly you're writing to a file that already exists. If you write to a newly created file, the beginning of the file is also the end of the file.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 17 ·
Replies
17
Views
7K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 5 ·
Replies
5
Views
11K