Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran Fortran runtime error: Sequential READ or WRITE not allowed

  1. May 21, 2015 #1
    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
  2. jcsd
  3. May 21, 2015 #2


    Staff: Mentor

    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.
  4. May 21, 2015 #3


    Staff: Mentor

    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook