using iargc()/getarg() form C
Steve Kargl
sgk@troutmask.apl.washington.edu
Wed Feb 23 04:24:00 GMT 2005
On Tue, Feb 22, 2005 at 10:00:56PM -0600, Satish Balay wrote:
> On Tue, 22 Feb 2005, Steve Kargl wrote:
>
> > > Could you tell me what are the correct symbols in the fortran
> > > library that I can call directly from C?
> >
> > I just looked at the implementation of iargc. You can't
> > get at the command line arguments with the gfortran
> > functions from a C program. Well, you might be able to
> > get them, but we need more details in exactly what
> > you're doing.
>
> This usage works with gcc4 with the following change:
> iargc_ -> _gfortran_iargc
> getarg_ -> _gfortran_getarg_i4
You don't need to do the above.
> # gcc -c arg.c
> # gcc4 -c arg.c
> # gfortran arg-test.f arg.o -o arg-test
This is crucial. You must link the final program with the
gfortran command.
kargl[218] ~/gcc/work/bin/gcc -c gr.c
kargl[219] gfc -o foo foo.f90 gr.o
kargl[220] ./foo 1 2 3
3
kargl[221] cat gr.c
extern int _gfortran_iargc(void);
int iargc_(void)
{
return _gfortran_iargc();
}
kargl[222] cat foo.f90
program main
integer i
i = iargc()
print *, i
end
I leave getargs to you to wrap.
--
Steve
More information about the Fortran
mailing list