CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   FLUENT received fatal signal (ACCESS_VIOLATION)??? (http://www.cfd-online.com/Forums/fluent-udf/68634-fluent-received-fatal-signal-access_violation.html)

Jinfeng September 26, 2009 19:04

FLUENT received fatal signal (ACCESS_VIOLATION)???
 
Dear Friends,

I wrote a DEFINE_ON_DEMAND type code to read some data from files into FLUENT so that I can use the data in later source term calculations. After interpreting it successfully, I clicked "EXCUTE" the Excute on Demand panel and I got this error message:

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:()

I have no idea what the problem could be, I am seeking some experts' opinions.........

Here is that part of the code(The matrix definitions was defined as global variables and were not pasted here):

DEFINE_ON_DEMAND(read_rho_exeyez)
{
int numnodes;
int i;

FILE *ifp; // Pointer for the data file
FILE *kfp;
int k=0;

numnodes = xdirnodes * ydirnodes * zdirnodes; // Calculate total number of nodes in volume
ifp = fopen("Rho.dat", "r"); // Open data file for scanning
kfp = fopen("ExEyEz.dat", "r");

//*** READ IN VALUES ***//
for(i=1; i<=numnodes; i++)
{
fscanf(ifp,
"%f", rho[k]);
fscanf(kfp,
"%f", dvdx[k]);
fscanf(kfp,
"%f", dvdy[k]);
fscanf(kfp,
"%f", dvdz[k]);
k++;
}

fclose(ifp);
fclose(kfp);
}

dmoroian October 19, 2009 12:03

Pointers... always a problem
 
You should put a check for the pointers:
Code:

if (NULL == if)
  Error("Something is wrong with your input file!\n");

To read data with fscanf you need pointers, which means you have to dereference the variable if is not a pointer.

Code:

fscanf(ifp, "%f", &rho[k]);
To make the code look nicer I would use i-1 instead of k.

Dragos


All times are GMT -4. The time now is 11:06.