5.6. Common Errors When Building and Loading a UDF Library

A common compiler error occurs when you forget to put an #include "udf.h" statement at the beginning of your source file. You’ll get a long list of compiler error messages that include illegal declarations of variables. Similarly, if your function requires an auxiliary header file (for example, sg_pdf.h) and you forgot to include it, you’ll get a similar compiler error message.

Another common error occurs when the argument list for a DEFINE statement is placed on multiple lines. (All DEFINE macro arguments must be listed on the same line in a C file.) The compiler will typically not report any error message but it will report a single warning message in the log file to indicate that this occurred:

  warning: no newline at end of file

If your compiled UDF library loads successfully, then each function contained within the library will be reported to the console (and log file). For example, if you built a shared library named libudf containing two user-defined functions superfluid_density and speed_sound, a successful library load (on a Linux machine) will result in the following message being reported to the console (and log file):

 Opening library "libudf"...
 Library "path/libudf/lnamd64/3d_node/libudf.so" opened
   superfluid_density
   speed_sound 
Done. 

If, instead, no function names are listed, then it is likely that your source file did not successfully compile. In this case, you must consult the log to view the compilation history, and debug your function(s). Note that you must unload the UDF library using the UDF Library Manager dialog box before you reload the debugged version of your library.

Another common error occurs when you try to read a case file that was saved with a shared library, and that shared library has subsequently been moved to another location. In this case, the following error will be reported to the console (and log file) on a Linux machine:

 Opening library "path/libudf"...
 Error: No such file or directory:
 path/libudf/lnamd64/3d_node/libudf.so  

Similarly, you will get an error message when you try to load a shared library before it has been built.

 Error: UDF library "libudf" not available at path 

For more information, see the following section:


Note:  If you have a source file that contains DOS-style line endings, before you can compile the source file in Ansys Fluent on Linux, you must first run the dos2unix utility (for example, dos2unix filename.c) in the command line in order to make the source file compatible with the Ansys Fluent Linux compiler.


5.6.1. Windows Distributed Parallel

If you are trying to load a compiled UDF while running Ansys Fluent in distributed parallel, you may receive this error:

 Error: open_udf_library: The system cannot find the path specified 

This error occurs because the other computer(s) on the cluster cannot "see" the UDF through the network. To remedy this, you must:

  1. Modify the environment variables on the computer where the compiled UDF, case, and data files reside

  2. Share the folder where the files reside. See Compiling a UDF Using the GUI for details on file sharing or contact Ansys Fluent installation support for additional assistance.

There are instances when Ansys Fluent can hang when trying to read a compiled UDF using network parallel as a result of a network communicator problem. Contact Ansys Fluent installation support for details.

You may receive an error message when you invoke the command nmake or scons if you have the wrong compiler installed or if you have not launched the compiler command prompt window prior to building the UDF. See Compilers and Compiling a UDF Using the GUI for details or contact Ansys Fluent installation support for further assistance.