Board index » cppbuilder » thread stopped
cory
![]() CBuilder Developer |
thread stopped2003-09-23 11:09:59 AM cppbuilder35 I run the following code which calls several subroutines and then writes intermediate data to files. After calling the subroutine "convect" for the 47th time (that's right, the 47th) -- I get an error "Thread stopped. Fault: access violation at 0x426440: read of address 0xffffffff" I also get a standard error message on my screen that the file hydro3.txt can't be opened. I programmed this message into my code. I don't know what the run time error message means. I have checked to make sure that the data I am writing is good, but if I remove the subroutine convect, evrything works fine. Ideas? Thanks. =============================================================== #include "includes.h" int main() { FILE *fp; // Define types double *rho; // mass density double *m; // momentum density double *E; // total energy density double *E_field; // electric field double *phi; // potential double *D; // doping profile double dt; // temp{*word*203}step size double dx; // spatial step size double *a; // interpolation coeffcient int i; int j; // Read in initial densities and electric field D = dvector(0,N+1); rho = dvector(0,N+1); m = dvector(0,N+1); E = dvector(0,N+1); E_field = dvector(0,N+1); phi = dvector(0,N+1); a = dvector(0,N+1); dx = initial(D, rho, phi, E_field, m, E, N); if ((fp = fopen("hydro1.txt","w")) == NULL) fprintf(stderr, "Error opening file%s.", "hydro1.txt"); for (i=0; i <= N+1 ; ++i ) fprintf(fp, "%-e\t%-e\t%-e\t%-e\t%-e\n\n", rho[i], m[i], E[i], phi[i], E_field[i]); fclose(fp); for (j=1;j<=200;j++) { // Step One: Relaxation and Electric Field update dt = relax(D, rho, phi, E_field, m, E, dx, a, N); if ((fp = fopen("hydro2.txt","w")) == NULL) fprintf(stderr, "Error opening file % s.", "hydro2.txt"); for (i=0; i <= N+1 ; ++i ) fprintf(fp, "%-e\t%-e\t%-e\t%-e\t%-e\n\n",rho[i], m[i], E[i], phi[i], E_field[i]); fclose(fp); //Step Two: Convection convect(rho, m, E, E_field, N, dt, dx, a); if ((fp = fopen("hydro3.txt","w")) == NULL) fprintf(stderr, "Error opening file% s.", "hydro3.txt"); for (i=0; i <= N+1 ; i++ ) fprintf(fp, "%-e\t%-e\t%-e\t%-e\t%-e\n\n", rho[i], m[i], E[i], phi[i], E_field[i]); fclose(fp); printf("%-d\n",j); } return 0; }//end main |