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

Unformated file opening error (IoStat=30)

tiborkibedi
Beginner
982 Views
I am using the same subroutine to open and read unformatted files in two different programs, built on a Win2000 machine using CVF 6.6a. The files have been created on a VMS machine, with a fixed record length.

The following code, which is part of a subroutine, is used to examine the properties of the files and open them:
	Open(		Unit		= FileLun,	&						! try to open exisiting file
     			File		= FileName,	&
     			Form		= 'UNFORMATTED',	&
     			IoStat		= IoStat,	&
!dvf     		Recl		= 512,								! VMS
     			Recl		= 128,		&						! CVF
     			RecordType	= 'FIXED',	&
     			Shared,			&
     			Status		= 'OLD')


The two programs report different properties for the same file:

Program A: exists=.True., recl=0, Recordtype=UNKNOWN and the Open command is successful.

Program B: exists=.True., recl=132, Recordtype=STREAM_LF and the Open command fails with IoStat=30

I looked carefully the compiler and linker options, but they look the same.

Any clue, where to look for a solution.
0 Kudos
6 Replies
tiborkibedi
Beginner
982 Views
I just noticed, that the inquire command has been left out from the code posted. Please add the following line in front of the Open statement:
	INQUIRE (FILE = FileName, EXIST = exists, recl=recl, recordtype=recordtype)
0 Kudos
Steven_L_Intel1
Employee
982 Views
Take off the IOSTAT and see what error you get.

Note that RECL= in INQUIRE isn't useful for non-opened files on Windows.

Steve
0 Kudos
tiborkibedi
Beginner
982 Views
The following error was observed after removing the IoStat from the open statement:

forrtl: The process cannot access the file because it is being used by another process.
forrtl: severe (30): open failure, unit 11, file C:RE179TG.SPC

There is no other process running, which wants to open this file. Restarting the computer and running the application gives the same error.
0 Kudos
Steven_L_Intel1
Employee
982 Views
Well, something has the file open - perhaps it is opened in the same program on another unit?

Steve
0 Kudos
tiborkibedi
Beginner
982 Views
Steve,

You are right. The file has been opened by the program using a different unit number. Interestingly it did not cause any problem on the VMS system, where the program has been developed.
0 Kudos
james1
Beginner
982 Views
If all your OPENs use same options, I would still suspect an external agent. If all units are open shared that should work on either OS.

James
0 Kudos
Reply