Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!jato!csi.jpl.nasa.gov!mwette From: mwette@csi.jpl.nasa.gov (Matt Wette) Newsgroups: comp.lang.fortran Subject: Re: Command line arguements? Message-ID: <1991May30.155930.7361@jato.jpl.nasa.gov> Date: 30 May 91 15:59:30 GMT References: <1991May30.135749.10529@eagle.lerc.nasa.gov> Sender: news@jato.jpl.nasa.gov Reply-To: mwette@csi.jpl.nasa.gov (Matt Wette) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 60 Nntp-Posting-Host: mr-ed.jpl.nasa.gov In article <1991May30.135749.10529@eagle.lerc.nasa.gov>, pstowne@zargon.lerc.nasa.gov (Charlie Towne) writes: |> In article eesnyder@boulder.Colorado.EDU (Eric E. Snyder) writes: |> >I need to write a program that takes arguements from the |> >command line and passes them to variables with in the program. |> > |> >eg: |> > |> > a.out arg1 arg2 .... |> > |> >This must be amazingly simple but I can't find anything in |> >my SGI Iris 4D f77 manual. What do you call this and where |> >can I find out about it? |> |> See the getarg(3F) man page in the Iris-4D Fortran 77 Reference Manual |> Pages (Doc. number 007-0621-030). It can be used as follows: |> |> character*1 iargc,jargc |> c |> c-----get arguments from command line |> c |> call getarg(1,iargc) |> call getarg(2,jargc) |> read (iargc,'(i1)') iarg |> read (jargc,'(i1)') jarg |> |> The calls to getarg return the 1st and 2nd arguments in the character |> variables iargc and jargc. The internal reads convert the character |> variables to integers. Note that this example is for single digit |> integer arguments. |> |> >Disclaimer: |> > |> > Be nice-- I'm just a biologist:-) |> |> That's OK. I'm just an engineer. |> |> -- |> Charlie Towne Email: pstowne@zargon.lerc.nasa.gov |> MS 5-11 Phone: (216) 433-5851 |> NASA Lewis Research Center |> Cleveland, OH 44135 The problem here is that getting command line arguments is a machine dependent process. The solution is to write a wrapper for each machine that makes the process of getting command line arguments portable. This has been done in R.K.Jones and T.Crabtree, "Fortran Tools for VAX/VMS and MS-DOS," Wiley, 1988 I've written SunFortran versions of thier routines. Things work much nicer in Fortran if you take the time to set up enough utility routines as in the above reference.... Matt -- _________________________________________________________________ Matthew R. Wette | Jet Propulsion Laboratory, 198-326 mwette@csi.jpl.nasa.gov | 4800 Oak Grove Dr, Pasadena,CA 91109 -----------------------------------------------------------------