This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Small mountain


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]