From: lafage8770@my-deja.com
Subject: Re: Ada95 + FORTRAN 77
Date: 1999/09/06
Date: 1999-09-06T00:00:00+00:00 [thread overview]
Message-ID: <7r07rr$gap$1@nnrp1.deja.com> (raw)
In-Reply-To: m3hfl8ihzd.fsf@kiuk0156.chembio.ntnu.no
In article <m3hfl8ihzd.fsf@kiuk0156.chembio.ntnu.no>,
Preben Randhol <randhol@pvv.org> wrote:
> I have read (think it was on the net) that one can bind Fortran and
> Ada95 together. Does anybody know if one can use Fortran 77?
Yes, for instance g77 cooperates well with gnat on my GNU/Linux box.
> I have a calculation program written in FORTRAN 77 and want to just
> make a graphical interface to it so that it will be easier to do
> calculations. I want to use Ada95 and GTK+. So I'm wondering if
> anybody know of a working example for the Ada95 - FORTRAN 77
> connection (don't have to be any GUI) that I could look at?
First, I will send you an example which has been given
on this list
(by Sune Falck on Fri, 12 Dec 1997 20:03:46 +0200)
-------------------------------------------------------------------
-- file ftest.adb
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
procedure Ftest is
procedure Adder (A : in Float; B: in Float; Sum : out Float);
pragma Import (Fortran, Adder, Link_Name => "adder_");
A : Float := 12.0;
B : Float := 13.0;
Sum : Float;
begin
Adder (A, B, Sum);
Put (A); Put (B); Put ('='); Put (Sum); New_Line;
end Ftest;
-------------------------------------------------------------------
file adder.f:
SUBROUTINE ADDER (A, B, SUM)
REAL*4 A
REAL*4 B
REAL*4 SUM
SUM = A + B
END
-------------------------------------------------------------------
g77 -c adder.f
gnatmake ftest -largs adder.o
... and it works
AND NOW even better: how to pass common ?
(It works, but I do not know if this is the ``proper way''
and would appreciate any comment)
-------------------------------------------------------------------
file common_basic.ads:
with Interfaces.Fortran; use Interfaces.Fortran;
package Common_Basic is
type Basic_Common is record
X, Y, Z : Double_Precision;
end record;
Basic : Basic_Common;
pragma Import(Fortran, Basic, Link_Name => "basic_");
end Common_Basic;
-------------------------------------------------------------------
file ada_application.adb:
with Interfaces.Fortran; use Interfaces.Fortran;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Common_Basic; use Common_Basic;
procedure Ada_Application is
procedure Compute(T : in Double_Precision);
pragma Import(Fortran, Compute, Link_Name => "compute_");
begin
Basic.X :=1.0;
Basic.Y :=2.0;
Basic.Z :=3.0;
Put(Float(Basic.X));
Put(Float(Basic.Y));
Put(Float(Basic.Z));
New_Line;
Compute(0.0);
Put(Float(Basic.X));
Put(Float(Basic.Y));
Put(Float(Basic.Z));
New_Line;
end Ada_Application;
-------------------------------------------------------------------
file compute.f:
subroutine compute(t)
implicit none
c double precision t
real*8 t
double precision x,y,z
common /basic/ x,y,z
write(*,*)'t : ',t
write(*,*)'x : ',x
write(*,*)'y : ',y
write(*,*)'z : ',z
z=sqrt(z)
return
end
-------------------------------------------------------------------
g77 -c compute.f
gnatmake ada_application -largs compute.o
Et voila !
-------------------------------------------------------------------
--
Vincent Lafage
``Qui est un plumeur de faisan ? ''
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
next prev parent reply other threads:[~1999-09-06 0:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-09-06 0:00 Ada95 + FORTRAN 77 Preben Randhol
1999-09-06 0:00 ` Gisle S�lensminde
1999-09-06 0:00 ` Preben Randhol
1999-09-06 0:00 ` lafage8770 [this message]
1999-09-06 0:00 ` Matthew Heaney
1999-09-06 0:00 ` Robert Dewar
1999-09-06 0:00 ` Preben Randhol
1999-09-06 0:00 ` Robert Dewar
1999-09-06 0:00 ` Preben Randhol
1999-09-06 0:00 ` Robert Dewar
1999-09-07 0:00 ` Preben Randhol
1999-09-08 0:00 ` Robert Dewar
1999-09-07 0:00 ` okellogg
1999-09-08 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox