* How To Compile Ada Prog Interfaced With Fortran @ 1998-09-23 0:00 Samir N. Muhammad 1998-09-23 0:00 ` David C. Hoos, Sr. 1998-09-23 0:00 ` Samuel Tardieu 0 siblings, 2 replies; 12+ messages in thread From: Samir N. Muhammad @ 1998-09-23 0:00 UTC (permalink / raw) Hello Everybody Could any one tell me what are the steps for compiling, binding, and linking an Ada program interfaced with an intrinsic Fortran function(e.g. the MATMUL or DOT_PRODUCT). For example, an Ada program interfaced with Fortran might look like procedure Linear_Algebra is ...... function Dot_Product(V1:Vector_Type;V2:Vector_Type) return Scalar_Type; pragma Import(Fortran,Dot_Product,"DOT_PRODUCT") ; ..... begin -- Linear_Algebra ..... S := Dot_Product(Vect1,Vect2) ; ...... end Linear_Algebra ; Now anyone could argue: why not write the Dot_Product in Ada? I used Dot_Product for illustration. The larger picture is how to utilize the already available and highly optimized linear algebra packages such as BLAS(Basic Linear Algebra Subroutines) that are written in Fortran. Any help is highly appreciated. Samir Muhammad, ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 How To Compile Ada Prog Interfaced With Fortran Samir N. Muhammad @ 1998-09-23 0:00 ` David C. Hoos, Sr. 1998-09-24 0:00 ` dewarr 1998-09-23 0:00 ` Samuel Tardieu 1 sibling, 1 reply; 12+ messages in thread From: David C. Hoos, Sr. @ 1998-09-23 0:00 UTC (permalink / raw) Samir N. Muhammad wrote in message ... >Hello Everybody > >Could any one tell me what are the steps for compiling, binding, >and linking >an Ada program interfaced with an intrinsic Fortran function(e.g. the >MATMUL or DOT_PRODUCT). <snip> I would begin by studying the Referenc Manual Section B.5, obscurely named "Interfacing with Fortran." ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` David C. Hoos, Sr. @ 1998-09-24 0:00 ` dewarr 0 siblings, 0 replies; 12+ messages in thread From: dewarr @ 1998-09-24 0:00 UTC (permalink / raw) In article <AIfjfq059GA.180@samson.airnet.net>, "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> wrote: > > Samir N. Muhammad wrote in message ... > >Hello Everybody > > > >Could any one tell me what are the steps for compiling, binding, > >and linking > >an Ada program interfaced with an intrinsic Fortran function(e.g. the > >MATMUL or DOT_PRODUCT). > <snip> > > I would begin by studying the Referenc Manual Section B.5, obscurely named > "Interfacing with Fortran." Now you've gone and given away our most guarded secret. Next you will probably be telling people to read the secret GNAT documentation carefully hidden away in the documentation subdirectory and there will be NO MORE SECRETS :-) -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 How To Compile Ada Prog Interfaced With Fortran Samir N. Muhammad 1998-09-23 0:00 ` David C. Hoos, Sr. @ 1998-09-23 0:00 ` Samuel Tardieu 1998-09-23 0:00 ` oliver 1998-10-03 0:00 ` bglbv 1 sibling, 2 replies; 12+ messages in thread From: Samuel Tardieu @ 1998-09-23 0:00 UTC (permalink / raw) >>>>> "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. Sam -- Samuel Tardieu -- sam@ada.eu.org ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` Samuel Tardieu @ 1998-09-23 0:00 ` oliver 1998-09-23 0:00 ` Larry Kilgallen ` (4 more replies) 1998-10-03 0:00 ` bglbv 1 sibling, 5 replies; 12+ messages in thread From: oliver @ 1998-09-23 0:00 UTC (permalink / raw) In article <87ogs6g498.fsf@zaphod.enst.fr>, 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. > > Sam This seems to good to be true. Could one use this approach to gain complete access to LAPACK or to the Numerical Recipes software? Or is this something that one can do in theory but no one does in practice? I'm looking into using Ada for numeric programming, but I'm disheartened to find that there is very little supporting code available. Is this because it is very easy in Ada to access existing functions in such packages as LAPACK? -Bill ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` oliver @ 1998-09-23 0:00 ` Larry Kilgallen 1998-09-23 0:00 ` Gisle S{lensminde ` (3 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: Larry Kilgallen @ 1998-09-23 0:00 UTC (permalink / raw) In article <william.oliver-2309981150180001@tele-anx0207.colorado.edu>, william.oliver@colorado.edu (oliver) writes: > In article <87ogs6g498.fsf@zaphod.enst.fr>, sam@ada.eu.org wrote: >>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. >> >> Sam > > This seems to good to be true. Could one use this approach to gain > complete access to LAPACK or to the Numerical Recipes software? Or is this > something that one can do in theory but no one does in practice? I'm > looking into using Ada for numeric programming, but I'm disheartened to > find that there is very little supporting code available. Is this because > it is very easy in Ada to access existing functions in such packages as > LAPACK? Supposedly Ada is devoted to reusing good software. It would be fatuous to adopt an attitude that software cannot be "good" if it was written in another language. This is particularly the case where the nature of the software is the specialty of the other languages, as numerics are to Fortran. Larry Kilgallen ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` oliver 1998-09-23 0:00 ` Larry Kilgallen @ 1998-09-23 0:00 ` Gisle S{lensminde 1998-09-23 0:00 ` Alain Le Guennec ` (2 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: Gisle S{lensminde @ 1998-09-23 0:00 UTC (permalink / raw) >> Sam > >This seems to good to be true. Could one use this approach to gain >complete access to LAPACK or to the Numerical Recipes software? Or is this >something that one can do in theory but no one does in practice? I'm >looking into using Ada for numeric programming, but I'm disheartened to >find that there is very little supporting code available. Is this because >it is very easy in Ada to access existing functions in such packages as >LAPACK? There is already made a LAPACK binding for Ada, and you can find it at ftp://ftp.cs.nyu.edu/pub/gnat/contrib/lapack-ada/ I have not tried it myself, so I can't guaranty the quality. -- ------------------------------------------------------------------------ Gisle S�lensminde Tlf: 55 34 07 63 Eliasmarken 16 5031 Laksev�g epost: gisle@ii.uib.no UNIX is user friendly. It's just selective about who its friends are. ------------------------------------------------------------------------ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` oliver 1998-09-23 0:00 ` Larry Kilgallen 1998-09-23 0:00 ` Gisle S{lensminde @ 1998-09-23 0:00 ` Alain Le Guennec 1998-09-23 0:00 ` Robert I. Eachus 1998-09-24 0:00 ` Ken Thomas 4 siblings, 0 replies; 12+ messages in thread From: Alain Le Guennec @ 1998-09-23 0:00 UTC (permalink / raw) On any GNAT ftp-mirror, you'll find an Ada binding to LAPACK in the sub-directory contrib/lapack-ada/ I used it successfully about 2 years ago. No need to reinvent the wheel. william.oliver@colorado.edu (oliver) writes: > >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. > > > > Sam > > This seems to good to be true. Could one use this approach to gain > complete access to LAPACK or to the Numerical Recipes software? Or is this > something that one can do in theory but no one does in practice? I'm > looking into using Ada for numeric programming, but I'm disheartened to > find that there is very little supporting code available. Is this because > it is very easy in Ada to access existing functions in such packages as > LAPACK? > > -Bill /Alain Le Guennec, not speaking for IRISA. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` oliver ` (2 preceding siblings ...) 1998-09-23 0:00 ` Alain Le Guennec @ 1998-09-23 0:00 ` Robert I. Eachus 1998-09-24 0:00 ` Ken Thomas 4 siblings, 0 replies; 12+ messages in thread From: Robert I. Eachus @ 1998-09-23 0:00 UTC (permalink / raw) In article <william.oliver-2309981150180001@tele-anx0207.colorado.edu> william.oliver@colorado.edu (oliver) writes: > This seems to good to be true. Could one use this approach to gain > complete access to LAPACK or to the Numerical Recipes software? Yes. > Or is this something that one can do in theory but no one does in > practice? Sort of. > I'm looking into using Ada for numeric programming, but I'm > disheartened to find that there is very little supporting code > available. Is this because it is very easy in Ada to access > existing functions in such packages as LAPACK? Yes and no. There are some good numerics libraries available which support Ada (NaG and others), and in fact there are some good numerics libraries which are written in Ada, even when used from Fortran. But when you use the "standard" Fortran libraries, you find there is a problem. They generate junk if the values go out of range or the matrices become too stiff. Even though, in the good libraries, there is an error number scheme to tell you when that happens, on the Ada side, users expect to get notified through exceptions. So when you look at binding to numerics libraries, some bindings are trivial, some are available from the vendor, and some are just too much work. I've looked at the Numerical Recipies book, and been appalled at the amount of non-trivial work to recode some of them in Ada. The problem is not the actual algorithmic code, it is the amount of thinking necessary to design appropriate Ada interfaces. (Rewriting the code in Ada, although unnecessary, would probably be done anyway. It would amount to such a small part of the effort compared to changing the interfaces and rewriting the documentation.) -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is... ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` oliver ` (3 preceding siblings ...) 1998-09-23 0:00 ` Robert I. Eachus @ 1998-09-24 0:00 ` Ken Thomas 1998-09-24 0:00 ` dewarr 4 siblings, 1 reply; 12+ messages in thread From: Ken Thomas @ 1998-09-24 0:00 UTC (permalink / raw) oliver wrote: > > In article <87ogs6g498.fsf@zaphod.enst.fr>, 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). > > > > > > > Sam > > This seems to good to be true. Could one use this approach to gain > complete access to LAPACK or to the Numerical Recipes software? Or is this > something that one can do in theory but no one does in practice? I'm > looking into using Ada for numeric programming, but I'm disheartened to > find that there is very little supporting code available. Is this because > it is very easy in Ada to access existing functions in such packages as > LAPACK? > > -Bill Bindings to LAPACK are around see gnat directories. Ken -- Dr K.S. Thomas Department of Electronics and Computer Science University of Southampton Highfield Southampton SO17 1BJ United Kingdom Telephone : (+44) 01703 592170 Fax : (+44) 01703 593903 email: kst@ecs.soton.ac.uk ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-24 0:00 ` Ken Thomas @ 1998-09-24 0:00 ` dewarr 0 siblings, 0 replies; 12+ messages in thread From: dewarr @ 1998-09-24 0:00 UTC (permalink / raw) In article <360A0045.39F4@ecs.soton.ac.uk>, Ken Thomas <kst@ecs.soton.ac.uk> wrote: > Bindings to LAPACK are around see gnat directories. > Ken It is worth mentioning that in fact it is very easy to create such bindings. These LAPACK bindings were done by a student at NYU, who previously knew very little Ada. If you look at them you will see that the process is indeed simple ("too good to be true" :-) -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How To Compile Ada Prog Interfaced With Fortran 1998-09-23 0:00 ` Samuel Tardieu 1998-09-23 0:00 ` oliver @ 1998-10-03 0:00 ` bglbv 1 sibling, 0 replies; 12+ messages in thread From: bglbv @ 1998-10-03 0:00 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~1998-10-03 0:00 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1998-09-23 0:00 How To Compile Ada Prog Interfaced With Fortran Samir N. Muhammad 1998-09-23 0:00 ` David C. Hoos, Sr. 1998-09-24 0:00 ` dewarr 1998-09-23 0:00 ` Samuel Tardieu 1998-09-23 0:00 ` oliver 1998-09-23 0:00 ` Larry Kilgallen 1998-09-23 0:00 ` Gisle S{lensminde 1998-09-23 0:00 ` Alain Le Guennec 1998-09-23 0:00 ` Robert I. Eachus 1998-09-24 0:00 ` Ken Thomas 1998-09-24 0:00 ` dewarr 1998-10-03 0:00 ` bglbv
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox