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-Thread: 103376,49eb370bfd3baa90 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!not-for-mail From: Gerald.Kasner@Physik.Uni-Magdeburg.de (Gerald) Newsgroups: comp.lang.ada Subject: Re: Memory limits in Ada where Fortran has none Date: 6 Mar 2005 14:13:13 -0800 Organization: http://groups.google.com Message-ID: <79567951.0503061413.42aab38e@posting.google.com> References: <1110070479.250902.220540@l41g2000cwc.googlegroups.com> NNTP-Posting-Host: 217.80.81.44 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1110147193 27899 127.0.0.1 (6 Mar 2005 22:13:13 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 6 Mar 2005 22:13:13 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:8775 Date: 2005-03-06T14:13:13-08:00 List-Id: "braver" wrote in message news:<1110070479.250902.220540@l41g2000cwc.googlegroups.com>... > I'm interoperating with a Fortran algorithm using a very large array of > integers: > > PARAMETER (NMAX=100000000) ! a hundred million > DIMENSION ND(NMAX) > C ... > > In Ada, I declared it as > > type Intarray is array (Positive range <>) of Integer; > > ND: Intarray(1..NMAX); -- (1) > > -- then I get a STORAGE_ERROR right about NMAX is 2_000_000. > > If I do, instead, > > type Intarray_Ptr is access Intarray; > ND: Intarray_Ptr; > -- ... > ND := new Intarray(1..NMAX); > > -- I get the STORAGE_ERROR right about NMAX=256*1024*256, which, given > the size of Integer as 32 bits, shows the limit of the _total heap size > in bits_ as the max 32 value. So it leaves me with a 256 MB heap size, > or about 67_108_864 elements -- ~2/3 of what I need. > How do I increase the heap size, if at all possible, or the main memory > size? > > In GNU f77, the array allocates and works fine, so I thought to import > it with pragma Import, just as I do with subroutines -- but the linkage > name for a variable in MAIN__ is not showing in mn main.o! Any idea > how to link/import a GNU f77 _variable_ from GNAT? > > Overall, Ada being the language for large systems, I found it > surprising that Fortran can allocate enough arrays to fill in my > memory, or even take up virtual memory, while Ada raises > STORAGE_ERRORs! I'd like to simply use (1), as in Fortran, and be done > with it... > > Cheers, > Alexy You should dynamically allocate the big array: with Ada.Text_IO; use Ada.Text_IO; procedure mtest is NMAX: constant := 3_000_000; type Intarray is array (Positive range <>) of Integer; type Intarray_Ptr is access all Intarray; ND: Intarray_Ptr; s : Long_Integer; begin ND:=new Intarray(1..NMAX); for i in ND'range loop ND(i):=1; end loop; s:=0; for i in ND'range loop s:=s+Long_Integer(ND(i)); end loop; Put(Long_Integer'Image(s)); end mtest; ./mtest 3000000