Is this a code problem?

Is this a code problem?

I have Compaq Visual Fortran 6.1 running under Windows 2000. Someone sent me a source file that I compiled and linked with no warnings or errors reported, but it won't run. The problematic code is:

logical ex
inquire (FILE='model_input',exist=ex)
if (.not. ex) then
stop 'model_input not found'
end if
c define required properties
OPEN (14, FILE='model_input', STATUS='UNKNOWN')

When I execute the program, it writes 'model_input not found' and stops. I added the INQUIRE statement after the OPEN statement failed. The file model_input, in fact, exists and can be opened with Notepad. Copies of the file are located in both the Project and the Debug folders.

Can anyone suggest a trick to get this code to find and open this input file?

Many thanks in advance.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I tried your test case in CVF 6.6B and it seemed to work ok. I don't spot anything obviously wrong, but I wondered at first if perhaps the lack of an extension on the filename would cause problems. (Didn't seem to in my test.)

Interesting thing to do would be to do an INQUIRE of the unit after the open and see what NAME= returns as a value.


Retired 12/31/2016

Thanks for your thoughts, Steve. I have ordered the CVF 6.6 upgrade; it should arrive in a few days.

I would try an INQUIRE after the OPEN if the program did not stop with an error 'file not found' at the OPEN line.

My guess is that the default folder has been changed so it's looking somewhere else. You can set this in the Debug project settings tab. I tend to doubt that it's a CVF bug.


Retired 12/31/2016

Well, the problem, whatever it was, is solved. The solution was to create a new input file with WordPad and save it as a MS-DOS text file named input.dat. Of course, the code was changed to the new file name, but the file location was the projectDebug folder, where the original model_input file resided.

Thanks for your time and comments.

Leave a Comment

Please sign in to add a comment. Not a member? Join today