practical use of iargc() getarg()
RadSurfer
RadSurfer@yahoo.com
Fri Aug 10 06:34:00 GMT 2007
Steve Kargl <sgk <at> troutmask.apl.washington.edu> writes:
>
> On Fri, Aug 10, 2007 at 03:46:19AM +0000, RadSurfer wrote:
[Snip]
> You need to use an internal read.
> PROGRAM test_getarg
> INTEGER :: i
> CHARACTER(len=32) :: arg
> real x
> DO i = 1, iargc()
> CALL getarg(i, arg)
> read(arg,*) x
> END DO
> END PROGRAM
> The above is completely untested.
Works like a charm! Beautiful.
by the way from gfortran.pdf, no example at all for iargc():
6.94 IARGC â Get the number of command line arguments
Description :
IARGC() returns the number of arguments passed on the command
line when the containing program was invoked.
This intrinsic routine is provided for backwards compatibility
with GNU Fortran77. In new code, programmers should consider the
use of the Section 6.37
[COMMAND ARGUMENT COUNT], page 54 intrinsic deï¬ned by the Fortran
2003 standard.
Standard : GNU extension
Class : Non-elemental Function
Syntax : RESULT = IARGC()
Arguments :
None.
Chapter 6: Intrinsic Procedures 87
Return value :
The number of command line arguments, type INTEGER(4).
Example : See Section 6.79 [GETARG], page 79
See also : GNU Fortran 77 compatibility subroutine:
Section 6.79 [GETARG], page 79
F2003 functions and subroutines: Section 6.80 [GET COMMAND],
page 79, Section 6.81 [GET COMMAND ARGUMENT], page 80,
Section 6.37 [COMMAND ARGUMENT COUNT], page 54
TOP PAGE gfortran.pdf reads:
Using GNU Fortran
For gcc version 4.2.1
More information about the Fortran
mailing list