getarg and iargc in gcc-4.0.2

Paul Thomas paulthomas2@wanadoo.fr
Mon Dec 5 22:41:00 GMT 2005


Germund,

The following works with gfortran

[prt@localhost svn]# cat demo.f90
program test_arg
  character(80) :: buffer
  narg = iargc ()
  print *, "no. of args = ", narg
  do i = 1, narg
    call getarg (i, buffer)
    print *, buffer
  end do
end program test_arg

[prt@localhost svn]# ./a.out my arg your arg
 no. of args =            4
 my
 arg
 your
 arg

Whilst not standard (as using -std=f95 will demonstrate), this is a 
fairly common manifestation of argument reading in fortran.

Regards

Paul Thomas



More information about the Gcc-help mailing list