Fortran vararg intrinsics from C/C++
Steve Kargl
sgk@troutmask.apl.washington.edu
Fri Jan 9 17:02:00 GMT 2009
On Fri, Jan 09, 2009 at 12:38:55PM -0000, Paul Keir wrote:
> Hi all,
>
> Is there a way to call Fortran statements or intrinsics, which have a
> variable number of arguments, from C/C++?
AFAIK. No.
> I'm thinking of IO statements
> such as "write", but also intrinsics such as "max" and "min".
Many intrinsics are expanded in-line, so library routines do
not exist. If you go trawling through trans-intrinsics.c, you'll
find that min and max fall into this category.
> I had the idea to generate my own Fortran stub subroutines; one for
> each argument count that I needed for each case: e.g. max2i4, max3i4,
> write1, write2 etc. But while nm can find other intrinsic names in
> libfortran.o (say _gfortran_random_r4), I don't see any with
> variable argument counts.
That's because there aren't any intrinsics that have a variable number
of arguments that make to the library.
> I guess this is because the gfortran compiler takes care of their
> uniqueness itself. Is there then no option apart from printf and
> my own custom C/C++ varargs versions. I had hoped I could use
> libgfortran.a for all intrinsics.
You could define a module procedure or use Fortran's optional attribute
to simulate varargs, but AFAIK Fortran itself does not have that
concept.
--
Steve
More information about the Fortran
mailing list