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

assigning input file to stdin when debugging fortran in intel visual studio

Linda_S_
Beginner
1,665 Views

I want to run a fortran code in debug mode in visual studio.  the code reads input from stdin (unif 5).  I would like it to read from an input file.  Can you tell me how to assign my input file to stdin?

0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,665 Views

This is VERY easy to do.

Right click on the project, select Properties > Debugging, In the field "Command Arguments" type:

< inputfilename.txt

By default it will look in the project directory.

View solution in original post

0 Kudos
6 Replies
mecej4
Honored Contributor III
1,665 Views

You can do this by setting environment variables. See the details at https://software.intel.com/en-us/node/510821 .

0 Kudos
dboggs
New Contributor I
1,665 Views

Do you really want to TEMPORARILY (e.g. for debugging) want to assign a file to unit 5? I.e. not permanently, in which case you would simply open the input file to another unit number?

0 Kudos
Linda_S_
Beginner
1,665 Views

I tried setting the environment variable FORT5 to my file name (including path).  that didn't help the situation in the debugger.  when I run the code in visual studio a command prompt window opens and the code expects input there.   I don't want to change the code to open the file explicitly.  Thanks for your hellp

0 Kudos
Steven_L_Intel1
Employee
1,666 Views

This is VERY easy to do.

Right click on the project, select Properties > Debugging, In the field "Command Arguments" type:

< inputfilename.txt

By default it will look in the project directory.

0 Kudos
mecej4
Honored Contributor III
1,665 Views

Linda S.: Please read the documentation fully. If, as is usual these days, you used UNIT=* rather than UNIT=5 for console input in READ statements, the variable to set is FOR_READ, not FORT5. I tried this in VS 2015, and the redirection of the input worked fine.

0 Kudos
Linda_S_
Beginner
1,665 Views

Thank you Steve

0 Kudos
Reply