This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: reading from a over 2Gbyte file


[ cc'd to gcc-bugs@gcc.gnu.org ]

Yosuke Toh wrote:

> Do the g77(v0.5.24) support for reading from a over 2Gbyte file?
> (My program is run on FreeBSD(3.3).)
> This program can read under 2Gbyte.
> But over 2Gbyte, can't do it.
> 
> open and read
> 
> open(15,file=open_file,access='direct',recl=bufferdatasize*2,err=
> 9029,status='old',iostat=iosopen)
> read(15,rec=renum,err= 9029,iostat=iosread)(data(i),i=1,bufferdatasize)
> 
> When 'rec=renum' is extend to 2Gbyte, 'iostat=iosread' return to -1.

Hmmm, when I tried to write over 2 Gbyte, using this program:

      PARAMETER (NRECLN=250 000, NRECS=2 500)
      REAL A(NRECLN)
      DO I = 1, NRECLN
         A(I) = I
      ENDDO
      OPEN(UNIT=1,ACCESS='DIRECT',RECL=4*NRECLN,STATUS='UNKNOWN')
      DO I = 1, NRECS
         WRITE(UNIT=1,REC=I,IOSTAT=IOS) A
         IF (IOS .NE. 0) THEN
            PRINT*,'WRITE FAILED, REC=',I,' IOSTAT=',IOS
            GOTO 10
         ENDIF
      ENDDO
   10 CONTINUE
      CLOSE(UNIT=1)
      END

on i686-pc-linux-gnu, it also failed to write more than 2 Gbyte:

$ ls -l /tmp/aap
-rw-rw-r--   1 toon     toon     2147483647 Jul 26 15:25 /tmp/aap

Unfortunately, it didn't give an error indication (it just completed
"normally" :-().  This was using the g77-0.5.25 that's in gcc-2.95.2.

On alphaev6-unknown-linux-gnu (a machine with 64-bit sizes and offsets)
the above program with NRECS=5 000 was able to create the correctly
sized file:

ls -l /tmp/aap
-rw-rw-r--   1 toon     toon     5000000000 Jul 26 16:10 /tmp/aap

So most probably the limitation is inside the libf2c run time library,
that uses `long' variables for I/O sizes and offsets - which is 32 bits
on an Intel PC and 64 bits on Alpha.

Hope this helps,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://g95.sourceforge.net/ (under construction)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]