From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3b74366795b5f025 X-Google-Attributes: gid103376,public X-Google-Thread: 1094ba,91de07e135ca7c3b,start X-Google-Attributes: gid1094ba,public From: bglbv@my-dejanews.com Subject: Re: How To Compile Ada Prog Interfaced With Fortran Date: 1998/10/03 Message-ID: <6v5k8l$5fr$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 397371998 References: <87ogs6g498.fsf@zaphod.enst.fr> X-Http-Proxy: 1.0 x5.dejanews.com:80 (Squid/1.1.22) for client 130.225.238.252 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Sat Oct 03 16:44:04 1998 GMT Newsgroups: comp.lang.ada,comp.lang.fortran X-Http-User-Agent: Mozilla/4.04 [en] (X11; I; IRIX64 6.2 IP19) Date: 1998-10-03T00:00:00+00:00 List-Id: In article <87ogs6g498.fsf@zaphod.enst.fr>, Samuel Tardieu wrote: > >>>>> "Samir" == Samir N Muhammad 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 <> 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