matlab与fortran混合编程mex文件编译
在vs2013中编译用于Matlab调用的mex文件,出现以下错误,是什么原因呢?代码格式基本是按标准mex框架写的错误 2 error #5082: Syntax error, found ',' when expecting one of: ( % [ . = =>
错误 5 error #5082: Syntax error, found ',' when expecting one of: ( % [ : . = =>
错误 6 error #5082: Syntax error, found ',' when expecting one of: ( % [ : . = =>
错误 7 error #5082: Syntax error, found ',' when expecting one of: ( % [ : . = =>
错误 8 error #5082: Syntax error, found ',' when expecting one of: ( % [ : . = =>
错误 3 error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( % [ : . = =>
错误 4 error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( % [ : . = =>
错误 9 error #6218: This statement is positioned incorrectly and/or has syntax errors.
错误 12 error #6236: A specification statement cannot appear in the executable section.
错误 13 error #6236: A specification statement cannot appear in the executable section.
错误 14 error #6236: A specification statement cannot appear in the executable section.
错误 15 error #6236: A specification statement cannot appear in the executable section.
错误 20 error #6404: This name does not have a type, and must have an explicit type.
错误 24 error #6404: This name does not have a type, and must have an explicit type.
错误 16 error #6404: This name does not have a type, and must have an explicit type.
错误 10 error #6404: This name does not have a type, and must have an explicit type.
错误 18 error #6404: This name does not have a type, and must have an explicit type.
错误 21 error #6404: This name does not have a type, and must have an explicit type.
错误 17 error #6404: This name does not have a type, and must have an explicit type.
错误 27 error #6404: This name does not have a type, and must have an explicit type.
错误 22 error #6404: This name does not have a type, and must have an explicit type.
错误 25 error #6404: This name does not have a type, and must have an explicit type.
错误 11 error #6404: This name does not have a type, and must have an explicit type.
错误 23 error #6404: This name does not have a type, and must have an explicit type.
错误 19 error #6404: This name does not have a type, and must have an explicit type.
错误 28 error #6404: This name does not have a type, and must have an explicit type.
错误 30 error #6404: This name does not have a type, and must have an explicit type.
错误 26 error #6404: This name does not have a type, and must have an explicit type.
错误 29 error #6404: This name does not have a type, and must have an explicit type.
错误 31 error #6410: This name has not been declared as an array or a function.
警告 1 warning #5117: Bad # preprocessor line
错误 32 Compilation Aborted (code 1)
请给出必要的代码。
“输出窗口”的内容,复制粘贴。(不要看“错误列表”窗口) fcode 发表于 2018-8-9 14:47
请给出必要的代码。
“输出窗口”的内容,复制粘贴。(不要看“错误列表”窗口) ...
提示错误的代码区域如下:
#include <fintrf.h>
C
C
C This subroutine is the main gateway to MATLAB.When a MEX function
Cis executed MATLAB calls the MEXFUNCTION subroutine in the corresponding
CMEX 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*4x_input_YMDH!TIME
real*8x_input_LLH, y_output!LATITUDELONGITUDEHEIGHT 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'. 输出窗口提示请给更多一些。
注意 <fintrf.h> 文件是什么格式?如果是自由格式,则源代码也要是自由格式。如果是固定格式,则源代码也要是固定格式。 fcode 发表于 2018-8-9 21:56
输出窗口提示请给更多一些。
注意文件是什么格式?如果是自由格式,则源代码也要是自由格式。如果是固定 ...
我不是特别清楚自由格式是咋回事。。就是把matlab里的文件复制到工程里。。
输出窗口显示如图:
假如我格式对的,在matlab里编译mex文件是不是就可以了?我试了一下,但还是提示错误太多。。
第一个错误是 #Bad preprocessor line
这说明你需要开启 预处理。
项目(工程,Project)菜单,属性,Fortran(展开),Preprocessor,Preprocessor Source File,Yes
fcode 发表于 2018-8-10 10:29
第一个错误是 #Bad preprocessor line
这说明你需要开启 预处理。
项目(工程,Project)菜单,属性,Fortr ...
嗯嗯,谢谢您!少了很多错误,还剩下点我再调调 fcode 发表于 2018-8-10 10:29
第一个错误是 #Bad preprocessor line
这说明你需要开启 预处理。
项目(工程,Project)菜单,属性,Fortr ...
您好,我在matlab中编译mex文件时出现以下错误,其中READ_IG_RZ、 READAPF107、IRI_WEB是我计算子程序中调用的子函数
fcode 发表于 2018-8-10 10:29
第一个错误是 #Bad preprocessor line
这说明你需要开启 预处理。
项目(工程,Project)菜单,属性,Fortr ...
如果在VS中编译,提示的错误如下:
页:
[1]