How to Avoid "Program Too Large for Memory" (67194)
The information in this article applies to:
- Microsoft FORTRAN Compiler for MS-DOS 4.1
- Microsoft FORTRAN Compiler for MS-DOS 5.0
- Microsoft FORTRAN Compiler for MS-DOS 5.1
- Microsoft FORTRAN compiler for OS/2 4.1
- Microsoft FORTRAN compiler for OS/2 5.0
- Microsoft FORTRAN compiler for OS/2 5.1
This article was previously published under Q67194 SUMMARY
When you attempt to run a very large program in MS-DOS, the error
"Program Too Large For Memory" may occur. MS-DOS runs in real mode,
which does not allow more than 640K of memory for applications. This
article discusses possible methods to circumvent this limitation.
These methods include using the OS/2 operating system instead of DOS,
direct-access disk file(s) for data storage, ALLOCATABLE arrays, and
overlays.
MORE INFORMATIONUsing Expanded and Extended Memory with Microsoft FORTRAN
Some DOS applications can use an expanded memory manager (EMM) driver
program and expanded memory board(s) to access memory beyond the 1 MB
limit of conventional memory. Microsoft FORTRAN, however, does not
have the capability to use expanded memory. It can utilize extended
memory (above 1 MB), but only when used with the OS/2 operating system
and protected mode libraries. Extended memory is the term used to
refer to the memory at physical addresses above 1 MB that can be
accessed by an 80286 or 80386 CPU in protected mode.
Using a Direct Access Disk File to Store Large Amounts of Data
A disk drive can be used to store large amounts of data in a direct-
access disk file, thus freeing up the memory that would otherwise be
used by the data. By using a direct-access file, records can be read
from or written to in any order, simulating the use of an array. If
expanded or extended memory is available, it can be used for a RAM
drive. By using a RAM drive, I/O access to the data is much faster
than when using a fixed disk drive.
Using Allocatable Arrays in FORTRAN Version 5.00
An ALLOCATABLE array is an array that is dynamically sized at run time
by using the ALLOCATE statement and the ALLOCATABLE attribute (see
pages 21-25 of the "Microsoft FORTRAN Reference" manual). The ALLOCATE
statement (see pages 113-114 of the "Microsoft FORTRAN Reference"
manual) establishes the upper and lower bounds of each ARRAY dimension
and reserves sufficient memory. The array can then be DEALLOCATED at
run time by using the DEALLOCATE statement (see page 143 of the
"Microsoft FORTRAN Reference" manual) to free memory for use by other
arrays.
For example:
INTEGER data [ALLOCATABLE] (:,:)
INTEGER error
DATA i, j / 10,50 /
ALLOCATE (data (i,j), STAT=error)
DEALLOCATE (data, STAT=error)
Using Overlays in FORTRAN Versions 4.00, 4.01, 4.10, and 5.00
Overlays (see pages 366-367 of the "Microsoft FORTRAN Reference"
manual for versions 5.00 and pages 258-260 of the "Microsoft FORTRAN
CodeView and Utilities User's Guide") allow several program modules to
use the same memory area. When needed, a module or group of modules is
loaded into memory from the disk. Module access time can be shortened
if a RAM drive is used to store the executable. Modules that are to be
overlaid are enclosed in parentheses. CODE (but NEVER DATA) is
overlaid. Note: If the program consists of mostly DATA, then this
procedure will be of little help.
The following example is for versions 4.00, 4.01, 4.10, and 5.00:
At LINK command line: LINK A (B C) (E F)
Object modules B and C are swapped in and out of the same memory for
Object modules E and F. Note: Object modules in parentheses are
overlaid together so that they will be loaded into memory at the
same time.
The following example is for versions 4.10 and 5.00:
At FL command line: FL MAIN.FOR (OVER1.FOR) (OVER2.FOR)
FORTRAN code modules OVER1 and OVER2 are swapped in and out of the
same memory location.
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | KB67194 |
---|
|