Search code examples
fortranfortran90gfortranftell

GFortran: Read file bigger than 2GB


Does GFortran allow 8-byte integers as values for the read and inquire pos= argument?

Has GFortran an 8-byte version of ftell for getting file positions past 2GB?

The INTEL Fortran compiler has an 8-byte integer version of ftell called ftelli8 but I don't find anything regarding Gfortran.


Solution

  • The Fortran standard doesn't require specific integer kind as an pos argument to read. You can use any kind, including 8 bytes.

    The GCC nonstandard function ftell returns kind 8 on my 64 bit system, which is an 8 byte integer in gfortran. You could easily check by a simple program

      print *, kind(FTELL(6))
      end
    

    which prints 8, or

      print *, bit_size(FTELL(6))
      end
    

    which prints 64.