CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   RP_Set_List_of_Integer (http://www.cfd-online.com/Forums/fluent/70689-rp_set_list_of_integer.html)

linch December 2, 2009 11:41

RP_Set_List_of_Integer
 
Hi everyone,

I have a problem with using RP_Set_List_of_Integer macro. Does somebody know how does it work?

For example I define a global variable <testlist> in the Fluent text interface or in a scheme file first:
(rp-var-define 'testlist '() 'integer-list #f)

Next I write a simple UDF to test the macro:

Code:

DEFINE_ON_DEMAND(demand_test_list_set)
{
int a=10, b=20, c=30;

    RP_Set_List_of_Integer("testlist", &a, 1);
    RP_Set_List_of_Integer("testlist", &b, 2);
    RP_Set_List_of_Integer("testlist", &c, 3);

    Message("Length of the list: %i\n",RP_Get_List_Length("testlist"));
    Message("1st element of the list: %i\n",RP_Get_List_Ref_Int("testlist",0));
    Message("2nd element of the list: %i\n",RP_Get_List_Ref_Int("testlist",1));
    Message("3rd element of the list: %i\n",RP_Get_List_Ref_Int("testlist",2));
}

It works almost perfectly, with an only exception, that fluent returns the elements in an inverse order:
Code:

Length of the list: 3
1st element of the list: 30
2nd element of the list: 20
3rd element of the list: 10

It's a kind of strange, but I can live with it.

But if I pass the &a-pointer twice (a.e. if I want the third element of the list to be the same as the 1st):
Code:

    RP_Set_List_of_Integer("testlist", &a, 1);
    RP_Set_List_of_Integer("testlist", &b, 2);
    RP_Set_List_of_Integer("testlist", &a, 3);

it doesn't work properly. What I get is:
Code:

1st element of the list: 10
2nd element of the list: -1213829304
3rd element of the list: -1214887304

Why? What's the problem? :eek:

I went on trying and it seems not to work with arrays also:
Code:

int d[3];
    d[0]=10;
    d[1]=20;
    d[2]=30;

    RP_Set_List_of_Integer("testlist", d, 1);
    RP_Set_List_of_Integer("testlist", (d+1), 2);
    RP_Set_List_of_Integer("testlist", (d+2), 3);

The result looks similar to the previous example.

Can somebody please help me and tell me, how to use the RP_Set_List_of_Integer macro properly?

I need to store some arrays globally and as I want to do it anytime I want, I can not use the DEFINE_RW_FILE macro. So, the only way I see is to store them as RP-variables.

I would be grateful if you had some advices for me.


All times are GMT -4. The time now is 14:22.