Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29249 Discussions

out of memory when reading a record from unformatted file

felotti
Beginner
1,235 Views

I get the following message

forrtl: severe (98): cannot allocate memory for the file buffer - out of memory, unit 22, file D:BIGmensola.VIR

when I try to read a record from an unformatted file.

In a subroutine I write a 'big' record of integer*4

write(vir) ia(1:n)

where N=97.954.383

Next in the program, I try to read the record and I get the error in the subject.

The length of the 'record' is 97954383*4*8 = 3.134.540.256 bit > HUGE(1) = 2**31.

Why I can write the roecord and I cannot read it?

There is some limit to the 'lenght' in bit of a record?

0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,235 Views
Is array IA dimensioned 1:N? If so, try removing the (1:n) from the WRITE and READ.
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,235 Views

Steve.

??> The length of the 'record' is 97954383*4*8 = 3.134.540.256 bit > HUGE(1) = 2**31.

Would this imply that file I/O is bit granular? Or at least record size is bit granular?

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
1,235 Views
No, it is not bit granular. But large unformatted records are split into segments as documented in the Building Applications manual.
0 Kudos
felotti
Beginner
1,235 Views

The real code, for writing the file is the following:

c

c we store on VIR file for future usage

c

nfvir=iunit ('VIR',nerror)

rewind (nfvir)

c

c 1.st record on VIR : master record

c

write(nfvir)neq,ntote

c

c 2.nd record on VIR : columns (1,...,NTOTE)

c (currently unuseful)

c

c write(nfvir)(iarea (k,1),k=1,ntote)

call writearr( nfvir, iarea, ntote)

c

where the subroutine WRITEARR is the following:

subroutine writearr( iunit, ia, n )

dimension ia(n)

write(iunit) ia

return

end

Really, I must skip the record, and my original source code is:

c

c get info on the nfvir file

c

rewind (nfvir)

read (nfvir)i,j ! neq, nonz

read (nfvir)! (iarea (k,1),k=1,ntote)

c read (nfvir)(ipoint(l),l=1,neq+1)

read (nfvir) ipoint

I get the error on the 2nd READ, when I try to skyp the 'big' record.

I tried to do it with the following code:

read (nfvir)idum! (iarea (k,1),k=1,ntote)

but I get always the error message.

0 Kudos
Steven_L_Intel1
Employee
1,235 Views
That sounds like a bug. Please report it and provide a sample program.
0 Kudos
felotti
Beginner
1,235 Views

I compiled my program as 64 bit application and the code works without problem: the 'big' record is skipped.

0 Kudos
Steven_L_Intel1
Employee
1,235 Views
That somewhat makes sense - I don't know how you would be able to process a large record if you did not have sufficient address space.
0 Kudos
Reply