文档详情

Adams2013编译C语言用户子程序生成dll超详细教程.doc

发布:2017-05-20约2.18千字共8页下载文档
文本预览下载声明
1.操作系统:Windows xp 32位 2.软件版本:Adams 2013 32位、Visual Studio 2010专业版 32位 3.编译软件:Intel Visual Fortran 11.0 4.环境配置: 1) 在操作系统环境变量Path中增加Adams启动文件mdi.bat的路径,如D:\MSC.Software\Adams\2013\common\mdi.bat 2) 把Fortran安装路径,如 D:\IVF2011\Intel\ComposerXE-2011\compiler\lib\ia32 把libifcoremd.liblibifcoremd.lib、libmmd.lib、libifportmd.lib、libirc.lib、svml_dispmd.lib这个库文件复制到Adams安装路径下win32文件夹下 5.编写用户子程序 Adams安装程序D:\MSC.Software\Adams\2013\solver\c_usersubs文件夹下有C语言编写的常用的用户子程序,其中slv_c_utils.h文件是用户子程序的头文件。编写用户子程序时,在这些程序的基础上进行更改会有事半功倍的效果。 本文以编写VForce用户子程序为例,对其编写、编译操作过程进行说明。 复制vfosub.c和slv_c_utils.h两个文件到个人工作文件夹本文直接使用vfosub.c的原始代码,其代码为: #include slv_c_utils.h adams_c_Vfosub Vfosub; /* * Note: * Use mixed case names for the Adams subroutine names when using the C * style interface. For the default subroutine name capitalize the first * letter and have the remaining letters lower case; Gfosub for example. * Doing this insures that Adams Solver correctly distinguishes a C style * subroutine from Fortran and calls with the appropriate interface. * */ void Vfosub(const struct sAdamsVforce* vfo, double time, int dflag, int iflag, double* result) { /* Assign readable variable names to passed parameters */ double c=vfo-PAR[0]; int ipar[3]={(int)vfo-PAR[1], (int)vfo-PAR[2],(int)vfo-PAR[1]}; /* Local variables */ double vel[3]; int nstates; int errflg; /* call SYSARY for translation velocities TVEL */ c_sysary(TVEL, ipar, 3, vel, nstates, errflg); c_errmes(errflg, Error calling SYSARY for TVEL, vfo-ID, STOP); /* --- Evaluate VFORCE components ------------------------- */ result[0] = -c * vel[0]; result[2] = -c * vel[1]; result[2] = -c * vel[2]; } 注意:因为代码中引用了slv_c_utils.h,复制时必须同时复制slv_c_utils.h文件,否则编译时会报错。 6.编译操作 在开始菜单下,启动Visual Studio 20命令提示工具。 把工作路径设置到用户子程序文件所在路径D:输入指令cd D:\Adams_Matlab并按回车。 (3) 输入D:\MSC.Software\Adams\2013\common\mdi.bat并按回车, 系统进入Adams环境中 输入cr-u, 进入编译子程序,这时系统提示是否在调试状态下连接,直接输入回车。 输入C语言用户子程序的文件名vfosub.c并回车注意:该文件必须是以.c为后缀名,不能以.cp
显示全部
相似文档