Fluent6: Documentation: UDF Manual: Section 3.2: Add the fact that multi-dimensional arrays don't work!

A UDF that contains and uses a multi-dimensional array ("real x[3][7]") can be read by the UDF interpreter without error message. However, executing it generates unpredictable bad results.

It is only the static allocation of the array that goes wrong.
Allocating the memory dynamically works OK.
Example:
Instead of...
real dat[5][10];
...set the following in you source code:
real *dat[5];
for (i = 0; i < 5; i++)
{
dat[i] = malloc(sizeof(real) * 10);
}
Then you can use the bi-dimensional array as you like.

If you want to make the array a global variable, you will have to do the allocation exactly once before the first access.





Show Form
No comments yet. Be the first to add a comment!