Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cs.dal.ca!silvert From: silvert@cs.dal.ca (Bill Silvert) Newsgroups: comp.lang.fortran Subject: Re: Command line arguements? Message-ID: <1991May30.175533.13315@cs.dal.ca> Date: 30 May 91 17:55:33 GMT References: <1991May30.135749.10529@eagle.lerc.nasa.gov> Sender: silvert@cs.dal.ca.UUCP (Bill Silvert) Reply-To: silvert%biome@cs.dal.ca Organization: Habitat Ecology Div., Bedford Inst. of Oceanography Lines: 34 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. >> a.out arg1 arg2 .... > >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. Whoa! My manual says that iargc() returns an integer. The usage is: CALL GETARG(I, STRING) and ICOUNT = IARGC() Conversion with internal reads is not called for! (I just checked it, the manual description is correct.) -- William Silvert, Habitat Ecology Division, Bedford Inst. of Oceanography P. O. Box 1006, Dartmouth, Nova Scotia, CANADA B2Y 4A2. Tel. (902)426-1577 UUCP=..!{uunet|watmath}!dalcs!biome!silvert BITNET=silvert%biome%dalcs@dalac InterNet=silvert%biome@cs.dal.ca