[ANSYS, Inc. Logo] return to home search
next up previous contents index

3.7 Input/Output Macros

ANSYS FLUENT provides some utilities in addition to the standard C I/O functions that you can use to perform input/output (I/O) tasks. These are listed below and are described in the following sections:


Message(format, ...) prints a message to the console
Error(format, ...) prints an error message to the console
   



Message


The Message macro is a utility that displays data to the console in a format that you specify.

int Message(char *format, ...);

The first argument in the Message macro is the format string. It specifies how the remaining arguments are to be displayed in the console. The format string is defined within quotes. The value of the replacement variables that follow the format string will be substituted in the display for all instances of %type. The % character is used to designate the character type. Some common format characters are: %d for integers, %f for floating point numbers, %g for double data type, and %e for floating point numbers in exponential format (with e before the exponent). Consult a C programming language manual for more details. The format string for Message is similar to printf, the standard C I/O function (see Section  A.13.3 for details).

In the example below, the text Volume integral of turbulent dissipation: will be displayed in the console, and the value of the replacement variable, sum_diss, will be substituted in the message for all instances of %g.

Example:

Message("Volume integral of turbulent dissipation: %g\n", sum_diss);
     /*  g represents floating point number in f or e format */
     /*  \n denotes a new line  */

figure   

It is recommended that you use Message instead of printf in compiled UDFs (UNIX only).



Error


You can use Error when you want to stop execution of a UDF and print an error message to the console.

Example:

if (table_file == NULL)
   Error("error reading file");

figure   

Error is not supported by the interpreter and can be used only in compiled UDFs.


next up previous contents index Previous: 3.6.4 Accessing a Scheme
Up: 3. Additional Macros for
Next: 3.8 Miscellaneous Macros
Release 12.0 © ANSYS, Inc. 2009-01-14