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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,89d280850f5d8df,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-19 17:57:10 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcarron@belcan.com (Karen Carron) Newsgroups: comp.lang.ada Subject: Passing Unconstrained Arrays from FORTRAN to an Ada95 subunit Date: 19 Jul 2002 17:57:09 -0700 Organization: http://groups.google.com/ Message-ID: <5489a352.0207191657.5fac87a8@posting.google.com> NNTP-Posting-Host: 205.133.202.67 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1027126630 7276 127.0.0.1 (20 Jul 2002 00:57:10 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 20 Jul 2002 00:57:10 GMT Xref: archiver1.google.com comp.lang.ada:27260 Date: 2002-07-20T00:57:10+00:00 List-Id: What I have found is that the offset in referencing individual array elements in FORTRAN is 1 (ex. the first element is referenced with a subscript of value 1) but in Ada it is 0. This is causing a problem since the subscripts are variables in a fortran common. Here is an example of what I'm trying to do: FORTRAN calling routine: program callada common /subs/ i1,i2,i3 integer a(10) i1 = 1 i2 = 2 i3 = 3 a(i1) = 10 a(i2) = 20 a(i3) = 30 call adainit call pass_array(a) stop end ... Ada units: package type_decl is type int_array_type is array(integer range <>) of integer; end type_decl; ... with type_decl; use type_decl; package routines is procedure pass_array (a : in out int_array_type); pragma export (fortran, pass_array, "pass_array"); end routines; ... package common_subs is type subs_rec is i1, i2, i3 : integer; end record; subs : subs_rec; pragma volatile (subs); pragma import_object (subs, "subs"); end common_subs; ... with common_subs; package body routines is -- pass_array can be called by more than one unit with varying -- sizes of arrays procedure pass_array (a : in out int_array_type) is var1 : integer; begin var1 := a(common_subs.subs.i1) + a(common_subs.subs.i2); end pass_array; end routines; In the fortran equivalent of pass_array, the var1 would be 30. But in the ada version, var1 is 50. I tried the following but without any success: 1) I modified type_decl package as follows: -- added: with interfaces.fortran; use interfaces.fortran; package type_decl is type int_array_type is array(integer range <>) of integer; -- added: pragma convention (fortran, int_array_type); end type_decl; 2) I modified the original type_decl package as follows: package type_decl is -- I changed the range to positive from integer type int_array_type is array(positive range <>) of integer; end type_decl; I would very much appreciate any other ideas. Thanks!