Hello! I am making a program which does many computations for a Photovoltaic system. The problem is that i get a strange segmentation fault error when I run the program. Here is where it crushes (at for-loop of calculation S5) :
commands.....
...
...
/******************** WIRING *******************************/
Ni = N_I/(Ns*Np);
S1 = 0;
for(j=0; j<Np; j++)
S1 += (j-1)*Lpv2 + Lpv2/2;
S2 = 0;
for(j=0; j<Nr; j++)
S2 += 2*h_d + W_T + (j-1)*Np*Lpv2;
S3 = 0;
for(j=0; j<Nc; j++)
S3 += h_d + (j-1)*Ns*Lpv1;
S4 = 0;
for(j=0; j<Nc_nm; j++)
S4 += h_d + (j-1)*Ns*Lpv1;
S5 = 0;
for(j=0; j<N_row; j++)
S5 += (j-1)*(W_T + Fy);
PL_ac = (1 + SF2)*( Pi_n_ac*(N_row - 1)*Nr*S3 + Pi_n_ac*Nr*S4 + Pi_n_ac*Nr*Nc*(N_row - 1)*S5 + Pi_n_ac*Ni*(Lpv1*n_t/2 + h_d) );
Pic = Ni*Pi_n_ac/1000;
more commands follow......
...
...
When S5 calculated in for-loop, I get segfault. If I put in comments, it works ok. If i put in comments one other variable (for example S4 and its loop) and leave S5 as it is, it works again. But for all for-loops, segfault appears.
I doubled the stack size with ulimit, but no improvement. I have some houndreds of double variables and some decades large arrays of double variables. I sense that the problem has to do with the memory that the program uses, but I'm really stucked. If someone has an idea what's happening, it would be very helpful.
My system is OpenSuse 11.4 (Celadon), the processor is Intel core2duo at 2,3GHz and system memory is 4Gb.
Sorry if my English is poor... Thanks!