# problem printf fluent

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

 June 4, 2010, 04:50 problem printf fluent #1 New Member   marie Join Date: May 2010 Posts: 21 Rep Power: 15 Hi, I need to create a UDF function. I've written a program in C but the result is not correct. So I've decided to check each step. And I've realised that this simple program : #include"udf.h" #include"mem.h" #include"stdio.h" DEFINE_PROPERTY(cell_visco, cell, thread) { int I[3][3]; int i,j; real mu_lam; real vitesse = C_U(cell, thread); I[0][0] = 1; I[0][1] = 2; I[0][2] = 2; I[1][0] = 2; I[1][1] = 2; I[1][2] = 2; I[2][0] = 2; I[2][1] = 2; I[2][2] = 1; for(i=0; i<3; i++) { for (j=0; j<3; j++) printf("I[%d][%d] = %d \n", i , j, I[i][j]); } if (vitesse>0.000001) mu_lam = 2.; else mu_lam = 40.; } return an incorrect matrix I : I[0][0] = 1 I[0][1] = 2 I[0][2] = 2 I[1][0] = 2 I[1][1] = 1 I[1][2] = 2 I[2][0] = 0 I[2][1] = 2 I[2][2] = 1 If I change the values of the matrix I, the result printed in Fluent is incorrect for I[1][1] and I[2][0] but correct for the other terms. If anyone could help me... thank you so much!

 June 4, 2010, 10:46 #2 Senior Member   Join Date: Nov 2009 Posts: 411 Rep Power: 18 Your code is absolutely correct, here is a truncated version that will compile independently: #include"stdio.h" int main() { int I[3][3]; int i,j; I[0][0] = 1; I[0][1] = 2; I[0][2] = 2; I[1][0] = 2; I[1][1] = 2; I[1][2] = 2; I[2][0] = 2; I[2][1] = 2; I[2][2] = 1; for(i=0; i<3; i++) { for (j=0; j<3; j++) printf("I[%d][%d] = %d \n", i , j, I[i][j]); } return 0; } and the results: =============== C:\Users\Dol\Desktop\tste>a.exe I[0][0] = 1 I[0][1] = 2 I[0][2] = 2 I[1][0] = 2 I[1][1] = 2 I[1][2] = 2 I[2][0] = 2 I[2][1] = 2 I[2][2] = 1 C:\Users\Do\Desktop\tste> =============== Probably you have a problem in some other place. A suggestion will be to use Message function instead of printf, Message is a Fluent's own replacement for printf. Hope this will help, Do

 June 7, 2010, 05:19 #3 New Member   marie Join Date: May 2010 Posts: 21 Rep Power: 15 Hi, Thank you for your answer. I tried with the function Message but I have this error :CX_Message : no function prototype And in the user guide, I found "It is recommended that you use Message instead of printf in compiled UDFs (UNIX only)" But I do not use UNIX... Moreover if I write int main() in my program, it doesn't work anymore...

 Tags fluent, pritnf