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

running program with piped input from visual studio

michael83
Beginner
2,082 Views
I have a fortran program that reads data using read(5,*) statements. I can compile and link it with IVF and can run it from the command line using a command like:

myprog.exe < input_data.txt

Is there some way to do this in Visual Studio? I've tried a few different run options but nothing works. I'm running the 8.1.019 version of IVF and the standard 2003 C++ .net visual studio.

Thanks.

Michael
0 Kudos
7 Replies
Steven_L_Intel1
Employee
2,082 Views
Project Properties.General..Debugging..Command Arguments - put in "< input_data.txt" (no quotes)
Note that the default directory is that of the project.
0 Kudos
michael83
Beginner
2,082 Views
I tried this and it did not work. I put some getarg statements into the program. When running from Visual Studio getarg picked up
"< input_data.txt" as an argument but the program still hung while waiting for standard input. When running from the command line getarg does not pick up anything put the program does read in the file.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,082 Views
I think Steve's wrong in this regard -- redirection isfeature of the command interpreter (cmd.exe) rather than the process itself.
You need something like:
Executable for debug session:
C:Winntsystem32cmd.exe
Program arguments:
/c D:UsersDujaCodeBrisiDebugTest.exe < Test.txt
Jugoslav
0 Kudos
Steven_L_Intel1
Employee
2,082 Views
This did work in CVF/VS6. I have not yet tried in in VS.NET - it should be the same.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
2,082 Views
Ah, sorry Steve -- it does work indeed.
Jugoslav
0 Kudos
michael83
Beginner
2,082 Views
Hi,

I'm not sure how you guys got Steve's suggestion to work. I'm running in Windows XP, service pack 2. That may be making a difference.

But I tried your suggestion, Jugoslav, and that worked (except that I had to substitute WINDOWS for winnt).

Thanks.

Michael
0 Kudos
Steven_L_Intel1
Employee
2,082 Views
I can't get it to work in VS.NET either. Hmm. I will have to research this when I get back to the office (I'm doing training off-site this week.)
0 Kudos
Reply