FIX: F6700: READ with END= and Character Formats

Last reviewed: September 16, 1997
Article ID: Q75761
5.00 5.10 | 5.00 5.10
MS-DOS    | OS/2
kbprg kbfile kbappnote kbfixlist kbbuglist

SYMPTOMS

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

CAUSE

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.

RESOLUTION

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.

Download HF0451.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download HF0451.EXE (size: 27151 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the SOFTLIB\MSLFILES directory
          Get HF0451.EXE (size: 27151 bytes) 
    

STATUS

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 reference words: 5.00 5.10 HF0451
KBCategory: kbprg kbfile kbappnote kbfixlist kbbuglist
KBSubcategory: FORTLngIss
Keywords : FORTLngIss kbappnote kbbuglist kbfile kbfixlist kbprg
Version : 5.00 5.10 | 5.00 5.10
Platform : MS-DOS OS/2
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.