Progam not running

V

vj

Hi All,

I am using C++Builder V5.0 to run my C programs. I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go to Options--Linker and increase the MaxStackSize, which
sorts out the problem.

All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:

C++ Builder Development Environment has encountered a problem and
needs to close. We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.

The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.
Any suggestions are most welcome.
Thanks
 
Z

zeppe

vj said:
Hi All,

I am using C++Builder V5.0 to run my C programs.

what part of *comp*.*lang*.*c++* you haven't understood? In other words,
you are OT.

Additionally, crosspost is evil, so i've removed it.
I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go to Options--Linker and increase the MaxStackSize, which
sorts out the problem.

Oh well, this means that your program is bad written, not that you do
huge amount of data processing. Don't use static memory if you have to
allocate big data structures.
All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:

C++ Builder Development Environment has encountered a problem and
needs to close. We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.

I suggest you not to send. Apart from this, if the compiler crashes,
change compiler.
The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.

it's not the case. Is the limited stack size. Use dynamic allocation.

Regards,

Zeppe
 
J

jacob navia

vj said:
Hi All,

I am using C++Builder V5.0 to run my C programs. I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go to Options--Linker and increase the MaxStackSize, which
sorts out the problem.

All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:

C++ Builder Development Environment has encountered a problem and
needs to close.

This means that the Integrated Development Environment (IDE) has
crashed. Your program has nothing to do with this. As the message says:
"C++ Builder Development Environment has encountered a problem "
not your program.

We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.

Send it to Microsoft, but probably your project file has been corrupted.
Just rebuild your project from scratch and it will probably work.
The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.
Any suggestions are most welcome.
Thanks

This has nothing to do with your program. It is NOT your program
that crashed but VC++
 
U

user923005

This has nothing to do with your program. It is NOT your program
that crashed but VC++

I doubt it. He said he is running C++ Builder. That's Borland.

To the O.P.:
If you can produce a simple example that demonstrates the problem,
post it here and we can diagnose it.
 
R

Richard Heathfield

jacob navia said:
vj wrote:

Send it to Microsoft,

Why? What can they do to help?

This has nothing to do with your program. It is NOT your program
that crashed but VC++

I disagree. This is the C++ Builder debugger that's crashed, probably as
a result of the OP ignorantly* breaching some unwritten limit.

* This is not intended as an insult. For even the most knowledgeable
programmers, that state of knowledge is preceded by a state of
ignorance.
 
A

Aioanei Rares

vj said:
Hi All,

I am using C++Builder V5.0 to run my C programs. I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go to Options--Linker and increase the MaxStackSize, which
sorts out the problem.

All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:

C++ Builder Development Environment has encountered a problem and
needs to close. We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.

The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.
Any suggestions are most welcome.
Thanks
Have you recently updated/upgraded your OS and/or IDE ?
 
R

Richard Heathfield

Aioanei Rares said:

Have you recently updated/upgraded your OS and/or IDE ?

Occam's Razor applies. The most likely cause of his troubles is that he
has a misconception about C that is causing him to write programs that
BCB's runtime is having trouble with. The fix is almost certainly to
take a look at one or two of his C programs that have been causing him
trouble, and see if we can't spot some obvious abuse or other.
 
B

Barry

jacob navia said:
This means that the Integrated Development Environment (IDE) has
crashed. Your program has nothing to do with this. As the message says:
"C++ Builder Development Environment has encountered a problem "
not your program.



Send it to Microsoft, but probably your project file has been corrupted.
Just rebuild your project from scratch and it will probably work.


This has nothing to do with your program. It is NOT your program
that crashed but VC++

<OT>
Well I guess I need to read up. I didn't know Borland used VC++.

There is never a use in sending a problem to Microsoft.

Ask in a forum that deals with Borland, some of them can be
found simply by searching for Borland C.
</OT>
 
J

Jim Langston

vj said:
Hi All,

I am using C++Builder V5.0 to run my C programs. I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go to Options--Linker and increase the MaxStackSize, which
sorts out the problem.

All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:

C++ Builder Development Environment has encountered a problem and
needs to close. We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.

The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.
Any suggestions are most welcome.
Thanks

If you are having to increase your stack for your programs to run, you
should probably use the freestore instead of stack memory.

That is, instead of having:

int MyArray[10000];
you should do:
int* MyArray;
MyArray = malloc( sizeof( int ) * 10000 );

Then later

free( MyArray );
when you are done with the memory.

(In C++ you would use new and delete).

Check for MyArray being null. I don't remember if you have to cast it in C
or not. Either C or C++ you have to cast from malloc, but I don't remember
which. Anyway, this will use the freestore which you have a lot more of.

The other reason you could need a lot of stack space is because of
recursion, not much you can do there except either make it non recursive or
just increase the stack size.
 
V

vj

Hi All,

I am using C++Builder V5.0 to run my C programs. I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go toOptions--LinkerandincreasetheMaxStackSize, which
sorts out the problem.

All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:

C++ Builder Development Environment has encountered a problem and
needs to close. We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.

The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.
Any suggestions are most welcome.
Thanks

Hi All,
Thanks a lot for all your replies. As an update, I have noticed that I
get an error message in the small window at the bottom of the source-
code window saying: "[Linker Errror] Could not create filename.tds
[error code 123]". Here filename is the actual filename of my file.

I remember I have run this code successfully in the past, and also
other programmes are still working fine (that have lower memory
requirements I think). I have not changed my OS and/or IDE or any
other changes. I have tried sending the report to Microsoft (as
suggested in one of the replies), but after sending the report, it
just says "error reporting complete", and doesn't give any feedback.
I have also tried making the project from scratch, but no success,
same problems continues.
 
U

user923005

I am using C++Builder V5.0 to run my C programs. I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go toOptions--LinkerandincreasetheMaxStackSize, which
sorts out the problem.
All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:
C++ Builder Development Environment has encountered a problem and
needs to close. We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.
The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.
Any suggestions are most welcome.
Thanks

Hi All,
Thanks a lot for all your replies. As an update, I have noticed that I
get an error message in the small window at the bottom of the source-
code window saying: "[Linker Errror] Could not create filename.tds
[error code 123]". Here filename is the actual filename of my file.

How much free disk space is currently available on your machine?
I remember I have run this code successfully in the past, and also
other programmes are still working fine (that have lower memory
requirements I think). I have not changed my OS and/or IDE or any
other changes. I have tried sending the report to Microsoft (as
suggested in one of the replies), but after sending the report, it
just says "error reporting complete", and doesn't give any feedback.
I have also tried making the project from scratch, but no success,
same problems continues.

Since Microsoft does not make C++ Builder, I suggest that you have
sent the problem report to the wrong place.
 
R

Richard Heathfield

vj said:

I have also tried making the project from scratch, but no success,
same problems continues.

So perhaps now is the time to show us the code that you're struggling
with. (Actually, earlier was the time, but now will do.)
 
V

vj

vj said:



So perhaps now is the time to show us the code that you're struggling
with. (Actually, earlier was the time, but now will do.)

Thanks for the replies. The free disk space is at least 4 GB.
I am copying below the code. The interesting thing is that the same
code is running alright on a different machine, so this makes me think
that there seems to be problem with my machine. (Of course I have to
increase the stack size on the other machine also, and this is what I
normally do, and it works fine). As mentioned in my previous post, I
don't remember doing anything signifacant with the machine (only thing
I can remember is wiriting a songs CD using Nero). Here is the code
(I admit that the code is far from being an example of an efficient
code :), but serves my purpose well) :



#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stddef.h>
#include <complex.h>
#include <fstream>
#include <time.h>
#define PI 3.14159265
#define c 3.0e8
#define dX 50.0e-9//73.170731e-9
#define dT dX/(c)

#define NX 780
#define NY 600

#define NM 4
#define double_complex complex <double>


class D2{
public:
int NT;


double **V10, **V11, **V8, **V9, **Iy, **Ix, **Vz;
double **Sez;
double **pez, **X1z, **X2z;
double ALPHA[NM], d[NM], w0[NM];
double Tp0[NM], b0, b1[NM], b2[NM], b3[NM], Tp1[NM], Te2[NM],
Te1[NM];

double *h1, *h2, *h3, *h4;
int X, Y, N;

D2( );
~D2( );
void iterate( );
};

main(){
time_t starttime,endtime;
starttime=time(NULL);

D2 A;
A.iterate();
endtime=time(NULL);
cout<<endl<<"Total Run time"<<"\t"<<endtime-starttime<<" sec
("<<(endtime-starttime)/60<<" min "<<(endtime-starttime)%60<<"
sec)"<<endl;

getchar();
}

D2 :: D2(){
int array_counter;
V10 = new double *[NX];
V11 = new double *[NX];
V8 = new double *[NX];
V9 = new double *[NX];
Iy = new double *[NX];
Ix = new double *[NX];
Vz = new double *[NX];
Sez = new double *[NX];
pez = new double *[NX];
X1z = new double *[NX];
X2z = new double *[NX];

for (array_counter = 0; array_counter < NX; array_counter++)
{
V10[array_counter] = new double [NY];
V11[array_counter] = new double [NY];
V8[array_counter] = new double [NY];
V9[array_counter] = new double [NY];
Iy[array_counter] = new double [NY];
Ix[array_counter] = new double [NY];
Vz[array_counter] = new double [NY];
//Sey[array_counter] = new double [NY];
Sez[array_counter] = new double [NY];
pez[array_counter] = new double [NY];
//pey[array_counter] = new double [NY];
X1z[array_counter] = new double [NY];
//X1y[array_counter] = new double [NY];
X2z[array_counter] = new double [NY];
//X2y[array_counter] = new double [NY];
}


cout << "Enter no. of Timesteps (NT) - ";
cin >> NT;
ofstream outfileNT("Last_NT.out");
outfileNT<<"Last NT= "<<NT<<endl;
// NT=30;
h1=new double [NT];
h2=new double [NT];
h3=new double [NT];
h4=new double [NT];
}

D2 :: ~D2(){
int array_counter;
for (array_counter = 0; array_counter < NX; array_counter++)
{
delete [] V10[array_counter];
delete [] V11[array_counter];
delete [] V8[array_counter];
delete [] V9[array_counter];
delete [] Iy[array_counter];
delete [] Ix[array_counter];
delete [] Vz[array_counter];
// delete [] Sey[array_counter];
delete [] Sez[array_counter];
delete [] pez[array_counter];
// delete [] pey[array_counter];
delete [] X1z[array_counter];
// delete [] X1y[array_counter];
delete [] X2z[array_counter];
//delete [] X2y[array_counter];
}
delete [] V10;
delete [] V11;
delete [] V8;
delete [] V9;
delete [] Iy;
delete [] Ix;
delete [] Vz;
// delete [] Sey;
delete [] Sez;
delete [] pez;
// delete [] pey;
delete [] X1z;
// delete [] X1y;
delete [] X2z;
// delete [] X2y;

delete []h1;
delete []h2;
delete []h3;
delete []h4;

}
void D2 :: iterate(){

ofstream outfile1("sp_dist_Ix_NL.out");
//ofstream outfile1_ENV("sp_dist_Vx_NL_Envelope.out");
ofstream outfile2A("FFT_Vz_NL.out");
//ofstream outfile2B("FFT_Vy_NL.out");
//ofstream outfile2C("FFT_I_NL.out");
//ofstream outfile2D("FFT_P_NL.out");
ofstream outfile3("TimeData_NL.out");

//ofstream outfile4A("sp_dist_Vy_NL_1.out");
//ofstream outfile4B("sp_dist_Vy_NL_2.out");
//ofstream outfile4C("sp_dist_Vy_NL_3.out");
ofstream outfile4("sp_dist_Iy_NL.out");
ofstream outfileMatProfile("MaterialProfile.out");

//ofstream outfile4_ENV("sp_dist_Vy_NL_Envelope.out");
ofstream outfile5("sp_dist_Vz_NL.out");
ofstream outfile5A("sp_dist_Vz_NL_NT1000.out");
ofstream outfile5B("sp_dist_Vz_NL_NT1200.out");
ofstream outfile5C("sp_dist_Vz_NL_NT1400.out");
ofstream outfile5D("sp_dist_Vz_NL_NT800.out");
//ofstream outfile5E("sp_dist_Vz_NL_NT400.out");

//ofstream outfile5_ENV("sp_dist_I_NL_Envelope.out");
ofstream outfile6("sp_dist_P_NL.out");

//ofstream outfile6_ENV("sp_dist_P_NL_Envelope.out");
ofstream StoreVoltages("AllVoltages.out");
ifstream ReadVoltages("AllVoltages_400.in");


int MaterialPresent[NX][NY];

int NLB = 220;//NX-10;
int StripStartY_LEFT = (NY/2)-30;
int StripEndY_LEFT = (NY/2)+30;

int StripStartY_RIGHT = StripStartY_LEFT;//(NY/2)-6; //=144;
int StripEndY_RIGHT = StripEndY_LEFT;//(NY/2)+6; //=156;


for (X=0; X<NX; X++)
{
for (Y=0; Y<NY; Y++)
{
if (X<=NLB)
{
if (Y>=StripStartY_LEFT && Y<=StripEndY_LEFT) MaterialPresent[X][Y]
=1;
else MaterialPresent[X][Y]=0;

}
if (X>NLB)
{
if (Y>=StripStartY_RIGHT && Y<=StripEndY_RIGHT)
MaterialPresent[X][Y] =2;
else MaterialPresent[X][Y]=3;
}

outfileMatProfile<<MaterialPresent[X][Y];

}
outfileMatProfile<<endl;
}

double CH[NM];
double T1[NM];

CH[0] = (10.487 * 10.487) - 1.0;
CH[1] = (10.491 * 10.491) - 1.0;
CH[2] = (10.491 * 10.491) - 1.0;
CH[3] = (10.487 * 10.487) - 1.0;



double n0_0=10.487, n0_1=10.491, n0_2=10.491, n0_3=10.487, n2=2.5e16;
double e0 = 8.854e-12;
double Z0=376.7;
double dCH_0 = n0_0*n0_0 + 1.0;
double dCH_1 = n0_1*n0_1 + 1.0;
double dCH_2 = n0_2*n0_2 - 1.0;
double dCH_3 = n0_3*n0_3 + 1.0;

double alpha_value_0 = 2.0 * n0_0 * n2 / (dCH_0*dCH_0*dCH_0*2.0*Z0) ;
double alpha_value_1 = 2.0 * n0_1 * n2 / (dCH_1*dCH_1*dCH_1*2.0*Z0) ;
double alpha_value_2 = 2.0 * n0_2 * n2 / (dCH_2*dCH_2*dCH_2*2.0*Z0) ;
double alpha_value_3 = 2.0 * n0_3 * n2 / (dCH_3*dCH_3*dCH_3*2.0*Z0) ;
double x=-0*1.0/2000.0;
ALPHA[0] = 0.0*alpha_value_0;
ALPHA[1] = 0.0*alpha_value_1;
ALPHA[2] = x*alpha_value_2;
ALPHA[3] = x*alpha_value_3;

w0[0] = 2.0 * M_PI * 1500e12;
w0[1] = 2.0 * M_PI * 1500e12;
w0[2] = 2.0 * M_PI * 1500e12;
w0[3] = 2.0 * M_PI * 1500e12;

d[0] = w0[0] * 1e-3;
d[1] = w0[1] * 1e-3;
d[2] = w0[2] * 1e-3;
d[3] = w0[3] * 1e-3;

w0[0] = 2.0 * M_PI * 1500e12 * 1e50;
w0[1] = 2.0 * M_PI * 1500e12 * 1e50;
w0[2] = 2.0 * M_PI * 1500e12 * 1e50;
w0[3] = 2.0 * M_PI * 1500e12 * 1e50;




w0[0] = w0[0] * (dT);
w0[1] = w0[1] * (dT);
w0[2] = w0[2] * (dT);
w0[3] = w0[3] * (dT);

d[0] = d[0] * (dT);
d[1] = d[1] * (dT);
d[2] = d[2] * (dT);
d[3] = d[3] * (dT);

double Convergence_z = 1.5e-9;
//double Convergence_y = 1.5e-9;

Tp0[0] = 1.0 / (4.0 + 4.0*d[0]);
Tp0[1] = 1.0 / (4.0 + 4.0*d[1]);
Tp0[2] = 1.0 / (4.0 + 4.0*d[2]);
Tp0[3] = 1.0 / (4.0 + 4.0*d[3]);

b0 = 8.0;

b1[0] = -2.0 * w0[0] * w0[0];
b1[1] = -2.0 * w0[1] * w0[1];
b1[2] = -2.0 * w0[2] * w0[2];
b1[3] = -2.0 * w0[3] * w0[3];

b2[0] = 2.0 * CH[0] * w0[0] * w0[0];
b2[1] = 2.0 * CH[1] * w0[1] * w0[1];
b2[2] = 2.0 * CH[2] * w0[2] * w0[2];
b2[3] = 2.0 * CH[3] * w0[3] * w0[3];

b3[0] = -(4.0 - 4.0 * d[0]);
b3[1] = -(4.0 - 4.0 * d[1]);
b3[2] = -(4.0 - 4.0 * d[2]);
b3[3] = -(4.0 - 4.0 * d[3]);

double Te = 0.5;
double Ke = -2.0;
Tp1[0] = 1.0 / (1.0 + 2.0 * CH[0] * w0[0] * w0[0] * Tp0[0] * Te);
Tp1[1] = 1.0 / (1.0 + 2.0 * CH[1] * w0[1] * w0[1] * Tp0[1] * Te);
Tp1[2] = 1.0 / (1.0 + 2.0 * CH[2] * w0[2] * w0[2] * Tp0[2] * Te);
Tp1[3] = 1.0 / (1.0 + 2.0 * CH[3] * w0[3] * w0[3] * Tp0[3] * Te);

Te2[0] = Tp0[0];
Te2[1] = Tp0[1];
Te2[2] = Tp0[2];
Te2[3] = Tp0[3];

Te1[0] = CH[0] * w0[0] * w0[0];
Te1[1] = CH[1] * w0[1] * w0[1];
Te1[2] = CH[2] * w0[2] * w0[2];
Te1[3] = CH[3] * w0[3] * w0[3];



double r_Abs_LEFT, r_Abs_RIGHT, r_Abs_TOP, r_Abs_BOTTOM;
//double r_Metal = -1.0;



int Noff=300;


for (X=0; X<NX; X++)
{
for (Y=0; Y<NY; Y++)
{
V10[X][Y] = V11[X][Y] = V8[X][Y] = V9[X][Y] =Iy[X][Y]=Ix[X][Y]=Vz[X]
[Y]/*=Sey[X][Y]*/=Sez[X][Y]=0.0;
pez[X][Y] = /*pey[X][Y] =*/ X1z[X][Y] = /*X1y[X][Y] =*/ X2z[X][Y] /
*= X2y[X][Y]*/ = 0.0;
}
}

int SignalFromSource, SignalFromFile;
SignalFromSource=1;
SignalFromFile=!SignalFromSource;
if (SignalFromSource==1){cout<<"Taking input signal from SOURCE.....
\n";}
if (SignalFromFile==1){cout<<"Taking input signal from File.....\n";}

if (SignalFromFile==1)
{
for (X=0; X<NX; X++)
{
for (Y=NY-1; Y>=0; Y--)
{
if(X>=150 && X<990)
{
int Xn = X-148;
ReadVoltages>>V8[Xn][Y]>>V9[Xn][Y]>>V10[Xn][Y]>>V11[Xn]
[Y]>>Ix[Xn][Y]>>Iy[Xn][Y]>>Vz[Xn][Y]>>/*Sex[Xn][Y]>>*/Sez[Xn]
[Y]>>X1z[Xn][Y]>>X2z[Xn][Y]>>/*X1y[Xn][Y]>>X2y[Xn][Y]>>*/pez[Xn][Y]/
*>>pey[Xn][Y]*/;
}
else {double junk;
ReadVoltages>>junk>>junk>>junk>>junk>>junk>>junk>>junk>>junk>>junk>>junk>>junk/
*>>junk>>junk>>junk>>junk*/;}
}

}
}





for (N=0; N<NT; N++)
{

/*if (N%200==0) */cout << "Time Step N= "<<N<<endl;

if (SignalFromSource==1)
{


// if (N<Noff)

{

for (Y=0; Y<NY; Y++)//Y=NY/2;//=150;
// Y=NY/2.0;
{



double MD = (1000.0/sqrt(2.0))* exp(log(0.001)*(N-double(Noff)/
2.0)*(N-double(Noff)/2.0)/((double(Noff)/2.0)*(double(Noff)/2.0)))*
cos(2.0 * PI * 196.07843e12 * double(N) * dT);



double a= (StripEndY_LEFT - StripStartY_LEFT +1.0)/2.0;
double u=/*0.9899;0.872;*/ 0.573982;
double w=/*1.508;1.038;*/ 0.371137;
if (Y>= StripStartY_LEFT && Y<=StripEndY_LEFT)
{
V10[20][Y]+= (0.5/sqrt(2.0))* MD *cos((Y-NY/2.0)*(u/a)) /
cos(a);
V11[20][Y]+= (0.5/sqrt(2.0))* MD*cos((Y-NY/2.0)*(u/a)) /
cos(a);
V8[20][Y]+=0.5/sqrt(2.0) * MD*cos((Y-NY/2.0)*(u/a)) /
cos(a);
V9[20][Y]+= 0.5/sqrt(2.0) * MD*cos((Y-NY/2.0)*(u/a)) /
cos(a);
}
else
{

V10[20][Y]+= (0.5/sqrt(2.0) )* MD *exp(-fabs(Y-NY/2.0)*w/a)/
exp(-a);
V11[20][Y]+= (0.5/sqrt(2.0) )* MD*exp(-fabs(Y-NY/2.0)*w/a)/
exp(-a);
V8[20][Y]+=0.5/sqrt(2.0) * MD*exp(-fabs(Y-NY/2.0)*w/a)/
exp(-a);
V9[20][Y]+= 0.5/sqrt(2.0) * MD*exp(-fabs(Y-NY/2.0)*w/a)/
exp(-a);
}




}
}
}
int Xout =115 ;
int Yout =(double(NY))/2.0;

h1[N] = Vz[Xout][Yout];
//h2[N] = Iy[Xout][Yout];
//h3[N] = Vz[Xout][Yout];
//h4[N] = Ix[Xout][Yout] * Ix[Xout][Yout] + Iy[Xout][Yout] * Iy[Xout]
[Yout];


outfile3<<N<<" "<<h1[N]<<endl;


for (X=0; X<NX; X++)
{
for (Y=0; Y<NY; Y++)
{
double v8 = V8[X][Y];
double v9 = V9[X][Y];
double v10 = V10[X][Y];
double v11 = V11[X][Y];
// if (N>=54) cout<<"X= "<<X<<" Y= "<<Y<<" N=
"<<N<<endl;
// I[X][Y] = 0.5 * (-V2[X][Y]+ V4[X][Y] + V3[X][Y] - V5[X][Y]);
Ix[X][Y] = (V8[X][Y] + V9[X][Y]);
Iy[X][Y] = (V10[X][Y] + V11[X][Y]);

//if (Iy[X][Y]!=0.0) {cout<<"N= "<<N<<" X= "<<X<<"
Y= "<<Y<<" Iy[X][Y]= "<<Iy[X][Y]<<endl;char fff; cin>>fff;}

// Vy[X][Y] = V4[X][Y] + V5[X][Y];
{
double Uez = (Te * (2.0 * (v9+v10) + Sez[X][Y]))/2.0;
double Wez = Te2[MaterialPresent[X][Y]] * (b2[MaterialPresent[X]
[Y]] * Uez + X1z[X][Y]);
double P0z = pez[X][Y];

// int itercount_z =0;
for ( ; ; ) {
// if (X==310 && Y==25){ cout<<"itercount_y =
"<<itercount_y<<" at timestep N = "<<N<<" (X,Y) = "<<X<<","<<Y<<endl;
char iterchecky; cin>>iterchecky;}
// itercount_z++;
double P1z = P0z - (P0z - b1[MaterialPresent[X][Y]] *
Te2[MaterialPresent[X][Y]] *exp(ALPHA[MaterialPresent[X]
[Y]]*(P0z*P0z)) * P0z - Wez) / (1.0 - 0.5*b1[MaterialPresent[X][Y]] *
Te2[MaterialPresent[X][Y]] *exp(ALPHA[MaterialPresent[X]
[Y]]*(P0z*P0z)) * (1.0 + 2.0*ALPHA[MaterialPresent[X][Y]]*P0z*P0z) );
if (fabs(P1z - P0z) < Convergence_z) {pez[X][Y] = P1z;
break;}
P0z = P1z;
}
Vz[X][Y] = Uez + 2.0 * Te * pez[X][Y];
Sez[X][Y] = (2.0 * (V10[X][Y] - V11[X][Y] + V8[X][Y] - V9[X]
[Y]) + 2.0* Ke * Vz[X][Y] + 2.0* 2.0 * pez[X][Y]);

X1z[X][Y] = b0 * pez[X][Y] + b1[MaterialPresent[X][Y]] *
exp((ALPHA[MaterialPresent[X][Y]]*(pez[X][Y]*pez[X][Y]))) *pez[X][Y] +
b2[MaterialPresent[X][Y]] *
Vz[X][Y] + X2z[X][Y];
//if (N>474 && X>400 ){ cout<<"X= "<<X<<" Y= "<<Y<<" N= "<<N<<"
X1z[X][Y]= "<<X1z[X][Y]<<endl; char zz; cin>>zz;}
X2z[X][Y] = b3[MaterialPresent[X][Y]] * pez[X][Y] +
0.5*b1[MaterialPresent[X][Y]] * exp((ALPHA[MaterialPresent[X]
[Y]]*(pez[X][Y]*pez[X][Y] ))) * pez[X][Y] + 0.5*b2[MaterialPresent[X]
[Y]] *
Vz[X][Y];
}




//Vx[X][Y] = V2[X][Y] + V3[X][Y];


V10[X][Y] = Vz[X][Y] + Iy[X][Y] - v11;
V11[X][Y] = Vz[X][Y] + Iy[X][Y] - v10;
V8[X][Y] = Vz[X][Y] - Ix[X][Y] - v9;
V9[X][Y] = Vz[X][Y] + Ix[X][Y] - v8;
}
}


double tempref89=20.0;
double tempref1011=20.0;

for (Y=0; Y<NY; Y++)
{
if (Y>=StripStartY_LEFT && Y<=StripEndY_LEFT) r_Abs_LEFT =
(sqrt(tempref1011) - sqrt(CH[1] + 1.0)) / (sqrt(tempref1011) +
sqrt(CH[1] + 1.0));
else r_Abs_LEFT = (sqrt(tempref1011) - sqrt(CH[0] + 1.0)) /
(sqrt(tempref1011) + sqrt(CH[0] + 1.0));

if (Y>=StripStartY_RIGHT && Y<=StripEndY_RIGHT) r_Abs_RIGHT =
(sqrt(tempref1011) - sqrt(CH[2] + 1.0)) / (sqrt(tempref1011) +
sqrt(CH[2] + 1.0));
else r_Abs_RIGHT = (sqrt(tempref1011) - sqrt(CH[3] + 1.0)) /
(sqrt(tempref1011) + sqrt(CH[3] + 1.0));

//r_Abs_RIGHT = (sqrt(2.0) - sqrt(CH[2] + 1.0)) / (sqrt(2.0) +
sqrt(CH[2] + 1.0));
//r_Abs_RIGHT = r_Abs_LEFT;
//r_Abs_RIGHT = (sqrt(2.0) - sqrt(CH[2] + 1.0)) / (sqrt(2.0) +
sqrt(CH[2] + 1.0));

r_Abs_LEFT=r_Abs_RIGHT=0.3637;
V10[0][Y] = V10[0][Y]*(-r_Abs_LEFT);
V11[NX-1][Y] = V11[NX-1][Y] *(-r_Abs_RIGHT);
}


for (X=0; X<NX; X++)
{
if (X>NLB) r_Abs_BOTTOM = (sqrt(tempref89) - sqrt(CH[3] +
1.0)) / (sqrt(tempref89) + sqrt(CH[3] + 1.0));
else r_Abs_BOTTOM = (sqrt(tempref89) -
sqrt(CH[0] + 1.0)) / (sqrt(tempref89) + sqrt(CH[0] + 1.0));

if (X>NLB) r_Abs_TOP = (sqrt(tempref89) - sqrt(CH[3] + 1.0)) /
(sqrt(tempref89) + sqrt(CH[3] + 1.0));
else r_Abs_TOP = (sqrt(tempref89) - sqrt(CH[0] + 1.0)) /
(sqrt(tempref89) + sqrt(CH[0] + 1.0));
r_Abs_BOTTOM=r_Abs_TOP=0.3637;
V8[X][0] = V8[X][0] *(-r_Abs_BOTTOM);
V9[X][NY-1] = V9[X][NY-1] *(-r_Abs_TOP);

}




if (N==1000)
{

for (X=0; X<NX; X++)
{
for (Y=NY-1;Y>=0; Y--)
{

outfile5A<<X<<"\t"<<Y<<"\t"<<Vz[X][Y]<<endl;

}
outfile5A<<endl;

}
}





if (N==1200)
{

for (X=0; X<NX; X++)
{
for (Y=NY-1;Y>=0; Y--)
{

outfile5B<<X<<"\t"<<Y<<"\t"<<Vz[X][Y]<<endl;

}
outfile5B<<endl;

}
}






if (N==1400)
{

for (X=0; X<NX; X++)
{
for (Y=NY-1;Y>=0; Y--)
{

outfile5C<<X<<"\t"<<Y<<"\t"<<Vz[X][Y]<<endl;

}
outfile5C<<endl;

}
}


if (N==800)
{

for (X=0; X<NX; X++)
{
for (Y=NY-1;Y>=0; Y--)
{

outfile5D<<X<<"\t"<<Y<<"\t"<<Vz[X][Y]<<endl;

}
outfile5D<<endl;

}
}



if (N>1)
{

for (X=0; X<NX; X++)
{


{


}

}
}

}







for (X=0; X<NX; X++)
{
for (Y=NY-1;Y>=0; Y--)
{

outfile1<<X<<"\t"<<Y<<"\t"<<Ix[X][Y]<<endl;
outfile4<<X<<"\t"<<Y<<"\t"<<Iy[X][Y]<<endl;
outfile5<<X<<"\t"<<Y<<"\t"<<Vz[X][Y]<<endl;
outfile6<<X<<"\t"<<Y<<"\t"<<Iy[X][Y]*Iy[X][Y]+Ix[X][Y]*Ix[X]
[Y]<<endl;


StoreVoltages<<V8[X][Y]<<"\t"<<V9[X][Y]<<"\t"<<V10[X]
[Y]<<"\t"<<V11[X][Y]<<"\t"<<Ix[X][Y]<<"\t"<<Iy[X][Y]<<"\t"<<Vz[X]
[Y]<<"\t"<<Sez[X][Y]<<"\t"/*<<Sey[X][Y]*/<<"\t"<<X1z[X]
[Y]<<"\t"<<X2z[X][Y]<<"\t"<</*X1y[X][Y]<<"\t"<<X2y[X]
[Y]<<*/"\t"<<pez[X][Y]/*<<"\t"<<pey[X][Y]*/<<endl;

}
outfile1<<endl;
outfile4<<endl;
outfile5<<endl;
outfile6<<endl;
}




}
 
R

Richard Heathfield

vj said:

Thanks for the replies. The free disk space is at least 4 GB.
I am copying below the code. The interesting thing is that the same
code is running alright on a different machine, so this makes me think
that there seems to be problem with my machine. (Of course I have to
increase the stack size on the other machine also, and this is what I
normally do, and it works fine). As mentioned in my previous post, I
don't remember doing anything signifacant with the machine (only thing
I can remember is wiriting a songs CD using Nero). Here is the code
(I admit that the code is far from being an example of an efficient
code :), but serves my purpose well) :

The code is not C (as you originally claimed). It's closer to being C++,
but has issues even as a C++ program. I suggest, therefore, that you
constrain further discussion of it to alt.comp.lang.learn.c-c++
(followups set).
 
B

Bart van Ingen Schenau

[removed c.l.c from the groups, as this is OT there]

vj wrote:

#define NX 780
#define NY 600

#define NM 4
#define double_complex complex <double>
void D2 :: iterate(){
int MaterialPresent[NX][NY];

This variable alone takes up about 1.7 MB of memory (assuming 32-bit
int).
Variables with that kind of size should not be placed on the stack, but
should be allocated dynamically.

int** MaterialPresent = new int*[NX];
for (int i=0; i<NX; i++)
{
MaterialPresent = new int[NY];
}

And don't forget to delete this memory at the end of the function.

I have not checked for other problems, as I don't have the time to
really analyse such a single big function.

Bart v Ingen Schenau
 
J

Jim Langston

vj said:
Thanks for the replies. The free disk space is at least 4 GB.
I am copying below the code. The interesting thing is that the same
code is running alright on a different machine, so this makes me think
that there seems to be problem with my machine. (Of course I have to
increase the stack size on the other machine also, and this is what I
normally do, and it works fine). As mentioned in my previous post, I
don't remember doing anything signifacant with the machine (only thing
I can remember is wiriting a songs CD using Nero). Here is the code
(I admit that the code is far from being an example of an efficient
code :), but serves my purpose well) :

Do a complete scan disk.

[Snip code]
 
S

Sam of California

user923005 said:
Since Microsoft does not make C++ Builder, I suggest that you have
sent the problem report to the wrong place.

Not necessarily. I am nearly certain that Microsoft offers crash reports to
other vendors. My guess is that if Windows asks if a dump should be sent,
the vendor has made arrangemts to get the dumps for the third-party vendor's
products.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top