Fortran Coder

matlab与fortran混合编程mex文件编译

查看数: 7266 | 评论数: 8 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2018-8-9 14:38

正文摘要:

在vs2013中编译用于Matlab调用的mex文件,出现以下错误,是什么原因呢?代码格式基本是按标准mex框架写的 错误        2         error #5082: Syntax error, fo ...

回复

MrLIN 发表于 2018-8-10 21:01:09
fcode 发表于 2018-8-10 10:29
第一个错误是 #Bad preprocessor line
这说明你需要开启 预处理。
项目(工程,Project)菜单,属性,Fortr ...

嗯嗯,谢谢您!少了很多错误,还剩下点我再调调
fcode 发表于 2018-8-10 10:29:25
第一个错误是 #Bad preprocessor line
这说明你需要开启 预处理。
项目(工程,Project)菜单,属性,Fortran(展开),Preprocessor,Preprocessor Source File,Yes
fcode 发表于 2018-8-9 21:56:38
输出窗口提示请给更多一些。

注意 <fintrf.h> 文件是什么格式?如果是自由格式,则源代码也要是自由格式。如果是固定格式,则源代码也要是固定格式。
MrLIN 发表于 2018-8-9 14:59:14
fcode 发表于 2018-8-9 14:47
请给出必要的代码。
“输出窗口”的内容,复制粘贴。(不要看“错误列表”窗口) ...

提示错误的代码区域如下:
#include <fintrf.h>
C
C
C This subroutine is the main gateway to MATLAB.  When a MEX function
C  is executed MATLAB calls the MEXFUNCTION subroutine in the corresponding
C  MEX file.  
C
C
C     Gateway routine
      subroutine mexFunction(nlhs, plhs, nrhs, prhs)
      
C     Declarations
      implicit none
      
C-----------------------------------------------------------------------
C     mexFunction arguments:
      mwPointer plhs(*), prhs(*)
      integer nlhs, nrhs
      
C-----------------------------------------------------------------------
C     Function declarations:
      mwPointer mxGetPr
      mwPointer mxCreateDoubleMatrix
      integer mxIsNumeric
      mwPointer mxGetM, mxGetN
      
C-----------------------------------------------------------------------      
C     Pointers to input/output mxArrays:
      mwPointer x_ptr_LLH, x_ptr_YMDH, y_ptr

C-----------------------------------------------------------------------
C     Array information:
      mwPointer mrows1, ncols1,  mrows2, ncols2
      mwSize size1, size2

C-----------------------------------------------------------------------
C     Arguments for computational routine:
      integer*4  x_input_YMDH  !TIME
      real*8  x_input_LLH, y_output  !LATITUDE  LONGITUDE  HEIGHT   OTUPUT
C-----------------------------------------------------------------------
C     Get the size of the input array.
      mrows1 = mxGetM(prhs(1))
      ncols1 = mxGetN(prhs(1))
      size1 = mrows1*ncols1
      
      mrows2 = mxGetM(prhs(2))
      ncols2 = mxGetN(prhs(2))
      size2 = mrows2*ncols2

C     Create Fortran array from the input argument.
      x_ptr_LLH = mxGetPr(prhs(1))
      call mxCopyPtrToReal8(x_ptr_LLH,x_input_LLH,size1)
      x_ptr_YMDH = mxGetPr(prhs(2))
      call mxCopyPtrToInteger4(x_ptr_YMDH,x_input_YMDH,size2)
      
C     Create matrix for the return argument.
      plhs(1) = mxCreateDoubleMatrix(1,20,0)
      y_ptr = mxGetPr(plhs(1))
      
C     Call the computational subroutine.
      call Ionosphere(y_output, x_input_LLH, x_input_YMDH)

C     Load the data into y_ptr, which is the output to MATLAB.
      call mxCopyReal8ToPtr(y_output,y_ptr,20)     

      return
      end
计算子程序名称为:
C-----------------------------------------------------------------------
C     Computational routine

      subroutine Ionosphere(y_output, x_input_LLH, x_input_YMDH)

输出窗口重要提示为:
remark #8290: Recommended relationship between field width 'W' and the number of fractional digits 'D' in this edit descriptor is 'W>=D+3'.
fcode 发表于 2018-8-9 14:47:14
请给出必要的代码。
“输出窗口”的内容,复制粘贴。(不要看“错误列表”窗口)

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-30 08:11

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表