🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50587

Re: Large Arrays

#50587
From: Stephan Melin
Date: Thu, 16 Sep 1993 08:39
74 lines
2446 bytes
In article <276tfp$96n@nuscc.nus.sg>, engp3056@leonis.nus.sg (JEROME HANSABHAYA ELLEPOLA) writes:
|> I am writing a CFD code which needs 10, arrays of [101][801] in the main
|> program.
|> 
|> In one function there is another 5, arrays of [101][801],
|> the program runs fine on a Spark10 but core dumps ( segmentation fault )
|> at that point.
|> 
|> When the arrays are defined as floats things seem to work.
|> 
|> I have about 64MB of RAM, and assuming that all functions use the memory
|> at all times, with 3 functions I would need (3*5+8)*101*801*4=15MB
|> 
|> Hardly a problem right?
|> 
|> I look forward to any pointers.
|> 
|> Regards
|> 
|> Jerome

What about explicitly using malloc?

Look at those two programs:
#include <stdio.h>

#define BIG 10000000


void main( void)
{
   double big[ BIG];
   

   printf( "Success\n");
}
This programs compiles but dies on my SparcStation 10.

This one here works fine and prints 'Success':
#include <malloc.h>
#include <stdio.h>

#define BIG 10000000


void main( void)
{
   double  *big;
   
   big = malloc( BIG * sizeof( double));
   if (big != NULL)
      {
         printf( "Success\n");
      }
   else
      {
         printf( "Failed\n");
      }
}


I hope this helps...

  Stephan

BTW: Why do you use static array definitions in C ?
     Or is it just an F2Ced f77 source?

-- 
Stephan Melin                     | 38# 70" Hoyt GoldMedalist, 32.5" ACE 430
melin@hlrserv.hlrz.kfa-juelich.de | and 32.5" XX75 2216, ACE UHR rod, ACE short
hkf418@djukfa11.bitnet            | rods, ACE V-bar extd., AGF V-bar, AGF ZGV,
Phone: (49)2461/61-2318  (office) | 20 string fastflight
Fax: (49)2461/61-2430    (office) | sometimes '92 Trek 8000
Technical Details
Message-ID: <1993Sep16.103910@hlrz24.hlrz.kfa-juelich.de>
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!darwin.sura.net!news.dfn.de!zam103!hlrz24!melin
References: <276tfp$96n@nuscc.nus.sg>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,5b89b3128344e7ac
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-09-16 01:55:58 PST
Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!darwin.sura.net!news.dfn.de!zam103!hlrz24!melin
From: melin@hlrz24.hlrz.kfa-juelich.de (Stephan Melin)
Newsgroups: gnu.gcc.help
Subject: Re: Large Arrays
Keywords: Double, Float
Message-ID: <1993Sep16.103910@hlrz24.hlrz.kfa-juelich.de>
Date: 16 Sep 93 08:39:10 GMT
References: <276tfp$96n@nuscc.nus.sg>
Sender: news@zam103.zam.kfa-juelich.de
Organization: Forschungszentrum Juelich GmbH (KFA), Germany
Lines: 74
Nntp-Posting-Host: hlrz24