http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60956
Bug ID: 60956
Summary: error reading (and writing) large text files in
gfortran
Product: gcc
Version: 4.7.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: awrichar at gmail dot com
Created attachment 32678
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32678&action=edit
demonstrates gfortran failed read/write of large text files
I'm getting some buggy behavior when working with very large data files
(complex, n=120^4) in gfortran 4.7.3. I get "End of record" errors when
reading, and recently, "Cannot allocate memory" when writing.
Originally, I was able to successfuly write the large files, but when I try to
read them, gfortran issues the error:
>> test_complex_sort.f90 (unit = 100, file = 'sigma_hat_1.txt')
>> Fortran runtime error: End of file
If I explicitly loop through each element of the array during the READ instead,
gfortran has no issues. (Also if I use the Portland Group compiler and assign
the array all at once, there are no issues.) If I reduce the variable size to
(120^4)/12, it runs, but (120^4)/10 fails.
I've written a test case (see attached), but this fails to WRITE the large
file, saying:
>> At line 19 of file test_complex_io.f90 (unit = 100, file = 'dummy.txt')
>> Fortran runtime error: Cannot allocate memory
The line in question (19) is simply
>> WRITE(100, *) u
and runs fine for cases (n.LT.10**8). (All cases run fine when compiling with
the Portland Group Fortran compiler.)
Lastly, if I generate the 4GB text file using PG Fortran, then comment out
lines 18-20 in the attached file and complie with gfortran, I get a seg-fault
during the READ for the n=10^8 case.
These errors occurs on a computer with dual Xeon E-2690v2 processors and 256GB
(not a typo) of RAM, under Ubuntu 13.04 with gfortran 4.7.3. (NOTE: When using
the PG Fortran compiler, the attached code uses ~3.2GB of memory, and writes a
4GB text file for the largest test case.)
Has anyone else experienced similar issues? Is this reproducible for anyone
else, or in newer gfortran versions? I haven't found any recent bugs reports
that seem similar, but I easily could have overlooked something.
--Andy