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

I/O problem (Finding input file)

anishtain4
Beginner
495 Views
I have changed default path of the command prompt according to this guide:
http://www.ghacks.net/2007/11/16/change-the-default-command-prompt-directory/

to "E:\\C++\\" For some reasons, now when I want to "start without debugging" (either in debug or release) it says that the file cannot be found in E:\\C++\\.

My open command is as: OPEN(10,FILE='grid1.plt'). grid1.plt is in the same directory as of the source code and when I "Start debugging" it runs untill the end! What should I do?
0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
495 Views
Change the default path back to the project directory (or project build directory)

What you have done is equivilent to command lines:

(somewhere)>E:
E:\>CD \C++
E:\C++>C:\YourProjectBuildPathHere\YourProgram.exe [optional args]


Your open with 'grid1.plt' with no drive and path uses "current directory" (now E:\C++) and not the run from directory (C:\YourProjectBuildPathHere\). Either change the default path back to the project or project build (Debug/Release/other) or obtain the run from directory from the comman line arg 0 (or use a Windows API which I did not bother to look up for you). Note, the arg 0 (usually, but not always) provides the full path and file name of what was run. From there you can chop off the program name to get the folder from which the file was run. Until you move/copy the program this will be the project build directory.

Jim Dempsey
0 Kudos
anishtain4
Beginner
495 Views
Well I took the simplest way and changed the directory to default, but I was wondering if there is any option that tells open command use relative directory? this piece of code does not worth involving in APIs
thanks anyway
0 Kudos
mecej4
Honored Contributor III
495 Views
Set the property

Project->Properties->Configuration Properties->Debugging->Working Directory

to the location of the data files.

Or, choose for the value of this property some directory that is a parent of the one where the data files reside, and in your program specify the relative path from the property value just entered.

When you say "relative" the associated question of "relative to what" needs to have a known answer.
0 Kudos
jimdempseyatthecove
Honored Contributor III
495 Views
You are using relative directory. The problem is... you are setting the "current directory" to somewhere else than the location of the program

C:\YourProjectFolder>dir
C:\YourProjectFolder>Release\YourProgram.exe

lists the current directory C:\YourProjectFolder
And your OPEN will use the relative directory "." == C:\YourProjectFolder
(although the program resides in C:\YourProjectFolder\Release")

C:\YourProjectFolder>E:
E:\>cd C++
E:\C++>dir
E:\C++>C:\YourProjectFolder>Release\YourProgram.exe

Lists the current directory E:\C++
Andyour OPEN will use the relative directory "." == E:\C++
(although the program resides in C:\YourProjectFolder\Release")

It is yourresponsibility to specify the location(drive and folder) to which you wish things to be relative.

VS has a property page for doing this.
Or when you runby command line or by shortcut you can manipulatethe current drive and directory via actions (commands)or properties (shortcut).

What you cannot do is assume the system can read your mind.

Jim Dempsey
0 Kudos
Reply