如何在UDF中调用fortran子程序(整理网上资料)

2025-03-11 08:16:08
推荐回答(1个)
回答1:

下面有些路径是根据我自己的程序安装路径。 1)set environment variables for Fluent, C++, Fortran;//设置FLUENT,c++,Fortran的环境变量; 2)put sorce code file into ..\src folder, put compiled fortran .obj files into ..\ntx86\2d folder, copy sed.exe, user_nt.udf and makefile_nt.udf to the same folder as compiled fortran .obj files; (this two folders are created by yourself, you can put them under your case folder). 将源文件代码放入\src文件夹下,将编译之后的fortran的.obj文件放在路径为···\ntx86\2d的文件夹下,复制文件sed.exe,user_nt.udf和makefile_nt.udf文件到路径为···\ntx86\2d的文件夹下(这两个是自己创建的,你可以放它们在你的case文件夹下)。 3)modify user_nt.udf file {follow the instructions. e.g. USER_OBJECTS = test.obj this obj file is the complied fortran .obj file ,SOURCES = $(SRC)test_use.c(c source file that is in the \src fold), VERSION = 2d(your model dimension), PARALLEL_NODE = none; 按下面的方法修改user_nt.udf文件: USER_OBJECTS = test.obj // test是你编译之后的fortran程序文件名; SOURCES = $(SRC)test_use.c(text_use.c是你放入\src文件下的c程序的源码文件) ; VERSION = 2d //为你模型的维数。 PARALLEL_NODE = none; //是否并行计算,一般选择不并行计算。 4)change the name of file makefile_nt.udf tomakefile , modify makefile, (add this line "FLUENT_INC= D:\Fluent.Inc" below "UDFDATA = udf_names.c"; 改变makefile_nt.udf的文件名为:makefile;并且添加在UDFDATA = udf_names.c这行后面添加FLUENT_INC= D:\Fluent.Inc; * 5)You might need to copy all the .lib files under Fortran\lib fold to folder D:\Fluent.Inc\fluent6.3.26\ntx86\Fortran_lib (this folder is created by myself) change this line "LIBS = /Libpath:$(FLUENT_INC)\fluent$(RELEASE)\$(FLUENT_ARCH) \$(VERSION)" in the makefile file to "LIBS = /Libpath:$(FLUENT_INC)\fluent$(RELEASE)\$(FLUENT_ARCH)\$(VERSION) D:\Fluent.Inc\fluent6.3.26\ntx86\Fortran_lib\*.lib" 你需要复制fortran的库文件到fluent的安装文件D:\Fluent.Inc\fluent6.3.26\ntx86\Fortran_lib(其中Fortran_lib为自己创建的文件名);并且改变makefile文件中的行LIBS = /Libpath:$(FLUENT_INC)\fluent$(RELEASE)\$(FLUENT_ARCH) \$(VERSION)为LIBS = /Libpath:$(FLUENT_INC)\fluent$(RELEASE)\$(FLUENT_ARCH)\$(VERSION) 6)Type "nmake" in the command line console, make sure the console is displaying the right path that is including your files such as: "makefile",".obj","sed.exe". 在编译之后,确保在fluent的界面中出现,文件"makefile",".obj","sed.exe".的正确路径。 7)Put the generated .dll file with your .cas and .data files together. 连接你的dll文件和你的case文件和date文件一起。