so I declared it with the following sentence:
nx=4096;
ny=400;
nz=129;
double u3d[nx][ny][nz];
C++ repeatedly gives the following error message:
/bin/sh: line 1: 4587 Segmentation fault
If I set nx up to 30, it's OK, but if nx is greater than 30,
segmentation fault messages occur.
Am I using a too big array to handle in my system?
I cannot understand since in Fortran there was no problem with the following
command:
real, allocatable, dimension(:,:,:) :: u3d
allocate(u3d(1:nx,1:ny,1:nz))
Allocate it on heap via the new operator. The array is too large for the stack:
double *u3d = newdouble[nx][ny][nz]
Also, using variables to specify the size of stack arrays should be illegal. NOTE: Though GCC allows it, it still warns you as it isn't a flexible method of allocation and will not compile on any others. GCC is breaking the specification at the users expense which most do not.