I am trying to run a simulation in C++ using codeblocks which involves a large number of dynamical variables and which runs for a large number of time steps (N). A part of the code goes something like this:
#include <iostream>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <random>
#define N 20000
#define A 40
#define B 30
#define C 300
using namespace std;
double t1[A][B][N];
double t2[A][B][N];
.
.
. // around 30 arrays like this
double r1[C][N];
double r2[C][N];
.
.
. // around 20 arrays like this
int main(){
// code where I update these arrays to record the dynamics of the variables
// Even if I leave the main function empty and just build and run, it gives me the same error, depending on whether N is very large or not.
}
After this, I define my dynamical variables as arrays of the form Array[A][B][N] and Array_2[C][N]. There are around 50 such arrays. The problem I am facing is that for N = 20000, the program gives me the message - 'Process returned 4258096 (0x40F930)', while if I increase it to 200000, it works fine, returning the message - 'Process returned 0 (0x0)'. On decreasing it to N = 60000, it again returns the same message - 'Process returned 4258096 (0x40F930)'. In general, when I run my complete code which involves the evolution of these variables over the given timesteps, it doesn't build properly beyond N =30000. I am wondering if there is a way to get around this problem.