Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Fortran Programming Language

read data


I have a short program 1.f
program main
integer i
read(*,*)i
write(*,*)i
stop
end
when I compile it, i have 1.exe, I want to do this
1.exe 3
to execute and read in a number 3 in ONE line, how can this be
achieved?
On May 31, 4:58 pm, xuan.@gmail.com wrote:

> I have a short program 1.f
> program main
> integer i
> read(*,*)i
> write(*,*)i
> stop
> end
> when I compile it, i have 1.exe, I want to do this
> 1.exe 3
> to execute and read in a number 3 in ONE line, how can this be
> achieved?

Two choices...

First requires and intermediate step but avoids changing your program--
put the data in a file say, 3.dat and use input redirection

 1.exe < 3.dat

Second requires using an extension to read the command line and parse
it to read the data from it.  Not in Standard Fortran until F2003 but
many (most?) compilers have compiler-specific implementations.  CVF
uses GETARG(

You have to call a function which moves the text of the command line
("1.exe 3 <ret>") to a string or individual strings in memory. Try
looking for "getarg" in your fortran manual.

One of the possible version of the function allows you to select which
parameter (0) the 1.exe,
or parameter (1) the value 3.

Requesting parameter (2) should return a code which indicates "no more
parameters"

My system uses   CALL GETARG(N, string,L)
 where N is the argument number, string is the character string
variable and L is the maximum length to return and changes to the
actual length found including zero for NONE. Your services may be
different.

Do a Google search for 'f2kcli'. This library gives a standard interface to all
the different (pre-F2003) platform-dependent ways of accessing command-line
arguments and environment variables.

cheers,

R

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc