Fortran Coder

查看: 9697|回复: 5
打印 上一主题 下一主题

[混编] matlab调用fortran后崩溃,不知道程序出现什么问题

[复制链接]

3

帖子

1

主题

0

精华

新人

F 币
27 元
贡献
12 点
跳转到指定楼层
楼主
发表于 2018-1-5 09:56:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神指教
在用mex方法成功生成调用文件之后,使用matlab调用mex文件结果计算崩溃,不知道是什么原因。贴一下我的程序:
! 油膜求解测试程序1——线接触弹性变形方程
[Fortran] 纯文本查看 复制代码
    subroutine mexFunction(nlhs, plhs, nrhs, prhs)
     implicit none
      Integer nlhs, nrhs
      Integer plhs(*), prhs(*)
      Integer mxIsNumeric,mxGetM, mxGetN
      Integer mxCreateDoubleMatrix,mxGetPr
      Integer N_pr, V_pr
      Integer m1,n1,size
      real*8 N,V(1000)
      m1=mxGetM(prhs(1))
      n1=mxGetN(prhs(1))
      size=m1*n1
      N_pr=mxGetPr(prhs(1))
      call mxCopyPtrToReal8(N_pr,N,1)
      call LINE(N,V)
      plhs(1)=mxCreateDoubleMatrix(1,100,0)
      V_pr=mxGetPr(plhs(1))  
      call mxCopyReal8ToPtr(V,V_pr,100)
      return
      end
    !SUBROUTINE LINE(N,V,m2,n2)
    SUBROUTINE LINE(N,V)
    !integer m2,n2
    DIMENSION P(1000),H0(1000),H(1000),V(1000),X(1000)

        X1=1.4
        X0=-4.0
        DX=(X1-X0)/(N-1.0)
        DO I=1,N
        X(I)=-4.0+(I-1)*DX
        H0(I)=0.5*X(I)*X(I)
        H(I)=H0(I)
        P(I)=0.0
        IF(X(I).GE.-1.0.AND.X(I).LE.1.0)THEN
        P(I)=SQRT(1-X(I)*X(I))
        ENDIF
        ENDDO
        CALL SUBAK(N)
        CALL VI(N,DX,P,V)
        DO I=1,N
        H(I)=H(I)+V(I)

        ENDDO
        STOP
        END
        SUBROUTINE VI(N,DX,P,V)
        DIMENSION P(N),V(N)
        COMMON /COMAK/AK(0:1100)
        PAI1=0.318309886
        C=ALOG(DX)
        DO 10 I=1,N
        V(I)=0.0
        DO 10 J=1,N
        IJ=IABS(I-J)
10        V(I)=V(I)+(AK(IJ)+C)*DX*P(J)
        DO I=1,N
        V(I)=-PAI1*V(I)
        ENDDO
        RETURN
        END
        SUBROUTINE SUBAK(MM)
        COMMON /COMAK/AK(0:1100)
        DO 10 I=0,MM
10      AK(I)=(I+0.5)*(ALOG(ABS(I+0.5))-1.)-(I-0.5)*(ALOG(ABS(I-0.5))-1.)
        RETURN
        END

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

798

帖子

2

主题

0

精华

大宗师

F 币
3793 元
贡献
2268 点
沙发
发表于 2018-1-6 17:31:38 | 只看该作者
给出出错的提示。

3

帖子

1

主题

0

精华

新人

F 币
27 元
贡献
12 点
板凳
 楼主| 发表于 2018-1-7 10:56:24 | 只看该作者
li913 发表于 2018-1-6 17:31
给出出错的提示。

这个是出错后的信息

MATLAB crash file:C:\Users\ADMINI~1\AppData\Local\Temp\matlab_crash_dump.7508-1:


------------------------------------------------------------------------
          Access violation detected at Wed Dec 27 13:43:57 2017
------------------------------------------------------------------------

Configuration:
  Crash Decoding     : Disabled
  Default Encoding   : GBK
  MATLAB Architecture: win64
  MATLAB Root        : D:\matlab2014a
  MATLAB Version     : 8.3.0.532 (R2014a)
  Operating System   : Microsoft Windows 7 旗舰版
  Processor ID       : x86 Family 6 Model 58 Stepping 9, GenuineIntel
  Virtual Machine    : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  Window System      : Version 6.1 (Build 7601: Service Pack 1)

Fault Count: 1


Abnormal termination:
Access violation

Register State (from fault):
  RAX = 0000000000000008  RBX = 0000000000000000
  RCX = 0000000004029f40  RDX = 6f9ffec06c1f7fa0
  RSP = 0000000004029ec8  RBP = 000000000402b060
  RSI = 000000000402b060  RDI = 000000000402af40

   R8 = 0000000000000008   R9 = 0000000000000001
  R10 = 0000000000000001  R11 = 0000000004029f40
  R12 = 000007fef8460000  R13 = 00000000706c92a0
  R14 = 0000000000000001  R15 = 000000000402b060

  RIP = 000000007928bfbf  EFL = 00010202

   CS = 0033   FS = 0053   GS = 002b

Stack Trace (from fault):
[  0] 0x000000007928bfbf              D:\matlab2014a\bin\win64\MSVCR100.dll+00245695 memmove+00000095
[  1] 0x000007fef84610a5                                     F:\LINE.mexw64+00004261 MEXFUNCTION+00000165
[  2] 0x00000000fc5ef700                D:\matlab2014a\bin\win64\libmex.dll+00063232 mexRunMexFile+00000112
[  3] 0x00000000fc5ee1e2                D:\matlab2014a\bin\win64\libmex.dll+00057826 inSwapMexfileReader+00000226
[  4] 0x00000000fc5ef294                D:\matlab2014a\bin\win64\libmex.dll+00062100 _constructor_lm_mexmaci64+00001620
[  5] 0x000000000580be4f          D:\matlab2014a\bin\win64\m_dispatcher.dll+00048719 Mfh_file::dispatch_fh+00000687
[  6] 0x000000000580c77a          D:\matlab2014a\bin\win64\m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[  7] 0x0000000005985e04         D:\matlab2014a\bin\win64\m_interpreter.dll+00744964 MathWorks::MException::MExceptionEnvelope::GetID+00539764
[  8] 0x0000000005970782         D:\matlab2014a\bin\win64\m_interpreter.dll+00657282 MathWorks::MException::MExceptionEnvelope::GetID+00452082
[  9] 0x0000000005963f6f         D:\matlab2014a\bin\win64\m_interpreter.dll+00606063 MathWorks::MException::MExceptionEnvelope::GetID+00400863
[ 10] 0x000000000594cd43         D:\matlab2014a\bin\win64\m_interpreter.dll+00511299 MathWorks::MException::MExceptionEnvelope::GetID+00306099
[ 11] 0x000000000595644f         D:\matlab2014a\bin\win64\m_interpreter.dll+00549967 MathWorks::MException::MExceptionEnvelope::GetID+00344767
[ 12] 0x0000000005964962         D:\matlab2014a\bin\win64\m_interpreter.dll+00608610 MathWorks::MException::MExceptionEnvelope::GetID+00403410
[ 13] 0x000000000596192c         D:\matlab2014a\bin\win64\m_interpreter.dll+00596268 MathWorks::MException::MExceptionEnvelope::GetID+00391068
[ 14] 0x00000000059711c9         D:\matlab2014a\bin\win64\m_interpreter.dll+00659913 MathWorks::MException::MExceptionEnvelope::GetID+00454713
[ 15] 0x000000000580c00e          D:\matlab2014a\bin\win64\m_dispatcher.dll+00049166 Mfh_file::dispatch_fh+00001134
[ 16] 0x000000000580c77a          D:\matlab2014a\bin\win64\m_dispatcher.dll+00051066 Mfunction_handle::dispatch+00000810
[ 17] 0x00000000059e4a0e         D:\matlab2014a\bin\win64\m_interpreter.dll+01133070 inValidateLoadedObject+00003486
[ 18] 0x00000000059ebd95         D:\matlab2014a\bin\win64\m_interpreter.dll+01162645 inResetInterpreter+00005029
[ 19] 0x00000000059f0a05         D:\matlab2014a\bin\win64\m_interpreter.dll+01182213 MathWorks::MException::MExceptionEnvelope::Copy+00010997
[ 20] 0x00000000059f09d2         D:\matlab2014a\bin\win64\m_interpreter.dll+01182162 MathWorks::MException::MExceptionEnvelope::Copy+00010946
[ 21] 0x00000000059f0997         D:\matlab2014a\bin\win64\m_interpreter.dll+01182103 MathWorks::MException::MExceptionEnvelope::Copy+00010887
[ 22] 0x0000000005dde89c         D:\matlab2014a\bin\win64\m_interpreter.dll+05302428 inMexPutVariable+00004204
[ 23] 0x0000000005ddebf6         D:\matlab2014a\bin\win64\m_interpreter.dll+05303286 inMexPutVariable+00005062
[ 24] 0x0000000005ddf02e         D:\matlab2014a\bin\win64\m_interpreter.dll+05304366 inMexPutVariable+00006142
[ 25] 0x0000000005ddf36c         D:\matlab2014a\bin\win64\m_interpreter.dll+05305196 inMexPutVariable+00006972
[ 26] 0x0000000005cf0161         D:\matlab2014a\bin\win64\m_interpreter.dll+04325729 inEvalCmdWithLocalReturn+00000065
[ 27] 0x000000000634becd           D:\matlab2014a\bin\win64\libmwbridge.dll+00048845 mnDebugPrompt+00000109
[ 28] 0x000000000634cfaf           D:\matlab2014a\bin\win64\libmwbridge.dll+00053167 mnParser+00000735
[ 29] 0x00000000fd0afae4                   D:\matlab2014a\bin\win64\mcr.dll+00195300 mcrInstance::mnParser_on_interpreter_thread+00000036
[ 30] 0x00000000fd093af0                   D:\matlab2014a\bin\win64\mcr.dll+00080624 mcr::runtime::setInterpreterThreadToCurrent+00029488
[ 31] 0x00000000fd093b50                   D:\matlab2014a\bin\win64\mcr.dll+00080720 mcr::runtime::setInterpreterThreadToCurrent+00029584
[ 32] 0x00000000fab6e026                   D:\matlab2014a\bin\win64\uiw.dll+00581670 UIW_IsUserMessage+00000086
[ 33] 0x00000000fab6e705                   D:\matlab2014a\bin\win64\uiw.dll+00583429 UIW_SetGLIMUserMsg+00000117
[ 34] 0x00000000fab6e789                   D:\matlab2014a\bin\win64\uiw.dll+00583561 UIW_SetGLIMUserMsg+00000249
[ 35] 0x00000000775287b2                     C:\Windows\system32\USER32.dll+00165810 GetMenuBarInfo+00000626
[ 36] 0x000000007750f587                     C:\Windows\system32\USER32.dll+00062855 SystemParametersInfoW+00000247
[ 37] 0x0000000077514815                     C:\Windows\system32\USER32.dll+00083989 IsProcessDPIAware+00000453
[ 38] 0x000000000407b4f6                                   <unknown-module>+00000000
[ 39] 0x000000000402f2c8                                   <unknown-module>+00000000


This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

If this problem is reproducible, please submit a Service Request via:
    http://www.mathworks.com/support/contact_us/

A technical support engineer might contact you with further information.

Thank you for your help.

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

地板
发表于 2018-1-7 15:07:54 | 只看该作者
为啥不能用matlab改写呢?
考虑版权的问题,可以用pcode加密核心部分的matlab代码

3

帖子

1

主题

0

精华

新人

F 币
27 元
贡献
12 点
5#
 楼主| 发表于 2018-1-8 16:30:37 | 只看该作者
pasuka 发表于 2018-1-7 15:07
为啥不能用matlab改写呢?
考虑版权的问题,可以用pcode加密核心部分的matlab代码 ...

这是一个测试程序,想用这个改一下尝试matlab调用,我需要用到的程序挺麻烦的。可是不知道用这种方式调用出现什么问题

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

6#
发表于 2018-1-8 17:47:27 | 只看该作者
zhangchunyu312 发表于 2018-1-8 16:30
这是一个测试程序,想用这个改一下尝试matlab调用,我需要用到的程序挺麻烦的。可是不知道用这种方式调用 ...

个人建议:
1、电子邮件咨询原作者
2、使用相同的操作系统、matlab以及Fortran编译器版本
3、调试软件自带的测试算例
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

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

GMT+8, 2024-4-30 12:47

Powered by Tencent X3.4

© 2013-2024 Tencent

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