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

Command Line Arguments

sumitm
Beginner
1,217 Views
Hi
My C# developer needed my executeables to have command line arguments
like Myprog.exe readfile1.txt readfile2.txt output1.bmp

I have specified the /fpscomp:filesfromcmd option and generated the required exe where everytime it sees a File='' it asks for input and takes that in.

My problem is with the last section the bmp file.

I use
	status = SAVEIMAGE('preform_design.bmp', 1,1 , myscreen.numxpixels-1,myscreen.numypixels-105 

to generate a bmp. To give it a filename read in from the command line seems to be tough.


My quickwin graphics opens with
open (unit=5,File='user',status='replace')
If I make file='' ,I get the option to save the file as something.bmp but the bmp is totally blank.

Is there a way to trap that file name and use it in the saveimage ('something.bmp'....)

I know this is not the most elegant solution but I am just trying to getby.
Thanks
0 Kudos
4 Replies
sumitm
Beginner
1,217 Views
I think I got it with GETARG.

Thanks
0 Kudos
ritesh_agrawal
Beginner
1,217 Views
Hello

I am having a problem which I think you already solved. I have a fortran file and its executable file. I have to run the executable file from command prompt and also pass the input file and output file name. For example
icfm.exe -I infile.txt -o outfile.txt

How can I write a code that can look for input file after -I and for output file after -o.

Thanks for any help in advance
Ritesh Agrawal
0 Kudos
sumitm
Beginner
1,217 Views
Ritesh,
You need to do the following:
1. Under Project Settings you need to go to
Fortran/Compatibility and check File Names from Command line
2. In your program it should read
program ReadInputSendOutput
use dfwin
character(256) flnout

IMPLICIT NONE

call GETARG(2,flnout)   

Call Read_Data
Call Perform_Calculations
Call SaveData
end program readInputSendOutput


From the command line type
ReadInputSendOutPut InputFile Outputfile

3. In the subroutine Read_Data
the file open statement should be
 OPEN(UNIT = 100, FILE = '', STATUS = 'OLD', IOSTAT = IERR)

  READ(100,DATAINPUT, IOSTAT = IERR)

  CLOSE(UNIT=100)

4. In the Subroutine SaveData the statements should be
open(18,file=fln3,status='replace')
Write(18,*) NewData
close(18)

Hope This helps

Sumit
0 Kudos
ritesh_agrawal
Beginner
1,217 Views
Hello Sumit

Thank for your detailed answer

Let me make you more clear. I dont have any idea of fortran coding and even I dont have a compiler. So first of all let me ask you from where I can download a fortran compiler. I tried using GNU but its giving lot of errors.

Okie once I get the compiler what exactly I have to do. What lines I will have to add in fortran so that when I make a executable file (suppose abcd.exe) of that fortran code and give the following commnad on command prompt

c: > abcd.exe -I infile -o outfile -A 23 45

The abcd.exe should get executed and if -I is present then the code should look for the data in that directory or otherwise in the same directory and if -o is present then the code should put the data in that directory and -A is present then it should look for the arguments.

If you are in US and you can give me your phone number (if not a problem for you). I will call you so that we can chat directly. Please reply as if replying to neophyte.

Thanks once again

Ritesh Agrawal
0 Kudos
Reply