comp.lang.ada
 help / color / mirror / Atom feed
From: bglbv@my-dejanews.com
Subject: Re: How To Compile Ada Prog Interfaced With Fortran
Date: 1998/10/03
Date: 1998-10-03T00:00:00+00:00	[thread overview]
Message-ID: <6v5k8l$5fr$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 87ogs6g498.fsf@zaphod.enst.fr

In article <87ogs6g498.fsf@zaphod.enst.fr>,
  Samuel Tardieu <sam@ada.eu.org> wrote:
> >>>>> "Samir" == Samir N Muhammad <sam818@felix.seas.gwu.edu> writes:
>
> Samir> Hello Everybody Could any one tell me what are the steps for
> Samir> compiling, binding, and linking an Ada program interfaced with
> Samir> an intrinsic Fortran function(e.g. the MATMUL or
> Samir> DOT_PRODUCT).
>
> Compile your Fortran code into x.o, y.o and z.o (for example), then
> use the regular gnatmake command with additionnal objects given to the
> linker (using the -largs switch):
>
> % gnatmake my_ada_program -largs x.o y.o z.o
>
> Or better, put your Fortran objects into a library (let's call it libft.a),
> and add a <<pragma Linker_Options ("-lft");>> in an Ada package that
> uses that library.

While this is reasonable advice in general, it should be noted that the
original poster asked about Fortran *intrinsic* procedures. Fortran has
some restrictions about intrinsic procedures, such as:

"If an intrinsic function does not have a specific name, it shall not be used
as an actual argument." (section 13.1 of the Fortran 95 standard)

The intrinsic functions that do have specific names are listed in section
13.13, and even some of those are disallowed as actual arguments. DOT_PRODUCT
and MATMUL do not even have specific names in the first place.

I would have to check the exact wording of Annex B of the Ada 95 standard,
but as far as I remember one needs to specify the external name of the
Fortran subprogram in a pragma Import() for things to work. This may be
difficult if there is no external name (for example because the Fortran
processor always inlines the intrinsic call). A sufficiently smart Ada
processor could of course be thoroughly familiar with Fortran intrinsic
functions and inline them just as the Fortran compiler would; are there
any such Ada processors on the market at the moment?

On a broader note, writing Ada 95 interfaces for Fortran 90/95 module
procedures, or even for non-module procedures which require an explicit
interface (for example because they have OPTIONAL or POINTER or assumed-shape
arguments) might also be less than trivial even after reading Annex B.
Most Fortran 90/95 compilers I'm familiar with do not document the details
of either the name mangling or the internal representation of pointers and
assumed-shape arrays (NAGWare f95 is an exception to this), and I would be
very surprised if the developers of Ada 95 compilers were able to provide
full interfacing support without having access to such documentation.

What Ada 95 does is provide a standard way to express in Ada source code
the fact that a subprogram is implemented in another language. But there
is no guarantee that in so doing one won't exceed the capabilities of a
particular Ada implementation.

That said, I'm quite willing to believe that calling Fortran 66/77 numerical
routines from Ada is relatively painless in practice, at least as long as the
Fortran and Ada compilers involved agree on what argument passing convention
should be used.

I'll also note that the original question was about Ada in general, not about
any particular implementation. The response I'm following up on assumed GNAT,
perhaps incorrectly.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  parent reply	other threads:[~1998-10-03  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-23  0:00 How To Compile Ada Prog Interfaced With Fortran Samir N. Muhammad
1998-09-23  0:00 ` Samuel Tardieu
1998-09-23  0:00   ` oliver
1998-09-23  0:00     ` Alain Le Guennec
1998-09-23  0:00     ` Robert I. Eachus
1998-09-23  0:00     ` Gisle S{lensminde
1998-09-23  0:00     ` Larry Kilgallen
1998-09-24  0:00     ` Ken Thomas
1998-09-24  0:00       ` dewarr
1998-10-03  0:00   ` bglbv [this message]
1998-09-23  0:00 ` David C. Hoos, Sr.
1998-09-24  0:00   ` dewarr
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox