HF0451.EXE - F6700: READ with END= and Character Formats

ID: Q75761


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.1


SUMMARY

Programs compiled with Microsoft FORTRAN versions 5.0 and 5.1 and run for a period of time can generate the error:

run-time error F6700:
-heap space exceeded
The three conditions that are necessary to cause this error are:

  1. The program must contain a READ or WRITE statement that contains an END=, ERR=, or IOSTAT= specification.


  2. The READ or WRITE statement that contains one of the above specifications must use a character string variable for a FORMAT specifier.


  3. The program code must repeatedly execute the READ or WRITE statement in such a way as to force the use of one of the specifications; for example, repeatedly hitting the end of a file and causing the END= specification to go to the specified label.


Given the above conditions, the near heap will fill up with replicates of the character string FORMAT specifier until the F6700 error is generated. The larger the character string, the faster the near heap will be filled up. The F6700 error most commonly occurs on an OPEN statement. The OPEN statement allocates some memory in both the near and far heap and will fail with the F6700 error if sufficient near heap does not exist. A patched version of a component (PUTERR.OBJ) of the run-time library has been made available as an application note. With the new replacement routines in the PUTERR.OBJ module, the accumulation of allocated memory on the near heap does not occur because the memory used is correctly deallocated following termination of the READ or WRITE statement.

The following file is available for download from the Microsoft Download Center. Click the file name below to download the file:
hf0451.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center. Microsoft has confirmed this to be a problem in FORTRAN versions 5.0 and 5.1. This problem was corrected in FORTRAN PowerStation.


MORE INFORMATION

The following code can be used to reproduce the problem:

Sample Code


     parameter(n=19000)
      integer*4 ai
      integer*1 arr1(n),arr2(n),arr3(n)
      character*256 str,formstr

      formstr = '(a)'
      str = 'this is junk'
      open(1,file='test.dat')

      write(1,formstr) str
      rewind(1)
      ai = 1
10    read(1,formstr,end=20) str
      goto 10

20    rewind(1)
      write(*,*)
      write(*,*) 'At end of file at iteration ',ai
      ai=ai+1
      goto 10
      end 

Additional query words:

Keywords : kbfile kbFortranPS kbLangFortran
Version : :5.1
Platform :
Issue type : kbinfo


Last Reviewed: November 17, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.