BUG: Opening More Than 61 Files in a FORTRAN Windows NT AppLast reviewed: December 11, 1995Article ID: Q112339 |
The information in this article applies to:
SYMPTOMSA FORTRAN PowerStation application on Windows NT can have only 61 files open at a time. Attempting to OPEN the file number 62 will produce the run- time error:
error F6417: too many open filesPage 806 of the FORTRAN PowerStation "Programmer's Guide" incorrectly states that the fix for this problem is to change the FILES= setting in CONFIG.SYS.
CAUSEThe 64-file limit of the PowerStation for MS-DOS has been carried over to Powerstation for Windows NT. Three of these files are reserved for system use, leaving 61 files for the program to use.
RESOLUTIONUse WIN32 application programming interface (API) functions to perform some or all of your file I/O.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe following sample keeps 100 files open at the same time:
Sample Code #1c Compile options needed: none c include 'IO.FI' program OPEN_TEST character*9 fname/'FILE.000 '/ integer*4 j fname(9:9) = CHAR(0) ! Append null character do j = 1,100 write(*,*) fname call open(fname) write(fname(6:8),'(i3.3)') j ! Write file extension enddo endc subroutine open(name) character*(*) name, buffer*16 integer lcreat, handle, len data buffer/'Open many files.'/ handle = lcreat(name, 0) ! Create a new file len = lwrite(handle, buffer, 16) ! Write to file len = llseek(handle, 0, 0) ! Seek to the beginning len = lread(handle, buffer, 16) ! Read data back from file endThe following interface file, IO.FI, is used by the program above:
Sample Code #2C Open an existing file interface to integer function lopen + [stdcall, alias:'__lopen@8'](filename, mode) character*1 filename[reference] ! null terminated file name integer mode[value] ! 0 = read-only, 1 = write-only ! 2 = read-write endC Create a file (erase the old file if one exists) interface to integer function lcreat + [stdcall, alias:'__lcreat@8'](filename, mode) character*1 filename [reference] ! null terminated file name integer mode[value] ! 0 = read-write, 1 = read-only ! 2 = hidden, 3 = system endC Close a file (use with files opened by lcreat or lopen) interface to integer function lclose + [stdcall, alias:'__lclose@4'](handle) integer handle[value] endC Move the file pointer to a specific offset in a file interface to integer function llseek + [stdcall, alias:'__llseek@12'](handle,offset,origin) integer handle[value] integer offset[value] ! number of bytes to move pointer integer origin[value] ! 0 = beginning, 1 = current position ! 2 = end of the file endC Read a specified number of bytes from a file interface to integer function lread + [stdcall, alias:'__lread@12'](handle,buffer,length) integer handle[value] character*1 buffer integer length[value] ! number of bytes endC Write a specified number of bytes to a file interface to integer function lwrite + [stdcall, alias:'__lwrite@12'](handle,buffer,length) integer handle[value] character*1 buffer integer length[value] end |
Additional reference words: 1.00 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |