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: Robert Dewar Subject: Re: Ada95 + FORTRAN 77 Date: 1999/09/06 Message-ID: <7r0u2o$vik$1@nnrp1.deja.com>#1/1 X-Deja-AN: 521738736 References: <7r07rr$gap$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x25.deja.com:80 (Squid/1.1.22) for client 129.37.79.39 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Mon Sep 06 17:36:25 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-09-06T00:00:00+00:00 List-Id: In article , Preben Randhol wrote: > Thanks! It worked very nice. I also noticed that one have to be > careful with the variable types. Changing, in the F77 program, REAL*4 > to DOUBLE PRECISION resulted in a bug in the output. But when I added > Interfaces.Fortran and used Double_Precision it worked fine again :-) Well yes, of course you must be careful to have corresponding types, and typically systems will not be able to check this in Ada-Fortran interfacing (actually most Fortran compilers don't even check this in Fortran-Fortran interfacing). Do if you are using DOUBLE PRECISION in the Fortran program, you must use Interfaces.Fortran.Double_Precision. In GNAT, you can simply use Long_Float, and this will always work, because GNAT always defines type Fortran_Integer is new Integer; type Real is new Float; type Double_Precision is new Long_Float; One other point is to be careful of type Logical in the Fortran interface. This is defined to be a new Boolean, but with very unusual (zero/non-zero) semantics. There are no ACVC tests to ensure that this is done right, and it is quite a lot of specialized mechanism in the compiler to deal with this very non-standard Boolean type. So if you rely on this, be careful to check that your compiler handles this. The proper handling of Fortran Logical was only recently added to GNAT (for version 3.12). At the same time, we also implemented a rather nice feature: type C_Bool is new Boolean; pragma Convention (C, C_Bool); the semantics of this boolean will be like C, zero/non-zero, rather than normal Ada representation semantics. This can make interfacing to booleans in C quite a bit cleaner and more abstract (otherwise you have to explicitly treat the C logical values as integers on the Ada sign with zero/non-zero semantics) Robert Dewar Ada Core Technologies Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.