CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF - Interpreted works and compiled doesn't (https://www.cfd-online.com/Forums/fluent/42151-udf-interpreted-works-compiled-doesnt.html)

AlwaysLearning August 27, 2006 13:54

UDF - Interpreted works and compiled doesn't
 
I am writing some UDF's so that I can get at some of the flow data - not relevant right now.

To allow me to see how my UDF's are performing, I wanted to sprinkle the code with some printf statements.

Unfortuntaley the Printf doesn't seem to do anything.

I have now stripped the UDF right down to simply a few lines of Printf.

This works OK when interpreted but not when compiled. When I compile the UDF I don't seem to get any errors and it loads alright.

Anyone got any ideas?


RoM August 28, 2006 02:25

Re: UDF - Interpreted works and compiled doesn't
 
Use "Message" or "CX_Message" (same syntax as printf) instead of "printf" for compiled udfs.

RoM

AlwaysLearning August 28, 2006 05:44

Re: UDF - Interpreted works and compiled doesn't
 
Thank you for this. Very helpful. I have also located some text in the fluent help file that refers to 'Message'. Strange thing is that it seems as though it should work (printf), in both interpreted and compiled mode.


RoM August 28, 2006 06:32

Re: UDF - Interpreted works and compiled doesn't
 
I had a discussion with fluent suuport about this problem. The output from the fluent solver (written in c) to the cortex (scheme) is buffered and the message buffer needs to be fluhed bevor you will see the output in the cortex gui. The standard printf function wont do this, so fluent provides the Message macro. As far as i know, Message will work only in compiled udfs and not in interpreted mode.

RoM

PAD August 30, 2006 01:36

Re: UDF - Interpreted works and compiled doesn't
 
On windows clients "printf" only works in interpreted mode. "Message" should work for both modes regardless of operating system.

RoM August 30, 2006 05:44

Re: UDF - Interpreted works and compiled doesn't
 
The good old hello-world-udf will not run in interpreted mode on my WinXP machine.

#include "udf.h"

DEFINE_ON_DEMAND(hello)
{
Message("Hello world!\n");
}

The interpreter quits with
Error: C:\hello.c: line 7: function "CX_Message" not found (pc=5).

Compiling works fine though.

RoM

Chunrong October 29, 2018 18:13

Quote:

Originally Posted by RoM
;135315
The good old hello-world-udf will not run in interpreted mode on my WinXP machine.

#include "udf.h"

DEFINE_ON_DEMAND(hello)
{
Message("Hello world!\n");
}

The interpreter quits with
Error: C:\hello.c: line 7: function "CX_Message" not found (pc=5).

Compiling works fine though.

RoM

Hi RoM,

I got "Error code 126" when I used COMPLIED but okay for INTERPRETED. Do you know why it happened ? I tried to fix it by referring https://www.cfd-online.com/Forums/fluent/174350-udf-compilation-error-code-126-a.html but didn't work.

many thanks

AlexanderZ October 29, 2018 20:40

reason of error code 126 is version mismatch

best regards

Chunrong October 29, 2018 20:54

Hi AlexanderZ,

Very appreciate your reply. Since I don't own much knowledge about CS, can you explain it in details and what should I do to fix this error?

thanks and regards

AlexanderZ October 30, 2018 00:52

in other thread you've mentioned, that you have both v19.0 and v.18.2 version of fluent.

Most likely you are compiling your UDF using one version, but run it with another.
Or you are not compiling library, because of some problems with compiler or code) and than try to read "bad" library, which was compiled long time ago for other fluent version

best regards


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