|
[Sponsors] |
October 6, 2009, 15:13 |
PlZ help debugging this simple code
|
#1 |
New Member
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 17 |
Hi all,
This code is pretty simple. All it's trying to do is just to read data from a file (data.dat) and then print some data on the console window to make sure the data was read and stored in correctly. #include"udf.h" float rho[8]; //one-dimensional matrix for storing data// DEFINE_ON_DEMAND(read_data) { int i; int k=0; FILE *ifp; ifp=fopen("data.dat", "r"); for(i=1; i<=9; i++) { fscanf(ifp, "%f", rho[k]); k++; } fclose(ifp); printf("rho[1]= %f\n" , rho[1]); printf("rho[5]= %f\n" , rho[5]); printf("rho[8]= %f\n" , rho[8]); } I can interpret the code with no problem, but when I tried to excute it, it gave me this: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save cas/data under new name. 3. Exit programme and restart to continue. 4. Report error to your distributor. Error Object: () Does anybody know what the problem could be? Any help would be appreciated! Thanks. Jinfeng |
|
October 6, 2009, 19:15 |
|
#2 |
New Member
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 17 |
Never Mind! I think I found the problem. It should be
fscanf(ifp, "%f", &rho[k]); Lesson: Small things can cause big trouble. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sample SIMPLE method CFD code | entitledx | Main CFD Forum | 8 | May 27, 2012 07:22 |
What is the Better Way to Do CFD? | John C. Chien | Main CFD Forum | 54 | April 23, 2001 09:10 |
SIMPLE code for 3_D problem | bobby | Main CFD Forum | 1 | December 26, 2000 00:20 |
SIMPLE code | Bivan | Main CFD Forum | 8 | October 24, 2000 22:25 |
SIMPLE algorithm | Jonathan Castro | Main CFD Forum | 3 | December 10, 1999 05:59 |