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

cannot allocate memory and end-of-file during read with Release mode

Mike896
Beginner
781 Views

Hi

When one of my library project is set as Release, error shows:

"cannot allocate memory for the file buffer-out of memory, unit 12, fort.88".

But when I set it to Debug mode, it can be run.

That part of generating "fort.88" is a system call to run a *.exe which was generated by CVF.

Does this matter? or any suggestion?

ps. I use IVF11.0.66

Mike

0 Kudos
5 Replies
TimP
Honored Contributor III
781 Views

DId you check whether increasing the stack allocation in the .exe, by /link /stack:nnnnnnn option or by editbin, will resolve this?

0 Kudos
Steven_L_Intel1
Employee
781 Views

Without seeing a test case all I can do is guess, and what I would guess is that your program is corrupting memory somewhere. The "where" would naturally differ between an unoptimized and optimized version due to data layout and instruction differences. I don't even know what operation your program is doing to trigger this error.

0 Kudos
Mike896
Beginner
781 Views

Without seeing a test case all I can do is guess, and what I would guess is that your program is corrupting memory somewhere. The "where" would naturally differ between an unoptimized and optimized version due to data layout and instruction differences. I don't even know what operation your program is doing to trigger this error.

Now, the memory allocation error is disappeared.

I missed settings for Release: Fortran-> Additional Include Directories and Linker->Additional Dependencies.

I also missed settings fortran->Compatibility->Powerstation i/o format (yes), since I use unformatted i/o.

After I set these as Release for my two static libraries and also main project, I rebuild and rerun it, errors are :

end-of-file during read, ........fort.88

If I set two static libraries as Release and set Debug for main project, it can work well.

I have tried the all cases :

MyLibrary Main RunningWell?

Debug Debug Yes

Debug Release fail

Release Debug Yes

Release Release Fail

In other words, main project needs to be set as Debug. But why? I mean the fort.88, failed to be read and thus having the "end-of-file error during read " error message, is read by some subroutine of MyLibrary project. Isn't this error message nothing with MainProject?

As I said I set fortran->Compatibility->Powerstation i/o format (yes), since I use unformatted i/o. In that subroutine, it is like:

subroutine ReadMyOutput(io_unit,fn_MyOutput,....)

.....

read(io_unit)ref
if(present(sdtr))then
read(io_unit)sdtr
read(io_unit,end=1)piz
end if
1 return

end subroutine ReadMyOutput

The calling program is

open(io_unit,file=trim(fn_MyOutput),status='old',action='read',form='unformatted')

I remember, I do usually have some end-of-file reading error when I have the unformatted-read.

Besides, in CVF I need to set fortran->Compatibility->Powerstation i/o format (yes). Sometimes, I forgot to set this and spend hours to debug.

Mike

0 Kudos
Steven_L_Intel1
Employee
781 Views

I'm afraid I still don't follow this. Are you reading files that were written by Microsoft Fortran PowerStation? That's the only time you should be setting that PowerStation I/O compatibility option.

I could see that if you set this and read a non-FPS file, or didn't set it and did read a FPS file, that you could get memory errors as the run-time library would misinterpret record lengths.

0 Kudos
Mike896
Beginner
781 Views

I'm afraid I still don't follow this. Are you reading files that were written by Microsoft Fortran PowerStation? That's the only time you should be setting that PowerStation I/O compatibility option.

I could see that if you set this and read a non-FPS file, or didn't set it and did read a FPS file, that you could get memory errors as the run-time library would misinterpret record lengths.

I did have some old *.exe compiled by PowerStation. After recompiling by IVF and setting PowerStation i/o format into Default(no), there is no error message now. The problem I had before is due to the unconsistency you mentioned.

Thank you for the help.

Mike

0 Kudos
Reply