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=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ebf0c2e0d9df034 X-Google-Attributes: gid103376,public From: lafage8770@my-deja.com Subject: Re: Ada95 + FORTRAN 77 Date: 1999/09/06 Message-ID: <7r07rr$gap$1@nnrp1.deja.com>#1/1 X-Deja-AN: 521622640 References: X-Http-Proxy: 1.0 x21.deja.com:80 (Squid/1.1.22) for client 130.87.249.119 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Mon Sep 06 11:17:20 1999 GMT X-MyDeja-Info: XMYDJUIDlafage8770 Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.08 [en] (X11; I; Linux 2.2.11 i686) Date: 1999-09-06T00:00:00+00:00 List-Id: In article , Preben Randhol 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.