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

Can I set program arguments in Visual Studio 2008?

Christina_S_
Beginner
4,204 Views
I am running a code in Digital Fortran where a .run file is specified under Program>Settings>Program Arguments. The code runs succesfully.
I am also currently trying to translate the code so that it can run in Visual Studio 2008. Is there a way to specify the same .run file as a program argument there? I tried to specify the file under Project>Properties>Configuration Properties>Debugging>Command Arguments but it doesn't seem to work.

Thank you.
Christina
0 Kudos
16 Replies
Steven_L_Intel1
Employee
4,204 Views
Yes, it works the same way as in VS98/CVF. I've done this many times.
0 Kudos
Christina_S_
Beginner
4,204 Views
Unfortunately it still does not seem to work. So when I specify the argument do I just write down the file name including the extention? Is there any symbol I need to include?

Thanks.
Christina
0 Kudos
bmchenry
New Contributor II
4,204 Views
Note you can havedifferent settings for command arguments, etc for debug and release.
Haveyou set the command arguments for both debug and release?
0 Kudos
Christina_S_
Beginner
4,204 Views
Thanks for the note. I just did and still does not work.
0 Kudos
Steven_L_Intel1
Employee
4,204 Views
Can you attach a ZIP of a sample project showing the problem?
0 Kudos
lklawrie
Beginner
4,204 Views
You need to have the file in the same folder as the project. or provide the complete path to the file.

Also, if you have release configuration and debug, you need to put it in the correct configuration -- plus, you would need to run from within the IDE. This hasn't changed from CVF, DVF, etc.

0 Kudos
Steven_L_Intel1
Employee
4,204 Views
I just tried this with this sample program:

[plain]    program cmdargs

    implicit none

    character(80) arg
    integer i, num_args

    num_args = COMMAND_ARGUMENT_COUNT()
    print *, "There are", num_args, "arguments"
    do i=1,num_args
      call GET_COMMAND_ARGUMENT(i,arg)
      print *, "Argument", i, "is ", trim(arg)
      end do

    end program cmdargs[/plain]
In the project properties, Debugging, Command Arguments I have: First Second Third

When I run the program I get:
[plain] There are 3 arguments
 Argument 1 is First
 Argument 2 is Second
 Argument 3 is Third[/plain]

0 Kudos
Christina_S_
Beginner
4,204 Views
The line that gives the problem in the code is :

read(kcfile, '(a8)', end= 10) zcmndt

Variable "zcmndt" is supposed to read the data from the .run file (which I defined under the command arguments) -and it doesn't.
Do I need to make any further changes to this line except setting the file in the command arguments to make it work?

Thanks
Christina
0 Kudos
Steven_L_Intel1
Employee
4,204 Views
Ah, there were aspects you weren't telling us!

My guess is that you are relying on the Microsoft Fortran PowerStation feature where you can do:

OPEN (UNIT=kcfile, FILE='')

and it will open the file named in the first argument on the command line. You need an option to get that behavior - as you did in DVF/CVF. In Visual Studio, right click on the project and select Properties. Go to the Fortran > Compatibility property page and change "Files from command line (PowerStation)" to Yes, then rebuild.

If that doesn't solve the problem, please show us the statement where unit kcfile is opened.
0 Kudos
Christina_S_
Beginner
4,204 Views
Sorry for not being too clear but there are so many details..
Unfortunately that didn't solve the problem as well.
I believe this is the line you are looking for:

open(unit = kcfile, file = zcfile, status = 'UNKNOWN')

However, in the code the line menioned above exists in an "if statement" that is false and therefore is not read. kcfile is set equal to 5 in a previous if statement.
Does this make any sense?

Thanks!
Christina
0 Kudos
IanH
Honored Contributor III
4,204 Views
Were you using input redirection previously (did you have something like in the command's "arguments")?
0 Kudos
SergeyKostrov
Valued Contributor II
4,204 Views
Unfortunately it still does not seem to work. So when I specify the argument do I just write down the file name including the extention?

[SergeyK] What about a path to that file?

Is there any symbol I need to include?

Thanks.
Christina

0 Kudos
Steven_L_Intel1
Employee
4,204 Views
Can you attach the actual program? Do you still have the DVF/CVF project and, if so, can you attach the .dsp file from that project? So far I am not seeing anything you have told us that would look at the command line.

Please also tell us what you have put in for the command arguments value. Ian had a good suggestion that you are using redirection. This has been broken in some earlier versions of Visual Studio - which Visual Studio version are you using?
0 Kudos
SergeyKostrov
Valued Contributor II
4,204 Views
Yes, it works the same way as in VS98/CVF. I've done this many times.


Hi Steve,

Why did you mention VS98 ( Visual Studio 98 )?

Just in case, I have a VS98 Enterprise Edition on one of my test laptops and I could verifyredirection,if
needed. Just let me know.

Best regards,
Sergey

PS:
It is 8:19pm inCalgary, AB and the current temparature outside is -32 Celsius. With a windchill it feels like -45 Celsius...

0 Kudos
Christina_S_
Beginner
4,204 Views
Yes, you are right! I was using Now I am trying to run the code in Microsoft Visual Studio 2008 and it doesn't work.

Thank you..again!Learning a lot..
Christina
0 Kudos
Steven_L_Intel1
Employee
4,204 Views
I mentioned VS98 because CVF used VS98 as the development environment.

I just tried an experiment with redirection in VS2008 and it worked. Make sure that your VTC_Mesh.run file is in the project folder (the one with the .vfproj file) and not with the executable. As an alternative, give the full path to the input file (enclose the file specification in "" if there are embedded spaces.)

There had been a bug in earlier VS versions through VS2005 where this did not work, but it does in VS2008.

What are the values of kcfile and zcfile? I am especially suspicious of your having FILE= in the OPEN because that would tend to block redirection. The redirection you are using assumes you are reading from "standard input" which is, by default, connected to unit 5. If you OPEN unit 5 to a separate file, then the redirection will not work.
0 Kudos
Reply