You are on page 1of 2

How to compile FORTRAN file as UDF? ehsanfaghani.com This document is based on ANSYS-FLUENT 12.1 and windows 7 64. 1.

Install Microsoft Visual C++ 2010 Express It is free software and you can download from Microsoft website. Recommended to be installed prior to ANSYS-FLEUNT. Install all parts during the installation process (automatically will be done but doubleckeck). Note: some versions of visual C++ may not work for this purpose. New versions are better if it matches with other parts. 2. Install Microsoft Windows SDK 7.1 It is also free software and you can download from Microsoft website. Installation will automatically install all sub-softwares. 3. Install ANSYS-FLUENT After inserting CD, neglect Autorun, right click on CD and open and run setup.exe as administrator. Neglect prerequisite softwares (if you do that it will install c++ 2005 which do not work with other parts) Note: after installation check if all parts of the software works, check Ansys workbench and under that geometry (design modeler). If it does not work you need to install prerequisite softwares, you can either install prerequisite software later, install all prerequisite softwares by Ansys and then uninstall c++ and related parts (important to uninstall all parts) or you can find which software you need and download it separately. 4. Set environment variables You need to set environment variables for both visual c++ and Fluent. Run SDK command prompt (under SDK software in all programs) and go to C:\Program Files\ANSYS Inc\v121\fluent\ntbin\win64 (use DOS command cd, cd.., etc )run setenv by typing setenv.exe Go to set environment variables(right click on computer screen ..propertiesadvanced system setting environmental variables) and add more options to your path (user variable not system variable): C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin 5. Interpret UDF Make sure your UDF is working fine (no structural error), open fluent/define/ user-defined function/interpreted.

UDF could be even in text files the format of file is not important here. 6. Compile UDF Run fluent from SDK command prompt (in command prompt go to where Fluent case in located and type fluent e.g. c:\users\ehsan\desktop>fleunt). Note: Check if setup compilation environment for UDF under udf compiler is checked and browser is pointing udf.bat. Open fluent and then open your case. Go to define\user-defined function\compiles and add udf to your source (here udf should be .c file e.g. test.c) Note: udf file should not have space e.g gas nozzle.c should be gas_nozzle.c or simply make a single word. Build your file and load it. You can see a folder libudf is created in your directory. 7. Set a working directory See Fleunt manual for making directories. Note: directory notes should not have space in its name e.g. not working directory use working_directory. 8. Copy udf files Copy udf files from fluent directory to working directory and modify it according to fleunt manual. Copy make_nt.udf in the same folder and change the name to makefile

9. Build library In SDK command prompt go to each version e.g. 2d and type nmake. See manual Open fluent from command prompt and go to define\user-defined function\manage and add libudf to your library (it will add libudf which is made in working directory) 10. Compiled objects Using notepad or WordPad edit use_nt.udf, last line according to instruction written in the file. Copy compiled objects like FORTRAN files to each version of fluent in win64 folder and you can add library similar to step 9.

You might also like