Fortran runtime error: Sequential READ or WRITE not allowed

In summary: So if you write to such a file, then try to read from it, you could well get this error. So if you're writing to a file, you might want to check if the file already exists, and if so, delete it before writing to it.In summary, the user is experiencing an error while running the NMTO package for constructing Wannier functions for a material. The error is related to a Fortran runtime error at line 329 of the code plotnmto.f90, and suggests that the user should check their data file and compare it to a known working file. They may also need to delete and recreate the file they are writing to in order to avoid this error. The user is seeking help from experts
  • #1
fort_phys
3
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
  • #2
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.
 
  • #3
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.
 

Related to Fortran runtime error: Sequential READ or WRITE not allowed

1. What does the error message "Fortran runtime error: Sequential READ or WRITE not allowed" mean?

The error message indicates that there is an attempt to perform a sequential read or write operation on a file that has not been opened for sequential access.

2. What causes a Fortran runtime error for sequential READ or WRITE?

This error can occur when a file is opened for direct access instead of sequential access, or when an attempt is made to read or write to a file that is not open.

3. How can I fix a Fortran runtime error for sequential READ or WRITE?

To fix this error, make sure that the file is opened for sequential access before attempting to perform a sequential read or write operation. Also, ensure that the file is properly closed after use.

4. Can this error be caused by incorrect file permissions?

No, this error is not related to file permissions. It is caused by attempting a sequential read or write operation on a file that is not open or is not opened for sequential access.

5. Is there a way to prevent this error in my Fortran code?

Yes, to prevent this error, always make sure to open files for the correct type of access (sequential, direct, or formatted), and to properly close the file after use. Also, use error handling techniques to catch and handle any potential errors related to file input/output operations.

Similar threads

  • Programming and Computer Science
Replies
17
Views
5K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
9
Views
1K
  • Computing and Technology
Replies
11
Views
174
  • Programming and Computer Science
Replies
4
Views
695
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
19
Views
5K
Back
Top