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

Directory (or Path) Issue

orangecccc
Beginner
429 Views

I'd like to run the Fortran execution file at any directory. But the problem is that its input file should be existed with the execution file in the same directory. For example,

An execution file (model.exe) and input file (input.dat) are locatedat c:projectsmodelrun est

But a working directory is c: est

So I'd like to command using DOS prompt as follows:

c: estc:projectsmodelrun estmodel.exe input

The model.exe was recognized, but the input.dat wasn't because of its loacation directory...

Do you have any comments or suggestions to solve it? Thanks in advance...

0 Kudos
2 Replies
dbruceg
Beginner
429 Views

WHY does the input file have to be in the same directory as the executable?

Bruce

0 Kudos
anthonyrichards
New Contributor III
429 Views
Use GETARGS twice, onceto get the full-path name of the executable (first argument, numbered '0'), second to get the input data file name (second argument, numbered '1',). use SPLITPATHQQ on the executable to get the path to the executable. It will probably be safe to use SPLITPATHQQ on the second argument also, just in case the datafile is given with a full path, so that you can obtain the bare data file name with no path, then addthe path to the executable (drive+directory+'')to the input data file name. Then use the resulting full-path name to the data file in your OPEN statement.
0 Kudos
Reply