CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

PlZ help debugging this simple code

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 6, 2009, 14:13
Default PlZ help debugging this simple code
  #1
New Member
 
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 7
Jinfeng is on a distinguished road
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
Jinfeng is offline   Reply With Quote

Old   October 6, 2009, 18:15
Default
  #2
New Member
 
Jinfeng
Join Date: Aug 2009
Posts: 6
Rep Power: 7
Jinfeng is on a distinguished road
Never Mind! I think I found the problem. It should be

fscanf(ifp, "%f", &rho[k]);

Lesson: Small things can cause big trouble.
Jinfeng is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample SIMPLE method CFD code entitledx Main CFD Forum 8 May 27, 2012 06:22
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 08: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 21:25
SIMPLE algorithm Jonathan Castro Main CFD Forum 3 December 10, 1999 05:59


All times are GMT -4. The time now is 05:35.