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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,89d280850f5d8df X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-21 18:17:50 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcarron@belcan.com (Karen Carron) Newsgroups: comp.lang.ada Subject: Re: Passing Unconstrained Arrays from FORTRAN to an Ada95 subunit Date: 21 Jul 2002 18:17:50 -0700 Organization: http://groups.google.com/ Message-ID: <5489a352.0207211717.cd9e66f@posting.google.com> References: <5489a352.0207210544.3d50d423@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 1027300670 7345 127.0.0.1 (22 Jul 2002 01:17:50 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 22 Jul 2002 01:17:50 GMT Xref: archiver1.google.com comp.lang.ada:27289 Date: 2002-07-22T01:17:50+00:00 List-Id: tmoran@acm.org wrote in message news:... > > > What happens if you pass a constrained array, ie, > > > type int_array_type is array(integer range 1.. 10) of integer; > > Yes, this works, but the routine with the unconstrained array is called > > by many other routines which pass it varying sizes of arrays. > One technique used in interfacing to C is to declare > type int_array_type is array(positive) of integer; > That is, declare the array type large enough for any actual instance > and then make sure in the Ada routine that you don't index beyond > the actual data. It used to be common practice in Fortran to pass > the length of the array as a separate parameter, eg > procedure something(a,n) > integer n,a(n) > which you could write in Ada as > procedure something(a : in out int_array_type; > n : in positive); > Does modern Fortran pass the length implicitly? Apparently your Ada > compiler doesn't think so. Thanks for your suggestions. I got it to work by constraining the array to the subtype positive. So type int_array_type is now: type int_array_type (positive) of integer; but it performed the same as before when I constrained int_array_type to integer (!!!!), although it did get rid of the compiler warnings. I was thinking it worked because the range was now constrained, but that appears to not be the case; not only must it be constrained, but the lower bounds must be 1.