Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!amdcad!sun!khb From: khb@chiba.Eng.Sun.COM (Keith Bierman - SPD Advanced Languages) Newsgroups: comp.lang.fortran Subject: Re: Fortran commmand line arguments Message-ID: Date: 28 Jun 90 16:07:19 GMT References: <1990Jun28.153908.4911@caen.engin.umich.edu> Sender: news@sun.Eng.Sun.COM Distribution: usa Organization: Sun MegaSystems Lines: 62 In-reply-to: cys@caen.engin.umich.edu's message of 28 Jun 90 15:39:08 GMT In article <1990Jun28.153908.4911@caen.engin.umich.edu> cys@caen.engin.umich.edu (CAO YUSONG ) writes: I am writting a Fortran program now. I used to be a C programmer. In C, one can retrieve information from command line arguments, i.e. ..... It depends on what system you are on. On many systems it is quite easy. For example, on a Sun see page 309 (f77v1.3) of the fortran ref guide, or getarg(3f) NAME getarg, iargc - get the kth command line argument SYNOPSIS subroutine getarg ( k, arg ) character*(*) arg function iargc () DESCRIPTION The statement call getarg( k , arg ) will get the kth command-line argument and put it into arg . The 0th argument is the command name. The function iargc returns the index of the last command- line argument, and therefore the number of arguments after the command name. EXAMPLE demo% cat tesargs.f character argv*10 integer i, iargc, m m = iargc() i = 1 do while ( i .le. m ) call getarg ( i, argv ) write( *, '( i2, 1x, a )' ) i, argv i = i + 1 end do stop end demo % a.out first second last 1 first 2 second 3 last demo% FILES /usr/lang/SC0.0/libF77.a SEE ALSO execve(2), getenv(3F) -- Keith H. Bierman |*My thoughts are my own. !! kbierman@Eng.Sun.COM It's Not My Fault | MTS --Only my work belongs to Sun* khb@chiba.Eng.Sun.COM I Voted for Bill & | Advanced Languages/Floating Point Group (415 336 2648) Opus "When the going gets Weird .. the Weird turn PRO"