This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Small mountain
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Richard L Walker <rlwalker2 at cox dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 16 Apr 2002 00:08:14 +0200
- Subject: Re: Small mountain
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <NCBBLJOPGKHBOJFHPCPOGEAJEHAA.rlwalker2@cox.net>
Richard L Walker wrote:
>
> I am trying to create an example FORTRAN program that will be able to handle
> command line arguments once it is compiled and run. I have read several web
> pages about IARGC, GETARG, a library named LIBG2C and something called
> F_SETARG. Is there any documentation and program example that actually
> shows how a program can be set up so it will handle command line arguments
> once compiled and run?
The program (in file arg.f):
CHARACTER*50 ARG
DO I = 1, IARGC()
CALL GETARG(I, ARG)
PRINT*, 'ARG #', I, ' IS ', ARG
ENDDO
END
Compiling it:
g77 arg.f
Using it:
./a.out aap noot mies
Result printed:
ARG # 1 IS aap
ARG # 2 IS noot
ARG # 3 IS mies
Hope this helps,
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)